2015-05-29 17:42:57 +00:00
|
|
|
#ifndef DIVEPICTUREMODEL_H
|
|
|
|
#define DIVEPICTUREMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QFuture>
|
|
|
|
|
|
|
|
struct PhotoHelper {
|
|
|
|
QImage image;
|
|
|
|
int offsetSeconds;
|
|
|
|
};
|
|
|
|
|
2015-08-06 13:14:18 +00:00
|
|
|
typedef QList<struct picture *> SPictureList;
|
|
|
|
typedef struct picture *picturepointer;
|
|
|
|
typedef QPair<picturepointer, QImage> SPixmap;
|
|
|
|
|
|
|
|
// function that will scale the pixmap, used inside the QtConcurrent thread.
|
|
|
|
SPixmap scaleImages(picturepointer picture);
|
|
|
|
|
2015-05-29 17:42:57 +00:00
|
|
|
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();
|
2015-05-29 17:42:57 +00:00
|
|
|
void updateDivePicturesWhenDone(QList<QFuture<void> >);
|
2015-10-20 19:03:53 +00:00
|
|
|
void removePicture(const QString& fileUrl, bool last);
|
2015-05-29 17:42:57 +00:00
|
|
|
|
2015-08-06 13:14:18 +00:00
|
|
|
protected:
|
2015-05-29 17:42:57 +00:00
|
|
|
DivePictureModel();
|
|
|
|
int numberOfPictures;
|
|
|
|
// Currently, load the images on the fly
|
|
|
|
// Later, use a thread to load the images
|
|
|
|
// Later, save the thumbnails so we don't need to reopen every time.
|
|
|
|
QHash<QString, PhotoHelper> stringPixmapCache;
|
|
|
|
};
|
|
|
|
|
2015-08-06 13:14:18 +00:00
|
|
|
#endif
|