summaryrefslogtreecommitdiffstats
path: root/logic/RecursiveFileSystemWatcher.h
diff options
context:
space:
mode:
authorJan Dalheimer <jan@dalheimer.de>2014-07-12 17:58:23 +0200
committerPetr Mrázek <peterix@gmail.com>2014-07-12 23:31:05 +0200
commit5c4384235989b16d6931cc0cfa26dd192af68b96 (patch)
tree90e9fa1b758c97302726e01882e9c7c914426182 /logic/RecursiveFileSystemWatcher.h
parentaba1f89e2abfd596eb01c674d1b2deee3bdc1047 (diff)
downloadMultiMC-5c4384235989b16d6931cc0cfa26dd192af68b96.tar
MultiMC-5c4384235989b16d6931cc0cfa26dd192af68b96.tar.gz
MultiMC-5c4384235989b16d6931cc0cfa26dd192af68b96.tar.lz
MultiMC-5c4384235989b16d6931cc0cfa26dd192af68b96.tar.xz
MultiMC-5c4384235989b16d6931cc0cfa26dd192af68b96.zip
Add a new page that can show all sorts of logs
Diffstat (limited to 'logic/RecursiveFileSystemWatcher.h')
-rw-r--r--logic/RecursiveFileSystemWatcher.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/logic/RecursiveFileSystemWatcher.h b/logic/RecursiveFileSystemWatcher.h
new file mode 100644
index 00000000..54fc1d12
--- /dev/null
+++ b/logic/RecursiveFileSystemWatcher.h
@@ -0,0 +1,51 @@
+#pragma once
+
+#include <QFileSystemWatcher>
+#include <QDir>
+
+class RecursiveFileSystemWatcher : public QObject
+{
+ Q_OBJECT
+public:
+ RecursiveFileSystemWatcher(QObject *parent);
+
+ void setRootDir(const QDir &root);
+ QDir rootDir() const { return m_root; }
+
+ // WARNING: setting this to true may be bad for performance
+ void setWatchFiles(const bool watchFiles);
+ bool watchFiles() const { return m_watchFiles; }
+
+ void setFileExpression(const QString &exp) { m_exp = exp; }
+ QString fileExpression() const { return m_exp; }
+
+ QStringList files() const { return m_files; }
+
+signals:
+ void filesChanged();
+ void fileChanged(const QString &path);
+
+public
+slots:
+ void enable();
+ void disable();
+
+private:
+ QDir m_root;
+ bool m_watchFiles = false;
+ bool m_isEnabled = false;
+ QString m_exp;
+
+ QFileSystemWatcher *m_watcher;
+
+ QStringList m_files;
+ void setFiles(const QStringList &scanRecursive);
+
+ void addFilesToWatcherRecursive(const QDir &dir);
+ QStringList scanRecursive(const QDir &dir);
+
+private
+slots:
+ void fileChange(const QString &path);
+ void directoryChange(const QString &path);
+};