What class of Proxy Model should I pick in the case?
QAbstractItemModelwhere I embody tree data structure and I need a proxy model with List data structure.
I need to find suitable proxy model class to be able to
- Map Souce model index from Tree to Proxy Model index which converts tree index to List index.
- Filter data by criteria
- Sort data by criteria.
So far I do not understand if
QSortFilterProxyModelmeets this task and is it possible to reimplement
QSortFilterProxyModel::mapToSource(const QModelIndex & proxyIndex) constand
QSortFilterProxyModel::mapFromSource(const QModelIndex & sourceIndex) constand do I have t o reimplement this.
If you have experience with proxy models pls advice me.
actually in your case you need to reimplement the whole logic by yourself, since you want to merge different data sources and map tree structure to a list structure.
A QSortFitlerProxyModel is rather a 1:1 relation to the source model. So you need to subclass QAbstractProxyModel.
In indexes your model creates you can store an internal pointer to your internal data source which helps you identify the QModelIndex.
Shall I reimplement
mapSelectionToSource()in case of Converting tree to List?
Is it enough to impementat just index mapping methods?
I really spend so much time with Qt documentation. It is unclear.
mapFromSource() and mapToSource() are enough. The default implementation should depend on these methods only.