]>
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. A context menu with the options
106 * 'Move Here', 'Copy Here', 'Link Here' and
107 * 'Cancel' is offered to the user.
108 * @param urls List of URLs which have been
110 * @param destination Destination URL, where the
111 * list or URLs should be moved,
112 * copied or linked to.
114 void dropUrls(const KUrl::List
& urls
,
115 const KUrl
& destination
);
118 * Returns the main window ID used through DBus.
123 * Inform all affected dolphin components (sidebars, views) of an URL
126 void changeUrl(const KUrl
& url
);
129 * Inform all affected dolphin components that a selection change is
132 void changeSelection(const KFileItemList
& selection
);
134 /** Stores all settings and quits Dolphin. */
139 * Is send if the active view has been changed in
140 * the split view mode.
142 void activeViewChanged();
145 * Is sent if the selection of the currently active view has
148 void selectionChanged(const KFileItemList
& selection
);
151 * Is sent if the url of the currently active view has
154 void urlChanged(const KUrl
& url
);
157 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
158 * If item is null, no item information request is pending.
160 void requestItemInfo(const KFileItem
& item
);
163 /** @see QMainWindow::closeEvent() */
164 virtual void closeEvent(QCloseEvent
* event
);
166 /** @see KMainWindow::saveProperties() */
167 virtual void saveProperties(KConfigGroup
& group
);
169 /** @see KMainWindow::readProperties() */
170 virtual void readProperties(const KConfigGroup
& group
);
173 /** Updates the 'Create New...' sub menu. */
174 void updateNewMenu();
177 * Let the user input a name for the selected item(s) and trigger
178 * a renaming afterwards.
182 /** Moves the selected items of the active view to the trash. */
185 /** Deletes the selected items of the active view. */
189 * Opens the properties window for the selected items of the
190 * active view. The properties windows shows information
191 * like name, size and permissions.
196 * Shows the error information from the places model
199 void slotHandlePlacesError(const QString
&message
);
202 * Updates the state of the 'Undo' menu action dependent
203 * from the parameter \a available.
205 void slotUndoAvailable(bool available
);
207 /** Sets the text of the 'Undo' menu action to \a text. */
208 void slotUndoTextChanged(const QString
& text
);
210 /** Performs the current undo operation. */
214 * Copies all selected items to the clipboard and marks
215 * the items as cutted.
219 /** Copies all selected items to the clipboard. */
222 /** Pastes the clipboard data to the active view. */
226 * Updates the text of the paste action dependent from
227 * the number of items which are in the clipboard.
229 void updatePasteAction();
231 /** Selects all items from the active view. */
235 * Inverts the selection of all items of the active view:
236 * Selected items get nonselected and nonselected items get
239 void invertSelection();
241 /** The current active view is switched to a new view mode. */
242 void setViewMode(QAction
*);
244 /** The sorting of the current view should be done by the name. */
247 /** The sorting of the current view should be done by the size. */
250 /** The sorting of the current view should be done by the date. */
253 /** The sorting of the current view should be done by the permissions. */
254 void sortByPermissions();
256 /** The sorting of the current view should be done by the owner. */
259 /** The sorting of the current view should be done by the group. */
262 /** The sorting of the current view should be done by the type. */
265 /** The sorting of the current view should be done by the rating. */
268 /** The sorting of the current view should be done by tags. */
271 /** Switches between an ascending and descending sorting order. */
272 void toggleSortOrder();
274 /** Switches between sorting by categories or not. */
275 void toggleSortCategorization();
277 /** Switches between showing the size as additional information for the item or not. */
278 void toggleSizeInfo();
280 /** Switchtes between showing the date as additional information for the item or not. */
281 void toggleDateInfo();
283 /** Switchtes between showing the permissions as additional information for the item or not. */
284 void togglePermissionsInfo();
286 /** Switchtes between showing the owner as additional information for the item or not. */
287 void toggleOwnerInfo();
289 /** Switchtes between showing the group as additional information for the item or not. */
290 void toggleGroupInfo();
292 /** Switches between showing the MIME type as additional information for the item or not. */
293 void toggleMimeInfo();
296 * Switches between one and two views:
297 * If one view is visible, it will get split into two views.
298 * If already two views are visible, the nonactivated view gets closed.
300 void toggleSplitView();
302 /** Reloads the current active view. */
305 /** Stops the loading process for the current active view. */
308 /** Switches between showing a preview of the file content and showing the icon. */
309 void togglePreview();
312 * Switches between showing and hiding of hidden marked files dependent
313 * from the current state of the 'Show Hidden Files' menu toggle action.
315 void toggleShowHiddenFiles();
318 * Toggles between showing and hiding of the filter bar dependent
319 * from the current state of the 'Show Filter Bar' menu toggle action.
321 void toggleFilterBarVisibility();
323 /** Increases the size of the current set view mode. */
326 /** Decreases the size of the current set view mode. */
330 * Toggles between edit and brose mode of the navigation bar.
332 void toggleEditLocation();
335 * Switches to the edit mode of the navigation bar. If the edit mode is
336 * already active, it is assured that the navigation bar get focused.
341 * Opens the view properties dialog, which allows to modify the properties
342 * of the currently active view.
344 void adjustViewProperties();
346 /** Goes back on step of the URL history. */
349 /** Goes forward one step of the URL history. */
352 /** Goes up one hierarchy of the current URL. */
355 /** Goes to the home URL. */
358 /** Opens KFind for the current shown directory. */
361 /** Opens Kompare for 2 selected files. */
365 * Hides the menu bar if it is visible, makes the menu bar
366 * visible if it is hidden.
368 void toggleShowMenuBar();
370 /** Opens the settings dialog for Dolphin. */
373 /** Updates the state of all 'View' menu actions. */
374 void slotViewModeChanged();
376 /** Updates the state of the 'Show preview' menu action. */
377 void slotShowPreviewChanged();
379 /** Updates the state of the 'Show hidden files' menu action. */
380 void slotShowHiddenFilesChanged();
382 /** Updates the state of the 'Categorized sorting' menu action. */
383 void slotCategorizedSortingChanged();
385 /** Updates the state of the 'Sort by' actions. */
386 void slotSortingChanged(DolphinView::Sorting sorting
);
388 /** Updates the state of the 'Sort Ascending/Descending' action. */
389 void slotSortOrderChanged(Qt::SortOrder order
);
391 /** Updates the state of the 'Additional Information' actions. */
392 void slotAdditionalInfoChanged(KFileItemDelegate::InformationList info
);
395 * Updates the state of the 'Edit' menu actions and emits
396 * the signal selectionChanged().
398 void slotSelectionChanged(const KFileItemList
& selection
);
400 /** Emits the signal requestItemInfo(). */
401 void slotRequestItemInfo(const KFileItem
&);
404 * Updates the state of the 'Back' and 'Forward' menu
405 * actions corresponding the the current history.
407 void slotHistoryChanged();
409 /** Updates the state of the 'Show filter bar' menu action. */
410 void updateFilterBarAction(bool show
);
412 /** Open a new main window. */
413 void openNewMainWindow();
415 /** Toggles the active view if two views are shown within the main window. */
416 void toggleActiveView();
418 /** Called when the view is doing a file operation, like renaming, copying, moving etc. */
419 void slotDoingOperation(KonqFileUndoManager::CommandType type
);
422 DolphinMainWindow(int id
);
426 * Activates the given view, which means that
427 * all menu actions are applied to this view. When
428 * having a split view setup, the nonactive view
429 * is usually shown in darker colors.
431 void setActiveViewContainer(DolphinViewContainer
* view
);
434 void setupDockWidgets();
435 void updateHistory();
436 void updateEditActions();
437 void updateViewActions();
438 void updateGoActions();
439 void clearStatusBar();
442 * Connects the signals from the created DolphinView with
443 * the index \a viewIndex with the corresponding slots of
444 * the DolphinMainWindow. This method must be invoked each
445 * time a DolphinView has been created.
447 void connectViewSignals(int viewIndex
);
450 * Updates the text of the split action:
451 * If two views are shown, the text is set to "Split",
452 * otherwise the text is set to "Join". The icon
453 * is updated to match with the text and the currently active view.
455 void updateSplitAction();
458 * Helper method for the slots toggleDateInfo(), toggleSizeInfo()
459 * and toggleMimeInfo(). Applies \a info dependent from the current
460 * checked state of the action \a actionName to the file item delegate.
462 void toggleAdditionalInfo(const char* actionName
,
463 KFileItemDelegate::Information info
);
467 * DolphinMainWindow supports up to two views beside each other.
471 PrimaryView
= 0, ///< View shown on the left side of the main window.
472 SecondaryView
= 1 ///< View shown on the left side of the main window.
476 * Implements a custom error handling for the undo manager. This
477 * assures that all errors are shown in the status bar of Dolphin
478 * instead as modal error dialog with an OK button.
480 class UndoUiInterface
: public KonqFileUndoManager::UiInterface
483 UndoUiInterface(DolphinMainWindow
* mainWin
);
484 virtual ~UndoUiInterface();
485 virtual void jobError(KIO::Job
* job
);
488 DolphinMainWindow
* m_mainWin
;
492 KAction
* m_showMenuBar
;
493 QSplitter
* m_splitter
;
494 DolphinViewContainer
* m_activeViewContainer
;
497 DolphinViewContainer
* m_viewContainer
[SecondaryView
+ 1];
499 /// remember pending undo operations until they are finished
500 QList
<KonqFileUndoManager::CommandType
> m_undoCommandTypes
;
503 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
505 return m_activeViewContainer
;
508 inline bool DolphinMainWindow::isSplit() const
510 return m_viewContainer
[SecondaryView
] != 0;
513 inline KNewMenu
* DolphinMainWindow::newMenu() const
518 inline KAction
* DolphinMainWindow::showMenuBarAction() const
520 return m_showMenuBar
;
523 inline int DolphinMainWindow::getId() const
528 #endif // DOLPHIN_MAINWINDOW_H