File indexing completed on 2024-05-12 04:42:42

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #ifndef KPUBLICTRANSPORT_ATTRIBUTION_H
0008 #define KPUBLICTRANSPORT_ATTRIBUTION_H
0009 
0010 #include "kpublictransport_export.h"
0011 #include "datatypes.h"
0012 
0013 #include <vector>
0014 
0015 class QJsonArray;
0016 class QJsonObject;
0017 class QString;
0018 class QUrl;
0019 
0020 namespace KPublicTransport {
0021 
0022 class AttributionPrivate;
0023 
0024 /** Copyright and license information about the provided data.
0025  *  Should be displayed by the application in order to comply with licenses and/or terms and conditions
0026  *  of the data providers.
0027  */
0028 class KPUBLICTRANSPORT_EXPORT Attribution
0029 {
0030     KPUBLICTRANSPORT_GADGET(Attribution)
0031     /** Name of the entity providing the data. */
0032     KPUBLICTRANSPORT_PROPERTY(QString, name, setName)
0033     /** Link to the entity providing the data. */
0034     KPUBLICTRANSPORT_PROPERTY(QUrl, url, setUrl)
0035     /** Name of the license for the provided data. */
0036     KPUBLICTRANSPORT_PROPERTY(QString, license, setLicense)
0037     /** Link to the license or terms and conditions text. */
0038     KPUBLICTRANSPORT_PROPERTY(QUrl, licenseUrl, setLicenseUrl)
0039 
0040     /** @c true if there is license information for this attribution object. */
0041     Q_PROPERTY(bool hasLicense READ hasLicense STORED false)
0042 
0043 public:
0044     /** Returns @c true if this is an empty or default-constructed Attribution object. */
0045     bool isEmpty() const;
0046 
0047     bool hasLicense() const;
0048 
0049     /** Serializes one Attribution object to JSON. */
0050     static QJsonObject toJson(const Attribution &attr);
0051     /** Serializes an array of Attribution objects to JSON. */
0052     static QJsonArray toJson(const std::vector<Attribution> &attrs);
0053     /** Deserialize an Attribution object from JSON. */
0054     static Attribution fromJson(const QJsonObject &obj);
0055     /** Dezerializes an array of Attribution objects from JSON. */
0056     static std::vector<Attribution> fromJson(const QJsonArray &a);
0057 };
0058 
0059 }
0060 
0061 Q_DECLARE_METATYPE(KPublicTransport::Attribution)
0062 
0063 #endif // KPUBLICTRANSPORT_ATTRIBUTION_H