diff options
author | Arno <am@disconnect.de> | 2013-06-23 05:47:10 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-06-23 05:47:10 +0200 |
commit | 1e247c6fea51dab6815e3a15f22cd08e56039e89 (patch) | |
tree | 3bba38aa28dfdc4b4f6b0440accab7d83a16ad75 /archivemodel.h | |
parent | 5dbcc16c289d7067132d133b374a9b7dcd2c7fd2 (diff) | |
download | SheMov-1e247c6fea51dab6815e3a15f22cd08e56039e89.tar.gz SheMov-1e247c6fea51dab6815e3a15f22cd08e56039e89.tar.bz2 SheMov-1e247c6fea51dab6815e3a15f22cd08e56039e89.zip |
Make the archive cache useful
Read the cache if there is one, if not, read it in another thread and
update the view when it's done.
Diffstat (limited to 'archivemodel.h')
-rw-r--r-- | archivemodel.h | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/archivemodel.h b/archivemodel.h index 0e3e29c..c24c130 100644 --- a/archivemodel.h +++ b/archivemodel.h @@ -29,7 +29,6 @@ class ArchiveModel : public SmTreeModel { explicit ArchiveModel(const QStringList &headers, QObject *parent = 0); const QStringList availableOrders() const; const QHash<QString, int> availableOrdersHash() const { return mAvailableOrders; } - ArchiveCollector *collector() { return mCollector; } virtual QVariant data(const QModelIndex &index, int role) const; virtual bool setData(const QModelIndex &idx, const QVariant &value, int role); virtual bool matchRecursive(const QModelIndex &parent, const QRegExp ®ex, int column = 0) const; @@ -40,6 +39,7 @@ class ArchiveModel : public SmTreeModel { signals: void needRefresh(); void databaseError(const QString &error); + void message(const QString &msg); public slots: void setOrder(int order); @@ -47,12 +47,12 @@ class ArchiveModel : public SmTreeModel { void refresh(); private slots: - void collectorFinished(); + void collectorFinished(QObject *thread); private: bool checkParents(const SmTreeItem *item, const QRegExp ®ex, int column) const; void emitDatabaseError(const QSqlError &e); - void writeCache(int o); + void writeCache(int o, SmTreeItem *rItem); void writeRecursive(SmTreeItem *start, QDataStream &stream); void writeItem(SmTreeItem *item, QDataStream &stream); SmTreeItem *readCache(int o); @@ -60,19 +60,17 @@ class ArchiveModel : public SmTreeModel { const QString cacheFile(int o) const; QSqlDatabase mDb; QHash<QString, int> mAvailableOrders; - ArchiveCollector *mCollector; + QMutex mDoneMx; + QList<ArchiveCollector*> mCollectors; int mOrder; }; class ArchiveCollector : public QThread { Q_OBJECT public: - explicit ArchiveCollector(int numFields, QObject *parent = 0); - SmTreeItem *rootItem(); - int sortOrder(); - - public slots: - void populate(int order, SmTreeItem *rootItem); + explicit ArchiveCollector(int numFields, int order, QObject *parent = 0); + SmTreeItem *rootItem() { return mRootItem; } + int sortOrder() const { return mSortOrder; } signals: void message(const QString message); |