]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/kitemviews/kitemlistcontroller.cpp
Fixes Bug 305783 - dragging a file over a directory #c4
[dolphin.git] / src / kitemviews / kitemlistcontroller.cpp
index 88f5d9f7cff1614fb8595b470d46916584710a27..5a7175e4ccc628617aedbd353c97299c4d645e24 100644 (file)
@@ -47,6 +47,8 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
     m_selectionTogglePressed(false),
     m_clearSelectionIfItemsAreNotDragged(false),
     m_selectionBehavior(NoSelection),
+    m_autoActivationBehavior(ActivationAndExpansion),
+    m_mouseDoubleClickAction(ActivateItemOnly),
     m_model(0),
     m_view(0),
     m_selectionManager(new KItemListSelectionManager(this)),
@@ -157,6 +159,26 @@ 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::setMouseDoubleClickAction(MouseDoubleClickAction action)
+{
+    m_mouseDoubleClickAction = action;
+}
+
+KItemListController::MouseDoubleClickAction KItemListController::mouseDoubleClickAction() const
+{
+    return m_mouseDoubleClickAction;
+}
+
 void KItemListController::setAutoActivationDelay(int delay)
 {
     m_autoActivationTimer->setInterval(delay);
@@ -467,11 +489,20 @@ void KItemListController::slotAutoActivationTimeout()
         return;
     }
 
-    if (m_model->supportsDropping(index)) {
+    /* m_view->isUnderMouse() fixes a bug in the Folder-View-Panel and in the
+     * Places-Panel.
+     *
+     * Bug: When you drag a file onto a Folder-View-Item or a Places-Item and
+     * then move away before the auto-activation timeout triggers, than the
+     * item still becomes activated/expanded.
+     *
+     * See Bug 293200 and 305783
+     */
+    if (m_model->supportsDropping(index) && m_view->isUnderMouse()) {
         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);
         }
     }
@@ -744,6 +775,14 @@ bool KItemListController::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event,
     const QPointF pos = transform.map(event->pos());
     const int index = m_view->itemAt(pos);
 
+    // Expand item if desired - See Bug 295573
+    if (m_mouseDoubleClickAction != ActivateItemOnly) {
+        if (m_view && m_model && m_view->supportsItemExpanding() && m_model->isExpandable(index)) {
+            const bool expanded = m_model->isExpanded(index);
+            m_model->setExpanded(index, !expanded);
+        }
+    }
+
     bool emitItemActivated = !m_singleClickActivation &&
                              (event->button() & Qt::LeftButton) &&
                              index >= 0 && index < m_model->count();