]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinmainwindow.h
remove unused signal
[dolphin.git] / src / dolphinmainwindow.h
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz <peter.penz@gmx.at> *
3 * Copyright (C) 2006 by Stefan Monov <logixoul@gmail.com> *
4 * Copyright (C) 2006 by Cvetoslav Ludmiloff <ludmiloff@gmail.com> *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20 ***************************************************************************/
21
22 #ifndef DOLPHIN_MAINWINDOW_H
23 #define DOLPHIN_MAINWINDOW_H
24
25 #include "dolphinview.h"
26 #include "sidebarpage.h"
27
28 #include <config-nepomuk.h>
29
30 #include <kfileitemdelegate.h>
31 #include <konq_fileundomanager.h>
32 #include <ksortablelist.h>
33 #include <kxmlguiwindow.h>
34
35 #include <QtCore/QList>
36
37 class KAction;
38 class DolphinViewActionHandler;
39 class DolphinApplication;
40 class DolphinViewContainer;
41 class KNewMenu;
42 class KUrl;
43 class QSplitter;
44
45 /**
46 * @short Main window for Dolphin.
47 *
48 * Handles the menus, toolbars and Dolphin views.
49 */
50 class DolphinMainWindow: public KXmlGuiWindow
51 {
52 Q_OBJECT
53 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
54 Q_PROPERTY(int id READ getId SCRIPTABLE true)
55 friend class DolphinApplication;
56
57 public:
58 virtual ~DolphinMainWindow();
59
60 /**
61 * Returns the currently active view.
62 * All menu actions are applied to this view. When
63 * having a split view setup, the nonactive view
64 * is usually shown in darker colors.
65 */
66 DolphinViewContainer* activeViewContainer() const;
67
68 /**
69 * Returns true, if the main window contains two instances
70 * of a view container. The active view constainer can be
71 * accessed by DolphinMainWindow::activeViewContainer().
72 */
73 bool isSplit() const;
74
75 /**
76 * If the main window contains two instances of a view container
77 * (DolphinMainWindow::isSplit() returns true), then the
78 * two views get toggled (the right view is on the left, the left
79 * view on the right).
80 */
81 void toggleViews();
82
83 /** Renames the item represented by \a oldUrl to \a newUrl. */
84 void rename(const KUrl& oldUrl, const KUrl& newUrl);
85
86 /**
87 * Refreshes the views of the main window by recreating them dependent from
88 * the given Dolphin settings.
89 */
90 void refreshViews();
91
92 /**
93 * Returns the 'Create New...' sub menu which also can be shared
94 * with other menus (e. g. a context menu).
95 */
96 KNewMenu* newMenu() const;
97
98 /**
99 * Returns the 'Show Menubar' action which can be shared with
100 * other menus (e. g. a context menu).
101 */
102 KAction* showMenuBarAction() const;
103
104 public slots:
105 /**
106 * Handles the dropping of URLs to the given
107 * destination. This is only called by the TreeViewSidebarPage.
108 */
109 void dropUrls(const KUrl::List& urls,
110 const KUrl& destination);
111
112 /**
113 * Returns the main window ID used through DBus.
114 */
115 int getId() const;
116
117 /**
118 * Inform all affected dolphin components (sidebars, views) of an URL
119 * change.
120 */
121 void changeUrl(const KUrl& url);
122
123 /**
124 * Inform all affected dolphin components that a selection change is
125 * requested.
126 */
127 void changeSelection(const KFileItemList& selection);
128
129 /** Stores all settings and quits Dolphin. */
130 void quit();
131
132 signals:
133 /**
134 * Is sent if the selection of the currently active view has
135 * been changed.
136 */
137 void selectionChanged(const KFileItemList& selection);
138
139 /**
140 * Is sent if the url of the currently active view has
141 * been changed.
142 */
143 void urlChanged(const KUrl& url);
144
145 /**
146 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
147 * If item is null, no item information request is pending.
148 */
149 void requestItemInfo(const KFileItem& item);
150
151 protected:
152 /** @see QMainWindow::closeEvent() */
153 virtual void closeEvent(QCloseEvent* event);
154
155 /** @see KMainWindow::saveProperties() */
156 virtual void saveProperties(KConfigGroup& group);
157
158 /** @see KMainWindow::readProperties() */
159 virtual void readProperties(const KConfigGroup& group);
160
161 private slots:
162 void clearStatusBar();
163
164 /** Updates the 'Create New...' sub menu. */
165 void updateNewMenu();
166
167 /**
168 * Opens the properties window for the selected items of the
169 * active view. The properties windows shows information
170 * like name, size and permissions.
171 */
172 void properties();
173
174 /**
175 * Shows the error information from the places model
176 * in the status bar.
177 */
178 void slotHandlePlacesError(const QString &message);
179
180 /**
181 * Updates the state of the 'Undo' menu action dependent
182 * from the parameter \a available.
183 */
184 void slotUndoAvailable(bool available);
185
186 /** Sets the text of the 'Undo' menu action to \a text. */
187 void slotUndoTextChanged(const QString& text);
188
189 /** Performs the current undo operation. */
190 void undo();
191
192 /**
193 * Copies all selected items to the clipboard and marks
194 * the items as cutted.
195 */
196 void cut();
197
198 /** Copies all selected items to the clipboard. */
199 void copy();
200
201 /** Pastes the clipboard data to the active view. */
202 void paste();
203
204 /**
205 * Updates the text of the paste action dependent from
206 * the number of items which are in the clipboard.
207 */
208 void updatePasteAction();
209
210 /** Selects all items from the active view. */
211 void selectAll();
212
213 /**
214 * Inverts the selection of all items of the active view:
215 * Selected items get nonselected and nonselected items get
216 * selected.
217 */
218 void invertSelection();
219
220 /**
221 * Switches between one and two views:
222 * If one view is visible, it will get split into two views.
223 * If already two views are visible, the nonactivated view gets closed.
224 */
225 void toggleSplitView();
226
227 /** Reloads the current active view. */
228 void reloadView();
229
230 /** Stops the loading process for the current active view. */
231 void stopLoading();
232
233 /**
234 * Toggles between showing and hiding of the filter bar
235 */
236 void toggleFilterBarVisibility(bool show);
237
238 /**
239 * Toggles between edit and browse mode of the navigation bar.
240 */
241 void toggleEditLocation();
242
243 /**
244 * Switches to the edit mode of the navigation bar. If the edit mode is
245 * already active, it is assured that the navigation bar get focused.
246 */
247 void editLocation();
248
249 /**
250 * Opens the view properties dialog, which allows to modify the properties
251 * of the currently active view.
252 */
253 void adjustViewProperties();
254
255 /** Goes back on step of the URL history. */
256 void goBack();
257
258 /** Goes forward one step of the URL history. */
259 void goForward();
260
261 /** Goes up one hierarchy of the current URL. */
262 void goUp();
263
264 /** Goes to the home URL. */
265 void goHome();
266
267 /** Opens KFind for the current shown directory. */
268 void findFile();
269
270 /** Opens Kompare for 2 selected files. */
271 void compareFiles();
272
273 /**
274 * Hides the menu bar if it is visible, makes the menu bar
275 * visible if it is hidden.
276 */
277 void toggleShowMenuBar();
278
279 /** Opens the settings dialog for Dolphin. */
280 void editSettings();
281
282 /** Updates the state of the 'Show Full Location' action. */
283 void slotEditableStateChanged(bool editable);
284
285 /**
286 * Updates the state of the 'Edit' menu actions and emits
287 * the signal selectionChanged().
288 */
289 void slotSelectionChanged(const KFileItemList& selection);
290
291 /** Emits the signal requestItemInfo(). */
292 void slotRequestItemInfo(const KFileItem&);
293
294 /**
295 * Updates the state of the 'Back' and 'Forward' menu
296 * actions corresponding the the current history.
297 */
298 void updateHistory();
299
300 /** Updates the state of the 'Show filter bar' menu action. */
301 void updateFilterBarAction(bool show);
302
303 /** Open a new main window. */
304 void openNewMainWindow();
305
306 /** Toggles the active view if two views are shown within the main window. */
307 void toggleActiveView();
308
309 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
310 void slotDoingOperation(KonqFileUndoManager::CommandType type);
311
312 private:
313 DolphinMainWindow(int id);
314 void init();
315
316 /**
317 * Activates the given view, which means that
318 * all menu actions are applied to this view. When
319 * having a split view setup, the nonactive view
320 * is usually shown in darker colors.
321 */
322 void setActiveViewContainer(DolphinViewContainer* view);
323
324 void setupActions();
325 void setupDockWidgets();
326 void updateEditActions();
327 void updateViewActions();
328 void updateGoActions();
329
330 /**
331 * Connects the signals from the created DolphinView with
332 * the index \a viewIndex with the corresponding slots of
333 * the DolphinMainWindow. This method must be invoked each
334 * time a DolphinView has been created.
335 */
336 void connectViewSignals(int viewIndex);
337
338 /**
339 * Updates the text of the split action:
340 * If two views are shown, the text is set to "Split",
341 * otherwise the text is set to "Join". The icon
342 * is updated to match with the text and the currently active view.
343 */
344 void updateSplitAction();
345
346 private:
347 /**
348 * DolphinMainWindow supports up to two views beside each other.
349 */
350 enum ViewIndex
351 {
352 PrimaryView = 0, ///< View shown on the left side of the main window.
353 SecondaryView = 1 ///< View shown on the left side of the main window.
354 };
355
356 /**
357 * Implements a custom error handling for the undo manager. This
358 * assures that all errors are shown in the status bar of Dolphin
359 * instead as modal error dialog with an OK button.
360 */
361 class UndoUiInterface : public KonqFileUndoManager::UiInterface
362 {
363 public:
364 UndoUiInterface(DolphinMainWindow* mainWin);
365 virtual ~UndoUiInterface();
366 virtual void jobError(KIO::Job* job);
367
368 private:
369 DolphinMainWindow* m_mainWin;
370 };
371
372 KNewMenu* m_newMenu;
373 KAction* m_showMenuBar;
374 QSplitter* m_splitter;
375 DolphinViewContainer* m_activeViewContainer;
376 int m_id;
377
378 DolphinViewContainer* m_viewContainer[SecondaryView + 1];
379
380 DolphinViewActionHandler* m_actionHandler;
381
382 /// remember pending undo operations until they are finished
383 QList<KonqFileUndoManager::CommandType> m_undoCommandTypes;
384 };
385
386 inline DolphinViewContainer* DolphinMainWindow::activeViewContainer() const
387 {
388 return m_activeViewContainer;
389 }
390
391 inline bool DolphinMainWindow::isSplit() const
392 {
393 return m_viewContainer[SecondaryView] != 0;
394 }
395
396 inline KNewMenu* DolphinMainWindow::newMenu() const
397 {
398 return m_newMenu;
399 }
400
401 inline KAction* DolphinMainWindow::showMenuBarAction() const
402 {
403 return m_showMenuBar;
404 }
405
406 inline int DolphinMainWindow::getId() const
407 {
408 return m_id;
409 }
410
411 #endif // DOLPHIN_MAINWINDOW_H
412