summaryrefslogtreecommitdiffstats
path: root/smdirwatcher.h
diff options
context:
space:
mode:
Diffstat (limited to 'smdirwatcher.h')
-rw-r--r--smdirwatcher.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/smdirwatcher.h b/smdirwatcher.h
index 3167aeb..19cd746 100644
--- a/smdirwatcher.h
+++ b/smdirwatcher.h
@@ -9,18 +9,21 @@
#define SMDIRWATCHER_H
#include <QThread>
-#include <QMutex>
#include <QList>
#include <QVariant>
#include <QFileInfo>
+#include <QQueue>
class SmTreeItem;
+class QSemaphore;
+class SmDataColletor;
class SmDirWatcher : public QThread {
Q_OBJECT
public:
- enum DWEvent { Added, Deleted, Modified };
+ enum DWEvent { None, Added, Deleted, Modified, Populate };
explicit SmDirWatcher(QObject *parent = 0);
+ SmDataColletor *collector() { return mCollector; }
~SmDirWatcher();
signals:
@@ -34,20 +37,23 @@ class SmDirWatcher : public QThread {
private:
int mFd;
int mDescr;
- QMutex mWatchMx;
QString mCurrent;
+ SmDataColletor *mCollector;
+ QSemaphore *mSemFree;
+ QSemaphore *mSemUsed;
+ QQueue<QPair<QString, DWEvent> > *mDataQueue;
+ char *mINdata;
+ int mBufLen;
};
-class SmDataGatherer : public QThread {
+class SmDataColletor : public QThread {
Q_OBJECT
public:
- explicit SmDataGatherer(const int numFields, QObject *parent = 0);
- void setCurrent(const QString &current, int mode = -1);
+ explicit SmDataColletor(const int numFields, QObject *parent = 0);
+ void init(QSemaphore *set, QSemaphore *get, QQueue<QPair<QString, SmDirWatcher::DWEvent> > *data);
public slots:
void run();
- //void setFile(const QString &fullPath, int event);
- //void populate(const QString &dir);
signals:
void newData(const QList<QVariant>,int);
@@ -55,12 +61,12 @@ class SmDataGatherer : public QThread {
void needRefresh();
private:
- //QList<QList<QVariant> > populate();
- SmTreeItem *populate();
+ SmTreeItem *populate(const QString &dir);
const QList<QVariant> fileData(const QFileInfo &fi) const;
QString mCurrent;
- QMutex mRunMx;
- QMutex mSetMx;
+ QSemaphore *mSemFree;
+ QSemaphore *mSemUsed;
+ QQueue<QPair<QString, SmDirWatcher::DWEvent> > *mDataQueue;
int mMode;
const int mNumFields;
};