Class WStringListModel
This model only manages a unidimensional list of items and is optimized for usage by view widgets such as combo-boxes.
It supports all features of a typical item model, including data for multiple roles, editing and addition and removal of data rows.
You can populate the model by passing a list of strings to its consructor, or by using the
setStringList() method. You can set or
retrieve data using the setData() and getData() methods, and add or remove data using the insertRows() and removeRows() methods.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty string list model.WStringListModel(List<WString> strings) Creates a new string list model. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddString(CharSequence string) Adds a string.getData(WModelIndex index, ItemDataRole role) Returns data at a specified model index for the given role.getFlags(WModelIndex index) Returns the flags for an item.intgetRowCount(WModelIndex parent) Returns the number of rows.Returns the string list.booleaninsertRows(int row, int count, WModelIndex parent) Inserts one or more rows.voidinsertString(int row, CharSequence string) Inserts a string.booleanremoveRows(int row, int count, WModelIndex parent) Removes rows.booleansetData(WModelIndex index, Object value, ItemDataRole role) Sets data at the given model index.final voidSets model flags for an item.voidSets model flags for an item.voidsetStringList(List<WString> strings) Sets a new string list.voidSorts the model according to a particular column.Methods inherited from class eu.webtoolkit.jwt.WAbstractListModel
getColumnCount, getIndex, getParentMethods inherited from class eu.webtoolkit.jwt.WAbstractItemModel
beginInsertColumns, beginInsertRows, beginRemoveColumns, beginRemoveRows, collapseColumn, columnsAboutToBeInserted, columnsAboutToBeRemoved, columnsInserted, columnsRemoved, copyData, createIndex, createIndex, dataChanged, dropEvent, dropEvent, endInsertColumns, endInsertRows, endRemoveColumns, endRemoveRows, expandColumn, fromRawIndex, getAcceptDropMimeTypes, getColumnCount, getData, getData, getData, getData, getHeaderData, getHeaderData, getHeaderData, getHeaderFlags, getHeaderFlags, getIndex, getItemData, getMimeType, getRowCount, hasChildren, hasIndex, hasIndex, headerDataChanged, insertColumn, insertColumn, insertColumns, insertColumns, insertRow, insertRow, insertRows, layoutAboutToBeChanged, layoutChanged, match, modelReset, removeColumn, removeColumn, removeColumns, removeColumns, removeRow, removeRow, removeRows, reset, rowsAboutToBeInserted, rowsAboutToBeRemoved, rowsInserted, rowsRemoved, setData, setData, setData, setData, setHeaderData, setHeaderData, setHeaderData, setItemData, sort, toRawIndexMethods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
Constructor Details
-
WStringListModel
public WStringListModel()Creates a new empty string list model. -
WStringListModel
Creates a new string list model.
-
-
Method Details
-
setStringList
Sets a new string list.Replaces the current string list with a new list.
-
insertString
Inserts a string.- See Also:
-
addString
Adds a string.- See Also:
-
getStringList
Returns the string list.- See Also:
-
setFlags
Sets model flags for an item.The default item flags are
ItemFlag.Selectable|ItemFlag.Editable. -
setFlags
Sets model flags for an item. -
getFlags
Returns the flags for an item.This method is reimplemented to return flags set in
setFlags().- Overrides:
getFlagsin classWAbstractItemModel- See Also:
-
setData
Description copied from class:WAbstractItemModelSets data at the given model index.Returns
trueif the operation was successful.The default implementation returns
false.The model implementation must emit the
dataChanged()signal after data was changed.- Overrides:
setDatain classWAbstractItemModel- See Also:
-
getData
Description copied from class:WAbstractItemModelReturns data at a specified model index for the given role.You should check the
roleto decide what data to return. Usually a View class will ask for data for several roles which affect not only the contents (ItemDataRole.Display) but also icons (ItemDataRole.Decoration), URLs (ItemDataRole.Link), and other visual aspects. If your item does not specify data for a particular role, it should simply return a Wt::cpp17::any(). -
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:
-
insertRows
Description copied from class:WAbstractItemModelInserts one or more rows.In models that support row insertion, this inserts
countrows, starting atrow, and returnstrueif the operation was successful. The new rows are inserted underparent.If parent had no children, then a single column is added with
countrows.The default implementation returns
false.The model implementation must call
beginInsertRows()andendInsertRows()before and after the operation whenever its geometry is changed by inserting rows. This emits signals for views to properly react to these changes.- Overrides:
insertRowsin classWAbstractItemModel- See Also:
-
removeRows
Description copied from class:WAbstractItemModelRemoves rows.Returns
trueif the operation was successful.The default implementation returns
false.The model implementation must call
beginRemoveRows()andendRemoveRows()before and after the operation whenever its geometry is changed by removing rows. This emits signals for views to properly react to these changes.- Overrides:
removeRowsin 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:
-