1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef JSONDISPLAYMODEL_H |
6 | #define JSONDISPLAYMODEL_H |
7 | |
8 | #include <json/json.h> |
9 | |
10 | #include <QStandardItemModel> |
11 | |
12 | class JsonDisplayModelPrivate; |
13 | class JsonDisplayModel : public QStandardItemModel |
14 | { |
15 | Q_OBJECT |
16 | JsonDisplayModelPrivate *const d; |
17 | public: |
18 | explicit JsonDisplayModel(QObject *parent = nullptr); |
19 | virtual ~JsonDisplayModel(); |
20 | public slots: |
21 | void parseJson(const Json::Value &value); |
22 | |
23 | protected: |
24 | virtual QVariant headerData(int section, Qt::Orientation orientation, |
25 | int role = Qt::DisplayRole) const override; |
26 | virtual bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, |
27 | int role = Qt::EditRole) override; |
28 | virtual QModelIndex index(int row, int column, |
29 | const QModelIndex &parent = QModelIndex()) const override; |
30 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; |
31 | }; |
32 | |
33 | #endif // JSONDISPLAYMODEL_H |
34 |