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
|
|
|
|
|
2018-07-15 15:56:18 +00:00
|
|
|
#include "core/units.h"
|
|
|
|
|
2015-05-29 17:42:57 +00:00
|
|
|
#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
|
|
|
QString filename;
|
2015-05-29 17:42:57 +00:00
|
|
|
QImage image;
|
|
|
|
int offsetSeconds;
|
2019-04-14 14:19:23 +00:00
|
|
|
duration_t length;
|
2015-05-29 17:42:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class DivePictureModel : public QAbstractTableModel {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
static DivePictureModel *instance();
|
2018-09-29 20:13:44 +00:00
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
|
2018-07-31 05:41:19 +00:00
|
|
|
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-07-15 15:56:18 +00:00
|
|
|
void updateThumbnail(QString filename, QImage thumbnail, duration_t duration);
|
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
|