]>
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 DolphinApplication
;
38 class DolphinViewContainer
;
44 * @short Main window for Dolphin.
46 * Handles the menus, toolbars and Dolphin views.
48 class DolphinMainWindow
: public KXmlGuiWindow
51 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
52 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
53 friend class DolphinApplication
;
56 virtual ~DolphinMainWindow();
59 * Returns the currently active view.
60 * All menu actions are applied to this view. When
61 * having a split view setup, the nonactive view
62 * is usually shown in darker colors.
64 DolphinViewContainer
* activeViewContainer() const;
67 * Returns true, if the main window contains two instances
68 * of a view container. The active view constainer can be
69 * accessed by DolphinMainWindow::activeViewContainer().
74 * If the main window contains two instances of a view container
75 * (DolphinMainWindow::isSplit() returns true), then the
76 * two views get toggled (the right view is on the left, the left
81 /** Renames the item represented by \a oldUrl to \a newUrl. */
82 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
85 * Refreshes the views of the main window by recreating them dependent from
86 * the given Dolphin settings.
91 * Returns the 'Create New...' sub menu which also can be shared
92 * with other menus (e. g. a context menu).
94 KNewMenu
* newMenu() const;
97 * Returns the 'Show Menubar' action which can be shared with
98 * other menus (e. g. a context menu).
100 KAction
* showMenuBarAction() const;
104 * Handles the dropping of URLs to the given
105 * destination. This is only called by the TreeViewSidebarPage.
107 void dropUrls(const KUrl::List
& urls
,
108 const KUrl
& destination
);
111 * Returns the main window ID used through DBus.
116 * Inform all affected dolphin components (sidebars, views) of an URL
119 void changeUrl(const KUrl
& url
);
122 * Inform all affected dolphin components that a selection change is
125 void changeSelection(const KFileItemList
& selection
);
127 /** Stores all settings and quits Dolphin. */
132 * Is send if the active view has been changed in
133 * the split view mode.
135 void activeViewChanged();
138 * Is sent if the selection of the currently active view has
141 void selectionChanged(const KFileItemList
& selection
);
144 * Is sent if the url of the currently active view has
147 void urlChanged(const KUrl
& url
);
150 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
151 * If item is null, no item information request is pending.
153 void requestItemInfo(const KFileItem
& item
);
156 /** @see QMainWindow::closeEvent() */
157 virtual void closeEvent(QCloseEvent
* event
);
159 /** @see KMainWindow::saveProperties() */
160 virtual void saveProperties(KConfigGroup
& group
);
162 /** @see KMainWindow::readProperties() */
163 virtual void readProperties(const KConfigGroup
& group
);
166 /** Opens the dialog for creating a directory. */
169 /** Updates the 'Create New...' sub menu. */
170 void updateNewMenu();
173 * Let the user input a name for the selected item(s) and trigger
174 * a renaming afterwards.
178 /** Moves the selected items of the active view to the trash. */
181 /** Deletes the selected items of the active view. */
185 * Opens the properties window for the selected items of the
186 * active view. The properties windows shows information
187 * like name, size and permissions.
192 * Shows the error information from the places model
195 void slotHandlePlacesError(const QString
&message
);
198 * Updates the state of the 'Undo' menu action dependent
199 * from the parameter \a available.
201 void slotUndoAvailable(bool available
);
203 /** Sets the text of the 'Undo' menu action to \a text. */
204 void slotUndoTextChanged(const QString
& text
);
206 /** Performs the current undo operation. */
210 * Copies all selected items to the clipboard and marks
211 * the items as cutted.
215 /** Copies all selected items to the clipboard. */
218 /** Pastes the clipboard data to the active view. */
222 * Updates the text of the paste action dependent from
223 * the number of items which are in the clipboard.
225 void updatePasteAction();
227 /** Selects all items from the active view. */
231 * Inverts the selection of all items of the active view:
232 * Selected items get nonselected and nonselected items get
235 void invertSelection();
237 /** The current active view is switched to a new view mode. */
238 void setViewMode(QAction
*);
240 /** The sorting of the current view should be done by the name. */
243 /** The sorting of the current view should be done by the size. */
246 /** The sorting of the current view should be done by the date. */
249 /** The sorting of the current view should be done by the permissions. */
250 void sortByPermissions();
252 /** The sorting of the current view should be done by the owner. */
255 /** The sorting of the current view should be done by the group. */
258 /** The sorting of the current view should be done by the type. */
261 /** The sorting of the current view should be done by the rating. */
264 /** The sorting of the current view should be done by tags. */
267 /** Switches between an ascending and descending sorting order. */
268 void toggleSortOrder();
270 /** Switches between sorting by categories or not. */
271 void toggleSortCategorization();
273 /** Switches between showing the size as additional information for the item or not. */
274 void toggleSizeInfo();
276 /** Switchtes between showing the date as additional information for the item or not. */
277 void toggleDateInfo();
279 /** Switchtes between showing the permissions as additional information for the item or not. */
280 void togglePermissionsInfo();
282 /** Switchtes between showing the owner as additional information for the item or not. */
283 void toggleOwnerInfo();
285 /** Switchtes between showing the group as additional information for the item or not. */
286 void toggleGroupInfo();
288 /** Switches between showing the MIME type as additional information for the item or not. */
289 void toggleMimeInfo();
292 * Switches between one and two views:
293 * If one view is visible, it will get split into two views.
294 * If already two views are visible, the nonactivated view gets closed.
296 void toggleSplitView();
298 /** Reloads the current active view. */
301 /** Stops the loading process for the current active view. */
304 /** Switches between showing a preview of the file content and showing the icon. */
305 void togglePreview();
308 * Switches between showing and hiding of hidden marked files dependent
309 * from the current state of the 'Show Hidden Files' menu toggle action.
311 void toggleShowHiddenFiles();
314 * Toggles between showing and hiding of the filter bar dependent
315 * from the current state of the 'Show Filter Bar' menu toggle action.
317 void toggleFilterBarVisibility();
319 /** Increases the size of the current set view mode. */
322 /** Decreases the size of the current set view mode. */
326 * Toggles between edit and brose mode of the navigation bar.
328 void toggleEditLocation();
331 * Switches to the edit mode of the navigation bar. If the edit mode is
332 * already active, it is assured that the navigation bar get focused.
337 * Opens the view properties dialog, which allows to modify the properties
338 * of the currently active view.
340 void adjustViewProperties();
342 /** Goes back on step of the URL history. */
345 /** Goes forward one step of the URL history. */
348 /** Goes up one hierarchy of the current URL. */
351 /** Goes to the home URL. */
354 /** Opens KFind for the current shown directory. */
357 /** Opens Kompare for 2 selected files. */
361 * Hides the menu bar if it is visible, makes the menu bar
362 * visible if it is hidden.
364 void toggleShowMenuBar();
366 /** Opens the settings dialog for Dolphin. */
369 /** Updates the state of all 'View' menu actions. */
370 void slotViewModeChanged();
372 /** Updates the state of the 'Show preview' menu action. */
373 void slotShowPreviewChanged();
375 /** Updates the state of the 'Show hidden files' menu action. */
376 void slotShowHiddenFilesChanged();
378 /** Updates the state of the 'Categorized sorting' menu action. */
379 void slotCategorizedSortingChanged();
381 /** Updates the state of the 'Sort by' actions. */
382 void slotSortingChanged(DolphinView::Sorting sorting
);
384 /** Updates the state of the 'Sort Ascending/Descending' action. */
385 void slotSortOrderChanged(Qt::SortOrder order
);
387 /** Updates the state of the 'Additional Information' actions. */
388 void slotAdditionalInfoChanged(KFileItemDelegate::InformationList info
);
391 * Updates the state of the 'Edit' menu actions and emits
392 * the signal selectionChanged().
394 void slotSelectionChanged(const KFileItemList
& selection
);
396 /** Emits the signal requestItemInfo(). */
397 void slotRequestItemInfo(const KFileItem
&);
400 * Updates the state of the 'Back' and 'Forward' menu
401 * actions corresponding the the current history.
403 void slotHistoryChanged();
405 /** Updates the state of the 'Show filter bar' menu action. */
406 void updateFilterBarAction(bool show
);
408 /** Open a new main window. */
409 void openNewMainWindow();
411 /** Toggles the active view if two views are shown within the main window. */
412 void toggleActiveView();
414 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
415 void slotDoingOperation(KonqFileUndoManager::CommandType type
);
418 DolphinMainWindow(int id
);
422 * Activates the given view, which means that
423 * all menu actions are applied to this view. When
424 * having a split view setup, the nonactive view
425 * is usually shown in darker colors.
427 void setActiveViewContainer(DolphinViewContainer
* view
);
430 void setupDockWidgets();
431 void updateHistory();
432 void updateEditActions();
433 void updateViewActions();
434 void updateGoActions();
435 void clearStatusBar();
438 * Connects the signals from the created DolphinView with
439 * the index \a viewIndex with the corresponding slots of
440 * the DolphinMainWindow. This method must be invoked each
441 * time a DolphinView has been created.
443 void connectViewSignals(int viewIndex
);
446 * Updates the text of the split action:
447 * If two views are shown, the text is set to "Split",
448 * otherwise the text is set to "Join". The icon
449 * is updated to match with the text and the currently active view.
451 void updateSplitAction();
454 * Helper method for the slots toggleDateInfo(), toggleSizeInfo()
455 * and toggleMimeInfo(). Applies \a info dependent from the current
456 * checked state of the action \a actionName to the file item delegate.
458 void toggleAdditionalInfo(const char* actionName
,
459 KFileItemDelegate::Information info
);
463 * DolphinMainWindow supports up to two views beside each other.
467 PrimaryView
= 0, ///< View shown on the left side of the main window.
468 SecondaryView
= 1 ///< View shown on the left side of the main window.
472 * Implements a custom error handling for the undo manager. This
473 * assures that all errors are shown in the status bar of Dolphin
474 * instead as modal error dialog with an OK button.
476 class UndoUiInterface
: public KonqFileUndoManager::UiInterface
479 UndoUiInterface(DolphinMainWindow
* mainWin
);
480 virtual ~UndoUiInterface();
481 virtual void jobError(KIO::Job
* job
);
484 DolphinMainWindow
* m_mainWin
;
488 KAction
* m_showMenuBar
;
489 QSplitter
* m_splitter
;
490 DolphinViewContainer
* m_activeViewContainer
;
493 DolphinViewContainer
* m_viewContainer
[SecondaryView
+ 1];
495 /// remember pending undo operations until they are finished
496 QList
<KonqFileUndoManager::CommandType
> m_undoCommandTypes
;
499 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
501 return m_activeViewContainer
;
504 inline bool DolphinMainWindow::isSplit() const
506 return m_viewContainer
[SecondaryView
] != 0;
509 inline KNewMenu
* DolphinMainWindow::newMenu() const
514 inline KAction
* DolphinMainWindow::showMenuBarAction() const
516 return m_showMenuBar
;
519 inline int DolphinMainWindow::getId() const
524 #endif // DOLPHIN_MAINWINDOW_H