forked from qt-creator/qt-creator
QmlDesigner: Do not show icons for the itemlibrary in resources
Everything that is in or below a designer folder with a *.metainfo file is not supposed to show up in the resource browser. The code is written very defensive way and we check a maximum of 3 directories above the current file. Change-Id: I14b3ae8a7e47208e15e9adfc1696c531a8589231 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -88,6 +88,33 @@ void CustomFileSystemModel::setFilter(QDir::Filters)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString filterMetaIcons(const QString fileName)
|
||||||
|
{
|
||||||
|
|
||||||
|
QFileInfo info(fileName);
|
||||||
|
|
||||||
|
if (info.dir().path().split("/").contains("designer")) {
|
||||||
|
|
||||||
|
QDir currentDir = info.dir();
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (!currentDir.isRoot() && i < 3) {
|
||||||
|
if (currentDir.dirName() == "designer") {
|
||||||
|
if (!currentDir.entryList({"*.metainfo"}).isEmpty())
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDir.cdUp();
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.dir().dirName() == "designer")
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex CustomFileSystemModel::setRootPath(const QString &newPath)
|
QModelIndex CustomFileSystemModel::setRootPath(const QString &newPath)
|
||||||
{
|
{
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
@@ -114,7 +141,7 @@ QModelIndex CustomFileSystemModel::setRootPath(const QString &newPath)
|
|||||||
QDirIterator fileIterator(newPath, nameFilterList, QDir::Files, QDirIterator::Subdirectories);
|
QDirIterator fileIterator(newPath, nameFilterList, QDir::Files, QDirIterator::Subdirectories);
|
||||||
|
|
||||||
while (fileIterator.hasNext())
|
while (fileIterator.hasNext())
|
||||||
m_files.append(fileIterator.next());
|
m_files.append(filterMetaIcons(fileIterator.next()));
|
||||||
|
|
||||||
QDirIterator dirIterator(newPath, {}, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
QDirIterator dirIterator(newPath, {}, QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories);
|
||||||
while (dirIterator.hasNext())
|
while (dirIterator.hasNext())
|
||||||
|
Reference in New Issue
Block a user