Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
5.15
-
None
Description
Hi,
In the current implementation of timedatesettings, it is difficult to filter timezones.
(e.g., Just filtering out Asia + America or Asia + America + Europe etc).
The reason is that the filter is treated as a string,
and roles are compared with role.contains() a filter or not. That's not so flexible.
As a suggestion, can we modify m_filter to be a QRegularExpression?
The patchset is attached to this issue. And if the suggestion is acceptable, I'll create a patchset on Gerrit.
The API will remain the same for the most part (loosing out on case-insensitivity):
@@ -67,7 +67,7 @@ bool TimezoneFilterModel::filterAcceptsRow( int source_row, const QModelIndex& s if (nameRole.isValid()) { QString name = nameRole.toString(); - if (name.contains(m_filter, Qt::CaseInsensitive)) { + if (name.contains(m_filter)) { ret = true; } } @@ -75,7 +75,7 @@ bool TimezoneFilterModel::filterAcceptsRow( int source_row, const QModelIndex& s if (ret == false && countryRole.isValid()) { QString country = countryRole.toString(); - if (country.contains(m_filter, Qt::CaseInsensitive)) { + if (country.contains(m_filter)) { ret = true; } }
The input and output can still be QStrings:
@@ -46,12 +46,12 @@ TimezoneFilterModel::~TimezoneFilterModel() QString TimezoneFilterModel::filter() const { - return m_filter; + return m_filter.pattern(); } void TimezoneFilterModel::setFilter(const QString& aFilter) { - m_filter = aFilter; + m_filter = QRegularExpression(aFilter);; emit filterChanged(); }