From e5c0854e6613c607ad1209bd826ef75b657a0c9a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Sep 2017 14:24:05 +0200 Subject: [PATCH] Licensing: re-import GPLv3 version of QJsonItem - include full license headers, - copied from - repo: https://github.com/dridk/QJsonmodel - rev: fbd4fb3b1c1311f69cd8ada9bbb7a89fd6fe171e --- LICENSES/GPLv3+-QJsonModel | 18 ++++++++++ src/libcalamaresui/utils/qjsonitem.cpp | 42 ++++++++++------------ src/libcalamaresui/utils/qjsonitem.h | 25 ++----------- src/libcalamaresui/utils/qjsonmodel.cpp | 48 ++++++++++++------------- src/libcalamaresui/utils/qjsonmodel.h | 23 +----------- 5 files changed, 63 insertions(+), 93 deletions(-) create mode 100644 LICENSES/GPLv3+-QJsonModel diff --git a/LICENSES/GPLv3+-QJsonModel b/LICENSES/GPLv3+-QJsonModel new file mode 100644 index 000000000..8a8e272c0 --- /dev/null +++ b/LICENSES/GPLv3+-QJsonModel @@ -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 . + +**********************************************/ diff --git a/src/libcalamaresui/utils/qjsonitem.cpp b/src/libcalamaresui/utils/qjsonitem.cpp index 35c9725dd..b278913b4 100644 --- a/src/libcalamaresui/utils/qjsonitem.cpp +++ b/src/libcalamaresui/utils/qjsonitem.cpp @@ -1,27 +1,25 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ +/*********************************************** + 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 . + +**********************************************/ #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)); diff --git a/src/libcalamaresui/utils/qjsonitem.h b/src/libcalamaresui/utils/qjsonitem.h index 1dfa5c65e..6e030c656 100644 --- a/src/libcalamaresui/utils/qjsonitem.h +++ b/src/libcalamaresui/utils/qjsonitem.h @@ -1,22 +1,3 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ - #ifndef JSONITEM_H #define JSONITEM_H #include @@ -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: diff --git a/src/libcalamaresui/utils/qjsonmodel.cpp b/src/libcalamaresui/utils/qjsonmodel.cpp index 3d427d0fb..45086b7c6 100644 --- a/src/libcalamaresui/utils/qjsonmodel.cpp +++ b/src/libcalamaresui/utils/qjsonmodel.cpp @@ -1,22 +1,21 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ +/*********************************************** + 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 . + +**********************************************/ #include "qjsonmodel.h" #include @@ -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; } diff --git a/src/libcalamaresui/utils/qjsonmodel.h b/src/libcalamaresui/utils/qjsonmodel.h index 0bf8f5dab..cdb6caf86 100644 --- a/src/libcalamaresui/utils/qjsonmodel.h +++ b/src/libcalamaresui/utils/qjsonmodel.h @@ -1,23 +1,3 @@ -/* === This file is part of Calamares - === - * - * Originally from QJsonModel - * Copyright 2015, Sacha Schutz - * - * 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 . - */ - - #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);