diff options
Diffstat (limited to 'src/core/FileWatcher.h')
-rw-r--r-- | src/core/FileWatcher.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/core/FileWatcher.h b/src/core/FileWatcher.h index f6953cf80..3793ae860 100644 --- a/src/core/FileWatcher.h +++ b/src/core/FileWatcher.h @@ -23,34 +23,39 @@ #include <QTimer> #include <QVariant> -class DelayingFileWatcher : public QObject +class FileWatcher : public QObject { Q_OBJECT public: - explicit DelayingFileWatcher(QObject* parent = nullptr); + explicit FileWatcher(QObject* parent = nullptr); - void blockAutoReload(bool block); - void start(const QString& path); - - void restart(); + void start(const QString& path, int checksumInterval = 1000); void stop(); - void ignoreFileChanges(); + + bool hasSameFileChecksum(); signals: void fileChanged(); public slots: - void observeFileChanges(bool delayed = false); + void pause(); + void resume(); private slots: void onWatchedFileChanged(); + void checkFileChecksum(); private: + QByteArray calculateChecksum(); + bool shouldIgnoreChanges(); + QString m_filePath; QFileSystemWatcher m_fileWatcher; + QByteArray m_fileChecksum; QTimer m_fileChangeDelayTimer; - QTimer m_fileUnblockTimer; + QTimer m_fileIgnoreDelayTimer; + QTimer m_fileChecksumTimer; bool m_ignoreFileChange; }; |