-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathqjsontablemodel.h
More file actions
33 lines (26 loc) · 996 Bytes
/
qjsontablemodel.h
File metadata and controls
33 lines (26 loc) · 996 Bytes
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
#ifndef QJSONTABLEMODEL_H
#define QJSONTABLEMODEL_H
#include <QObject>
#include <QVector>
#include <QMap>
#include <QAbstractTableModel>
#include <QJsonDocument>
#include <QJsonArray>
class QJsonTableModel : public QAbstractTableModel
{
public:
typedef QMap<QString,QString> Heading;
typedef QVector<Heading> Header;
QJsonTableModel( const Header& header, QObject * parent = 0);
bool setJson( const QJsonDocument& json );
bool setJson( const QJsonArray& array );
virtual QJsonObject getJsonObject( const QModelIndex &index ) const;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const;
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
private:
Header m_header;
QJsonArray m_json;
};
#endif // QJSONTABLEMODEL_H