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();
136 * Updates the state of the 'Sort Ascending/Descending' action.
138 void slotSortOrderChanged(Qt::SortOrder order
);
141 * Updates the state of the 'Sort by' actions.
143 void slotSortingChanged(DolphinView::Sorting sorting
);
146 * Updates the state of the 'Zoom In' and 'Zoom Out' actions.
148 void slotZoomLevelChanged(int level
);
151 * Switches on or off the displaying of additional information
152 * as specified by \a action.
154 void toggleAdditionalInfo(QAction
* action
);
157 * Changes the sorting of the current view.
159 void slotSortTriggered(QAction
*);
162 * Updates the state of the 'Additional Information' actions.
164 void slotAdditionalInfoChanged();
167 * Switches between sorting by categories or not.
169 void toggleSortCategorization(bool);
172 * Updates the state of the 'Categorized sorting' menu action.
174 void slotCategorizedSortingChanged();
177 * Switches between showing and hiding of hidden marked files
179 void toggleShowHiddenFiles(bool);
182 * Updates the state of the 'Show hidden files' menu action.
184 void slotShowHiddenFilesChanged();
187 * Opens the view properties dialog, which allows to modify the properties
188 * of the currently active view.
190 void slotAdjustViewProperties();
193 * Opens the Find File dialog for the currently shown directory.
198 * Connected to the "properties" action.
199 * Opens the properties dialog for the selected items of the
200 * active view. The properties dialog shows information
201 * like name, size and permissions.
203 void slotProperties();
207 * Create all the actions.
208 * This is called only once (by the constructor)
210 void createActions();
212 * Creates an action group with all the "show additional information" actions in it.
213 * Helper method for createActions();
215 QActionGroup
* createAdditionalInformationActionGroup();
218 * Creates an action group with all the "sort by" actions in it.
219 * Helper method for createActions();
221 QActionGroup
* createSortByActionGroup();
224 * Returns the "switch to icons mode" action.
225 * Helper method for createActions();
227 KToggleAction
* iconsModeAction();
230 * Returns the "switch to details mode" action.
231 * Helper method for createActions();
233 KToggleAction
* detailsModeAction();
236 * Returns the "switch to columns mode" action.
237 * Helper method for createActions();
239 KToggleAction
* columnsModeAction();
242 KActionCollection
* m_actionCollection
;
243 DolphinView
* m_currentView
;
246 #endif /* DOLPHINVIEWACTIONHANDLER_H */