]> 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 d87717692eee321f836daa560435b0169b78159f..7a71b685c2905801308b1d10ab0fea543be405f6 100644 (file)
 #include <kmainwindow.h>
 #include <ksortablelist.h>
 #include <konq_operations.h>
+#include <konq_undo.h>
 
 #include <QList>
 
+class KNewMenu;
 class KPrinter;
 class KUrl;
 class QLineEdit;
@@ -45,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();
 
@@ -83,19 +86,32 @@ public:
     void dropUrls(const KUrl::List& urls,
                   const KUrl& destination);
 
-    /**
-     * 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.
-     */
-    QLinkedList<QAction*> fileGroupActions() const { return m_fileGroupActions; }
-
     /**
      * 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).
+     */
+    KNewMenu* newMenu() const { return m_newMenu; }
+
+public slots:
+    /**
+     * Returns the main windows ID, mainly used throught DBus.
+     */
+    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:
     /**
      * Is send if the active view has been changed in
@@ -127,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();
@@ -149,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.
@@ -173,6 +183,9 @@ private slots:
     /** Sets the text of the 'Undo' menu action to \a text. */
     void slotUndoTextChanged(const QString& text);
 
+    /** Performs the current undo operation. */
+    void undo();
+
     /**
      * Copies all selected items to the clipboard and marks
      * the items as cutted.
@@ -216,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();
 
@@ -327,39 +349,21 @@ private slots:
     /** Open a new main window. */
     void openNewMainWindow();
 
-    /**
-     * Moves the items indicated by m_droppedUrls to the URL
-     * m_destination.
-     */
-    void moveDroppedItems();
-
-    /**
-     * Copies the items indicated by m_droppedUrls to the URL
-     * m_destination.
-     */
-    void copyDroppedItems();
-
-    /**
-     * Links the items indicated by m_droppedUrls to the URL
-     * m_destination.
-     */
-    void linkDroppedItems();
-
 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 copyUrls(const KUrl::List& source, const KUrl& dest);
     void moveUrls(const KUrl::List& source, const KUrl& dest);
+    void linkUrls(const KUrl::List& source, const KUrl& dest);
     void clearStatusBar();
 
     /**
@@ -371,12 +375,6 @@ private:
     void connectViewSignals(int viewIndex);
 
 private:
-    QSplitter* m_splitter;
-    DolphinView* m_activeView;
-
-    KUrl m_dropDestination;
-    KUrl::List m_droppedUrls;
-
     /**
      * DolphinMainWindowsupports only one or two views, which
      * are handled internally as primary and secondary view.
@@ -386,23 +384,32 @@ private:
         PrimaryIdx = 0,
         SecondaryIdx = 1
     };
-    DolphinView* m_view[SecondaryIdx + 1];
 
-    /// remember pending undo operations until they are finished
-    QList<KonqOperations::Operation> m_undoOperations;
-
-    /** Contains meta information for creating files. */
-    struct CreateFileEntry
+    /**
+     * 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.
+     */
+    class UndoUiInterface : public KonqUndoManager::UiInterface
     {
-        QString name;
-        QString filePath;
-        QString templatePath;
-        QString icon;
-        QString comment;
+    public:
+        UndoUiInterface(DolphinMainWindow* mainWin);
+        virtual ~UndoUiInterface();
+        virtual void jobError(KIO::Job* job);
+
+    private:
+        DolphinMainWindow* m_mainWin;
     };
 
-    QLinkedList<QAction*> m_fileGroupActions;
-    KSortableList<CreateFileEntry,QString> m_createFileTemplates;
+    KNewMenu* m_newMenu;
+    QSplitter* m_splitter;
+    DolphinView* m_activeView;
+    int m_id;
+
+    DolphinView* m_view[SecondaryIdx + 1];
+
+    /// remember pending undo operations until they are finished
+    QList<KonqOperations::Operation> m_undoOperations;
 };
 
 #endif // _DOLPHIN_H_