forked from qt-creator/qt-creator
QmlDesigner: Don't process folders when opening a standalone Qml file
Only assets on the same level as the open Qml file are visible. Fixes: QDS-6374 Change-Id: I51a1bad06ae98e5aa708517816c21395073859d1 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
@@ -27,10 +27,12 @@
|
|||||||
#include "assetslibrarydirsmodel.h"
|
#include "assetslibrarydirsmodel.h"
|
||||||
#include "assetslibraryfilesmodel.h"
|
#include "assetslibraryfilesmodel.h"
|
||||||
|
|
||||||
|
#include <designersettings.h>
|
||||||
|
#include <documentmanager.h>
|
||||||
|
#include <hdrimage.h>
|
||||||
|
#include <qmldesignerplugin.h>
|
||||||
#include <synchronousimagecache.h>
|
#include <synchronousimagecache.h>
|
||||||
#include <theme.h>
|
#include <theme.h>
|
||||||
#include <hdrimage.h>
|
|
||||||
#include <designersettings.h>
|
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
@@ -298,8 +300,8 @@ void AssetsLibraryModel::setRootPath(const QString &path)
|
|||||||
|
|
||||||
m_fileSystemWatcher->clear();
|
m_fileSystemWatcher->clear();
|
||||||
|
|
||||||
std::function<bool(AssetsLibraryDir *, int)> parseDirRecursive;
|
std::function<bool(AssetsLibraryDir *, int, bool)> parseDir;
|
||||||
parseDirRecursive = [this, &parseDirRecursive](AssetsLibraryDir *currAssetsDir, int currDepth) {
|
parseDir = [this, &parseDir](AssetsLibraryDir *currAssetsDir, int currDepth, bool recursive) {
|
||||||
m_fileSystemWatcher->addDirectory(currAssetsDir->dirPath(), Utils::FileSystemWatcher::WatchAllChanges);
|
m_fileSystemWatcher->addDirectory(currAssetsDir->dirPath(), Utils::FileSystemWatcher::WatchAllChanges);
|
||||||
|
|
||||||
QDir dir(currAssetsDir->dirPath());
|
QDir dir(currAssetsDir->dirPath());
|
||||||
@@ -317,20 +319,22 @@ void AssetsLibraryModel::setRootPath(const QString &path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dir.setNameFilters({});
|
if (recursive) {
|
||||||
dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
dir.setNameFilters({});
|
||||||
QDirIterator itDirs(dir);
|
dir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
|
||||||
|
QDirIterator itDirs(dir);
|
||||||
|
|
||||||
while (itDirs.hasNext()) {
|
while (itDirs.hasNext()) {
|
||||||
QDir subDir = itDirs.next();
|
QDir subDir = itDirs.next();
|
||||||
if (currDepth == 1 && ignoredTopLevelDirs.contains(subDir.dirName()))
|
if (currDepth == 1 && ignoredTopLevelDirs.contains(subDir.dirName()))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
auto assetsDir = new AssetsLibraryDir(subDir.path(), currDepth,
|
auto assetsDir = new AssetsLibraryDir(subDir.path(), currDepth,
|
||||||
loadExpandedState(subDir.path()), currAssetsDir);
|
loadExpandedState(subDir.path()), currAssetsDir);
|
||||||
currAssetsDir->addDir(assetsDir);
|
currAssetsDir->addDir(assetsDir);
|
||||||
saveExpandedState(loadExpandedState(assetsDir->dirPath()), assetsDir->dirPath());
|
saveExpandedState(loadExpandedState(assetsDir->dirPath()), assetsDir->dirPath());
|
||||||
isEmpty &= parseDirRecursive(assetsDir, currDepth + 1);
|
isEmpty &= parseDir(assetsDir, currDepth + 1, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_searchText.isEmpty() && isEmpty)
|
if (!m_searchText.isEmpty() && isEmpty)
|
||||||
@@ -344,7 +348,8 @@ void AssetsLibraryModel::setRootPath(const QString &path)
|
|||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_assetsDir = new AssetsLibraryDir(path, 0, true, this);
|
m_assetsDir = new AssetsLibraryDir(path, 0, true, this);
|
||||||
bool isEmpty = parseDirRecursive(m_assetsDir, 1);
|
bool hasProject = !QmlDesignerPlugin::instance()->documentManager().currentProjectDirPath().isEmpty();
|
||||||
|
bool isEmpty = parseDir(m_assetsDir, 1, hasProject);
|
||||||
setIsEmpty(isEmpty);
|
setIsEmpty(isEmpty);
|
||||||
|
|
||||||
bool noAssets = m_searchText.isEmpty() && isEmpty;
|
bool noAssets = m_searchText.isEmpty() && isEmpty;
|
||||||
|
Reference in New Issue
Block a user