]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Revert the moving of the action to the DolphinView instance, this doesn't work with...
authorDavid Faure <faure@kde.org>
Mon, 21 Jan 2008 19:08:52 +0000 (19:08 +0000)
committerDavid Faure <faure@kde.org>
Mon, 21 Jan 2008 19:08:52 +0000 (19:08 +0000)
(Each view would need its own action collection, but then DolphinView would have to become
a KXMLGUIClient, and the GUI would flicker when switching views).

Instead, use the same solution as the other shared actions: static method in DolphinView (for now),
slot in the mainwindow (and for the more complex actions than this one, shared code in DolphinView)

svn path=/branches/KDE/4.0/kdebase/apps/; revision=764429

src/dolphinmainwindow.cpp
src/dolphinmainwindow.h
src/dolphinpart.cpp
src/dolphinpart.h
src/dolphinview.cpp
src/dolphinview.h
src/dolphinviewcontainer.cpp

index 2048de1a5618aee14bf80411ae4ad917624ca6d4..1da9377c7d6c29ace603fe37c7a6787e1312a1c2 100644 (file)
@@ -60,6 +60,7 @@
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <konqmimedata.h>
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <konqmimedata.h>
+#include <konq_operations.h>
 #include <kpropertiesdialog.h>
 #include <kprotocolinfo.h>
 #include <ktoggleaction.h>
 #include <kpropertiesdialog.h>
 #include <kprotocolinfo.h>
 #include <ktoggleaction.h>
@@ -422,6 +423,12 @@ void DolphinMainWindow::readProperties(const KConfigGroup& group)
     }
 }
 
     }
 }
 
+void DolphinMainWindow::createDir()
+{
+    const KUrl& url = m_activeViewContainer->view()->url();
+    KonqOperations::newDir(this, url);
+}
+
 void DolphinMainWindow::updateNewMenu()
 {
     m_newMenu->slotCheckUpToDate();
 void DolphinMainWindow::updateNewMenu()
 {
     m_newMenu->slotCheckUpToDate();
@@ -985,6 +992,9 @@ void DolphinMainWindow::setupActions()
     connect(menu, SIGNAL(aboutToShow()),
             this, SLOT(updateNewMenu()));
 
     connect(menu, SIGNAL(aboutToShow()),
             this, SLOT(updateNewMenu()));
 
+    KAction* newDirAction = DolphinView::createNewDirAction(actionCollection());
+    connect(newDirAction, SIGNAL(triggered()), SLOT(createDir()));
+
     KAction* newWindow = actionCollection()->addAction("new_window");
     newWindow->setIcon(KIcon("window-new"));
     newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
     KAction* newWindow = actionCollection()->addAction("new_window");
     newWindow->setIcon(KIcon("window-new"));
     newWindow->setText(i18nc("@action:inmenu File", "New &Window"));
index f757520c371a7e10ee3daa0311e7d45a8922a220..e99add89619126d6984f7d63a30285d7504fe07f 100644 (file)
@@ -163,6 +163,12 @@ protected:
     virtual void readProperties(const KConfigGroup& group);
 
 private slots:
     virtual void readProperties(const KConfigGroup& group);
 
 private slots:
+    /**
+     * Opens the dialog for creating a directory. Is connected
+     * with the key shortcut for "new directory" (F10).
+     */
+    void createDir();
+
     /** Updates the 'Create New...' sub menu. */
     void updateNewMenu();
 
     /** Updates the 'Create New...' sub menu. */
     void updateNewMenu();
 
index 235f176cd43f38bc4fc42f86c5f1f164471d8f1a..2c4c1eaa36473233c8ad3bfda6e60de2b942791d 100644 (file)
@@ -70,8 +70,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
                              KUrl(),
                              m_dirLister,
                              m_dolphinModel,
                              KUrl(),
                              m_dirLister,
                              m_dolphinModel,
-                             m_proxyModel,
-                             actionCollection());
+                             m_proxyModel);
     setWidget(m_view);
 
     setXMLFile("dolphinpart.rc");
     setWidget(m_view);
 
     setXMLFile("dolphinpart.rc");
@@ -147,6 +146,9 @@ void DolphinPart::createActions()
 
     // Go menu
 
 
     // Go menu
 
