]>
cloud.milkyroute.net Git - dolphin.git/blob - 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> *
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. *
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. *
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 ***************************************************************************/
22 #ifndef DOLPHIN_MAINWINDOW_H
23 #define DOLPHIN_MAINWINDOW_H
25 #include "dolphinview.h"
26 #include "sidebarpage.h"
28 #include <config-nepomuk.h>
30 #include <kfileitemdelegate.h>
31 #include <konq_fileundomanager.h>
32 #include <ksortablelist.h>
33 #include <kxmlguiwindow.h>
35 #include <QtCore/QList>
37 class DolphinViewActionHandler
;
38 class DolphinApplication
;
39 class DolphinViewContainer
;
45 * @short Main window for Dolphin.
47 * Handles the menus, toolbars and Dolphin views.
49 class DolphinMainWindow
: public KXmlGuiWindow
52 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
53 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
54 friend class DolphinApplication
;
57 virtual ~DolphinMainWindow();
60 * Returns the currently active view.
61 * All menu actions are applied to this view. When
62 * having a split view setup, the nonactive view
63 * is usually shown in darker colors.
65 DolphinViewContainer
* activeViewContainer() const;
68 * Returns true, if the main window contains two instances
69 * of a view container. The active view constainer can be
70 * accessed by DolphinMainWindow::activeViewContainer().
75 * If the main window contains two instances of a view container
76 * (DolphinMainWindow::isSplit() returns true), then the
77 * two views get toggled (the right view is on the left, the left
82 /** Renames the item represented by \a oldUrl to \a newUrl. */
83 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
86 * Refreshes the views of the main window by recreating them dependent from
87 * the given Dolphin settings.
92 * Returns the 'Create New...' sub menu which also can be shared
93 * with other menus (e. g. a context menu).
95 KNewMenu
* newMenu() const;
98 * Returns the 'Show Menubar' action which can be shared with
99 * other menus (e. g. a context menu).
101 KAction
* showMenuBarAction() const;
105 * Handles the dropping of URLs to the given
106 * destination. This is only called by the TreeViewSidebarPage.
108 void dropUrls(const KUrl::List
& urls
,
109 const KUrl
& destination
);
112 * Returns the main window ID used through DBus.
117 * Inform all affected dolphin components (sidebars, views) of an URL
120 void changeUrl(const KUrl
& url
);
123 * Inform all affected dolphin components that a selection change is
126 void changeSelection(const KFileItemList
& selection
);
128 /** Stores all settings and quits Dolphin. */
133 * Is send if the active view has been changed in
134 * the split view mode.
136 void activeViewChanged();
139 * Is sent if the selection of the currently active view has
142 void selectionChanged(const KFileItemList
& selection
);
145 * Is sent if the url of the currently active view has
148 void urlChanged(const KUrl
& url
);
151 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
152 * If item is null, no item information request is pending.
154 void requestItemInfo(const KFileItem
& item
);
157 /** @see QMainWindow::closeEvent() */
158 virtual void closeEvent(QCloseEvent
* event
);
160 /** @see KMainWindow::saveProperties() */
161 virtual void saveProperties(KConfigGroup
& group
);
163 /** @see KMainWindow::readProperties() */
164 virtual void readProperties(const KConfigGroup
& group
);
167 void clearStatusBar();
169 /** Updates the 'Create New...' sub menu. */
170 void updateNewMenu();
173 * Opens the properties window for the selected items of the
174 * active view. The properties windows shows information
175 * like name, size and permissions.
180 * Shows the error information from the places model
183 void slotHandlePlacesError(const QString
&message
);
186 * Updates the state of the 'Undo' menu action dependent
187 * from the parameter \a available.
189 void slotUndoAvailable(bool available
);
191 /** Sets the text of the 'Undo' menu action to \a text. */
192 void slotUndoTextChanged(const QString
& text
);
194 /** Performs the current undo operation. */
198 * Copies all selected items to the clipboard and marks
199 * the items as cutted.
203 /** Copies all selected items to the clipboard. */
206 /** Pastes the clipboard data to the active view. */
210 * Updates the text of the paste action dependent from
211 * the number of items which are in the clipboard.
213 void updatePasteAction();
215 /** Selects all items from the active view. */
219 * Inverts the selection of all items of the active view:
220 * Selected items get nonselected and nonselected items get
223 void invertSelection();
225 /** The current active view is switched to a new view mode. */
226 void setViewMode(QAction
*);
228 /** The sorting of the current view should be done by the name. */
231 /** The sorting of the current view should be done by the size. */
234 /** The sorting of the current view should be done by the date. */
237 /** The sorting of the current view should be done by the permissions. */
238 void sortByPermissions();
240 /** The sorting of the current view should be done by the owner. */
243 /** The sorting of the current view should be done by the group. */
246 /** The sorting of the current view should be done by the type. */
249 /** The sorting of the current view should be done by the rating. */
252 /** The sorting of the current view should be done by tags. */
256 * Switches between one and two views:
257 * If one view is visible, it will get split into two views.
258 * If already two views are visible, the nonactivated view gets closed.
260 void toggleSplitView();
262 /** Reloads the current active view. */
265 /** Stops the loading process for the current active view. */
269 * Toggles between showing and hiding of the filter bar
271 void toggleFilterBarVisibility(bool show
);
274 * Toggles between edit and browse mode of the navigation bar.
276 void toggleEditLocation();
279 * Switches to the edit mode of the navigation bar. If the edit mode is
280 * already active, it is assured that the navigation bar get focused.
285 * Opens the view properties dialog, which allows to modify the properties
286 * of the currently active view.
288 void adjustViewProperties();
290 /** Goes back on step of the URL history. */
293 /** Goes forward one step of the URL history. */
296 /** Goes up one hierarchy of the current URL. */
299 /** Goes to the home URL. */
302 /** Opens KFind for the current shown directory. */
305 /** Opens Kompare for 2 selected files. */
309 * Hides the menu bar if it is visible, makes the menu bar
310 * visible if it is hidden.
312 void toggleShowMenuBar();
314 /** Opens the settings dialog for Dolphin. */
317 /** Updates the state of all 'View' menu actions. */
318 void slotViewModeChanged();
320 /** Updates the state of the 'Sort by' actions. */
321 void slotSortingChanged(DolphinView::Sorting sorting
);
323 /** Updates the state of the 'Show Full Location' action. */
324 void slotEditableStateChanged(bool editable
);
327 * Updates the state of the 'Edit' menu actions and emits
328 * the signal selectionChanged().
330 void slotSelectionChanged(const KFileItemList
& selection
);
332 /** Emits the signal requestItemInfo(). */
333 void slotRequestItemInfo(const KFileItem
&);
336 * Updates the state of the 'Back' and 'Forward' menu
337 * actions corresponding the the current history.
339 void slotHistoryChanged();
341 /** Updates the state of the 'Show filter bar' menu action. */
342 void updateFilterBarAction(bool show
);
344 /** Open a new main window. */
345 void openNewMainWindow();
347 /** Toggles the active view if two views are shown within the main window. */
348 void toggleActiveView();
350 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
351 void slotDoingOperation(KonqFileUndoManager::CommandType type
);
354 DolphinMainWindow(int id
);
358 * Activates the given view, which means that
359 * all menu actions are applied to this view. When
360 * having a split view setup, the nonactive view
361 * is usually shown in darker colors.
363 void setActiveViewContainer(DolphinViewContainer
* view
);
366 void setupDockWidgets();
367 void updateHistory();
368 void updateEditActions();
369 void updateViewActions();
370 void updateGoActions();
373 * Connects the signals from the created DolphinView with
374 * the index \a viewIndex with the corresponding slots of
375 * the DolphinMainWindow. This method must be invoked each
376 * time a DolphinView has been created.
378 void connectViewSignals(int viewIndex
);
381 * Updates the text of the split action:
382 * If two views are shown, the text is set to "Split",
383 * otherwise the text is set to "Join". The icon
384 * is updated to match with the text and the currently active view.
386 void updateSplitAction();
390 * DolphinMainWindow supports up to two views beside each other.
394 PrimaryView
= 0, ///< View shown on the left side of the main window.
395 SecondaryView
= 1 ///< View shown on the left side of the main window.
399 * Implements a custom error handling for the undo manager. This
400 * assures that all errors are shown in the status bar of Dolphin
401 * instead as modal error dialog with an OK button.
403 class UndoUiInterface
: public KonqFileUndoManager::UiInterface
406 UndoUiInterface(DolphinMainWindow
* mainWin
);
407 virtual ~UndoUiInterface();
408 virtual void jobError(KIO::Job
* job
);
411 DolphinMainWindow
* m_mainWin
;
415 KAction
* m_showMenuBar
;
416 QSplitter
* m_splitter
;
417 DolphinViewContainer
* m_activeViewContainer
;
420 DolphinViewContainer
* m_viewContainer
[SecondaryView
+ 1];
422 DolphinViewActionHandler
* m_actionHandler
;
424 /// remember pending undo operations until they are finished
425 QList
<KonqFileUndoManager::CommandType
> m_undoCommandTypes
;
428 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
430 return m_activeViewContainer
;
433 inline bool DolphinMainWindow::isSplit() const
435 return m_viewContainer
[SecondaryView
] != 0;
438 inline KNewMenu
* DolphinMainWindow::newMenu() const
443 inline KAction
* DolphinMainWindow::showMenuBarAction() const
445 return m_showMenuBar
;
448 inline int DolphinMainWindow::getId() const
453 #endif // DOLPHIN_MAINWINDOW_H