1 /***************************************************************************
2 * Copyright (C) 2008 by David Faure <faure@kde.org> *
3 * Copyright (C) 2012 by Peter Penz <peter.penz19@gmail.com> *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
22 #ifndef DOLPHINVIEWACTIONHANDLER_H
23 #define DOLPHINVIEWACTIONHANDLER_H
25 #include "dolphin_export.h"
26 #include "views/dolphinview.h"
33 class KActionCollection
;
36 * @short Handles all actions for DolphinView
38 * The action handler owns all the actions and slots related to DolphinView,
39 * but can the view that is acts upon can be switched to another one
40 * (this is used in the case of split views).
42 * The purpose of this class is also to share this code between DolphinMainWindow
46 * @see DolphinMainWindow
49 class DOLPHIN_EXPORT DolphinViewActionHandler
: public QObject
54 explicit DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
);
57 * Sets the view that this action handler should work on.
59 void setCurrentView(DolphinView
* view
);
62 * Returns the view that this action handler should work on.
64 DolphinView
* currentView();
67 * Returns the name of the action for the current viewmode
69 QString
currentViewModeActionName() const;
72 * Returns m_actionCollection
74 KActionCollection
* actionCollection();
78 * Update all actions in the 'View' menu, i.e. those that depend on the
79 * settings in the current view.
81 void updateViewActions();
85 * Emitted by DolphinViewActionHandler when the user triggered an action.
86 * This is only used for clearining the statusbar in DolphinMainWindow.
88 void actionBeingHandled();
91 * Emitted if the user requested creating a new directory by the F10 key.
92 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
93 * the method createDirectory of their KNewFileMenu instance.
95 void createDirectory();
99 * Emitted when the user requested a change of view mode
101 void slotViewModeActionTriggered(QAction
*);
104 * Let the user input a name for the selected item(s) and trigger
105 * a renaming afterwards.
110 * Moves the selected items of the active view to the trash.
111 * This methods adds "shift means del" handling.
113 void slotTrashActivated();
116 * Deletes the selected items of the active view.
118 void slotDeleteItems();
121 * Switches between showing a preview of the file content and showing the icon.
123 void togglePreview(bool);
125 /** Updates the state of the 'Show preview' menu action. */
126 void slotPreviewsShownChanged(bool shown
);
128 /** Increases the size of the current set view mode. */
131 /** Decreases the size of the current set view mode. */
134 /** Switches between an ascending and descending sorting order. */
135 void toggleSortOrder();
137 /** Switches between a separate sorting and a mixed sorting of files and folders. */
138 void toggleSortFoldersFirst();
141 * Updates the state of the 'Sort Ascending/Descending' action.
143 void slotSortOrderChanged(Qt::SortOrder order
);
146 * Updates the state of the 'Sort Folders First' action.
148 void slotSortFoldersFirstChanged(bool foldersFirst
);
151 * Updates the state of the 'Sort by' actions.
153 void slotSortRoleChanged(const QByteArray
& role
);
156 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
158 void slotZoomLevelChanged(int current
, int previous
);
161 * Switches on or off the displaying of additional information
162 * as specified by \a action.
164 void toggleVisibleRole(QAction
* action
);
167 * Changes the sorting of the current view.
169 void slotSortTriggered(QAction
*);
172 * Updates the state of the 'Additional Information' actions.
174 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
175 const QList
<QByteArray
>& previous
);
178 * Switches between sorting by groups or not.
180 void toggleGroupedSorting(bool);
183 * Updates the state of the 'Categorized sorting' menu action.
185 void slotGroupedSortingChanged(bool sortCategorized
);
188 * Switches between showing and hiding of hidden marked files
190 void toggleShowHiddenFiles(bool);
193 * Updates the state of the 'Show hidden files' menu action.
195 void slotHiddenFilesShownChanged(bool shown
);
198 * Updates the state of the 'Create Folder...' action.
200 void slotWriteStateChanged(bool isFolderWritable
);
203 * Opens the view properties dialog, which allows to modify the properties
204 * of the currently active view.
206 void slotAdjustViewProperties();
209 * Connected to the "properties" action.
210 * Opens the properties dialog for the selected items of the
211 * active view. The properties dialog shows information
212 * like name, size and permissions.
214 void slotProperties();
218 * Create all the actions.
219 * This is called only once (by the constructor)
221 void createActions();
224 * Creates an action-group out of all roles from KFileItemModel.
225 * Dependent on the group-prefix either a radiobutton-group is
226 * created for sorting (prefix is "sort_by_") or a checkbox-group
227 * is created for additional information (prefix is "show_").
228 * The changes of actions are reported to slotSortTriggered() or
229 * toggleAdditionalInfo().
231 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
234 * Returns the "switch to icons mode" action.
235 * Helper method for createActions();
237 KToggleAction
* iconsModeAction();
240 * Returns the "switch to compact mode" action.
241 * Helper method for createActions();
243 KToggleAction
* compactModeAction();
246 * Returns the "switch to details mode" action.
247 * Helper method for createActions();
249 KToggleAction
* detailsModeAction();
251 KActionCollection
* m_actionCollection
;
252 DolphinView
* m_currentView
;
254 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
255 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
258 #endif /* DOLPHINVIEWACTIONHANDLER_H */