mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
4583cd8e09
We had pointers to data structures on the stack which we frequently reallocated. These data structure contain basically a filename and an offset. We then create a hash of the pointers to those datastructures with the filename being the key. And then we passed those pointers around through a Qt model(!!!) only in order to then later look up by filename what the offset might be. I am at a loss for words for the lunacy behind this design. How about we just remember the offsets and pass the integers around? Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
#ifndef DIVEPICTUREWIDGET_H
|
|
#define DIVEPICTUREWIDGET_H
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QListView>
|
|
#include <QThread>
|
|
|
|
struct PhotoHelper {
|
|
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;
|
|
void updateDivePictures();
|
|
void removePicture(const QString& fileUrl);
|
|
|
|
private:
|
|
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;
|
|
};
|
|
|
|
class DivePictureWidget : public QListView {
|
|
Q_OBJECT
|
|
public:
|
|
DivePictureWidget(QWidget *parent);
|
|
signals:
|
|
void photoDoubleClicked(const QString filePath);
|
|
private
|
|
slots:
|
|
void doubleClicked(const QModelIndex &index);
|
|
};
|
|
|
|
class DivePictureThumbnailThread : public QThread {
|
|
};
|
|
|
|
#endif
|