+    KAction* newDirAction = DolphinView::createNewDirAction(actionCollection());
+    connect(newDirAction, SIGNAL(triggered()), SLOT(createDir()));
+
     QActionGroup* goActionGroup = new QActionGroup(this);
     connect(goActionGroup, SIGNAL(triggered(QAction*)),
             this, SLOT(slotGoTriggered(QAction*)));
     QActionGroup* goActionGroup = new QActionGroup(this);
     connect(goActionGroup, SIGNAL(triggered(QAction*)),
             this, SLOT(slotGoTriggered(QAction*)));
@@ -424,4 +426,9 @@ void DolphinPart::slotProperties()
     }
 }
 
     }
 }
 
+void DolphinPart::createDir()
+{
+    KonqOperations::newDir(m_view, url());
+}
+
 #include "dolphinpart.moc"
 #include "dolphinpart.moc"
index 3e3c73f6643377b3f64394631be0a153e208683a..04161b6be6053bb34dd156d2887604eb57bc1f41 100644 (file)
@@ -130,6 +130,12 @@ private Q_SLOTS:
      */
     void slotProperties();
 
      */
     void slotProperties();
 
+    /**
+     * Opens the dialog for creating a directory. Is connected
+     * with the key shortcut for "new directory" (F10).
+     */
+    void createDir();
+
 private:
     void createActions();
     void createGoAction(const char* name, const char* iconName,
 private:
     void createActions();
     void createGoAction(const char* name, const char* iconName,
index 4a1fbb927d348270c68b74b2e48fc10689e93713..138971360c1a357bea566ee85ecc09ac7f579cdb 100644 (file)
@@ -19,8 +19,6 @@
  ***************************************************************************/
 
 #include "dolphinview.h"
  ***************************************************************************/
 
 #include "dolphinview.h"
-#include <ktoggleaction.h>
-#include <kactioncollection.h>
 
 #include <QApplication>
 #include <QClipboard>
 
 #include <QApplication>
 #include <QClipboard>
@@ -30,6 +28,7 @@
 #include <QTimer>
 #include <QScrollBar>
 
 #include <QTimer>
 #include <QScrollBar>
 
+#include <kactioncollection.h>
 #include <kcolorscheme.h>
 #include <kdirlister.h>
 #include <kfileitemdelegate.h>
 #include <kcolorscheme.h>
 #include <kdirlister.h>
 #include <kfileitemdelegate.h>
@@ -43,6 +42,7 @@
 #include <kmimetyperesolver.h>
 #include <konqmimedata.h>
 #include <konq_operations.h>
 #include <kmimetyperesolver.h>
 #include <konqmimedata.h>
 #include <konq_operations.h>
+#include <ktoggleaction.h>
 #include <kurl.h>
 
 #include "dolphindropcontroller.h"
 #include <kurl.h>
 
 #include "dolphindropcontroller.h"
@@ -61,8 +61,7 @@ DolphinView::DolphinView(QWidget* parent,
                          const KUrl& url,
                          KDirLister* dirLister,
                          DolphinModel* dolphinModel,
                          const KUrl& url,
                          KDirLister* dirLister,
                          DolphinModel* dolphinModel,
-                         DolphinSortFilterProxyModel* proxyModel,
-                         KActionCollection* actionCollection) :
+                         DolphinSortFilterProxyModel* proxyModel) :
     QWidget(parent),
     m_active(true),
     m_showPreview(false),
     QWidget(parent),
     m_active(true),
     m_showPreview(false),
@@ -128,16 +127,6 @@ DolphinView::DolphinView(QWidget* parent,
 
     applyViewProperties(url);
     m_topLayout->addWidget(itemView());
 
     applyViewProperties(url);
     m_topLayout->addWidget(itemView());
-
-    Q_ASSERT(actionCollection != 0);
-    if (actionCollection->action("create_dir") == 0) {
-        // This action doesn't appear in the GUI, it's for the shortcut only.
-        // KNewMenu takes care of the GUI stuff.
-        KAction* newDirAction = actionCollection->addAction("create_dir");
-        newDirAction->setText(i18n("Create Folder..."));
-        connect(newDirAction, SIGNAL(triggered()), SLOT(createDir()));
-        newDirAction->setShortcut(Qt::Key_F10);
-    }
 }
 
 DolphinView::~DolphinView()
 }
 
 DolphinView::~DolphinView()
