One option could be to wrap the QItemSelectionModel into a QAbstractListModel. This way the model would operate on the selected indexes only (whereas the proxy operates on the whole source model).
One option could be to wrap the QItemSelectionModel into a QAbstractListModel. This way the model would operate on the selected indexes only (whereas the proxy operates on the whole source model).
J-P Nurmi
Thanks a lot for your hint! Here is what I did, I created a class ProxyModel which extends QAbstractListModel and takes the source model and the item selection model as arguments. The proxy model contains the list of selected indexes from the source model. I connect the QItemSelectionModel::selectionChanged signal to a slot which updates the Proxy Model, ie. removes the indexes which were diselected and appends indexes which were selected. I also overwrite the data() method in the Proxy Model so that it returns data from the source model.
You can find a working implementation attached, there might be some additional checkings/optimizations to be done, but it shows the idea. Comments are welcome.
Bookmarks