diff options
| author | David Faure <[email protected]> | 2007-11-17 00:08:54 +0000 |
|---|---|---|
| committer | David Faure <[email protected]> | 2007-11-17 00:08:54 +0000 |
| commit | 8578ad1e751d218b40c49a601934a23d8ecd027d (patch) | |
| tree | 9d486cf3620757d56f320dcefe80d99440d6e752 /src/dolphinpart.cpp | |
| parent | 3a1d98a8eb1c758859152a27c7bb697d8d0162e9 (diff) | |
Fix "delete" and "move to trash" actions in dolphinpart; moved all logic for those out of konqueror.
Inside dolphin, the usual: moving code to DolphinView.
Pressing shift while clicking on "Move to Trash" in konq (dolphinpart) offers to delete, as in kde3 (this bit of logic might be good for dolphin itself too? see DolphinPart::slotTrashActivated)
CCMAIL: [email protected]
svn path=/trunk/KDE/kdebase/apps/; revision=737682
Diffstat (limited to 'src/dolphinpart.cpp')
| -rw-r--r-- | src/dolphinpart.cpp | 45 |
1 files changed, 34 insertions, 11 deletions
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index a0871ce06..113b840e7 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -91,8 +91,9 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi createActions(); updateViewActions(); + slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions - // TODO provide these actions in the menu, merged with the existing view-mode-actions somehow + // TODO provide the viewmode actions in the menu, merged with the existing view-mode-actions somehow // [Q_PROPERTY introspection?] // TODO sort_by_* actions @@ -104,8 +105,6 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QStringLi // (sort of spacial navigation) // TODO MMB-click should do something like KonqDirPart::mmbClicked - - // TODO updating the trash and del actions too - or removing special handling of those from konq? } DolphinPart::~DolphinPart() @@ -121,11 +120,15 @@ void DolphinPart::createActions() viewModeActions->addAction(DolphinView::columnsModeAction(actionCollection())); connect(viewModeActions, SIGNAL(triggered(QAction*)), this, SLOT(slotViewModeActionTriggered(QAction*))); - KAction* renameAction = new KAction(i18nc("@action:inmenu", "Rename..."), this); + KAction* renameAction = DolphinView::createRenameAction(actionCollection()); connect(renameAction, SIGNAL(triggered()), m_view, SLOT(renameSelectedItems())); - renameAction->setEnabled(false); - renameAction->setShortcut(Qt::Key_F2); - actionCollection()->addAction("rename", renameAction); + + KAction* moveToTrashAction = DolphinView::createMoveToTrashAction(actionCollection()); + connect(moveToTrashAction, SIGNAL(triggered(Qt::MouseButtons, Qt::KeyboardModifiers)), + this, SLOT(slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers))); + + KAction* deleteAction = DolphinView::createDeleteAction(actionCollection()); + connect(deleteAction, SIGNAL(triggered()), m_view, SLOT(deleteSelectedItems())); } void DolphinPart::slotSelectionChanged(const KFileItemList& selection) @@ -136,13 +139,18 @@ void DolphinPart::slotSelectionChanged(const KFileItemList& selection) stateChanged("has_no_selection"); } else { stateChanged("has_selection"); + } - QAction* renameAction = actionCollection()->action("rename"); - Q_ASSERT(renameAction); - if (renameAction) { - renameAction->setEnabled(true); + QStringList actions; + actions << "rename" << "move_to_trash" << "delete"; + foreach(const QString& actionName, actions) { + QAction* action = actionCollection()->action(actionName); + Q_ASSERT(action); + if (action) { + action->setEnabled(hasSelection); } } + emit m_extension->enableAction("cut", hasSelection); emit m_extension->enableAction("copy", hasSelection); } @@ -251,6 +259,8 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&) KParts::BrowserExtension::ActionGroupMap actionGroups; QList<QAction *> editActions; editActions.append(actionCollection()->action("rename")); + editActions.append(actionCollection()->action("move_to_trash")); + editActions.append(actionCollection()->action("delete")); actionGroups.insert("editactions", editActions); KFileItemList items; items.append(item); @@ -295,4 +305,17 @@ void DolphinPartBrowserExtension::paste() m_part->view()->paste(); } +//// + +void DolphinPart::slotTrashActivated(Qt::MouseButtons, Qt::KeyboardModifiers modifiers) +{ + // Note: kde3's konq_mainwindow.cpp used to check + // reason == KAction::PopupMenuActivation && ... + // but this isn't supported anymore + if (modifiers & Qt::ShiftModifier) + m_view->deleteSelectedItems(); + else + m_view->trashSelectedItems(); +} + #include "dolphinpart.moc" |
