2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
#include "utils_global.h"
|
|
|
|
|
|
2023-01-23 09:51:21 +01:00
|
|
|
#include "filepath.h"
|
|
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QObject>
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
namespace Utils {
|
|
|
|
|
class FileSystemWatcherPrivate;
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
// Documentation inside.
|
|
|
|
|
class QTCREATOR_UTILS_EXPORT FileSystemWatcher : public QObject
|
2010-03-29 15:54:14 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2011-07-13 18:02:35 +02:00
|
|
|
|
2010-03-29 15:54:14 +02:00
|
|
|
public:
|
2011-04-15 15:55:11 +02:00
|
|
|
enum WatchMode
|
|
|
|
|
{
|
|
|
|
|
WatchModifiedDate,
|
|
|
|
|
WatchAllChanges
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-07 17:33:02 +02:00
|
|
|
explicit FileSystemWatcher(QObject *parent = nullptr);
|
|
|
|
|
explicit FileSystemWatcher(int id, QObject *parent = nullptr);
|
2018-05-07 15:07:21 +02:00
|
|
|
~FileSystemWatcher() override;
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2023-01-23 13:54:54 +01:00
|
|
|
void clear();
|
|
|
|
|
|
2023-01-23 09:51:21 +01:00
|
|
|
// 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:
|
2011-04-15 15:55:11 +02:00
|
|
|
void addFile(const QString &file, WatchMode wm);
|
|
|
|
|
void addFiles(const QStringList &files, WatchMode wm);
|
2010-03-29 15:54:14 +02:00
|
|
|
|
|
|
|
|
void removeFile(const QString &file);
|
|
|
|
|
void removeFiles(const QStringList &files);
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
bool watchesFile(const QString &file) const;
|
2010-03-29 15:54:14 +02:00
|
|
|
QStringList files() const;
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
void addDirectory(const QString &file, WatchMode wm);
|
|
|
|
|
void addDirectories(const QStringList &files, WatchMode wm);
|
2010-03-29 15:54:14 +02:00
|
|
|
|
|
|
|
|
void removeDirectories(const QStringList &files);
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
bool watchesDirectory(const QString &file) const;
|
2010-03-29 15:54:14 +02:00
|
|
|
QStringList directories() const;
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
void fileChanged(const QString &path);
|
|
|
|
|
void directoryChanged(const QString &path);
|
|
|
|
|
|
|
|
|
|
private:
|
2011-04-15 15:55:11 +02:00
|
|
|
void init();
|
2016-06-28 22:31:02 +03:00
|
|
|
void slotFileChanged(const QString &path);
|
|
|
|
|
void slotDirectoryChanged(const QString &path);
|
2010-03-29 15:54:14 +02:00
|
|
|
|
2011-09-16 15:00:41 +02:00
|
|
|
FileSystemWatcherPrivate *d;
|
2010-03-29 15:54:14 +02:00
|
|
|
};
|
|
|
|
|
|
2011-04-15 15:55:11 +02:00
|
|
|
} // namespace Utils
|