blob: 3f78b6b266bb29b9ff3dcaf09154121e556cdf6b [file] [log] [blame]
jareda9541812013-01-09 00:08:46 -08001#ifndef FILESYSTEMWATCHER_H
2#define FILESYSTEMWATCHER_H
3
4#include <QtGui>
Jared Lindblom4d1d00a2013-01-11 01:14:23 -08005#include <QSqlDatabase>
6#include <QSqlQuery>
7#include <QSqlResult>
8#include <QDebug>
9#include <QHash>
jareda9541812013-01-09 00:08:46 -080010
11namespace Ui {
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080012class FileSystemWatcher;
jareda9541812013-01-09 00:08:46 -080013}
14
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080015class FileSystemWatcher : public QMainWindow
jareda9541812013-01-09 00:08:46 -080016{
17 Q_OBJECT
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080018
jareda9541812013-01-09 00:08:46 -080019public:
20 // constructor
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080021 FileSystemWatcher(QString dirPath, QWidget *parent = 0);
jareda9541812013-01-09 00:08:46 -080022
23 // destructor
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080024 ~FileSystemWatcher();
jareda9541812013-01-09 00:08:46 -080025
26private slots:
jareda9541812013-01-09 00:08:46 -080027 // signal for changes to monitored directories
28 void dirChangedSlot(QString dirPath);
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080029
jareda9541812013-01-09 00:08:46 -080030private:
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080031 // 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
40private:
41 Ui::FileSystemWatcher* m_ui; // user interface
jareda9541812013-01-09 00:08:46 -080042 QFileSystemWatcher* m_watcher; // filesystem watcher
43 QStringListModel* m_listViewModel; // list view model
44 QListView* m_listView; // list
45 QString m_dirPath; // monitored path
Jared Lindblom4d1d00a2013-01-11 01:14:23 -080046
47 QSqlDatabase m_db; // filesystem database
jareda9541812013-01-09 00:08:46 -080048};
49
50#endif // FILESYSTEMWATCHER_H