From: Jean-Baptiste Mardelle Date: Thu, 15 Apr 2010 21:52:41 +0000 (+0000) Subject: Optimise project tree UI X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=7f37c376a4256a94c6a0f907f172bee6f6b4e5a3;p=kdenlive Optimise project tree UI svn path=/trunk/kdenlive/; revision=4385 --- diff --git a/src/projectlist.cpp b/src/projectlist.cpp index ebce6b7c..6f698385 100644 --- a/src/projectlist.cpp +++ b/src/projectlist.cpp @@ -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); diff --git a/src/projectlistview.cpp b/src/projectlistview.cpp index c4b8d4f5..432a9e46 100644 --- a/src/projectlistview.cpp +++ b/src/projectlistview.cpp @@ -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(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) { diff --git a/src/projectlistview.h b/src/projectlistview.h index a7f1e2ec..906c0a0c 100644 --- a/src/projectlistview.h +++ b/src/projectlistview.h @@ -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: