KItinerary

place.h
1 /*
2  SPDX-FileCopyrightText: 2018 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "kitinerary_export.h"
10 
11 #include "datatypes.h"
12 
13 #include <QUrl>
14 
15 namespace KItinerary {
16 
17 class GeoCoordinatesPrivate;
18 
19 /** Geographic coordinates.
20  * @see https://schema.org/GeoCoordinates
21  */
22 class KITINERARY_EXPORT GeoCoordinates
23 {
24  KITINERARY_GADGET(GeoCoordinates)
25  KITINERARY_PROPERTY(float, latitude, setLatitude)
26  KITINERARY_PROPERTY(float, longitude, setLongitude)
27 
28  Q_PROPERTY(bool isValid READ isValid STORED false)
29 public:
30  GeoCoordinates(float latitude, float longitude);
31 
32  /** Returns @c true if both latitude and longitude are set and within
33  * the valid range.
34  */
35  bool isValid() const;
36 private:
38 };
39 
40 class PostalAddressPrivate;
41 
42 /** Postal address.
43  * @see https://schema.org/PostalAddress
44  */
45 class KITINERARY_EXPORT PostalAddress
46 {
47  KITINERARY_GADGET(PostalAddress)
48  KITINERARY_PROPERTY(QString, streetAddress, setStreetAddress)
49  KITINERARY_PROPERTY(QString, addressLocality, setAddressLocality)
50  KITINERARY_PROPERTY(QString, postalCode, setPostalCode)
51  KITINERARY_PROPERTY(QString, addressRegion, setAddressRegion)
52  /** The country this address is in, as ISO 3166-1 alpha 2 code. */
53  KITINERARY_PROPERTY(QString, addressCountry, setAddressCountry)
54 
55  Q_PROPERTY(bool isEmpty READ isEmpty STORED false)
56 public:
57  /** Returns @c true if there is no property set in this object. */
58  bool isEmpty() const;
59 private:
60  QExplicitlySharedDataPointer<PostalAddressPrivate> d;
61 };
62 
63 class PlacePrivate;
64 
65 /** Base class for places.
66  * @see https://schema.org/Place
67  */
68 class KITINERARY_EXPORT Place
69 {
70  KITINERARY_BASE_GADGET(Place)
71  KITINERARY_PROPERTY(QString, name, setName)
72  KITINERARY_PROPERTY(KItinerary::PostalAddress, address, setAddress)
73  KITINERARY_PROPERTY(KItinerary::GeoCoordinates, geo, setGeo)
74  KITINERARY_PROPERTY(QString, telephone, setTelephone)
75  /** Identifier.
76  * We use the following schemas currently:
77  * - 'uic:', UIC station code (see https://www.wikidata.org/wiki/Property:P722)
78  * - 'sncf:', SNCF station id (see https://www.wikidata.org/wiki/Property:P8181), French train station identifier.
79  * - 'ibnr:', Internationale Bahnhofsnummer (see https://www.wikidata.org/wiki/Property:P954), German train station identifier.
80  * - 'ir:', Indian Railways station code (see https://www.wikidata.org/wiki/Property:P5696).
81  * - 'vrfi:', Finish railway station codes.
82  * - 'benerail:', Belgian railway station codes.
83  * @see http://schema.org/docs/datamodel.html#identifierBg
84  */
85  KITINERARY_PROPERTY(QString, identifier, setIdentifier)
86 
87  /** @see LocationUtil::geoUri() */
88  Q_PROPERTY(QUrl geoUri READ geoUri STORED false)
89 
90 public:
91  QUrl geoUri() const;
92 
93 protected:
94  ///@cond internal
95  QExplicitlySharedDataPointer<PlacePrivate> d;
96  ///@endcond
97 };
98 
99 /** Airport.
100  * @see https://schema.org/Airport.
101  */
102 class KITINERARY_EXPORT Airport : public Place
103 {
104  KITINERARY_GADGET(Airport)
105  KITINERARY_PROPERTY(QString, iataCode, setIataCode)
106 };
107 
108 /** Boat or ferry terminal.
109  * @see https://schema.org/BoatTerminal
110  */
111 class KITINERARY_EXPORT BoatTerminal : public Place
112 {
113  KITINERARY_GADGET(BoatTerminal)
114 };
115 
116 /** Train station.
117  * @see https://schema.org/TrainStation
118  */
119 class KITINERARY_EXPORT TrainStation : public Place
120 {
121  KITINERARY_GADGET(TrainStation)
122 };
123 
124 /** Bus station.
125  * @see https://schema.org/BusStation
126  */
127 class KITINERARY_EXPORT BusStation : public Place
128 {
129  KITINERARY_GADGET(BusStation)
130 };
131 
132 
133 /** Tourist attraction (e.g. Museum, sight, etc.).
134  * @see https://schema.org/TouristAttraction
135  */
136 class KITINERARY_EXPORT TouristAttraction : public Place
137 {
138  KITINERARY_GADGET(TouristAttraction)
139 };
140 
141 }
142 
143 Q_DECLARE_METATYPE(KItinerary::Place)
144 Q_DECLARE_METATYPE(KItinerary::GeoCoordinates)
145 Q_DECLARE_METATYPE(KItinerary::PostalAddress)
146 Q_DECLARE_METATYPE(KItinerary::Airport)
147 Q_DECLARE_METATYPE(KItinerary::BoatTerminal)
148 Q_DECLARE_METATYPE(KItinerary::TrainStation)
149 Q_DECLARE_METATYPE(KItinerary::BusStation)
150 Q_DECLARE_METATYPE(KItinerary::TouristAttraction)
151 
Boat or ferry terminal.
Definition: place.h:111
Base class for places.
Definition: place.h:68
Postal address.
Definition: place.h:45
Geographic coordinates.
Definition: place.h:22
Train station.
Definition: place.h:119
Bus station.
Definition: place.h:127
Airport.
Definition: place.h:102
Tourist attraction (e.g.
Definition: place.h:136
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Oct 6 2022 03:57:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.