group items (time/track/...) are expanded on single-click
authorpavelpa <pavelpa@localhost>
Wed, 20 Jan 2010 22:04:12 +0000 (22:04 +0000)
committerpavelpa <pavelpa@localhost>
Wed, 20 Jan 2010 22:04:12 +0000 (22:04 +0000)
src/mvc/treeview.cpp
src/mvc/treeview.h

index e9971e6..ac1e5d7 100644 (file)
@@ -14,6 +14,7 @@
 TreeView::TreeView(QWidget *aParent)
     : QTreeView(aParent)
 {
+    connect(this, SIGNAL(clicked(QModelIndex)), SLOT(handleItemClicked(QModelIndex)));
 }
 
 void TreeView::mouseReleaseEvent(QMouseEvent *aEvent)
@@ -123,3 +124,14 @@ bool TreeView::testForControlClicked(const QModelIndex &aIndex, const QPoint &aP
     return handled;
 }
 
+void TreeView::handleItemClicked(const QModelIndex &index)
+{
+    if(!index.parent().isValid()) // time-group
+    {
+        if(isExpanded(index)) 
+            setExpanded(index, false);
+        else
+            setExpanded(index, true);
+    }
+}
+
index 7f2d198..cf21e06 100644 (file)
@@ -12,6 +12,8 @@ public:
 private:
     void mouseReleaseEvent(QMouseEvent *aEvent);
     bool testForControlClicked(const QModelIndex &aIndex, const QPoint &aPoint);
+private slots:
+    void handleItemClicked(const QModelIndex &index);
 signals:
     void requestForMap(const QModelIndex &aIndex);
 };