]>
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_
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 the list of actions which are part of the file group
98 * of the 'Create New...' sub menu. Usually the list contains actions
99 * for creating folders, text files, HTML files etc.
101 QLinkedList
<QAction
*> fileGroupActions() const { return m_fileGroupActions
; }
104 * Refreshs the views of the main window by recreating them dependent from
105 * the given Dolphin settings.
111 * Is send if the active view has been changed in
112 * the split view mode.
114 void activeViewChanged();
117 * Is send if the selection of the currently active view has
120 void selectionChanged();
123 /** @see QMainWindow::closeEvent */
124 virtual void closeEvent(QCloseEvent
* event
);
127 * This method is called when it is time for the app to save its
128 * properties for session management purposes.
130 void saveProperties(KConfig
*);
133 * This method is called when this app is restored. The KConfig
134 * object points to the session management config file that was saved
135 * with @ref saveProperties
137 void readProperties(KConfig
*);
140 /** Opens an input dialog for creating a new folder. */
143 /** Creates a file with the MIME type given by the sender. */
146 /** Renames the selected item of the active view. */
149 /** Moves the selected items of the active view to the trash. */
152 /** Deletes the selected items of the active view. */
156 * Opens the properties window for the selected items of the
157 * active view. The properties windows shows informations
158 * like name, size and permissions.
162 /** Stores all settings and quits Dolphin. */
166 * Shows the error information of the job \a job
169 void slotHandleJobError(KJob
* job
);
172 * Indicates in the status bar that the delete operation
173 * of the job \a job has been finished.
175 void slotDeleteFileFinished(KJob
* job
);
178 * Updates the state of the 'Undo' menu action dependent
179 * from the parameter \a available.
181 void slotUndoAvailable(bool available
);
183 /** Sets the text of the 'Undo' menu action to \a text. */
184 void slotUndoTextChanged(const QString
& text
);
187 * Updates the state of the 'Redo' menu action dependent
188 * from the parameter \a available.
190 void slotRedoAvailable(bool available
);
192 /** Sets the text of the 'Redo' menu action to \a text. */
193 void slotRedoTextChanged(const QString
& text
);
196 * Copies all selected items to the clipboard and marks
197 * the items as cutted.
201 /** Copies all selected items to the clipboard. */
204 /** Pastes the clipboard data to the active view. */
208 * Updates the text of the paste action dependent from
209 * the number of items which are in the clipboard.
211 void updatePasteAction();
213 /** Selects all items from the active view. */
217 * Inverts the selection of all items of the active view:
218 * Selected items get nonselected and nonselected items get
221 void invertSelection();
223 /** The current active view is switched to the icons mode. */
226 /** The current active view is switched to the details mode. */
227 void setDetailsView();
229 /** The sorting of the current view should be done by the name. */
232 /** The sorting of the current view should be done by the size. */
235 /** The sorting of the current view should be done by the date. */
238 /** Switches between an ascending and descending sorting order. */
239 void toggleSortOrder();
242 * Switches between one and two views:
243 * If one view is visible, it will get split into two views.
244 * If already two views are visible, the nonactivated view gets closed.
246 void toggleSplitView();
248 /** Reloads the current active view. */
251 /** Stops the loading process for the current active view. */
254 /** Switches between showing a preview of the file content and showing the icon. */
255 void togglePreview();
258 * Switches between showing and hiding of hidden marked files dependent
259 * from the current state of the 'Show Hidden Files' menu toggle action.
261 void toggleShowHiddenFiles();
264 * Switches between showing and hiding of the filter bar dependent
265 * from the current state of the 'Show Filter Bar' menu toggle action.
267 void showFilterBar();
269 /** Increases the size of the current set view mode. */
272 /** Decreases the size of the current set view mode. */
276 * Toggles between edit and brose mode of the navigation bar.
278 void toggleEditLocation();
281 * Switches to the edit mode of the navigation bar. If the edit mode is
282 * already active, it is assured that the navigation bar get focused.
287 * Opens the view properties dialog, which allows to modify the properties
288 * of the currently active view.
290 void adjustViewProperties();
292 /** Goes back on step of the Url history. */
295 /** Goes forward one step of the Url history. */
298 /** Goes up one hierarchy of the current Url. */
301 /** Goes to the home Url. */
304 /** Opens a terminal for the current shown directory. */
307 /** Opens KFind for the current shown directory. */
310 /** Opens Kompare for 2 selected files. */
313 /** Opens the settings dialog for Dolphin. */
317 * Adds the undo operation given by \a job
318 * to the UndoManager.
320 void addUndoOperation(KJob
* job
);
322 /** Updates the state of all 'View' menu actions. */
323 void slotViewModeChanged();
325 /** Updates the state of the 'Show hidden files' menu action. */
326 void slotShowHiddenFilesChanged();
328 /** Updates the state of the 'Sort by' actions. */
329 void slotSortingChanged(DolphinView::Sorting sorting
);
331 /** Updates the state of the 'Sort Ascending/Descending' action. */
332 void slotSortOrderChanged(Qt::SortOrder order
);
334 /** Updates the state of the 'Edit' menu actions. */
335 void slotSelectionChanged();
338 * Updates the state of the 'Back' and 'Forward' menu
339 * actions corresponding the the current history.
341 void slotHistoryChanged();
344 * Updates the caption of the main window and the state
345 * of all menu actions which depend from a changed Url.
347 void slotUrlChanged(const KUrl
& url
);
349 /** Updates the state of the 'Show filter bar' menu action. */
350 void updateFilterBarAction(bool show
);
352 /** Executes the redo operation (see UndoManager::Redo ()). */
355 /** Executes the undo operation (see UndoManager::Undo()). */
358 /** Open a new main window. */
359 void openNewMainWindow();
368 void setupDockWidgets();
369 void setupCreateNewMenuActions();
370 void updateHistory();
371 void updateEditActions();
372 void updateViewActions();
373 void updateGoActions();
374 void updateViewProperties(const KUrl::List
& urls
);
375 void copyUrls(const KUrl::List
& source
, const KUrl
& dest
);
376 void moveUrls(const KUrl::List
& source
, const KUrl
& dest
);
377 void addPendingUndoJob(KIO::Job
* job
,
378 DolphinCommand::Type commandType
,
379 const KUrl::List
& source
,
381 void clearStatusBar();
384 * Connects the signals from the created DolphinView with
385 * the index \a viewIndex with the corresponding slots of
386 * the DolphinMainWindow. This method must be invoked each
387 * time a DolphinView has been created.
389 void connectViewSignals(int viewIndex
);
392 QSplitter
* m_splitter
;
393 DolphinView
* m_activeView
;
396 * DolphinMainWindowsupports only one or two views, which
397 * are handled internally as primary and secondary view.
404 DolphinView
* m_view
[SecondaryIdx
+ 1];
407 * Asynchronous operations like 'Move' and 'Copy' may only be added as undo
408 * operation after they have been finished successfully. When an asynchronous
409 * operation is started, it is added to a pending undo jobs list in the meantime.
410 * As soon as the job has been finished, the operation is added to the undo mangager.
412 * @see DolphinMainWindow::addPendingUndoJob
413 * @see DolphinMainWindow::addUndoOperation
418 DolphinCommand command
;
420 Q3ValueList
<UndoInfo
> m_pendingUndoJobs
;
422 /** Contains meta information for creating files. */
423 struct CreateFileEntry
427 QString templatePath
;
432 QLinkedList
<QAction
*> m_fileGroupActions
;
433 KSortableList
<CreateFileEntry
,QString
> m_createFileTemplates
;
436 #endif // _DOLPHIN_H_