jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 1 | #ifndef FILESYSTEMWATCHER_H |
| 2 | #define FILESYSTEMWATCHER_H |
| 3 | |
| 4 | #include <QtGui> |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 5 | #include <QSqlDatabase> |
| 6 | #include <QSqlQuery> |
| 7 | #include <QSqlResult> |
| 8 | #include <QDebug> |
| 9 | #include <QHash> |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 10 | |
| 11 | namespace Ui { |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 12 | class FileSystemWatcher; |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 13 | } |
| 14 | |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 15 | class FileSystemWatcher : public QMainWindow |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 16 | { |
| 17 | Q_OBJECT |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 18 | |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 19 | public: |
| 20 | // constructor |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 21 | FileSystemWatcher(QString dirPath, QWidget *parent = 0); |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 22 | |
| 23 | // destructor |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 24 | ~FileSystemWatcher(); |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 25 | |
| 26 | private slots: |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 27 | // signal for changes to monitored directories |
| 28 | void dirChangedSlot(QString dirPath); |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 29 | |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 30 | private: |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 31 | // scan directory and populate file list |
| 32 | QHash<QString, QFileInfo> scanDirectory(QString filePath); |
| 33 | |
| 34 | // reconcile directory, find changes |
| 35 | QStringList reconcileDirectory(QHash<QString, QFileInfo> fileList); |
| 36 | |
| 37 | // create file table in database |
| 38 | bool createFileTable(); |
| 39 | |
| 40 | private: |
| 41 | Ui::FileSystemWatcher* m_ui; // user interface |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 42 | QFileSystemWatcher* m_watcher; // filesystem watcher |
| 43 | QStringListModel* m_listViewModel; // list view model |
| 44 | QListView* m_listView; // list |
| 45 | QString m_dirPath; // monitored path |
Jared Lindblom | 4d1d00a | 2013-01-11 01:14:23 -0800 | [diff] [blame^] | 46 | |
| 47 | QSqlDatabase m_db; // filesystem database |
jared | a954181 | 2013-01-09 00:08:46 -0800 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | #endif // FILESYSTEMWATCHER_H |