Purpose of QItemSelectionModel::Current and "two layer" selection approach in QItemSelectionModel

  • Hi,

    I'm wondering if anyone has insight into the purpose of QItemSelectionModel::Current and the "two layer approach to selection management" in QItemSelectionModel (quote taken from the standard docs on QItemSelectionModel class)?

    From what I can tell, the difference between the current and committed selection is not exposed at all in the public interface of QItemSelectionModel, so views (i.e. subclasses of QAbstractItemView) cannot leverage this information.

    So the only way for a developer to get at the difference between the current and committed selection and do something with it is to subclass QItemSelectionModel. This also means that all the current Qt provided QAbstractItemView subsclasses (QTreeView, ...) could just be rewritten to not use QItemSelectionModel::Current at all and there would be no noticeable difference as long as every use of these views used a standard QItemSelectionModel as their selection model.

    Also, I imagined that a view would use QItemSelectionModel::Current when it wanted to communicate to its selection model that the selection it was setting was somehow transient, but that the selection would be finalized ('committed') once the user was done with their current 'operation' that was creating this selection.

    For example, if the user was performing a rubber-band select in a QTreeView I expected the selection to be set with QItemSelectionModel::Current while the selection was happening (i.e. while the user was dragging their mouse across the items), but then on mouse-up the selection would be committed by the QTreeView by removing the items from the current selection and then adding them to the committed selection. But this isn't entirely the case (nothing happens on mouse up to commit the selection, so the items just stay in the current selection).

    Am I missing some core information related to the purpose of QItemSelectionModel::Current? Or has anyone found a good, consistent use with the difference between the 'current' and 'committed' selection in QItemSelectionModel?

    Thanks for your time!

Log in to reply