mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-01 10:03:23 +00:00
c73828d605
The code of DivePictureModel used a QHash to keep track of thumbnails. Not only was the code rather complex - it also had the consequence that pictures are sorted according to the hash function, i.e. seemingly random. This commit replaces the QHash by a simple QList which keeps track of thumbnails and some meta-data. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
36 lines
882 B
C++
36 lines
882 B
C++
// SPDX-License-Identifier: GPL-2.0
|
|
#include "qt-models/divesitepicturesmodel.h"
|
|
#include "core/dive.h"
|
|
#include <stdint.h>
|
|
|
|
#include <QtConcurrent>
|
|
#include <QPixmap>
|
|
|
|
DiveSitePicturesModel* DiveSitePicturesModel::instance() {
|
|
static DiveSitePicturesModel *self = new DiveSitePicturesModel();
|
|
return self;
|
|
}
|
|
|
|
DiveSitePicturesModel::DiveSitePicturesModel() {
|
|
|
|
}
|
|
|
|
void DiveSitePicturesModel::updateDivePictures() {
|
|
beginResetModel();
|
|
pictures.clear();
|
|
endResetModel();
|
|
|
|
const uint32_t ds_uuid = displayed_dive_site.uuid;
|
|
struct dive *d;
|
|
int i;
|
|
|
|
for_each_dive (i, d)
|
|
if (d->dive_site_uuid == ds_uuid && dive_get_picture_count(d))
|
|
FOR_EACH_PICTURE(d)
|
|
pictures.push_back({picture, picture->filename, QImage(), picture->offset.seconds});
|
|
|
|
QtConcurrent::blockingMap(pictures, scaleImages);
|
|
|
|
beginInsertRows(QModelIndex(), 0, pictures.count() - 1);
|
|
endInsertRows();
|
|
}
|