Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qitemselectionmodel.cpp File Reference
#include "qitemselectionmodel.h"
#include "qitemselectionmodel_p.h"
#include <private/qitemselectionmodel_p.h>
#include <private/qabstractitemmodel_p.h>
#include <private/qduplicatetracker_p.h>
#include <private/qoffsetstringarray_p.h>
#include <qdebug.h>
#include <algorithm>
#include <functional>
#include "moc_qitemselectionmodel.cpp"
+ Include dependency graph for qitemselectionmodel.cpp:

Go to the source code of this file.

Classes

struct  RowOrColumnDefinition
 

Namespaces

namespace  QtFunctionObjects
 

Functions

static void rowLengthsFromRange (const QItemSelectionRange &range, QList< QPair< QPersistentModelIndex, uint > > &result)
 
static bool isSelectableAndEnabled (Qt::ItemFlags flags)
 
template<typename ModelIndexContainer >
static void indexesFromRange (const QItemSelectionRange &range, ModelIndexContainer &result)
 
template<typename ModelIndexContainer >
static ModelIndexContainer qSelectionIndexes (const QItemSelection &selection)
 
static QList< QPair< QPersistentModelIndex, uint > > qSelectionPersistentRowLengths (const QItemSelection &sel)
 
static QItemSelection mergeRowLengths (const QList< QPair< QPersistentModelIndex, uint > > &rowLengths)
 
static QItemSelection mergeIndexes (const QList< QPersistentModelIndex > &indexes)
 
static bool qt_PersistentModelIndexLessThan (const QPersistentModelIndex &i1, const QPersistentModelIndex &i2)
 
static bool selectionIsEmpty (const QItemSelection &selection)
 
size_t qHash (const RowOrColumnDefinition &key, size_t seed=0) noexcept
 
QDebug operator<< (QDebug dbg, const QItemSelectionRange &range)
 

Function Documentation

◆ indexesFromRange()

template<typename ModelIndexContainer >
static void indexesFromRange ( const QItemSelectionRange range,
ModelIndexContainer &  result 
)
static

Definition at line 263 of file qitemselectionmodel.cpp.

References QModelIndex::column(), isSelectableAndEnabled(), QModelIndex::row(), and QModelIndex::sibling().

Referenced by QItemSelectionRange::indexes(), and qSelectionIndexes().

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

◆ isSelectableAndEnabled()

static bool isSelectableAndEnabled ( Qt::ItemFlags  flags)
static

Definition at line 257 of file qitemselectionmodel.cpp.

References Qt::ItemIsEnabled, and Qt::ItemIsSelectable.

Referenced by QItemSelectionModel::columnIntersectsSelection(), QItemSelection::contains(), indexesFromRange(), QItemSelectionModel::isColumnSelected(), QItemSelectionRange::isEmpty(), QItemSelectionModel::isRowSelected(), QItemSelectionModel::isSelected(), and QItemSelectionModel::rowIntersectsSelection().

+ Here is the caller graph for this function:

◆ mergeIndexes()

static QItemSelection mergeIndexes ( const QList< QPersistentModelIndex > &  indexes)
static

Merges indexes into an item selection made up of ranges. Assumes that the indexes are sorted.

Definition at line 914 of file qitemselectionmodel.cpp.

References QList< T >::append(), QList< T >::at(), QItemSelectionRange::bottomRight(), QPersistentModelIndex::column(), QModelIndex::column(), i, QPersistentModelIndex::isValid(), next, QModelIndex::parent(), QPersistentModelIndex::parent(), QPersistentModelIndex::row(), QModelIndex::row(), QList< T >::size(), and QItemSelectionRange::topLeft().

Referenced by QItemSelectionModelPrivate::_q_layoutChanged().

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

◆ mergeRowLengths()

static QItemSelection mergeRowLengths ( const QList< QPair< QPersistentModelIndex, uint > > &  rowLengths)
static

Definition at line 874 of file qitemselectionmodel.cpp.

References QPersistentModelIndex::column(), i, QPersistentModelIndex::isValid(), next, QPersistentModelIndex::parent(), QPersistentModelIndex::row(), and QPersistentModelIndex::sibling().

Referenced by QItemSelectionModelPrivate::_q_layoutChanged().

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

◆ operator<<()

QDebug operator<< ( QDebug  dbg,
const QItemSelectionRange range 
)

Definition at line 1965 of file qitemselectionmodel.cpp.

◆ qHash()

size_t qHash ( const RowOrColumnDefinition key,
size_t  seed = 0 
)
noexcept

Definition at line 1738 of file qitemselectionmodel.cpp.

References hash, and seed.

◆ qSelectionIndexes()

template<typename ModelIndexContainer >
static ModelIndexContainer qSelectionIndexes ( const QItemSelection selection)
static

Definition at line 281 of file qitemselectionmodel.cpp.

References indexesFromRange(), and selection.

+ Here is the call graph for this function:

◆ qSelectionPersistentRowLengths()

static QList< QPair< QPersistentModelIndex, uint > > qSelectionPersistentRowLengths ( const QItemSelection sel)
static

Definition at line 435 of file qitemselectionmodel.cpp.

References rowLengthsFromRange().

Referenced by QItemSelectionModelPrivate::_q_layoutAboutToBeChanged().

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

◆ qt_PersistentModelIndexLessThan()

static bool qt_PersistentModelIndexLessThan ( const QPersistentModelIndex i1,
const QPersistentModelIndex i2 
)
static

Sort predicate function for QItemSelectionModelPrivate::_q_layoutChanged(), sorting by parent first in addition to operator<(). This is to prevent fragmentation of the selection by grouping indexes with the same row, column of different parents next to each other, which may happen when a selection spans sub-trees.

Definition at line 985 of file qitemselectionmodel.cpp.

References QPersistentModelIndex::parent().

Referenced by QItemSelectionModelPrivate::_q_layoutChanged().

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

◆ rowLengthsFromRange()

static void rowLengthsFromRange ( const QItemSelectionRange range,
QList< QPair< QPersistentModelIndex, uint > > &  result 
)
static

Definition at line 241 of file qitemselectionmodel.cpp.

References QModelIndex::column(), qMakePair(), QModelIndex::row(), and QModelIndex::sibling().

Referenced by qSelectionPersistentRowLengths().

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

◆ selectionIsEmpty()

static bool selectionIsEmpty ( const QItemSelection selection)
static

Check whether the selection is empty. In contrast to selection.isEmpty(), this takes into account whether items are enabled and whether they are selectable.

Definition at line 1679 of file qitemselectionmodel.cpp.

References QList< T >::begin(), QList< T >::end(), and selection.

Referenced by QItemSelectionModel::hasSelection().

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