X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/b1d5b6b7467d15417131c8df8fdecb22b2008db4..abf17941f7:/src/dolphinmainwindow.h diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index 8b5694619..7a71b685c 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -16,29 +16,22 @@ * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * ***************************************************************************/ #ifndef _DOLPHIN_MAINWINDOW_H_ #define _DOLPHIN_MAINWINDOW_H_ -#ifdef HAVE_CONFIG_H -#include -#endif +#include "dolphinview.h" -#include #include -#include -#include -#include -//Added by qt3to4: -#include #include -#include +#include +#include -#include "dolphinview.h" -#include "undomanager.h" +#include +class KNewMenu; class KPrinter; class KUrl; class QLineEdit; @@ -54,13 +47,14 @@ class DolphinApplication; * @short Main window for Dolphin. * * Handles the menus, toolbars and Dolphin views. - * - * @author Peter Penz -*/ + */ class DolphinMainWindow: public KMainWindow { Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.dolphin.MainWindow") + Q_PROPERTY(int id READ getId SCRIPTABLE true) friend class DolphinApplication; + public: virtual ~DolphinMainWindow(); @@ -93,25 +87,30 @@ public: const KUrl& destination); /** - * Returns 'true', if the clipboard contains data - * which has been cutted by the Cut action (Ctrl + X). + * Refreshs the views of the main window by recreating them dependent from + * the given Dolphin settings. + */ + void refreshViews(); + + /** + * Returns the 'Create New...' sub menu which also can be shared + * with other menus (e. g. a context menu). */ - bool clipboardContainsCutData() const { return m_clipboardContainsCutData; } + KNewMenu* newMenu() const { return m_newMenu; } +public slots: /** - * Returns the list of actions which are part of the file group - * of the 'Create New...' sub menu. Usually the list contains actions - * for creating folders, text files, HTML files etc. + * Returns the main windows ID, mainly used throught DBus. */ - const Q3PtrList& fileGroupActions() const { return m_fileGroupActions; } - //const QPtrList& linkGroupActions() const { return m_linkGroupActions; } - //const QPtrList& linkToDeviceActions() const { return m_linkToDeviceActions; } + int getId() const { return m_id; } /** - * Refreshs the views of the main window by recreating them dependent from - * the given Dolphin settings. + * Changes the URL of the current active DolphinView to \a url. */ - void refreshViews(); + void changeUrl(const QString& url); + + /** Stores all settings and quits Dolphin. */ + void quit(); signals: /** @@ -126,51 +125,6 @@ signals: */ void selectionChanged(); -public slots: - /** - * Updates the state of the 'Back' and 'Forward' menu - * actions corresponding the the current history. - */ - void slotHistoryChanged(); - - /** - * Updates the caption of the main window and the state - * of all menu actions which depend from a changed Url. - */ - void slotUrlChanged(const KUrl& url); - - /** - * Go to the given Url. - */ - void slotUrlChangeRequest(const KUrl& url); - - /** Updates the state of all 'View' menu actions. */ - void slotViewModeChanged(); - - /** Updates the state of the 'Show hidden files' menu action. */ - void slotShowHiddenFilesChanged(); - - /** Updates the state of the 'Show filter bar' menu action. */ - void slotShowFilterBarChanged(); - - /** Updates the state of the 'Sort by' actions. */ - void slotSortingChanged(DolphinView::Sorting sorting); - - /** Updates the state of the 'Sort Ascending/Descending' action. */ - void slotSortOrderChanged(Qt::SortOrder order); - - /** Updates the state of the 'Edit' menu actions. */ - void slotSelectionChanged(); - - /** Executes Redo operation */ - void slotRedo(); - - /** @see slotUndo() */ - void slotUndo(); - - /** Open a new mainwindow */ - void slotNewMainWindow(); - protected: /** @see QMainWindow::closeEvent */ virtual void closeEvent(QCloseEvent* event); @@ -189,11 +143,8 @@ protected: void readProperties(KConfig*); private slots: - /** Opens an input dialog for creating a new folder. */ - void createFolder(); - - /** Creates a file with the MIME type given by the sender. */ - void createFile(); + /** Updates the 'Create New...' sub menu. */ + void updateNewMenu(); /** Renames the selected item of the active view. */ void rename(); @@ -211,9 +162,6 @@ private slots: */ void properties(); - /** Stores all settings and quits Dolphin. */ - void quit(); - /** * Shows the error information of the job \a job * in the status bar. @@ -235,14 +183,8 @@ private slots: /** Sets the text of the 'Undo' menu action to \a text. */ void slotUndoTextChanged(const QString& text); - /** - * Updates the state of the 'Redo' menu action dependent - * from the parameter \a available. - */ - void slotRedoAvailable(bool available); - - /** Sets the text of the 'Redo' menu action to \a text. */ - void slotRedoTextChanged(const QString& text); + /** Performs the current undo operation. */ + void undo(); /** * Copies all selected items to the clipboard and marks @@ -278,9 +220,6 @@ private slots: /** The current active view is switched to the details mode. */ void setDetailsView(); - /** The current active view is switched to the previews mode. */ - void setPreviewsView(); - /** The sorting of the current view should be done by the name. */ void sortByName(); @@ -290,6 +229,15 @@ private slots: /** The sorting of the current view should be done by the date. */ void sortByDate(); + /** The sorting of the current view should be done by the permissions. */ + void sortByPermissions(); + + /** The sorting of the current view should be done by the owner. */ + void sortByOwner(); + + /** The sorting of the current view should be done by the group. */ + void sortByGroup(); + /** Switches between an ascending and descending sorting order. */ void toggleSortOrder(); @@ -306,11 +254,14 @@ private slots: /** Stops the loading process for the current active view. */ void stopLoading(); + /** Switches between showing a preview of the file content and showing the icon. */ + void togglePreview(); + /** * Switches between showing and hiding of hidden marked files dependent * from the current state of the 'Show Hidden Files' menu toggle action. */ - void showHiddenFiles(); + void toggleShowHiddenFiles(); /** * Switches between showing and hiding of the filter bar dependent @@ -365,38 +316,65 @@ private slots: /** Opens the settings dialog for Dolphin. */ void editSettings(); + /** Updates the state of all 'View' menu actions. */ + void slotViewModeChanged(); + + /** Updates the state of the 'Show hidden files' menu action. */ + void slotShowHiddenFilesChanged(); + + /** Updates the state of the 'Sort by' actions. */ + void slotSortingChanged(DolphinView::Sorting sorting); + + /** Updates the state of the 'Sort Ascending/Descending' action. */ + void slotSortOrderChanged(Qt::SortOrder order); + + /** Updates the state of the 'Edit' menu actions. */ + void slotSelectionChanged(); + /** - * Adds the undo operation given by \a job - * to the UndoManager. + * Updates the state of the 'Back' and 'Forward' menu + * actions corresponding the the current history. */ - void addUndoOperation(KJob* job); + void slotHistoryChanged(); + + /** + * Updates the caption of the main window and the state + * of all menu actions which depend from a changed Url. + */ + void slotUrlChanged(const KUrl& url); + + /** Updates the state of the 'Show filter bar' menu action. */ + void updateFilterBarAction(bool show); + /** Open a new main window. */ + void openNewMainWindow(); private: - DolphinMainWindow(); + DolphinMainWindow(int id); void init(); void loadSettings(); void setupAccel(); void setupActions(); void setupDockWidgets(); - void setupCreateNewMenuActions(); void updateHistory(); void updateEditActions(); void updateViewActions(); void updateGoActions(); - void updateViewProperties(const KUrl::List& urls); void copyUrls(const KUrl::List& source, const KUrl& dest); void moveUrls(const KUrl::List& source, const KUrl& dest); - void addPendingUndoJob(KIO::Job* job, - DolphinCommand::Type commandType, - const KUrl::List& source, - const KUrl& dest); + void linkUrls(const KUrl::List& source, const KUrl& dest); void clearStatusBar(); - QSplitter* m_splitter; - DolphinView* m_activeView; + /** + * Connects the signals from the created DolphinView with + * the index \a viewIndex with the corresponding slots of + * the DolphinMainWindow. This method must be invoked each + * time a DolphinView has been created. + */ + void connectViewSignals(int viewIndex); +private: /** * DolphinMainWindowsupports only one or two views, which * are handled internally as primary and secondary view. @@ -406,44 +384,32 @@ private: PrimaryIdx = 0, SecondaryIdx = 1 }; - DolphinView* m_view[SecondaryIdx + 1]; - - /// If set to true, the clipboard contains data which should be cutted after pasting. - bool m_clipboardContainsCutData; /** - * Asynchronous operations like 'Move' and 'Copy' may only be added as undo - * operation after they have been finished successfully. When an asynchronous - * operation is started, it is added to a pending undo jobs list in the meantime. - * As soon as the job has been finished, the operation is added to the undo mangager. - * @see UndoManager - * @see DolphinMainWindow::addPendingUndoJob - * @see DolphinMainWindow::addUndoOperation + * Implements a custom error handling for the undo manager. This + * assures that all errors are shown in the status bar of Dolphin + * instead as modal error dialog with an OK button. */ - struct UndoInfo + class UndoUiInterface : public KonqUndoManager::UiInterface { - int id; - DolphinCommand command; - }; - Q3ValueList m_pendingUndoJobs; + public: + UndoUiInterface(DolphinMainWindow* mainWin); + virtual ~UndoUiInterface(); + virtual void jobError(KIO::Job* job); - /** Contains meta information for creating files. */ - struct CreateFileEntry - { - QString name; - QString filePath; - QString templatePath; - QString icon; - QString comment; + private: + DolphinMainWindow* m_mainWin; }; - Q3PtrList m_fileGroupActions; - KSortableList m_createFileTemplates; + KNewMenu* m_newMenu; + QSplitter* m_splitter; + DolphinView* m_activeView; + int m_id; + + DolphinView* m_view[SecondaryIdx + 1]; - // TODO: not used yet. See documentation of DolphinMainWindow::linkGroupActions() - // and DolphinMainWindow::linkToDeviceActions() in for details. - //QPtrList m_linkGroupActions; - //QPtrList m_linkToDeviceActions; + /// remember pending undo operations until they are finished + QList m_undoOperations; }; #endif // _DOLPHIN_H_