2018-03-17 19:26:51 +00:00
|
|
|
|
|
|
|
#ifndef JSONMODEL_H
|
|
|
|
#define JSONMODEL_H
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
|
|
|
#include <QJsonDocument>
|
|
|
|
#include <QJsonValue>
|
|
|
|
#include <QJsonArray>
|
|
|
|
#include <QJsonObject>
|
|
|
|
#include <QIcon>
|
|
|
|
|
|
|
|
#include "JsonTreeItem.h"
|
|
|
|
|
|
|
|
class JsonTreeItem;
|
|
|
|
|
|
|
|
class JsonModel : public QAbstractItemModel
|
|
|
|
{
|
2018-03-21 20:32:32 +00:00
|
|
|
|
2018-03-17 19:26:51 +00:00
|
|
|
public:
|
|
|
|
explicit JsonModel(QObject *parent = 0);
|
2018-03-21 20:32:32 +00:00
|
|
|
bool load(QIODevice *device);
|
|
|
|
bool loadJson(const QByteArray &json);
|
2018-03-17 19:26:51 +00:00
|
|
|
QVariant data(const QModelIndex &index, int role) const Q_DECL_OVERRIDE;
|
|
|
|
QVariant headerData(int section, Qt::Orientation orientation, int role) const Q_DECL_OVERRIDE;
|
2018-03-21 20:32:32 +00:00
|
|
|
QModelIndex index(int row, int column,
|
|
|
|
const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
2018-03-17 19:26:51 +00:00
|
|
|
QModelIndex parent(const QModelIndex &index) const Q_DECL_OVERRIDE;
|
|
|
|
int rowCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
|
|
|
int columnCount(const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
|
|
|
~JsonModel();
|
|
|
|
private:
|
2018-03-21 20:32:32 +00:00
|
|
|
JsonTreeItem *mRootItem;
|
2018-03-17 19:26:51 +00:00
|
|
|
QJsonDocument mDocument;
|
|
|
|
QStringList mHeaders;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // JSONMODEL_H
|