diff --git a/src/datatypes/organization.cpp b/src/datatypes/organization.cpp index 3a6dbb9..cd73b8f 100644 --- a/src/datatypes/organization.cpp +++ b/src/datatypes/organization.cpp @@ -1,63 +1,75 @@ /* Copyright (C) 2018 Luca Beltrame 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 "organization.h" #include "datatypes_p.h" #include using namespace KItinerary; namespace KItinerary { class OrganizationPrivate: public QSharedData { KITINERARY_PRIVATE_BASE_GADGET(Organization) public: QString name; QString email; QString telephone; QUrl url; PostalAddress address; }; KITINERARY_MAKE_BASE_CLASS(Organization) KITINERARY_MAKE_PROPERTY(Organization, QString, name, setName) KITINERARY_MAKE_PROPERTY(Organization, QString, email, setEmail) KITINERARY_MAKE_PROPERTY(Organization, QString, telephone, setTelephone) KITINERARY_MAKE_PROPERTY(Organization, QUrl, url, setUrl) KITINERARY_MAKE_PROPERTY(Organization, PostalAddress, address, setAddress) class AirlinePrivate : public OrganizationPrivate { KITINERARY_PRIVATE_GADGET(Airline) public: QString iataCode; }; KITINERARY_MAKE_SUB_CLASS(Airline, Organization) KITINERARY_MAKE_PROPERTY(Airline, QString, iataCode, setIataCode) +class FoodEstablishmentPrivate: public OrganizationPrivate +{ + KITINERARY_PRIVATE_GADGET(FoodEstablishment) +}; +KITINERARY_MAKE_SUB_CLASS(FoodEstablishment, Organization) + +class LodgingBusinessPrivate : public OrganizationPrivate +{ + KITINERARY_PRIVATE_GADGET(LodgingBusiness) +}; +KITINERARY_MAKE_SUB_CLASS(LodgingBusiness, Organization) + } template <> KItinerary::OrganizationPrivate *QExplicitlySharedDataPointer::clone() { return d->clone(); } #include "moc_organization.cpp" diff --git a/src/datatypes/organization.h b/src/datatypes/organization.h index 73efe91..5e5069b 100644 --- a/src/datatypes/organization.h +++ b/src/datatypes/organization.h @@ -1,67 +1,85 @@ /* Copyright (C) 2018 Luca Beltrame 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 KITINERARY_ORGANIZATION_H #define KITINERARY_ORGANIZATION_H #include "kitinerary_export.h" #include "datatypes.h" #include "place.h" class QUrl; namespace KItinerary { class OrganizationPrivate; /** An organization * @see https://schema.org/Organization */ class KITINERARY_EXPORT Organization { KITINERARY_BASE_GADGET(Organization) KITINERARY_PROPERTY(QString, name, setName) KITINERARY_PROPERTY(QString, email, setEmail) KITINERARY_PROPERTY(QString, telephone, setTelephone) KITINERARY_PROPERTY(QUrl, url, setUrl) KITINERARY_PROPERTY(KItinerary::PostalAddress, address, setAddress) protected: ///@cond internal QExplicitlySharedDataPointer d; ///@endcond }; class AirlinePrivate; /** An airline. * @see https://schema.org/Airline */ class KITINERARY_EXPORT Airline : public Organization { KITINERARY_GADGET(Airline) KITINERARY_PROPERTY(QString, iataCode, setIataCode) }; +/** Hotel. + * @see https://schema.org/LodgingBusiness + */ +class KITINERARY_EXPORT LodgingBusiness: public Organization +{ + KITINERARY_GADGET(LodgingBusiness) +}; + +/** Food-related business (such as a restaurant, or a bakery). + * @see https://schema.org/FoodEstablishment + */ +class KITINERARY_EXPORT FoodEstablishment: public Organization +{ + KITINERARY_GADGET(FoodEstablishment) +}; + } // namespace KItinerary Q_DECLARE_METATYPE(KItinerary::Organization) Q_DECLARE_METATYPE(KItinerary::Airline) +Q_DECLARE_METATYPE(KItinerary::FoodEstablishment) +Q_DECLARE_METATYPE(KItinerary::LodgingBusiness) #endif // KITINERARY_ORGANIZATION_H diff --git a/src/datatypes/place.cpp b/src/datatypes/place.cpp index aba183a..8142e2a 100644 --- a/src/datatypes/place.cpp +++ b/src/datatypes/place.cpp @@ -1,133 +1,120 @@ /* 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 "place.h" #include "datatypes_p.h" #include using namespace KItinerary; namespace KItinerary { class GeoCoordinatesPrivate : public QSharedData { public: float latitude = NAN; float longitude = NAN; }; KITINERARY_MAKE_SIMPLE_CLASS(GeoCoordinates) KITINERARY_MAKE_PROPERTY(GeoCoordinates, float, latitude, setLatitude) KITINERARY_MAKE_PROPERTY(GeoCoordinates, float, longitude, setLongitude) bool GeoCoordinates::isValid() const { return !std::isnan(d->latitude) && !std::isnan(d->longitude); } class PostalAddressPrivate : public QSharedData { public: QString streetAddress; QString addressLocality; QString postalCode; QString addressRegion; QString addressCountry; }; KITINERARY_MAKE_SIMPLE_CLASS(PostalAddress) KITINERARY_MAKE_PROPERTY(PostalAddress, QString, streetAddress, setStreeAddress) KITINERARY_MAKE_PROPERTY(PostalAddress, QString, addressLocality, setAddressLocality) KITINERARY_MAKE_PROPERTY(PostalAddress, QString, postalCode, setPostalCode) KITINERARY_MAKE_PROPERTY(PostalAddress, QString, addressRegion, setAddressRegion) KITINERARY_MAKE_PROPERTY(PostalAddress, QString, addressCountry, setAddressCountry) bool PostalAddress::isEmpty() const { return d->streetAddress.isEmpty() && d->addressLocality.isEmpty() && d->postalCode.isEmpty() && d->addressRegion.isEmpty() && d->addressCountry.isEmpty(); } class PlacePrivate : public QSharedData { KITINERARY_PRIVATE_BASE_GADGET(Place) public: QString name; PostalAddress address; GeoCoordinates geo; }; KITINERARY_MAKE_BASE_CLASS(Place) KITINERARY_MAKE_PROPERTY(Place, QString, name, setName) KITINERARY_MAKE_PROPERTY(Place, PostalAddress, address, setAddress) KITINERARY_MAKE_PROPERTY(Place, GeoCoordinates, geo, setGeo) class AirportPrivate : public PlacePrivate { KITINERARY_PRIVATE_GADGET(Airport) public: QString iataCode; }; KITINERARY_MAKE_SUB_CLASS(Airport, Place) KITINERARY_MAKE_PROPERTY(Airport, QString, iataCode, setIataCode) class TrainStationPrivate : public PlacePrivate { KITINERARY_PRIVATE_GADGET(TrainStation) }; KITINERARY_MAKE_SUB_CLASS(TrainStation, Place) class BusStationPrivate : public PlacePrivate { KITINERARY_PRIVATE_GADGET(BusStation) }; KITINERARY_MAKE_SUB_CLASS(BusStation, Place) -class LodgingBusinessPrivate : public PlacePrivate -{ - KITINERARY_PRIVATE_GADGET(LodgingBusiness) -}; -KITINERARY_MAKE_SUB_CLASS(LodgingBusiness, Place) - -} class TouristAttractionPrivate: public PlacePrivate { KITINERARY_PRIVATE_GADGET(TouristAttraction) }; KITINERARY_MAKE_SUB_CLASS(TouristAttraction, Place) -class FoodEstablishmentPrivate: public PlacePrivate -{ - KITINERARY_PRIVATE_GADGET(FoodEstablishment) -}; -KITINERARY_MAKE_SUB_CLASS(FoodEstablishment, Place) - - +} template <> KItinerary::PlacePrivate *QExplicitlySharedDataPointer::clone() { return d->clone(); } #include "moc_place.cpp" diff --git a/src/datatypes/place.h b/src/datatypes/place.h index 785f23a..5477dfd 100644 --- a/src/datatypes/place.h +++ b/src/datatypes/place.h @@ -1,149 +1,133 @@ /* 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 KITINERARY_PLACE_H #define KITINERARY_PLACE_H #include "kitinerary_export.h" #include "datatypes.h" class QVariant; namespace KItinerary { class GeoCoordinatesPrivate; /** Geographic coordinates. * @see https://schema.org/GeoCoordinates */ class KITINERARY_EXPORT GeoCoordinates { KITINERARY_GADGET(GeoCoordinates) KITINERARY_PROPERTY(float, latitude, setLatitude) KITINERARY_PROPERTY(float, longitude, setLongitude) Q_PROPERTY(bool isValid READ isValid STORED false) public: /** Returns @c true if both latitude and longitude are set and within * the valid range. */ bool isValid() const; private: QExplicitlySharedDataPointer d; }; class PostalAddressPrivate; /** Postal address. * @see https://schema.org/PostalAddress */ class KITINERARY_EXPORT PostalAddress { KITINERARY_GADGET(PostalAddress) KITINERARY_PROPERTY(QString, streetAddress, setStreeAddress) KITINERARY_PROPERTY(QString, addressLocality, setAddressLocality) KITINERARY_PROPERTY(QString, postalCode, setPostalCode) KITINERARY_PROPERTY(QString, addressRegion, setAddressRegion) KITINERARY_PROPERTY(QString, addressCountry, setAddressCountry) Q_PROPERTY(bool isEmpty READ isEmpty STORED false) public: /** Returns @c true if there is no property set in this object. */ bool isEmpty() const; private: QExplicitlySharedDataPointer d; }; class PlacePrivate; /** Base class for places. * @see https://schema.org/Place */ class KITINERARY_EXPORT Place { KITINERARY_BASE_GADGET(Place) KITINERARY_PROPERTY(QString, name, setName) KITINERARY_PROPERTY(KItinerary::PostalAddress, address, setAddress) KITINERARY_PROPERTY(KItinerary::GeoCoordinates, geo, setGeo) protected: ///@cond internal QExplicitlySharedDataPointer d; ///@endcond }; /** Airport. * @see https://schema.org/Airport. */ class KITINERARY_EXPORT Airport : public Place { KITINERARY_GADGET(Airport) KITINERARY_PROPERTY(QString, iataCode, setIataCode) }; /** Train station. * @see https://schema.org/TrainStation */ class KITINERARY_EXPORT TrainStation : public Place { KITINERARY_GADGET(TrainStation) }; /** Bus station. * @see https://schema.org/BusStation */ class KITINERARY_EXPORT BusStation : public Place { KITINERARY_GADGET(BusStation) }; -/** Hotel. - * @see https://schema.org/LodgingBusiness - */ -class KITINERARY_EXPORT LodgingBusiness: public Place -{ - KITINERARY_GADGET(LodgingBusiness) -}; /** Tourist attraction (e.g. Museum, sight, etc.). * @see https://schema.org/TouristAttraction */ class KITINERARY_EXPORT TouristAttraction: public Place { KITINERARY_GADGET(TouristAttraction) }; -/** Food-related business (such as a restaurant, or a bakery). - * @see https://schema.org/FoodEstablishment - */ -class KITINERARY_EXPORT FoodEstablishment: public Place -{ - KITINERARY_GADGET(FoodEstablishment) -}; - } Q_DECLARE_METATYPE(KItinerary::GeoCoordinates) Q_DECLARE_METATYPE(KItinerary::PostalAddress) Q_DECLARE_METATYPE(KItinerary::Airport) Q_DECLARE_METATYPE(KItinerary::TrainStation) Q_DECLARE_METATYPE(KItinerary::BusStation) -Q_DECLARE_METATYPE(KItinerary::LodgingBusiness) Q_DECLARE_METATYPE(KItinerary::TouristAttraction) -Q_DECLARE_METATYPE(KItinerary::FoodEstablishment) + #endif // KITINERARY_PLACE_H