]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewactionhandler.h
BUG: 175658
[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 private Q_SLOTS:
89 /**
90 * Opens the dialog for creating a directory. Is connected
91 * with the key shortcut for "new directory" (F10).
92 */
93 void slotCreateDir();
94
95 /**
96 * Emitted when the user requested a change of view mode
97 */
98 void slotViewModeActionTriggered(QAction*);
99
100 /**
101 * Let the user input a name for the selected item(s) and trigger
102 * a renaming afterwards.
103 */
104 void slotRename();
105
106 /**
107 * Moves the selected items of the active view to the trash.
108 * This methods adds "shift means del" handling.
109 */
110 void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
111
112 /**
113 * Deletes the selected items of the active view.
114 */
115 void slotDeleteItems();
116
117 /**
118 * Switches between showing a preview of the file content and showing the icon.
119 */
120 void togglePreview(bool);
121
122 /** Updates the state of the 'Show preview' menu action. */
123 void slotShowPreviewChanged();
124
125 /** Increases the size of the current set view mode. */
126 void zoomIn();
127
128 /** Decreases the size of the current set view mode. */
129 void zoomOut();
130
131 /** Switches between an ascending and descending sorting order. */
132 void toggleSortOrder();
133
134 /**
135 * Updates the state of the 'Sort Ascending/Descending' action.
136 */
137 void slotSortOrderChanged(Qt::SortOrder order);
138
139 /**
140 * Updates the state of the 'Sort by' actions.
141 */
142 void slotSortingChanged(DolphinView::Sorting sorting);
143
144 /**
145 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
146 */
147 void slotZoomLevelChanged(int level);
148
149 /**
150 * Switches on or off the displaying of additional information
151 * as specified by \a action.
152 */
153 void toggleAdditionalInfo(QAction* action);
154
155 /**
156 * Changes the sorting of the current view.
157 */
158 void slotSortTriggered(QAction*);
159
160 /**
161 * Updates the state of the 'Additional Information' actions.
162 */
163 void slotAdditionalInfoChanged();
164
165 /**
166 * Switches between sorting by categories or not.
167 */
168 void toggleSortCategorization(bool);
169
170 /**
171 * Updates the state of the 'Categorized sorting' menu action.
172 */
173 void slotCategorizedSortingChanged();
174
175 /**
176 * Switches between showing and hiding of hidden marked files
177 */
178 void toggleShowHiddenFiles(bool);
179
180 /**
181 * Updates the state of the 'Show hidden files' menu action.
182 */
183 void slotShowHiddenFilesChanged();
184
185 /**
186 * Opens the view properties dialog, which allows to modify the properties
187 * of the currently active view.
188 */
189 void slotAdjustViewProperties();
190
191 /**
192 * Opens the Find File dialog for the currently shown directory.
193 */
194 void slotFindFile();
195
196 /**
197 * Connected to the "properties" action.
198 * Opens the properties dialog for the selected items of the
199 * active view. The properties dialog shows information
200 * like name, size and permissions.
201 */
202 void slotProperties();
203
204 private:
205 /**
206 * Create all the actions.
207 * This is called only once (by the constructor)
208 */
209 void createActions();
210 /**
211 * Creates an action group with all the "show additional information" actions in it.
212 * Helper method for createActions();
213 */
214 QActionGroup* createAdditionalInformationActionGroup();
215
216 /**
217 * Creates an action group with all the "sort by" actions in it.
218 * Helper method for createActions();
219 */
220 QActionGroup* createSortByActionGroup();
221
222 /**
223 * Returns the "switch to icons mode" action.
224 * Helper method for createActions();
225 */
226 KToggleAction* iconsModeAction();
227
228 /**
229 * Returns the "switch to details mode" action.
230 * Helper method for createActions();
231 */
232 KToggleAction* detailsModeAction();
233
234 /**
235 * Returns the "switch to columns mode" action.
236 * Helper method for createActions();
237 */
238 KToggleAction* columnsModeAction();
239
240
241 KActionCollection* m_actionCollection;
242 DolphinView* m_currentView;
243 };
244
245 #endif /* DOLPHINVIEWACTIONHANDLER_H */