diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-09-17 16:56:58 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-09-17 08:56:25 -0700 |
commit | d0145621a1d6a76922cc271208e07ed5827a6590 (patch) | |
tree | 1cafd5ac0cfc8ea124d78872cebd67ca964bfbae /qthelper.cpp | |
parent | 2d376de68ddde1bfc159f0e182120c1e8bc62610 (diff) | |
download | subsurface-d0145621a1d6a76922cc271208e07ed5827a6590.tar.gz |
Hash images upon loading divelog file rather than when loading image
Up to now, we only computed hashes of images upon actually displaying the images.
With this patch we start to compute hashes once we load the xml or from git. This
happens in the background, so the user should note an increased CPU load only once
per divelog.
Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qthelper.cpp')
-rw-r--r-- | qthelper.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp index a4dc09057..6e3c957a6 100644 --- a/qthelper.cpp +++ b/qthelper.cpp @@ -1057,6 +1057,7 @@ void read_hashes() if (hashfile.open(QIODevice::ReadOnly)) { QDataStream stream(&hashfile); stream >> localFilenameOf; + stream >> hashOf; hashfile.close(); } } @@ -1067,6 +1068,7 @@ void write_hashes() if (hashfile.open(QIODevice::WriteOnly)) { QDataStream stream(&hashfile); stream << localFilenameOf; + stream << hashOf; hashfile.commit(); } else { qDebug() << "cannot open" << hashfile.fileName(); @@ -1124,6 +1126,20 @@ void updateHash(struct picture *picture) { free(old); } +void hashPicture(struct picture *picture) +{ + learnHash(picture, hashFile(QString(picture->filename))); + mark_divelist_changed((true)); + +} + +extern "C" void cache_picture(struct picture *picture) +{ + QString filename = picture->filename; + if (!hashOf.contains(filename)) + QtConcurrent::run(hashPicture, picture); +} + void learnImages(const QDir dir, int max_recursions, bool recursed) { QDir current(dir); |