Commit 7502ddf1 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

Update WeatherLocation on creation

This saves us some external update calls
parent d01a9334
Pipeline #77206 passed with stage
in 17 seconds
......@@ -18,7 +18,6 @@
WeatherForecastManager::WeatherForecastManager()
: m_model(new WeatherLocationListModel(this))
{
update();
}
WeatherForecastManager *WeatherForecastManager::inst()
......@@ -26,11 +25,3 @@ WeatherForecastManager *WeatherForecastManager::inst()
static WeatherForecastManager singleton;
return &singleton;
}
void WeatherForecastManager::update()
{
qDebug() << "update start";
auto &locations = m_model->locations();
for (auto location : locations) {
location->update();
}
}
......@@ -27,10 +27,6 @@ public:
{
return m_model;
}
signals:
void updated();
private slots:
void update();
private:
WeatherLocationListModel *m_model;
......
......@@ -40,6 +40,9 @@ WeatherLocation::WeatherLocation(QString locationId,
this->m_timer->start(60 - QDateTime::currentDateTime().currentMSecsSinceEpoch() % 60);
m_lastUpdated = forecast.createdTime();
update();
determineCurrentForecast();
connect(this, &WeatherLocation::selectedDayChanged, this, [this] {
......
......@@ -156,7 +156,6 @@ void WeatherLocationListModel::addLocation(const KWeatherCore::LocationQueryResu
// add location
auto *location = new WeatherLocation(locId, locName, QString(), lat, lon);
location->update();
insert(m_locations.size(), location);
}
......@@ -178,7 +177,6 @@ void WeatherLocationListModel::requestCurrentLocation()
void WeatherLocationListModel::addCurrentLocation(const KWeatherCore::LocationQueryResult &ret)
{
auto location = new WeatherLocation(ret.geonameId(), ret.toponymName(), QString(), ret.latitude(), ret.longitude());
location->update();
insert(0, location);
Q_EMIT successfullyCreatedDefault();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment