|
||||||||||
| 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
eu.webtoolkit.jwt.WBatchEditProxyModel
public class WBatchEditProxyModel
A proxy model for Wt's item models that provides batch editing.
This proxy model presents data from a source model, and caches any editing
operation without affecting the underlying source model, until
commitAll() or
revertAll() is called. In this way,
you can commit all the editing in batch to the underlying source model, only
when the user confirms the changes.
All editing operations are supported:
setData())insertRows() and
removeRows())insertColumns() and
removeColumns())The model supports both simple tabular models, as well as hierarchical (tree-like / treetable-like) models, with children under items in the first column.
Default values for a newly inserted row can be set using
setNewRowData() and flags for its items using
setNewRowFlags().
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WAbstractProxyModel |
|---|
WAbstractProxyModel.BaseItem |
| Constructor Summary | |
|---|---|
WBatchEditProxyModel()
Constructor. |
|
WBatchEditProxyModel(WObject parent)
Constructor. |
|
| Method Summary | |
|---|---|
void |
commitAll()
Commits changes. |
int |
getColumnCount(WModelIndex parent)
Returns the number of columns. |
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.Object |
getHeaderData(int section,
Orientation orientation,
int role)
Returns the row or column header data. |
WModelIndex |
getIndex(int row,
int column,
WModelIndex parent)
Returns the child index for the given row and column. |
WModelIndex |
getParent(WModelIndex index)
Returns the parent for a model index. |
int |
getRowCount(WModelIndex parent)
Returns the number of rows. |
boolean |
insertColumns(int column,
int count,
WModelIndex parent)
Inserts one or more columns. |
boolean |
insertRows(int row,
int count,
WModelIndex parent)
Inserts one or more rows. |
boolean |
isDirty()
Returns whether changes have not yet been committed. |
WModelIndex |
mapFromSource(WModelIndex sourceIndex)
Maps a source model index to the proxy model. |
WModelIndex |
mapToSource(WModelIndex proxyIndex)
Maps a proxy model index to the source model. |
boolean |
removeColumns(int column,
int count,
WModelIndex parent)
Removes columns. |
boolean |
removeRows(int row,
int count,
WModelIndex parent)
Removes rows. |
void |
revertAll()
Reverts changes. |
boolean |
setData(WModelIndex index,
java.lang.Object value,
int role)
Sets item data. |
void |
setDirtyIndication(int role,
java.lang.Object data)
Configures data used to indicate a modified item. |
void |
setNewRowData(int column,
java.lang.Object data)
Sets default data for a newly inserted row. |
void |
setNewRowData(int column,
java.lang.Object data,
int role)
Sets default data for a newly inserted row. |
void |
setNewRowFlags(int column,
java.util.EnumSet<ItemFlag> flags)
Sets the item flags for items in a newly inserted row. |
void |
setNewRowFlags(int column,
ItemFlag flag,
ItemFlag... flags)
Sets the item flags for items in a newly inserted row. |
void |
setSourceModel(WAbstractItemModel model)
Sets the source model. |
void |
sort(int column,
SortOrder order)
Sorts the model according to a particular column. |
| Methods inherited from class eu.webtoolkit.jwt.WAbstractProxyModel |
|---|
createSourceIndex, dropEvent, fromRawIndex, getAcceptDropMimeTypes, getMimeType, getSourceModel, shiftModelIndexes, toRawIndex |
| 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 WBatchEditProxyModel(WObject parent)
public WBatchEditProxyModel()
Calls this((WObject)null)
| Method Detail |
|---|
public boolean isDirty()
Returns whether have been made to the proxy model, which could be
committed using commitAll() or
reverted using revertAll().
public void commitAll()
This commits all changes to the source model.
revertAll()public void revertAll()
This reverts all changes.
commitAll()
public void setNewRowData(int column,
java.lang.Object data,
int role)
You can use this method to initialize data for a newly inserted row.
public final void setNewRowData(int column,
java.lang.Object data)
Calls setNewRowData(column, data, ItemDataRole.DisplayRole)
public void setNewRowFlags(int column,
java.util.EnumSet<ItemFlag> flags)
By default, getFlags() will return ItemIsSelectable.
public final void setNewRowFlags(int column,
ItemFlag flag,
ItemFlag... flags)
Calls setNewRowFlags(column, EnumSet.of(flag, flags))
public void setDirtyIndication(int role,
java.lang.Object data)
This sets data for item data role role to be
returned by
getData() for an item that is dirty (e.g. because it belongs to a newly
inserted row/column, or because new data has been set for it.
When role is ItemDataRole.StyleClassRole, the style
class is appended to any style already returned by the source model or
set by
setNewRowData().
By default there is no dirty indication.
public WModelIndex mapFromSource(WModelIndex sourceIndex)
WAbstractProxyModel
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().
mapFromSource in class WAbstractProxyModelWAbstractProxyModel.mapToSource(WModelIndex proxyIndex)public WModelIndex mapToSource(WModelIndex proxyIndex)
WAbstractProxyModel
This method returns a model index in the source model that corresponds to
the proxy model index proxyIndex.
mapToSource in class WAbstractProxyModelWAbstractProxyModel.mapFromSource(WModelIndex sourceIndex)public void setSourceModel(WAbstractItemModel model)
WAbstractProxyModelThe source model provides the actual data for the proxy model.
Ownership of the source model is not transferred.
setSourceModel in class WAbstractProxyModelpublic int getColumnCount(WModelIndex parent)
WAbstractItemModel
This returns the number of columns at index parent.
getColumnCount in class WAbstractItemModelWAbstractItemModel.getRowCount(WModelIndex parent)public int getRowCount(WModelIndex parent)
WAbstractItemModel
This returns the number of rows at index parent.
getRowCount in class WAbstractItemModelWAbstractItemModel.getColumnCount(WModelIndex parent)public WModelIndex getParent(WModelIndex index)
WAbstractItemModel
An implementation should use
createIndex() to create a model index that corresponds to the parent of
a given index.
Note that the index itself may be stale (referencing a row/column within
the parent that is outside the model geometry), but its parent
(identified by the WModelIndex#getInternalPointer()) is referencing an existing parent. A
stale index can only be used while the model geometry is being updated,
i.e. during the emission of the corresponding
[rows/columns](Being)[Removed/Inserted]() signals.
getParent in class WAbstractItemModelWAbstractItemModel.getIndex(int row, int column, WModelIndex parent)
public WModelIndex getIndex(int row,
int column,
WModelIndex parent)
WAbstractItemModel
When implementing this method, you can use
createIndex() to create an index that corresponds to the item at
row and column within parent.
If the location is invalid (out of bounds at the parent), then an invalid index must be returned.
getIndex in class WAbstractItemModelWAbstractItemModel.getParent(WModelIndex index)
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 WAbstractProxyModelWAbstractItemModel.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)
The default implementation will copy ItemDataRole.EditRole data
to ItemDataRole.DisplayRole. You may want to specialize the model
to provide a more specialized editing behaviour.
setData in class WAbstractProxyModelWAbstractItemModel.getData(WModelIndex index, int role)public java.util.EnumSet<ItemFlag> getFlags(WModelIndex index)
WAbstractItemModel
The default implementation returns ItemIsSelectable.
getFlags in class WAbstractProxyModelItemFlag
public java.lang.Object getHeaderData(int section,
Orientation orientation,
int role)
WAbstractItemModel
When orientation is Horizontal, section is a column number, when
orientation is Vertical,
section is a row number.
getHeaderData in class WAbstractItemModelWAbstractItemModel.getData(WModelIndex index, int role),
WAbstractItemModel.setHeaderData(int section, Orientation
orientation, Object value, int role)
public boolean insertRows(int row,
int count,
WModelIndex parent)
WAbstractItemModel
In models that support row insertion, this inserts count
rows, starting at row, and returns true if the
operation was successful. The new rows are inserted under
parent.
If parent had no children, then a single column is added with
count rows.
The default implementation returns false.
The model implementation must call
beginInsertRows() and endInsertRows() before and after the operation whenever its geometry is
changed by inserting rows. This emits signals for views to properly react
to these changes.
insertRows in class WAbstractItemModelWAbstractItemModel.insertColumns(int column, int count, WModelIndex
parent),
WAbstractItemModel.removeRows(int row, int count, WModelIndex
parent),
WAbstractItemModel.beginInsertRows(WModelIndex parent, int first,
int last),
WAbstractItemModel.endInsertRows()
public boolean removeRows(int row,
int count,
WModelIndex parent)
WAbstractItemModel
Returns true if the operation was successful.
The default implementation returns false.
The model implementation must call
beginRemoveRows() and endRemoveRows() before and after the operation whenever its geometry is
changed by removing rows. This emits signals for views to properly react
to these changes.
removeRows in class WAbstractItemModelWAbstractItemModel.removeColumns(int column, int count, WModelIndex
parent),
WAbstractItemModel.insertRows(int row, int count, WModelIndex
parent),
WAbstractItemModel.beginRemoveRows(WModelIndex parent, int first,
int last),
WAbstractItemModel.endRemoveRows()
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 WAbstractProxyModelWAbstractItemModel.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 WAbstractProxyModelWAbstractItemModel.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 void sort(int column,
SortOrder order)
WAbstractItemModel
If the model supports sorting, then it should emit the
layoutAboutToBeChanged() signal, rearrange its items, and afterwards
emit the layoutChanged()
signal.
sort in class WAbstractItemModelWAbstractItemModel.layoutAboutToBeChanged(),
WAbstractItemModel.layoutChanged()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||