diff --git a/src/publictransport/datatypes/location.cpp b/src/publictransport/datatypes/location.cpp index e51c92d..287db58 100644 --- a/src/publictransport/datatypes/location.cpp +++ b/src/publictransport/datatypes/location.cpp @@ -1,82 +1,95 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "location.h" #include "datatypes_p.h" +#include #include #include using namespace KPublicTransport; namespace KPublicTransport { class LocationPrivate : public QSharedData { public: QString name; float latitude = NAN; float longitude = NAN; QTimeZone timeZone; + QHash ids; }; } KPUBLICTRANSPORT_MAKE_GADGET(Location) QString Location::name() const { return d->name; } void Location::setName(const QString &name) { d.detach(); d->name = name; } float Location::latitude() const { return d->latitude; } float Location::longitude() const { return d->longitude; } void Location::setCoordinate(float latitude, float longitude) { d.detach(); d->latitude = latitude; d->longitude = longitude; } QTimeZone Location::timeZone() const { return d->timeZone; } void Location::setTimeZone(const QTimeZone &tz) { d.detach(); d->timeZone = tz; } +QString Location::identifier(const QString &identifierType) const +{ + return d->ids.value(identifierType); +} + +void Location::setIdentifier(const QString &identifierType, const QString &id) +{ + d.detach(); + d->ids.insert(identifierType, id); +} + #include "moc_location.cpp" diff --git a/src/publictransport/datatypes/location.h b/src/publictransport/datatypes/location.h index c754de2..5a55965 100644 --- a/src/publictransport/datatypes/location.h +++ b/src/publictransport/datatypes/location.h @@ -1,55 +1,59 @@ /* Copyright (C) 2018 Volker Krause This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #ifndef KPUBLICTRANSPORT_LOCATION_H #define KPUBLICTRANSPORT_LOCATION_H #include "datatypes.h" class QTimeZone; namespace KPublicTransport { class LocationPrivate; /** A location. */ class Location { KPUBLICTRANSPORT_GADGET(Location) /** Human-readable name of the location. */ Q_PROPERTY(QString name READ name WRITE setName) // TODO: type, coords, id, address public: QString name() const; void setName(const QString &name); float latitude() const; float longitude() const; void setCoordinate(float latitude, float longitude); /** The timezone this location is in, if known. */ QTimeZone timeZone() const; void setTimeZone(const QTimeZone &tz); + + /** Location identifiers. */ + QString identifier(const QString &identifierType) const; + void setIdentifier(const QString &identifierType, const QString &id); }; } Q_DECLARE_METATYPE(KPublicTransport::Location) #endif // KPUBLICTRANSPORT_LOCATION_H