]>
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>
38 class DolphinViewActionHandler
;
39 class DolphinApplication
;
40 class DolphinViewContainer
;
46 * @short Main window for Dolphin.
48 * Handles the menus, toolbars and Dolphin views.
50 class DolphinMainWindow
: public KXmlGuiWindow
53 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
54 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
55 friend class DolphinApplication
;
58 virtual ~DolphinMainWindow();
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.
66 DolphinViewContainer
* activeViewContainer() const;
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().
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
83 /** Renames the item represented by \a oldUrl to \a newUrl. */
84 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
87 * Refreshes the views of the main window by recreating them dependent from
88 * the given Dolphin settings.
93 * Returns the 'Create New...' sub menu which also can be shared
94 * with other menus (e. g. a context menu).
96 KNewMenu
* newMenu() const;
99 * Returns the 'Show Menubar' action which can be shared with
100 * other menus (e. g. a context menu).
102 KAction
* showMenuBarAction() const;
106 * Handles the dropping of URLs to the given
107 * destination. This is only called by the TreeViewSidebarPage.
109 void dropUrls(const KUrl::List
& urls
,
110 const KUrl
& destination
);
113 * Returns the main window ID used through DBus.
118 * Inform all affected dolphin components (sidebars, views) of an URL
121 void changeUrl(const KUrl
& url
);
124 * Inform all affected dolphin components that a selection change is
127 void changeSelection(const KFileItemList
& selection
);
129 /** Stores all settings and quits Dolphin. */
134 * Is send if the active view has been changed in
135 * the split view mode.
137 void activeViewChanged();
140 * Is sent if the selection of the currently active view has
143 void selectionChanged(const KFileItemList
& selection
);
146 * Is sent if the url of the currently active view has
149 void urlChanged(const KUrl
& url
);
152 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
153 * If item is null, no item information request is pending.
155 void requestItemInfo(const KFileItem
& item
);
158 /** @see QMainWindow::closeEvent() */
159 virtual void closeEvent(QCloseEvent
* event
);
161 /** @see KMainWindow::saveProperties() */
162 virtual void saveProperties(KConfigGroup
& group
);
164 /** @see KMainWindow::readProperties() */
165 virtual void readProperties(const KConfigGroup
& group
);
168 void clearStatusBar();
170 /** Updates the 'Create New...' sub menu. */
171 void updateNewMenu();
174 * Opens the properties window for the selected items of the
175 * active view. The properties windows shows information
176 * like name, size and permissions.
181 * Shows the error information from the places model
184 void slotHandlePlacesError(const QString
&message
);
187 * Updates the state of the 'Undo' menu action dependent
188 * from the parameter \a available.
190 void slotUndoAvailable(bool available
);
192 /** Sets the text of the 'Undo' menu action to \a text. */
193 void slotUndoTextChanged(const QString
& text
);
195 /** Performs the current undo operation. */
199 * Copies all selected items to the clipboard and marks
200 * the items as cutted.
204 /** Copies all selected items to the clipboard. */
207 /** Pastes the clipboard data to the active view. */
211 * Updates the text of the paste action dependent from
212 * the number of items which are in the clipboard.
214 void updatePasteAction();
216 /** Selects all items from the active view. */
220 * Inverts the selection of all items of the active view:
221 * Selected items get nonselected and nonselected items get
224 void invertSelection();
227 * Switches between one and two views:
228 * If one view is visible, it will get split into two views.
229 * If already two views are visible, the nonactivated view gets closed.
231 void toggleSplitView();
233 /** Reloads the current active view. */
236 /** Stops the loading process for the current active view. */
240 * Toggles between showing and hiding of the filter bar
242 void toggleFilterBarVisibility(bool show
);
245 * Toggles between edit and browse mode of the navigation bar.
247 void toggleEditLocation();
250 * Switches to the edit mode of the navigation bar. If the edit mode is
251 * already active, it is assured that the navigation bar get focused.
256 * Opens the view properties dialog, which allows to modify the properties
257 * of the currently active view.
259 void adjustViewProperties();
261 /** Goes back on step of the URL history. */
264 /** Goes forward one step of the URL history. */
267 /** Goes up one hierarchy of the current URL. */
270 /** Goes to the home URL. */
273 /** Opens KFind for the current shown directory. */
276 /** Opens Kompare for 2 selected files. */
280 * Hides the menu bar if it is visible, makes the menu bar
281 * visible if it is hidden.
283 void toggleShowMenuBar();
285 /** Opens the settings dialog for Dolphin. */
288 /** Updates the state of the 'Show Full Location' action. */
289 void slotEditableStateChanged(bool editable
);
292 * Updates the state of the 'Edit' menu actions and emits
293 * the signal selectionChanged().
295 void slotSelectionChanged(const KFileItemList
& selection
);
297 /** Emits the signal requestItemInfo(). */
298 void slotRequestItemInfo(const KFileItem
&);
301 * Updates the state of the 'Back' and 'Forward' menu
302 * actions corresponding the the current history.
304 void updateHistory();
306 /** Updates the state of the 'Show filter bar' menu action. */
307 void updateFilterBarAction(bool show
);
309 /** Open a new main window. */
310 void openNewMainWindow();
312 /** Toggles the active view if two views are shown within the main window. */
313 void toggleActiveView();
315 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
316 void slotDoingOperation(KonqFileUndoManager::CommandType type
);
319 DolphinMainWindow(int id
);
323 * Activates the given view, which means that
324 * all menu actions are applied to this view. When
325 * having a split view setup, the nonactive view
326 * is usually shown in darker colors.
328 void setActiveViewContainer(DolphinViewContainer
* view
);
331 void setupDockWidgets();
332 void updateEditActions();
333 void updateViewActions();
334 void updateGoActions();
337 * Connects the signals from the created DolphinView with
338 * the index \a viewIndex with the corresponding slots of
339 * the DolphinMainWindow. This method must be invoked each
340 * time a DolphinView has been created.
342 void connectViewSignals(int viewIndex
);
345 * Updates the text of the split action:
346 * If two views are shown, the text is set to "Split",
347 * otherwise the text is set to "Join". The icon
348 * is updated to match with the text and the currently active view.
350 void updateSplitAction();
354 * DolphinMainWindow supports up to two views beside each other.
358 PrimaryView
= 0, ///< View shown on the left side of the main window.
359 SecondaryView
= 1 ///< View shown on the left side of the main window.
363 * Implements a custom error handling for the undo manager. This
364 * assures that all errors are shown in the status bar of Dolphin
365 * instead as modal error dialog with an OK button.
367 class UndoUiInterface
: public KonqFileUndoManager::UiInterface
370 UndoUiInterface(DolphinMainWindow
* mainWin
);
371 virtual ~UndoUiInterface();
372 virtual void jobError(KIO::Job
* job
);
375 DolphinMainWindow
* m_mainWin
;
379 KAction
* m_showMenuBar
;
380 QSplitter
* m_splitter
;
381 DolphinViewContainer
* m_activeViewContainer
;
384 DolphinViewContainer
* m_viewContainer
[SecondaryView
+ 1];
386 DolphinViewActionHandler
* m_actionHandler
;
388 /// remember pending undo operations until they are finished
389 QList
<KonqFileUndoManager::CommandType
> m_undoCommandTypes
;
392 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
394 return m_activeViewContainer
;
397 inline bool DolphinMainWindow::isSplit() const
399 return m_viewContainer
[SecondaryView
] != 0;
402 inline KNewMenu
* DolphinMainWindow::newMenu() const
407 inline KAction
* DolphinMainWindow::showMenuBarAction() const
409 return m_showMenuBar
;
412 inline int DolphinMainWindow::getId() const
417 #endif // DOLPHIN_MAINWINDOW_H