From 90ea538f243fc0655f39b800b9dde6866b143bd9 Mon Sep 17 00:00:00 2001 From: Mahmoud Badri Date: Fri, 4 Jun 2021 16:27:17 +0300 Subject: [PATCH] QmlDesigner: Add empty assets directories to the model ...so that changes to empty asset folders are detected and handled. Also remove a check for folders named as the project's name as it doesn't seem necessary. Task-number: QDS-4429 Change-Id: I8031fb57d3c02bb6599824f04f222414a52d08c9 Reviewed-by: Thomas Hartmann --- .../itemlibrary/itemlibraryassetsmodel.cpp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetsmodel.cpp b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetsmodel.cpp index 2cfa852e6f0..acf03739726 100644 --- a/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetsmodel.cpp +++ b/src/plugins/qmldesigner/components/itemlibrary/itemlibraryassetsmodel.cpp @@ -39,9 +39,6 @@ #include #include #include -#include "qmldesignerplugin.h" -#include -#include #include #include @@ -155,14 +152,8 @@ void ItemLibraryAssetsModel::setRootPath(const QString &path) m_fileSystemWatcher->removeDirectories(m_fileSystemWatcher->directories()); m_fileSystemWatcher->removeFiles(m_fileSystemWatcher->files()); - DesignDocument *currDesignDoc = QmlDesignerPlugin::instance()->currentDesignDocument(); - if (!currDesignDoc) // happens sometimes on QDS shutdown - return; - ProjectExplorer::Project *project = ProjectExplorer::SessionManager::projectForFile(currDesignDoc->fileName()); - QString projectName = project ? project->displayName() : ""; - std::function parseDirRecursive; - parseDirRecursive = [this, &parseDirRecursive, &projectName](ItemLibraryAssetsDir *currAssetsDir, int currDepth) { + parseDirRecursive = [this, &parseDirRecursive](ItemLibraryAssetsDir *currAssetsDir, int currDepth) { m_fileSystemWatcher->addDirectory(currAssetsDir->dirPath(), Utils::FileSystemWatcher::WatchAllChanges); QDir dir(currAssetsDir->dirPath()); @@ -186,10 +177,8 @@ void ItemLibraryAssetsModel::setRootPath(const QString &path) while (itDirs.hasNext()) { QDir subDir = itDirs.next(); - if (subDir.isEmpty() || projectName == subDir.dirName() - || (currDepth == 1 && !supportedTopLevelDirs.contains(subDir.dirName()))) { + if (currDepth == 1 && !supportedTopLevelDirs.contains(subDir.dirName())) continue; - } ItemLibraryAssetsDir *assetsDir = new ItemLibraryAssetsDir(subDir.path(), currDepth, loadExpandedState(subDir.path()), currAssetsDir); currAssetsDir->addDir(assetsDir);