![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
\inmodule QtCore More...
#include <qitemselectionmodel.h>
Public Member Functions | |
Q_CORE_EXPORT | QItemSelection (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
Constructs an empty selection. | |
Q_CORE_EXPORT void | select (const QModelIndex &topLeft, const QModelIndex &bottomRight) |
Adds the items in the range that extends from the top-left model item, specified by the topLeft index, to the bottom-right item, specified by bottomRight to the list. | |
Q_CORE_EXPORT bool | contains (const QModelIndex &index) const |
Returns true if the selection contains the given index; otherwise returns false . | |
Q_CORE_EXPORT QModelIndexList | indexes () const |
Returns a list of model indexes that correspond to the selected items. | |
Q_CORE_EXPORT void | merge (const QItemSelection &other, QItemSelectionModel::SelectionFlags command) |
Merges the other selection with this QItemSelection using the command given. | |
Public Member Functions inherited from QList< QItemSelectionRange > | |
DataPointer & | data_ptr () & |
QList (DataPointer dd) noexcept | |
QList< QItemSelectionRange > & | operator= (std::initializer_list< QItemSelectionRange > args) |
void | swap (QList &other) noexcept |
QTypeTraits::compare_eq_result_container< QList, U > | operator== (const QList &other) const |
QTypeTraits::compare_eq_result_container< QList, U > | operator!= (const QList &other) const |
QTypeTraits::compare_lt_result_container< QList, U > | operator< (const QList &other) const noexcept(noexcept(std::lexicographical_compare< typename QList< U >::const_iterator, typename QList::const_iterator >(std::declval< QList< U > >().begin(), std::declval< QList< U > >().end(), other.begin(), other.end()))) |
QTypeTraits::compare_lt_result_container< QList, U > | operator> (const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >())) |
QTypeTraits::compare_lt_result_container< QList, U > | operator<= (const QList &other) const noexcept(noexcept(other< std::declval< QList< U > >())) |
QTypeTraits::compare_lt_result_container< QList, U > | operator>= (const QList &other) const noexcept(noexcept(std::declval< QList< U > >()< other)) |
constexpr qsizetype | size () const noexcept |
constexpr qsizetype | count () const noexcept |
constexpr qsizetype | length () const noexcept |
constexpr bool | isEmpty () const noexcept |
void | resize (qsizetype size) |
void | resizeForOverwrite (qsizetype size) |
qsizetype | capacity () const |
void | reserve (qsizetype size) |
void | squeeze () |
void | detach () |
bool | isDetached () const noexcept |
bool | isSharedWith (const QList< QItemSelectionRange > &other) const |
pointer | data () |
const_pointer | constData () const noexcept |
void | clear () |
const_reference | at (qsizetype i) const noexcept |
reference | operator[] (qsizetype i) |
void | append (parameter_type t) |
void | prepend (rvalue_ref t) |
reference | emplaceBack (Args &&... args) |
reference | emplaceFront (Args &&... args) |
iterator | insert (qsizetype i, parameter_type t) |
QList & | assign (qsizetype n, parameter_type t) |
iterator | emplace (const_iterator before, Args &&... args) |
void | replace (qsizetype i, parameter_type t) |
void | remove (qsizetype i, qsizetype n=1) |
void | removeFirst () noexcept |
void | removeLast () noexcept |
value_type | takeFirst () |
value_type | takeLast () |
QList< QItemSelectionRange > & | fill (parameter_type t, qsizetype size=-1) |
void | removeAt (qsizetype i) |
qsizetype | removeAll (const AT &t) |
bool | removeOne (const AT &t) |
qsizetype | removeIf (Predicate pred) |
QItemSelectionRange | takeAt (qsizetype i) |
void | move (qsizetype from, qsizetype to) |
iterator | begin () |
iterator | end () |
const_iterator | cbegin () const noexcept |
const_iterator | cend () const noexcept |
const_iterator | constBegin () const noexcept |
const_iterator | constEnd () const noexcept |
reverse_iterator | rbegin () |
reverse_iterator | rend () |
const_reverse_iterator | crbegin () const noexcept |
const_reverse_iterator | crend () const noexcept |
iterator | erase (const_iterator begin, const_iterator end) |
QItemSelectionRange & | first () |
const QItemSelectionRange & | constFirst () const noexcept |
QItemSelectionRange & | last () |
const QItemSelectionRange & | constLast () const noexcept |
bool | startsWith (parameter_type t) const |
bool | endsWith (parameter_type t) const |
QList< QItemSelectionRange > | mid (qsizetype pos, qsizetype len=-1) const |
QList< QItemSelectionRange > | sliced (qsizetype pos) const |
QItemSelectionRange | value (qsizetype i) const |
void | swapItemsAt (qsizetype i, qsizetype j) |
void | push_back (parameter_type t) |
void | push_front (rvalue_ref t) |
void | pop_back () noexcept |
void | pop_front () noexcept |
reference | emplace_back (Args &&... args) |
bool | empty () const noexcept |
reference | front () |
reference | back () |
void | shrink_to_fit () |
constexpr qsizetype | max_size () const noexcept |
QList< QItemSelectionRange > & | operator+= (const QList< QItemSelectionRange > &l) |
QList< QItemSelectionRange > | operator+ (const QList< QItemSelectionRange > &l) const & |
QList< QItemSelectionRange > & | operator<< (parameter_type t) |
QList< QItemSelectionRange > | toList () const noexcept |
QList< QItemSelectionRange > | toVector () const noexcept |
Public Member Functions inherited from QListSpecialMethodsBase< QItemSelectionRange > | |
qsizetype | indexOf (const AT &t, qsizetype from=0) const noexcept |
qsizetype | lastIndexOf (const AT &t, qsizetype from=-1) const noexcept |
bool | contains (const AT &t) const noexcept |
Static Public Member Functions | |
static Q_CORE_EXPORT void | split (const QItemSelectionRange &range, const QItemSelectionRange &other, QItemSelection *result) |
Splits the selection range using the selection other range. | |
Static Public Member Functions inherited from QList< QItemSelectionRange > | |
static constexpr qsizetype | maxSize () |
static QList< QItemSelectionRange > | fromList (const QList< QItemSelectionRange > &list) noexcept |
static QList< QItemSelectionRange > | fromVector (const QList< QItemSelectionRange > &vector) noexcept |
static QList< QItemSelectionRange > | fromReadOnlyData (const QItemSelectionRange(&t)[N]) noexcept |
Additional Inherited Members | |
Public Types inherited from QList< QItemSelectionRange > | |
using | Type |
using | value_type |
using | pointer |
using | const_pointer |
using | reference |
using | const_reference |
using | size_type |
using | difference_type |
using | parameter_type |
using | rvalue_ref |
using | Iterator |
using | ConstIterator |
using | reverse_iterator |
using | const_reverse_iterator |
Protected Types inherited from QListSpecialMethodsBase< QItemSelectionRange > | |
using | Self |
Protected Member Functions inherited from QListSpecialMethods< QItemSelectionRange > | |
QListSpecialMethods ()=default | |
Protected Member Functions inherited from QListSpecialMethodsBase< QItemSelectionRange > | |
QListSpecialMethodsBase ()=default | |
Self * | self () |
\inmodule QtCore
The QItemSelection class manages information about selected items in a model.
A QItemSelection describes the items in a model that have been selected by the user. A QItemSelection is basically a list of selection ranges, see QItemSelectionRange. It provides functions for creating and manipulating selections, and selecting a range of items from a model.
The QItemSelection class is one of the \l{Model/View Classes} and is part of Qt's \l{Model/View Programming}{model/view framework}.
An item selection can be constructed and initialized to contain a range of items from an existing model. The following example constructs a selection that contains a range of items from the given model
, beginning at the topLeft
, and ending at the bottomRight
.
An empty item selection can be constructed, and later populated as required. So, if the model is going to be unavailable when we construct the item selection, we can rewrite the above code in the following way:
QItemSelection saves memory, and avoids unnecessary work, by working with selection ranges rather than recording the model item index for each item in the selection. Generally, an instance of this class will contain a list of non-overlapping selection ranges.
Use merge() to merge one item selection into another without making overlapping ranges. Use split() to split one selection range into smaller ranges based on a another selection range.
Definition at line 179 of file qitemselectionmodel.h.
QItemSelection::QItemSelection | ( | const QModelIndex & | topLeft, |
const QModelIndex & | bottomRight ) |
Constructs an empty selection.
Constructs an item selection that extends from the top-left model item, specified by the topLeft index, to the bottom-right item, specified by bottomRight.
Definition at line 423 of file qitemselectionmodel.cpp.
bool QItemSelection::contains | ( | const QModelIndex & | index | ) | const |
Returns true
if the selection contains the given index; otherwise returns false
.
Definition at line 463 of file qitemselectionmodel.cpp.
QModelIndexList QItemSelection::indexes | ( | ) | const |
Returns a list of model indexes that correspond to the selected items.
Definition at line 474 of file qitemselectionmodel.cpp.
void QItemSelection::merge | ( | const QItemSelection & | other, |
QItemSelectionModel::SelectionFlags | command ) |
Merges the other selection with this QItemSelection using the command given.
This method guarantees that no ranges are overlapping.
Note that only QItemSelectionModel::Select, QItemSelectionModel::Deselect, and QItemSelectionModel::Toggle are supported.
Definition at line 497 of file qitemselectionmodel.cpp.
void QItemSelection::select | ( | const QModelIndex & | topLeft, |
const QModelIndex & | bottomRight ) |
Adds the items in the range that extends from the top-left model item, specified by the topLeft index, to the bottom-right item, specified by bottomRight to the list.
Definition at line 435 of file qitemselectionmodel.cpp.
|
static |
Splits the selection range using the selection other range.
Removes all items in other from range and puts the result in result. This can be compared with the semantics of the subtract operation of a set.
Definition at line 551 of file qitemselectionmodel.cpp.