@@ -25,7 +25,7 @@
25TimeZoneModel::TimeZoneModel(QObject *parent)
25TimeZoneModel::TimeZoneModel(QObject *parent)
26 : QAbstractListModel(parent)
26 : QAbstractListModel(parent)
28− QMetaObject::invokeMethod(this, "init");
28+ init();
31QString TimeZoneModel::selectedZoneId() const
31QString TimeZoneModel::selectedZoneId() const
@@ -72,8 +72,10 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const
73 case Comment:
73 case Comment:
74 return tz.comment();
74 return tz.comment();
76+ return QDateTime::currentDateTime().toTimeZone(tz).toString("H:mm");
76− qWarning() << Q_FUNC_INFO << "Unsupported data role";
78+ qWarning() << Q_FUNC_INFO << "Unsupported data role" << role;
@@ -83,7 +85,7 @@ QVariant TimeZoneModel::data(const QModelIndex &index, int role) const
84QHash<int, QByteArray> TimeZoneModel::roleNames() const
86QHash<int, QByteArray> TimeZoneModel::roleNames() const
86− return {{IdRole, "id"}, {Abbreviation, "abbreviation"}, {Country, "country"}, {City, "city"}, {Comment, "comment"}};
88+ return {{IdRole, "id"}, {Abbreviation, "abbreviation"}, {Country, "country"}, {City, "city"}, {Comment, "comment"}, {Time, "time"}};
89void TimeZoneModel::init()
91void TimeZoneModel::init()
@@ -92,3 +94,39 @@ void TimeZoneModel::init()
92 m_zoneIds = QTimeZone::availableTimeZoneIds();
94 m_zoneIds = QTimeZone::availableTimeZoneIds();
93 endResetModel();
95 endResetModel();
99+TimeZoneFilterModel::TimeZoneFilterModel(QObject *parent)
100+ : QSortFilterProxyModel(parent)
102+ m_stringMatcher.setCaseSensitivity(Qt::CaseInsensitive);
105+bool TimeZoneFilterModel::filterAcceptsRow(int row, const QModelIndex &parentIndex) const
107+ if (!sourceModel() || m_filter.isEmpty()) {
111+ const QString city = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::City).toString();
112+ const QString country = sourceModel()->index(row, 0, parentIndex).data(TimeZoneModel::Country).toString();
114+ if (m_stringMatcher.indexIn(city) != -1 || m_stringMatcher.indexIn(country) != -1) {
121+QString TimeZoneFilterModel::filter() const
126+void TimeZoneFilterModel::setFilter(const QString &filter)
129+ m_stringMatcher.setPattern(m_filter);
130+ Q_EMIT filterChanged();