Commit 79efe85b authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇 Committed by Volker Krause
Browse files

[Statistics] Allow to show names of visited countries

I suck at geography and flags, allow showing the names of the countries.
parent 23528e9b
......@@ -14,6 +14,7 @@ import "." as App
RowLayout {
id: root
property var statItem
property alias label: labelItem
Kirigami.FormData.label: root.statItem.label
Layout.fillWidth: true
......@@ -27,6 +28,7 @@ RowLayout {
}
QQC2.Label {
id: labelItem
Layout.fillWidth: true
text: root.statItem.value
wrapMode: Text.Wrap
......
......@@ -47,7 +47,36 @@ Kirigami.ScrollablePage {
StatisticsDelegate { statItem: model.totalDistance }
StatisticsDelegate { statItem: model.totalNights }
StatisticsDelegate { statItem: model.totalCO2 }
StatisticsDelegate { statItem: model.visitedCountries }
StatisticsDelegate {
statItem: model.visitedCountries
label.text: model.visitedCountries.value.split(" ").map(countryCode => Localizer.countryFlag(countryCode)).join(" ")
visible: !countryDetailsLink.checked
}
ColumnLayout {
Kirigami.FormData.label: model.visitedCountries.label
Kirigami.FormData.labelAlignment: Qt.AlignTop
visible: countryDetailsRepeater.count > 0
Repeater {
id: countryDetailsRepeater
model: countryDetailsLink.checked ? model.visitedCountries.value.split(" ") : []
QQC2.Label {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: Localizer.countryFlag(modelData) + " " + Localizer.countryName(modelData);
}
}
}
Kirigami.LinkButton {
id: countryDetailsLink
property bool checked: false
text: checked ? i18nc("@action", "Hide Names") : i18nc("@action", "Show Names")
onClicked: checked = !checked
}
Kirigami.Separator {
Kirigami.FormData.isSection: true
......
......@@ -116,7 +116,7 @@ StatisticsItem StatisticsModel::visitedCountries() const
QStringList l;
l.reserve(m_countries.size());
std::transform(m_countries.begin(), m_countries.end(), std::back_inserter(l), [](const auto &iso) {
return Localizer().countryFlag(iso);
return iso;
});
return StatisticsItem(i18n("Visited countries"), l.join(QLatin1Char(' ')), StatisticsItem::TrendUnknown);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment