diff options
author | hjk <[email protected]> | 2025-03-13 13:55:41 +0100 |
---|---|---|
committer | hjk <[email protected]> | 2025-03-14 08:14:04 +0000 |
commit | 472660f8453c7e256180f636899e6871aaea4b48 (patch) | |
tree | bcf3d485317407c7ddc1ef398687a2eb856d6a0e | |
parent | 347c7b643a4dc3d54b887416e84028638c538826 (diff) |
Utils: Convert FileSystemWatcher signals to FilePath
Task-number: QTCREATORBUG-26870
Change-Id: Ida2e2664a4944e139f1a667928978f521ff9cd1f
Reviewed-by: Marcus Tillmanns <[email protected]>
18 files changed, 47 insertions, 38 deletions
diff --git a/src/libs/qmljs/qmljsplugindumper.cpp b/src/libs/qmljs/qmljsplugindumper.cpp index e34ce53d7f9..5cc97ad1af0 100644 --- a/src/libs/qmljs/qmljsplugindumper.cpp +++ b/src/libs/qmljs/qmljsplugindumper.cpp @@ -314,9 +314,9 @@ void PluginDumper::qmlPluginTypeDumpDone(Process *process) } } -void PluginDumper::pluginChanged(const QString &pluginLibrary) +void PluginDumper::pluginChanged(const FilePath &pluginLibrary) { - const int pluginIndex = m_libraryToPluginIndex.value(FilePath::fromString(pluginLibrary), -1); + const int pluginIndex = m_libraryToPluginIndex.value(pluginLibrary, -1); if (pluginIndex == -1) return; diff --git a/src/libs/qmljs/qmljsplugindumper.h b/src/libs/qmljs/qmljsplugindumper.h index e27bfeba968..750641c3fde 100644 --- a/src/libs/qmljs/qmljsplugindumper.h +++ b/src/libs/qmljs/qmljsplugindumper.h @@ -42,7 +42,7 @@ private: const QString &importVersion); Q_INVOKABLE void dumpAllPlugins(); void qmlPluginTypeDumpDone(Utils::Process *process); - void pluginChanged(const QString &pluginLibrary); + void pluginChanged(const Utils::FilePath &pluginLibrary); private: class Plugin { diff --git a/src/libs/utils/filesystemwatcher.cpp b/src/libs/utils/filesystemwatcher.cpp index bc64adae273..585e9d2290c 100644 --- a/src/libs/utils/filesystemwatcher.cpp +++ b/src/libs/utils/filesystemwatcher.cpp @@ -161,7 +161,7 @@ void FileSystemWatcherPrivate::fileChanged(const QString &path) if (m_postponed) m_postponedFiles.insert(path); else - emit q->fileChanged(path); + emit q->fileChanged(FilePath::fromString(path)); } void FileSystemWatcherPrivate::directoryChanged(const QString &path) @@ -169,7 +169,7 @@ void FileSystemWatcherPrivate::directoryChanged(const QString &path) if (m_postponed) m_postponedDirectories.insert(path); else - emit q->directoryChanged(path); + emit q->directoryChanged(FilePath::fromString(path)); } void FileSystemWatcherPrivate::autoReloadPostponed(bool postponed) @@ -179,10 +179,10 @@ void FileSystemWatcherPrivate::autoReloadPostponed(bool postponed) m_postponed = postponed; if (!postponed) { for (const QString &file : std::as_const(m_postponedFiles)) - emit q->fileChanged(file); + emit q->fileChanged(FilePath::fromString(file)); m_postponedFiles.clear(); for (const QString &directory : std::as_const(m_postponedDirectories)) - emit q->directoryChanged(directory); + emit q->directoryChanged(FilePath::fromString(directory)); m_postponedDirectories.clear(); } } diff --git a/src/libs/utils/filesystemwatcher.h b/src/libs/utils/filesystemwatcher.h index d90ab9dfe72..e3ebea39433 100644 --- a/src/libs/utils/filesystemwatcher.h +++ b/src/libs/utils/filesystemwatcher.h @@ -69,8 +69,8 @@ public: QStringList directories() const; signals: - void fileChanged(const QString &path); - void directoryChanged(const QString &path); + void fileChanged(const Utils::FilePath &path); + void directoryChanged(const Utils::FilePath &path); private: void init(); diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp index 9e175614adb..f92d8a2da68 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.cpp @@ -165,10 +165,10 @@ void ClangToolsDiagnosticModel::clearAndSetupCache() stepsToItemsCache.clear(); } -void ClangToolsDiagnosticModel::onFileChanged(const QString &path) +void ClangToolsDiagnosticModel::onFileChanged(const FilePath &path) { forItemsAtLevel<2>([&](DiagnosticItem *item){ - if (item->diagnostic().location.targetFilePath == FilePath::fromString(path)) + if (item->diagnostic().location.targetFilePath == path) item->setFixItStatus(FixitStatus::Invalidated); }); m_filesWatcher->removeFile(path); diff --git a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h index d7580c1c09a..800619e088a 100644 --- a/src/plugins/clangtools/clangtoolsdiagnosticmodel.h +++ b/src/plugins/clangtools/clangtoolsdiagnosticmodel.h @@ -116,10 +116,9 @@ signals: private: void connectFileWatcher(); void updateItems(const DiagnosticItem *changedItem); - void onFileChanged(const QString &path); + void onFileChanged(const Utils::FilePath &path); void clearAndSetupCache(); -private: QHash<Utils::FilePath, FilePathItem *> m_filePathToItem; QSet<Diagnostic> m_diagnostics; std::map<QVector<ExplainingStep>, QVector<DiagnosticItem *>> stepsToItemsCache; diff --git a/src/plugins/cmakeprojectmanager/fileapireader.cpp b/src/plugins/cmakeprojectmanager/fileapireader.cpp index df542f13dfc..e2e2618f587 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.cpp +++ b/src/plugins/cmakeprojectmanager/fileapireader.cpp @@ -414,7 +414,7 @@ void FileApiReader::cmakeFinishedState(int exitCode) m_lastCMakeExitCode != 0); } -void FileApiReader::handleReplyIndexFileChange(const QString &indexFile) +void FileApiReader::handleReplyIndexFileChange(const FilePath &indexFile) { if (m_isParsing) return; // This has been triggered by ourselves, ignore. @@ -424,7 +424,7 @@ void FileApiReader::handleReplyIndexFileChange(const QString &indexFile) if (dir.isEmpty()) return; // CMake started to fill the result dir, but has not written a result file yet QTC_CHECK(dir.isLocal()); - QTC_ASSERT(dir == FilePath::fromString(indexFile).parentDir(), return); + QTC_ASSERT(dir == indexFile.parentDir(), return); if (m_lastReplyTimestamp.isValid() && reply.lastModified() > m_lastReplyTimestamp) { m_lastReplyTimestamp = reply.lastModified(); diff --git a/src/plugins/cmakeprojectmanager/fileapireader.h b/src/plugins/cmakeprojectmanager/fileapireader.h index 56908313a5f..565fe9919c4 100644 --- a/src/plugins/cmakeprojectmanager/fileapireader.h +++ b/src/plugins/cmakeprojectmanager/fileapireader.h @@ -78,7 +78,7 @@ private: void startCMakeState(const QStringList &configurationArguments); void cmakeFinishedState(int exitCode); - void handleReplyIndexFileChange(const QString &indexFile); + void handleReplyIndexFileChange(const Utils::FilePath &indexFile); void makeBackupConfiguration(bool store); void writeConfigurationIntoBuildDirectory(const QStringList &configuration); diff --git a/src/plugins/insight/insightmodel.cpp b/src/plugins/insight/insightmodel.cpp index 716993c02b2..4f75a97f156 100644 --- a/src/plugins/insight/insightmodel.cpp +++ b/src/plugins/insight/insightmodel.cpp @@ -28,6 +28,8 @@ #include <QApplication> #include <QDebug> +using namespace Utils; + namespace QmlDesigner { namespace { @@ -553,8 +555,9 @@ void InsightModel::selectAllCustom() selectAll(customCategories(), m_customCheckState); } -void InsightModel::handleFileChange(const QString &path) +void InsightModel::handleFileChange(const FilePath &filePath) { + const QString path = filePath.toFSPathString(); if (m_mainQmlInfo.absoluteFilePath() == path) parseMainQml(); else if (m_configInfo.absoluteFilePath() == path) diff --git a/src/plugins/insight/insightmodel.h b/src/plugins/insight/insightmodel.h index 302d79e25b4..1058b33d171 100644 --- a/src/plugins/insight/insightmodel.h +++ b/src/plugins/insight/insightmodel.h @@ -67,7 +67,7 @@ public: Q_INVOKABLE void selectAllPredefined(); Q_INVOKABLE void selectAllCustom(); - void handleFileChange(const QString &path); + void handleFileChange(const Utils::FilePath &path); void setAuxiliaryEnabled(bool value); void setAuxiliaryCategories(const std::vector<std::string> &categories); diff --git a/src/plugins/nim/project/nimbleproject.cpp b/src/plugins/nim/project/nimbleproject.cpp index 3407d4a15e9..840ce480fc1 100644 --- a/src/plugins/nim/project/nimbleproject.cpp +++ b/src/plugins/nim/project/nimbleproject.cpp @@ -115,8 +115,8 @@ NimbleBuildSystem::NimbleBuildSystem(BuildConfiguration *bc) { m_projectScanner.watchProjectFilePath(); - connect(&m_projectScanner, &NimProjectScanner::fileChanged, this, [this](const QString &path) { - if (path == projectFilePath().toUrlishString()) + connect(&m_projectScanner, &NimProjectScanner::fileChanged, this, [this](const FilePath &path) { + if (path == projectFilePath()) requestDelayedParse(); }); @@ -125,11 +125,11 @@ NimbleBuildSystem::NimbleBuildSystem(BuildConfiguration *bc) connect(&m_projectScanner, &NimProjectScanner::finished, this, &NimbleBuildSystem::updateProject); - connect(&m_projectScanner, &NimProjectScanner::directoryChanged, this, [this] (const QString &directory){ + connect(&m_projectScanner, &NimProjectScanner::directoryChanged, this, [this] (const FilePath &directory) { // Workaround for nimble creating temporary files in project root directory // when querying the list of tasks. // See https://github.com/nim-lang/nimble/issues/720 - if (FilePath::fromString(directory) != projectDirectory()) + if (directory != projectDirectory()) requestDelayedParse(); }); diff --git a/src/plugins/nim/project/nimproject.h b/src/plugins/nim/project/nimproject.h index 09b8e58611c..62b755662b8 100644 --- a/src/plugins/nim/project/nimproject.h +++ b/src/plugins/nim/project/nimproject.h @@ -47,8 +47,8 @@ public: signals: void finished(); void requestReparse(); - void directoryChanged(const QString &path); - void fileChanged(const QString &path); + void directoryChanged(const Utils::FilePath &path); + void fileChanged(const Utils::FilePath &path); private: void loadSettings(); diff --git a/src/plugins/projectexplorer/workspaceproject.cpp b/src/plugins/projectexplorer/workspaceproject.cpp index d82f55d2bf9..7dcc130531e 100644 --- a/src/plugins/projectexplorer/workspaceproject.cpp +++ b/src/plugins/projectexplorer/workspaceproject.cpp @@ -136,8 +136,8 @@ WorkspaceBuildSystem::WorkspaceBuildSystem(BuildConfiguration *bc) m_watcher.get(), &FileSystemWatcher::directoryChanged, this, - [this](const QString &path) { - handleDirectoryChanged(FilePath::fromPathPart(path)); + [this](const FilePath &path) { + handleDirectoryChanged(path); }); addNodes(root.get()); diff --git a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp index fc781f698dd..15007fdbfec 100644 --- a/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp +++ b/src/plugins/qmakeprojectmanager/qmakeparsernodes.cpp @@ -1734,7 +1734,8 @@ void QmakeProFile::applyEvaluate(const QmakeEvalResultPtr &result) m_wildcardWatcher = std::make_unique<FileSystemWatcher>(); QObject::connect( m_wildcardWatcher.get(), &FileSystemWatcher::directoryChanged, - [this](QString path) { + [this](const FilePath &filePath) { + const QString path = filePath.toFSPathString(); QStringList directoryContents = QDir(path).entryList(); if (m_wildcardDirectoryContents.value(path) != directoryContents) { m_wildcardDirectoryContents.insert(path, directoryContents); diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp index edb82baf5ea..edf5f1eb36f 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp @@ -21,6 +21,8 @@ #include <QFileSystemModel> #include <QMessageBox> +using namespace Utils; + namespace QmlDesigner { AssetsLibraryModel::AssetsLibraryModel(QObject *parent) @@ -45,10 +47,10 @@ void AssetsLibraryModel::createBackendModel() syncIsEmpty(); }); - m_fileWatcher = new Utils::FileSystemWatcher(parent()); - QObject::connect(m_fileWatcher, &Utils::FileSystemWatcher::fileChanged, this, - [this] (const QString &path) { - emit fileChanged(path); + m_fileWatcher = new FileSystemWatcher(parent()); + QObject::connect(m_fileWatcher, &FileSystemWatcher::fileChanged, this, + [this] (const FilePath &path) { + emit fileChanged(path.toFSPathString()); }); } diff --git a/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp b/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp index 33a8b8913b9..9cdf62e3d66 100644 --- a/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp +++ b/src/plugins/qmlpreview/qmlpreviewconnectionmanager.cpp @@ -12,6 +12,8 @@ #include <QMessageBox> +using namespace Utils; + namespace QmlPreview { QmlPreviewConnectionManager::QmlPreviewConnectionManager(QObject *parent) : @@ -206,23 +208,23 @@ void QmlPreviewConnectionManager::createPreviewClient() "QML Live Preview is not available for this version of Qt."); }, Qt::QueuedConnection); // Queue it, so that it interfere with the connection timer - connect(&m_fileSystemWatcher, &Utils::FileSystemWatcher::fileChanged, - m_qmlPreviewClient.data(), [this](const QString &changedFile) { + connect(&m_fileSystemWatcher, &FileSystemWatcher::fileChanged, + m_qmlPreviewClient.data(), [this](const FilePath &changedFile) { if (!m_fileLoader || !m_lastLoadedUrl.isValid()) return; bool success = false; - const QByteArray contents = m_fileLoader(changedFile, &success); + const QByteArray contents = m_fileLoader(changedFile.toFSPathString(), &success); if (!success) return; - if (!m_fileClassifier(changedFile)) { + if (!m_fileClassifier(changedFile.toFSPathString())) { emit restart(); return; } - const QString remoteChangedFile = m_targetFileFinder.findPath(changedFile, &success); + const QString remoteChangedFile = m_targetFileFinder.findPath(changedFile.toFSPathString(), &success); if (success) m_qmlPreviewClient->announceFile(remoteChangedFile, contents); else diff --git a/src/plugins/qmlprojectmanager/buildsystem/projectitem/filefilteritems.cpp b/src/plugins/qmlprojectmanager/buildsystem/projectitem/filefilteritems.cpp index a06b5dee7b9..4cd87b40e58 100644 --- a/src/plugins/qmlprojectmanager/buildsystem/projectitem/filefilteritems.cpp +++ b/src/plugins/qmlprojectmanager/buildsystem/projectitem/filefilteritems.cpp @@ -12,6 +12,8 @@ #include <QImageReader> #include <QRegularExpression> +using namespace Utils; + namespace QmlProjectManager { FileFilterItem::FileFilterItem(){ @@ -40,7 +42,7 @@ Utils::FileSystemWatcher *FileFilterItem::dirWatcher() connect(m_dirWatcher, &Utils::FileSystemWatcher::directoryChanged, this, &FileFilterItem::updateFileList); connect(m_dirWatcher, &Utils::FileSystemWatcher::fileChanged, - [this](const QString& path) { emit fileModified(path); }); + [this](const FilePath &path) { emit fileModified(path.toFSPathString()); }); } return m_dirWatcher; } diff --git a/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp b/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp index dc0b11174f8..40b66770344 100644 --- a/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp +++ b/src/plugins/qmlprojectmanager/buildsystem/qmlbuildsystem.cpp @@ -251,7 +251,7 @@ void QmlBuildSystem::initMcuProjectItems() connect(&m_mcuProjectFilesWatcher, &Utils::FileSystemWatcher::fileChanged, this, - [this](const QString &file) { + [this](const FilePath &file) { Q_UNUSED(file) initMcuProjectItems(); refresh(RefreshOptions::Files); |