2017-04-27 18:25:32 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2015-05-29 17:42:57 +00:00
|
|
|
#ifndef DIVEPICTUREMODEL_H
|
|
|
|
#define DIVEPICTUREMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QFuture>
|
|
|
|
|
2017-12-09 23:07:46 +00:00
|
|
|
struct PictureEntry {
|
2018-06-30 19:32:14 +00:00
|
|
|
int diveId;
|
2017-12-09 23:07:46 +00:00
|
|
|
struct picture *picture;
|
|
|
|
QString filename;
|
2015-05-29 17:42:57 +00:00
|
|
|
QImage image;
|
|
|
|
int offsetSeconds;
|
|
|
|
};
|
|
|
|
|
|
|
|
class DivePictureModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static DivePictureModel *instance();
|
|
|
|
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
2015-08-06 13:14:18 +00:00
|
|
|
virtual void updateDivePictures();
|
2018-05-18 19:57:18 +00:00
|
|
|
void removePictures(const QVector<QString> &fileUrls);
|
2018-06-30 19:32:14 +00:00
|
|
|
void updateDivePictureOffset(int diveId, const QString &filename, int offsetSeconds);
|
2018-06-30 09:36:37 +00:00
|
|
|
signals:
|
|
|
|
void picturesRemoved(const QVector<QString> &fileUrls);
|
2017-12-17 15:17:38 +00:00
|
|
|
public slots:
|
|
|
|
void setZoomLevel(int level);
|
2018-03-10 15:36:20 +00:00
|
|
|
void updateThumbnail(QString filename, QImage thumbnail);
|
2017-12-17 13:49:40 +00:00
|
|
|
private:
|
2015-05-29 17:42:57 +00:00
|
|
|
DivePictureModel();
|
2018-05-19 19:18:39 +00:00
|
|
|
QVector<PictureEntry> pictures;
|
2018-05-01 10:35:18 +00:00
|
|
|
int findPictureId(const QString &filename); // Return -1 if not found
|
2017-12-17 15:17:38 +00:00
|
|
|
double zoomLevel; // -1.0: minimum, 0.0: standard, 1.0: maximum
|
2018-04-11 04:56:46 +00:00
|
|
|
int size;
|
2017-12-17 15:17:38 +00:00
|
|
|
void updateThumbnails();
|
2018-04-11 04:56:46 +00:00
|
|
|
void updateZoom();
|
2015-05-29 17:42:57 +00:00
|
|
|
};
|
|
|
|
|
2015-08-06 13:14:18 +00:00
|
|
|
#endif
|