@@ -117,15 +117,20 @@ TimeZoneFilterModel::TimeZoneFilterModel(QObject *parent)
118bool TimeZoneFilterModel::filterAcceptsRow(int row, const QModelIndex &parentIndex) const
118bool TimeZoneFilterModel::filterAcceptsRow(int row, const QModelIndex &parentIndex) const
120− if (!sourceModel() || m_filter.isEmpty()) {
120+ if (!sourceModel()) {
121 return true;
121 return true;
124+ if (!m_filter.isEmpty()) { // filtering by freeform text input, cf setFilter(QString)
124− const QString city = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::City).toString();
125+ const QString city = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::City).toString();
125− const QString country = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::Country).toString();
126+ const QString country = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::Country).toString();
127− if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(country) != -1) {
128+ if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(country) != -1) {
128− return true;
129+ return true;
131+ } else if (!m_country.isEmpty()) { // filter by country code
132+ const QString countryCode = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::CountryCode).toString();
133+ return m_country.compare(countryCode, Qt::CaseInsensitive) == 0;
131 return false;
136 return false;
@@ -143,3 +148,17 @@ void TimeZoneFilterModel::setFilter(const QString &filter)
143 Q_EMIT filterChanged();
148 Q_EMIT filterChanged();
144 invalidate();
149 invalidate();
152+QString TimeZoneFilterModel::country() const
157+void TimeZoneFilterModel::setCountry(const QString &country)
159+ if (m_country == country)
162+ m_country = country;
163+ Q_EMIT countryChanged(country);