]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewactionhandler.h
Move "Adjust view properties" to dolphinviewactionhandler so that it's available...
[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 name of the action for the current viewmode
61 */
62 QString currentViewModeActionName() const;
63
64 public Q_SLOTS:
65 /**
66 * Update all actions in the 'View' menu, i.e. those that depend on the
67 * settings in the current view.
68 */
69 void updateViewActions();
70
71 Q_SIGNALS:
72 /**
73 * Emitted by DolphinViewActionHandler when the user triggered an action.
74 * This is only used for clearining the statusbar in DolphinMainWindow.
75 */
76 void actionBeingHandled();
77
78 private Q_SLOTS:
79 /**
80 * Opens the dialog for creating a directory. Is connected
81 * with the key shortcut for "new directory" (F10).
82 */
83 void slotCreateDir();
84
85 /**
86 * Emitted when the user requested a change of view mode
87 */
88 void slotViewModeActionTriggered(QAction*);
89
90 /**
91 * Let the user input a name for the selected item(s) and trigger
92 * a renaming afterwards.
93 */
94 void slotRename();
95
96 /**
97 * Moves the selected items of the active view to the trash.
98 * This methods adds "shift means del" handling.
99 */
100 void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
101
102 /**
103 * Deletes the selected items of the active view.
104 */
105 void slotDeleteItems();
106
107 /**
108 * Switches between showing a preview of the file content and showing the icon.
109 */
110 void togglePreview(bool);
111
112 /** Updates the state of the 'Show preview' menu action. */
113 void slotShowPreviewChanged();
114
115 /** Increases the size of the current set view mode. */
116 void zoomIn();
117
118 /** Decreases the size of the current set view mode. */
119 void zoomOut();
120
121 /** Switches between an ascending and descending sorting order. */
122 void toggleSortOrder();
123
124 /**
125 * Updates the state of the 'Sort Ascending/Descending' action.
126 */
127 void slotSortOrderChanged(Qt::SortOrder order);
128
129 /**
130 * Updates the state of the 'Sort by' actions.
131 */
132 void slotSortingChanged(DolphinView::Sorting sorting);
133
134 /**
135 * Switches on or off the displaying of additional information
136 * as specified by \a action.
137 */
138 void toggleAdditionalInfo(QAction* action);
139
140 /**
141 * Changes the sorting of the current view.
142 */
143 void slotSortTriggered(QAction*);
144
145 /**
146 * Updates the state of the 'Additional Information' actions.
147 */
148 void slotAdditionalInfoChanged();
149
150 /**
151 * Switches between sorting by categories or not.
152 */
153 void toggleSortCategorization(bool);
154
155 /**
156 * Updates the state of the 'Categorized sorting' menu action.
157 */
158 void slotCategorizedSortingChanged();
159
160 /**
161 * Switches between showing and hiding of hidden marked files
162 */
163 void toggleShowHiddenFiles(bool);
164
165 /**
166 * Updates the state of the 'Show hidden files' menu action.
167 */
168 void slotShowHiddenFilesChanged();
169
170 /**
171 * Opens the view properties dialog, which allows to modify the properties
172 * of the currently active view.
173 */
174 void slotAdjustViewProperties();
175
176 private:
177 /**
178 * Create all the actions.
179 * This is called only once (by the constructor)
180 */
181 void createActions();
182 /**
183 * Creates an action group with all the "show additional information" actions in it.
184 * Helper method for createActions();
185 */
186 QActionGroup* createAdditionalInformationActionGroup();
187
188 /**
189 * Creates an action group with all the "sort by" actions in it.
190 * Helper method for createActions();
191 */
192 QActionGroup* createSortByActionGroup();
193
194 /**
195 * Returns the "switch to icons mode" action.
196 * Helper method for createActions();
197 */
198 KToggleAction* iconsModeAction();
199
200 /**
201 * Returns the "switch to details mode" action.
202 * Helper method for createActions();
203 */
204 KToggleAction* detailsModeAction();
205
206 /**
207 * Returns the "switch to columns mode" action.
208 * Helper method for createActions();
209 */
210 KToggleAction* columnsModeAction();
211
212
213 KActionCollection* m_actionCollection;
214 DolphinView* m_currentView;
215 };
216
217 #endif /* DOLPHINVIEWACTIONHANDLER_H */