KWeatherCore

locationqueryresult.h
1/*
2 * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com>
3 * SPDX-FileCopyrightText: 2020 Devin Lin <espidev@gmail.com>
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>
14namespace 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 <hanyoung@protonmail.com>
24 */
25class 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)
35public:
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 geonameId internal unique id
46 * @param subdivision state, province, or other country subdivision, Follows ISO 3166-2
47 */
48 LocationQueryResult(double latitude,
49 double longitude,
50 QString toponymName = QString(),
51 QString name = QString(),
52 QString countryCode = QString(),
53 QString geonameId = QString(),
54 std::optional<QString> subdivision = std::nullopt);
58 LocationQueryResult &operator=(const LocationQueryResult &other);
59 LocationQueryResult &operator=(LocationQueryResult &&other) noexcept;
60 double latitude() const;
61
62 double longitude() const;
63 /**
64 * toponym name of location, detailed
65 */
66 const QString &toponymName() const;
67 /**
68 * display name, short
69 */
70 const QString &name() const;
71 /**
72 * country code, follow no standard but should be unique
73 */
74 const QString &countryCode() const;
75 /**
76 * Translated name of the country.
77 */
78 [[nodiscard]] QString countryName() const;
79 /**
80 * internal unique id
81 */
82 const QString &geonameId() const;
83
84 /**
85 * Country subdivision such as state, province, etc. Follows ISO 3166-2
86 */
87 const std::optional<QString> &subdivision() const;
88
89private:
90 class LocationQueryResultPrivate;
91 std::unique_ptr<LocationQueryResultPrivate> d;
92};
93}
94Q_DECLARE_METATYPE(KWeatherCore::LocationQueryResult)
Class represents location query result.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 12:02:06 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.