Rename property "tag" to "name" in tag definitions

This commit is contained in:
Timotej Lazar 2021-09-07 21:54:40 +02:00
parent ff63d29adb
commit 1eee2fc2b5
No known key found for this signature in database
GPG key ID: B6F38793D143456F
2 changed files with 13 additions and 9 deletions

View file

@ -80,11 +80,15 @@ void EventList::load(const QJsonObject& json)
{
const auto& jsonTags = json["tags"].toArray();
if (!jsonTags.isEmpty()) {
// Map tag name to definition and remember tag order.
tags = {};
tagsOrder.clear();
for (int i = 0; i < jsonTags.size(); i++) {
const auto name = jsonTags[i]["tag"].toString();
tags[name] = jsonTags[i].toObject();
const auto& tag = jsonTags[i].toObject();
// Compatibility with older tag definitions.
const auto& nameKey = tag.contains("name") ? "name" : "tag";
const auto name = tag[nameKey].toString();
tags[name] = tag;
tagsOrder.append(name);
}
emit tagsChanged();