Wt 3.1.10
|
An abstract proxy model for Wt's item models. More...
#include <Wt/WAbstractProxyModel>
Classes | |
struct | BaseItem |
A base class for an item modeling a source index parent. More... | |
Public Member Functions | |
WAbstractProxyModel (WObject *parent=0) | |
Constructor. | |
virtual WModelIndex | mapFromSource (const WModelIndex &sourceIndex) const =0 |
Maps a source model index to the proxy model. | |
virtual WModelIndex | mapToSource (const WModelIndex &proxyIndex) const =0 |
Maps a proxy model index to the source model. | |
virtual void | setSourceModel (WAbstractItemModel *sourceModel) |
Sets the source model. | |
WAbstractItemModel * | sourceModel () const |
Returns the source model. | |
Protected Types | |
typedef std::map< WModelIndex, BaseItem * > | ItemMap |
A map for items. | |
Protected Member Functions | |
WModelIndex | createSourceIndex (int row, int column, void *ptr) const |
Create a source model index. | |
void | shiftModelIndexes (const WModelIndex &sourceParent, int start, int count, ItemMap &items) |
Utility methods to shift items in an item map. |
An abstract proxy model for Wt's item models.
A proxy model does not store data, but presents data from a source model in another way. It may provide filtering, sorting, or other computed changes to the source model. A proxy model may be a fully functional model, that also allows modification of the underlying model.
This abstract proxy model may be used as a starting point for implementing a custom proxy model, when WSortFilterProxyModel is not adequate. It implements data access and manipulation using the a virtual mapping method (mapToSource()) to access and manipulate the underlying sourceModel().
typedef std::map<WModelIndex, BaseItem *> Wt::WAbstractProxyModel::ItemMap [protected] |
A map for items.
WModelIndex Wt::WAbstractProxyModel::createSourceIndex | ( | int | row, |
int | column, | ||
void * | ptr | ||
) | const [protected] |
Create a source model index.
This is a utility function that allows you to create indexes in the source model. In this way, you can reuse the internal pointers of the source model in proxy model indexes, and convert a proxy model index back to the source model index using this method.
virtual WModelIndex Wt::WAbstractProxyModel::mapFromSource | ( | const WModelIndex & | sourceIndex | ) | const [pure virtual] |
Maps a source model index to the proxy model.
This method returns a model index in the proxy model that corresponds to the model index sourceIndex
in the source model. This method must only be implemented for source model indexes that are mapped and thus are the result of mapToSource().
Implemented in Wt::WAggregateProxyModel, Wt::WBatchEditProxyModel, and Wt::WSortFilterProxyModel.
virtual WModelIndex Wt::WAbstractProxyModel::mapToSource | ( | const WModelIndex & | proxyIndex | ) | const [pure virtual] |
Maps a proxy model index to the source model.
This method returns a model index in the source model that corresponds to the proxy model index proxyIndex
.
Implemented in Wt::WAggregateProxyModel, Wt::WBatchEditProxyModel, and Wt::WSortFilterProxyModel.
virtual void Wt::WAbstractProxyModel::setSourceModel | ( | WAbstractItemModel * | sourceModel | ) | [virtual] |
Sets the source model.
The source model provides the actual data for the proxy model.
Ownership of the source model is not transferred.
Reimplemented in Wt::WAggregateProxyModel, Wt::WBatchEditProxyModel, and Wt::WSortFilterProxyModel.
void Wt::WAbstractProxyModel::shiftModelIndexes | ( | const WModelIndex & | sourceParent, |
int | start, | ||
int | count, | ||
ItemMap & | items | ||
) | [protected] |
Utility methods to shift items in an item map.
You can use this method to adjust an item map after the source model has inserted or removed rows. When removing rows (count < 0), items may possibly be removed and deleted.
WAbstractItemModel* Wt::WAbstractProxyModel::sourceModel | ( | ) | const |
Returns the source model.