Commit 9073c550 authored by Robert Loehning's avatar Robert Loehning

Class view: Fix expanding of items on double click

Task-number: QTCREATORBUG-2536
Change-Id: I94471c265c9f9dbffe253d7c6e8a1e834b47f91f
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent ad9b4ce4
......@@ -40,6 +40,7 @@
#include <utils/qtcassert.h>
#include <QDebug>
#include <QVariant>
#include <QVBoxLayout>
enum { debug = false };
......@@ -102,6 +103,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
treeView->setDragEnabled(true);
treeView->setDragDropMode(QAbstractItemView::DragOnly);
treeView->setDefaultDropAction(Qt::MoveAction);
treeView->setExpandsOnDoubleClick(false);
verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(
treeView, Core::ItemViewFind::DarkColored,
Core::ItemViewFind::FetchMoreWhileSearching));
......@@ -114,6 +116,9 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
// selected item
connect(treeView, SIGNAL(activated(QModelIndex)), SLOT(onItemActivated(QModelIndex)));
// double-clicked item
connect(treeView, SIGNAL(doubleClicked(QModelIndex)), SLOT(onItemDoubleClicked(QModelIndex)));
// connections to the manager
Manager *manager = Manager::instance();
......@@ -236,6 +241,26 @@ void NavigationWidget::onItemActivated(const QModelIndex &index)
emit requestGotoLocations(list);
}
/*!
Expands/collapses the item given by \a index if it
refers to a project file (.pro/.pri)
*/
void NavigationWidget::onItemDoubleClicked(const QModelIndex &index)
{
if (!index.isValid())
return;
const QVariant iconType = treeModel->data(index, Constants::IconTypeRole);
if (!iconType.isValid())
return;
bool ok = false;
const int type = iconType.toInt(&ok);
if (ok && type == INT_MIN)
treeView->setExpanded(index, !treeView->isExpanded(index));
}
/*!
Receives new data for the tree. \a result is a pointer to the Class View
model root item. The function does nothing if null is passed.
......
......@@ -72,6 +72,7 @@ signals:
public slots:
void onItemActivated(const QModelIndex &index);
void onItemDoubleClicked(const QModelIndex &index);
void onDataUpdate(QSharedPointer<QStandardItem> result);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment