![]() |
WeatherApp v0.1
|
Public Member Functions | |
Weather () | |
Default Constructor. | |
Weather (QString unit) | |
Overloaded Constructor with default unit. More... | |
Weather (QString unit, QString lang) | |
Overloaded Constructor with default unit and language. More... | |
void | changeLanguage (QString lang) |
Change language of the API response. More... | |
void | changeUnit (QString unit) |
Change the current unit system. More... | |
QString | getTempUnit () |
Return the current unit selected. More... | |
int | getFromCity (QString city) |
Get data from a City Name. More... | |
int | getFromGeo (double lat, double lon) |
Get data from coordinates. More... | |
void | city2geo (QString city) |
QString | geo2city (double lat, double lon) |
Public Attributes | |
struct { | |
} | data |
Struct to match the JSON format. More... | |
Private Member Functions | |
int | sendAndDecode (QUrl url) |
send a request from URL and decode JSON response More... | |
QByteArray | get (QUrl url) |
https GET from URL More... | |
Private Attributes | |
QNetworkAccessManager | _networkManager |
Network Manager. | |
QString | _api = "api.openweathermap.org" |
API URL. | |
QString | _token = API_TOKEN |
API Token. | |
Weather::Weather | ( | QString | unit | ) |
Overloaded Constructor with default unit.
unit |
Definition at line 10 of file weather.cpp.
Weather::Weather | ( | QString | unit, |
QString | lang | ||
) |
Overloaded Constructor with default unit and language.
unit | |
lang |
Definition at line 11 of file weather.cpp.
void Weather::changeLanguage | ( | QString | lang | ) |
Change language of the API response.
lang |
Refer to API: https://openweathermap.org/current#multi
Definition at line 14 of file weather.cpp.
void Weather::changeUnit | ( | QString | unit | ) |
Change the current unit system.
unit |
Example:
Definition at line 15 of file weather.cpp.
void Weather::city2geo | ( | QString | city | ) |
city |
Definition at line 144 of file weather.cpp.
QString Weather::geo2city | ( | double | lat, |
double | lon | ||
) |
lat | |
lon |
Definition at line 151 of file weather.cpp.
|
private |
https GET from URL
url |
Definition at line 121 of file weather.cpp.
int Weather::getFromCity | ( | QString | city | ) |
Get data from a City Name.
city |
Status code:
1 : ok
0 : Empty response
-1 Error
Definition at line 28 of file weather.cpp.
int Weather::getFromGeo | ( | double | lat, |
double | lon | ||
) |
Get data from coordinates.
lat | |
lon |
1 : ok
0 : Empty response
-1 Error
Definition at line 41 of file weather.cpp.
QString Weather::getTempUnit | ( | ) |
Return the current unit selected.
Refer to API: https://openweathermap.org/current#data
Definition at line 16 of file weather.cpp.
|
private |
send a request from URL and decode JSON response
url |
Definition at line 52 of file weather.cpp.
struct { ... } Weather::data |
Struct to match the JSON format.