┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/dolphinpart.cpp
diff options
context:
space:
mode:
authorDavid Faure <[email protected]>2007-11-15 14:59:02 +0000
committerDavid Faure <[email protected]>2007-11-15 14:59:02 +0000
commit53d65e6392d3b03d7709385df5006d5d34c22852 (patch)
tree8835b13baca4e53540c3f94cc1f4472c77c4567c /src/dolphinpart.cpp
parent205bf2035d30517e781271bbcae8e4c102d71871 (diff)
Implement renaming in dolphinpart.
No more rename action provided by konqueror, the part provides it now. Had to move a bit of code around in dolphin, as discussed with Peter. svn path=/trunk/KDE/kdebase/apps/; revision=737121
Diffstat (limited to 'src/dolphinpart.cpp')
-rw-r--r--src/dolphinpart.cpp45
1 files changed, 40 insertions, 5 deletions
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index 2f52447ec..27000eae6 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -78,14 +78,18 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi
this, SLOT(slotErrorMessage(QString)));
connect(m_view, SIGNAL(itemTriggered(KFileItem)),
this, SLOT(slotItemTriggered(KFileItem)));
- connect(m_view, SIGNAL(requestContextMenu(KFileItem, const KUrl&)),
- this, SLOT(slotOpenContextMenu(KFileItem, const KUrl&)));
+ connect(m_view, SIGNAL(requestContextMenu(KFileItem,KUrl)),
+ this, SLOT(slotOpenContextMenu(KFileItem,KUrl)));
connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
m_extension, SIGNAL(selectionInfo(KFileItemList)));
+ connect(m_view, SIGNAL(selectionChanged(KFileItemList)),
+ this, SLOT(slotSelectionChanged(KFileItemList)));
connect(m_view, SIGNAL(requestItemInfo(KFileItem)),
this, SLOT(slotRequestItemInfo(KFileItem)));
- connect(m_view, SIGNAL(urlChanged(const KUrl&)),
- this, SLOT(slotUrlChanged(const KUrl&)));
+ connect(m_view, SIGNAL(urlChanged(KUrl)),
+ this, SLOT(slotUrlChanged(KUrl)));
+ connect(m_view, SIGNAL(modeChanged()),
+ this, SLOT(updateViewActions()));
createActions();
updateViewActions();
@@ -122,6 +126,27 @@ void DolphinPart::createActions()
viewModeActions->addAction(DolphinView::detailsModeAction(actionCollection()));
viewModeActions->addAction(DolphinView::columnsModeAction(actionCollection()));
connect(viewModeActions, SIGNAL(triggered(QAction*)), this, SLOT(slotViewModeActionTriggered(QAction*)));
+
+ KAction* renameAction = new KAction(i18nc("@action:inmenu", "Rename..."), this);
+ connect(renameAction, SIGNAL(triggered()), m_view, SLOT(renameSelectedItems()));
+ renameAction->setShortcut(Qt::Key_F2);
+ actionCollection()->addAction("rename", renameAction);
+}
+
+void DolphinPart::slotSelectionChanged(const KFileItemList& selection)
+{
+ // Yes, DolphinMainWindow has very similar code :/
+ if (selection.isEmpty()) {
+ stateChanged("has_no_selection");
+ } else {
+ stateChanged("has_selection");
+
+ QAction* renameAction = actionCollection()->action("rename");
+ Q_ASSERT(renameAction);
+ if (renameAction) {
+ renameAction->setEnabled(true);
+ }
+ }
}
void DolphinPart::updateViewActions()
@@ -218,8 +243,18 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
item = KFileItem( S_IFDIR, (mode_t)-1, url() );
}
+ KParts::BrowserExtension::ActionGroupMap actionGroups;
+ QList<QAction *> editActions;
+ editActions.append(actionCollection()->action("rename"));
+ actionGroups.insert("editactions", editActions);
+
KFileItemList items; items.append(item);
- emit m_extension->popupMenu( QCursor::pos(), items, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags );
+ emit m_extension->popupMenu(QCursor::pos(),
+ items,
+ KParts::OpenUrlArguments(),
+ KParts::BrowserArguments(),
+ popupFlags,
+ actionGroups);
}
void DolphinPart::slotViewModeActionTriggered(QAction* action)