diff options
| author | Timotej Lazar <timotej.lazar@araneo.si> | 2021-09-07 21:54:40 +0200 |
|---|---|---|
| committer | Timotej Lazar <timotej.lazar@araneo.si> | 2021-09-16 20:33:47 +0200 |
| commit | 1eee2fc2b5a50928c9583cc4c0ebdf520912c851 (patch) | |
| tree | 0dc015cdf1584d5b1700c06441ab9c9f24c5c99a /event_list.cpp | |
| parent | ff63d29adbbc4fb291dbcbdc14cc8c6701f2998a (diff) | |
Rename property "tag" to "name" in tag definitions
Diffstat (limited to 'event_list.cpp')
| -rw-r--r-- | event_list.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/event_list.cpp b/event_list.cpp index a1e88a5..31e7dd1 100644 --- a/event_list.cpp +++ b/event_list.cpp @@ -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(); |
