Added a registerable signal (callback) function and an example use class, simpleeventcatcher. filesystemwatcher is fully implemented.
diff --git a/filesystemwatcher/filesystemwatcher.h b/filesystemwatcher/filesystemwatcher.h
index aa1f3b8..543fba6 100644
--- a/filesystemwatcher/filesystemwatcher.h
+++ b/filesystemwatcher/filesystemwatcher.h
@@ -1,35 +1,44 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Jared Lindblom <lindblom@cs.ucla.edu>
+ */
#ifndef FILESYSTEMWATCHER_H
#define FILESYSTEMWATCHER_H
-#include <QtGui>
+#include <QFileSystemWatcher>
+#include <QCryptographicHash>
+#include <QDirIterator>
+#include <QFileInfo>
+#include <QDateTime>
+#include <QTimer>
#include <QDebug>
#include <QHash>
-#include <QCryptographicHash>
+#include <structs.h>
#define DEBUG 1
-enum eEvent {
- ADDED = 0,
- MODIFIED,
- DELETED
-};
-
-struct sEventInfo {
- eEvent event;
- std::string absFilePath;
-};
-
-namespace Ui {
-class FileSystemWatcher;
-}
-
-class FileSystemWatcher : public QMainWindow
+class FileSystemWatcher : public QObject
{
Q_OBJECT
public:
// constructor
- FileSystemWatcher(QString dirPath, QWidget *parent = 0);
+ FileSystemWatcher(QString dirPath, QObject* parent = 0);
// destructor
~FileSystemWatcher();
@@ -45,6 +54,9 @@
// handle callback from timer
void timerCallbackSlot();
+ // bootstrap
+ void bootstrap();
+
private:
// handle callback from either the watcher or timer
void handleCallback(QString dirPath);
@@ -62,10 +74,7 @@
void printChanges(std::vector<sEventInfo> dirChanges);
private:
- Ui::FileSystemWatcher* m_ui; // user interface
QFileSystemWatcher* m_watcher; // filesystem watcher
- QStringListModel* m_listViewModel; // list view model
- QListView* m_listView; // list
QTimer* m_timer; // timer
QString m_dirPath; // monitored path