Commit e6e4beba authored by Volker Krause's avatar Volker Krause
Browse files

Move driving side label computation to C++

The driving side enum is a uint8_t, which QML apparently doesn't like and
we thus end up with arbitrary values there. As the "driving side changed"
flag is correct, and due to the way the driving side enum was queried we
ended up with "left" for any bogus value. That is however only wrong if
your native driving side is left as well.

FIXED-IN: 22.12.0
BUG: 461438
parent 56f746e8
Pipeline #263702 passed with stage
in 4 minutes and 46 seconds
......@@ -57,9 +57,7 @@ Kirigami.AbstractCard {
QQC2.Label {
width: topLayout.width
text: locationInfo.drivingSide == KItinerary.KnowledgeDb.DrivingSide.Right ?
i18n("People are driving on the right side.") :
i18n("People are driving on the left side.")
text: locationInfo.drivingSideLabel
visible: locationInfo.drivingSideDiffers
wrapMode: Text.WordWrap
......@@ -79,6 +79,16 @@ bool LocationInformation::drivingSideDiffers() const
return m_drivingSideDiffers;
QString LocationInformation::drivingSideLabel() const
switch (m_drivingSide) {
case KItinerary::KnowledgeDb::DrivingSide::Right: return i18n("People are driving on the right side.");
case KItinerary::KnowledgeDb::DrivingSide::Left: return i18n("People are driving on the left side.");
case KItinerary::KnowledgeDb::DrivingSide::Unknown: return {};
return {};
LocationInformation::PowerPlugCompatibility LocationInformation::powerPlugCompatibility() const
return m_powerPlugCompat;
......@@ -19,9 +19,14 @@ class LocationInformation
Q_PROPERTY(QString isoCode READ isoCode)
/** @warning Careful with using this in QML, this is an 8bit enum which QML doesn't seem to like
* and you might silently get arbitrary values instead.
Q_PROPERTY(KItinerary::KnowledgeDb::DrivingSide drivingSide READ drivingSide)
/** This indicates that the driving side information changed and needs to be displayed. */
Q_PROPERTY(bool drivingSideDiffers READ drivingSideDiffers)
/** Display label for the driving side information. */
Q_PROPERTY(QString drivingSideLabel READ drivingSideLabel STORED false)
Q_PROPERTY(PowerPlugCompatibility powerPlugCompatibility READ powerPlugCompatibility)
/** Plugs from the home country that will not fit. */
......@@ -54,6 +59,7 @@ public:
KItinerary::KnowledgeDb::DrivingSide drivingSide() const;
bool drivingSideDiffers() const;
QString drivingSideLabel() const;
PowerPlugCompatibility powerPlugCompatibility() const;
QString powerPlugTypes() const;
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