diff options
Diffstat (limited to 'src/core/FileWatcher.h')
-rw-r--r-- | src/core/FileWatcher.h | 56 |
1 files changed, 3 insertions, 53 deletions
diff --git a/src/core/FileWatcher.h b/src/core/FileWatcher.h index 9b55badc1..27159d17a 100644 --- a/src/core/FileWatcher.h +++ b/src/core/FileWatcher.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 KeePassXC Team <team@keepassxc.org> + * Copyright (C) 2020 KeePassXC Team <team@keepassxc.org> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,9 +19,7 @@ #define KEEPASSXC_FILEWATCHER_H #include <QFileSystemWatcher> -#include <QSet> #include <QTimer> -#include <QVariant> class FileWatcher : public QObject { @@ -29,6 +27,7 @@ class FileWatcher : public QObject public: explicit FileWatcher(QObject* parent = nullptr); + ~FileWatcher() override; void start(const QString& path, int checksumIntervalSeconds = 0, int checksumSizeKibibytes = -1); void stop(); @@ -36,7 +35,7 @@ public: bool hasSameFileChecksum(); signals: - void fileChanged(); + void fileChanged(const QString& path); public slots: void pause(); @@ -59,53 +58,4 @@ private: bool m_ignoreFileChange = false; }; -class BulkFileWatcher : public QObject -{ - Q_OBJECT - - enum Signal - { - Created, - Updated, - Removed - }; - -public: - explicit BulkFileWatcher(QObject* parent = nullptr); - - void clear(); - - void removePath(const QString& path); - void addPath(const QString& path); - - void ignoreFileChanges(const QString& path); - -signals: - void fileCreated(QString); - void fileChanged(QString); - void fileRemoved(QString); - -public slots: - void observeFileChanges(bool delayed = false); - -private slots: - void handleFileChanged(const QString& path); - void handleDirectoryChanged(const QString& path); - void emitSignals(); - -private: - void scheduleSignal(Signal event, const QString& path); - -private: - QMap<QString, bool> m_watchedPaths; - QMap<QString, QDateTime> m_watchedFilesIgnored; - QFileSystemWatcher m_fileWatcher; - QMap<QString, QMap<QString, qint64>> m_watchedFilesInDirectory; - // needed for Import/Export-References to prevent update after self-write - QTimer m_watchedFilesIgnoreTimer; - // needed to tolerate multiple signals for same event - QTimer m_pendingSignalsTimer; - QMap<QString, QList<Signal>> m_pendingSignals; -}; - #endif // KEEPASSXC_FILEWATCHER_H |