forked from qt-creator/qt-creator
ProjectExplorer: Don't hide empty resource files like empty directories
Task-number: QTCREATORBUG-18748 Change-Id: I4de59743c42b99ce0b402f814b4cd0ba5d299338 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -730,6 +730,11 @@ bool FolderNode::showInSimpleTree() const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool FolderNode::showWhenEmpty() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class ProjectExplorer::VirtualFolderNode
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user