| 191 | } |
| 192 | |
| 193 | bool QJsonModel::loadJson(const QByteArray& json) { |
| 194 | QJsonParseError jsonError; |
| 195 | |
| 196 | const QJsonDocument& doc = QJsonDocument::fromJson(json, &jsonError); |
| 197 | if (jsonError.error == QJsonParseError::NoError) { |
| 198 | const bool rc = loadJson(doc); |
| 199 | if (!rc) |
| 200 | Q_EMIT error(i18n("Failed to load the JSON file. Empty JSON document.")); |
| 201 | else |
| 202 | Q_EMIT error(QString()); |
| 203 | |
| 204 | return rc; |
| 205 | } else { |
| 206 | Q_EMIT error(i18n("Failed to load JSON document. Error: %1.", jsonError.errorString())); |
| 207 | return false; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | bool QJsonModel::loadJson(const QJsonDocument& jdoc) { |
| 212 | PERFTRACE(QStringLiteral("load json document into the model")); |
no test coverage detected