]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Cleanup: let the DolphinView be aware about the used action collection. This will...
authorPeter Penz <peter.penz19@gmail.com>
Mon, 21 Jan 2008 14:16:31 +0000 (14:16 +0000)
committerPeter Penz <peter.penz19@gmail.com>
Mon, 21 Jan 2008 14:16:31 +0000 (14:16 +0000)
CCMAIL: faure@kde.org

svn path=/trunk/KDE/kdebase/apps/; revision=764347

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

index 1157124f927e90f04d4c885379547ca2bd1dea50..e0386467ee5bceea714b952b8637d9b3c5b025ea 100644 (file)
@@ -59,7 +59,6 @@
 #include <kmenu.h>
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <kmenu.h>
 #include <kmenubar.h>
 #include <kmessagebox.h>
-#include <konq_operations.h>
 #include <konqmimedata.h>
 #include <kpropertiesdialog.h>
 #include <kprotocolinfo.h>
 #include <konqmimedata.h>
 #include <kpropertiesdialog.h>
 #include <kprotocolinfo.h>
@@ -423,12 +422,6 @@ 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();
@@ -992,13 +985,6 @@ void DolphinMainWindow::setupActions()
     connect(menu, SIGNAL(aboutToShow()),
             this, SLOT(updateNewMenu()));
 
     connect(menu, SIGNAL(aboutToShow()),
             this, SLOT(updateNewMenu()));
 
-    // 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);
-
     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 43dc2248aa5657e276f4e3d57ab816fd675c2fd9..f757520c371a7e10ee3daa0311e7d45a8922a220 100644 (file)
@@ -163,9 +163,6 @@ protected:
     virtual void readProperties(const KConfigGroup& group);
 
 private slots:
     virtual void readProperties(const KConfigGroup& group);
 
 private slots:
-    /** Opens the dialog for creating a directory. */
-    void createDir();
-
     /** Updates the 'Create New...' sub menu. */
     void updateNewMenu();
 
     /** Updates the 'Create New...' sub menu. */
     void updateNewMenu();
 
index d26f14061fd00722fd383fd8cba7ace4f0de0e5b..235f176cd43f38bc4fc42f86c5f1f164471d8f1a 100644 (file)
@@ -70,7 +70,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
                              KUrl(),
                              m_dirLister,
                              m_dolphinModel,
                              KUrl(),
                              m_dirLister,
                              m_dolphinModel,
-                             m_proxyModel);
+                             m_proxyModel,
+                             actionCollection());
     setWidget(m_view);
 
     setXMLFile("dolphinpart.rc");
     setWidget(m_view);
 
     setXMLFile("dolphinpart.rc");
@@ -144,14 +145,6 @@ void DolphinPart::createActions()
     propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return);
     connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
 
     propertiesAction->setShortcut(Qt::ALT+Qt::Key_Return);
     connect(propertiesAction, SIGNAL(triggered()), SLOT(slotProperties()));
 
-    // 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(slotNewDir()));
-    newDirAction->setShortcut(Qt::Key_F10);
-    widget()->addAction(newDirAction);
-
     // Go menu
 
     QActionGroup* goActionGroup = new QActionGroup(this);
     // Go menu
 
     QActionGroup* goActionGroup = new QActionGroup(this);
@@ -414,11 +407,6 @@ void DolphinPart::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers mod
         m_view->trashSelectedItems();
 }
 
         m_view->trashSelectedItems();
 }
 
-void DolphinPart::slotNewDir()
-{
-    KonqOperations::newDir(widget(), url());
-}
-
 void DolphinPart::slotEditMimeType()
 {
     const KFileItemList items = m_view->selectedItems();
 void DolphinPart::slotEditMimeType()
 {
     const KFileItemList items = m_view->selectedItems();
index 300924a8da9d79c939f18655c88f34dc0b805004..3e3c73f6643377b3f64394631be0a153e208683a 100644 (file)
@@ -115,11 +115,6 @@ private Q_SLOTS:
      */
     void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
 
      */
     void slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers);
 
-    /**
-     * Connected to the key shortcut for "new directory" (F10)
-     */
-    void slotNewDir();
-
     /**
      * Connected to all "Go" menu actions provided by DolphinPart
      */
     /**
      * Connected to all "Go" menu actions provided by DolphinPart
      */
index 09dd153a00d3a2bb685252a6342871f96a249786..819420210a3463d21ab123761255392a13a7a35e 100644 (file)
@@ -62,7 +62,8 @@ DolphinView::DolphinView(QWidget* parent,
                          const KUrl& url,
                          KDirLister* dirLister,
                          DolphinModel* dolphinModel,
                          const KUrl& url,
                          KDirLister* dirLister,
                          DolphinModel* dolphinModel,
-                         DolphinSortFilterProxyModel* proxyModel) :
+                         DolphinSortFilterProxyModel* proxyModel,
+                         KActionCollection* actionCollection) :
     QWidget(parent),
     m_active(true),
     m_showPreview(false),
     QWidget(parent),
     m_active(true),
     m_showPreview(false),
@@ -122,6 +123,16 @@ 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()
@@ -1026,6 +1037,11 @@ void DolphinView::slotDeleteFileFinished(KJob* job)
     }
 }
 
     }
 }
 
+void DolphinView::createDir()
+{
+    KonqOperations::newDir(this, url());
+}
+
 void DolphinView::cutSelectedItems()
 {
     QMimeData* mimeData = new QMimeData();
 void DolphinView::cutSelectedItems()
 {
     QMimeData* mimeData = new QMimeData();
index fa5b18471b4edd6831774d4a00c1eb322f53ff65..b42f57007334e3b1da52dc47a98a01852e7c0a6b 100644 (file)
@@ -47,6 +47,7 @@ class DolphinModel;
 class DolphinSortFilterProxyModel;
 class IconManager;
 class KAction;
 class DolphinSortFilterProxyModel;
 class IconManager;
 class KAction;
+class KActionCollection;
 class KDirLister;
 class KFileItemDelegate;
 class KUrl;
 class KDirLister;
 class KFileItemDelegate;
 class KUrl;
@@ -116,21 +117,23 @@ public:
     };
 
     /**
     };
 
     /**
-     * @param parent          Parent widget of the view.
-     * @param url             Specifies the content which should be shown.
-     * @param dirLister       Used directory lister. The lister is not owned
-     *                        by the view and won't get deleted.
-     * @param dolphinModel    Used directory model. 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 parent           Parent widget of the view.
+     * @param url              Specifies the content which should be shown.
+     * @param dirLister        Used directory lister. The lister is not owned
+     *                         by the view and won't get deleted.
+     * @param dolphinModel     Used directory model. 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);
+                DolphinSortFilterProxyModel* proxyModel,
+                KActionCollection* actionCollection);
 
     virtual ~DolphinView();
 
 
     virtual ~DolphinView();
 
@@ -591,6 +594,12 @@ private slots:
      */
     void slotDeleteFileFinished(KJob* job);
 
      */
     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);
 
 private:
     void loadDirectory(const KUrl& url, bool reload = false);
 
index a1846dc758c73bd2acb4a9351595cf3fc284c21c..b9caa7b8e6fdafd27cd0ae7b80abeb27afc31868 100644 (file)
@@ -115,7 +115,8 @@ DolphinViewContainer::DolphinViewContainer(DolphinMainWindow* mainWindow,
                              url,
                              m_dirLister,
                              m_dolphinModel,
                              url,
                              m_dirLister,
                              m_dolphinModel,
-                             m_proxyModel);
+                             m_proxyModel,
+                             mainWindow->actionCollection());
     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&)),