Commit fd019caa authored by Stuart Dilts's avatar Stuart Dilts
Browse files

Show a location's State if it located in the U.S.

When adding a new location, show the location's state alongside the
city / country if the location is in the U.S.
parent 15ebb4f0
Pipeline #72957 passed with stage
in 17 seconds
......@@ -22,6 +22,14 @@ int LocationQueryModel::rowCount(const QModelIndex &parent) const
return m_results.size();
}
static QString buildResultName(const KWeatherCore::LocationQueryResult &result) {
const auto &countryCode = result.countryCode();
if(result.subdivision() && countryCode == "US") {
return result.toponymName() + ", " + *result.subdivision() + " | " + result.countryName();
}
return result.toponymName() + " | " + result.countryName();
}
QVariant LocationQueryModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
......@@ -30,7 +38,7 @@ QVariant LocationQueryModel::data(const QModelIndex &index, int role) const
auto result = m_results.at(index.row());
if (role == NameRole) {
return result.toponymName() + ", " + result.countryName();
return buildResultName(result);
}
return QVariant();
......
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