From afe20ce029a0194e1a8e9e8fbc6f32da1cfdec75 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 10 Mar 2018 16:36:20 +0100 Subject: 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 --- qt-models/divepicturemodel.cpp | 12 ++++++++++++ qt-models/divepicturemodel.h | 1 + 2 files changed, 13 insertions(+) (limited to 'qt-models') 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> 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 pictures; -- cgit v1.2.3-70-g09d2