1 /***************************************************************************
2 * Copyright (C) 2008 by David Faure <faure@kde.org> *
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. *
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. *
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 ***************************************************************************/
21 #ifndef DOLPHINVIEWACTIONHANDLER_H
22 #define DOLPHINVIEWACTIONHANDLER_H
24 #include "dolphinview.h"
25 #include "libdolphin_export.h"
26 #include <QtCore/QObject>
31 class KActionCollection
;
34 * @short Handles all actions for DolphinView
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).
40 * The purpose of this class is also to share this code between DolphinMainWindow
44 * @see DolphinMainWindow
47 class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler
: public QObject
52 explicit DolphinViewActionHandler(KActionCollection
* collection
, QObject
* parent
);
55 * Sets the view that this action handler should work on.
57 void setCurrentView(DolphinView
* view
);
60 * Returns the view that this action handler should work on.
62 DolphinView
* currentView();
65 * Returns the name of the action for the current viewmode
67 QString
currentViewModeActionName() const;
70 * Returns m_actionCollection
72 KActionCollection
* actionCollection();
76 * Update all actions in the 'View' menu, i.e. those that depend on the
77 * settings in the current view.
79 void updateViewActions();
83 * Emitted by DolphinViewActionHandler when the user triggered an action.
84 * This is only used for clearining the statusbar in DolphinMainWindow.
86 void actionBeingHandled();
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.
93 void createDirectory();
97 * Emitted when the user requested a change of view mode
99 void slotViewModeActionTriggered(QAction
*);
102 * Let the user input a name for the selected item(s) and trigger
103 * a renaming afterwards.
108 * Moves the selected items of the active view to the trash.
109 * This methods adds "shift means del" handling.
111 void slotTrashActivated(Qt::MouseButtons
, Qt::KeyboardModifiers
);
114 * Deletes the selected items of the active view.
116 void slotDeleteItems();
119 * Switches between showing a preview of the file content and showing the icon.
121 void togglePreview(bool);
123 /** Updates the state of the 'Show preview' menu action. */
124 void slotShowPreviewChanged();
126 /** Increases the size of the current set view mode. */
129 /** Decreases the size of the current set view mode. */
132 /** Switches between an ascending and descending sorting order. */
133 void toggleSortOrder();
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 slotSortingChanged(DolphinView::Sorting sorting
);
154 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
156 void slotZoomLevelChanged(int level
);
159 * Switches on or off the displaying of additional information
160 * as specified by \a action.
162 void toggleAdditionalInfo(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 slotAdditionalInfoChanged();
175 * Switches between sorting by categories or not.
177 void toggleSortCategorization(bool);
180 * Updates the state of the 'Categorized sorting' menu action.
182 void slotCategorizedSortingChanged();
185 * Switches between showing and hiding of hidden marked files
187 void toggleShowHiddenFiles(bool);
190 * Updates the state of the 'Show hidden files' menu action.
192 void slotShowHiddenFilesChanged();
195 * Opens the view properties dialog, which allows to modify the properties
196 * of the currently active view.
198 void slotAdjustViewProperties();
201 * Opens the Find File dialog for the currently shown directory.
206 * Connected to the "properties" action.
207 * Opens the properties dialog for the selected items of the
208 * active view. The properties dialog shows information
209 * like name, size and permissions.
211 void slotProperties();
215 * Create all the actions.
216 * This is called only once (by the constructor)
218 void createActions();
220 * Creates an action group with all the "show additional information" actions in it.
221 * Helper method for createActions();
223 QActionGroup
* createAdditionalInformationActionGroup();
226 * Creates an action group with all the "sort by" actions in it.
227 * Helper method for createActions();
229 QActionGroup
* createSortByActionGroup();
232 * Returns the "switch to icons mode" action.
233 * Helper method for createActions();
235 KToggleAction
* iconsModeAction();
238 * Returns the "switch to details mode" action.
239 * Helper method for createActions();
241 KToggleAction
* detailsModeAction();
244 * Returns the "switch to columns mode" action.
245 * Helper method for createActions();
247 KToggleAction
* columnsModeAction();
250 KActionCollection
* m_actionCollection
;
251 DolphinView
* m_currentView
;
254 #endif /* DOLPHINVIEWACTIONHANDLER_H */