KWeatherCore

locationquery.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 "locationqueryresult.h"
10 #include <QObject>
11 #include <kweathercore/kweathercore_export.h>
12 class QNetworkReply;
13 namespace KWeatherCore
14 {
15 class LocationQueryPrivate;
16 /**
17  * @short Class locates current location and search locations by name
18  *
19  * This is a class that locates current location (GPS or IP) and search
20  * locations by name
21  * ## Usage example
22  *
23  * Example usage:
24  * @code
25  * #include <KWeatherCore/LocationQuery>
26  * using namespace KWeatherCore;
27  *
28  * //...
29  *
30  * LocationQuery m_locationSource;
31  *
32  * // find places called "Oslo"
33  * m_locationSource.query("Oslo")
34  * connect(m_locationSource, &LocationQuery::queryFinished,
35  * [](const std::vector<LocationQueryResult> &result)
36  * {
37  * for(auto location : result)
38  * {
39  * qDebug() << location.toponymName();
40  * }
41  * });
42  * connect(m_locationSource, &LocationQuery::queryError,
43  * []{qDebug() << "can't find this place";});
44  *
45  * m_locationSource.locate();
46  * connect(m_locationSource, &LocationQuery::located,
47  * [](const LocationQueryResult &result){qDebug() << "your coordinate: " <<
48  * result.latitude() << ", " << longitude();}
49  * //...
50  * @endcode
51  *
52  * @author Han Young <[email protected]>
53  */
54 class KWEATHERCORE_EXPORT LocationQuery : public QObject
55 {
56  Q_OBJECT
57 public:
58  /**
59  * LocationQuery
60  */
61  LocationQuery(QObject *parent = nullptr);
62  /**
63  * query query locations by name
64  * @param name name of location, not necessary in English
65  * @param number max numbers of query returned, the actual size could be
66  * less than @param number
67  */
68  void query(QString name, int number = 30);
69  /**
70  * locate current location
71  */
72  void locate();
73 Q_SIGNALS:
74  /**
75  * the name search has completed
76  */
77  void queryFinished(std::vector<LocationQueryResult> result);
78  /**
79  * current location has been determined
80  */
81  void located(const LocationQueryResult &result);
82  /**
83  * a error has encounted during query, network error or no result
84  * found
85  */
86  void queryError();
87 
88 private:
89  LocationQueryPrivate *d = nullptr;
90 };
91 }
Class represents location query result.
Class locates current location and search locations by name.
Definition: locationquery.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Oct 19 2021 23:05:29 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.