summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-11-09 16:48:12 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-03-15 22:38:35 -0700
commit2368f3371bbdb587888d5f04095623c7b8b2ac2e (patch)
tree53420ac62c056136c542d60aede4cfeb257c3866
parent126ce41b5c3a6e486f59340d7e810913f61035e0 (diff)
downloadsubsurface-2368f3371bbdb587888d5f04095623c7b8b2ac2e.tar.gz
Store Thumbnails with image hashes
This drastically improves the time it takes to select a dive with several pictures at the expense of longer startup and bigger hash files. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-models/divepicturemodel.cpp10
-rw-r--r--qthelper.cpp3
2 files changed, 9 insertions, 4 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 1f37423e2..d61af3c5e 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -5,19 +5,21 @@
#include <QtConcurrent>
+extern QHash <QString, QImage > thumbnailCache;
+
+
SPixmap scaleImages(picturepointer picture)
{
- static QHash <QString, QImage > cache;
SPixmap ret;
ret.first = picture;
- if (cache.contains(picture->filename) && !cache.value(picture->filename).isNull()) {
- ret.second = cache.value(picture->filename);
+ if (thumbnailCache.contains(picture->filename) && !thumbnailCache.value(picture->filename).isNull()) {
+ ret.second = thumbnailCache.value(picture->filename);
} else {
int dim = defaultIconMetrics().sz_pic;
QImage p = SHashedImage(picture);
if(!p.isNull()) {
p = p.scaled(dim, dim, Qt::KeepAspectRatio);
- cache.insert(picture->filename, p);
+ thumbnailCache.insert(picture->filename, p);
}
ret.second = p;
}
diff --git a/qthelper.cpp b/qthelper.cpp
index 7e4d64ec8..67ce5daff 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -1108,6 +1108,7 @@ extern "C" void reverseGeoLookup(degrees_t latitude, degrees_t longitude, uint32
QHash<QString, QByteArray> hashOf;
QMutex hashOfMutex;
QHash<QByteArray, QString> localFilenameOf;
+QHash <QString, QImage > thumbnailCache;
extern "C" char * hashstring(char * filename)
{
@@ -1131,6 +1132,7 @@ void read_hashes()
QDataStream stream(&hashfile);
stream >> localFilenameOf;
stream >> hashOf;
+ stream >> thumbnailCache;
hashfile.close();
}
}
@@ -1142,6 +1144,7 @@ void write_hashes()
QDataStream stream(&hashfile);
stream << localFilenameOf;
stream << hashOf;
+ stream << thumbnailCache;
hashfile.commit();
} else {
qDebug() << "cannot open" << hashfile.fileName();