summaryrefslogtreecommitdiffstats
path: root/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-02-26 14:44:27 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-02-27 06:30:49 +0100
commite6482bbdc8a1359d51c70aaf847d3aac7895b960 (patch)
treeaab14f7043fd1d19d182578e7549f4d9a8da151f /qthelper.cpp
parentb02bf002a677e45dbaa4d28edadbaafc89a7badc (diff)
downloadsubsurface-e6482bbdc8a1359d51c70aaf847d3aac7895b960.tar.gz
UI to learn hashes of local image files
This addes a menu entry for the user to select a directory that is recursively traversed to look for image files and compute the hashes of those images (for those images to be available to be displayed in dives according to their hash values). This traversal and hash computation happens in and independend thread and so far the only feedback to the user is that upon completion the dispayed images are updated. 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.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/qthelper.cpp b/qthelper.cpp
index 74c67d769..14e67e089 100644
--- a/qthelper.cpp
+++ b/qthelper.cpp
@@ -849,3 +849,27 @@ void updateHash(struct picture *picture) {
picture->hash = strdup(hash.toHex());
free(old);
}
+
+void learnImages(const QDir dir, int max_recursions, bool recursed)
+{
+ QDir current(dir);
+ QStringList filters, files;
+
+ if (max_recursions) {
+ foreach (QString dirname, dir.entryList(QStringList(), QDir::NoDotAndDotDot | QDir::Dirs)) {
+ learnImages(QDir(dir.filePath(dirname)), max_recursions - 1, true);
+ }
+ }
+
+ foreach (QString format, QImageReader::supportedImageFormats()) {
+ filters.append(QString("*.").append(format));
+ }
+
+ foreach (QString file, dir.entryList(filters, QDir::Files)) {
+ files.append(dir.absoluteFilePath(file));
+ }
+
+ QtConcurrent::blockingMap(files, hashFile);
+ if (!recursed)
+ DivePictureModel::instance()->updateDivePictures();
+}