Commit 851ad00f authored by Volker Krause's avatar Volker Krause
Browse files

Inform about different currencies at the destination

This still misses proper currency names, inclusion in trip group summaries
and exchange rates, but it's at least shown in the right places in the
timeline already.
parent 323b3c8a
......@@ -67,6 +67,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "GBP",
"drivingSide": "Left",
"drivingSideDiffers": true,
"isoCode": "GB",
......@@ -149,6 +151,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
......
......@@ -67,6 +67,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "GBP",
"drivingSide": "Left",
"drivingSideDiffers": true,
"isoCode": "GB",
......@@ -149,6 +151,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
......
......@@ -318,6 +318,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": false,
"currencyName": "EUR",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "IT",
......
......@@ -101,6 +101,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
......
......@@ -94,6 +94,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
......
......@@ -284,6 +284,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": false,
"currencyName": "EUR",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "IT",
......@@ -482,6 +484,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
......@@ -639,6 +643,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
......@@ -769,6 +775,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
......
......@@ -191,6 +191,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
......@@ -348,6 +350,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "USD",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "US",
......@@ -478,6 +482,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
......
......@@ -143,6 +143,8 @@
"locationInformation": {
"@context": "http://schema.org",
"@type": "LocationInformation",
"currencyDiffers": true,
"currencyName": "CHF",
"drivingSide": "Right",
"drivingSideDiffers": false,
"isoCode": "CH",
......
......@@ -91,6 +91,15 @@ Kirigami.AbstractCard {
visible: locationInfo.timeZoneDiffers
wrapMode: Text.WordWrap
}
QQC2.Label {
width: topLayout.width
text: i18n("Currency: %1", locationInfo.currencyName)
color: Kirigami.Theme.neutralTextColor
visible: locationInfo.currencyDiffers
wrapMode: Text.WordWrap
}
}
}
......@@ -6,6 +6,7 @@
#include "locationinformation.h"
#include <KCountry>
#include <KLocalizedString>
#include <QDebug>
......@@ -20,8 +21,9 @@ bool LocationInformation::operator==(const LocationInformation& other) const
const auto dsEqual = m_drivingSide == other.m_drivingSide || m_drivingSide == KnowledgeDb::DrivingSide::Unknown || other.m_drivingSide == KnowledgeDb::DrivingSide::Unknown;
const auto ppEqual = (m_incompatPlugs == other.m_incompatPlugs && m_incompatSockets == other.m_incompatSockets)
|| m_powerPlugs == KnowledgeDb::Unknown || other.m_powerPlugs == KnowledgeDb::Unknown;
const auto currencyEqual = m_currency == other.m_currency || m_currency.isEmpty() || other.m_currency.isEmpty();
return dsEqual && ppEqual && !hasRelevantTimeZoneChange(other);
return dsEqual && ppEqual && !hasRelevantTimeZoneChange(other) && currencyEqual;
}
QString LocationInformation::isoCode() const
......@@ -45,6 +47,12 @@ void LocationInformation::setIsoCode(const QString& isoCode)
const auto countryRecord = KnowledgeDb::countryForId(id);
setDrivingSide(countryRecord.drivingSide);
setPowerPlugTypes(countryRecord.powerPlugTypes);
auto currency = KCountry::fromAlpha2(isoCode).currencyCode();
if (currency != m_currency && !m_currency.isEmpty() && !currency.isEmpty()) {
m_currencyDiffers = true;
}
m_currency = currency;
}
KnowledgeDb::DrivingSide LocationInformation::drivingSide() const
......@@ -179,3 +187,13 @@ int LocationInformation::timeZoneOffsetDelta() const
{
return m_timeZoneOffsetDelta;
}
bool LocationInformation::currencyDiffers() const
{
return m_currencyDiffers;
}
QString LocationInformation::currencyName() const
{
return m_currency;
}
......@@ -33,6 +33,9 @@ class LocationInformation
Q_PROPERTY(QString timeZoneName READ timeZoneName)
Q_PROPERTY(int timeZoneOffsetDelta READ timeZoneOffsetDelta)
Q_PROPERTY(bool currencyDiffers READ currencyDiffers)
Q_PROPERTY(QString currencyName READ currencyName)
public:
LocationInformation();
~LocationInformation();
......@@ -64,6 +67,9 @@ public:
QString timeZoneName() const;
int timeZoneOffsetDelta() const;
bool currencyDiffers() const;
QString currencyName() const;
private:
void setDrivingSide(KItinerary::KnowledgeDb::DrivingSide drivingSide);
void setPowerPlugTypes(KItinerary::KnowledgeDb::PowerPlugTypes powerPlugs);
......@@ -71,6 +77,7 @@ private:
QString m_isoCode;
QTimeZone m_timeZone;
QDateTime m_transitionTime;
QString m_currency;
KItinerary::KnowledgeDb::PowerPlugTypes m_powerPlugs = KItinerary::KnowledgeDb::Unknown;
KItinerary::KnowledgeDb::PowerPlugTypes m_incompatPlugs = KItinerary::KnowledgeDb::Unknown;
KItinerary::KnowledgeDb::PowerPlugTypes m_incompatSockets = KItinerary::KnowledgeDb::Unknown;
......@@ -78,6 +85,7 @@ private:
bool m_drivingSideDiffers = false;
PowerPlugCompatibility m_powerPlugCompat = FullyCompatible;
int m_timeZoneOffsetDelta = 0;
bool m_currencyDiffers = false;
};
Q_DECLARE_METATYPE(LocationInformation)
......
Markdown is supported
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