-
Notifications
You must be signed in to change notification settings - Fork 0
/
qjsonmodel.h
executable file
·37 lines (27 loc) · 998 Bytes
/
qjsonmodel.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
30
31
32
33
34
35
36
37
#ifndef QJSONMODEL_H
#define QJSONMODEL_H
#include <QAbstractItemModel>
#include "qjsonitem.h"
#include <QJsonDocument>
#include <QJsonObject>
#include <QIcon>
class QJsonModel : public QAbstractItemModel
{
Q_OBJECT
public:
explicit QJsonModel(QObject *parent = 0);
void setJsonObject(const QJsonObject object);
QVariant data(const QModelIndex &index, int role) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent(const QModelIndex &index) const;
int rowCount(const QModelIndex &parent = QModelIndex()) const;
int columnCount(const QModelIndex &parent = QModelIndex()) const;
void setIcon(const QJsonValue::Type& type, const QIcon& icon);
private:
QJsonTreeItem * mRootItem;
QJsonDocument mDocument;
QStringList mHeaders;
QHash<QJsonValue::Type, QIcon> mTypeIcons;
};
#endif // QJSONMODEL_H