diff --git a/formats/jsonparser.cpp b/formats/jsonparser.cpp index dc08ff4..559ea20 100644 --- a/formats/jsonparser.cpp +++ b/formats/jsonparser.cpp @@ -98,12 +98,16 @@ ModelItemValues JsonParser::jsonObjectToItemValues(const QJsonObject& itemJsonOb values.insert(keyValuePair.first, keyValuePair.second); } - QListIterator i(USER_FACING_ROLES); - while (i.hasNext()) { - const UserRoles role = i.next(); - std::pair keyValuePair = getKeyValuePair(itemJsonObject, role); - values.insert(keyValuePair.first, keyValuePair.second); + for (auto iter = itemJsonObject.constBegin(), end = itemJsonObject.constEnd(); iter != end; + ++iter) { + const QString roleName = iter.key(); + if (ROLE_NAMES.values().contains(roleName)) { + const int role = ROLE_NAMES.key(roleName.toLatin1()); + std::pair keyValuePair = getKeyValuePair(itemJsonObject, role); + values.insert(keyValuePair.first, keyValuePair.second); + } } + return values; } diff --git a/model/tablemodel.cpp b/model/tablemodel.cpp index 66672b9..860bae0 100644 --- a/model/tablemodel.cpp +++ b/model/tablemodel.cpp @@ -302,13 +302,6 @@ QMap TableModel::onlyChangedValues(const QModelIndex& index, const QVariant oldValue = index.data(role); // TODO check if role is a editable role? if (oldValue != newValue) { - bool emptyValueIsEqualToZero = isEmptyValueEqualToZero(role); - // REFACTOR the next if statement is too complex - if (emptyValueIsEqualToZero && oldValue == QVariant() && newValue == 0) { - qDebug() << "oldValue:" << oldValue << "& newValue:" << newValue - << "mean the same. Ignoring..."; - continue; - } qDebug() << "oldValue:" << oldValue << "!= newValue:" << newValue; result.insert(role, newValue); } else {