weather-setup: rename weather_loc struct members

Origin commit data
------------------
Commit: 7647f4a843
Author: vanhofen <vanhofen@gmx.de>
Date: 2022-01-18 (Tue, 18 Jan 2022)

Origin message was:
------------------
- weather-setup: rename weather_loc struct members
This commit is contained in:
vanhofen
2022-01-18 23:47:16 +01:00
parent 1a4d0aeb96
commit 5fe803f27d
2 changed files with 11 additions and 9 deletions

View File

@@ -121,8 +121,8 @@ int CWeatherSetup::showSelectWeatherLocation()
CMenuForwarder *mf; CMenuForwarder *mf;
for (size_t i = 0; i < locations.size(); i++) for (size_t i = 0; i < locations.size(); i++)
{ {
mf = new CMenuForwarder(locations[i].key, true, NULL, selector, to_string(i).c_str()); mf = new CMenuForwarder(locations[i].city, true, NULL, selector, to_string(i).c_str());
mf->setHint(NEUTRINO_ICON_HINT_SETTINGS, locations[i].value.c_str()); mf->setHint(NEUTRINO_ICON_HINT_SETTINGS, locations[i].coords.c_str());
m->addItem(mf); m->addItem(mf);
} }
@@ -135,8 +135,8 @@ int CWeatherSetup::showSelectWeatherLocation()
delete selector; delete selector;
} }
g_settings.weather_location = locations[select].value; g_settings.weather_location = locations[select].coords;
g_settings.weather_city = std::string(locations[select].key); g_settings.weather_city = std::string(locations[select].city);
CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city); CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city);
return res; return res;
@@ -175,13 +175,14 @@ void CWeatherSetup::loadLocations(std::string filename)
{ {
while ((xmlGetNextOccurence(l1, "location"))) while ((xmlGetNextOccurence(l1, "location")))
{ {
//const char *country = xmlGetAttribute(l1, "country"); const char *country = xmlGetAttribute(l1, "country");
const char *city = xmlGetAttribute(l1, "city"); const char *city = xmlGetAttribute(l1, "city");
const char *latitude = xmlGetAttribute(l1, "latitude"); const char *latitude = xmlGetAttribute(l1, "latitude");
const char *longitude = xmlGetAttribute(l1, "longitude"); const char *longitude = xmlGetAttribute(l1, "longitude");
weather_loc loc; weather_loc loc;
loc.key = strdup(city); loc.country = strdup(country);
loc.value = std::string(latitude) + "," + std::string(longitude); loc.city = strdup(city);
loc.coords = std::string(latitude) + "," + std::string(longitude);
locations.push_back(loc); locations.push_back(loc);
l1 = xmlNextNode(l1); l1 = xmlNextNode(l1);
} }

View File

@@ -31,8 +31,9 @@ class CWeatherSetup : public CMenuTarget, CChangeObserver
private: private:
struct weather_loc struct weather_loc
{ {
char *key; char *country;
std::string value; char *city;
std::string coords;
}; };
std::vector<weather_loc> locations; std::vector<weather_loc> locations;