]> cloud.milkyroute.net Git - dolphin.git/blob - src/viewextensionsfactory.h
Cheat a bit with the root item: give it the view URL, rather than the dirlister url
[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 FolderExpander;
33 class QModelIndex;
34 class SelectionManager;
35 class ToolTipManager;
36 class QAbstractItemView;
37 class VersionControlObserver;
38
39 /**
40 * @brief Responsible for creating extensions like tooltips and previews
41 * that are available in all view implementations.
42 *
43 * Each view implementation (iconsview, detailsview, columnview) must
44 * instantiate an instance of this class to assure having
45 * a common behavior that is independent from the custom functionality of
46 * a view implementation.
47 */
48 class ViewExtensionsFactory : public QObject
49 {
50 Q_OBJECT
51
52 public:
53 explicit ViewExtensionsFactory(QAbstractItemView* view,
54 DolphinController* controller);
55 virtual ~ViewExtensionsFactory();
56
57 /**
58 * Must be invoked by the item view, when QAbstractItemView::currentChanged()
59 * has been called. Assures that the current item stays visible when it has been
60 * changed by the keyboard.
61 */
62 void handleCurrentIndexChange(const QModelIndex& current, const QModelIndex& previous);
63
64 DolphinFileItemDelegate* fileItemDelegate() const;
65
66 /**
67 * Enables the automatically expanding of a folder when dragging
68 * items above the folder.
69 */
70 void setAutoFolderExpandingEnabled(bool enabled);
71 bool autoFolderExpandingEnabled() const;
72
73 protected:
74 virtual bool eventFilter(QObject* watched, QEvent* event);
75
76 private slots:
77 void slotZoomLevelChanged();
78 void cancelPreviews();
79 void slotShowPreviewChanged();
80 void slotShowHiddenFilesChanged();
81 void slotSortingChanged(DolphinView::Sorting sorting);
82 void slotSortOrderChanged(Qt::SortOrder order);
83 void slotSortFoldersFirstChanged(bool foldersFirst);
84 void slotNameFilterChanged(const QString& nameFilter);
85 void slotRequestVersionControlActions(const KFileItemList& items);
86 void requestActivation();
87
88 private:
89 DolphinSortFilterProxyModel* proxyModel() const;
90
91 private:
92 QAbstractItemView* m_view;
93 DolphinController* m_controller;
94 ToolTipManager* m_toolTipManager;
95 KFilePreviewGenerator* m_previewGenerator;
96 SelectionManager* m_selectionManager;
97 DolphinViewAutoScroller* m_autoScroller;
98 DolphinFileItemDelegate* m_fileItemDelegate;
99 VersionControlObserver* m_versionControlObserver;
100 FolderExpander* m_folderExpander;
101 };
102
103 #endif
104