From 03831d3669ea49a99a15aaf5d17724be8c533b85 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 20 Mar 2013 21:27:35 +0100 Subject: Use a Thread for collecting file data blocking the GUI isn't nice, so use a separate Thread to gather all the data for SmDirModel. Populating and changing directory works, but modifying a file is most likely broken. --- smdirmodel.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'smdirmodel.h') diff --git a/smdirmodel.h b/smdirmodel.h index 3712cba..c8cc69c 100644 --- a/smdirmodel.h +++ b/smdirmodel.h @@ -23,12 +23,15 @@ class SmDirWatcher; class QTimer; class SmTreeItem; +class QMutex; +class SmDataGatherer; class SmDirModel : public SmTreeModel { Q_OBJECT public: enum CustomRoles { NameRole = Qt::UserRole + 1, SizeRole = Qt::UserRole + 2, TypeRole = Qt::UserRole + 3, CreatedRole = Qt::UserRole + 4, Md5sumRole = Qt::UserRole + 5, DurationRole = Qt::UserRole + 6, BitrateRole = Qt::UserRole + 7, FullPathRole = Qt::UserRole + 8 }; enum Fields { Name = 0, Size = 1, Type = 2, Created = 3, Md5sum = 4, Duration = 5, Bitrate = 6, FullPath = 7 }; + enum { NumFields = 8 }; enum FileDate { Access, Modified, Status }; explicit SmDirModel(const QStringList &headers, QObject *parent = 0); ~SmDirModel(); @@ -36,7 +39,6 @@ class SmDirModel : public SmTreeModel { virtual bool setData(const QModelIndex &index, const QVariant &value, int role); bool isDir(const QModelIndex &idx) const; QFileInfo fileInfo(const QModelIndex &idx) const; - QDir dir() const { return QDir(mCur); }; public slots: void setDir(const QString &dir); @@ -45,7 +47,7 @@ class SmDirModel : public SmTreeModel { void refresh(); private slots: - void populate(); + void populate(SmTreeItem *root); signals: void needResize(); @@ -54,9 +56,12 @@ class SmDirModel : public SmTreeModel { const QList fileData(const QFileInfo &fi) const; SmDirWatcher *mWatch; QStringList mHeaders; + QString mCurrentDir; QString mCur; QTimer *mRunTimer; QMap mIcons; + QMutex *mCollectorMx; + SmDataGatherer *mCollector; }; #endif // SMDIRMODEL_H -- cgit v1.2.3-70-g09d2