#include <Wt/WAbstractProxyModel>
Public Member Functions | |
WAbstractProxyModel (WObject *parent=0) | |
Constructor. | |
virtual WModelIndex | mapFromSource (const WModelIndex &sourceIndex) const =0 |
Map a source model index to the proxy model. | |
virtual WModelIndex | mapToSource (const WModelIndex &proxyIndex) const =0 |
Map a proxy model index to the source model. | |
virtual void | setSourceModel (WAbstractItemModel *sourceModel) |
Set a source model. | |
WAbstractItemModel * | sourceModel () const |
Returns the source model. | |
virtual boost::any | data (const WModelIndex &index, int role=DisplayRole) const |
Returns data at a specific model index. | |
virtual bool | setData (const WModelIndex &index, const boost::any &value, int role=EditRole) |
Set data at the given model index. | |
virtual WFlags< ItemFlag > | flags (const WModelIndex &index) const |
Returns the flags for an item. | |
virtual bool | setHeaderData (int section, Orientation orientation, const boost::any &value, int role=EditRole) |
Set header data for a column or row. | |
virtual boost::any | headerData (int section, Orientation orientation=Horizontal, int role=DisplayRole) const |
Returns the row or column header data. | |
virtual bool | insertColumns (int column, int count, const WModelIndex &parent=WModelIndex()) |
Insert one or more columns. | |
virtual bool | insertRows (int row, int count, const WModelIndex &parent=WModelIndex()) |
Insert one or more rows. | |
virtual bool | removeColumns (int column, int count, const WModelIndex &parent=WModelIndex()) |
Remove columns. | |
virtual bool | removeRows (int row, int count, const WModelIndex &parent=WModelIndex()) |
Remove rows. | |
virtual std::string | mimeType () const |
Returns a mime-type for dragging a set of indexes. | |
virtual std::vector< std::string > | acceptDropMimeTypes () const |
Returns a list of mime-types that could be accepted for a drop event. | |
virtual void | dropEvent (const WDropEvent &e, DropAction action, int row, int column, const WModelIndex &parent) |
Handle a drop event. | |
virtual void * | toRawIndex (const WModelIndex &index) const |
Convert a model index to a raw pointer that remains valid while the model's layout is changed. | |
virtual WModelIndex | fromRawIndex (void *rawIndex) const |
Convert a raw pointer to a model index. |
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().
virtual WModelIndex Wt::WAbstractProxyModel::mapFromSource | ( | const WModelIndex & | sourceIndex | ) | const [pure virtual] |
Map 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::WSortFilterProxyModel.
virtual WModelIndex Wt::WAbstractProxyModel::mapToSource | ( | const WModelIndex & | proxyIndex | ) | const [pure virtual] |
Map 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::WSortFilterProxyModel.
void Wt::WAbstractProxyModel::setSourceModel | ( | WAbstractItemModel * | sourceModel | ) | [virtual] |
Set a source model.
The source model provides the actual data for the proxy model.
Ownership of the source model is not transferred.
Reimplemented in Wt::WSortFilterProxyModel.
WAbstractItemModel* Wt::WAbstractProxyModel::sourceModel | ( | ) | const [inline] |
boost::any Wt::WAbstractProxyModel::data | ( | const WModelIndex & | index, | |
int | role = DisplayRole | |||
) | const [virtual] |
Returns data at a specific model index.
Return data for a given role at a given index.
Implements Wt::WAbstractItemModel.
bool Wt::WAbstractProxyModel::setData | ( | const WModelIndex & | index, | |
const boost::any & | value, | |||
int | role = EditRole | |||
) | [virtual] |
Set data at the given model index.
Returns true if the operation was successful.
The default implementation returns false. If you reimplement this method, you must emit the dataChanged() signal after data was changed.
Reimplemented from Wt::WAbstractItemModel.
WFlags< ItemFlag > Wt::WAbstractProxyModel::flags | ( | const WModelIndex & | index | ) | const [virtual] |
Returns the flags for an item.
The default implementation returns ItemIsSelectable.
Reimplemented from Wt::WAbstractItemModel.
bool Wt::WAbstractProxyModel::setHeaderData | ( | int | section, | |
Orientation | orientation, | |||
const boost::any & | value, | |||
int | role = EditRole | |||
) | [virtual] |
Set header data for a column or row.
Returns true if the operation was successful.
Reimplemented from Wt::WAbstractItemModel.
boost::any Wt::WAbstractProxyModel::headerData | ( | int | section, | |
Orientation | orientation = Horizontal , |
|||
int | role = DisplayRole | |||
) | const [virtual] |
Returns the row or column header data.
When orientation is Horizontal, section is a column number, when orientation is Vertical, section is a row number.
Reimplemented from Wt::WAbstractItemModel.
bool Wt::WAbstractProxyModel::insertColumns | ( | int | column, | |
int | count, | |||
const WModelIndex & | parent = WModelIndex() | |||
) | [virtual] |
Insert one or more columns.
Returns true if the operation was successful.
The default implementation returns false. If you reimplement this method, then you must call beginInsertColumns() and endInsertColumns() before and after the operation.
Reimplemented from Wt::WAbstractItemModel.
bool Wt::WAbstractProxyModel::insertRows | ( | int | row, | |
int | count, | |||
const WModelIndex & | parent = WModelIndex() | |||
) | [virtual] |
Insert one or more rows.
Returns true if the operation was successful. If you reimplement this method, then you must call beginInsertRows() and endInsertRows() before and after the operation.
The default implementation returns false.
Reimplemented from Wt::WAbstractItemModel.
bool Wt::WAbstractProxyModel::removeColumns | ( | int | column, | |
int | count, | |||
const WModelIndex & | parent = WModelIndex() | |||
) | [virtual] |
Remove columns.
Returns true if the operation was successful.
The default implementation returns false. If you reimplement this method, then you must call beginRemoveColumns() and endRemoveColumns() before and after the operation.
Reimplemented from Wt::WAbstractItemModel.
bool Wt::WAbstractProxyModel::removeRows | ( | int | row, | |
int | count, | |||
const WModelIndex & | parent = WModelIndex() | |||
) | [virtual] |
Remove rows.
Returns true if the operation was successful.
The default implementation returns false. If you reimplement this method, then you must call beginRemoveRows() and endRemoveRows() before and after the operation.
Reimplemented from Wt::WAbstractItemModel.
std::string Wt::WAbstractProxyModel::mimeType | ( | ) | const [virtual] |
Returns a mime-type for dragging a set of indexes.
This method returns a mime-type that describes dragging of a selection of items.
The drop event will indicate a selection model for this abstract item model as source.
The default implementation returns a mime-type for generic drag&drop support between abstract item models.
Reimplemented from Wt::WAbstractItemModel.
std::vector< std::string > Wt::WAbstractProxyModel::acceptDropMimeTypes | ( | ) | const [virtual] |
Returns a list of mime-types that could be accepted for a drop event.
The default implementation only accepts drag&drop support between abstract item models.
Reimplemented from Wt::WAbstractItemModel.
void Wt::WAbstractProxyModel::dropEvent | ( | const WDropEvent & | e, | |
DropAction | action, | |||
int | row, | |||
int | column, | |||
const WModelIndex & | parent | |||
) | [virtual] |
Handle a drop event.
The default implementation only handles generic drag&drop between abstract item models. Source item data is copied (but not the source item's flags).
The location in the model is indicated by the row and column within the parent index. If row is -1, then the item is appended to the parent. Otherwise, the item is inserted at or copied over the indicated item (and subsequent rows). When action is a MoveAction, the original items are deleted from the source model.
You may want to reimplement this method if you want to handle other mime-type data, or if you want to refine how the drop event of an item selection must be interpreted.
Reimplemented from Wt::WAbstractItemModel.
void * Wt::WAbstractProxyModel::toRawIndex | ( | const WModelIndex & | index | ) | const [virtual] |
Convert a model index to a raw pointer that remains valid while the model's layout is changed.
Use this method to temporarily save model indexes while the model's layout is changed by for example a sorting operation.
The default implementation returns 0, which indicates that the index cannot be converted to a raw pointer. If you reimplement this method, you also need to reimplemnt fromRawIndex().
Reimplemented from Wt::WAbstractItemModel.
WModelIndex Wt::WAbstractProxyModel::fromRawIndex | ( | void * | rawIndex | ) | const [virtual] |
Convert a raw pointer to a model index.
Use this method to create model index from temporary raw pointers. It is the reciproce method of toRawIndex().
You can return an invalid modelindex if the rawIndex no longer points to a valid item because of the layout change.
Reimplemented from Wt::WAbstractItemModel.