38 lines
913 B
C++
38 lines
913 B
C++
#pragma once
|
|
|
|
#include <QAbstractTableModel>
|
|
#include <QImage>
|
|
#include <QJsonObject>
|
|
#include <QFutureWatcher>
|
|
|
|
struct ArtPiece {
|
|
QString filename, jsonFilename;
|
|
QString title;
|
|
QJsonObject object;
|
|
|
|
QDate date;
|
|
QImage image, thumbnail;
|
|
|
|
bool hasAltText = false;
|
|
};
|
|
|
|
class ArtModel : public QAbstractTableModel {
|
|
public:
|
|
explicit ArtModel(const QString& definitionDirectory, const QString& assetDirectory);
|
|
|
|
int rowCount(const QModelIndex &parent) const override;
|
|
int columnCount(const QModelIndex &parent) const override;
|
|
|
|
QVariant data(const QModelIndex &index, int role) const override;
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
|
|
|
|
private:
|
|
void loadData(ArtPiece& piece, const QString& filename, const QString& assetFilename);
|
|
|
|
void pieceFinished(int index);
|
|
void finished();
|
|
|
|
QFutureWatcher<ArtPiece>* piecesFuture;
|
|
|
|
QList<ArtPiece> m_artPieces;
|
|
};
|