forked from qt-creator/qt-creator
QmlDesigner: Filter item library assets
Change-Id: I3d6b1dbfc071e73277ad8ea60ec0e14ec1602bfb Reviewed-by: Brook Cronin <brook.cronin@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -162,6 +162,33 @@ QVariant FileResourcesModel::modelNodeBackend() const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool 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 false;
|
||||||
|
}
|
||||||
|
|
||||||
|
currentDir.cdUp();
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.dir().dirName() == "designer")
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void FileResourcesModel::setupModel()
|
void FileResourcesModel::setupModel()
|
||||||
{
|
{
|
||||||
m_lock = true;
|
m_lock = true;
|
||||||
@@ -174,7 +201,8 @@ void FileResourcesModel::setupModel()
|
|||||||
QDirIterator it(m_dirPath.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories);
|
QDirIterator it(m_dirPath.absolutePath(), filterList, QDir::Files, QDirIterator::Subdirectories);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
QString absolutePath = it.next();
|
QString absolutePath = it.next();
|
||||||
m_model.append(m_dirPath.relativeFilePath(absolutePath));
|
if (filterMetaIcons(absolutePath))
|
||||||
|
m_model.append(m_dirPath.relativeFilePath(absolutePath));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_lock = false;
|
m_lock = false;
|
||||||
|
Reference in New Issue
Block a user