From 77b6cc27c7c2a97b0759332cdfa382d4b32b8749 Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 22 Jun 2013 15:08:14 +0200 Subject: 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... --- archivemodel.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'archivemodel.h') diff --git a/archivemodel.h b/archivemodel.h index 29f10ab..08b4fd3 100644 --- a/archivemodel.h +++ b/archivemodel.h @@ -11,6 +11,7 @@ #include #include #include +#include #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 mAvailableOrders; ArchiveCollector *mCollector; -- cgit v1.2.3-70-g09d2