]> cloud.milkyroute.net Git - dolphin.git/blob - src/viewextensionsfactory.h
restore sorting functionality in a generic way which also works for the column view
[dolphin.git] / src / viewextensionsfactory.h
1 /***************************************************************************
2 * Copyright (C) 2009 by Peter Penz <peter.penz@gmx.at> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
18 ***************************************************************************/
19
20 #ifndef VIEWEXTENSIONSFACTORY_H
21 #define VIEWEXTENSIONSFACTORY_H
22
23 #include <QObject>
24
25 #include "dolphinview.h"
26
27 class DolphinController;
28 class DolphinFileItemDelegate;
29 class DolphinSortFilterProxyModel;
30 class DolphinViewAutoScroller;
31 class KFilePreviewGenerator;
32 class QModelIndex;
33 class SelectionManager;
34 class ToolTipManager;
35 class QAbstractItemView;
36
37 /**
38 * @brief Responsible for creating extensions like tooltips and previews
39 * that are available in all view implementations.
40 *
41 * Each view implementation (iconsview, detailsview, columnview) must
42 * instantiate an instance of this class to assure having
43 * a common behavior that is independent from the custom functionality of
44 * a view implementation.
45 */
46 class ViewExtensionsFactory : public QObject
47 {
48 Q_OBJECT
49
50 public:
51 explicit ViewExtensionsFactory(QAbstractItemView* view,
52 DolphinController* controller);
53 virtual ~ViewExtensionsFactory();
54
55 /**
56 * Must be invoked by the item view, when QAbstractItemView::currentChanged()
57 * has been called. Assures that the current item stays visible when it has been
58 * changed by the keyboard.
59 */
60 void handleCurrentIndexChange(const QModelIndex& current, const QModelIndex& previous);
61
62 DolphinFileItemDelegate* fileItemDelegate() const;
63
64 protected:
65 virtual bool eventFilter(QObject* watched, QEvent* event);
66
67 private slots:
68 void slotZoomLevelChanged();
69 void cancelPreviews();
70 void slotShowPreviewChanged();
71 void slotShowHiddenFilesChanged();
72 void slotSortingChanged(DolphinView::Sorting sorting);
73 void slotSortOrderChanged(Qt::SortOrder order);
74 void slotSortFoldersFirstChanged(bool foldersFirst);
75 void requestActivation();
76
77 private:
78 DolphinSortFilterProxyModel* proxyModel() const;
79
80 private:
81 QAbstractItemView* m_view;
82 DolphinController* m_controller;
83 ToolTipManager* m_toolTipManager;
84 KFilePreviewGenerator* m_previewGenerator;
85 SelectionManager* m_selectionManager;
86 DolphinViewAutoScroller* m_autoScroller;
87 DolphinFileItemDelegate* m_fileItemDelegate;
88 };
89
90 #endif
91