Commit 9c18e718 authored by hjk's avatar hjk
Browse files

ProjectExplorer: Merge the two loops in FlatModel::addFolderNode



And inline the filtering to avoid the duplicated type check
and save a few cycles.

Change-Id: I0dae5e51b05b0a4e581359e7ad7d3b9d4f684141
Reviewed-by: Tobias Hunger's avatarTobias Hunger <tobias.hunger@qt.io>
parent a63998f5
......@@ -266,7 +266,8 @@ void FlatModel::addFolderNode(WrapperNode *parent, FolderNode *folderNode, QSet<
{
for (Node *node : folderNode->nodes()) {
if (FolderNode *subFolderNode = node->asFolderNode()) {
if (!filter(subFolderNode) && !seen->contains(subFolderNode)) {
const bool isHidden = m_filterProjects && !subFolderNode->showInSimpleTree();
if (!isHidden && !seen->contains(subFolderNode)) {
seen->insert(subFolderNode);
auto node = new WrapperNode(subFolderNode);
parent->appendChild(node);
......@@ -275,11 +276,9 @@ void FlatModel::addFolderNode(WrapperNode *parent, FolderNode *folderNode, QSet<
} else {
addFolderNode(parent, subFolderNode, seen);
}
}
}
for (Node *node : folderNode->nodes()) {
if (FileNode *fileNode = node->asFileNode()) {
if (!filter(fileNode) && !seen->contains(fileNode)) {
} else if (FileNode *fileNode = node->asFileNode()) {
const bool isHidden = m_filterProjects && fileNode->isGenerated();
if (!isHidden && !seen->contains(fileNode)) {
seen->insert(fileNode);
parent->appendChild(new WrapperNode(fileNode));
}
......@@ -353,19 +352,6 @@ Node *FlatModel::nodeForIndex(const QModelIndex &index) const
return flatNode ? flatNode->m_node : nullptr;
}
bool FlatModel::filter(Node *node) const
{
bool isHidden = false;
if (FolderNode *folderNode = node->asFolderNode()) {
if (m_filterProjects)
isHidden = !folderNode->showInSimpleTree();
} else if (FileNode *fileNode = node->asFileNode()) {
if (m_filterGeneratedFiles)
isHidden = fileNode->isGenerated();
}
return isHidden;
}
const QLoggingCategory &FlatModel::logger()
{
static QLoggingCategory logger("qtc.projectexplorer.flatmodel");
......
......@@ -85,8 +85,6 @@ signals:
void requestExpansion(const QModelIndex &index);
private:
bool filter(Node *node) const; // Returns true if node is hidden.
bool m_filterProjects = false;
bool m_filterGeneratedFiles = true;
......
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