@@ -1149,11 +1138,6 @@ void DolphinView::slotPreviewJobFinished(KJob* job)
     m_previewJob = 0;
 }
 
     m_previewJob = 0;
 }
 
-void DolphinView::createDir()
-{
-    KonqOperations::newDir(this, url());
-}
-
 void DolphinView::cutSelectedItems()
 {
     QMimeData* mimeData = new QMimeData();
 void DolphinView::cutSelectedItems()
 {
     QMimeData* mimeData = new QMimeData();
@@ -1263,4 +1247,14 @@ KAction* DolphinView::createDeleteAction(KActionCollection* collection)
     return deleteAction;
 }
 
     return deleteAction;
 }
 
+KAction* DolphinView::createNewDirAction(KActionCollection* collection)
+{
+    // This action doesn't appear in the GUI, it's for the shortcut only.
+    // KNewMenu takes care of the GUI stuff.
+    KAction* newDirAction = collection->addAction("create_dir");
+    newDirAction->setText(i18n("Create Folder..."));
+    newDirAction->setShortcut(Qt::Key_F10);
+    return newDirAction;
+}
+
 #include "dolphinview.moc"
 #include "dolphinview.moc"
index 485748751de7ef1c96a28a9992f256a2f43d6ae6..8076a62f0bb3a88d2b4fc9846a8b365ed4f0bfc5 100644 (file)
@@ -128,14 +128,12 @@ public:
      * @param proxyModel       Used proxy model which specifies the sorting. The
      *                         model is not owned by the view and won't get
      *                         deleted.
      * @param proxyModel       Used proxy model which specifies the sorting. The
      *                         model is not owned by the view and won't get
      *                         deleted.
-     * @param actionCollection Action collection which contains the menu actions.
      */
     DolphinView(QWidget* parent,
                 const KUrl& url,
                 KDirLister* dirLister,
                 DolphinModel* dolphinModel,
      */
     DolphinView(QWidget* parent,
                 const KUrl& url,
                 KDirLister* dirLister,
                 DolphinModel* dolphinModel,
-                DolphinSortFilterProxyModel* proxyModel,
-                KActionCollection* actionCollection);
+                DolphinSortFilterProxyModel* proxyModel);
 
     virtual ~DolphinView();
 
 
     virtual ~DolphinView();
 
@@ -364,6 +362,12 @@ public:
      */
     static KAction* createDeleteAction(KActionCollection* collection);
 
      */
     static KAction* createDeleteAction(KActionCollection* collection);
 
+    /**
+     * Creates the "new directory" action.
+     * This code is here to share it between the mainwindow and the part
+     */
+    static KAction* createNewDirAction(KActionCollection* collection);
+
     /**
      * Returns the action name corresponding to the current view mode
      */
     /**
      * Returns the action name corresponding to the current view mode
      */
@@ -618,12 +622,6 @@ private slots:
      */
     void slotPreviewJobFinished(KJob* job);
 
      */
     void slotPreviewJobFinished(KJob* job);
 
-    /**
-     * Opens the dialog for creating a directory. Is connected
-     * with the key shortcut for "new directory" (F10).
-     */
-    void createDir();
-
 private:
     void loadDirectory(const KUrl& url, bool reload = false);
 
 private:
     void loadDirectory(const KUrl& url, bool reload = false);
 
index b9caa7b8e6fdafd27cd0ae7b80abeb27afc31868..a1846dc758c73bd2acb4a9351595cf3fc284c21c 100644 (file)
@@ -115,8 +115,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
                              url,
                              m_dirLister,
                              m_dolphinModel,
                              url,
                              m_dirLister,
                              m_dolphinModel,
-                             m_proxyModel,
-                             mainWindow->actionCollection());
+                             m_proxyModel);
     connect(m_view, SIGNAL(urlChanged(const KUrl&)),
             m_urlNavigator, SLOT(setUrl(const KUrl&)));
     connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),
     connect(m_view, SIGNAL(urlChanged(const KUrl&)),
             m_urlNavigator, SLOT(setUrl(const KUrl&)));
     connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),