@@ -117,15 +117,20 @@ TimeZoneFilterModel::TimeZoneFilterModel(QObject *parent)
117117
118118bool TimeZoneFilterModel::filterAcceptsRow(int row, const QModelIndex &parentIndex) const
119119{
120− if (!sourceModel() || m_filter.isEmpty()) {
120+ if (!sourceModel()) {
121121 return true;
122122 }
123123
124− 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();
124+ if (!m_filter.isEmpty()) { // filtering by freeform text input, cf setFilter(QString)
125+ const QString city = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::City).toString();
126+ const QString country = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::Country).toString();
126127
127− if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(country) != -1) {
128− return true;
128+ if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(country) != -1) {
129+ return true;
130+ }
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;
129134 }
130135
131136 return false;
@@ -143,3 +148,17 @@ void TimeZoneFilterModel::setFilter(const QString &filter)
143148 Q_EMIT filterChanged();
144149 invalidate();
145150}
151+
152+QString TimeZoneFilterModel::country() const
153+{
154+ return m_country;
155+}
156+
157+void TimeZoneFilterModel::setCountry(const QString &country)
158+{
159+ if (m_country == country)
160+ return;
161+
162+ m_country = country;
163+ Q_EMIT countryChanged(country);
164+}