Class WItemSelectionModel
WAbstractItemView
.
This model is currently only used by WTreeView
, and plays only a role in drag &
drop of an item selection.
When an item selection is dragged from a view widget, the generated drop events will have as
source object (see WDropEvent.getSource()
) this selection model.
Although this class does not (yet) allow you to modify the selection, note that manipulations to the model may modify the selection (row insertions and removals may shift the selection, and row deletions may shrink the selection).
Note: Currently this class cannot be shared between multiple views.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class eu.webtoolkit.jwt.WObject
WObject.FormData
-
Method Summary
Modifier and TypeMethodDescriptionReturns the selection mime type.getModel()
Returns theWAbstractItemModel
.Returns the set of selected items.Returns the selection behaviour.boolean
isSelected
(WModelIndex index) Returns wheter an item is selected.void
setSelectionBehavior
(SelectionBehavior behavior) Sets the selection behaviour.Methods inherited from class eu.webtoolkit.jwt.WObject
getId, getObjectName, remove, setFormData, setObjectName, tr
-
Method Details
-
getModel
Returns theWAbstractItemModel
. -
getSelectedIndexes
Returns the set of selected items.The model indexes are returned as a set, topologically ordered (in the order they appear in the view).
When selection operates on rows (
SelectionBehavior.Rows
), this method only returns the model index of first column's element of the selected rows. -
isSelected
Returns wheter an item is selected.When selection operates on rows (
SelectionBehavior.Rows
), this method returns true for each element in a selected row.- See Also:
-
setSelectionBehavior
Sets the selection behaviour.By default, the selection contains rows (
SelectionBehavior.Rows
), in which case model indexes will always be have column 0, but represent the whole row.Alternatively, you can allow selection for individual items (
SelectionBehavior.Items
). -
getSelectionBehavior
Returns the selection behaviour. -
getMimeType
Returns the selection mime type.This should return the mime type for the current selection, or an emtpy string if the selection cannot be dragged.
The default implementation returns the mime type based on
ItemDataRole.MimeType
data if all selected items indicate the same mime type, or the modelgetMimeType()
otherwise.If one or more items indicate that they cannot be dragged, then an empty string is returned.
-