source: calamares/trunk/fuentes/src/libcalamaresui/utils/qjsonmodel.h @ 7538

Last change on this file since 7538 was 7538, checked in by kbut, 13 months ago

sync with github

File size: 1.2 KB
Line 
1/* === This file is part of Calamares - <https://github.com/calamares> ===
2 *
3 *   SPDX-License-Identifier: GPL-3.0+
4 *   License-Filename: LICENSES/GPLv3+-QJsonModel
5 */
6
7#ifndef QJSONMODEL_H
8#define QJSONMODEL_H
9
10#include <QAbstractItemModel>
11#include "qjsonitem.h"
12#include <QJsonDocument>
13#include <QJsonObject>
14#include <QIcon>
15class QJsonModel : public QAbstractItemModel
16{
17    Q_OBJECT
18public:
19    explicit QJsonModel(QObject *parent = 0);
20    ~QJsonModel();
21    bool load(const QString& fileName);
22    bool load(QIODevice * device);
23    bool loadJson(const QByteArray& json);
24    QVariant data(const QModelIndex &index, int role) const;
25    QVariant headerData(int section, Qt::Orientation orientation, int role) const;
26    QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
27    QModelIndex parent(const QModelIndex &index) const;
28    int rowCount(const QModelIndex &parent = QModelIndex()) const;
29    int columnCount(const QModelIndex &parent = QModelIndex()) const;
30    void setIcon(const QJsonValue::Type& type, const QIcon& icon);
31
32
33
34private:
35    QJsonTreeItem * mRootItem;
36    QJsonDocument mDocument;
37    QStringList mHeaders;
38    QHash<QJsonValue::Type, QIcon> mTypeIcons;
39
40
41};
42
43#endif // QJSONMODEL_H
Note: See TracBrowser for help on using the repository browser.