]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewactionhandler.h
BUG: 164489
[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 /**
136 * Updates the state of the 'Sort Ascending/Descending' action.
137 */
138 void slotSortOrderChanged(Qt::SortOrder order);
139
140 /**
141 * Updates the state of the 'Sort by' actions.
142 */
143 void slotSortingChanged(DolphinView::Sorting sorting);
144
145 /**
146 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
147 */
148 void slotZoomLevelChanged(int level);
149
150 /**
151 * Switches on or off the displaying of additional information
152 * as specified by \a action.
153 */
154 void toggleAdditionalInfo(QAction* action);
155
156 /**
157 * Changes the sorting of the current view.
158 */
159 void slotSortTriggered(QAction*);
160
161 /**
162 * Updates the state of the 'Additional Information' actions.
163 */
164 void slotAdditionalInfoChanged();
165
166 /**
167 * Switches between sorting by categories or not.
168 */
169 void toggleSortCategorization(bool);
170
171 /**
172 * Updates the state of the 'Categorized sorting' menu action.
173 */
174 void slotCategorizedSortingChanged();
175
176 /**
177 * Switches between showing and hiding of hidden marked files
178 */
179 void toggleShowHiddenFiles(bool);
180
181 /**
182 * Updates the state of the 'Show hidden files' menu action.
183 */
184 void slotShowHiddenFilesChanged();
185
186 /**
187 * Opens the view properties dialog, which allows to modify the properties
188 * of the currently active view.
189 */
190 void slotAdjustViewProperties();
191
192 /**
193 * Opens the Find File dialog for the currently shown directory.
194 */
195 void slotFindFile();
196
197 /**
198 * Connected to the "properties" action.
199 * Opens the properties dialog for the selected items of the
200 * active view. The properties dialog shows information
201 * like name, size and permissions.
202 */
203 void slotProperties();
204
205 private:
206 /**
207 * Create all the actions.
208 * This is called only once (by the constructor)
209 */
210 void createActions();
211 /**
212 * Creates an action group with all the "show additional information" actions in it.
213 * Helper method for createActions();
214 */
215 QActionGroup* createAdditionalInformationActionGroup();
216
217 /**
218 * Creates an action group with all the "sort by" actions in it.
219 * Helper method for createActions();
220 */
221 QActionGroup* createSortByActionGroup();
222
223 /**
224 * Returns the "switch to icons mode" action.
225 * Helper method for createActions();
226 */
227 KToggleAction* iconsModeAction();
228
229 /**
230 * Returns the "switch to details mode" action.
231 * Helper method for createActions();
232 */
233 KToggleAction* detailsModeAction();
234
235 /**
236 * Returns the "switch to columns mode" action.
237 * Helper method for createActions();
238 */
239 KToggleAction* columnsModeAction();
240
241
242 KActionCollection* m_actionCollection;
243 DolphinView* m_currentView;
244 };
245
246 #endif /* DOLPHINVIEWACTIONHANDLER_H */