-
Notifications
You must be signed in to change notification settings - Fork 1
/
CustomJsonModel.h
29 lines (26 loc) · 1.04 KB
/
CustomJsonModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#ifndef CUSTOMJSONMODEL_H
#define CUSTOMJSONMODEL_H
#include <memory>
#include <QAbstractTableModel>
#include <QJsonObject>
#include <QJsonArray>
class CustomJsonModel : public QAbstractTableModel
{
public:
CustomJsonModel(const QJsonArray &src, QObject *parent = Q_NULLPTR);
int columnCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
//QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
//QModelIndex parent(const QModelIndex &index) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const override;
protected:
QJsonArray m_src;
int m_rowCount;
int m_columnCount = 0;
QVariantMap m_vmapHead;
std::unique_ptr<QString[]> m_headers;
QList<QVariantMap> m_data;
QString currencyAt(int offset) const;
};
#endif // CUSTOMJSONMODEL_H