Licensing: re-import GPLv3 version of QJsonItem
- include full license headers, - copied from - repo: https://github.com/dridk/QJsonmodel - rev: fbd4fb3b1c1311f69cd8ada9bbb7a89fd6fe171e
This commit is contained in:
parent
13807ceabf
commit
e5c0854e66
18
LICENSES/GPLv3+-QJsonModel
Normal file
18
LICENSES/GPLv3+-QJsonModel
Normal file
@ -0,0 +1,18 @@
|
||||
/***********************************************
|
||||
Copyright (C) 2014 Schutz Sacha
|
||||
This file is part of QJsonModel (https://github.com/dridk/QJsonmodel).
|
||||
|
||||
QJsonModel 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.
|
||||
|
||||
QJsonModel 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 QJsonModel. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
**********************************************/
|
@ -1,27 +1,25 @@
|
||||
/* === 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/>.
|
||||
*/
|
||||
/***********************************************
|
||||
Copyright (C) 2014 Schutz Sacha
|
||||
This file is part of QJsonModel (https://github.com/dridk/QJsonmodel).
|
||||
|
||||
QJsonModel 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.
|
||||
|
||||
QJsonModel 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 QJsonModel. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
**********************************************/
|
||||
|
||||
#include "qjsonitem.h"
|
||||
|
||||
QJsonTreeItem::QJsonTreeItem(QJsonTreeItem *parent)
|
||||
: mType( QJsonValue::Null )
|
||||
{
|
||||
|
||||
mParent = parent;
|
||||
@ -104,8 +102,7 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren
|
||||
{
|
||||
|
||||
//Get all QJsonValue childs
|
||||
const auto keys = value.toObject().keys();
|
||||
for (const QString &key : keys){
|
||||
foreach (QString key , value.toObject().keys()){
|
||||
QJsonValue v = value.toObject().value(key);
|
||||
QJsonTreeItem * child = load(v,rootItem);
|
||||
child->setKey(key);
|
||||
@ -120,8 +117,7 @@ QJsonTreeItem* QJsonTreeItem::load(const QJsonValue& value, QJsonTreeItem* paren
|
||||
{
|
||||
//Get all QJsonValue childs
|
||||
int index = 0;
|
||||
const auto valueArray = value.toArray();
|
||||
for (const QJsonValue &v : valueArray) {
|
||||
foreach (QJsonValue v , value.toArray()){
|
||||
|
||||
QJsonTreeItem * child = load(v,rootItem);
|
||||
child->setKey(QString::number(index));
|
||||
|
@ -1,22 +1,3 @@
|
||||
/* === 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 JSONITEM_H
|
||||
#define JSONITEM_H
|
||||
#include <QtCore>
|
||||
@ -26,8 +7,8 @@
|
||||
class QJsonTreeItem
|
||||
{
|
||||
public:
|
||||
QJsonTreeItem(QJsonTreeItem * parent = nullptr);
|
||||
virtual ~QJsonTreeItem();
|
||||
QJsonTreeItem(QJsonTreeItem * parent = 0);
|
||||
~QJsonTreeItem();
|
||||
void appendChild(QJsonTreeItem * item);
|
||||
QJsonTreeItem *child(int row);
|
||||
QJsonTreeItem *parent();
|
||||
@ -41,7 +22,7 @@ public:
|
||||
QJsonValue::Type type() const;
|
||||
|
||||
|
||||
static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = nullptr);
|
||||
static QJsonTreeItem* load(const QJsonValue& value, QJsonTreeItem * parent = 0);
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -1,22 +1,21 @@
|
||||
/* === 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/>.
|
||||
*/
|
||||
/***********************************************
|
||||
Copyright (C) 2014 Schutz Sacha
|
||||
This file is part of QJsonModel (https://github.com/dridk/QJsonmodel).
|
||||
|
||||
QJsonModel 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.
|
||||
|
||||
QJsonModel 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 QJsonModel. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
**********************************************/
|
||||
|
||||
#include "qjsonmodel.h"
|
||||
#include <QFile>
|
||||
@ -36,13 +35,6 @@ QJsonModel::QJsonModel(QObject *parent) :
|
||||
|
||||
}
|
||||
|
||||
|
||||
QJsonModel::~QJsonModel()
|
||||
{
|
||||
delete mRootItem;
|
||||
}
|
||||
|
||||
|
||||
bool QJsonModel::load(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
@ -68,7 +60,11 @@ bool QJsonModel::loadJson(const QByteArray &json)
|
||||
if (!mDocument.isNull())
|
||||
{
|
||||
beginResetModel();
|
||||
mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.object()));
|
||||
if (mDocument.isArray()) {
|
||||
mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.array()));
|
||||
} else {
|
||||
mRootItem = QJsonTreeItem::load(QJsonValue(mDocument.object()));
|
||||
}
|
||||
endResetModel();
|
||||
return true;
|
||||
}
|
||||
|
@ -1,23 +1,3 @@
|
||||
/* === 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
|
||||
|
||||
@ -30,8 +10,7 @@ class QJsonModel : public QAbstractItemModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit QJsonModel(QObject *parent = nullptr);
|
||||
virtual ~QJsonModel();
|
||||
explicit QJsonModel(QObject *parent = 0);
|
||||
bool load(const QString& fileName);
|
||||
bool load(QIODevice * device);
|
||||
bool loadJson(const QByteArray& json);
|
||||
|
Loading…
Reference in New Issue
Block a user