diff options
author | Arno <am@disconnect.de> | 2013-03-21 16:14:54 +0100 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-03-21 16:14:54 +0100 |
commit | ce402f298b2f9733b614fbf1bde99a052d0ab5c0 (patch) | |
tree | 26da14cacb2e4fffcab47cf0a61d066568a15e7a /smdirmodel.h | |
parent | 03831d3669ea49a99a15aaf5d17724be8c533b85 (diff) | |
download | SheMov-ce402f298b2f9733b614fbf1bde99a052d0ab5c0.tar.gz SheMov-ce402f298b2f9733b614fbf1bde99a052d0ab5c0.tar.bz2 SheMov-ce402f298b2f9733b614fbf1bde99a052d0ab5c0.zip |
Final inotify!
A huge commit, I know, but it was definitely worth it! It makes the
homebrew FilesystemModel work! It's divided up into two threads:
1. The Watcher: it reacts on inotify events and dispatches them to:
2. The Collector: this thread gathers the data and emits the SIGNALS to
the the view.
Now we can actually refresh the View, not possible with
QFileSystemModel, and the data reloads in almost real time without
blocking the GUI.
Unfortunately this uncovered some bugs I had to fix:
1. Helper::md5sum: Don't crash if read fails with -1
2. SmTreeModel::addRow is broken. Even after 5h I couldn't figure out
how or why, so I brute forced it. Reset the moded when a file is added.
3. Get rid of a lot of unneeded #include's
I guess that's about it...
Diffstat (limited to 'smdirmodel.h')
-rw-r--r-- | smdirmodel.h | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/smdirmodel.h b/smdirmodel.h index c8cc69c..2db790b 100644 --- a/smdirmodel.h +++ b/smdirmodel.h @@ -8,13 +8,6 @@ #ifndef SMDIRMODEL_H #define SMDIRMODEL_H -#include <QStringList> -#include <QVariant> -#include <QModelIndex> -#include <QList> -#include <QFileInfo> -#include <QMap> -#include <QIcon> #include <QDir> #include <smtreemodel.h> @@ -24,7 +17,7 @@ class SmDirWatcher; class QTimer; class SmTreeItem; class QMutex; -class SmDataGatherer; +class SmDataColletor; class SmDirModel : public SmTreeModel { Q_OBJECT @@ -38,16 +31,19 @@ class SmDirModel : public SmTreeModel { virtual QVariant data(const QModelIndex &index, int role) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role); bool isDir(const QModelIndex &idx) const; + QDir dir() const; QFileInfo fileInfo(const QModelIndex &idx) const; + public slots: void setDir(const QString &dir); - void dirEvent(const QString &file, int e); + void dirEvent(const QList<QVariant> &data, int e); void readSettings(); void refresh(); private slots: void populate(SmTreeItem *root); + void addFile(const QList<QVariant> &data); signals: void needResize(); @@ -61,7 +57,7 @@ class SmDirModel : public SmTreeModel { QTimer *mRunTimer; QMap<QString, QIcon> mIcons; QMutex *mCollectorMx; - SmDataGatherer *mCollector; + SmDataColletor *mCollector; }; #endif // SMDIRMODEL_H |