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
QItemSelectionRange Class Reference

\inmodule QtCore More...

#include <qitemselectionmodel.h>

+ Collaboration diagram for QItemSelectionRange:

Public Member Functions

 QItemSelectionRange ()=default
 Constructs an empty selection range.
 
 QItemSelectionRange (const QModelIndex &topL, const QModelIndex &bottomR)
 Constructs a new selection range containing only the index specified by the topLeft and the index bottomRight.
 
 QItemSelectionRange (const QModelIndex &index)
 Constructs a new selection range containing only the model item specified by the model index index.
 
void swap (QItemSelectionRange &other) noexcept
 
int top () const
 Returns the row index corresponding to the uppermost selected row in the selection range.
 
int left () const
 Returns the column index corresponding to the leftmost selected column in the selection range.
 
int bottom () const
 Returns the row index corresponding to the lowermost selected row in the selection range.
 
int right () const
 Returns the column index corresponding to the rightmost selected column in the selection range.
 
int width () const
 Returns the number of selected columns in the selection range.
 
int height () const
 Returns the number of selected rows in the selection range.
 
const QPersistentModelIndextopLeft () const
 Returns the index for the item located at the top-left corner of the selection range.
 
const QPersistentModelIndexbottomRight () const
 Returns the index for the item located at the bottom-right corner of the selection range.
 
QModelIndex parent () const
 Returns the parent model item index of the items in the selection range.
 
const QAbstractItemModelmodel () const
 Returns the model that the items in the selection range belong to.
 
bool contains (const QModelIndex &index) const
 Returns true if the model item specified by the index lies within the range of selected items; otherwise returns false.
 
bool contains (int row, int column, const QModelIndex &parentIndex) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the model item specified by (row, column) and with parentIndex as the parent item lies within the range of selected items; otherwise returns false.
 
bool intersects (const QItemSelectionRange &other) const
 Returns true if this selection range intersects (overlaps with) the other range given; otherwise returns false.
 
QItemSelectionRange intersected (const QItemSelectionRange &other) const
 
bool isValid () const
 Returns true if the selection range is valid; otherwise returns false.
 
bool isEmpty () const
 Returns true if the selection range contains either no items or only items which are either disabled or marked as not selectable.
 
QModelIndexList indexes () const
 Returns the list of model index items stored in the selection.
 

Friends

bool comparesEqual (const QItemSelectionRange &lhs, const QItemSelectionRange &rhs) noexcept
 

Detailed Description

\inmodule QtCore

The QItemSelectionRange class manages information about a range of selected items in a model.

\compares equality

A QItemSelectionRange contains information about a range of selected items in a model. A range of items is a contiguous array of model items, extending to cover a number of adjacent rows and columns with a common parent item; this can be visualized as a two-dimensional block of cells in a table. A selection range has a top(), left() a bottom(), right() and a parent().

The QItemSelectionRange class is one of the \l{Model/View Classes} and is part of Qt's \l{Model/View Programming}{model/view framework}.

The model items contained in the selection range can be obtained using the indexes() function. Use QItemSelectionModel::selectedIndexes() to get a list of all selected items for a view.

You can determine whether a given model item lies within a particular range by using the contains() function. Ranges can also be compared using the overloaded operators for equality and inequality, and the intersects() function allows you to determine whether two ranges overlap.

See also
{Model/View Programming}, QAbstractItemModel, QItemSelection, QItemSelectionModel

Definition at line 17 of file qitemselectionmodel.h.

Constructor & Destructor Documentation

◆ QItemSelectionRange() [1/3]

QItemSelectionRange::QItemSelectionRange ( )
default

Constructs an empty selection range.

Referenced by intersected().

+ Here is the caller graph for this function:

◆ QItemSelectionRange() [2/3]

QItemSelectionRange::QItemSelectionRange ( const QModelIndex & topL,
const QModelIndex & bottomR )
inline

Constructs a new selection range containing only the index specified by the topLeft and the index bottomRight.

Definition at line 22 of file qitemselectionmodel.h.

◆ QItemSelectionRange() [3/3]

QItemSelectionRange::QItemSelectionRange ( const QModelIndex & index)
inlineexplicit

Constructs a new selection range containing only the model item specified by the model index index.

Definition at line 23 of file qitemselectionmodel.h.

Member Function Documentation

◆ bottom()

int QItemSelectionRange::bottom ( ) const
inline

Returns the row index corresponding to the lowermost selected row in the selection range.

Definition at line 33 of file qitemselectionmodel.h.

Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().

+ Here is the caller graph for this function:

◆ bottomRight()

QModelIndex QItemSelectionRange::bottomRight ( ) const
inline

Returns the index for the item located at the bottom-right corner of the selection range.

See also
bottom(), right(), topLeft()

Definition at line 39 of file qitemselectionmodel.h.

Referenced by intersected().

+ Here is the caller graph for this function:

