diff options
| author | George Goldberg <[email protected]> | 2008-06-02 10:07:13 +0000 |
|---|---|---|
| committer | George Goldberg <[email protected]> | 2008-06-02 10:07:13 +0000 |
| commit | 0a3a481ee2c850d6cacf48c2ffcf08b1ee8adce6 (patch) | |
| tree | fe0acecf35f143e763b0ccf3e61b4b2e62c3cd29 /src/dolphinpart.cpp | |
| parent | 6c24907d28a7879fba5d0b68c75b835db707e514 (diff) | |
Fix the edit-menu action disabling/enabling bug in dolphinpart finally! Also, move FileItemCapabilities from dolphin to KonqFileItemCapabilities at dfaure's request (making it implicitly shared along the way).
BUGS:161594
svn path=/trunk/KDE/kdebase/apps/; revision=815584
Diffstat (limited to 'src/dolphinpart.cpp')
| -rw-r--r-- | src/dolphinpart.cpp | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp index fb34941c2..766a8f0dd 100644 --- a/src/dolphinpart.cpp +++ b/src/dolphinpart.cpp @@ -23,6 +23,7 @@ #include "dolphinview.h" #include "dolphinmodel.h" +#include <konq_fileitemcapabilities.h> #include <konq_operations.h> #include <kaboutdata.h> @@ -185,24 +186,37 @@ void DolphinPart::slotGoTriggered(QAction* action) void DolphinPart::slotSelectionChanged(const KFileItemList& selection) { const bool hasSelection = !selection.isEmpty(); + + QAction* renameAction = actionCollection()->action("rename"); + QAction* moveToTrashAction = actionCollection()->action("move_to_trash"); + QAction* deleteAction = actionCollection()->action("delete"); + QAction* editMimeTypeAction = actionCollection()->action("editMimeType"); + QAction* propertiesAction = actionCollection()->action("properties"); + if (!hasSelection) { stateChanged("has_no_selection"); + + emit m_extension->enableAction("cut", false); + emit m_extension->enableAction("copy", false); + renameAction->setEnabled(false); + moveToTrashAction->setEnabled(false); + deleteAction->setEnabled(false); + editMimeTypeAction->setEnabled(false); + propertiesAction->setEnabled(false); } else { stateChanged("has_selection"); - } - QStringList actions; - actions << "rename" << "move_to_trash" << "delete" << "editMimeType" << "properties"; - foreach(const QString& actionName, actions) { - QAction* action = actionCollection()->action(actionName); - Q_ASSERT(action); - if (action) { - action->setEnabled(hasSelection); - } + KonqFileItemCapabilities capabilities(selection); + const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving(); + + renameAction->setEnabled(capabilities.supportsMoving()); + moveToTrashAction->setEnabled(enableMoveToTrash); + deleteAction->setEnabled(capabilities.supportsDeleting()); + editMimeTypeAction->setEnabled(true); + propertiesAction->setEnabled(true); + emit m_extension->enableAction("cut", capabilities.supportsMoving()); + emit m_extension->enableAction("copy", true); } - - emit m_extension->enableAction("cut", hasSelection); - emit m_extension->enableAction("copy", hasSelection); } void DolphinPart::updatePasteAction() |
