Class WAggregateProxyModel
This proxy model does not store data itself, but presents data from a source model, and presents methods to organize columns using aggregation, through which a user may navigate (usually to obtain more detailed results related to a single aggregate quantity).
To use this proxy model, you should provide a source model using setSourceModel()
, and define
column ranges that can be aggregated using addAggregate()
.
This example would render like this:
A WTreeView using a WAggregateProxyModel
Note: This model does not support dynamic changes to the column definition of the source model (i.e. insertions or deletions of source model columns).
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WAbstractProxyModel
WAbstractProxyModel.BaseItem
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addAggregate
(int parentColumn, int firstColumn, int lastColumn) Adds a new column aggregation definition.void
collapseColumn
(int column) Collapses a column.void
expandColumn
(int column) Expands a column.int
getColumnCount
(WModelIndex parent) Returns the number of columns.getHeaderData
(int section, Orientation orientation, ItemDataRole role) Returns the row or column header data.getHeaderFlags
(int section, Orientation orientation) Returns the flags for a header.getIndex
(int row, int column, WModelIndex parent) Returns the child index for the given row and column.getParent
(WModelIndex index) Returns the parent for a model index.int
getRowCount
(WModelIndex parent) Returns the number of rows.mapFromSource
(WModelIndex sourceIndex) Maps a source model index to the proxy model.mapToSource
(WModelIndex proxyIndex) Maps a proxy model index to the source model.boolean
setHeaderData
(int section, Orientation orientation, Object value, ItemDataRole role) Sets header data for a column or row.void
setSourceModel
(WAbstractItemModel model) Sets the source model.void
Sorts the model according to a particular column.Methods inherited from class eu.webtoolkit.jwt.WAbstractProxyModel
createSourceIndex, dropEvent, endShiftModelIndexes, fromRawIndex, getAcceptDropMimeTypes, getData, getFlags, getMimeType, getSourceModel, insertColumns, removeColumns, setData, setItemData, startShiftModelIndexes, toRawIndex
Methods inherited from class eu.webtoolkit.jwt.WAbstractItemModel
beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, columnsAboutToBeInserted, columnsAboutToBeRemoved, columnsInserted, columnsRemoved, copyData, createIndex, createIndex, dataChanged, dropEvent, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, getColumnCount, getData, getData, getData, getData, getHeaderData, getHeaderData, getHeaderFlags, getIndex, getItemData, getRowCount, hasChildren, hasIndex, hasIndex, headerDataChanged, insertColumn, insertColumn, insertColumns, insertRow, insertRow, insertRows, insertRows, layoutAboutToBeChanged, layoutChanged, match, modelReset, removeColumn, removeColumn, removeColumns, removeRow, removeRow, removeRows, removeRows, reset, rowsAboutToBeInserted, rowsAboutToBeRemoved, rowsInserted, rowsRemoved, setData, setData, setData, setData, setHeaderData, setHeaderData, sort
Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
Constructor Details
-
WAggregateProxyModel
public WAggregateProxyModel()Constructor.Sets up the proxy without aggregation functionality.
-
-
Method Details
-
addAggregate
public void addAggregate(int parentColumn, int firstColumn, int lastColumn) Adds a new column aggregation definition.The
parentColumn
is the column index in the source model that acts as an aggregate for columnsfirstColumn
tolastColumn
.parentColumn
must border the range defined byfirstColumn
tolastColumn:
parentColumn == firstColumn - 1 || parentColumn == lastColumn + 1
Note that column parameters reference column indexes in the source model.
Aggregation definitions can be nested, but should be strictly hierarchical.
The aggregate column will initially be collapsed.
Only one aggregate can be defined per
parentColumn
. -
mapFromSource
Description copied from class:WAbstractProxyModel
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 ofmapToSource()
.- Specified by:
mapFromSource
in classWAbstractProxyModel
- See Also:
-
mapToSource
Description copied from class:WAbstractProxyModel
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
.- Specified by:
mapToSource
in classWAbstractProxyModel
- See Also:
-
setSourceModel
Description copied from class:WAbstractProxyModel
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
andWSortFilterProxyModel
do. If you want to reimplement data() with no changes to row or column indices, consider the use ofWIdentityProxyModel
.- Overrides:
setSourceModel
in classWAbstractProxyModel
-
expandColumn
public void expandColumn(int column) Description copied from class:WAbstractItemModel
Expands a column.Expands a column. This may only be called by a view when the
HeaderFlag.ColumnIsCollapsed
flag is set.The default implementation does nothing.
- Overrides:
expandColumn
in classWAbstractItemModel
- See Also:
-
collapseColumn
public void collapseColumn(int column) Description copied from class:WAbstractItemModel
Collapses a column.Collapses a column. This may only be called by a view when the
HeaderFlag.ColumnIsExpandedLeft
orHeaderFlag.ColumnIsExpandedRight
flag is set.The default implementation does nothing.
- Overrides:
collapseColumn
in classWAbstractItemModel
- See Also:
-
getColumnCount
Description copied from class:WAbstractItemModel
Returns the number of columns.This returns the number of columns at index
parent
.- Specified by:
getColumnCount
in classWAbstractItemModel
- See Also:
-
getRowCount
Description copied from class:WAbstractItemModel
Returns the number of rows.This returns the number of rows at index
parent
.- Specified by:
getRowCount
in classWAbstractItemModel
- See Also:
-
getHeaderFlags
Description copied from class:WAbstractProxyModel
Returns the flags for a header.The default proxy implementation constructs a dummy
WModelIndex
with the row set to 0 and column set tosection
if the orientation isOrientation.Horizontal
, or with the row set tosection
and the column set to 0 if the orientation isOrientation.Vertical
.The resulting section that is forwarded to
getSourceModel()
.getHeaderFlags()
depends on how theWModelIndex
is transformed withmapToSource()
.- Overrides:
getHeaderFlags
in classWAbstractProxyModel
- See Also:
-
setHeaderData
Description copied from class:WAbstractItemModel
Sets header data for a column or row.Returns
true
if the operation was successful.- Overrides:
setHeaderData
in classWAbstractItemModel
- See Also:
-
getHeaderData
Description copied from class:WAbstractProxyModel
Returns the row or column header data.The default proxy implementation constructs a dummy
WModelIndex
with the row set to 0 and column set tosection
if the orientation isOrientation.Horizontal
, or with the row set tosection
and the column set to 0 if the orientation isOrientation.Vertical
.The resulting section that is forwarded to
getSourceModel()
.getHeaderData()
depends on how theWModelIndex
is transformed withmapToSource()
. -
getParent
Description copied from class:WAbstractItemModel
Returns the parent for a model index.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.- Specified by:
getParent
in classWAbstractItemModel
- See Also:
-
getIndex
Description copied from class:WAbstractItemModel
Returns the child index for the given row and column.When implementing this method, you can use
createIndex()
to create an index that corresponds to the item atrow
andcolumn
withinparent
.If the location is invalid (out of bounds at the parent), then an invalid index must be returned.
- Specified by:
getIndex
in classWAbstractItemModel
- See Also:
-
sort
Description copied from class:WAbstractItemModel
Sorts the model according to a particular column.If the model supports sorting, then it should emit the
layoutAboutToBeChanged()
signal, rearrange its items, and afterwards emit thelayoutChanged()
signal.- Overrides:
sort
in classWAbstractItemModel
- See Also:
-