Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlitemselectionmodel.qdoc
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \qmltype ItemSelectionModel
6 \nativetype QItemSelectionModel
7 \inqmlmodule QtQml.Models
8 \since 5.5
9 \ingroup qtquick-models
10
11 \brief Instantiates a QItemSelectionModel to be used in conjunction
12 with a QAbstractItemModel and any view supporting it.
13
14 \sa QItemSelectionModel, {Models and Views in Qt Quick}
15*/
16
17
18/*!
19 \qmlproperty QAbstractItemModel ItemSelectionModel::model
20
21 This property's value must match the view's model.
22*/
23
24/*!
25 \qmlproperty bool ItemSelectionModel::hasSelection
26 \readonly
27
28 It will trigger property binding updates every time \l selectionChanged()
29 is emitted, even though its value hasn't changed.
30
31 \sa selection, selectedIndexes, select(), selectionChanged()
32*/
33
34/*!
35 \qmlproperty QModelIndex ItemSelectionModel::currentIndex
36 \readonly
37
38 Use \l setCurrentIndex() to set its value.
39
40 \sa setCurrentIndex(), currentChanged()
41*/
42
43/*!
44 \qmlproperty list<var> ItemSelectionModel::selectedIndexes
45 \readonly
46
47 Contains the list of all the indexes (QModelIndex instances) in
48 the selection model.
49
50 \sa {QModelIndexList Type}
51*/
52
53/*!
54 \qmlmethod bool ItemSelectionModel::isSelected(QModelIndex index)
55
56 Returns \c true if the given model item \a index is selected.
57*/
58
59/*!
60 \qmlmethod bool ItemSelectionModel::isRowSelected(int row, QModelIndex parent)
61
62 Returns \c true if all items are selected in the \a row with the given
63 \a parent.
64
65 Note that this function is usually faster than calling isSelected()
66 on all items in the same row, and that unselectable items are ignored.
67*/
68
69/*!
70 \qmlmethod bool ItemSelectionModel::isColumnSelected(int column, QModelIndex parent)
71
72 Returns \c true if all items are selected in the \a column with the given
73 \a parent.
74
75 Note that this function is usually faster than calling isSelected()
76 on all items in the same column, and that unselectable items are ignored.
77*/
78
79/*!
80 \qmlmethod bool ItemSelectionModel::rowIntersectsSelection(int row, QModelIndex parent)
81
82 Returns \c true if there are any items selected in the \a row with the
83 given \a parent.
84*/
85
86/*!
87 \qmlmethod bool ItemSelectionModel::columnIntersectsSelection(int column, QModelIndex parent)
88
89 Returns \c true if there are any items selected in the \a column with the
90 given \a parent.
91*/
92
93/*!
94 \qmlmethod list<var> ItemSelectionModel::selectedRows(int column)
95
96 Returns the indexes (a list of QModelIndex instances) in the given \a column
97 for the rows where all columns are selected.
98
99 \sa selectedColumns(), {QModelIndexList Type}
100*/
101
102/*!
103 \qmlmethod list<var> ItemSelectionModel::selectedColumns(int row)
104
105 Returns the indexes (a list of QModelIndex instances) in the given \a row for
106 columns where all rows are selected.
107
108 \sa selectedRows(), {QModelIndexList Type}
109*/
110
111/*!
112 \qmlproperty object ItemSelectionModel::selection
113 \readonly
114
115 Holds the selection ranges stored in the selection model.
116*/
117
118/*!
119 \qmlmethod void ItemSelectionModel::setCurrentIndex(QModelIndex index, SelectionFlags command)
120
121 Sets the model item \a index to be the current item, and emits
122 currentChanged(). The current item is used for keyboard navigation and
123 focus indication; it is independent of any selected items, although a
124 selected item can also be the current item.
125
126 Depending on the specified \a command, the \a index can also become part
127 of the current selection.
128
129 Valid \a command values are described in \l {itemselectionmodelselectindex}
130 {select(\e index, \e command)}.
131
132 \sa select()
133*/
134
135/*!
136 \qmlmethod void ItemSelectionModel::select(QModelIndex index, SelectionFlags command)
137 \keyword itemselectionmodelselectindex
138
139 Selects the model item \a index using the specified \a command, and emits
140 selectionChanged().
141
142 Valid values for the \a command parameter, are:
143
144 \value NoUpdate No selection will be made.
145 \value Clear The complete selection will be cleared.
146 \value Select All specified indexes will be selected.
147 \value Deselect All specified indexes will be deselected.
148 \value Toggle All specified indexes will be selected or
149 deselected depending on their current state.
150 \value Current The current selection will be updated.
151 \value Rows All indexes will be expanded to span rows.
152 \value Columns All indexes will be expanded to span columns.
153 \value SelectCurrent A combination of Select and Current, provided for
154 convenience.
155 \value ToggleCurrent A combination of Toggle and Current, provided for
156 convenience.
157 \value ClearAndSelect A combination of Clear and Select, provided for
158 convenience.
159*/
160
161/*!
162 \qmlmethod void ItemSelectionModel::select(QItemSelection selection, SelectionFlags command)
163
164 Selects the item \a selection using the specified \a command, and emits
165 selectionChanged().
166
167 Valid \a command values are described in \l {itemselectionmodelselectindex}
168 {select(\e index, \e command)}.
169*/
170
171/*!
172 \qmlmethod void ItemSelectionModel::clear()
173
174 Clears the selection model. Emits selectionChanged() and currentChanged().
175*/
176
177/*!
178 \qmlmethod void ItemSelectionModel::reset()
179
180 Clears the selection model. Does not emit any signals.
181*/
182
183/*!
184 \qmlmethod void ItemSelectionModel::clearSelection()
185
186 Clears the selection in the selection model. Emits selectionChanged().
187*/
188
189/*!
190 \qmlmethod void ItemSelectionModel::clearCurrentIndex()
191
192 Clears the current index. Emits currentChanged().
193*/
194
195/*!
196 \qmlsignal ItemSelectionModel::selectionChanged(QItemSelection selected, QItemSelection deselected)
197
198 This signal is emitted whenever the selection changes. The change in the
199 selection is represented as an item selection of \a deselected items and
200 an item selection of \a selected items.
201
202 Note the that the current index changes independently from the selection.
203 Also note that this signal will not be emitted when the item model is reset.
204
205 \sa select(), currentChanged()
206*/
207
208/*!
209 \qmlsignal ItemSelectionModel::currentChanged(QModelIndex current, QModelIndex previous)
210
211 This signal is emitted whenever the current item changes. The \a previous
212 model item index is replaced by the \a current index as the selection's
213 current item.
214
215 Note that this signal will not be emitted when the item model is reset.
216
217 \sa currentIndex, setCurrentIndex(), selectionChanged()
218*/