pineapple-pictures/metadatamodel.h
2020-10-13 00:28:03 +08:00

37 lines
1.3 KiB
C++

#ifndef METADATAMODEL_H
#define METADATAMODEL_H
#include <QVector>
#include <QAbstractItemModel>
enum Sections : int;
class MetadataSection;
class MetadataModel : public QAbstractItemModel
{
Q_OBJECT
public:
MetadataModel();
~MetadataModel() override;
void setFile(const QString & url);
void setImageSize(const QSize & size);
QModelIndex index(int row, int col, const QModelIndex& parent = QModelIndex()) const override;
QModelIndex parent(const QModelIndex & index) const override;
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
int columnCount(const QModelIndex & = QModelIndex()) const override;
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
private:
QList<MetadataSection *> m_sections; // associated pointers free at destructor function.
QMap<Sections, MetadataSection *> m_sectionEnumIndexMap; // pointer shared with m_sections
void initGeneralSection();
bool sectionRegister(Sections sectionType, MetadataSection * section);
void setSectionEntryValue(Sections sectionType, const QString & key, const QString & value);
MetadataSection * section(Sections sectionType);
QVariant displayData(const QModelIndex & index) const;
};
#endif // METADATAMODEL_H