File: locationquery.cpp

package info (click to toggle)
kweathercore 25.04.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,064 kB
  • sloc: cpp: 3,507; xml: 681; sh: 8; makefile: 5
file content (28 lines) | stat: -rw-r--r-- 825 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * SPDX-FileCopyrightText: 2020-2021 Han Young <hanyoung@protonmail.com>
 *
 * SPDX-License-Identifier: LGPL-2.0-or-later
 */

#include <KWeatherCore/LocationQuery>
using namespace KWeatherCore;

//...

LocationQuery m_locationSource;

// find places called "Oslo"
m_locationSource.query("Oslo") connect(m_locationSource, &LocationQuery::queryFinished, [](const std::vector<LocationQueryResult> &result) {
    for (auto location : result) {
        qDebug() << location.toponymName();
    }
});
connect(m_locationSource, &LocationQuery::queryError, [] {
    qDebug() << "can't find this place";
});

m_locationSource.locate();
    connect(m_locationSource, &LocationQuery::located, 
            [](const LocationQueryResult &result){
    qDebug() << "your coordinate: " << result.latitude() << ", " << longitude();}
//...