]>
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 <kmainwindow.h>
26 #include <ksortablelist.h>
28 #include <q3valuelist.h>
30 #include "dolphinview.h"
31 #include "undomanager.h" // for DolphinCommand::Type
42 class DolphinApplication
;
45 * @short Main window for Dolphin.
47 * Handles the menus, toolbars and Dolphin views.
49 * @author Peter Penz <peter.penz@gmx.at>
51 class DolphinMainWindow
: public KMainWindow
54 friend class DolphinApplication
;
56 virtual ~DolphinMainWindow();
59 * Activates the given view, which means that
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 void setActiveView(DolphinView
* view
);
67 * Returns the currently active view. See
68 * DolphinMainWindow::setActiveView() for more details.
70 DolphinView
* activeView() const { return m_activeView
; }
73 * Handles the dropping of Urls to the given
74 * destination. A context menu with the options
75 * 'Move Here', 'Copy Here', 'Link Here' and
76 * 'Cancel' is offered to the user.
77 * @param urls List of Urls which have been
79 * @param destination Destination Url, where the
80 * list or Urls should be moved,
81 * copied or linked to.
83 void dropUrls(const KUrl::List
& urls
,
84 const KUrl
& destination
);
87 * Returns the list of actions which are part of the file group
88 * of the 'Create New...' sub menu. Usually the list contains actions
89 * for creating folders, text files, HTML files etc.
91 QLinkedList
<QAction
*> fileGroupActions() const { return m_fileGroupActions
; }
94 * Refreshs the views of the main window by recreating them dependent from
95 * the given Dolphin settings.
101 * Is send if the active view has been changed in
102 * the split view mode.
104 void activeViewChanged();
107 * Is send if the selection of the currently active view has
110 void selectionChanged();
113 /** @see QMainWindow::closeEvent */
114 virtual void closeEvent(QCloseEvent
* event
);
117 * This method is called when it is time for the app to save its
118 * properties for session management purposes.
120 void saveProperties(KConfig
*);
123 * This method is called when this app is restored. The KConfig
124 * object points to the session management config file that was saved
125 * with @ref saveProperties
127 void readProperties(KConfig
*);
130 /** Opens an input dialog for creating a new folder. */
133 /** Creates a file with the MIME type given by the sender. */
136 /** Renames the selected item of the active view. */
139 /** Moves the selected items of the active view to the trash. */
142 /** Deletes the selected items of the active view. */
146 * Opens the properties window for the selected items of the
147 * active view. The properties windows shows informations
148 * like name, size and permissions.
152 /** Stores all settings and quits Dolphin. */
156 * Shows the error information of the job \a job
159 void slotHandleJobError(KJob
* job
);
162 * Indicates in the status bar that the delete operation
163 * of the job \a job has been finished.
165 void slotDeleteFileFinished(KJob
* job
);
168 * Updates the state of the 'Undo' menu action dependent
169 * from the parameter \a available.
171 void slotUndoAvailable(bool available
);
173 /** Sets the text of the 'Undo' menu action to \a text. */
174 void slotUndoTextChanged(const QString
& text
);
177 * Updates the state of the 'Redo' menu action dependent
178 * from the parameter \a available.
180 void slotRedoAvailable(bool available
);
182 /** Sets the text of the 'Redo' menu action to \a text. */
183 void slotRedoTextChanged(const QString
& text
);
186 * Copies all selected items to the clipboard and marks
187 * the items as cutted.
191 /** Copies all selected items to the clipboard. */
194 /** Pastes the clipboard data to the active view. */
198 * Updates the text of the paste action dependent from
199 * the number of items which are in the clipboard.
201 void updatePasteAction();
203 /** Selects all items from the active view. */
207 * Inverts the selection of all items of the active view:
208 * Selected items get nonselected and nonselected items get
211 void invertSelection();
213 /** The current active view is switched to the icons mode. */
216 /** The current active view is switched to the details mode. */
217 void setDetailsView();
219 /** The sorting of the current view should be done by the name. */
222 /** The sorting of the current view should be done by the size. */
225 /** The sorting of the current view should be done by the date. */
228 /** Switches between an ascending and descending sorting order. */
229 void toggleSortOrder();
232 * Switches between one and two views:
233 * If one view is visible, it will get split into two views.
234 * If already two views are visible, the nonactivated view gets closed.
236 void toggleSplitView();
238 /** Reloads the current active view. */
241 /** Stops the loading process for the current active view. */
244 /** Switches between showing a preview of the file content and showing the icon. */
245 void togglePreview();
248 * Switches between showing and hiding of hidden marked files dependent
249 * from the current state of the 'Show Hidden Files' menu toggle action.
251 void toggleShowHiddenFiles();
254 * Switches between showing and hiding of the filter bar dependent
255 * from the current state of the 'Show Filter Bar' menu toggle action.
257 void showFilterBar();
259 /** Increases the size of the current set view mode. */
262 /** Decreases the size of the current set view mode. */
266 * Toggles between edit and brose mode of the navigation bar.
268 void toggleEditLocation();
271 * Switches to the edit mode of the navigation bar. If the edit mode is
272 * already active, it is assured that the navigation bar get focused.
277 * Opens the view properties dialog, which allows to modify the properties
278 * of the currently active view.
280 void adjustViewProperties();
282 /** Goes back on step of the Url history. */
285 /** Goes forward one step of the Url history. */
288 /** Goes up one hierarchy of the current Url. */
291 /** Goes to the home Url. */
294 /** Opens a terminal for the current shown directory. */
297 /** Opens KFind for the current shown directory. */
300 /** Opens Kompare for 2 selected files. */
303 /** Opens the settings dialog for Dolphin. */
307 * Adds the undo operation given by \a job
308 * to the UndoManager.
310 void addUndoOperation(KJob
* job
);
312 /** Updates the state of all 'View' menu actions. */
313 void slotViewModeChanged();
315 /** Updates the state of the 'Show hidden files' menu action. */
316 void slotShowHiddenFilesChanged();
318 /** Updates the state of the 'Sort by' actions. */
319 void slotSortingChanged(DolphinView::Sorting sorting
);
321 /** Updates the state of the 'Sort Ascending/Descending' action. */
322 void slotSortOrderChanged(Qt::SortOrder order
);
324 /** Updates the state of the 'Edit' menu actions. */
325 void slotSelectionChanged();
328 * Updates the state of the 'Back' and 'Forward' menu
329 * actions corresponding the the current history.
331 void slotHistoryChanged();
334 * Updates the caption of the main window and the state
335 * of all menu actions which depend from a changed Url.
337 void slotUrlChanged(const KUrl
& url
);
339 /** Updates the state of the 'Show filter bar' menu action. */
340 void updateFilterBarAction(bool show
);
342 /** Executes the redo operation (see UndoManager::Redo ()). */
345 /** Executes the undo operation (see UndoManager::Undo()). */
348 /** Open a new main window. */
349 void openNewMainWindow();
352 * Moves the items indicated by m_droppedUrls to the URL
355 void moveDroppedItems();
358 * Copies the items indicated by m_droppedUrls to the URL
361 void copyDroppedItems();
364 * Links the items indicated by m_droppedUrls to the URL
367 void linkDroppedItems();
376 void setupDockWidgets();
377 void setupCreateNewMenuActions();
378 void updateHistory();
379 void updateEditActions();
380 void updateViewActions();
381 void updateGoActions();
382 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
383 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
384 void addPendingUndoJob(KIO::Job
* job
,
385 DolphinCommand::Type commandType
,
386 const KUrl::List
& source
,
388 void clearStatusBar();
391 * Connects the signals from the created DolphinView with
392 * the index \a viewIndex with the corresponding slots of
393 * the DolphinMainWindow. This method must be invoked each
394 * time a DolphinView has been created.
396 void connectViewSignals(int viewIndex
);
399 QSplitter
* m_splitter
;
400 DolphinView
* m_activeView
;
402 KUrl m_dropDestination
;
403 KUrl::List m_droppedUrls
;
406 * DolphinMainWindowsupports only one or two views, which
407 * are handled internally as primary and secondary view.
414 DolphinView
* m_view
[SecondaryIdx
+ 1];
417 * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
418 * operation after they have been finished successfully. When an asynchronous
419 * operation is started, it is added to a pending undo jobs list in the meantime.
420 * As soon as the job has been finished, the operation is added to the undo mangager.
422 * @see DolphinMainWindow::addPendingUndoJob
423 * @see DolphinMainWindow::addUndoOperation
428 DolphinCommand command
;
430 Q3ValueList
<UndoInfo
> m_pendingUndoJobs
;
432 /** Contains meta information for creating files. */
433 struct CreateFileEntry
437 QString templatePath
;
442 QLinkedList
<QAction
*> m_fileGroupActions
;
443 KSortableList
<CreateFileEntry
,QString
> m_createFileTemplates
;
446 #endif // _DOLPHIN_H_