| 59 | } |
| 60 | |
| 61 | void SettingsPrivate::fromJson(const QByteArray &json, SettingData *data) |
| 62 | { |
| 63 | QJsonParseError error; |
| 64 | const QJsonDocument &doc = QJsonDocument::fromJson(json, &error); |
| 65 | if (error.error != QJsonParseError::NoError) { |
| 66 | qWarning() << "Failed to parse the setting file: " << error.errorString(); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | const QJsonObject &groupList = doc.object(); |
| 71 | for (auto grpIter = groupList.constBegin(); grpIter != groupList.constEnd(); ++grpIter) { |
| 72 | const QJsonValue &value = grpIter.value(); |
| 73 | if (!value.isObject()) |
| 74 | continue; |
| 75 | |
| 76 | const QJsonObject &groupObj = value.toObject(); |
| 77 | QVariantHash hash = groupObj.toVariantHash(); |
| 78 | data->values[grpIter.key()] = hash; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | QByteArray SettingsPrivate::toJson(const SettingData &data) |
| 83 | { |
no test coverage detected