]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Restore old behavior: Navigating by double-clicking in folder panel (Double-Click...
authorEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Thu, 20 Sep 2012 15:56:32 +0000 (17:56 +0200)
committerEmmanuel Pescosta <emmanuelpescosta099@gmail.com>
Thu, 20 Sep 2012 15:56:32 +0000 (17:56 +0200)
BUG: 295573
REVIEW: 106497
FIXED-IN: 4.9.2

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

index 52f8e007846ee5cb3c861638f85d0a346b4bbeef..41a86324bb1f612a0ca81b122cb3aeccb8e09cab 100644 (file)
@@ -48,6 +48,7 @@ KItemListController::KItemListController(KItemModelBase* model, KItemListView* v
     m_clearSelectionIfItemsAreNotDragged(false),
     m_selectionBehavior(NoSelection),
     m_autoActivationBehavior(ActivationAndExpansion),
+    m_mouseDoubleClickAction(ActivateItemOnly),
     m_model(0),
     m_view(0),
     m_selectionManager(new KItemListSelectionManager(this)),
@@ -168,6 +169,16 @@ KItemListController::AutoActivationBehavior KItemListController::autoActivationB
     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);
@@ -755,6 +766,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();
index 1ffd785640ec83269c1ee881da68c7d113a28cb0..235e4a9eb41e7dc8c13e89fd60ef151ab3a8ded8 100644 (file)
@@ -65,6 +65,7 @@ class LIBDOLPHINPRIVATE_EXPORT KItemListController : public QObject
     Q_PROPERTY(KItemListView *view READ view WRITE setView)
     Q_PROPERTY(SelectionBehavior selectionBehavior READ selectionBehavior WRITE setSelectionBehavior)
     Q_PROPERTY(AutoActivationBehavior autoActivationBehavior READ autoActivationBehavior WRITE setAutoActivationBehavior)
+    Q_PROPERTY(MouseDoubleClickAction mouseDoubleClickAction READ mouseDoubleClickAction WRITE setMouseDoubleClickAction)
 
 public:
     enum SelectionBehavior {
@@ -78,6 +79,11 @@ public:
         ExpansionOnly
     };
 
+    enum MouseDoubleClickAction {
+        ActivateAndExpandItem,
+        ActivateItemOnly
+    };
+
     /**
      * @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.
@@ -100,6 +106,9 @@ public:
     void setAutoActivationBehavior(AutoActivationBehavior behavior);
     AutoActivationBehavior autoActivationBehavior() const;
 
+    void setMouseDoubleClickAction(MouseDoubleClickAction action);
+    MouseDoubleClickAction mouseDoubleClickAction() const;
+
     /**
      * Sets the delay in milliseconds when dragging an object above an item
      * until the item gets activated automatically. A value of -1 indicates
@@ -297,6 +306,7 @@ private:
     bool m_clearSelectionIfItemsAreNotDragged;
     SelectionBehavior m_selectionBehavior;
     AutoActivationBehavior m_autoActivationBehavior;
+    MouseDoubleClickAction m_mouseDoubleClickAction;
     KItemModelBase* m_model;
     KItemListView* m_view;
     KItemListSelectionManager* m_selectionManager;
index e04842c4c0e007afef0039f1c7e1078b64ace746..13093fff690bef9431ada519fcf77b584e8aae7e 100644 (file)
@@ -141,6 +141,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->setMouseDoubleClickAction(KItemListController::ActivateAndExpandItem);
         m_controller->setAutoActivationDelay(750);
         m_controller->setSingleClickActivation(true);