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
ConstructorDescriptionCreates a new empty string list model.WStringListModel
(List<WString> strings) Creates a new string list model. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addString
(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.int
getRowCount
(WModelIndex parent) Returns the number of rows.Returns the string list.boolean
insertRows
(int row, int count, WModelIndex parent) Inserts one or more rows.void
insertString
(int row, CharSequence string) Inserts a string.boolean
removeRows
(int row, int count, WModelIndex parent) Removes rows.boolean
setData
(WModelIndex index, Object value, ItemDataRole role) Sets data at the given model index.final void
Sets model flags for an item.void
Sets model flags for an item.void
setStringList
(List<WString> strings) Sets a new string list.void
Sorts the model according to a particular column.Methods inherited from class eu.webtoolkit.jwt.WAbstractListModel
getColumnCount, getIndex, getParent
Methods 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, toRawIndex
Methods 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:
getFlags
in classWAbstractItemModel
- See Also:
-
setData
Description copied from class:WAbstractItemModel
Sets data at the given model index.Returns
true
if the operation was successful.The default implementation returns
false
.The model implementation must emit the
dataChanged()
signal after data was changed.- Overrides:
setData
in classWAbstractItemModel
- See Also:
-
getData
Description copied from class:WAbstractItemModel
Returns data at a specified model index for the given role.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.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:WAbstractItemModel
Returns the number of rows.This returns the number of rows at index
parent
.- Specified by:
getRowCount
in classWAbstractItemModel
- See Also:
-
insertRows
Description copied from class:WAbstractItemModel
Inserts one or more rows.In models that support row insertion, this inserts
count
rows, starting atrow
, and returnstrue
if the operation was successful. The new rows are inserted underparent
.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()
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:
insertRows
in classWAbstractItemModel
- See Also:
-
removeRows
Description copied from class:WAbstractItemModel
Removes rows.Returns
true
if 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:
removeRows
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:
-