Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-81253

qtdeviceutilities/timedatesettings: Use regex in TimezoneFilterModel

    XMLWordPrintable

Details

    • All

    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();
       }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            teemu.holappa Teemu Holappa
            gvkalra Gaurav Kalra
            Veli-Pekka Heinonen Veli-Pekka Heinonen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes