File indexing completed on 2024-10-27 04:20:49
0001 /* 0002 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #ifndef KPUBLICTRANSPORT_COVERAGEAREA_H 0008 #define KPUBLICTRANSPORT_COVERAGEAREA_H 0009 0010 #include "datatypes.h" 0011 #include <QStringList> 0012 0013 class QJsonObject; 0014 0015 namespace KPublicTransport { 0016 0017 class CoverageAreaPrivate; 0018 class Location; 0019 0020 /** Describes the area a specific KPublicTransport::Backend can provide information for. */ 0021 class KPUBLICTRANSPORT_EXPORT CoverageArea 0022 { 0023 KPUBLICTRANSPORT_GADGET(CoverageArea) 0024 public: 0025 /** Coverage quality as defined by the Transport API Repository format. */ 0026 enum Type { 0027 Realtime, 0028 Regular, 0029 Any 0030 }; 0031 Q_ENUM(Type) 0032 KPUBLICTRANSPORT_PROPERTY(Type, type, setType) 0033 0034 /** ISO 3166-1/2 codes of covered regions. 0035 * Note that actual coverage might be small (e.g. just a city inside the given region). 0036 */ 0037 KPUBLICTRANSPORT_PROPERTY(QStringList, regions, setRegions) 0038 0039 /** UIC company codes of operators covered by this backend. */ 0040 KPUBLICTRANSPORT_PROPERTY(QStringList, uicCompanyCodes, setUicCompanyCodes) 0041 /** VDV organization ids of operators covered by this backend. */ 0042 KPUBLICTRANSPORT_PROPERTY(QStringList, vdvOrganizationIds, setVdvOrganizationIds) 0043 0044 public: 0045 /** Checks whether this coverage area is empty. 0046 * coversLocation() would always return @p false for empty areas. 0047 */ 0048 bool isEmpty() const; 0049 0050 /** Returns @c true if this area covers the entire world. */ 0051 bool isGlobal() const; 0052 0053 /** Checks whether @p loc is covered by this area. */ 0054 bool coversLocation(const Location &loc) const; 0055 0056 /** Checks whether this includes the entire country @p country. */ 0057 bool hasNationWideCoverage(const QString &country) const; 0058 0059 /** Read a single coverage area information from a JSON object 0060 * in Transport API Repository format. 0061 */ 0062 static CoverageArea fromJson(const QJsonObject &obj); 0063 }; 0064 0065 } 0066 0067 #endif // KPUBLICTRANSPORT_COVERAGEAREA_H