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_
29 #include <kapplication.h>
30 #include <kmainwindow.h>
31 #include <ksortablelist.h>
34 #include <q3valuelist.h>
35 #include <q3ptrlist.h>
37 #include <QCloseEvent>
40 #include "dolphinview.h"
41 #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 QLinkedList
<QAction
*> fileGroupActions() const { return m_fileGroupActions
; }
108 //QLinkedList<QAction*>& linkGroupActions() const { return m_linkGroupActions; }
109 //QLinkedList<QAction*>& 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();
131 /** @see QMainWindow::closeEvent */
132 virtual void closeEvent(QCloseEvent
* event
);
135 * This method is called when it is time for the app to save its
136 * properties for session management purposes.
138 void saveProperties(KConfig
*);
141 * This method is called when this app is restored. The KConfig
142 * object points to the session management config file that was saved
143 * with @ref saveProperties
145 void readProperties(KConfig
*);
148 /** Opens an input dialog for creating a new folder. */
151 /** Creates a file with the MIME type given by the sender. */
154 /** Renames the selected item of the active view. */
157 /** Moves the selected items of the active view to the trash. */
160 /** Deletes the selected items of the active view. */
164 * Opens the properties window for the selected items of the
165 * active view. The properties windows shows informations
166 * like name, size and permissions.
170 /** Stores all settings and quits Dolphin. */
174 * Shows the error information of the job \a job
177 void slotHandleJobError(KJob
* job
);
180 * Indicates in the status bar that the delete operation
181 * of the job \a job has been finished.
183 void slotDeleteFileFinished(KJob
* job
);
186 * Updates the state of the 'Undo' menu action dependent
187 * from the parameter \a available.
189 void slotUndoAvailable(bool available
);
191 /** Sets the text of the 'Undo' menu action to \a text. */
192 void slotUndoTextChanged(const QString
& text
);
195 * Updates the state of the 'Redo' menu action dependent
196 * from the parameter \a available.
198 void slotRedoAvailable(bool available
);
200 /** Sets the text of the 'Redo' menu action to \a text. */
201 void slotRedoTextChanged(const QString
& text
);
204 * Copies all selected items to the clipboard and marks
205 * the items as cutted.
209 /** Copies all selected items to the clipboard. */
212 /** Pastes the clipboard data to the active view. */
216 * Updates the text of the paste action dependent from
217 * the number of items which are in the clipboard.
219 void updatePasteAction();
221 /** Selects all items from the active view. */
225 * Inverts the selection of all items of the active view:
226 * Selected items get nonselected and nonselected items get
229 void invertSelection();
231 /** The current active view is switched to the icons mode. */
234 /** The current active view is switched to the details mode. */
235 void setDetailsView();
237 /** The current active view is switched to the previews mode. */
238 void setPreviewsView();
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 /** Switches between an ascending and descending sorting order. */
250 void toggleSortOrder();
253 * Switches between one and two views:
254 * If one view is visible, it will get split into two views.
255 * If already two views are visible, the nonactivated view gets closed.
257 void toggleSplitView();
259 /** Reloads the current active view. */
262 /** Stops the loading process for the current active view. */
266 * Switches between showing and hiding of hidden marked files dependent
267 * from the current state of the 'Show Hidden Files' menu toggle action.
269 void showHiddenFiles();
272 * Switches between showing and hiding of the filter bar dependent
273 * from the current state of the 'Show Filter Bar' menu toggle action.
275 void showFilterBar();
277 /** Increases the size of the current set view mode. */
280 /** Decreases the size of the current set view mode. */
284 * Toggles between edit and brose mode of the navigation bar.
286 void toggleEditLocation();
289 * Switches to the edit mode of the navigation bar. If the edit mode is
290 * already active, it is assured that the navigation bar get focused.
295 * Opens the view properties dialog, which allows to modify the properties
296 * of the currently active view.
298 void adjustViewProperties();
300 /** Goes back on step of the Url history. */
303 /** Goes forward one step of the Url history. */
306 /** Goes up one hierarchy of the current Url. */
309 /** Goes to the home Url. */
312 /** Opens a terminal for the current shown directory. */
315 /** Opens KFind for the current shown directory. */
318 /** Opens Kompare for 2 selected files. */
321 /** Opens the settings dialog for Dolphin. */
325 * Adds the undo operation given by \a job
326 * to the UndoManager.
328 void addUndoOperation(KJob
* job
);
330 /** Updates the state of all 'View' menu actions. */
331 void slotViewModeChanged();
333 /** Updates the state of the 'Show hidden files' menu action. */
334 void slotShowHiddenFilesChanged();
336 /** Updates the state of the 'Sort by' actions. */
337 void slotSortingChanged(DolphinView::Sorting sorting
);
339 /** Updates the state of the 'Sort Ascending/Descending' action. */
340 void slotSortOrderChanged(Qt::SortOrder order
);
342 /** Updates the state of the 'Edit' menu actions. */
343 void slotSelectionChanged();
346 * Updates the state of the 'Back' and 'Forward' menu
347 * actions corresponding the the current history.
349 void slotHistoryChanged();
352 * Updates the caption of the main window and the state
353 * of all menu actions which depend from a changed Url.
355 void slotUrlChanged(const KUrl
& url
);
357 /** Updates the state of the 'Show filter bar' menu action. */
358 void updateFilterBarAction(bool show
);
360 /** Executes the redo operation (see UndoManager::Redo ()). */
363 /** Executes the undo operation (see UndoManager::Undo()). */
366 /** Open a new main window. */
367 void openNewMainWindow();
376 void setupDockWidgets();
377 void setupCreateNewMenuActions();
378 void updateHistory();
379 void updateEditActions();
380 void updateViewActions();
381 void updateGoActions();
382 void updateViewProperties(const KUrl::List
& urls
);
383 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
384 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
385 void addPendingUndoJob(KIO::Job
* job
,
386 DolphinCommand::Type commandType
,
387 const KUrl::List
& source
,
389 void clearStatusBar();
392 * Connects the signals from the created DolphinView with
393 * the index \a viewIndex with the corresponding slots of
394 * the DolphinMainWindow. This method must be invoked each
395 * time a DolphinView has been created.
397 void connectViewSignals(int viewIndex
);
400 QSplitter
* m_splitter
;
401 DolphinView
* m_activeView
;
404 * DolphinMainWindowsupports only one or two views, which
405 * are handled internally as primary and secondary view.
412 DolphinView
* m_view
[SecondaryIdx
+ 1];
414 /// If set to true, the clipboard contains data which should be cutted after pasting.
415 bool m_clipboardContainsCutData
;
418 * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
419 * operation after they have been finished successfully. When an asynchronous
420 * operation is started, it is added to a pending undo jobs list in the meantime.
421 * As soon as the job has been finished, the operation is added to the undo mangager.
423 * @see DolphinMainWindow::addPendingUndoJob
424 * @see DolphinMainWindow::addUndoOperation
429 DolphinCommand command
;
431 Q3ValueList
<UndoInfo
> m_pendingUndoJobs
;
433 /** Contains meta information for creating files. */
434 struct CreateFileEntry
438 QString templatePath
;
443 QLinkedList
<QAction
*> m_fileGroupActions
;
444 KSortableList
<CreateFileEntry
,QString
> m_createFileTemplates
;
446 // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions()
447 // and DolphinMainWindow::linkToDeviceActions() in for details.
448 //QLinkedList<QAction*> m_linkGroupActions;
449 //QLinkedList<QAction*> m_linkToDeviceActions;
452 #endif // _DOLPHIN_H_