]>
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_undo.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;
98 * Handles the dropping of URLs to the given
99 * destination. A context menu with the options
100 * 'Move Here', 'Copy Here', 'Link Here' and
101 * 'Cancel' is offered to the user.
102 * @param urls List of URLs which have been
104 * @param destination Destination URL, where the
105 * list or URLs should be moved,
106 * copied or linked to.
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
);
161 * This method is called when it is time for the app to save its
162 * properties for session management purposes.
164 void saveProperties(KConfig
*);
167 * This method is called when this app is restored. The KConfig
168 * object points to the session management config file that was saved
169 * with @ref saveProperties
171 void readProperties(KConfig
*);
174 /** Updates the 'Create New...' sub menu. */
175 void updateNewMenu();
178 * Let the user input a name for the selected item(s) and trigger
179 * a renaming afterwards.
183 /** Moves the selected items of the active view to the trash. */
186 /** Deletes the selected items of the active view. */
190 * Opens the properties window for the selected items of the
191 * active view. The properties windows shows information
192 * like name, size and permissions.
197 * Shows the error information from the places model
200 void slotHandlePlacesError(const QString
&message
);
203 * Shows the error information of the job \a job
206 void slotHandleJobError(KJob
* job
);
209 * Indicates in the status bar that the delete operation
210 * of the job \a job has been finished.
212 void slotDeleteFileFinished(KJob
* job
);
215 * Updates the state of the 'Undo' menu action dependent
216 * from the parameter \a available.
218 void slotUndoAvailable(bool available
);
220 /** Sets the text of the 'Undo' menu action to \a text. */
221 void slotUndoTextChanged(const QString
& text
);
223 /** Performs the current undo operation. */
227 * Copies all selected items to the clipboard and marks
228 * the items as cutted.
232 /** Copies all selected items to the clipboard. */
235 /** Pastes the clipboard data to the active view. */
239 * Updates the text of the paste action dependent from
240 * the number of items which are in the clipboard.
242 void updatePasteAction();
244 /** Selects all items from the active view. */
248 * Inverts the selection of all items of the active view:
249 * Selected items get nonselected and nonselected items get
252 void invertSelection();
254 /** The current active view is switched to the icons mode. */
257 /** The current active view is switched to the details mode. */
258 void setDetailsView();
260 /** The current active view is switched to the column mode. */
261 void setColumnView();
263 /** The sorting of the current view should be done by the name. */
266 /** The sorting of the current view should be done by the size. */
269 /** The sorting of the current view should be done by the date. */
272 /** The sorting of the current view should be done by the permissions. */
273 void sortByPermissions();
275 /** The sorting of the current view should be done by the owner. */
278 /** The sorting of the current view should be done by the group. */
281 /** The sorting of the current view should be done by the type. */
284 /** The sorting of the current view should be done by the rating. */
287 /** The sorting of the current view should be done by tags. */
290 /** Switches between an ascending and descending sorting order. */
291 void toggleSortOrder();
293 /** Switches between sorting by categories or not. */
294 void toggleSortCategorization();
296 /** Switches between showing the MIME type as additional information for the item or not. */
297 void toggleMimeInfo();
299 /** Switches between showing the size as additional information for the item or not. */
300 void toggleSizeInfo();
302 /** Switchtes between showing the date as additional information for the item or not. */
303 void toggleDateInfo();
306 * Switches between one and two views:
307 * If one view is visible, it will get split into two views.
308 * If already two views are visible, the nonactivated view gets closed.
310 void toggleSplitView();
312 /** Reloads the current active view. */
315 /** Stops the loading process for the current active view. */
318 /** Switches between showing a preview of the file content and showing the icon. */
319 void togglePreview();
322 * Switches between showing and hiding of hidden marked files dependent
323 * from the current state of the 'Show Hidden Files' menu toggle action.
325 void toggleShowHiddenFiles();
328 * Toggles between showing and hiding of the filter bar dependent
329 * from the current state of the 'Show Filter Bar' menu toggle action.
331 void toggleFilterBarVisibility();
333 /** Increases the size of the current set view mode. */
336 /** Decreases the size of the current set view mode. */
340 * Toggles between edit and brose mode of the navigation bar.
342 void toggleEditLocation();
345 * Switches to the edit mode of the navigation bar. If the edit mode is
346 * already active, it is assured that the navigation bar get focused.
351 * Opens the view properties dialog, which allows to modify the properties
352 * of the currently active view.
354 void adjustViewProperties();
356 /** Goes back on step of the URL history. */
359 /** Goes forward one step of the URL history. */
362 /** Goes up one hierarchy of the current URL. */
365 /** Goes to the home URL. */
368 /** Opens KFind for the current shown directory. */
371 /** Opens Kompare for 2 selected files. */
374 /** Opens the settings dialog for Dolphin. */
377 /** Updates the state of all 'View' menu actions. */
378 void slotViewModeChanged();
380 /** Updates the state of the 'Show preview' menu action. */
381 void slotShowPreviewChanged();
383 /** Updates the state of the 'Show hidden files' menu action. */
384 void slotShowHiddenFilesChanged();
386 /** Updates the state of the 'Categorized sorting' menu action. */
387 void slotCategorizedSortingChanged();
389 /** Updates the state of the 'Sort by' actions. */
390 void slotSortingChanged(DolphinView::Sorting sorting
);
392 /** Updates the state of the 'Sort Ascending/Descending' action. */
393 void slotSortOrderChanged(Qt::SortOrder order
);
395 /** Updates the state of the 'Additional Information' actions. */
396 void slotAdditionalInfoChanged(KFileItemDelegate::InformationList info
);
399 * Updates the state of the 'Edit' menu actions and emits
400 * the signal selectionChanged().
402 void slotSelectionChanged(const KFileItemList
& selection
);
404 /** Emits the signal requestItemInfo(). */
405 void slotRequestItemInfo(const KFileItem
&);
408 * Updates the state of the 'Back' and 'Forward' menu
409 * actions corresponding the the current history.
411 void slotHistoryChanged();
413 /** Updates the state of the 'Show filter bar' menu action. */
414 void updateFilterBarAction(bool show
);
416 /** Open a new main window. */
417 void openNewMainWindow();
419 /** Toggles the active view if two views are shown within the main window. */
420 void toggleActiveView();
423 DolphinMainWindow(int id
);
427 * Activates the given view, which means that
428 * all menu actions are applied to this view. When
429 * having a split view setup, the nonactive view
430 * is usually shown in darker colors.
432 void setActiveViewContainer(DolphinViewContainer
* view
);
435 void setupDockWidgets();
436 void updateHistory();
437 void updateEditActions();
438 void updateViewActions();
439 void updateGoActions();
440 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
441 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
442 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
443 void clearStatusBar();
446 * Connects the signals from the created DolphinView with
447 * the index \a viewIndex with the corresponding slots of
448 * the DolphinMainWindow. This method must be invoked each
449 * time a DolphinView has been created.
451 void connectViewSignals(int viewIndex
);
454 * Updates the text of the split action:
455 * If two views are shown, the text is set to "Split",
456 * otherwise the text is set to "Join". The icon
457 * is updated to match with the text and the currently active view.
459 void updateSplitAction();
462 * Helper method for the slots toggleDateInfo(), toggleSizeInfo()
463 * and toggleMimeInfo(). Applies \a info dependent from the current
464 * checked state of the action \a actionName to the file item delegate.
466 void toggleAdditionalInfo(const char* actionName
,
467 KFileItemDelegate::Information info
);
471 * DolphinMainWindow supports up to two views beside each other.
475 PrimaryView
= 0, ///< View shown on the left side of the main window.
476 SecondaryView
= 1 ///< View shown on the left side of the main window.
480 * Implements a custom error handling for the undo manager. This
481 * assures that all errors are shown in the status bar of Dolphin
482 * instead as modal error dialog with an OK button.
484 class UndoUiInterface
: public KonqUndoManager::UiInterface
487 UndoUiInterface(DolphinMainWindow
* mainWin
);
488 virtual ~UndoUiInterface();
489 virtual void jobError(KIO::Job
* job
);
492 DolphinMainWindow
* m_mainWin
;
496 QSplitter
* m_splitter
;
497 DolphinViewContainer
* m_activeViewContainer
;
500 DolphinViewContainer
* m_viewContainer
[SecondaryView
+ 1];
502 /// remember pending undo operations until they are finished
503 QList
<KonqUndoManager::CommandType
> m_undoCommandTypes
;
506 inline DolphinViewContainer
* DolphinMainWindow::activeViewContainer() const
508 return m_activeViewContainer
;
511 inline bool DolphinMainWindow::isSplit() const
513 return m_viewContainer
[SecondaryView
] != 0;
516 inline KNewMenu
* DolphinMainWindow::newMenu() const
521 inline int DolphinMainWindow::getId() const
526 #endif // DOLPHIN_MAINWINDOW_H