From c00478bbc1001d10dcfc04e9b0ea251620837e85 Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 21 Jan 2008 19:08:52 +0000 Subject: [PATCH] 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=/branches/KDE/4.0/kdebase/apps/; revision=764429 --- src/dolphinmainwindow.cpp | 10 ++++++++++ src/dolphinmainwindow.h | 6 ++++++ src/dolphinpart.cpp | 11 +++++++++-- src/dolphinpart.h | 6 ++++++ src/dolphinview.cpp | 32 +++++++++++++------------------- src/dolphinview.h | 16 +++++++--------- src/dolphinviewcontainer.cpp | 3 +-- 7 files changed, 52 insertions(+), 32 deletions(-) diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 2048de1a5..1da9377c7 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -60,6 +60,7 @@ #include #include #include +#include #include #include #include @@ -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")); diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h index f757520c3..e99add896 100644 --- a/src/dolphinmainwindow.h +++ b/src/dolphinmainwindow.h @@ -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(); diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index 235f176cd..2c4c1eaa3 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -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" diff --git a/src/dolphinpart.h b/src/dolphinpart.h index 3e3c73f66..04161b6be 100644 --- a/src/dolphinpart.h +++ b/src/dolphinpart.h @@ -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, diff --git a/src/dolphinview.cpp b/src/dolphinview.cpp index 4a1fbb927..138971360 100644 --- a/src/dolphinview.cpp +++ b/src/dolphinview.cpp @@ -19,8 +19,6 @@ ***************************************************************************/ #include "dolphinview.h" -#include -#include #include #include @@ -30,6 +28,7 @@ #include #include +#include #include #include #include @@ -43,6 +42,7 @@ #include #include #include +#include #include #include "dolphindropcontroller.h" @@ -61,8 +61,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), @@ -128,16 +127,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() @@ -1149,11 +1138,6 @@ void DolphinView::slotPreviewJobFinished(KJob* job) m_previewJob = 0; } -void DolphinView::createDir() -{ - KonqOperations::newDir(this, url()); -} - void DolphinView::cutSelectedItems() { QMimeData* mimeData = new QMimeData(); @@ -1263,4 +1247,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" diff --git a/src/dolphinview.h b/src/dolphinview.h index 485748751..8076a62f0 100644 --- a/src/dolphinview.h +++ b/src/dolphinview.h @@ -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 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(); @@ -364,6 +362,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 */ @@ -618,12 +622,6 @@ private slots: */ 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); diff --git a/src/dolphinviewcontainer.cpp b/src/dolphinviewcontainer.cpp index b9caa7b8e..a1846dc75 100644 --- a/src/dolphinviewcontainer.cpp +++ b/src/dolphinviewcontainer.cpp @@ -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&)), -- 2.47.3