]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix dolphinpart context menu so that the delete/rename/send to trash options are...
authorGeorge Goldberg <grundleborg@googlemail.com>
Mon, 2 Jun 2008 02:50:36 +0000 (02:50 +0000)
committerGeorge Goldberg <grundleborg@googlemail.com>
Mon, 2 Jun 2008 02:50:36 +0000 (02:50 +0000)
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

src/dolphinpart.cpp

index 46867dbadd223e8482100787f77d5c6e32660f16..fefec95a13aeb09d6ff0a3e9822f804440f6c614 100644 (file)
@@ -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;
     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;
 
     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
     }
 
     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";
 
 
         bool addTrash = false;
         bool addDel = false;
 
         bool isIntoTrash = _item.url().protocol() == "trash";
 
-        if ( /*TODO sMoving &&*/ !isIntoTrash )
+        if ( sMoving && !isIntoTrash )
             addTrash = true;
 
             addTrash = true;
 
-        /* TODO if ( sDeleting ) */ {
+        if ( sDeleting ) {
             if ( !item.isLocalFile() )
                 addDel = true;
             else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
             if ( !item.isLocalFile() )
                 addDel = true;
             else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {