TreeView: Set current index by selection

... on KeyPress event and others.

This fixes e.g. deleting a watch expression by pressing the Delete key.

Change-Id: Ie0eabf20fb4aeee8349d0282aa4378835d07bc43
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Orgad Shaneh
2016-09-20 22:01:31 +03:00
committed by Orgad Shaneh
parent 67cf72e377
commit 5305a58a51

View File

@@ -417,6 +417,7 @@ void BaseTreeView::setSettings(QSettings *settings, const QByteArray &key)
ItemViewEvent::ItemViewEvent(QEvent *ev, QAbstractItemView *view)
: m_event(ev), m_view(view)
{
QItemSelectionModel *selection = view->selectionModel();
switch (ev->type()) {
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
@@ -435,10 +436,10 @@ ItemViewEvent::ItemViewEvent(QEvent *ev, QAbstractItemView *view)
m_index = view->indexAt(m_pos);
break;
default:
m_index = selection->currentIndex();
break;
}
QItemSelectionModel *selection = view->selectionModel();
m_selectedRows = selection->selectedRows();
if (m_selectedRows.isEmpty()) {
QModelIndex current = selection->currentIndex();