File indexing completed on 2025-02-02 05:02:31
0001 /* 0002 SPDX-FileCopyrightText: 2018 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef LOCATIONINFORMATION_H 0008 #define LOCATIONINFORMATION_H 0009 0010 #include <KItinerary/CountryDb> 0011 0012 #include <QMetaType> 0013 #include <QString> 0014 #include <QTimeZone> 0015 0016 /** Data for country information elements in the timeline model. */ 0017 class LocationInformation 0018 { 0019 Q_GADGET 0020 Q_PROPERTY(QString isoCode READ isoCode) 0021 0022 /** @warning Careful with using this in QML, this is an 8bit enum which QML doesn't seem to like 0023 * and you might silently get arbitrary values instead. 0024 */ 0025 Q_PROPERTY(KItinerary::KnowledgeDb::DrivingSide drivingSide READ drivingSide) 0026 /** This indicates that the driving side information changed and needs to be displayed. */ 0027 Q_PROPERTY(bool drivingSideDiffers READ drivingSideDiffers) 0028 /** Display label for the driving side information. */ 0029 Q_PROPERTY(QString drivingSideLabel READ drivingSideLabel STORED false) 0030 0031 Q_PROPERTY(PowerPlugCompatibility powerPlugCompatibility READ powerPlugCompatibility) 0032 /** Plugs from the home country that will not fit. */ 0033 Q_PROPERTY(QString powerPlugTypes READ powerPlugTypes) 0034 /** Sockets in the destination country that are incompatible with (some of) my plugs. */ 0035 Q_PROPERTY(QString powerSocketTypes READ powerSocketTypes) 0036 0037 Q_PROPERTY(bool timeZoneDiffers READ timeZoneDiffers) 0038 Q_PROPERTY(QString timeZoneName READ timeZoneName) 0039 Q_PROPERTY(int timeZoneOffsetDelta READ timeZoneOffsetDelta) 0040 0041 Q_PROPERTY(bool currencyDiffers READ currencyDiffers) 0042 Q_PROPERTY(QString currencyCode READ currencyCode) 0043 0044 public: 0045 LocationInformation(); 0046 ~LocationInformation(); 0047 0048 enum PowerPlugCompatibility { 0049 FullyCompatible, 0050 PartiallyCompatible, 0051 Incompatible 0052 }; 0053 Q_ENUM(PowerPlugCompatibility) 0054 0055 bool operator==(const LocationInformation &other) const; 0056 0057 QString isoCode() const; 0058 void setIsoCode(const QString &isoCode); 0059 0060 KItinerary::KnowledgeDb::DrivingSide drivingSide() const; 0061 bool drivingSideDiffers() const; 0062 QString drivingSideLabel() const; 0063 0064 PowerPlugCompatibility powerPlugCompatibility() const; 0065 QString powerPlugTypes() const; 0066 QString powerSocketTypes() const; 0067 0068 QTimeZone timeZone() const; 0069 QDateTime transitionTime() const; 0070 void setTimeZone(const QTimeZone &tz, const QDateTime &transitionTime); 0071 bool hasRelevantTimeZoneChange(const LocationInformation &other) const; 0072 bool timeZoneDiffers() const; 0073 QString timeZoneName() const; 0074 int timeZoneOffsetDelta() const; 0075 0076 bool currencyDiffers() const; 0077 QString currencyCode() const; 0078 0079 private: 0080 void setDrivingSide(KItinerary::KnowledgeDb::DrivingSide drivingSide); 0081 void setPowerPlugTypes(KItinerary::KnowledgeDb::PowerPlugTypes powerPlugs); 0082 0083 QString m_isoCode; 0084 QTimeZone m_timeZone; 0085 QDateTime m_transitionTime; 0086 QString m_currency; 0087 KItinerary::KnowledgeDb::PowerPlugTypes m_powerPlugs = KItinerary::KnowledgeDb::Unknown; 0088 KItinerary::KnowledgeDb::PowerPlugTypes m_incompatPlugs = KItinerary::KnowledgeDb::Unknown; 0089 KItinerary::KnowledgeDb::PowerPlugTypes m_incompatSockets = KItinerary::KnowledgeDb::Unknown; 0090 KItinerary::KnowledgeDb::DrivingSide m_drivingSide = KItinerary::KnowledgeDb::DrivingSide::Unknown; 0091 bool m_drivingSideDiffers = false; 0092 PowerPlugCompatibility m_powerPlugCompat = FullyCompatible; 0093 int m_timeZoneOffsetDelta = 0; 0094 bool m_currencyDiffers = false; 0095 }; 0096 0097 Q_DECLARE_METATYPE(LocationInformation) 0098 0099 #endif // LOCATIONINFORMATION_H