- - Select group -
- Group 1
- Group 2
- Group 3
- Create new group...
Proxy models are models that you can stack (many of them) on another model (like our group model) to filter them, sort them or process data in any way. For "Add buddy" window there are 2 proxy models on top on group model:
GroupsModel *groupComboModel = new GroupsModel(GroupCombo); QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(GroupCombo); sortModel->setSourceModel(groupComboModel); ActionsProxyModel *groupsProxyModel = new ActionsProxyModel(groupsModelBeforeActions, groupsModelAfterActions, GroupCombo); groupsProxyModel->setSourceModel(sortModel); GroupCombo->setModel(groupsProxyModel);
The most important part is that you can reuse these proxy models everywhere you want and you don't have to manually update this combobox when new groups are created ;) Models do everything for you.