]> cloud.milkyroute.net Git - dolphin.git/commitdiff
forwardport 764429:
authorDavid Faure <faure@kde.org>
Mon, 21 Jan 2008 19:31:07 +0000 (19:31 +0000)
committerDavid Faure <faure@kde.org>
Mon, 21 Jan 2008 19:31:07 +0000 (19:31 +0000)
Revert the moving of the action to the DolphinView instance, this doesn't work with splitted views.
(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=/trunk/KDE/kdebase/apps/; revision=764436

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

index e0386467ee5bceea714b952b8637d9b3c5b025ea..8948a53a93141b48313375a8f123934221fac360 100644 (file)
@@ -60,6 +60,7 @@
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <konqmimedata.h>
+#include <konq_operations.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();
@@ -985,6 +992,9 @@ void DolphinMainWindow::setupActions()
     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"));
index f757520c371a7e10ee3daa0311e7d45a8922a220..e99add89619126d6984f7d63a30285d7504fe07f 100644 (file)
@@ -163,6 +163,12 @@ protected:
     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();
 
index 235f176cd43f38bc4fc42f86c5f1f164471d8f1a..2c4c1eaa36473233c8ad3bfda6e60de2b942791d 100644 (file)
@@ -70,8 +70,7 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
                              KUrl(),
                              m_dirLister,
                              m_dolphinModel,
-                             m_proxyModel,
-                             actionCollection());
+                             m_proxyModel);
     setWidget(m_view);
 
     setXMLFile("dolphinpart.rc");
@@ -147,6 +146,9 @@ void DolphinPart::createActions()
 
     // 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*)));
@@ -424,4 +426,9 @@ void DolphinPart::slotProperties()
     }
 }
 
+void DolphinPart::createDir()
+{
+    KonqOperations::newDir(m_view, url());
+}
+
 #include "dolphinpart.moc"
index 3e3c73f6643377b3f64394631be0a153e208683a..04161b6be6053bb34dd156d2887604eb57bc1f41 100644 (file)
@@ -130,6 +130,12 @@ private Q_SLOTS:
      */
     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,
index 819420210a3463d21ab123761255392a13a7a35e..bd5be21093b21187e43b03cded2b511bfd86eeed 100644 (file)
@@ -19,8 +19,6 @@
  ***************************************************************************/
 
 #include "dolphinview.h"
-#include <ktoggleaction.h>
-#include <kactioncollection.h>
 
 #include <QApplication>
 #include <QClipboard>
@@ -30,6 +28,7 @@
 #include <QTimer>
 #include <QScrollBar>
 
+#include <kactioncollection.h>
 #include <kcolorscheme.h>
 #include <kdirlister.h>
 #include <kfileitemdelegate.h>
@@ -43,6 +42,7 @@
 #include <kmimetyperesolver.h>
 #include <konq_operations.h>
 #include <konqmimedata.h>
+#include <ktoggleaction.h>
 #include <kurl.h>
 
 #include "dolphindropcontroller.h"
@@ -62,8 +62,7 @@ DolphinView::DolphinView(QWidget* parent,
                          const KUrl& url,
                          KDirLister* dirLister,
                          DolphinModel* dolphinModel,
-                         DolphinSortFilterProxyModel* proxyModel,
-                         KActionCollection* actionCollection) :
+                         DolphinSortFilterProxyModel* proxyModel) :
     QWidget(parent),
     m_active(true),
     m_showPreview(false),
@@ -123,16 +122,6 @@ DolphinView::DolphinView(QWidget* parent,
 
     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()
@@ -1037,11 +1026,6 @@ void DolphinView::slotDeleteFileFinished(KJob* job)
     }
 }
 
-void DolphinView::createDir()
-{
-    KonqOperations::newDir(this, url());
-}
-
 void DolphinView::cutSelectedItems()
 {
     QMimeData* mimeData = new QMimeData();
@@ -1151,4 +1135,14 @@ KAction* DolphinView::createDeleteAction(KActionCollection* collection)
     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"
index b42f57007334e3b1da52dc47a98a01852e7c0a6b..44efbc438930bacb687b314224cd473af0702871 100644 (file)
@@ -126,14 +126,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 actionCollection Action collection which contains the menu actions.
      */
     DolphinView(QWidget* parent,
                 const KUrl& url,
                 KDirLister* dirLister,
                 DolphinModel* dolphinModel,
-                DolphinSortFilterProxyModel* proxyModel,
-                KActionCollection* actionCollection);
+                DolphinSortFilterProxyModel* proxyModel);
 
     virtual ~DolphinView();
 
@@ -362,6 +360,12 @@ public:
      */
     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
      */
@@ -594,12 +598,6 @@ private slots:
      */
     void slotDeleteFileFinished(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);
 
index 1059f0f9a7bd211c4d00afd4d0f08ee41f0237c3..e6966affb153b30e01af5f06e36e8b97602930eb 100644 (file)
@@ -115,8 +115,7 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
                              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&)),