forwardport 764429:

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
This commit is contained in:
David Faure 2008-01-21 19:31:07 +00:00
parent 20641620c8
commit e3da86af95
7 changed files with 52 additions and 32 deletions

View 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"));

View 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();

View 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"

View 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,

View 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"

View 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);

View 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&)),