Utils: Start migration of FileSystemWatcher to FilePath

This duplication of the interface is a first step, the
QString based part will be gone in the end.

Change-Id: I5e6378a92f96324188b917599b50def536f57bbe
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-01-23 09:51:21 +01:00
parent 5bbc7ea0f5
commit 156ef28d90
2 changed files with 86 additions and 1 deletions

View File

@@ -2,6 +2,8 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "filesystemwatcher.h"
#include "algorithm.h"
#include "globalfilechangeblocker.h"
#include <QDebug>
@@ -454,4 +456,64 @@ void FileSystemWatcher::slotDirectoryChanged(const QString &path)
}
}
} // namespace Utils
void FileSystemWatcher::addFile(const FilePath &file, WatchMode wm)
{
addFile(file.toFSPathString(), wm);
}
void FileSystemWatcher::addFiles(const FilePaths &files, WatchMode wm)
{
addFiles(transform(files, &FilePath::toFSPathString), wm);
}
void FileSystemWatcher::removeFile(const FilePath &file)
{
removeFile(file.toFSPathString());
}
void FileSystemWatcher::removeFiles(const FilePaths &files)
{
removeFiles(transform(files, &FilePath::toFSPathString));
}
bool FileSystemWatcher::watchesFile(const FilePath &file) const
{
return watchesFile(file.toFSPathString());
}
FilePaths FileSystemWatcher::filePaths() const
{
return transform(files(), &FilePath::fromString);
}
void FileSystemWatcher::addDirectory(const FilePath &file, WatchMode wm)
{
addDirectory(file.toFSPathString(), wm);
}
void FileSystemWatcher::addDirectories(const FilePaths &files, WatchMode wm)
{
addDirectories(transform(files, &FilePath::toFSPathString), wm);
}
void FileSystemWatcher::removeDirectory(const FilePath &file)
{
removeDirectory(file.toFSPathString());
}
void FileSystemWatcher::removeDirectories(const FilePaths &files)
{
removeDirectories(transform(files, &FilePath::toFSPathString));
}
bool FileSystemWatcher::watchesDirectory(const FilePath &file) const
{
return watchesDirectory(file.toFSPathString());
}
FilePaths FileSystemWatcher::directoryPaths() const
{
return transform(directories(), &FilePath::fromString);
}
} //Utils

View File

@@ -5,6 +5,8 @@
#include "utils_global.h"
#include "filepath.h"
#include <QObject>
namespace Utils {
@@ -26,6 +28,27 @@ public:
explicit FileSystemWatcher(int id, QObject *parent = nullptr);
~FileSystemWatcher() override;
// Good to use in new code:
void addFile(const Utils::FilePath &file, WatchMode wm);
void addFiles(const Utils::FilePaths &files, WatchMode wm);
void removeFile(const Utils::FilePath &file);
void removeFiles(const Utils::FilePaths &files);
bool watchesFile(const Utils::FilePath &file) const;
Utils::FilePaths filePaths() const;
void addDirectory(const Utils::FilePath &file, WatchMode wm);
void addDirectories(const Utils::FilePaths &files, WatchMode wm);
void removeDirectory(const Utils::FilePath &file);
void removeDirectories(const Utils::FilePaths &files);
bool watchesDirectory(const Utils::FilePath &file) const;
Utils::FilePaths directoryPaths() const;
// Phase out:
void addFile(const QString &file, WatchMode wm);
void addFiles(const QStringList &files, WatchMode wm);