]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Fixes Bug 293200 - Drag&drop files in dolphin doesnt preserve origin
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Wed, 19 Sep 2012 17:00:52 +0000 (19:00 +0200)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Wed, 19 Sep 2012 17:00:52 +0000 (19:00 +0200)
Patch 106381 Comment #3:
When "Open folders during drag operations" is enabled, two things happen, both in the DolphinView and in the Folders Panel:

1) When hovering a folder that can be expanded (this is the case for folders with sub-folders in the Folders Panel and in the DolphinView if in Details View mode), toggle its "expanded" state.
2) When hovering a folder that can not be expanded (i.e., a folder without sub-folders or any folder in Icons or Compact View), open this folder in the DolphinView via the KItemListController's itemActivated(int) signal.

The bug described in bug 293200 comment 3 is that 1) is always wanted, but 2) is not wanted for the Folders Panel.

BUG: 293200
FIXED-IN: 4.9.2

src/kitemviews/kitemlistcontroller.cpp
src/kitemviews/kitemlistcontroller.h
src/panels/folders/folderspanel.cpp

index 88f5d9f7cff1614fb8595b470d46916584710a27..52f8e007846ee5cb3c861638f85d0a346b4bbeef 100644 (file)
@@ -47,6 +47,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
     m_selectionTogglePressed(false),
     m_clearSelectionIfItemsAreNotDragged(false),
     m_selectionBehavior(NoSelection),
+    m_autoActivationBehavior(ActivationAndExpansion),
     m_model(0),
     m_view(0),
     m_selectionManager(new KItemListSelectionManager(this)),
@@ -157,6 +158,16 @@ KItemListController::SelectionBehavior KItemListController::selectionBehavior()
     return m_selectionBehavior;
 }
 
+void KItemListController::setAutoActivationBehavior(AutoActivationBehavior behavior)
+{
+    m_autoActivationBehavior = behavior;
+}
+
+KItemListController::AutoActivationBehavior KItemListController::autoActivationBehavior() const
+{
+    return m_autoActivationBehavior;
+}
+
 void KItemListController::setAutoActivationDelay(int delay)
 {
     m_autoActivationTimer->setInterval(delay);
@@ -471,7 +482,7 @@ void KItemListController::slotAutoActivationTimeout()
         if (m_view->supportsItemExpanding() && m_model->isExpandable(index)) {
             const bool expanded = m_model->isExpanded(index);
             m_model->setExpanded(index, !expanded);
-        } else {
+        } else if (m_autoActivationBehavior != ExpansionOnly) {
             emit itemActivated(index);
         }
     }
index a88152622b5c8bd1c92f9386141107f50ad48f1c..1ffd785640ec83269c1ee881da68c7d113a28cb0 100644 (file)
@@ -64,6 +64,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject
     Q_PROPERTY(KItemModelBase* model READ model WRITE setModel)
     Q_PROPERTY(KItemListView *view READ view WRITE setView)
     Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
+    Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior)
 
 public:
     enum SelectionBehavior {
@@ -72,6 +73,11 @@ public:
         MultiSelection
     };
 
+    enum AutoActivationBehavior {
+        ActivationAndExpansion,
+        ExpansionOnly
+    };
+
     /**
      * @param model  Model of the controller. The ownership is passed to the controller.
      * @param view   View of the controller. The ownership is passed to the controller.
@@ -91,6 +97,9 @@ public:
     void setSelectionBehavior(SelectionBehavior behavior);
     SelectionBehavior selectionBehavior() const;
 
+    void setAutoActivationBehavior(AutoActivationBehavior behavior);
+    AutoActivationBehavior autoActivationBehavior() const;
+
     /**
      * Sets the delay in milliseconds when dragging an object above an item
      * until the item gets activated automatically. A value of -1 indicates
@@ -287,6 +296,7 @@ private:
     bool m_selectionTogglePressed;
     bool m_clearSelectionIfItemsAreNotDragged;
     SelectionBehavior m_selectionBehavior;
+    AutoActivationBehavior m_autoActivationBehavior;
     KItemModelBase* m_model;
     KItemListView* m_view;
     KItemListSelectionManager* m_selectionManager;
index 0760200b63098ebad8be35d39dc657bf7e1bf9f2..e04842c4c0e007afef0039f1c7e1078b64ace746 100644 (file)
@@ -140,6 +140,7 @@ void FoldersPanel::showEvent(QShowEvent* event)
 
         m_controller = new KItemListController(m_model, view, this);
         m_controller->setSelectionBehavior(KItemListController::SingleSelection);
+        m_controller->setAutoActivationBehavior(KItemListController::ExpansionOnly);
         m_controller->setAutoActivationDelay(750);
         m_controller->setSingleClickActivation(true);