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.BaseItemNested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAggregate(int parentColumn, int firstColumn, int lastColumn) Adds a new column aggregation definition.voidcollapseColumn(int column) Collapses a column.voidexpandColumn(int column) Expands a column.intgetColumnCount(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.intgetRowCount(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.booleansetHeaderData(int section, Orientation orientation, Object value, ItemDataRole role) Sets header data for a column or row.voidsetSourceModel(WAbstractItemModel model) Sets the source model.voidSorts 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, toRawIndexMethods 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, sortMethods 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
parentColumnis the column index in the source model that acts as an aggregate for columnsfirstColumntolastColumn.parentColumnmust border the range defined byfirstColumntolastColumn:parentColumn == firstColumn - 1 || parentColumn == lastColumn + 1Note 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:WAbstractProxyModelMaps a source model index to the proxy model.This method returns a model index in the proxy model that corresponds to the model index
sourceIndexin the source model. This method must only be implemented for source model indexes that are mapped and thus are the result ofmapToSource().- Specified by:
mapFromSourcein classWAbstractProxyModel- See Also:
-
mapToSource
Description copied from class:WAbstractProxyModelMaps 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:
mapToSourcein classWAbstractProxyModel- See Also:
-
setSourceModel
Description copied from class:WAbstractProxyModelSets 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
WBatchEditProxyModelandWSortFilterProxyModeldo. If you want to reimplement data() with no changes to row or column indices, consider the use ofWIdentityProxyModel.- Overrides:
setSourceModelin classWAbstractProxyModel
-
expandColumn
public void expandColumn(int column) Description copied from class:WAbstractItemModelExpands a column.Expands a column. This may only be called by a view when the
HeaderFlag.ColumnIsCollapsedflag is set.The default implementation does nothing.
- Overrides:
expandColumnin classWAbstractItemModel- See Also:
-
collapseColumn
public void collapseColumn(int column) Description copied from class:WAbstractItemModelCollapses a column.Collapses a column. This may only be called by a view when the
HeaderFlag.ColumnIsExpandedLeftorHeaderFlag.ColumnIsExpandedRightflag is set.The default implementation does nothing.
- Overrides:
collapseColumnin classWAbstractItemModel- See Also:
-
getColumnCount
Description copied from class:WAbstractItemModelReturns the number of columns.This returns the number of columns at index
parent.- Specified by:
getColumnCountin classWAbstractItemModel- See Also:
-
getRowCount
Description copied from class:WAbstractItemModelReturns the number of rows.This returns the number of rows at index
parent.- Specified by:
getRowCountin classWAbstractItemModel- See Also:
-
getHeaderFlags
Description copied from class:WAbstractProxyModelReturns the flags for a header.The default proxy implementation constructs a dummy
WModelIndexwith the row set to 0 and column set tosectionif the orientation isOrientation.Horizontal, or with the row set tosectionand the column set to 0 if the orientation isOrientation.Vertical.The resulting section that is forwarded to
getSourceModel().getHeaderFlags()depends on how theWModelIndexis transformed withmapToSource().- Overrides:
getHeaderFlagsin classWAbstractProxyModel- See Also:
-
setHeaderData
Description copied from class:WAbstractItemModelSets header data for a column or row.Returns
trueif the operation was successful.- Overrides:
setHeaderDatain classWAbstractItemModel- See Also:
-
getHeaderData
Description copied from class:WAbstractProxyModelReturns the row or column header data.The default proxy implementation constructs a dummy
WModelIndexwith the row set to 0 and column set tosectionif the orientation isOrientation.Horizontal, or with the row set tosectionand the column set to 0 if the orientation isOrientation.Vertical.The resulting section that is forwarded to
getSourceModel().getHeaderData()depends on how theWModelIndexis transformed withmapToSource(). -
getParent
Description copied from class:WAbstractItemModelReturns 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:
getParentin classWAbstractItemModel- See Also:
-
getIndex
Description copied from class:WAbstractItemModelReturns 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 atrowandcolumnwithinparent.If the location is invalid (out of bounds at the parent), then an invalid index must be returned.
- Specified by:
getIndexin classWAbstractItemModel- See Also:
-
sort
Description copied from class:WAbstractItemModelSorts 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:
sortin classWAbstractItemModel- See Also:
-