Debugger: Improve keyboard navigation in locals view

Expanding items in the locals view results in replacing the original
tree item with a newly created one. This ultimately resets the selection
and the current item of the view, which in turn makes it cumbersome to
navigate by keyboard.

Save a list of selected inames and the iname of the current index when
requesting the update and try to reselect them after the update
finished.

Fixes: QTCREATORBUG-27569
Change-Id: I9d8f51631e4ee490e19307877cbef44798506016
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2024-04-29 14:18:12 +02:00
parent 1fc135822f
commit 15e56078b6
3 changed files with 50 additions and 13 deletions

View File

@@ -469,7 +469,6 @@ public:
QSet<QString> m_expandedINames;
QHash<QString, int> m_maxArrayCount;
QTimer m_requestUpdateTimer;
QTimer m_localsWindowsTimer;
QHash<QString, TypeInfo> m_reportedTypeInfo;
@@ -513,10 +512,6 @@ WatchModel::WatchModel(WatchHandler *handler, DebuggerEngine *engine)
root->appendChild(m_tooltipRoot);
setRootItem(root);
m_requestUpdateTimer.setSingleShot(true);
connect(&m_requestUpdateTimer, &QTimer::timeout,
this, &WatchModel::updateStarted);
m_localsWindowsTimer.setSingleShot(true);
m_localsWindowsTimer.setInterval(50);
connect(&m_localsWindowsTimer, &QTimer::timeout, this, [this] {
@@ -2310,7 +2305,7 @@ void WatchHandler::notifyUpdateStarted(const UpdateParameters &updateParameters)
}
}
m_model->m_requestUpdateTimer.start(80);
emit m_model->updateStarted();
m_model->m_contentsValid = false;
updateLocalsWindow();
}
@@ -2350,7 +2345,6 @@ void WatchHandler::notifyUpdateFinished()
m_model->m_contentsValid = true;
updateLocalsWindow();
m_model->reexpandItems();
m_model->m_requestUpdateTimer.stop();
emit m_model->updateFinished();
}