]>
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
;
47 * @short Main window for Dolphin.
49 * Handles the menus, toolbars and Dolphin views.
51 class DolphinMainWindow
: public KXmlGuiWindow
54 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
55 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
56 friend class DolphinApplication
;
59 virtual ~DolphinMainWindow();
62 * Returns the currently active view.
63 * All menu actions are applied to this view. When
64 * having a split view setup, the nonactive view
65 * is usually shown in darker colors.
67 DolphinViewContainer
* activeViewContainer() const;
70 * Returns true, if the main window contains two instances
71 * of a view container. The active view constainer can be
72 * accessed by DolphinMainWindow::activeViewContainer().
77 * If the main window contains two instances of a view container
78 * (DolphinMainWindow::isSplit() returns true), then the
79 * two views get toggled (the right view is on the left, the left
84 /** Renames the item represented by \a oldUrl to \a newUrl. */
85 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
88 * Refreshes the views of the main window by recreating them dependent from
89 * the given Dolphin settings.
94 * Returns the 'Create New...' sub menu which also can be shared
95 * with other menus (e. g. a context menu).
97 KNewMenu
* newMenu() const;
100 * Returns the 'Show Menubar' action which can be shared with
101 * other menus (e. g. a context menu).
103 KAction
* showMenuBarAction() const;
107 * Handles the dropping of URLs to the given
108 * destination. This is only called by the TreeViewSidebarPage.
110 void dropUrls(const KUrl::List
& urls
,
111 const KUrl
& destination
);
114 * Pastes the clipboard data into the currently selected folder
115 * of the active view. If not exactly one folder is selected,
116 * no pasting is done at all.
118 void pasteIntoFolder();
121 * Returns the main window ID used through DBus.
126 * Inform all affected dolphin components (sidebars, views) of an URL
129 void changeUrl(const KUrl
& url
);
132 * Inform all affected dolphin components that a selection change is
135 void changeSelection(const KFileItemList
& selection
);
137 /** Stores all settings and quits Dolphin. */
142 * Is sent if the selection of the currently active view has
145 void selectionChanged(const KFileItemList
& selection
);
148 * Is sent if the url of the currently active view has
151 void urlChanged(const KUrl
& url
);
154 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
155 * If item is null, no item information request is pending.
157 void requestItemInfo(const KFileItem
& item
);
160 /** @see QMainWindow::closeEvent() */
161 virtual void closeEvent(QCloseEvent
* event
);
163 /** @see KMainWindow::saveProperties() */
164 virtual void saveProperties(KConfigGroup
& group
);
166 /** @see KMainWindow::readProperties() */
167 virtual void readProperties(const KConfigGroup
& group
);
170 void clearStatusBar();
172 /** Updates the 'Create New...' sub menu. */
173 void updateNewMenu();
176 * Opens the properties window for the selected items of the
177 * active view. The properties windows shows information
178 * like name, size and permissions.
183 * Shows the error information from the places model
186 void slotHandlePlacesError(const QString
&message
);
189 * Updates the state of the 'Undo' menu action dependent
190 * from the parameter \a available.
192 void slotUndoAvailable(bool available
);
194 /** Sets the text of the 'Undo' menu action to \a text. */
195 void slotUndoTextChanged(const QString
& text
);
197 /** Performs the current undo operation. */
201 * Copies all selected items to the clipboard and marks
202 * the items as cutted.
206 /** Copies all selected items to the clipboard. */
209 /** Pastes the clipboard data to the active view. */
213 * Updates the text of the paste action dependent from
214 * the number of items which are in the clipboard.
216 void updatePasteAction();
218 /** Selects all items from the active view. */
222 * Inverts the selection of all items of the active view:
223 * Selected items get nonselected and nonselected items get
226 void invertSelection();
229 * Switches between one and two views:
230 * If one view is visible, it will get split into two views.
231 * If already two views are visible, the nonactivated view gets closed.
233 void toggleSplitView();
235 /** Reloads the current active view. */
238 /** Stops the loading process for the current active view. */
242 * Toggles between showing and hiding of the filter bar
244 void toggleFilterBarVisibility(bool show
);
247 * Toggles between edit and browse mode of the navigation bar.
249 void toggleEditLocation();
252 * Switches to the edit mode of the navigation bar. If the edit mode is
253 * already active, it is assured that the navigation bar get focused.
258 * Opens the view properties dialog, which allows to modify the properties
259 * of the currently active view.
261 void adjustViewProperties();
263 /** Goes back on step of the URL history. */
266 /** Goes forward one step of the URL history. */
269 /** Goes up one hierarchy of the current URL. */
272 /** Goes to the home URL. */
275 /** Opens KFind for the current shown directory. */
278 /** Opens Kompare for 2 selected files. */
282 * Hides the menu bar if it is visible, makes the menu bar
283 * visible if it is hidden.
285 void toggleShowMenuBar();
287 /** Opens the settings dialog for Dolphin. */
290 /** Updates the state of the 'Show Full Location' action. */
291 void slotEditableStateChanged(bool editable
);
294 * Updates the state of the 'Edit' menu actions and emits
295 * the signal selectionChanged().
297 void slotSelectionChanged(const KFileItemList
& selection
);
299 /** Emits the signal requestItemInfo(). */
300 void slotRequestItemInfo(const KFileItem
&);
303 * Updates the state of the 'Back' and 'Forward' menu
304 * actions corresponding the the current history.
306 void updateHistory();
308 /** Updates the state of the 'Show filter bar' menu action. */
309 void updateFilterBarAction(bool show
);
311 /** Open a new main window. */
312 void openNewMainWindow();
314 /** Opens a new view with the current URL that is part of a tab. */
318 * Opens a new tab showing the URL \a url.
320 void openNewTab(const KUrl
& url
);
322 /** Toggles the active view if two views are shown within the main window. */
323 void toggleActiveView();
325 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
326 void slotDoingOperation(KonqFileUndoManager::CommandType type
);
329 * Activates the tab with the index \a index, which means that the current view
330 * is replaced by the view of the given tab.
332 void setActiveTab(int index
);
334 /** Closes the currently active tab. */
338 * Closes the tab with the index \index and activates the tab with index - 1.
340 void closeTab(int index
);
343 * Opens a context menu for the tab with the index \a index
344 * on the position \a pos.
346 void openTabContextMenu(int index
, const QPoint
& pos
);
349 DolphinMainWindow(int id
);
353 * Activates the given view, which means that
354 * all menu actions are applied to this view. When
355 * having a split view setup, the nonactive view
356 * is usually shown in darker colors.
358 void setActiveViewContainer(DolphinViewContainer
* view
);
361 void setupDockWidgets();
362 void updateEditActions();
363 void updateViewActions();
364 void updateGoActions();
367 * Connects the signals from the created DolphinView with
368 * the DolphinViewContainer \a container with the corresponding slots of
369 * the DolphinMainWindow. This method must be invoked each
370 * time a DolphinView has been created.
372 void connectViewSignals(DolphinViewContainer
* container
);
375 * Updates the text of the split action:
376 * If two views are shown, the text is set to "Split",
377 * otherwise the text is set to "Join". The icon
378 * is updated to match with the text and the currently active view.
380 void updateSplitAction();
382 /** Returns the name of the tab for the URL \a url. */
383 QString
tabName(const KUrl
& url
) const;
387 * Implements a custom error handling for the undo manager. This
388 * assures that all errors are shown in the status bar of Dolphin
389 * instead as modal error dialog with an OK button.
391 class UndoUiInterface
: public KonqFileUndoManager::UiInterface
395 virtual ~UndoUiInterface();
396 virtual void jobError(KIO::Job
* job
);
400 KAction
* m_showMenuBar
;
402 DolphinViewContainer
* m_activeViewContainer
;
403 QVBoxLayout
* m_centralWidgetLayout
;
408 ViewTab() : isPrimaryViewActive(true), primaryView(0), secondaryView(0), splitter(0) {}
409 bool isPrimaryViewActive
;
410 DolphinViewContainer
* primaryView
;
411 DolphinViewContainer
* secondaryView
;
416 QList
<ViewTab
> m_viewTab
;
418 DolphinViewActionHandler
* m_actionHandler
;
420 /// remember pending undo operations until they are finished
421 QList
<KonqFileUndoManager::CommandType
> m_undoCommandTypes
;
424 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
426 return m_activeViewContainer
;
429 inline bool DolphinMainWindow::isSplit() const
431 return m_viewTab
[m_tabIndex
].secondaryView
!= 0;
434 inline KNewMenu
* DolphinMainWindow::newMenu() const
439 inline KAction
* DolphinMainWindow::showMenuBarAction() const
441 return m_showMenuBar
;
444 inline int DolphinMainWindow::getId() const
449 #endif // DOLPHIN_MAINWINDOW_H