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>
This commit is contained in:
Berthold Stoeger 2018-03-10 16:36:20 +01:00 committed by Dirk Hohndel
parent 3967b1fd4d
commit afe20ce029
3 changed files with 14 additions and 0 deletions

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include "TabDivePhotos.h"
#include "ui_TabDivePhotos.h"
#include "core/imagedownloader.h"
#include <qt-models/divepicturemodel.h>

View file

@ -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));
}
}

View file

@ -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;