Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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 \instantiates 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 QModelIndexList ItemSelectionModel::selectedIndexes
45 \readonly
46
47 Contains the list of all the indexes in the selection model.
48*/
49
50/*!
51 \qmlmethod bool ItemSelectionModel::isSelected(QModelIndex index)
52
53 Returns \c true if the given model item \a index is selected.
54*/
55
56/*!
57 \qmlmethod bool ItemSelectionModel::isRowSelected(int row, QModelIndex parent)
58
59 Returns \c true if all items are selected in the \a row with the given
60 \a parent.
61
62 Note that this function is usually faster than calling isSelected()
63 on all items in the same row, and that unselectable items are ignored.
64*/
65
66/*!
67 \qmlmethod bool ItemSelectionModel::isColumnSelected(int column, QModelIndex parent)
68
69 Returns \c true if all items are selected in the \a column with the given
70 \a parent.
71
72 Note that this function is usually faster than calling isSelected()
73 on all items in the same column, and that unselectable items are ignored.
74*/
75
76/*!
77 \qmlmethod bool ItemSelectionModel::rowIntersectsSelection(int row, QModelIndex parent)
78
79 Returns \c true if there are any items selected in the \a row with the
80 given \a parent.
81*/
82
83/*!
84 \qmlmethod bool ItemSelectionModel::columnIntersectsSelection(int column, QModelIndex parent)
85
86 Returns \c true if there are any items selected in the \a column with the
87 given \a parent.
88*/
89
90/*!
91 \qmlmethod QModelIndexList ItemSelectionModel::selectedRows(int column)
92
93 Returns the indexes in the given \a column for the rows where all columns
94 are selected.
95
96 \sa selectedColumns()
97*/
98
99/*!
100 \qmlmethod QModelIndexList ItemSelectionModel::selectedColumns(int row)
101
102 Returns the indexes in the given \a row for columns where all rows are
103 selected.
104
105 \sa selectedRows()
106*/
107
108/*!
109 \qmlproperty object ItemSelectionModel::selection
110 \readonly
111
112 Holds the selection ranges stored in the selection model.
113*/
114
115/*!
116 \qmlmethod void ItemSelectionModel::setCurrentIndex(QModelIndex index, SelectionFlags command)
117
118 Sets the model item \a index to be the current item, and emits
119 currentChanged(). The current item is used for keyboard navigation and
120 focus indication; it is independent of any selected items, although a
121 selected item can also be the current item.
122
123 Depending on the specified \a command, the \a index can also become part
124 of the current selection.
125
126 Valid \a command values are described in \l {itemselectionmodelselectindex}
127 {select(\e index, \e command)}.
128
129 \sa select()
130*/
131
132/*!
133 \qmlmethod void ItemSelectionModel::select(QModelIndex index, SelectionFlags command)
134 \keyword itemselectionmodelselectindex
135
136 Selects the model item \a index using the specified \a command, and emits
137 selectionChanged().
138
139 Valid values for the \a command parameter, are:
140
141 \value NoUpdate No selection will be made.
142 \value Clear The complete selection will be cleared.
143 \value Select All specified indexes will be selected.
144 \value Deselect All specified indexes will be deselected.
145 \value Toggle All specified indexes will be selected or
146 deselected depending on their current state.
147 \value Current The current selection will be updated.
148 \value Rows All indexes will be expanded to span rows.
149 \value Columns All indexes will be expanded to span columns.
150 \value SelectCurrent A combination of Select and Current, provided for
151 convenience.
152 \value ToggleCurrent A combination of Toggle and Current, provided for
153 convenience.
154 \value ClearAndSelect A combination of Clear and Select, provided for
155 convenience.
156*/
157
158/*!
159 \qmlmethod void ItemSelectionModel::select(QItemSelection selection, SelectionFlags command)
160
161 Selects the item \a selection using the specified \a command, and emits
162 selectionChanged().
163
164 Valid \a command values are described in \l {itemselectionmodelselectindex}
165 {select(\e index, \e command)}.
166*/
167
168/*!
169 \qmlmethod void ItemSelectionModel::clear()
170
171 Clears the selection model. Emits selectionChanged() and currentChanged().
172*/
173
174/*!
175 \qmlmethod void ItemSelectionModel::reset()
176
177 Clears the selection model. Does not emit any signals.
178*/
179
180/*!
181 \qmlmethod void ItemSelectionModel::clearSelection()
182
183 Clears the selection in the selection model. Emits selectionChanged().
184*/
185
186/*!
187 \qmlmethod void ItemSelectionModel::clearCurrentIndex()
188
189 Clears the current index. Emits currentChanged().
190*/
191
192/*!
193 \qmlsignal ItemSelectionModel::selectionChanged(QItemSelection selected, QItemSelection deselected)
194
195 This signal is emitted whenever the selection changes. The change in the
196 selection is represented as an item selection of \a deselected items and
197 an item selection of \a selected items.
198
199 Note the that the current index changes independently from the selection.
200 Also note that this signal will not be emitted when the item model is reset.
201
202 \sa select(), currentChanged()
203*/
204
205/*!
206 \qmlsignal ItemSelectionModel::currentChanged(QModelIndex current, QModelIndex previous)
207
208 This signal is emitted whenever the current item changes. The \a previous
209 model item index is replaced by the \a current index as the selection's
210 current item.
211
212 Note that this signal will not be emitted when the item model is reset.
213
214 \sa currentIndex, setCurrentIndex(), selectionChanged()
215*/