(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
#include <kmenubar.h>
#include <kmessagebox.h>
#include <konqmimedata.h>
+#include <konq_operations.h>
#include <kpropertiesdialog.h>
#include <kprotocolinfo.h>
#include <ktoggleaction.h>
}
}
+void DolphinMainWindow::createDir()
+{
+ const KUrl& url = m_activeViewContainer->view()->url();
+ KonqOperations::newDir(this, url);
+}
+
void DolphinMainWindow::updateNewMenu()
{
m_newMenu->slotCheckUpToDate();
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"));
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();
KUrl(),
m_dirLister,
m_dolphinModel,
- m_proxyModel,
- actionCollection());
+ m_proxyModel);
setWidget(m_view);
setXMLFile("dolphinpart.rc");
// 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*)));
}
}
+void DolphinPart::createDir()
+{
+ KonqOperations::newDir(m_view, url());
+}
+
#include "dolphinpart.moc"
*/
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,
***************************************************************************/
#include "dolphinview.h"
-#include <ktoggleaction.h>
-#include <kactioncollection.h>
#include <QApplication>
#include <QClipboard>
#include <QTimer>
#include <QScrollBar>
+#include <kactioncollection.h>
#include <kcolorscheme.h>
#include <kdirlister.h>
#include <kfileitemdelegate.h>
#include <kmimetyperesolver.h>
#include <konqmimedata.h>
#include <konq_operations.h>
+#include <ktoggleaction.h>
#include <kurl.h>
#include "dolphindropcontroller.h"
const KUrl& url,
KDirLister* dirLister,
DolphinModel* dolphinModel,
- DolphinSortFilterProxyModel* proxyModel,
- KActionCollection* actionCollection) :
+ DolphinSortFilterProxyModel* proxyModel) :
QWidget(parent),
m_active(true),
m_showPreview(false),
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()
m_previewJob = 0;
}
-void DolphinView::createDir()
-{
- KonqOperations::newDir(this, url());
-}
-
void DolphinView::cutSelectedItems()
{
QMimeData* mimeData = new QMimeData();
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"
* @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();
*/
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
*/
*/
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);
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&)),