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

AppMan: Let IntentModel and ApplicationModel support multiple layers of filtering/sorting

    XMLWordPrintable

Details

    Description

      Currently, this code behaves as expected:

      IntentModel {
          id: im1
          sourceModel: IntentServer
          sortFunction: function(li, ri) { return li.name < ri.name }
      }
      
      IntentModel {
          id: im2
          sourceModel: im1
      }
      
      Repeater {
          model: im2
          ...
      }
      

       

      However, it breaks if we add actual filtering/sorting to both IntentModels. This is because the current implementation of IntentModel assumes that its source is always IntentServer::instance():

      int IntentModel::indexOfIntent(Intent *intent)
      {
          int idx = IntentServer::instance()->indexOfIntent(intent);
          return idx != -1 ? mapFromSource(idx) : idx;
      }
      

       

      It should work if we remove that assumption:

      int IntentModel::indexOfIntent(Intent *intent)
      {
          int idx = -1;
          if (auto src = qobject_cast<IntentServer*>(sourceModel()) // Most likely
              idx = src->indexOfIntent(intent);
          else if (auto src = qobject_cast<IntentModel*>(sourceModel()) // Less likely
              idx = src->indexOfIntent(intent);
          return idx != -1 ? mapFromSource(idx) : idx;
      }
      

       

      Notes
      The QML tools currently don't recognize the IntentModel.sourceModel property, so that ought to be addressed too (see QTBUG-114755 )

      Attachments

        Issue Links

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

          Activity

            People

              rgriebl Robert Griebl
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes