forked from qt-creator/qt-creator
ProjectNodes: Handle supported actions one-by-one
Getting the full list for a node can get quite expensive e.g. in cases of recursive calls of QMakeProjectManager::findPriFile. However, the FlatModel needs to decide quickly on whether an item is editable to potentially allow renaming. So split up QList<Actions> supportedActions() into individual bool supportsAction(action) calls and make sure Rename is not on the critical path. Task-number: QTCREATORBUG-17953 Change-Id: I31841847f8aa7d7b94c63d76ce71efb1c930fa69 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -215,14 +215,9 @@ bool Node::isEnabled() const
|
||||
return parent ? parent->isEnabled() : true;
|
||||
}
|
||||
|
||||
QList<ProjectAction> Node::supportedActions(Node *node) const
|
||||
bool Node::supportsAction(ProjectAction, Node *) const
|
||||
{
|
||||
if (FolderNode *folder = parentFolderNode()) {
|
||||
QList<ProjectAction> list = folder->supportedActions(node);
|
||||
list.append(InheritedFromParent);
|
||||
return list;
|
||||
}
|
||||
return {};
|
||||
return false;
|
||||
}
|
||||
|
||||
void Node::setEnabled(bool enabled)
|
||||
@@ -364,6 +359,14 @@ QList<FileNode *> FileNode::scanForFiles(const Utils::FileName &directory,
|
||||
return scanForFilesRecursively(directory, factory, visited, future, 0.0, 1000000.0);
|
||||
}
|
||||
|
||||
bool FileNode::supportsAction(ProjectAction action, Node *node) const
|
||||
{
|
||||
if (action == InheritedFromParent)
|
||||
return true;
|
||||
FolderNode *parentFolder = parentFolderNode();
|
||||
return parentFolder && parentFolder->supportsAction(action, node);
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::FolderNode
|
||||
|
||||
@@ -593,6 +596,14 @@ QString FolderNode::addFileFilter() const
|
||||
return parentFolderNode()->addFileFilter();
|
||||
}
|
||||
|
||||
bool FolderNode::supportsAction(ProjectAction action, Node *node) const
|
||||
{
|
||||
if (action == InheritedFromParent)
|
||||
return true;
|
||||
FolderNode *parentFolder = parentFolderNode();
|
||||
return parentFolder && parentFolder->supportsAction(action, node);
|
||||
}
|
||||
|
||||
bool FolderNode::addFiles(const QStringList &filePaths, QStringList *notAdded)
|
||||
{
|
||||
ProjectNode *pn = managingProject();
|
||||
@@ -812,11 +823,10 @@ QString ContainerNode::displayName() const
|
||||
return name;
|
||||
}
|
||||
|
||||
QList<ProjectAction> ContainerNode::supportedActions(Node *node) const
|
||||
bool ContainerNode::supportsAction(ProjectAction action, Node *node) const
|
||||
{
|
||||
if (Node *rootNode = m_project->rootProjectNode())
|
||||
return rootNode->supportedActions(node);
|
||||
return {};
|
||||
Node *rootNode = m_project->rootProjectNode();
|
||||
return rootNode && rootNode->supportsAction(action, node);
|
||||
}
|
||||
|
||||
ProjectNode *ContainerNode::rootProjectNode() const
|
||||
|
||||
Reference in New Issue
Block a user