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_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 class AirportPrivate;
100 
101 /** Airport.
102  * @see https://schema.org/Airport.
103  */
104 class KITINERARY_EXPORT Airport : public Place
105 {
106  KITINERARY_GADGET(Airport)
107  KITINERARY_PROPERTY(QString, iataCode, setIataCode)
108 };
109 
110 class BoatTerminalPrivate;
111 
112 /** Boat or ferry terminal.
113  * @see https://schema.org/BoatTerminal
114  */
115 class KITINERARY_EXPORT BoatTerminal : public Place
116 {
117  KITINERARY_GADGET(BoatTerminal)
118 };
119 
120 class TrainStationPrivate;
121 
122 /** Train station.
123  * @see https://schema.org/TrainStation
124  */
125 class KITINERARY_EXPORT TrainStation : public Place
126 {
127  KITINERARY_GADGET(TrainStation)
128 };
129 
130 class BusStationPrivate;
131 
132 /** Bus station.
133  * @see https://schema.org/BusStation
134  */
135 class KITINERARY_EXPORT BusStation : public Place
136 {
137  KITINERARY_GADGET(BusStation)
138 };
139 
140 class TouristAttractionPrivate;
141 
142 /** Tourist attraction (e.g. Museum, sight, etc.).
143  * @see https://schema.org/TouristAttraction
144  */
145 class KITINERARY_EXPORT TouristAttraction : public Place
146 {
147  KITINERARY_GADGET(TouristAttraction)
148 };
149 
150 }
151 
152 Q_DECLARE_METATYPE(KItinerary::Place)
153 Q_DECLARE_METATYPE(KItinerary::GeoCoordinates)
154 Q_DECLARE_METATYPE(KItinerary::PostalAddress)
155 Q_DECLARE_METATYPE(KItinerary::Airport)
156 Q_DECLARE_METATYPE(KItinerary::BoatTerminal)
157 Q_DECLARE_METATYPE(KItinerary::TrainStation)
158 Q_DECLARE_METATYPE(KItinerary::BusStation)
159 Q_DECLARE_METATYPE(KItinerary::TouristAttraction)
160 
Boat or ferry terminal.
Definition: place.h:115
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:125
Bus station.
Definition: place.h:135
Airport.
Definition: place.h:104
Tourist attraction (e.g.
Definition: place.h:145
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Sep 27 2023 03:54:49 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.