oKcerG / SortFilterProxyModel

A nicely exposed QSortFilterProxyModel for QML
MIT License
303 stars 102 forks source link

Improvement: role filtering in Expression {} filter #31

Closed iberiozko closed 7 years ago

iberiozko commented 7 years ago

In general, when we are using Expression {} filter, the return value of the expression is determined by a fixed list of roles.

For example, a code looks like:

SortFilterProxyModel {
  id: brokenObjectsModel
  sourceModel: myControlledObjectsModel
  filtres: [
    ExprrssionFilter {
      expression: { return model.telemetry.status & 0b00110010 // some bitmask to detect broken objects
    }
  ]
}
SortFilterProxyModel {
  id: allActiveObjectsModel
  sourceModel: myControlledObjectsModel
  filtres: [
    ExprrssionFilter {
      expression: { return model.status.isActive }
      triggerOnRoles: [ 'status' ] // List only roles affecting the result of expression
    }
  ]
}

My suggestion is: for the allActiveObjectsModel the 'telemetry' role does never change the result of filtering. So, we really should not call the expression and waste cpu time on it.

Do not have a nice idea how to implement this, let it be a long-term issue.

iberiozko commented 7 years ago

This issue should be closed. Just was a bad idea.