forked from qt-creator/qt-creator
Class view: Fix keyboard focus when using shortcut
Pass focus to the treeview, and make sure something is selected, so focus is also visibly moving there. Task-number: QTCREATORBUG-15920 Change-Id: Icf7c213765739e992edcb52cc88f8730875e0bed Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
This commit is contained in:
@@ -105,7 +105,7 @@ NavigationWidget::NavigationWidget(QWidget *parent) :
|
|||||||
verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
verticalLayout->addWidget(Core::ItemViewFind::createSearchableWrapper(
|
||||||
treeView, Core::ItemViewFind::DarkColored,
|
treeView, Core::ItemViewFind::DarkColored,
|
||||||
Core::ItemViewFind::FetchMoreWhileSearching));
|
Core::ItemViewFind::FetchMoreWhileSearching));
|
||||||
|
setFocusProxy(treeView);
|
||||||
// tree model
|
// tree model
|
||||||
treeModel = new TreeItemModel(this);
|
treeModel = new TreeItemModel(this);
|
||||||
treeView->setModel(treeModel);
|
treeView->setModel(treeModel);
|
||||||
@@ -282,10 +282,12 @@ void NavigationWidget::onDataUpdate(QSharedPointer<QStandardItem> result)
|
|||||||
|
|
||||||
// expand top level projects
|
// expand top level projects
|
||||||
QModelIndex sessionIndex;
|
QModelIndex sessionIndex;
|
||||||
|
const int toplevelCount = treeModel->rowCount(sessionIndex);
|
||||||
for (int i = 0; i < treeModel->rowCount(sessionIndex); ++i)
|
for (int i = 0; i < toplevelCount; ++i)
|
||||||
treeView->expand(treeModel->index(i, 0, sessionIndex));
|
treeView->expand(treeModel->index(i, 0, sessionIndex));
|
||||||
|
|
||||||
|
if (!treeView->currentIndex().isValid() && toplevelCount > 0)
|
||||||
|
treeView->setCurrentIndex(treeModel->index(0, 0, sessionIndex));
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "Class View:" << QDateTime::currentDateTime().toString()
|
qDebug() << "Class View:" << QDateTime::currentDateTime().toString()
|
||||||
<< "TreeView is updated in" << timer.elapsed() << "msecs";
|
<< "TreeView is updated in" << timer.elapsed() << "msecs";
|
||||||
|
Reference in New Issue
Block a user