]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewactionhandler.h
Let the user choose if folders are always shown first in the views of
[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 "dolphinview.h"
25 #include "libdolphin_export.h"
26 #include <QtCore/QObject>
27 class KToggleAction;
28 class QAction;
29 class QActionGroup;
30 class DolphinView;
31 class KActionCollection;
32
33 /**
34 * @short Handles all actions for DolphinView
35 *
36 * The action handler owns all the actions and slots related to DolphinView,
37 * but can the view that is acts upon can be switched to another one
38 * (this is used in the case of split views).
39 *
40 * The purpose of this class is also to share this code between DolphinMainWindow
41 * and DolphinPart.
42 *
43 * @see DolphinView
44 * @see DolphinMainWindow
45 * @see DolphinPart
46 */
47 class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject
48 {
49 Q_OBJECT
50
51 public:
52 explicit DolphinViewActionHandler(KActionCollection* collection, QObject* parent);
53
54 /**
55 * Sets the view that this action handler should work on.
56 */
57 void setCurrentView(DolphinView* view);
58
59 /**
60 * Returns the view that this action handler should work on.
61 */
62 DolphinView* currentView();
63
64 /**
65 * Returns the name of the action for the current viewmode
66 */
67 QString currentViewModeActionName() const;
68
69 /**
70 * Returns m_actionCollection
71 */
72 KActionCollection* actionCollection();
73
74 public Q_SLOTS:
75 /**
76 * Update all actions in the 'View' menu, i.e. those that depend on the
77 * settings in the current view.
78 */
79 void updateViewActions();
80
81 Q_SIGNALS:
82 /**
83 * Emitted by DolphinViewActionHandler when the user triggered an action.
84 * This is only used for clearining the statusbar in DolphinMainWindow.
85 */
86 void actionBeingHandled();
87
88 /**
89 * Emitted if the user requested creating a new directory by the F10 key.
90 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
91 * the method createDirectory of their KNewMenu instance.
92 */
93 void createDirectory();
94
95 private Q_SLOTS:
96 /**
97 * Emitted when the user requested a change of view mode
98 */
99 void slotViewModeActionTriggered(QAction*);
100
101 /**
102 * Let the user input a name for the selected item(s) and trigger
103 * a renaming afterwards.
104 */
105 void slotRename();
106
107 /**
108 * Moves the selected items of the active view to the trash.
109 * This methods adds "shift means del" handling.
110 */
111 void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
112
113 /**
114 * Deletes the selected items of the active view.
115 */
116 void slotDeleteItems();
117
118 /**
119 * Switches between showing a preview of the file content and showing the icon.
120 */
121 void togglePreview(bool);
122
123 /** Updates the state of the 'Show preview' menu action. */
124 void slotShowPreviewChanged();
125
126 /** Increases the size of the current set view mode. */
127 void zoomIn();
128
129 /** Decreases the size of the current set view mode. */
130 void zoomOut();
131
132 /** Switches between an ascending and descending sorting order. */
133 void toggleSortOrder();
134
135 /** Switches between a separate sorting and a mixed sorting of files and folders. */
136 void toggleSortFoldersFirst();
137
138 /**
139 * Updates the state of the 'Sort Ascending/Descending' action.
140 */
141 void slotSortOrderChanged(Qt::SortOrder order);
142
143 /**
144 * Updates the state of the 'Sort Folders First' action.
145 */
146 void slotSortFoldersFirstChanged(bool foldersFirst);
147
148 /**
149 * Updates the state of the 'Sort by' actions.
150 */
151 void slotSortingChanged(DolphinView::Sorting sorting);
152
153 /**
154 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
155 */
156 void slotZoomLevelChanged(int level);
157
158 /**
159 * Switches on or off the displaying of additional information
160 * as specified by \a action.
161 */
162 void toggleAdditionalInfo(QAction* action);
163
164 /**
165 * Changes the sorting of the current view.
166 */
167 void slotSortTriggered(QAction*);
168
169 /**
170 * Updates the state of the 'Additional Information' actions.
171 */
172 void slotAdditionalInfoChanged();
173
174 /**
175 * Switches between sorting by categories or not.
176 */
177 void toggleSortCategorization(bool);
178
179 /**
180 * Updates the state of the 'Categorized sorting' menu action.
181 */
182 void slotCategorizedSortingChanged();
183
184 /**
185 * Switches between showing and hiding of hidden marked files
186 */
187 void toggleShowHiddenFiles(bool);
188
189 /**
190 * Updates the state of the 'Show hidden files' menu action.
191 */
192 void slotShowHiddenFilesChanged();
193
194 /**
195 * Opens the view properties dialog, which allows to modify the properties
196 * of the currently active view.
197 */
198 void slotAdjustViewProperties();
199
200 /**
201 * Opens the Find File dialog for the currently shown directory.
202 */
203 void slotFindFile();
204
205 /**
206 * Connected to the "properties" action.
207 * Opens the properties dialog for the selected items of the
208 * active view. The properties dialog shows information
209 * like name, size and permissions.
210 */
211 void slotProperties();
212
213 private:
214 /**
215 * Create all the actions.
216 * This is called only once (by the constructor)
217 */
218 void createActions();
219 /**
220 * Creates an action group with all the "show additional information" actions in it.
221 * Helper method for createActions();
222 */
223 QActionGroup* createAdditionalInformationActionGroup();
224
225 /**
226 * Creates an action group with all the "sort by" actions in it.
227 * Helper method for createActions();
228 */
229 QActionGroup* createSortByActionGroup();
230
231 /**
232 * Returns the "switch to icons mode" action.
233 * Helper method for createActions();
234 */
235 KToggleAction* iconsModeAction();
236
237 /**
238 * Returns the "switch to details mode" action.
239 * Helper method for createActions();
240 */
241 KToggleAction* detailsModeAction();
242
243 /**
244 * Returns the "switch to columns mode" action.
245 * Helper method for createActions();
246 */
247 KToggleAction* columnsModeAction();
248
249
250 KActionCollection* m_actionCollection;
251 DolphinView* m_currentView;
252 };
253
254 #endif /* DOLPHINVIEWACTIONHANDLER_H */