diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-03-10 16:36:20 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-05-13 13:52:35 -0700 |
commit | afe20ce029a0194e1a8e9e8fbc6f32da1cfdec75 (patch) | |
tree | 2f90f07b65577067996c2be3c6e30c14b37df71e /qt-models | |
parent | 3967b1fd4d6ed2191daf12816d2cee1949c21d0b (diff) | |
download | subsurface-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')
-rw-r--r-- | qt-models/divepicturemodel.cpp | 12 | ||||
-rw-r--r-- | qt-models/divepicturemodel.h | 1 |
2 files changed, 13 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)); + } +} diff --git a/qt-models/divepicturemodel.h b/qt-models/divepicturemodel.h index 443be4a0e..0839630bd 100644 --- a/qt-models/divepicturemodel.h +++ b/qt-models/divepicturemodel.h @@ -26,6 +26,7 @@ public: int rowDDStart, rowDDEnd; public slots: void setZoomLevel(int level); + void updateThumbnail(QString filename, QImage thumbnail); private: DivePictureModel(); QList<PictureEntry> pictures; |