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 <kxmlguiwindow.h>
29 #include <ksortablelist.h>
30 #include <konq_undo.h>
32 #include <QtCore/QList>
34 class DolphinApplication
;
40 * @short Main window for Dolphin.
42 * Handles the menus, toolbars and Dolphin views.
44 class DolphinMainWindow
: public KXmlGuiWindow
47 Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow")
48 Q_PROPERTY(int id READ getId SCRIPTABLE
true)
49 friend class DolphinApplication
;
52 virtual ~DolphinMainWindow();
55 * Activates the given view, which means that
56 * all menu actions are applied to this view. When
57 * having a split view setup the nonactive view
58 * is usually shown in darker colors.
60 void setActiveView(DolphinView
* view
);
63 * Returns the currently active view. See
64 * DolphinMainWindow::setActiveView() for more details.
66 DolphinView
* activeView() const
71 /** Renames the item represented by \a oldUrl to \a newUrl. */
72 void rename(const KUrl
& oldUrl
, const KUrl
& newUrl
);
75 * Refreshs the views of the main window by recreating them dependent from
76 * the given Dolphin settings.
81 * Returns the 'Create New...' sub menu which also can be shared
82 * with other menus (e. g. a context menu).
84 KNewMenu
* newMenu() const
91 * Handles the dropping of URLs to the given
92 * destination. A context menu with the options
93 * 'Move Here', 'Copy Here', 'Link Here' and
94 * 'Cancel' is offered to the user.
95 * @param urls List of URLs which have been
97 * @param destination Destination URL, where the
98 * list or URLs should be moved,
99 * copied or linked to.
101 void dropUrls(const KUrl::List
& urls
,
102 const KUrl
& destination
);
105 * Returns the main window ID used through DBus.
113 * Inform all affected dolphin components (sidebars, views) of an URL
116 void changeUrl(const KUrl
& url
);
119 * Inform all affected dolphin components that a selection change is
122 void changeSelection(const KFileItemList
& selection
);
124 /** Stores all settings and quits Dolphin. */
129 * Is send if the active view has been changed in
130 * the split view mode.
132 void activeViewChanged();
135 * Is sent if the selection of the currently active view has
138 void selectionChanged(const KFileItemList
& selection
);
141 * Is sent if the url of the currently active view has
144 void urlChanged(const KUrl
& url
);
147 * Is emitted if information of an item is requested to be shown e. g. in the sidebar.
148 * It the URL is empty, no item information request is pending.
150 void requestItemInfo(const KUrl
& url
);
153 /** @see QMainWindow::closeEvent */
154 virtual void closeEvent(QCloseEvent
* event
);
157 * This method is called when it is time for the app to save its
158 * properties for session management purposes.
160 void saveProperties(KConfig
*);
163 * This method is called when this app is restored. The KConfig
164 * object points to the session management config file that was saved
165 * with @ref saveProperties
167 void readProperties(KConfig
*);
170 /** Updates the 'Create New...' sub menu. */
171 void updateNewMenu();
174 * Let the user input a name for the selected item(s) and trigger
175 * a renaming afterwards.
179 /** Moves the selected items of the active view to the trash. */
182 /** Deletes the selected items of the active view. */
186 * Opens the properties window for the selected items of the
187 * active view. The properties windows shows information
188 * like name, size and permissions.
193 * Shows the error information of the job \a job
196 void slotHandleJobError(KJob
* job
);
199 * Indicates in the status bar that the delete operation
200 * of the job \a job has been finished.
202 void slotDeleteFileFinished(KJob
* job
);
205 * Updates the state of the 'Undo' menu action dependent
206 * from the parameter \a available.
208 void slotUndoAvailable(bool available
);
210 /** Sets the text of the 'Undo' menu action to \a text. */
211 void slotUndoTextChanged(const QString
& text
);
213 /** Performs the current undo operation. */
217 * Copies all selected items to the clipboard and marks
218 * the items as cutted.
222 /** Copies all selected items to the clipboard. */
225 /** Pastes the clipboard data to the active view. */
229 * Updates the text of the paste action dependent from
230 * the number of items which are in the clipboard.
232 void updatePasteAction();
234 /** Selects all items from the active view. */
238 * Inverts the selection of all items of the active view:
239 * Selected items get nonselected and nonselected items get
242 void invertSelection();
244 /** The current active view is switched to the icons mode. */
247 /** The current active view is switched to the details mode. */
248 void setDetailsView();
250 /** The current active view is switched to the column mode. */
251 void setColumnView();
253 /** The sorting of the current view should be done by the name. */
256 /** The sorting of the current view should be done by the size. */
259 /** The sorting of the current view should be done by the date. */
262 /** The sorting of the current view should be done by the permissions. */
263 void sortByPermissions();
265 /** The sorting of the current view should be done by the owner. */
268 /** The sorting of the current view should be done by the group. */
271 /** The sorting of the current view should be done by the type. */
274 /** Switches between an ascending and descending sorting order. */
275 void toggleSortOrder();
277 /** Switches between sorting by categories or not. */
278 void toggleSortCategorization();
281 * Clears any additional information for an item except for the
286 /** Shows the MIME type as additional information for the item. */
289 /** Shows the size as additional information for the item. */
292 /** Shows the date as additional information for the item. */
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. */
364 /** Opens the settings dialog for Dolphin. */
367 /** Updates the state of all 'View' menu actions. */
368 void slotViewModeChanged();
370 /** Updates the state of the 'Show preview' menu action. */
371 void slotShowPreviewChanged();
373 /** Updates the state of the 'Show hidden files' menu action. */
374 void slotShowHiddenFilesChanged();
376 /** Updates the state of the 'Categorized sorting' menu action. */
377 void slotCategorizedSortingChanged();
379 /** Updates the state of the 'Sort by' actions. */
380 void slotSortingChanged(DolphinView::Sorting sorting
);
382 /** Updates the state of the 'Sort Ascending/Descending' action. */
383 void slotSortOrderChanged(Qt::SortOrder order
);
385 /** Updates the state of the 'Additional Information' actions. */
386 void slotAdditionalInfoChanged(KFileItemDelegate::AdditionalInformation info
);
389 * Updates the state of the 'Edit' menu actions and emits
390 * the signal selectionChanged().
392 void slotSelectionChanged(const KFileItemList
& selection
);
394 /** Emits the signal requestItemInfo(). */
395 void slotRequestItemInfo(const KUrl
& url
);
398 * Updates the state of the 'Back' and 'Forward' menu
399 * actions corresponding the the current history.
401 void slotHistoryChanged();
403 /** Updates the state of the 'Show filter bar' menu action. */
404 void updateFilterBarAction(bool show
);
406 /** Open a new main window. */
407 void openNewMainWindow();
410 DolphinMainWindow(int id
);
416 void setupDockWidgets();
417 void updateHistory();
418 void updateEditActions();
419 void updateViewActions();
420 void updateGoActions();
421 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
422 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
423 void linkUrls(const KUrl::List
& source
, const KUrl
& dest
);
424 void clearStatusBar();
427 * Connects the signals from the created DolphinView with
428 * the index \a viewIndex with the corresponding slots of
429 * the DolphinMainWindow. This method must be invoked each
430 * time a DolphinView has been created.
432 void connectViewSignals(int viewIndex
);
436 * DolphinMainWindowsupports only one or two views, which
437 * are handled internally as primary and secondary view.
446 * Implements a custom error handling for the undo manager. This
447 * assures that all errors are shown in the status bar of Dolphin
448 * instead as modal error dialog with an OK button.
450 class UndoUiInterface
: public KonqUndoManager::UiInterface
453 UndoUiInterface(DolphinMainWindow
* mainWin
);
454 virtual ~UndoUiInterface();
455 virtual void jobError(KIO::Job
* job
);
458 DolphinMainWindow
* m_mainWin
;
462 QSplitter
* m_splitter
;
463 DolphinView
* m_activeView
;
466 DolphinView
* m_view
[SecondaryIdx
+ 1];
468 /// remember pending undo operations until they are finished
469 QList
<KonqUndoManager::CommandType
> m_undoCommandTypes
;
472 #endif // DOLPHIN_MAINWINDOW_H