]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
Add some unit tests for grouping in KFileItemModel
[dolphin.git] / src / dolphinpart.cpp
index 642b1501365a1774a75ac25238e485e96efa29d8..fc7b74dc0cca431c89003f1b22ea203a7651de16 100644 (file)
@@ -58,6 +58,7 @@
 #include <QApplication>
 #include <QClipboard>
 #include <QDir>
+#include <QTextDocument>
 
 K_PLUGIN_FACTORY(DolphinPartFactory, registerPlugin<DolphinPart>();)
 K_EXPORT_PLUGIN(DolphinPartFactory("dolphinpart", "dolphin"))
@@ -355,7 +356,8 @@ void DolphinPart::slotRequestItemInfo(const KFileItem& item)
     if (item.isNull()) {
         updateStatusBar();
     } else {
-        ReadOnlyPart::setStatusBarText(item.getStatusBarInfo());
+        const QString escapedText = Qt::escape(item.getStatusBarInfo());
+        ReadOnlyPart::setStatusBarText(QString("<qt>%1</qt>").arg(escapedText));
     }
 }
 
@@ -426,10 +428,27 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
     editActions += customActions;
 
     if (!_item.isNull()) { // only for context menu on one or more items
-        bool supportsDeleting = capabilities.supportsDeleting();
-        bool supportsMoving = capabilities.supportsMoving();
-
-        if (!supportsDeleting) {
+        const bool supportsMoving = capabilities.supportsMoving();
+
+        if (capabilities.supportsDeleting()) {
+            const bool showDeleteAction = (KGlobal::config()->group("KDE").readEntry("ShowDeleteCommand", false) ||
+                                           !item.isLocalFile());
+            const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
+
+            if (showDeleteAction && showMoveToTrashAction) {
+                delete m_removeAction;
+                m_removeAction = 0;
+                editActions.append(actionCollection()->action("move_to_trash"));
+                editActions.append(actionCollection()->action("delete"));
+            } else if (showDeleteAction && !showMoveToTrashAction) {
+                editActions.append(actionCollection()->action("delete"));
+            } else {
+                if (!m_removeAction)
+                    m_removeAction = new DolphinRemoveAction(this, actionCollection());
+                editActions.append(m_removeAction);
+                m_removeAction->update();
+            }
+        } else {
             popupFlags |= KParts::BrowserExtension::NoDeletion;
         }
 
@@ -437,35 +456,6 @@ void DolphinPart::slotOpenContextMenu(const QPoint& pos,
             editActions.append(actionCollection()->action("rename"));
         }
 
-        bool addTrash = capabilities.isLocal() && supportsMoving;
-        bool addDel = false;
-        if (supportsDeleting) {
-            if ( !item.isLocalFile() )
-                addDel = true;
-            else if (QApplication::keyboardModifiers() & Qt::ShiftModifier) {
-                addTrash = false;
-                addDel = true;
-            }
-            else {
-                KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::IncludeGlobals);
-                KConfigGroup configGroup(globalConfig, "KDE");
-                addDel = configGroup.readEntry("ShowDeleteCommand", false);
-            }
-        }
-
-        if (!addTrash || !addDel) {
-            if (!m_removeAction) {
-                m_removeAction = new DolphinRemoveAction(this, actionCollection());
-            }
-            editActions.append(m_removeAction);
-            m_removeAction->update();
-        } else {
-            delete m_removeAction;
-            m_removeAction = 0;
-            editActions.append(actionCollection()->action("move_to_trash"));
-            editActions.append(actionCollection()->action("delete"));
-        }
-
         // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
         // since otherwise the created file would not be visible.
         // But in treeview mode we should allow it.