]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Fix dolphinpart context menu so that the delete/rename/send to trash options are...
[dolphin.git] / src / dolphinpart.cpp
index 296e101d614946c8580f75174db24f8e9174be3b..fefec95a13aeb09d6ff0a3e9822f804440f6c614 100644 (file)
@@ -100,6 +100,8 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent, const QVariantL
             this, SLOT(slotRequestItemInfo(KFileItem)));
     connect(m_view, SIGNAL(urlChanged(KUrl)),
             this, SLOT(slotUrlChanged(KUrl)));
+    connect(m_view, SIGNAL(requestUrlChange(KUrl)),
+            this, SLOT(slotRequestUrlChange(KUrl)));
     connect(m_view, SIGNAL(modeChanged()),
             this, SIGNAL(viewModeChanged())); // relay signal
 
@@ -295,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) {
@@ -356,6 +368,12 @@ void DolphinPart::slotOpenContextMenu(const KFileItem& _item, const KUrl&)
 }
 
 void DolphinPart::slotUrlChanged(const KUrl& url)
+{
+    QString prettyUrl = url.pathOrUrl();
+    emit m_extension->setLocationBarUrl(prettyUrl);
+}
+
+void DolphinPart::slotRequestUrlChange(const KUrl& url)
 {
     if (m_view->url() != url) {
         // If the view URL is not equal to 'url', then an inner URL change has