◆ contains() [1/2]

bool QItemSelectionRange::contains ( const QModelIndex & index) const
inline

Returns true if the model item specified by the index lies within the range of selected items; otherwise returns false.

Definition at line 43 of file qitemselectionmodel.h.

◆ contains() [2/2]

bool QItemSelectionRange::contains ( int row,
int column,
const QModelIndex & parentIndex ) const
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the model item specified by (row, column) and with parentIndex as the parent item lies within the range of selected items; otherwise returns false.

Definition at line 50 of file qitemselectionmodel.h.

References QModelIndex::row().

+ Here is the call graph for this function:

◆ height()

int QItemSelectionRange::height ( ) const
inline

Returns the number of selected rows in the selection range.

Definition at line 36 of file qitemselectionmodel.h.

◆ indexes()

QModelIndexList QItemSelectionRange::indexes ( ) const

Returns the list of model index items stored in the selection.

Definition at line 317 of file qitemselectionmodel.cpp.

References indexesFromRange().

+ Here is the call graph for this function:

◆ intersected()

QItemSelectionRange QItemSelectionRange::intersected ( const QItemSelectionRange & other) const
Since
4.2

Returns a new selection range containing only the items that are found in both the selection range and the other selection range.

Definition at line 206 of file qitemselectionmodel.cpp.

References QItemSelectionRange(), bottom(), bottomRight(), QAbstractItemModel::index(), left(), model(), other(), parent(), qMax(), qMin(), right(), top(), and topLeft().

Referenced by QQmlItemSelectionRangeValueType::intersected().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ intersects()

bool QItemSelectionRange::intersects ( const QItemSelectionRange & other) const

Returns true if this selection range intersects (overlaps with) the other range given; otherwise returns false.

Definition at line 185 of file qitemselectionmodel.cpp.

References model, and other().

Referenced by QItemSelectionModel::emitSelectionChanged().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isEmpty()

bool QItemSelectionRange::isEmpty ( ) const

Returns true if the selection range contains either no items or only items which are either disabled or marked as not selectable.

Since
4.7

Definition at line 298 of file qitemselectionmodel.cpp.

References bottom(), QAbstractItemModel::index(), isSelectableAndEnabled(), isValid(), left(), model(), parent(), right(), and top().

+ Here is the call graph for this function:

◆ isValid()

bool QItemSelectionRange::isValid ( ) const
inline

Returns true if the selection range is valid; otherwise returns false.

Definition at line 66 of file qitemselectionmodel.h.

Referenced by isEmpty().

+ Here is the caller graph for this function:

◆ left()

int QItemSelectionRange::left ( ) const
inline

Returns the column index corresponding to the leftmost selected column in the selection range.

Definition at line 32 of file qitemselectionmodel.h.

Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().

+ Here is the caller graph for this function:

◆ model()

const QAbstractItemModel * QItemSelectionRange::model ( ) const
inline

Returns the model that the items in the selection range belong to.

Definition at line 41 of file qitemselectionmodel.h.

Referenced by intersected(), and isEmpty().

+ Here is the caller graph for this function:

◆ parent()

QModelIndex QItemSelectionRange::parent ( ) const
inline

Returns the parent model item index of the items in the selection range.

Definition at line 40 of file qitemselectionmodel.h.

References QModelIndex::parent().

Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ right()

int QItemSelectionRange::right ( ) const
inline

Returns the column index corresponding to the rightmost selected column in the selection range.

Definition at line 34 of file qitemselectionmodel.h.

Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().

+ Here is the caller graph for this function:

◆ swap()

QItemSelectionRange::swap ( QItemSelectionRange & other)
inlinenoexcept
Since
5.6

Swaps this selection range's contents with other. This function is very fast and never fails.

Definition at line 25 of file qitemselectionmodel.h.

References other().

+ Here is the call graph for this function:

◆ top()

int QItemSelectionRange::top ( ) const
inline

Returns the row index corresponding to the uppermost selected row in the selection range.

Definition at line 31 of file qitemselectionmodel.h.

Referenced by QItemSelectionModelPrivate::expandSelection(), intersected(), and isEmpty().

+ Here is the caller graph for this function:

◆ topLeft()

QModelIndex QItemSelectionRange::topLeft ( ) const
inline

Returns the index for the item located at the top-left corner of the selection range.

See also
top(), left(), bottomRight()

Definition at line 38 of file qitemselectionmodel.h.

Referenced by intersected().

+ Here is the caller graph for this function:

◆ width()

int QItemSelectionRange::width ( ) const
inline

Returns the number of selected columns in the selection range.

Definition at line 35 of file qitemselectionmodel.h.

Friends And Related Symbol Documentation

◆ comparesEqual

bool comparesEqual ( const QItemSelectionRange & lhs,
const QItemSelectionRange & rhs )
friend

Definition at line 77 of file qitemselectionmodel.h.


The documentation for this class was generated from the following files: