KWeatherCore

locationqueryresult.h
1 /*
2  * SPDX-FileCopyrightText: 2020-2021 Han Young <[email protected]>
3  * SPDX-FileCopyrightText: 2020 Devin Lin <[email protected]>
4  *
5  * SPDX-License-Identifier: LGPL-2.0-or-later
6  */
7 
8 #pragma once
9 #include <QMetaType>
10 #include <QString>
11 #include <kweathercore/kweathercore_export.h>
12 #include <memory>
13 #include <optional>
14 namespace KWeatherCore
15 {
16 /**
17  * @short Class represents location query result
18  *
19  * This is a class to hold general information about a location
20  *
21  * @see LocationQuery
22  *
23  * @author Han Young <[email protected]>
24  */
25 class KWEATHERCORE_EXPORT LocationQueryResult
26 {
27  Q_GADGET
28  Q_PROPERTY(qreal latitude READ latitude)
29  Q_PROPERTY(qreal longitude READ longitude)
30  Q_PROPERTY(QString toponymName READ toponymName)
31  Q_PROPERTY(QString name READ name)
32  Q_PROPERTY(QString countryCode READ countryCode)
33  Q_PROPERTY(QString countryName READ countryName)
34  Q_PROPERTY(QString geonameId READ geonameId)
35 public:
36  // for QMetaType
38  /**
39  * LocationQueryResult construct location result with given data
40  * @param latitude latitude
41  * @param longitude longitude
42  * @param toponymName toponym name of location, detailed
43  * @param name display name, short
44  * @param countryCode country code, follow no standard but should be unique
45  * @param countryName country name
46  * @param geonameId internal unique id
47  * @param subdivision state, province, or other country subdivision, Follows ISO 3166-2
48  */
49  LocationQueryResult(double latitude,
50  double longitude,
51  QString toponymName = QString(),
52  QString name = QString(),
53  QString countryCode = QString(),
54  QString countryName = QString(),
55  QString geonameId = QString(),
56  std::optional<QString> subdivision = std::nullopt);
60  LocationQueryResult &operator=(const LocationQueryResult &other);
61  LocationQueryResult &operator=(LocationQueryResult &&other);
62  double latitude() const;
63 
64  double longitude() const;
65  /**
66  * toponym name of location, detailed
67  */
68  const QString &toponymName() const;
69  /**
70  * display name, short
71  */
72  const QString &name() const;
73  /**
74  * country code, follow no standard but should be unique
75  */
76  const QString &countryCode() const;
77  /**
78  * country name
79  */
80  const QString &countryName() const;
81  /**
82  * internal unique id
83  */
84  const QString &geonameId() const;
85 
86  /**
87  * Country subdivision such as state, province, etc. Follows ISO 3166-2
88  */
89  const std::optional<QString> &subdivision() const;
90 
91 private:
92  class LocationQueryResultPrivate;
93  std::unique_ptr<LocationQueryResultPrivate> d;
94 };
95 }
96 Q_DECLARE_METATYPE(KWeatherCore::LocationQueryResult)
Class represents location query result.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Oct 21 2021 23:05:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.