|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.WObject
eu.webtoolkit.jwt.WAbstractItemModel
eu.webtoolkit.jwt.WAbstractProxyModel
public abstract class WAbstractProxyModel
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
getSourceModel().
| Nested Class Summary | |
|---|---|
protected static class |
WAbstractProxyModel.BaseItem
A base class for an item modeling a source index parent. |
| Constructor Summary | |
|---|---|
WAbstractProxyModel()
Constructor. |
|
WAbstractProxyModel(WObject parent)
Constructor. |
|
| Method Summary | |
|---|---|
protected WModelIndex |
createSourceIndex(int row,
int column,
java.lang.Object ptr)
Create a source model index. |
void |
dropEvent(WDropEvent e,
DropAction action,
int row,
int column,
WModelIndex parent)
Handles a drop event. |
WModelIndex |
fromRawIndex(java.lang.Object rawIndex)
Converts a raw pointer to a model index. |
java.util.List<java.lang.String> |
getAcceptDropMimeTypes()
Returns a list of mime-types that could be accepted for a drop event. |
java.lang.Object |
getData(WModelIndex index,
int role)
Returns data at a specific model index. |
java.util.EnumSet<ItemFlag> |
getFlags(WModelIndex index)
Returns the flags for an item. |
java.lang.String |
getMimeType()
Returns a mime-type for dragging a set of indexes. |
WAbstractItemModel |
getSourceModel()
Returns the source model. |
boolean |
insertColumns(int column,
int count,
WModelIndex parent)
Inserts one or more columns. |
abstract WModelIndex |
mapFromSource(WModelIndex sourceIndex)
Maps a source model index to the proxy model. |
abstract WModelIndex |
mapToSource(WModelIndex proxyIndex)
Maps a proxy model index to the source model. |
boolean |
removeColumns(int column,
int count,
WModelIndex parent)
Removes columns. |
boolean |
setData(WModelIndex index,
java.lang.Object value,
int role)
Sets data at the given model index. |
void |
setSourceModel(WAbstractItemModel sourceModel)
Sets the source model. |
protected void |
shiftModelIndexes(WModelIndex sourceParent,
int start,
int count,
java.util.SortedMap<WModelIndex,WAbstractProxyModel.BaseItem> items)
Utility methods to shift items in an item map. |
java.lang.Object |
toRawIndex(WModelIndex index)
Converts a model index to a raw pointer that remains valid while the model's layout is changed. |
| Methods inherited from class eu.webtoolkit.jwt.WObject |
|---|
addChild, getId, getObjectName, remove, setObjectName, tr |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public WAbstractProxyModel(WObject parent)
public WAbstractProxyModel()
Calls this((WObject)null)
| Method Detail |
|---|
public abstract WModelIndex mapFromSource(WModelIndex sourceIndex)
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().
mapToSource(WModelIndex proxyIndex)public abstract WModelIndex mapToSource(WModelIndex proxyIndex)
This method returns a model index in the source model that corresponds to
the proxy model index proxyIndex.
mapFromSource(WModelIndex sourceIndex)public void setSourceModel(WAbstractItemModel sourceModel)
The source model provides the actual data for the proxy model.
Ownership of the source model is not transferred.
public WAbstractItemModel getSourceModel()
setSourceModel(WAbstractItemModel sourceModel)
public java.lang.Object getData(WModelIndex index,
int role)
WAbstractItemModelReturn data for a given role at a given index.
You should check the role to decide what data to return.
Usually a View class will ask for data for several roles which affect not
only the contents (ItemDataRole.DisplayRole) but also icons (
ItemDataRole.DecorationRole), URLs (ItemDataRole.LinkRole
), and other visual aspects. If your item does not specify data for a
particular role, it should simply return a boost::any().
getData in class WAbstractItemModelWAbstractItemModel.getFlags(WModelIndex index),
WAbstractItemModel.getHeaderData(int section, Orientation
orientation, int role),
WAbstractItemModel.setData(WModelIndex index, Object value, int
role)
public boolean setData(WModelIndex index,
java.lang.Object value,
int role)
WAbstractItemModel
Returns true if the operation was successful.
The default implementation returns false.
The model implementation must emit the
dataChanged() signal after data
was changed.
setData in class WAbstractItemModelWAbstractItemModel.getData(WModelIndex index, int role)public java.util.EnumSet<ItemFlag> getFlags(WModelIndex index)
WAbstractItemModel
The default implementation returns ItemIsSelectable.
getFlags in class WAbstractItemModelItemFlag
public boolean insertColumns(int column,
int count,
WModelIndex parent)
WAbstractItemModel
In models that support column insertion, this inserts count
columns, starting at column, and returns true
if the operation was successful. The new columns are inserted under
parent.
The default implementation returns false.
The model implementation must call
beginInsertColumns() and endInsertColumns() before and after the operation whenever its geometry
is changed by inserting columns. This emits signals for views to properly
react to these changes.
insertColumns in class WAbstractItemModelWAbstractItemModel.insertRows(int row, int count, WModelIndex
parent),
WAbstractItemModel.removeColumns(int column, int count, WModelIndex
parent),
WAbstractItemModel.beginInsertColumns(WModelIndex parent, int first,
int last),
WAbstractItemModel.endInsertColumns()
public boolean removeColumns(int column,
int count,
WModelIndex parent)
WAbstractItemModel
Returns true if the operation was successful.
The default implementation returns false.
The model implementation must call
beginRemoveColumns() and endRemoveColumns() before and after the operation whenever its geometry
is changed by removing columns. This emits signals for views to properly
react to these changes.
removeColumns in class WAbstractItemModelWAbstractItemModel.removeRows(int row, int count, WModelIndex
parent),
WAbstractItemModel.insertColumns(int column, int count, WModelIndex
parent),
WAbstractItemModel.beginRemoveColumns(WModelIndex parent, int first,
int last),
WAbstractItemModel.endRemoveColumns()public java.lang.String getMimeType()
WAbstractItemModelThis 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.
getMimeType in class WAbstractItemModelWAbstractItemModel.getAcceptDropMimeTypes()public java.util.List<java.lang.String> getAcceptDropMimeTypes()
WAbstractItemModelThe default implementation only accepts drag&drop support between abstract item models.
getAcceptDropMimeTypes in class WAbstractItemModelWAbstractItemModel.getMimeType()
public void dropEvent(WDropEvent e,
DropAction action,
int row,
int column,
WModelIndex parent)
WAbstractItemModelThe 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.
Note: Currently, only row selections are handled by the default implementation.
dropEvent in class WAbstractItemModelWAbstractItemModel.getMimeType(),
WItemSelectionModelpublic java.lang.Object toRawIndex(WModelIndex index)
WAbstractItemModelUse this method to temporarily save model indexes while the model's layout is changed by for example a sorting operation.
The default implementation returns null, which indicates
that the index cannot be converted to a raw pointer. If you reimplement
this method, you also need to reimplemnt
fromRawIndex().
toRawIndex in class WAbstractItemModelWAbstractItemModel.layoutAboutToBeChanged(),
WAbstractItemModel.sort(int column, SortOrder order),
WAbstractItemModel.fromRawIndex(Object rawIndex)public WModelIndex fromRawIndex(java.lang.Object rawIndex)
WAbstractItemModel
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.
fromRawIndex in class WAbstractItemModelWAbstractItemModel.toRawIndex(WModelIndex index)
protected WModelIndex createSourceIndex(int row,
int column,
java.lang.Object ptr)
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.
protected void shiftModelIndexes(WModelIndex sourceParent,
int start,
int count,
java.util.SortedMap<WModelIndex,WAbstractProxyModel.BaseItem> items)
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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||