mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
3967b1fd4d
commit
afe20ce029
3 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "TabDivePhotos.h"
|
#include "TabDivePhotos.h"
|
||||||
#include "ui_TabDivePhotos.h"
|
#include "ui_TabDivePhotos.h"
|
||||||
|
#include "core/imagedownloader.h"
|
||||||
|
|
||||||
#include <qt-models/divepicturemodel.h>
|
#include <qt-models/divepicturemodel.h>
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ DivePictureModel::DivePictureModel() : rowDDStart(0),
|
||||||
zoomLevel(0.0),
|
zoomLevel(0.0),
|
||||||
defaultSize(defaultIconMetrics().sz_pic)
|
defaultSize(defaultIconMetrics().sz_pic)
|
||||||
{
|
{
|
||||||
|
connect(Thumbnailer::instance(), &Thumbnailer::thumbnailChanged,
|
||||||
|
this, &DivePictureModel::updateThumbnail, Qt::QueuedConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DivePictureModel::updateDivePicturesWhenDone(QList<QFuture<void>> futures)
|
void DivePictureModel::updateDivePicturesWhenDone(QList<QFuture<void>> futures)
|
||||||
|
@ -160,3 +162,13 @@ int DivePictureModel::rowCount(const QModelIndex &parent) const
|
||||||
Q_UNUSED(parent);
|
Q_UNUSED(parent);
|
||||||
return pictures.count();
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
int rowDDStart, rowDDEnd;
|
int rowDDStart, rowDDEnd;
|
||||||
public slots:
|
public slots:
|
||||||
void setZoomLevel(int level);
|
void setZoomLevel(int level);
|
||||||
|
void updateThumbnail(QString filename, QImage thumbnail);
|
||||||
private:
|
private:
|
||||||
DivePictureModel();
|
DivePictureModel();
|
||||||
QList<PictureEntry> pictures;
|
QList<PictureEntry> pictures;
|
||||||
|
|
Loading…
Add table
Reference in a new issue