Using the typedef ModelItemValues for "QHash<int, QVariant>".

This commit is contained in:
2026-01-04 17:48:27 +01:00
parent 2702b9c835
commit 3e6273cb7d
15 changed files with 60 additions and 49 deletions

View File

@ -5,9 +5,9 @@
#include "../model/metadata.h"
QList<QHash<int, QVariant>> JsonParser::toItemValuesList(const QByteArray& jsonData,
const QString& objectName) {
QList<QHash<int, QVariant>> result;
QList<ModelItemValues> JsonParser::toItemValuesList(const QByteArray& jsonData,
const QString& objectName) {
QList<ModelItemValues> result;
if (jsonData.isEmpty()) {
return result;
@ -16,14 +16,14 @@ QList<QHash<int, QVariant>> JsonParser::toItemValuesList(const QByteArray& jsonD
QJsonArray itemArray = extractItemArray(jsonData, objectName);
foreach (QJsonValue value, itemArray) {
QJsonObject itemJsonObject = value.toObject();
QHash<int, QVariant> values = jsonObjectToItemValues(itemJsonObject);
QJsonObject itemJsonObject = value.toObject();
ModelItemValues values = jsonObjectToItemValues(itemJsonObject);
result.append(values);
}
return result;
}
QByteArray JsonParser::itemValuesListToJson(const QList<QHash<int, QVariant>>& itemValuesList,
QByteArray JsonParser::itemValuesListToJson(const QList<ModelItemValues>& itemValuesList,
const QString& objectName) {
QJsonDocument jsonDoc;
QJsonObject rootObject;
@ -72,8 +72,8 @@ QJsonArray JsonParser::extractItemArray(const QByteArray& jsonData, const QStrin
return itemArray;
}
QHash<int, QVariant> JsonParser::jsonObjectToItemValues(const QJsonObject& itemJsonObject) {
QHash<int, QVariant> values;
ModelItemValues JsonParser::jsonObjectToItemValues(const QJsonObject& itemJsonObject) {
ModelItemValues values;
QListIterator<UserRoles> i(USER_FACING_ROLES);
while (i.hasNext()) {