summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--event_list.cpp8
-rw-r--r--tags.json14
2 files changed, 13 insertions, 9 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();
diff --git a/tags.json b/tags.json
index 978e44f..6d0c4c2 100644
--- a/tags.json
+++ b/tags.json
@@ -1,6 +1,6 @@
[
{
- "tag": "pass", "key": "p", "fields": [
+ "name": "pass", "key": "p", "fields": [
{ "name": "player", "type": "Text", "key": "p" },
{
"name": "type", "type": "Enum",
@@ -14,7 +14,7 @@
]
},
{
- "tag": "shot", "key": "s", "fields": [
+ "name": "shot", "key": "s", "fields": [
{ "name": "player", "type": "Text", "key": "p" },
{
"name": "outcome", "type": "Enum",
@@ -29,28 +29,28 @@
]
},
{
- "tag": "foul", "key": "f", "fields": [
+ "name": "foul", "key": "f", "fields": [
{ "name": "player", "type": "Text", "key": "p" },
{ "name": "opponent", "type": "Text", "key": "o" },
{ "name": "comment", "type": "TextArea", "key": "c" }
]
},
{
- "tag": "offside", "key": "o", "fields": [
+ "name": "offside", "key": "o", "fields": [
{ "name": "player", "type": "Text", "key": "p" },
{ "name": "comment", "type": "TextArea", "key": "c" }
]
},
{
- "tag": "assist", "key": "a", "fields": [
+ "name": "assist", "key": "a", "fields": [
{ "name": "player", "type": "Text", "key": "p" },
{ "name": "comment", "type": "TextArea", "key": "c" }
]
},
{
- "tag": "offense", "key": "O", "fields": []
+ "name": "offense", "key": "O", "fields": []
},
{
- "tag": "defense", "key": "D", "fields": []
+ "name": "defense", "key": "D", "fields": []
}
]