File indexing completed on 2024-04-28 04:42:42

0001 /*
0002  * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com>
0003  * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
0004  *
0005  * SPDX-License-Identifier: LGPL-2.0-or-later
0006  */
0007 
0008 #pragma once
0009 #include <QMetaType>
0010 #include <QString>
0011 #include <kweathercore/kweathercore_export.h>
0012 #include <memory>
0013 #include <optional>
0014 namespace KWeatherCore
0015 {
0016 /**
0017  * @short Class represents location query result
0018  *
0019  * This is a class to hold general information about a location
0020  *
0021  * @see LocationQuery
0022  *
0023  * @author Han Young <hanyoung@protonmail.com>
0024  */
0025 class KWEATHERCORE_EXPORT LocationQueryResult
0026 {
0027     Q_GADGET
0028     Q_PROPERTY(qreal latitude READ latitude)
0029     Q_PROPERTY(qreal longitude READ longitude)
0030     Q_PROPERTY(QString toponymName READ toponymName)
0031     Q_PROPERTY(QString name READ name)
0032     Q_PROPERTY(QString countryCode READ countryCode)
0033     Q_PROPERTY(QString countryName READ countryName)
0034     Q_PROPERTY(QString geonameId READ geonameId)
0035 public:
0036     // for QMetaType
0037     LocationQueryResult();
0038     /**
0039      * LocationQueryResult construct location result with given data
0040      * @param latitude latitude
0041      * @param longitude longitude
0042      * @param toponymName toponym name of location, detailed
0043      * @param name display name, short
0044      * @param countryCode country code, follow no standard but should be unique
0045      * @param countryName country name
0046      * @param geonameId internal unique id
0047      * @param subdivision state, province, or other country subdivision, Follows ISO 3166-2
0048      */
0049     LocationQueryResult(double latitude,
0050                         double longitude,
0051                         QString toponymName = QString(),
0052                         QString name = QString(),
0053                         QString countryCode = QString(),
0054                         QString countryName = QString(),
0055                         QString geonameId = QString(),
0056                         std::optional<QString> subdivision = std::nullopt);
0057     LocationQueryResult(const LocationQueryResult &other);
0058     LocationQueryResult(LocationQueryResult &&other);
0059     ~LocationQueryResult();
0060     LocationQueryResult &operator=(const LocationQueryResult &other);
0061     LocationQueryResult &operator=(LocationQueryResult &&other);
0062     double latitude() const;
0063 
0064     double longitude() const;
0065     /**
0066      * toponym name of location, detailed
0067      */
0068     const QString &toponymName() const;
0069     /**
0070      * display name, short
0071      */
0072     const QString &name() const;
0073     /**
0074      * country code, follow no standard but should be unique
0075      */
0076     const QString &countryCode() const;
0077     /**
0078      * country name
0079      */
0080     const QString &countryName() const;
0081     /**
0082      * internal unique id
0083      */
0084     const QString &geonameId() const;
0085 
0086     /**
0087      * Country subdivision such as state, province, etc. Follows ISO 3166-2
0088      */
0089     const std::optional<QString> &subdivision() const;
0090 
0091 private:
0092     class LocationQueryResultPrivate;
0093     std::unique_ptr<LocationQueryResultPrivate> d;
0094 };
0095 }
0096 Q_DECLARE_METATYPE(KWeatherCore::LocationQueryResult)