diff options
author | Arno <am@disconnect.de> | 2013-06-22 15:08:14 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-06-22 15:08:14 +0200 |
commit | 77b6cc27c7c2a97b0759332cdfa382d4b32b8749 (patch) | |
tree | 37684e95c803cdec76b976d4b0c4f04ea75f19dc /archivemodel.h | |
parent | 1627d5fb197cb7d28191264e98b93dc55d92ed1b (diff) | |
download | SheMov-77b6cc27c7c2a97b0759332cdfa382d4b32b8749.tar.gz SheMov-77b6cc27c7c2a97b0759332cdfa382d4b32b8749.tar.bz2 SheMov-77b6cc27c7c2a97b0759332cdfa382d4b32b8749.zip |
Archive Cache
Create a caches of database archive views. Esp. gathering data for
actors takes a long time, and I don't see how to optimize the queries.
So write them to a QDataStream. It was much more difficult that it
sounds. Once again I was lost in recursion. Did I mention that I hate
recursion?
The solution:
When writing use the address of the SMTreeItem cast to qint64 as unique
key. On reading build a hash with the address as key and use it to find
the parent of the next item.
I hope that makes sense...
Diffstat (limited to 'archivemodel.h')
-rw-r--r-- | archivemodel.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/archivemodel.h b/archivemodel.h index 29f10ab..08b4fd3 100644 --- a/archivemodel.h +++ b/archivemodel.h @@ -11,6 +11,7 @@ #include <QHash> #include <QSqlDatabase> #include <QThread> +#include <QDataStream> #include "smtreemodel.h" @@ -50,6 +51,12 @@ class ArchiveModel : public SmTreeModel { private: bool checkParents(const SmTreeItem *item, const QRegExp ®ex, int column) const; void emitDatabaseError(const QSqlError &e); + void writeCache(int o); + void writeRecursive(SmTreeItem *start, QDataStream &stream); + void writeItem(SmTreeItem *item, QDataStream &stream); + SmTreeItem *readCache(int o); + SmTreeItem *readItem(QDataStream &stream) const; + const QString cacheFile(int o) const; QSqlDatabase mDb; QHash<QString, int> mAvailableOrders; ArchiveCollector *mCollector; |