Commit e8c57c98 authored by Tim Jenssen's avatar Tim Jenssen

ProjectTree: keep lastFocusedProjectTreeWidget to get currentNode

Also remove currentNode checks from updateFromDocumentManager()
We already checked for focus in the update() method.

Change-Id: Id1bc28ce442b5b56597a675516ceea4fbc1801de
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent 73c7cb19
......@@ -131,8 +131,13 @@ void ProjectTree::nodeChanged(ProjectTreeWidget *widget)
void ProjectTree::update()
{
ProjectTreeWidget *focus = m_focusForContextMenu;
if (!focus)
static QPointer<ProjectTreeWidget> lastFocusedProjectTreeWidget;
if (!focus) {
focus = Utils::findOrDefault(m_projectTreeWidgets, &ProjectTree::hasFocus);
lastFocusedProjectTreeWidget = focus;
}
if (!focus)
focus = lastFocusedProjectTreeWidget;
if (focus)
updateFromProjectTreeWidget(focus);
......@@ -150,16 +155,12 @@ void ProjectTree::updateFromProjectTreeWidget(ProjectTreeWidget *widget)
void ProjectTree::updateFromDocumentManager()
{
Core::IDocument *document = Core::EditorManager::currentDocument();
const FileName fileName = document ? document->filePath() : FileName();
Node *currentNode = nullptr;
if (m_currentNode && m_currentNode->filePath() == fileName)
currentNode = m_currentNode;
else
currentNode = ProjectTreeWidget::nodeForFile(fileName);
updateFromNode(currentNode);
if (Core::IDocument *document = Core::EditorManager::currentDocument()) {
const FileName fileName = document->filePath();
updateFromNode(ProjectTreeWidget::nodeForFile(fileName));
} else {
updateFromNode(nullptr);
}
}
void ProjectTree::updateFromNode(Node *node)
......
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