]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fix the edit-menu action disabling/enabling bug in dolphinpart finally! Also, move...
authorGeorge Goldberg <grundleborg@googlemail.com>
Mon, 2 Jun 2008 10:07:13 +0000 (10:07 +0000)
committerGeorge Goldberg <grundleborg@googlemail.com>
Mon, 2 Jun 2008 10:07:13 +0000 (10:07 +0000)
BUGS:161594

svn path=/trunk/KDE/kdebase/apps/; revision=815584

src/CMakeLists.txt
src/dolphincontextmenu.cpp
src/dolphincontextmenu.h
src/dolphinmainwindow.cpp
src/dolphinpart.cpp
src/fileitemcapabilities.cpp [deleted file]
src/fileitemcapabilities.h [deleted file]

index 90fade469b3ed668e05009fd8e4898b8b55d4ae4..b548c723f387241e2f04fe2cb890cc4b4942b1f3 100644 (file)
@@ -79,7 +79,7 @@ set(dolphinpart_SRCS
 
 kde4_add_plugin(dolphinpart ${dolphinpart_SRCS})
 
-target_link_libraries(dolphinpart dolphinprivate)
+target_link_libraries(dolphinpart dolphinprivate konq)
 
 install(TARGETS dolphinpart DESTINATION ${PLUGIN_INSTALL_DIR} )
 
@@ -104,7 +104,6 @@ set(dolphin_SRCS
     dolphinfileplacesview.cpp
     dolphinsettingsdialog.cpp
     draganddrophelper.cpp
-    fileitemcapabilities.cpp
     filterbar.cpp
     generalsettingspage.cpp
     generalviewsettingspage.cpp
index 13b1318da1bd70b141148114d6b3aad679091e09..a45d715dc79ded44fc818a2f7d3c8f5f84dc248b 100644 (file)
@@ -25,7 +25,6 @@
 #include "dolphinview.h"
 #include "dolphinviewcontainer.h"
 #include "dolphin_generalsettings.h"
-#include "fileitemcapabilities.h"
 
 #include <kactioncollection.h>
 #include <kfileplacesmodel.h>
@@ -39,6 +38,7 @@
 #include <kmimetypetrader.h>
 #include <knewmenu.h>
 #include <konqmimedata.h>
+#include <konq_fileitemcapabilities.h>
 #include <konq_operations.h>
 #include <konq_menuactions.h>
 #include <konq_popupmenuinformation.h>
@@ -451,10 +451,10 @@ QAction* DolphinContextMenu::createPasteAction()
     return action;
 }
 
-FileItemCapabilities& DolphinContextMenu::capabilities()
+KonqFileItemCapabilities& DolphinContextMenu::capabilities()
 {
     if (m_capabilities == 0) {
-        m_capabilities = new FileItemCapabilities(m_selectedItems);
+        m_capabilities = new KonqFileItemCapabilities(m_selectedItems);
     }
     return *m_capabilities;
 }
index 8b623114c6e1231f1b3562451525679b5bd67464..b3779c9ab71bed32aae26d4e4c270f5024d5ce47 100644 (file)
@@ -34,7 +34,7 @@ class KMenu;
 class KFileItem;
 class QAction;
 class DolphinMainWindow;
-class FileItemCapabilities;
+class KonqFileItemCapabilities;
 
 /**
  * @brief Represents the context menu which appears when doing a right
@@ -113,7 +113,7 @@ private:
     QAction* createPasteAction();
 
 private:
-    FileItemCapabilities& capabilities();
+    KonqFileItemCapabilities& capabilities();
 
 private:
     struct Entry
@@ -134,7 +134,7 @@ private:
     };
 
     DolphinMainWindow* m_mainWindow;
-    FileItemCapabilities* m_capabilities;
+    KonqFileItemCapabilities* m_capabilities;
     KFileItem m_fileInfo;
     KUrl m_baseUrl;
     KFileItemList m_selectedItems;
index 2cf81427bef434ea9a92d878572097f9b8ebff48..81d1e2670cbf4b7928425e00afebcd09f1eca423 100644 (file)
@@ -32,7 +32,6 @@
 #include "dolphinsettingsdialog.h"
 #include "dolphinstatusbar.h"
 #include "dolphinviewcontainer.h"
-#include "fileitemcapabilities.h"
 #include "infosidebarpage.h"
 #include "metadatawidget.h"
 #include "mainwindowadaptor.h"
@@ -63,6 +62,7 @@
 #include <kmenubar.h>
 #include <kmessagebox.h>
 #include <kurlnavigator.h>
+#include <konq_fileitemcapabilities.h>
 #include <konqmimedata.h>
 #include <kpropertiesdialog.h>
 #include <kprotocolinfo.h>
@@ -1114,7 +1114,7 @@ void DolphinMainWindow::updateEditActions()
         QAction* deleteAction      = col->action("delete");
         QAction* cutAction         = col->action(KStandardAction::name(KStandardAction::Cut));
 
-        FileItemCapabilities capabilities(list);
+        KonqFileItemCapabilities capabilities(list);
         const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
 
         renameAction->setEnabled(capabilities.supportsMoving());
index fb34941c2612558adb2f4ab9360aba520559dffd..766a8f0dd953a6091dbc959b1266b9fe4005392d 100644 (file)
@@ -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()
diff --git a/src/fileitemcapabilities.cpp b/src/fileitemcapabilities.cpp
deleted file mode 100644 (file)
index 6ab37ad..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at>                  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#include "fileitemcapabilities.h"
-
-#include <kfileitem.h>
-#include <kprotocolmanager.h>
-
-#include <QFileInfo>
-
-FileItemCapabilities::FileItemCapabilities(const KFileItemList& items) :
-    m_supportsReading(true),
-    m_supportsDeleting(true),
-    m_supportsWriting(true),
-    m_supportsMoving(true),
-    m_isLocal(true)
-{
-    QFileInfo parentDirInfo;
-    foreach (const KFileItem &item, items) {
-        const KUrl url = item.url();
-        m_isLocal = m_isLocal && url.isLocalFile();
-        m_supportsReading  = m_supportsReading  && KProtocolManager::supportsReading(url);
-        m_supportsDeleting = m_supportsDeleting && KProtocolManager::supportsDeleting(url);
-        m_supportsWriting  = m_supportsWriting  && KProtocolManager::supportsWriting(url);
-        m_supportsMoving   = m_supportsMoving   && KProtocolManager::supportsMoving(url);
-
-        // The following code has been taken from kdebase/apps/lib/konq/konq_popupmenu.cpp:
-        // For local files we can do better: check if we have write permission in parent directory
-        if (m_isLocal && (m_supportsDeleting || m_supportsMoving)) {
-            const QString directory = url.directory();
-            if (parentDirInfo.filePath() != directory) {
-                parentDirInfo.setFile(directory);
-            }
-            if (!parentDirInfo.isWritable()) {
-                m_supportsDeleting = false;
-                m_supportsMoving = false;
-            }
-        }
-    }
-}
-
-FileItemCapabilities::~FileItemCapabilities()
-{
-}
diff --git a/src/fileitemcapabilities.h b/src/fileitemcapabilities.h
deleted file mode 100644 (file)
index 5ed6d19..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/***************************************************************************
- *   Copyright (C) 2008 by Peter Penz <peter.penz@gmx.at>                  *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
-
-#ifndef FILEITEMCAPABILITIES_H
-#define FILEITEMCAPABILITIES_H
-
-class KFileItemList;
-
-/**
- * @brief Provides information about the access capabilities of file items.
- *
- * As soon as one file item does not support a specific capability, it is
- * marked as unsupported for all items.
- */
-class FileItemCapabilities
-{
-public:
-    FileItemCapabilities(const KFileItemList& items);
-    virtual ~FileItemCapabilities();
-    bool supportsReading() const;
-    bool supportsDeleting() const;
-    bool supportsWriting() const;
-    bool supportsMoving() const;
-    bool isLocal() const;
-
-private:
-    bool m_supportsReading : 1;
-    bool m_supportsDeleting : 1;
-    bool m_supportsWriting : 1;
-    bool m_supportsMoving : 1;
-    bool m_isLocal : 1;
-};
-
-inline bool FileItemCapabilities::supportsReading() const
-{
-    return m_supportsReading;
-}
-
-inline bool FileItemCapabilities::supportsDeleting() const
-{
-    return m_supportsDeleting;
-}
-
-inline bool FileItemCapabilities::supportsWriting() const
-{
-    return m_supportsWriting;
-}
-
-inline bool FileItemCapabilities::supportsMoving() const
-{
-    return m_supportsMoving;
-}
-
-inline bool FileItemCapabilities::isLocal() const
-{
-    return m_isLocal;
-}
-
-#endif