Wt  3.3.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Classes | Public Member Functions | Protected Types | Protected Member Functions
Wt::WAbstractProxyModel Class Reference

An abstract proxy model for Wt's item models. More...

#include <Wt/WAbstractProxyModel>

Inheritance diagram for Wt::WAbstractProxyModel:
Inheritance graph
[legend]

List of all members.

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.
WAbstractItemModelsourceModel () const
 Returns the source model.
virtual boost::any data (const WModelIndex &index, int role=DisplayRole) const
 Returns the data at a specific model index.
virtual boost::any headerData (int section, Orientation orientation=Horizontal, int role=DisplayRole) const
 Returns the row or column header data.
virtual bool setData (const WModelIndex &index, const boost::any &value, int role=EditRole)
 Sets the data at the given model index.
virtual bool setItemData (const WModelIndex &index, const DataMap &values)
 Sets the data at the given model index.
virtual WFlags< ItemFlagflags (const WModelIndex &index) const
 Returns the flags for an item.
virtual WFlags< HeaderFlagheaderFlags (int section, Orientation orientation=Horizontal) const
 Returns the flags for a header.
virtual bool insertColumns (int column, int count, const WModelIndex &parent=WModelIndex())
 Inserts one or more columns.
virtual bool removeColumns (int column, int count, const WModelIndex &parent=WModelIndex())
 Removes columns.
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)
 Handles a drop event.
virtual void * toRawIndex (const WModelIndex &index) const
 Converts a model index to a raw pointer that remains valid while the model's layout is changed.
virtual WModelIndex fromRawIndex (void *rawIndex) const
 Converts a raw pointer to a model index.

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.

Detailed Description

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().


Member Typedef Documentation

typedef std::map<WModelIndex, BaseItem *> Wt::WAbstractProxyModel::ItemMap [protected]

A map for items.

See also:
BaseItem

Member Function Documentation

virtual 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 proxy implementation calls sourceModel()->acceptDropMimeTypes()

Reimplemented from Wt::WAbstractItemModel.

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 boost::any Wt::WAbstractProxyModel::data ( const WModelIndex index,
int  role = DisplayRole 
) const [virtual]

Returns the data at a specific model index.

The default proxy implementation translates the index to the source model, and calls sourceModel()->data() with this index.

Implements Wt::WAbstractItemModel.

Reimplemented in Wt::WBatchEditProxyModel.

virtual void Wt::WAbstractProxyModel::dropEvent ( const WDropEvent e,
DropAction  action,
int  row,
int  column,
const WModelIndex parent 
) [virtual]

Handles a drop event.

The default proxy implementation maps the given row and parent to the row and parent in the source model, and forwards the dropEvent call to the source model.

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WReadOnlyProxyModel.

virtual WFlags<ItemFlag> Wt::WAbstractProxyModel::flags ( const WModelIndex index) const [virtual]

Returns the flags for an item.

The default proxy implementation calls sourceModel()->flags(mapToSource(index))

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WBatchEditProxyModel.

virtual WModelIndex Wt::WAbstractProxyModel::fromRawIndex ( void *  rawIndex) const [virtual]

Converts a raw pointer to a model index.

The default proxy implementation calls mapFromSource(sourceModel()->fromRawIndex(rawIndex))

Reimplemented from Wt::WAbstractItemModel.

virtual boost::any Wt::WAbstractProxyModel::headerData ( int  section,
Orientation  orientation = Horizontal,
int  role = DisplayRole 
) const [virtual]

Returns the row or column header data.

The default proxy implementation constructs a dummy WModelIndex with the row set to 0 and column set to section if the orientation is Wt::Horizontal, or with the row set to section and the column set to 0 if the orientation is Wt::Vertical.

The resulting section that is forwarded to sourceModel()->headerData() depends on how the WModelIndex is transformed with mapToSource().

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WSortFilterProxyModel, Wt::WAggregateProxyModel, and Wt::WBatchEditProxyModel.

virtual WFlags<HeaderFlag> Wt::WAbstractProxyModel::headerFlags ( int  section,
Orientation  orientation = Horizontal 
) const [virtual]

Returns the flags for a header.

The default proxy implementation constructs a dummy WModelIndex with the row set to 0 and column set to section if the orientation is Wt::Horizontal, or with the row set to section and the column set to 0 if the orientation is Wt::Vertical.

The resulting section that is forwarded to sourceModel()->headerFlags() depends on how the WModelIndex is transformed with mapToSource().

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WSortFilterProxyModel, and Wt::WAggregateProxyModel.

virtual bool Wt::WAbstractProxyModel::insertColumns ( int  column,
int  count,
const WModelIndex parent = WModelIndex() 
) [virtual]

Inserts one or more columns.

The default proxy implementation calls sourceModel()->insertColumns(column, count, parent)

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WBatchEditProxyModel, Wt::WIdentityProxyModel, and Wt::WReadOnlyProxyModel.

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().

See also:
mapToSource()

Implemented in Wt::WAggregateProxyModel, Wt::WSortFilterProxyModel, Wt::WBatchEditProxyModel, Wt::WIdentityProxyModel, and Wt::WReadOnlyProxyModel.

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.

See also:
mapFromSource()

Implemented in Wt::WAggregateProxyModel, Wt::WSortFilterProxyModel, Wt::WBatchEditProxyModel, Wt::WIdentityProxyModel, and Wt::WReadOnlyProxyModel.

virtual std::string Wt::WAbstractProxyModel::mimeType ( ) const [virtual]

Returns a mime-type for dragging a set of indexes.

The default proxy implementation calls sourceModel()->mimeType()

Reimplemented from Wt::WAbstractItemModel.

virtual bool Wt::WAbstractProxyModel::removeColumns ( int  column,
int  count,
const WModelIndex parent = WModelIndex() 
) [virtual]

Removes columns.

The default proxy implementation calls sourceModel()->removeColumns(column, count, parent)

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WBatchEditProxyModel, Wt::WIdentityProxyModel, and Wt::WReadOnlyProxyModel.

virtual bool Wt::WAbstractProxyModel::setData ( const WModelIndex index,
const boost::any &  value,
int  role = EditRole 
) [virtual]

Sets the data at the given model index.

The default proxy implementation calls sourceModel()->setData(mapToSource(index), value, role)

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WBatchEditProxyModel, and Wt::WReadOnlyProxyModel.

virtual bool Wt::WAbstractProxyModel::setItemData ( const WModelIndex index,
const DataMap values 
) [virtual]

Sets the data at the given model index.

The default proxy implementation calls sourceModel()->setData(mapToSource(index), values)

Reimplemented from Wt::WAbstractItemModel.

Reimplemented in Wt::WReadOnlyProxyModel.

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.

Note that the source model's signals are not forwarded to the proxy model by default, but some specializations, like WBatchEditProxyModel and WSortFilterProxyModel do. If you want to reimplement data() with no changes to row or column indices, consider the use of WIdentityProxyModel.

Reimplemented in Wt::WAggregateProxyModel, Wt::WSortFilterProxyModel, Wt::WBatchEditProxyModel, and Wt::WIdentityProxyModel.

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.

Returns the source model.

See also:
setSourceModel()
virtual void* Wt::WAbstractProxyModel::toRawIndex ( const WModelIndex index) const [virtual]

Converts a model index to a raw pointer that remains valid while the model's layout is changed.

The default proxy implementation calls sourceModel()->toRawIndex(mapToSource(index))

Reimplemented from Wt::WAbstractItemModel.

 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator

Generated on Tue Mar 22 2016 for the C++ Web Toolkit (Wt) by doxygen 1.7.6.1