mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-30 10:55:37 -04:00
Add QJsonModel.
This commit is contained in:
parent
f00a557d07
commit
9249d6e165
5 changed files with 429 additions and 0 deletions
56
src/libcalamaresui/utils/qjsonmodel.h
Normal file
56
src/libcalamaresui/utils/qjsonmodel.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* === This file is part of Calamares - <http://github.com/calamares> ===
|
||||
*
|
||||
* Originally from QJsonModel <https://github.com/dridk/QJsonmodel>
|
||||
* Copyright 2015, Sacha Schutz <sacha@labsquare.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Calamares is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Calamares. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef QJSONMODEL_H
|
||||
#define QJSONMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include "qjsonitem.h"
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QIcon>
|
||||
class QJsonModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QJsonModel(QObject *parent = 0);
|
||||
bool load(const QString& fileName);
|
||||
bool load(QIODevice * device);
|
||||
bool loadJson(const QByteArray& json);
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
QModelIndex index(int row, int column,const QModelIndex &parent = QModelIndex()) const;
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
void setIcon(const QJsonValue::Type& type, const QIcon& icon);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QJsonTreeItem * mRootItem;
|
||||
QJsonDocument mDocument;
|
||||
QStringList mHeaders;
|
||||
QHash<QJsonValue::Type, QIcon> mTypeIcons;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // QJSONMODEL_H
|
Loading…
Add table
Add a link
Reference in a new issue