aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/divepicturemodel.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-03-10 16:36:20 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-05-13 13:52:35 -0700
commitafe20ce029a0194e1a8e9e8fbc6f32da1cfdec75 (patch)
tree2f90f07b65577067996c2be3c6e30c14b37df71e /qt-models/divepicturemodel.cpp
parent3967b1fd4d6ed2191daf12816d2cee1949c21d0b (diff)
downloadsubsurface-afe20ce029a0194e1a8e9e8fbc6f32da1cfdec75.tar.gz
Dive pictures: Update pictures when thumbnails are ready
Connect the thumbnailer signal to the dive picture model slot. This needs some code-reshuffling in the dive picture model. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'qt-models/divepicturemodel.cpp')
-rw-r--r--qt-models/divepicturemodel.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/qt-models/divepicturemodel.cpp b/qt-models/divepicturemodel.cpp
index 53e631e17..c5453c3a9 100644
--- a/qt-models/divepicturemodel.cpp
+++ b/qt-models/divepicturemodel.cpp
@@ -21,6 +21,8 @@ DivePictureModel::DivePictureModel() : rowDDStart(0),
zoomLevel(0.0),
defaultSize(defaultIconMetrics().sz_pic)
{
+ connect(Thumbnailer::instance(), &Thumbnailer::thumbnailChanged,
+ this, &DivePictureModel::updateThumbnail, Qt::QueuedConnection);
}
void DivePictureModel::updateDivePicturesWhenDone(QList<QFuture<void>> futures)
@@ -160,3 +162,13 @@ int DivePictureModel::rowCount(const QModelIndex &parent) const
Q_UNUSED(parent);
return pictures.count();
}
+
+void DivePictureModel::updateThumbnail(QString filename, QImage thumbnail)
+{
+ for (int i = 0; i < pictures.size(); ++i) {
+ if (pictures[i].filename != filename)
+ continue;
+ pictures[i].image = thumbnail;
+ emit dataChanged(createIndex(i, 0), createIndex(i, 1));
+ }
+}