forked from qt-creator/qt-creator
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:
committed by
Orgad Shaneh
parent
67cf72e377
commit
5305a58a51
@@ -417,6 +417,7 @@ void BaseTreeView::setSettings(QSettings *settings, const QByteArray &key)
|
|||||||
ItemViewEvent::ItemViewEvent(QEvent *ev, QAbstractItemView *view)
|
ItemViewEvent::ItemViewEvent(QEvent *ev, QAbstractItemView *view)
|
||||||
: m_event(ev), m_view(view)
|
: m_event(ev), m_view(view)
|
||||||
{
|
{
|
||||||
|
QItemSelectionModel *selection = view->selectionModel();
|
||||||
switch (ev->type()) {
|
switch (ev->type()) {
|
||||||
case QEvent::MouseButtonPress:
|
case QEvent::MouseButtonPress:
|
||||||
case QEvent::MouseButtonRelease:
|
case QEvent::MouseButtonRelease:
|
||||||
@@ -435,10 +436,10 @@ ItemViewEvent::ItemViewEvent(QEvent *ev, QAbstractItemView *view)
|
|||||||
m_index = view->indexAt(m_pos);
|
m_index = view->indexAt(m_pos);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
m_index = selection->currentIndex();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QItemSelectionModel *selection = view->selectionModel();
|
|
||||||
m_selectedRows = selection->selectedRows();
|
m_selectedRows = selection->selectedRows();
|
||||||
if (m_selectedRows.isEmpty()) {
|
if (m_selectedRows.isEmpty()) {
|
||||||
QModelIndex current = selection->currentIndex();
|
QModelIndex current = selection->currentIndex();
|
||||||
|
|||||||
Reference in New Issue
Block a user