]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewactionhandler.h
Factorize all the view-related action handling to DolphinViewActionHandler, to remove...
[dolphin.git] / src / dolphinviewactionhandler.h
1 /***************************************************************************
2 * Copyright (C) 2008 by David Faure <faure@kde.org> *
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
21 #ifndef DOLPHINVIEWACTIONHANDLER_H
22 #define DOLPHINVIEWACTIONHANDLER_H
23
24 #include "libdolphin_export.h"
25 #include <QtCore/QObject>
26 class QAction;
27 class QActionGroup;
28 class DolphinView;
29 class KActionCollection;
30
31 /**
32 * @short Handles all actions for DolphinView
33 *
34 * The action handler owns all the actions and slots related to DolphinView,
35 * but can the view that is acts upon can be switched to another one
36 * (this is used in the case of split views).
37 *
38 * The purpose of this class is also to share this code between DolphinMainWindow
39 * and DolphinPart.
40 *
41 * @see DolphinView
42 * @see DolphinMainWindow
43 * @see DolphinPart
44 */
45 class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject
46 {
47 Q_OBJECT
48
49 public:
50 explicit DolphinViewActionHandler(KActionCollection* collection, QObject* parent);
51
52 /**
53 * Sets the view that this action handler should work on.
54 */
55 void setCurrentView(DolphinView* view);
56
57 /**
58 * Update all actions in the 'View' menu, i.e. those that depend on the
59 * settings in the current view.
60 */
61 void updateViewActions();
62
63 Q_SIGNALS:
64 /**
65 * Emitted by DolphinViewActionHandler when the user triggered an action.
66 * This is only used for clearining the statusbar in DolphinMainWindow.
67 */
68 void actionBeingHandled();
69
70 private Q_SLOTS:
71 /**
72 * Opens the dialog for creating a directory. Is connected
73 * with the key shortcut for "new directory" (F10).
74 */
75 void slotCreateDir();
76
77 /**
78 * Let the user input a name for the selected item(s) and trigger
79 * a renaming afterwards.
80 */
81 void slotRename();
82
83 /**
84 * Moves the selected items of the active view to the trash.
85 * This methods adds "shift means del" handling.
86 */
87 void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
88
89 /**
90 * Deletes the selected items of the active view.
91 */
92 void slotDeleteItems();
93
94 /**
95 * Switches between showing a preview of the file content and showing the icon.
96 */
97 void togglePreview(bool);
98
99 /** Updates the state of the 'Show preview' menu action. */
100 void slotShowPreviewChanged();
101
102 /** Increases the size of the current set view mode. */
103 void zoomIn();
104
105 /** Decreases the size of the current set view mode. */
106 void zoomOut();
107
108 /** Switches between an ascending and descending sorting order. */
109 void toggleSortOrder();
110
111 /**
112 * Updates the state of the 'Sort Ascending/Descending' action.
113 */
114 void slotSortOrderChanged(Qt::SortOrder order);
115
116 /**
117 * Switches on or off the displaying of additional information
118 * as specified by \a action.
119 */
120 void toggleAdditionalInfo(QAction* action);
121
122 /**
123 * Updates the state of the 'Additional Information' actions.
124 */
125 void slotAdditionalInfoChanged();
126
127 /**
128 * Switches between sorting by categories or not.
129 */
130 void toggleSortCategorization(bool);
131
132 /**
133 * Updates the state of the 'Categorized sorting' menu action.
134 */
135 void slotCategorizedSortingChanged();
136
137 /**
138 * Switches between showing and hiding of hidden marked files
139 */
140 void toggleShowHiddenFiles(bool);
141
142 /**
143 * Updates the state of the 'Show hidden files' menu action.
144 */
145 void slotShowHiddenFilesChanged();
146
147 private:
148 /**
149 * Create all the actions.
150 * This is called only once (by the constructor)
151 */
152 void createActions();
153 /**
154 * Creates an action group with all the "show additional information" actions in it.
155 * Helper method for createActions();
156 */
157 QActionGroup* createAdditionalInformationActionGroup();
158
159 KActionCollection* m_actionCollection;
160 DolphinView* m_currentView;
161 };
162
163
164 #endif /* DOLPHINVIEWACTIONHANDLER_H */
165