[weather] Use range-based for loops

parent 971134a4
......@@ -281,7 +281,7 @@ bool UKMETIon::updateIonSource(const QString& source)
// Gets specific city XML data
void UKMETIon::getXMLData(const QString& source)
{
foreach (const QString &fetching, m_obsJobList) {
for (const QString& fetching : qAsConst(m_obsJobList)) {
if (fetching == source) {
// already getting this source and awaiting the data
return;
......@@ -354,9 +354,9 @@ void UKMETIon::readSearchHTMLData(const QString& source, const QByteArray& html)
QJsonObject jsonDocumentObject = QJsonDocument::fromJson(html).object();
if (!jsonDocumentObject.isEmpty()) {
QJsonArray results = jsonDocumentObject.value(QStringLiteral("results")).toArray();
const QJsonArray results = jsonDocumentObject.value(QStringLiteral("results")).toArray();
foreach(const QJsonValue & resultValue, results) {
for (const QJsonValue& resultValue : results) {
QJsonObject result = resultValue.toObject();
const QString id = result.value(QStringLiteral("id")).toString();
const QString fullName = result.value(QStringLiteral("fullName")).toString();
......@@ -827,7 +827,7 @@ void UKMETIon::validate(const QString& source)
}
QString placeList;
foreach(const QString &place, m_locations) {
for (const QString& place : qAsConst(m_locations)) {
const QString p = place.section(QLatin1Char('|'), 1, 1);
placeList.append(QStringLiteral("|place|") + p + QStringLiteral("|extra|") + m_place[place].XMLurl);
}
......@@ -933,7 +933,7 @@ void UKMETIon::updateWeather(const QString& source)
data.insert(QStringLiteral("Total Weather Days"), forecasts.size());
int i = 0;
foreach(const WeatherData::ForecastInfo *forecastInfo, forecasts) {
for (const WeatherData::ForecastInfo* forecastInfo : forecasts) {
QString period = forecastInfo->period;
period.replace(QStringLiteral("Saturday"), i18nc("Short for Saturday", "Sat"));
period.replace(QStringLiteral("Sunday"), i18nc("Short for Sunday", "Sun"));
......
......@@ -525,7 +525,7 @@ void EnvCanadaIon::getXMLSetup()
// Gets specific city XML data
void EnvCanadaIon::getXMLData(const QString& source)
{
foreach (const QString& fetching, m_jobList) {
for (const QString& fetching : qAsConst(m_jobList)) {
if (fetching == source) {
// already getting this source and awaiting the data
return;
......@@ -1536,7 +1536,7 @@ void EnvCanadaIon::updateWeather(const QString& source)
data.insert(QStringLiteral("Total Weather Days"), forecasts.size());
int i = 0;
foreach(const WeatherData::ForecastInfo *forecastInfo, forecasts) {
for (const WeatherData::ForecastInfo* forecastInfo : forecasts) {
QString forecastPeriod = forecastInfo->forecastPeriod;
if (forecastPeriod.isEmpty()) {
......
......@@ -192,7 +192,7 @@ void NOAAIon::getXMLSetup() const
// Gets specific city XML data
void NOAAIon::getXMLData(const QString& source)
{
foreach (const QString &fetching, m_jobList) {
for (const QString& fetching : qAsConst(m_jobList)) {
if (fetching == source) {
// already getting this source and awaiting the data
return;
......@@ -265,7 +265,7 @@ void NOAAIon::setup_slotJobFinished(KJob *job)
const bool success = readXMLSetup();
setInitialized(success);
foreach (const QString &source, m_sourcesToReset) {
for (const QString& source : qAsConst(m_sourcesToReset)) {
updateSourceEvent(source);
}
}
......@@ -604,7 +604,7 @@ void NOAAIon::updateWeather(const QString& source)
data.insert(QStringLiteral("Total Weather Days"), weatherData.forecasts.size());
int i = 0;
foreach(const WeatherData::Forecast &forecast, weatherData.forecasts) {
for (const WeatherData::Forecast& forecast : weatherData.forecasts) {
ConditionIcons icon = getConditionIcon(forecast.summary.toLower(), true);
QString iconName = getWeatherIcon(icon);
......
......@@ -431,7 +431,7 @@ void WetterComIon::validate(const QString& source, bool parseError)
}
QString placeList;
foreach(const QString &place, m_locations) {
for (const QString& place : qAsConst(m_locations)) {
// Extra data format: placeCode;displayName
placeList.append(QLatin1String("|place|") + place + QLatin1String("|extra|") +
m_place[place].placeCode + QLatin1Char(';') + m_place[place].displayName);
......@@ -458,7 +458,7 @@ void WetterComIon::validate(const QString& source, bool parseError)
void WetterComIon::fetchForecast(const QString& source)
{
foreach (const QString &fetching, m_forecastJobList) {
for (const QString& fetching : qAsConst(m_forecastJobList)) {
if (fetching == source) {
// already fetching!
return;
......@@ -701,7 +701,7 @@ void WetterComIon::updateWeather(const QString& source, bool parseError)
data.insert(QStringLiteral("Temperature Unit"), KUnitConversion::Celsius);
int i = 0;
foreach(WeatherData::ForecastPeriod * forecastPeriod, weatherData.forecasts) {
for (const WeatherData::ForecastPeriod* forecastPeriod : weatherData.forecasts) {
if (i > 0) {
WeatherData::ForecastInfo weather = forecastPeriod->getWeather();
......@@ -803,7 +803,7 @@ WeatherData::ForecastInfo WeatherData::ForecastPeriod::getWeather() const
int WeatherData::ForecastPeriod::getMaxTemp(const QVector<WeatherData::ForecastInfo*>& forecastInfos) const
{
int result = -273;
foreach(const WeatherData::ForecastInfo * forecast, forecastInfos) {
for (const WeatherData::ForecastInfo* forecast : forecastInfos) {
result = std::max(result, forecast->tempHigh);
}
......@@ -813,7 +813,7 @@ int WeatherData::ForecastPeriod::getMaxTemp(const QVector<WeatherData::ForecastI
int WeatherData::ForecastPeriod::getMinTemp(const QVector<WeatherData::ForecastInfo*>& forecastInfos) const
{
int result = 100;
foreach(const WeatherData::ForecastInfo * forecast, forecastInfos) {
for (const WeatherData::ForecastInfo* forecast : forecastInfos) {
result = std::min(result, forecast->tempLow);
}
......
......@@ -61,7 +61,8 @@ void WeatherEngine::updateIonList(const QStringList &changedResources)
{
if (changedResources.isEmpty() || changedResources.contains(QStringLiteral("services"))) {
removeAllData(QStringLiteral("ions"));
foreach (const KPluginInfo &info, Plasma::PluginLoader::self()->listEngineInfo(QStringLiteral("weatherengine"))) {
const auto infos = Plasma::PluginLoader::self()->listEngineInfo(QStringLiteral("weatherengine"));
for (const KPluginInfo& info : infos) {
const QString data = info.name() + QLatin1Char('|') + info.pluginName();
setData(QStringLiteral("ions"), info.pluginName(), data);
}
......
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