]> git.sesse.net Git - kdenlive/commitdiff
Optimise project tree UI
authorJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 15 Apr 2010 21:52:41 +0000 (21:52 +0000)
committerJean-Baptiste Mardelle <jb@kdenlive.org>
Thu, 15 Apr 2010 21:52:41 +0000 (21:52 +0000)
svn path=/trunk/kdenlive/; revision=4385

src/projectlist.cpp
src/projectlistview.cpp
src/projectlistview.h

index ebce6b7c56d16b3493055db8160dcbedae5e563d..6f698385dc1841b1b334e4817a080ac028801811 100644 (file)
@@ -79,8 +79,7 @@ ProjectList::ProjectList(QWidget *parent) :
     m_listView = new ProjectListView(this);;
     QVBoxLayout *layout = new QVBoxLayout;
     layout->setContentsMargins(0, 0, 0, 0);
-
-
+    layout->setSpacing(0);
 
     // setup toolbar
     KTreeWidgetSearchLine *searchView = new KTreeWidgetSearchLine(this);
index c4b8d4f5ab3b44e90944b5488dcf76139130af98..432a9e463e89f942fd47e0a941596b955293ae75 100644 (file)
@@ -42,7 +42,8 @@ ProjectListView::ProjectListView(QWidget *parent) :
     setAlternatingRowColors(true);
     setDragEnabled(true);
     setAcceptDrops(true);
-
+    setFrameShape(QFrame::NoFrame);
+    setRootIsDecorated(false);
 
     setColumnCount(3);
     QStringList headers;
@@ -113,6 +114,15 @@ void ProjectListView::contextMenuEvent(QContextMenuEvent * event)
     emit requestMenu(event->globalPos(), itemAt(event->pos()));
 }
 
+// virtual
+void ProjectListView::keyPressEvent(QKeyEvent * event)
+{
+    if (event->key() == Qt::Key_Return) {
+        QTreeWidgetItem *it = currentItem();
+        if (it) it->setExpanded(!it->isExpanded());
+    } else QTreeWidget::keyPressEvent(event);
+}
+
 // virtual
 void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
 {
@@ -123,7 +133,14 @@ void ProjectListView::mouseDoubleClickEvent(QMouseEvent * event)
     }
     ProjectItem *item;
     if (it->type() == PROJECTFOLDERTYPE) {
-        if ((columnAt(event->pos().x()) == 0)) QTreeWidget::mouseDoubleClickEvent(event);
+        if ((columnAt(event->pos().x()) == 0)) {
+            QPixmap pix = qVariantValue<QPixmap>(it->data(0, Qt::DecorationRole));
+            int offset = pix.width() + indentation();
+            if (event->pos().x() < offset) {
+                it->setExpanded(!it->isExpanded());
+                event->accept();
+            } else QTreeWidget::mouseDoubleClickEvent(event);
+        }
         return;
     }
     if (it->type() == PROJECTSUBCLIPTYPE) {
index a7f1e2ec2e5ea74d9cc315190b6e17df486eeb72..906c0a0c140d81dfa7ee30124b4e0f8d8111f3c4 100644 (file)
@@ -48,6 +48,7 @@ protected:
     virtual QStringList mimeTypes() const;
     virtual Qt::DropActions supportedDropActions() const;
     virtual void dragMoveEvent(QDragMoveEvent * event);
+    virtual void keyPressEvent(QKeyEvent * event);
 
 public slots: