diff --git a/src/plugins/projectexplorer/projectmodels.cpp b/src/plugins/projectexplorer/projectmodels.cpp index b71f171705e..17504821ac3 100644 --- a/src/plugins/projectexplorer/projectmodels.cpp +++ b/src/plugins/projectexplorer/projectmodels.cpp @@ -323,14 +323,15 @@ void FlatModel::addFolderNode(WrapperNode *parent, FolderNode *folderNode, QSet< bool FlatModel::trimEmptyDirectories(WrapperNode *parent) { - if (!parent->m_node->asFolderNode()) + const FolderNode *fn = parent->m_node->asFolderNode(); + if (!fn) return false; for (int i = parent->childCount() - 1; i >= 0; --i) { if (trimEmptyDirectories(parent->childAt(i))) parent->removeChildAt(i); } - return parent->childCount() == 0; + return parent->childCount() == 0 && !fn->showWhenEmpty(); } Qt::DropActions FlatModel::supportedDragActions() const diff --git a/src/plugins/projectexplorer/projectnodes.cpp b/src/plugins/projectexplorer/projectnodes.cpp index e391b17444c..a3e7203e342 100644 --- a/src/plugins/projectexplorer/projectnodes.cpp +++ b/src/plugins/projectexplorer/projectnodes.cpp @@ -730,6 +730,11 @@ bool FolderNode::showInSimpleTree() const return false; } +bool FolderNode::showWhenEmpty() const +{ + return false; +} + /*! \class ProjectExplorer::VirtualFolderNode diff --git a/src/plugins/projectexplorer/projectnodes.h b/src/plugins/projectexplorer/projectnodes.h index eaebb6ae8dd..376e50192fe 100644 --- a/src/plugins/projectexplorer/projectnodes.h +++ b/src/plugins/projectexplorer/projectnodes.h @@ -272,6 +272,8 @@ public: // determines if node will be shown in the flat view, by default folder and projects aren't shown virtual bool showInSimpleTree() const; + // determines if node will always be shown when hiding empty directories + virtual bool showWhenEmpty() const; void addNode(Node *node); void removeNode(Node *node); diff --git a/src/plugins/resourceeditor/resourcenode.cpp b/src/plugins/resourceeditor/resourcenode.cpp index cb7b5be887b..fe0ec8e789e 100644 --- a/src/plugins/resourceeditor/resourcenode.cpp +++ b/src/plugins/resourceeditor/resourcenode.cpp @@ -492,6 +492,11 @@ bool ResourceTopLevelNode::showInSimpleTree() const return true; } +bool ResourceTopLevelNode::showWhenEmpty() const +{ + return true; +} + ResourceFolderNode::ResourceFolderNode(const QString &prefix, const QString &lang, ResourceTopLevelNode *parent) : FolderNode(FileName(parent->filePath()).appendPath(prefix)), // TOOD Why add existing directory doesn't work diff --git a/src/plugins/resourceeditor/resourcenode.h b/src/plugins/resourceeditor/resourcenode.h index e2f84e005a7..f9b9e65c37f 100644 --- a/src/plugins/resourceeditor/resourcenode.h +++ b/src/plugins/resourceeditor/resourcenode.h @@ -51,6 +51,7 @@ public: AddNewInformation addNewInformation(const QStringList &files, Node *context) const override; bool showInSimpleTree() const override; + bool showWhenEmpty() const override; bool removeNonExistingFiles(); QString contents() const { return m_contents; }