┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeorge Goldberg <[email protected]>2008-06-02 02:50:36 +0000
committerGeorge Goldberg <[email protected]>2008-06-02 02:50:36 +0000
commitdf7c2385eca7184e349af7265f585ebdabe66ab2 (patch)
tree9b87a3a3b03b0bb3276d7af39b49ba198af00ca1 /src
parent32298bba66fe57a6a42a1b92ae9aec002a637483 (diff)
Fix dolphinpart context menu so that the delete/rename/send to trash options are disabled when the directory containing the selected files/dirs is not writable.
CCBUGS: 161594 Issues remaining: Send to trash should be disabled on remote files (and replaced with delete) and edit menu of konqueror still has the actions like cut/delete/rename always enabled. svn path=/trunk/KDE/kdebase/apps/; revision=815517
Diffstat (limited to 'src')
-rw-r--r--src/dolphinpart.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/dolphinpart.cpp b/src/dolphinpart.cpp
index 46867dbad..fefec95a1 100644
--- a/src/dolphinpart.cpp
+++ b/src/dolphinpart.cpp
@@ -297,34 +297,44 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
KParts::BrowserExtension::PopupFlags popupFlags = KParts::BrowserExtension::DefaultPopupItems
| KParts::BrowserExtension::ShowProperties
| KParts::BrowserExtension::ShowUrlOperations;
- // TODO KonqKfmIconView had if ( !rootItem->isWritable() )
- // popupFlags |= KParts::BrowserExtension::NoDeletion;
KFileItem item(_item);
if (item.isNull()) { // viewport context menu
popupFlags |= KParts::BrowserExtension::ShowNavigationItems | KParts::BrowserExtension::ShowUp;
- // TODO get m_dirLister->rootItem if possible. or via kdirmodel?
- // and use this as fallback:
- item = KFileItem( S_IFDIR, (mode_t)-1, url() );
+ item = m_dirLister->rootItem();
+ if (item.isNull())
+ item = KFileItem( S_IFDIR, (mode_t)-1, url() );
}
KParts::BrowserExtension::ActionGroupMap actionGroups;
QList<QAction *> editActions;
if (!_item.isNull()) { // only for context menu on one or more items
- // TODO if ( sMoving )
- editActions.append(actionCollection()->action("rename"));
+ bool sDeleting = true;
+ bool sMoving = true;
+
+ // If the parent directory of the selected item is writable, moving
+ // and deleting are possible.
+ KFileItem parentDir = m_dirLister->rootItem();
+ if (!parentDir.isWritable()) {
+ popupFlags |= KParts::BrowserExtension::NoDeletion;
+ sDeleting = false;
+ sMoving = false;
+ }
+
+ if ( sMoving )
+ editActions.append(actionCollection()->action("rename"));
bool addTrash = false;
bool addDel = false;
bool isIntoTrash = _item.url().protocol() == "trash";
- if ( /*TODO sMoving &&*/ !isIntoTrash )
+ if ( sMoving && !isIntoTrash )
addTrash = true;
- /* TODO if ( sDeleting ) */ {
+ if ( sDeleting ) {
if ( !item.isLocalFile() )
addDel = true;
else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {