1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "jsondisplaymodel.h" |
6 | #include "jsondisplayview.h" |
7 | #include "jsondispalysfmodel.h" |
8 | |
9 | #include <QHeaderView> |
10 | #include <QSortFilterProxyModel> |
11 | class JsonDisplayViewPrivate |
12 | { |
13 | friend class JsonDisplayView; |
14 | JsonDisplayModel *model{nullptr}; |
15 | JsonDispalySFModel *sfModel{nullptr}; |
16 | }; |
17 | |
18 | JsonDisplayView::JsonDisplayView(QWidget *parent) |
19 | : QTableView (parent) |
20 | , d (new JsonDisplayViewPrivate) |
21 | { |
22 | d->model = new JsonDisplayModel(this); |
23 | d->sfModel = new JsonDispalySFModel(this); |
24 | d->sfModel->setSourceModel(d->model); |
25 | setSelectionMode(SelectionMode::SingleSelection); |
26 | setSelectionBehavior(SelectionBehavior::SelectRows); |
27 | setSortingEnabled(true); |
28 | setModel(d->sfModel); |
29 | } |
30 | |
31 | JsonDisplayView::~JsonDisplayView() |
32 | { |
33 | if (d) |
34 | delete d; |
35 | } |
36 | |
37 | void JsonDisplayView::parseJson(const Json::Value &jsonObj) |
38 | { |
39 | setUpdatesEnabled(false); |
40 | d->model->parseJson(jsonObj); |
41 | setUpdatesEnabled(true); |
42 | } |
43 |