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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
22 #ifndef _DOLPHIN_MAINWINDOW_H_
23 #define _DOLPHIN_MAINWINDOW_H_
29 #include <kapplication.h>
30 #include <kmainwindow.h>
31 #include <q3valuelist.h>
32 #include <q3ptrlist.h>
35 #include <QCloseEvent>
36 #include <ksortablelist.h>
39 #include "dolphinview.h"
40 #include "undomanager.h"
52 class DolphinApplication
;
55 * @short Main window for Dolphin.
57 * Handles the menus, toolbars and Dolphin views.
59 * @author Peter Penz <peter.penz@gmx.at>
61 class DolphinMainWindow
: public KMainWindow
64 friend class DolphinApplication
;
66 virtual ~DolphinMainWindow();
69 * Activates the given view, which means that
70 * all menu actions are applied to this view. When
71 * having a split view setup the nonactive view
72 * is usually shown in darker colors.
74 void setActiveView(DolphinView
* view
);
77 * Returns the currently active view. See
78 * DolphinMainWindow::setActiveView() for more details.
80 DolphinView
* activeView() const { return m_activeView
; }
83 * Handles the dropping of Urls to the given
84 * destination. A context menu with the options
85 * 'Move Here', 'Copy Here', 'Link Here' and
86 * 'Cancel' is offered to the user.
87 * @param urls List of Urls which have been
89 * @param destination Destination Url, where the
90 * list or Urls should be moved,
91 * copied or linked to.
93 void dropUrls(const KUrl::List
& urls
,
94 const KUrl
& destination
);
97 * Returns 'true', if the clipboard contains data
98 * which has been cutted by the Cut action (Ctrl + X).
100 bool clipboardContainsCutData() const { return m_clipboardContainsCutData
; }
103 * Returns the list of actions which are part of the file group
104 * of the 'Create New...' sub menu. Usually the list contains actions
105 * for creating folders, text files, HTML files etc.
107 const Q3PtrList
<KAction
>& fileGroupActions() const { return m_fileGroupActions
; }
108 //const QPtrList<KAction>& linkGroupActions() const { return m_linkGroupActions; }
109 //const QPtrList<KAction>& linkToDeviceActions() const { return m_linkToDeviceActions; }
112 * Refreshs the views of the main window by recreating them dependent from
113 * the given Dolphin settings.
119 * Is send if the active view has been changed in
120 * the split view mode.
122 void activeViewChanged();
125 * Is send if the selection of the currently active view has
128 void selectionChanged();
132 * Updates the state of the 'Back' and 'Forward' menu
133 * actions corresponding the the current history.
135 void slotHistoryChanged();
138 * Updates the caption of the main window and the state
139 * of all menu actions which depend from a changed Url.
141 void slotUrlChanged(const KUrl
& url
);
144 * Go to the given Url.
146 void slotUrlChangeRequest(const KUrl
& url
);
148 /** Updates the state of all 'View' menu actions. */
149 void slotViewModeChanged();
151 /** Updates the state of the 'Show hidden files' menu action. */
152 void slotShowHiddenFilesChanged();
154 /** Updates the state of the 'Show filter bar' menu action. */
155 void slotShowFilterBarChanged();
157 /** Updates the state of the 'Sort by' actions. */
158 void slotSortingChanged(DolphinView::Sorting sorting
);
160 /** Updates the state of the 'Sort Ascending/Descending' action. */
161 void slotSortOrderChanged(Qt::SortOrder order
);
163 /** Updates the state of the 'Edit' menu actions. */
164 void slotSelectionChanged();
166 /** Executes Redo operation */
169 /** @see slotUndo() */
172 /** Open a new mainwindow */
173 void slotNewMainWindow();
176 /** @see QMainWindow::closeEvent */
177 virtual void closeEvent(QCloseEvent
* event
);
180 * This method is called when it is time for the app to save its
181 * properties for session management purposes.
183 void saveProperties(KConfig
*);
186 * This method is called when this app is restored. The KConfig
187 * object points to the session management config file that was saved
188 * with @ref saveProperties
190 void readProperties(KConfig
*);
193 /** Opens an input dialog for creating a new folder. */
196 /** Creates a file with the MIME type given by the sender. */
199 /** Renames the selected item of the active view. */
202 /** Moves the selected items of the active view to the trash. */
205 /** Deletes the selected items of the active view. */
209 * Opens the properties window for the selected items of the
210 * active view. The properties windows shows informations
211 * like name, size and permissions.
215 /** Stores all settings and quits Dolphin. */
219 * Shows the error information of the job \a job
222 void slotHandleJobError(KJob
* job
);
225 * Indicates in the status bar that the delete operation
226 * of the job \a job has been finished.
228 void slotDeleteFileFinished(KJob
* job
);
231 * Updates the state of the 'Undo' menu action dependent
232 * from the parameter \a available.
234 void slotUndoAvailable(bool available
);
236 /** Sets the text of the 'Undo' menu action to \a text. */
237 void slotUndoTextChanged(const QString
& text
);
240 * Updates the state of the 'Redo' menu action dependent
241 * from the parameter \a available.
243 void slotRedoAvailable(bool available
);
245 /** Sets the text of the 'Redo' menu action to \a text. */
246 void slotRedoTextChanged(const QString
& text
);
249 * Copies all selected items to the clipboard and marks
250 * the items as cutted.
254 /** Copies all selected items to the clipboard. */
257 /** Pastes the clipboard data to the active view. */
261 * Updates the text of the paste action dependent from
262 * the number of items which are in the clipboard.
264 void updatePasteAction();
266 /** Selects all items from the active view. */
270 * Inverts the selection of all items of the active view:
271 * Selected items get nonselected and nonselected items get
274 void invertSelection();
276 /** The current active view is switched to the icons mode. */
279 /** The current active view is switched to the details mode. */
280 void setDetailsView();
282 /** The current active view is switched to the previews mode. */
283 void setPreviewsView();
285 /** The sorting of the current view should be done by the name. */
288 /** The sorting of the current view should be done by the size. */
291 /** The sorting of the current view should be done by the date. */
294 /** Switches between an ascending and descending sorting order. */
295 void toggleSortOrder();
298 * Switches between one and two views:
299 * If one view is visible, it will get split into two views.
300 * If already two views are visible, the nonactivated view gets closed.
302 void toggleSplitView();
304 /** Reloads the current active view. */
307 /** Stops the loading process for the current active view. */
311 * Switches between showing and hiding of hidden marked files dependent
312 * from the current state of the 'Show Hidden Files' menu toggle action.
314 void showHiddenFiles();
317 * Switches between showing and hiding of the filter bar dependent
318 * from the current state of the 'Show Filter Bar' menu toggle action.
320 void showFilterBar();
322 /** Increases the size of the current set view mode. */
325 /** Decreases the size of the current set view mode. */
329 * Toggles between edit and brose mode of the navigation bar.
331 void toggleEditLocation();
334 * Switches to the edit mode of the navigation bar. If the edit mode is
335 * already active, it is assured that the navigation bar get focused.
340 * Opens the view properties dialog, which allows to modify the properties
341 * of the currently active view.
343 void adjustViewProperties();
345 /** Goes back on step of the Url history. */
348 /** Goes forward one step of the Url history. */
351 /** Goes up one hierarchy of the current Url. */
354 /** Goes to the home Url. */
357 /** Opens a terminal for the current shown directory. */
360 /** Opens KFind for the current shown directory. */
363 /** Opens Kompare for 2 selected files. */
366 /** Opens the settings dialog for Dolphin. */
370 * Adds the undo operation given by \a job
371 * to the UndoManager.
373 void addUndoOperation(KJob
* job
);
376 void toggleSidebar();
379 * Stores the current sidebar width and closes
391 void setupCreateNewMenuActions();
392 void updateHistory();
393 void updateEditActions();
394 void updateViewActions();
395 void updateGoActions();
396 void updateViewProperties(const KUrl::List
& urls
);
397 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
398 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
399 void addPendingUndoJob(KIO::Job
* job
,
400 DolphinCommand::Type commandType
,
401 const KUrl::List
& source
,
403 void clearStatusBar();
406 QSplitter
* m_splitter
;
408 DolphinView
* m_activeView
;
411 * DolphinMainWindowsupports only one or two views, which
412 * are handled internally as primary and secondary view.
419 DolphinView
* m_view
[SecondaryIdx
+ 1];
421 /// If set to true, the clipboard contains data which should be cutted after pasting.
422 bool m_clipboardContainsCutData
;
425 * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
426 * operation after they have been finished successfully. When an asynchronous
427 * operation is started, it is added to a pending undo jobs list in the meantime.
428 * As soon as the job has been finished, the operation is added to the undo mangager.
430 * @see DolphinMainWindow::addPendingUndoJob
431 * @see DolphinMainWindow::addUndoOperation
436 DolphinCommand command
;
438 Q3ValueList
<UndoInfo
> m_pendingUndoJobs
;
440 /** Contains meta information for creating files. */
441 struct CreateFileEntry
445 QString templatePath
;
450 Q3PtrList
<KAction
> m_fileGroupActions
;
451 KSortableList
<CreateFileEntry
,QString
> m_createFileTemplates
;
453 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
454 // and DolphinMainWindow::linkToDeviceActions() in for details.
455 //QPtrList<KAction> m_linkGroupActions;
456 //QPtrList<KAction> m_linkToDeviceActions;
459 #endif // _DOLPHIN_H_