]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinmainwindow.cpp
fixed some stupid bugs I did not see in the previous commit -> after 9 hours in the...
[dolphin.git] / src / dolphinmainwindow.cpp
index 37fdce75b6fc1d6d224efc39c7ca2d2fd5b2228d..4b648e98806100deb1f4c2a9b743005d8850ae6f 100644 (file)
@@ -32,6 +32,7 @@
 #include "dolphinsettingsdialog.h"
 #include "dolphinstatusbar.h"
 #include "dolphinviewcontainer.h"
+#include "fileitemcapabilities.h"
 #include "infosidebarpage.h"
 #include "metadatawidget.h"
 #include "mainwindowadaptor.h"
@@ -457,10 +458,6 @@ void DolphinMainWindow::paste()
 void DolphinMainWindow::updatePasteAction()
 {
     QAction* pasteAction = actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
-    if (pasteAction == 0) {
-        return;
-    }
-
     QPair<bool, QString> pasteInfo = m_activeViewContainer->view()->pasteInfo();
     pasteAction->setEnabled(pasteInfo.first);
     pasteAction->setText(pasteInfo.second);
@@ -753,8 +750,9 @@ void DolphinMainWindow::openTabContextMenu(int index, const QPoint& pos)
     QAction* selectedAction = menu.exec(pos);
     if (selectedAction == newTabAction) {
         const ViewTab& tab = m_viewTab[index];
-        const KUrl url = tab.primaryView->isActive() ? tab.primaryView->url() :
-                                                       tab.secondaryView->url();
+        Q_ASSERT(tab.primaryView != 0);
+        const KUrl url = (tab.secondaryView != 0) && tab.secondaryView->isActive() ?
+                         tab.secondaryView->url() : tab.primaryView->url();
         openNewTab(url);
         m_tabBar->setCurrentIndex(m_viewTab.count() - 1);
     } else if (selectedAction == closeOtherTabsAction) {
@@ -1107,26 +1105,11 @@ void DolphinMainWindow::updateEditActions()
     } else {
         stateChanged("has_selection");
 
-        QAction* renameAction = actionCollection()->action("rename");
-        if (renameAction != 0) {
-            renameAction->setEnabled(true);
-        }
-
-        bool enableMoveToTrash = true;
-
-        KFileItemList::const_iterator it = list.begin();
-        const KFileItemList::const_iterator end = list.end();
-        while (it != end) {
-            const KUrl& url = (*it).url();
-            // only enable the 'Move to Trash' action for local files
-            if (!url.isLocalFile()) {
-                enableMoveToTrash = false;
-            }
-            ++it;
-        }
-
-        QAction* moveToTrashAction = actionCollection()->action("move_to_trash");
-        moveToTrashAction->setEnabled(enableMoveToTrash);
+        FileItemCapabilities capabilities(list);
+        actionCollection()->action("rename")->setEnabled(capabilities.supportsMoving());
+        const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
+        actionCollection()->action("move_to_trash")->setEnabled(enableMoveToTrash);
+        actionCollection()->action("delete")->setEnabled(capabilities.supportsDeleting());
     }
     updatePasteAction();
 }