]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinviewactionhandler.h
Provide the dolphinpart view modes (Icons, Details, Columns) in konqueror's View...
[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 "libdolphin_export.h"
25 #include <QtCore/QObject>
26 class KToggleAction;
27 class QAction;
28 class QActionGroup;
29 class DolphinView;
30 class KActionCollection;
31
32 /**
33 * @short Handles all actions for DolphinView
34 *
35 * The action handler owns all the actions and slots related to DolphinView,
36 * but can the view that is acts upon can be switched to another one
37 * (this is used in the case of split views).
38 *
39 * The purpose of this class is also to share this code between DolphinMainWindow
40 * and DolphinPart.
41 *
42 * @see DolphinView
43 * @see DolphinMainWindow
44 * @see DolphinPart
45 */
46 class LIBDOLPHINPRIVATE_EXPORT DolphinViewActionHandler : public QObject
47 {
48 Q_OBJECT
49
50 public:
51 explicit DolphinViewActionHandler(KActionCollection* collection, QObject* parent);
52
53 /**
54 * Sets the view that this action handler should work on.
55 */
56 void setCurrentView(DolphinView* view);
57
58 /**
59 * Returns the name of the action for the current viewmode
60 */
61 QString currentViewModeActionName() const;
62
63 public Q_SLOTS:
64 /**
65 * Update all actions in the 'View' menu, i.e. those that depend on the
66 * settings in the current view.
67 */
68 void updateViewActions();
69
70 Q_SIGNALS:
71 /**
72 * Emitted by DolphinViewActionHandler when the user triggered an action.
73 * This is only used for clearining the statusbar in DolphinMainWindow.
74 */
75 void actionBeingHandled();
76
77 private Q_SLOTS:
78 /**
79 * Opens the dialog for creating a directory. Is connected
80 * with the key shortcut for "new directory" (F10).
81 */
82 void slotCreateDir();
83
84 /**
85 * Emitted when the user requested a change of view mode
86 */
87 void slotViewModeActionTriggered(QAction*);
88
89 /**
90 * Let the user input a name for the selected item(s) and trigger
91 * a renaming afterwards.
92 */
93 void slotRename();
94
95 /**
96 * Moves the selected items of the active view to the trash.
97 * This methods adds "shift means del" handling.
98 */
99 void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
100
101 /**
102 * Deletes the selected items of the active view.
103 */
104 void slotDeleteItems();
105
106 /**
107 * Switches between showing a preview of the file content and showing the icon.
108 */
109 void togglePreview(bool);
110
111 /** Updates the state of the 'Show preview' menu action. */
112 void slotShowPreviewChanged();
113
114 /** Increases the size of the current set view mode. */
115 void zoomIn();
116
117 /** Decreases the size of the current set view mode. */
118 void zoomOut();
119
120 /** Switches between an ascending and descending sorting order. */
121 void toggleSortOrder();
122
123 /**
124 * Updates the state of the 'Sort Ascending/Descending' action.
125 */
126 void slotSortOrderChanged(Qt::SortOrder order);
127
128 /**
129 * Switches on or off the displaying of additional information
130 * as specified by \a action.
131 */
132 void toggleAdditionalInfo(QAction* action);
133
134 /**
135 * Updates the state of the 'Additional Information' actions.
136 */
137 void slotAdditionalInfoChanged();
138
139 /**
140 * Switches between sorting by categories or not.
141 */
142 void toggleSortCategorization(bool);
143
144 /**
145 * Updates the state of the 'Categorized sorting' menu action.
146 */
147 void slotCategorizedSortingChanged();
148
149 /**
150 * Switches between showing and hiding of hidden marked files
151 */
152 void toggleShowHiddenFiles(bool);
153
154 /**
155 * Updates the state of the 'Show hidden files' menu action.
156 */
157 void slotShowHiddenFilesChanged();
158
159 private:
160 /**
161 * Create all the actions.
162 * This is called only once (by the constructor)
163 */
164 void createActions();
165 /**
166 * Creates an action group with all the "show additional information" actions in it.
167 * Helper method for createActions();
168 */
169 QActionGroup* createAdditionalInformationActionGroup();
170
171 /**
172 * Returns the "switch to icons mode" action.
173 * Helper method for createActions();
174 */
175 KToggleAction* iconsModeAction();
176
177 /**
178 * Returns the "switch to details mode" action.
179 * Helper method for createActions();
180 */
181 KToggleAction* detailsModeAction();
182
183 /**
184 * Returns the "switch to columns mode" action.
185 * Helper method for createActions();
186 */
187 KToggleAction* columnsModeAction();
188
189
190 KActionCollection* m_actionCollection;
191 DolphinView* m_currentView;
192 };
193
194 #endif /* DOLPHINVIEWACTIONHANDLER_H */