Kstars

locationdialoglite.h
1/*
2 SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
3 SPDX-License-Identifier: GPL-2.0-or-later
4*/
5
6#pragma once
7
8#include "dms.h"
9
10#include <QHash>
11#include <QSqlDatabase>
12#include <QStringListModel>
13
16class QNetworkSession;
17class QNetworkReply;
18
19class GeoLocation;
20
21/**
22 * @class LocationDialogLite
23 * A backend of location dialog declared in QML.
24 *
25 * @author Artem Fedoskin, Jason Harris
26 * @version 1.0
27 */
29{
31
32 Q_PROPERTY(QString currentLocation READ getCurrentLocation WRITE setCurrentLocation NOTIFY currentLocationChanged)
33 Q_PROPERTY(QStringList TZList MEMBER m_TZList NOTIFY TZListChanged)
34 Q_PROPERTY(QStringList DSTRules MEMBER m_DSTRules NOTIFY DSTRulesChanged)
35 Q_PROPERTY(int currLocIndex MEMBER m_currLocIndex NOTIFY currLocIndexChanged)
36 public:
37 typedef enum { CITY_ADD, CITY_UPDATE, CITY_REMOVE } CityOperation;
38
40
41 Q_INVOKABLE void filterCity(const QString &city, const QString &province, const QString &country);
42
43 void setCurrentLocation(const QString &loc);
44 QString getCurrentLocation() { return m_currentLocation; }
45 Q_INVOKABLE bool editCity(const QString &fullName, const QString &city, const QString &province,
46 const QString &country, const QString &latitude,
47 const QString &longitude, const QString &TimeZoneString, const QString &TZRule);
48
49 Q_INVOKABLE bool setLocation(const QString &fullName);
50
51 Q_INVOKABLE bool addCity(const QString &city, const QString &province, const QString &country,
52 const QString &latitude, const QString &longitude,
53 const QString &TimeZoneString, const QString &TZRule);
54 Q_INVOKABLE bool deleteCity(const QString &fullName);
55
56 Q_INVOKABLE bool isReadOnly(const QString &fullName);
57
58 Q_INVOKABLE QString getCity(const QString &fullName);
59 Q_INVOKABLE QString getProvince(const QString &fullName);
60 Q_INVOKABLE QString getCountry(const QString &fullName);
61 Q_INVOKABLE double getLatitude(const QString &fullName);
62 Q_INVOKABLE double getLongitude(const QString &fullName);
63 Q_INVOKABLE int getTZ(const QString &fullName);
64 Q_INVOKABLE int getDST(const QString &fullName);
65 Q_INVOKABLE bool isDuplicate(const QString &city, const QString &province, const QString &country);
66
67 /**
68 * @brief checkLongLat checks whether given longitude and latitude are valid
69 */
70 Q_INVOKABLE bool checkLongLat(const QString &longitude, const QString &latitude);
71
72 /**
73 * TODO - port dmsBox to QML
74 * @brief createDms creates dms from string
75 * @param degree string that should be converted to degree
76 * @param deg if true, the value is in degrees. Otherwise, it is in hours.
77 * @param ok
78 * @return angle in dms
79 */
80 dms createDms(const QString &degree, bool deg, bool *ok);
81
82 /**
83 * @short Retrieve name of location by latitude and longitude. Name will be sent with
84 * sendNameFromCoordinates signal
85 */
86 Q_INVOKABLE void getNameFromCoordinates(double latitude, double longitude);
87
88 public slots:
89 void initCityList();
90 void updateCurrentLocation();
91
92 void processLocationNameData(QNetworkReply *rep);
93
94 signals:
95 void currentLocationChanged(QString);
96 void TZListChanged(QStringList);
97 void DSTRulesChanged(QStringList);
98 void currLocIndexChanged(int);
99 void newNameFromCoordinates(QString city, QString region, QString country);
100
101 private:
102 /**
103 * @short checks whether database with cities is already created. Creates a new otherwise
104 * @return city database
105 */
106 QSqlDatabase getDB();
107
108 QStringListModel m_cityList;
109 QHash<QString, GeoLocation *> filteredCityList;
110 GeoLocation *SelectedCity { nullptr };
111 GeoLocation *currentGeo { nullptr };
112 QString m_currentLocation;
113 int m_currLocIndex { 0 };
114
115 QStringList m_TZList;
116 QStringList m_DSTRules;
117
118 //Retrieve the name of city
119 QNetworkAccessManager *nam { nullptr };
120};
Contains all relevant information for specifying a location on Earth: City Name, State/Province name,...
Definition geolocation.h:28
A backend of location dialog declared in QML.
Q_INVOKABLE bool checkLongLat(const QString &longitude, const QString &latitude)
checkLongLat checks whether given longitude and latitude are valid
dms createDms(const QString &degree, bool deg, bool *ok)
TODO - port dmsBox to QML.
Q_INVOKABLE void getNameFromCoordinates(double latitude, double longitude)
Retrieve name of location by latitude and longitude.
An angle, stored as degrees, but expressible in many ways.
Definition dms.h:38
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.