]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.h
Dolphin is now a KUniqueApplication. A lot of thanks go to Oscar Blumberg, who submit...
[dolphin.git] / src / dolphinmainwindow.h
index 064bf18676593df9dd964ab1592eebd3e65089f7..7a71b685c2905801308b1d10ab0fea543be405f6 100644 (file)
 #ifndef _DOLPHIN_MAINWINDOW_H_
 #define _DOLPHIN_MAINWINDOW_H_
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
+#include "dolphinview.h"
 
-#include <kapplication.h>
 #include <kmainwindow.h>
 #include <ksortablelist.h>
-#include <kvbox.h>
-
-#include <q3valuelist.h>
-#include <q3ptrlist.h>
+#include <konq_operations.h>
+#include <konq_undo.h>
 
-#include <QCloseEvent>
-#include <QString>
-
-#include "dolphinview.h"
-#include "undomanager.h"
+#include <QList>
 
+class KNewMenu;
 class KPrinter;
 class KUrl;
 class QLineEdit;
@@ -55,13 +47,14 @@ class DolphinApplication;
  * @short Main window for Dolphin.
  *
  * Handles the menus, toolbars and Dolphin views.
- *
- * @author Peter Penz <peter.penz@gmx.at>
-*/
+ */
 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();
 
@@ -94,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.
      */
-    bool clipboardContainsCutData() const { return m_clipboardContainsCutData; }
+    void refreshViews();
 
     /**
-     * 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 'Create New...' sub menu which also can be shared
+     * with other menus (e. g. a context menu).
      */
-    const Q3PtrList<KAction>& fileGroupActions() const { return m_fileGroupActions; }
-    //const QPtrList<KAction>& linkGroupActions() const { return m_linkGroupActions; }
-    //const QPtrList<KAction>& linkToDeviceActions() const { return m_linkToDeviceActions; }
+    KNewMenu* newMenu() const { return m_newMenu; }
 
+public slots:
     /**
-     * Refreshs the views of the main window by recreating them dependent from
-     * the given Dolphin settings.
+     * Returns the main windows ID, mainly used throught DBus.
      */
-    void refreshViews();
+    int getId() const { return m_id; }
+
+    /**
+     * Changes the URL of the current active DolphinView to \a url.
+     */
+    void changeUrl(const QString& url);
+
+    /** Stores all settings and quits Dolphin. */
+    void quit();
 
 signals:
     /**
@@ -145,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();
@@ -167,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.
@@ -191,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
@@ -234,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();
 
@@ -246,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();
 
@@ -262,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
@@ -321,12 +316,6 @@ private slots:
     /** Opens the settings dialog for Dolphin. */
     void editSettings();
 
-    /**
-     * Adds the undo operation given by \a job
-     * to the UndoManager.
-     */
-    void addUndoOperation(KJob* job);
-
     /** Updates the state of all 'View' menu actions. */
     void slotViewModeChanged();
 
@@ -357,35 +346,24 @@ private slots:
     /** Updates the state of the 'Show filter bar' menu action. */
     void updateFilterBarAction(bool show);
 
-    /** Executes the redo operation (see UndoManager::Redo ()). */
-    void redo();
-
-    /** Executes the undo operation (see UndoManager::Undo()). */
-    void undo();
-
     /** 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();
 
     /**
@@ -397,9 +375,6 @@ private:
     void connectViewSignals(int viewIndex);
 
 private:
-    QSplitter* m_splitter;
-    DolphinView* m_activeView;
-
     /**
      * DolphinMainWindowsupports only one or two views, which
      * are handled internally as primary and secondary view.
@@ -409,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<UndoInfo> 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<KAction> m_fileGroupActions;
-    KSortableList<CreateFileEntry,QString> 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<KAction> m_linkGroupActions;
-    //QPtrList<KAction> m_linkToDeviceActions;
+    /// remember pending undo operations until they are finished
+    QList<KonqOperations::Operation> m_undoOperations;
 };
 
 #endif // _DOLPHIN_H_