[weather] Use QHash for faster lookup

parent 5c7651ec
......@@ -165,9 +165,9 @@ QMap<QString, IonInterface::ConditionIcons> const& WetterComIon::nightIcons() co
return val;
}
QMap<QString, QString> WetterComIon::setupCommonConditionMappings() const
QHash<QString, QString> WetterComIon::setupCommonConditionMappings() const
{
QMap<QString, QString> conditionList;
QHash<QString, QString> conditionList;
conditionList.insert(QStringLiteral("1"), i18nc("weather condition", "few clouds"));
conditionList.insert(QStringLiteral("10"), i18nc("weather condition", "few clouds"));
conditionList.insert(QStringLiteral("2"), i18nc("weather condition", "cloudy"));
......@@ -217,33 +217,33 @@ QMap<QString, QString> WetterComIon::setupCommonConditionMappings() const
return conditionList;
}
QMap<QString, QString> WetterComIon::setupDayConditionMappings() const
QHash<QString, QString> WetterComIon::setupDayConditionMappings() const
{
QMap<QString, QString> conditionList = setupCommonConditionMappings();
QHash<QString, QString> conditionList = setupCommonConditionMappings();
conditionList.insert(QStringLiteral("0"), i18nc("weather condition", "sunny"));
return conditionList;
}
QMap<QString, QString> const& WetterComIon::dayConditions() const
QHash<QString, QString> const& WetterComIon::dayConditions() const
{
static QMap<QString, QString> const val = setupDayConditionMappings();
static QHash<QString, QString> const val = setupDayConditionMappings();
return val;
}
QMap<QString, QString> WetterComIon::setupNightConditionMappings() const
QHash<QString, QString> WetterComIon::setupNightConditionMappings() const
{
QMap<QString, QString> conditionList = setupCommonConditionMappings();
QHash<QString, QString> conditionList = setupCommonConditionMappings();
conditionList.insert(QStringLiteral("0"), i18nc("weather condition", "clear sky"));
return conditionList;
}
QMap<QString, QString> const& WetterComIon::nightConditions() const
QHash<QString, QString> const& WetterComIon::nightConditions() const
{
static QMap<QString, QString> const val = setupNightConditionMappings();
static QHash<QString, QString> const val = setupNightConditionMappings();
return val;
}
QString WetterComIon::getWeatherCondition(const QMap<QString, QString> &conditionList, const QString& condition) const
QString WetterComIon::getWeatherCondition(const QHash<QString, QString> &conditionList, const QString& condition) const
{
return conditionList[condition];
}
......
......@@ -127,17 +127,17 @@ private:
QMap<QString, ConditionIcons> setupCommonIconMappings() const;
QMap<QString, ConditionIcons> setupDayIconMappings() const;
QMap<QString, ConditionIcons> setupNightIconMappings() const;
QMap<QString, QString> setupCommonConditionMappings() const;
QMap<QString, QString> setupDayConditionMappings() const;
QMap<QString, QString> setupNightConditionMappings() const;
QHash<QString, QString> setupCommonConditionMappings() const;
QHash<QString, QString> setupDayConditionMappings() const;
QHash<QString, QString> setupNightConditionMappings() const;
// Retrieve the mapping from the wetter.com condition code to the respective icon / condition name
QMap<QString, ConditionIcons> const& nightIcons() const;
QMap<QString, ConditionIcons> const& dayIcons() const;
QMap<QString, QString> const& dayConditions() const;
QMap<QString, QString> const& nightConditions() const;
QHash<QString, QString> const& dayConditions() const;
QHash<QString, QString> const& nightConditions() const;
QString getWeatherCondition(const QMap<QString, QString> &conditionList, const QString& condition) const;
QString getWeatherCondition(const QHash<QString, QString> &conditionList, const QString& condition) const;
// Find place
void findPlace(const QString& place, const QString& source);
......
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