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"
34 class KActionCollection
;
37 * @short Handles all actions for DolphinView
39 * The action handler owns all the actions and slots related to DolphinView,
40 * but the view that it acts upon can be switched to another one
41 * (this is used in the case of split views).
43 * The purpose of this class is also to share this code between DolphinMainWindow
47 * @see DolphinMainWindow
50 class DOLPHIN_EXPORT DolphinViewActionHandler
: public QObject
55 explicit DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
);
58 * Sets the view that this action handler should work on.
60 void setCurrentView(DolphinView
* view
);
63 * Returns the view that this action handler should work on.
65 DolphinView
* currentView();
68 * Returns the name of the action for the current viewmode
70 QString
currentViewModeActionName() const;
73 * Returns m_actionCollection
75 KActionCollection
* actionCollection();
79 * Update all actions in the 'View' menu, i.e. those that depend on the
80 * settings in the current view.
82 void updateViewActions();
86 * Emitted by DolphinViewActionHandler when the user triggered an action.
87 * This is only used for clearing the statusbar in DolphinMainWindow.
89 void actionBeingHandled();
92 * Emitted if the user requested creating a new directory by the F10 key.
93 * The receiver of the signal (DolphinMainWindow or DolphinPart) invokes
94 * the method createDirectory of their KNewFileMenu instance.
96 void createDirectoryTriggered();
100 * Emitted when the user requested a change of view mode
102 void slotViewModeActionTriggered(QAction
*);
105 * Let the user input a name for the selected item(s) and trigger
106 * a renaming afterwards.
111 * Moves the selected items of the active view to the trash.
112 * This methods adds "shift means del" handling.
114 void slotTrashActivated();
117 * Deletes the selected items of the active view.
119 void slotDeleteItems();
122 * Switches between showing a preview of the file content and showing the icon.
124 void togglePreview(bool);
126 /** Updates the state of the 'Show preview' menu action. */
127 void slotPreviewsShownChanged(bool shown
);
129 /** Increases the size of the current set view mode. */
132 /** Decreases the size of the current set view mode. */
135 /** Switches between a separate sorting and a mixed sorting of files and folders. */
136 void toggleSortFoldersFirst();
139 * Updates the state of the 'Sort Ascending/Descending' action.
141 void slotSortOrderChanged(Qt::SortOrder order
);
144 * Updates the state of the 'Sort Folders First' action.
146 void slotSortFoldersFirstChanged(bool foldersFirst
);
149 * Updates the state of the 'Sort by' actions.
151 void slotSortRoleChanged(const QByteArray
& role
);
154 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
156 void slotZoomLevelChanged(int current
, int previous
);
159 * Switches on or off the displaying of additional information
160 * as specified by \a action.
162 void toggleVisibleRole(QAction
* action
);
165 * Changes the sorting of the current view.
167 void slotSortTriggered(QAction
*);
170 * Updates the state of the 'Additional Information' actions.
172 void slotVisibleRolesChanged(const QList
<QByteArray
>& current
,
173 const QList
<QByteArray
>& previous
);
176 * Switches between sorting by groups or not.
178 void toggleGroupedSorting(bool);
181 * Updates the state of the 'Categorized sorting' menu action.
183 void slotGroupedSortingChanged(bool sortCategorized
);
186 * Switches between showing and hiding of hidden marked files
188 void toggleShowHiddenFiles(bool);
191 * Updates the state of the 'Show hidden files' menu action.
193 void slotHiddenFilesShownChanged(bool shown
);
196 * Updates the state of the 'Create Folder...' action.
198 void slotWriteStateChanged(bool isFolderWritable
);
201 * Opens the view properties dialog, which allows to modify the properties
202 * of the currently active view.
204 void slotAdjustViewProperties();
207 * Connected to the "properties" action.
208 * Opens the properties dialog for the selected items of the
209 * active view. The properties dialog shows information
210 * like name, size and permissions.
212 void slotProperties();
216 * Create all the actions.
217 * This is called only once (by the constructor)
219 void createActions();
222 * Creates an action-group out of all roles from KFileItemModel.
223 * Dependent on the group-prefix either a radiobutton-group is
224 * created for sorting (prefix is "sort_by_") or a checkbox-group
225 * is created for additional information (prefix is "show_").
226 * The changes of actions are reported to slotSortTriggered() or
227 * toggleAdditionalInfo().
229 QActionGroup
* createFileItemRolesActionGroup(const QString
& groupPrefix
);
232 * Returns the "switch to icons mode" action.
233 * Helper method for createActions();
235 KToggleAction
* iconsModeAction();
238 * Returns the "switch to compact mode" action.
239 * Helper method for createActions();
241 KToggleAction
* compactModeAction();
244 * Returns the "switch to details mode" action.
245 * Helper method for createActions();
247 KToggleAction
* detailsModeAction();
249 KActionCollection
* m_actionCollection
;
250 DolphinView
* m_currentView
;
252 QHash
<QByteArray
, KToggleAction
*> m_sortByActions
;
253 QHash
<QByteArray
, KToggleAction
*> m_visibleRoles
;
256 #endif /* DOLPHINVIEWACTIONHANDLER_H */