![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore More...
#include <qabstractitemmodel.h>
Public Member Functions | |
QPersistentModelIndex () | |
QPersistentModelIndex (const QModelIndex &index) | |
Creates a new QPersistentModelIndex that is a copy of the model index. | |
QPersistentModelIndex (const QPersistentModelIndex &other) | |
Creates a new QPersistentModelIndex that is a copy of the other persistent model index. | |
~QPersistentModelIndex () | |
bool | operator< (const QPersistentModelIndex &other) const |
bool | operator== (const QPersistentModelIndex &other) const |
Returns {true} if this persistent model index is equal to the other persistent model index; otherwise returns {false}. | |
bool | operator!= (const QPersistentModelIndex &other) const |
QPersistentModelIndex & | operator= (const QPersistentModelIndex &other) |
Sets the persistent model index to refer to the same item in a model as the other persistent model index. | |
QPersistentModelIndex (QPersistentModelIndex &&other) noexcept | |
Move-constructs a QPersistentModelIndex instance, making it point at the same object that other was pointing to. | |
void | swap (QPersistentModelIndex &other) noexcept |
bool | operator== (const QModelIndex &other) const |
Returns {true} if this persistent model index refers to the same location as the other model index; otherwise returns {false}. | |
bool | operator!= (const QModelIndex &other) const |
Returns {true} if this persistent model index does not refer to the same location as the other model index; otherwise returns {false}. | |
QPersistentModelIndex & | operator= (const QModelIndex &other) |
Sets the persistent model index to refer to the same item in a model as the other model index. | |
operator QModelIndex () const | |
Cast operator that returns a QModelIndex. | |
int | row () const |
Returns the row this persistent model index refers to. | |
int | column () const |
Returns the column this persistent model index refers to. | |
void * | internalPointer () const |
const void * | constInternalPointer () const |
quintptr | internalId () const |
QModelIndex | parent () const |
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no parent. | |
QModelIndex | sibling (int row, int column) const |
Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this position. | |
QVariant | data (int role=Qt::DisplayRole) const |
Returns the data for the given role for the item referred to by the index. | |
void | multiData (QModelRoleDataSpan roleDataSpan) const |
Populates the given roleDataSpan for the item referred to by the index. | |
Qt::ItemFlags | flags () const |
const QAbstractItemModel * | model () const |
Returns the model that the index belongs to. | |
bool | isValid () const |
Returns {true} if this persistent model index is valid; otherwise returns {false}. | |
Friends | |
size_t | qHash (const QPersistentModelIndex &, size_t seed) noexcept |
bool | qHashEquals (const QPersistentModelIndex &a, const QPersistentModelIndex &b) noexcept |
Q_CORE_EXPORT QDebug | operator<< (QDebug, const QPersistentModelIndex &) |
Related Symbols | |
(Note that these are not member symbols.) | |
size_t | qHash (const QPersistentModelIndex &index, size_t seed=0) |
\inmodule QtCore
The QPersistentModelIndex class is used to locate data in a data model.
A QPersistentModelIndex is a model index that can be stored by an application, and later used to access information in a model. Unlike the QModelIndex class, it is safe to store a QPersistentModelIndex since the model will ensure that references to items will continue to be valid as long as they can be accessed by the model.
It is good practice to check that persistent model indexes are valid before using them.
Definition at line 174 of file qabstractitemmodel.h.
QPersistentModelIndex::QPersistentModelIndex | ( | ) |
Definition at line 330 of file qabstractitemmodel.cpp.
QPersistentModelIndex::QPersistentModelIndex | ( | const QModelIndex & | index | ) |
Creates a new QPersistentModelIndex that is a copy of the model index.
Definition at line 352 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::create(), QPersistentModelIndexData::ref, and QBasicAtomicInteger< T >::ref().
QPersistentModelIndex::QPersistentModelIndex | ( | const QPersistentModelIndex & | other | ) |
Creates a new QPersistentModelIndex that is a copy of the other persistent model index.
Definition at line 342 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::ref, and QBasicAtomicInteger< T >::ref().
QPersistentModelIndex::~QPersistentModelIndex | ( | ) |
Definition at line 367 of file qabstractitemmodel.cpp.
References QBasicAtomicInteger< T >::deref(), QPersistentModelIndexData::destroy(), and QPersistentModelIndexData::ref.
|
inlinenoexcept |
Move-constructs a QPersistentModelIndex instance, making it point at the same object that other was pointing to.
Definition at line 186 of file qabstractitemmodel.h.
int QPersistentModelIndex::column | ( | ) | const |
Returns the column this persistent model index refers to.
Definition at line 518 of file qabstractitemmodel.cpp.
References QModelIndex::column(), and QPersistentModelIndexData::index.
Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(), QDataWidgetMapperPrivate::currentIdx(), mergeIndexes(), mergeRowLengths(), QTableViewPrivate::selectColumn(), and QItemSelectionModel::setCurrentIndex().
const void * QPersistentModelIndex::constInternalPointer | ( | ) | const |
Returns a {const void}
{*} pointer used by the model to associate the index with the internal data structure.
Definition at line 550 of file qabstractitemmodel.cpp.
References QModelIndex::constInternalPointer(), and QPersistentModelIndexData::index.
QVariant QPersistentModelIndex::data | ( | int | role = Qt::DisplayRole | ) | const |
Returns the data for the given role for the item referred to by the index.
Definition at line 606 of file qabstractitemmodel.cpp.
References QModelIndex::data(), and QPersistentModelIndexData::index.
Qt::ItemFlags QPersistentModelIndex::flags | ( | ) | const |
Returns the flags for the item referred to by the index.
Definition at line 632 of file qabstractitemmodel.cpp.
References QModelIndex::flags(), and QPersistentModelIndexData::index.
Referenced by QTreeView::collapseAll(), and QTreeView::expandToDepth().
quintptr QPersistentModelIndex::internalId | ( | ) | const |
Returns a {quintptr} used by the model to associate the index with the internal data structure.
Definition at line 566 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::internalId().
void * QPersistentModelIndex::internalPointer | ( | ) | const |
Returns a {void}
{*} pointer used by the model to associate the index with the internal data structure.
Definition at line 534 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::internalPointer().
bool QPersistentModelIndex::isValid | ( | ) | const |
Returns {true} if this persistent model index is valid; otherwise returns
{false}.
A valid index belongs to a model, and has non-negative row and column numbers.
Definition at line 661 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::isValid().
Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QListWidgetPrivate::_q_emitCurrentItemChanged(), QComboBoxPrivate::_q_returnPressed(), QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(), QComboBoxPrivate::_q_rowsInserted(), QComboBoxPrivate::_q_rowsRemoved(), QConcatenateTablesProxyModelPrivate::_q_slotSourceLayoutAboutToBeChanged(), QIdentityProxyModelPrivate::_q_sourceLayoutAboutToBeChanged(), QTreeView::collapseAll(), QQuickTableViewPrivate::columnsRemovedCallback(), QAbstractItemView::edit(), QQuickTableViewPrivate::editFromKeyEvent(), QTreeView::expandToDepth(), QAbstractItemView::keyPressEvent(), mergeIndexes(), mergeRowLengths(), QTreeView::mouseDoubleClickEvent(), QQuickTableViewPrivate::processLoadRequest(), QQuickTableViewPrivate::processRebuildTable(), QQuickTableViewPrivate::rowsRemovedCallback(), and QQmlTreeModelToTableModel::setModel().
const QAbstractItemModel * QPersistentModelIndex::model | ( | ) | const |
Returns the model that the index belongs to.
Definition at line 642 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::model().
Referenced by QQmlTreeModelToTableModel::setModel().
void QPersistentModelIndex::multiData | ( | QModelRoleDataSpan | roleDataSpan | ) | const |
Populates the given roleDataSpan for the item referred to by the index.
Definition at line 621 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::multiData().
QPersistentModelIndex::operator QModelIndex | ( | ) | const |
Cast operator that returns a QModelIndex.
Definition at line 463 of file qabstractitemmodel.cpp.
References d.
bool QPersistentModelIndex::operator!= | ( | const QModelIndex & | other | ) | const |
Returns {true} if this persistent model index does not refer to the same location as the other model index; otherwise returns
{false}.
Definition at line 492 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and other().
|
inline |
Returns {true} if this persistent model index is not equal to the other persistent model index; otherwise returns
{false}.
Definition at line 183 of file qabstractitemmodel.h.
References operator==(), and other().
bool QPersistentModelIndex::operator< | ( | const QPersistentModelIndex & | other | ) | const |
Returns {true} if this persistent model index is smaller than the other persistent model index; otherwise returns
{false}.
The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another persistent model index.
Definition at line 400 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and other().
QPersistentModelIndex & QPersistentModelIndex::operator= | ( | const QModelIndex & | other | ) |
Sets the persistent model index to refer to the same item in a model as the other model index.
Definition at line 444 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::create(), QBasicAtomicInteger< T >::deref(), QPersistentModelIndexData::destroy(), other(), QPersistentModelIndexData::ref, and QBasicAtomicInteger< T >::ref().
QPersistentModelIndex & QPersistentModelIndex::operator= | ( | const QPersistentModelIndex & | other | ) |
Sets the persistent model index to refer to the same item in a model as the other persistent model index.
Definition at line 421 of file qabstractitemmodel.cpp.
References QBasicAtomicInteger< T >::deref(), QPersistentModelIndexData::destroy(), other(), QPersistentModelIndexData::ref, and QBasicAtomicInteger< T >::ref().
bool QPersistentModelIndex::operator== | ( | const QModelIndex & | other | ) | const |
Returns {true} if this persistent model index refers to the same location as the other model index; otherwise returns
{false}.
The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another model index.
Definition at line 478 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and other().
bool QPersistentModelIndex::operator== | ( | const QPersistentModelIndex & | other | ) | const |
Returns {true} if this persistent model index is equal to the other persistent model index; otherwise returns
{false}.
The internal data pointer, row, column, and model values in the persistent model index are used when comparing with another persistent model index.
Definition at line 383 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and other().
QModelIndex QPersistentModelIndex::parent | ( | ) | const |
Returns the parent QModelIndex for this persistent index, or an invalid QModelIndex if it has no parent.
Definition at line 579 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::parent().
Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(), mergeIndexes(), mergeRowLengths(), qt_PersistentModelIndexLessThan(), QItemSelectionModel::setCurrentIndex(), and QSortFilterProxyModelPrivate::update_persistent_indexes().
int QPersistentModelIndex::row | ( | ) | const |
Returns the row this persistent model index refers to.
Definition at line 505 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::row().
Referenced by QItemSelectionModelPrivate::_q_columnsAboutToBeRemoved(), QComboBoxPrivate::_q_dataChanged(), QListWidgetPrivate::_q_emitCurrentItemChanged(), QComboBoxPrivate::_q_itemSelected(), QItemSelectionModelPrivate::_q_rowsAboutToBeRemoved(), QComboBoxPrivate::_q_rowsInserted(), QComboBoxPrivate::_q_rowsRemoved(), QComboBoxPrivate::_q_updateIndexBeforeChange(), QDataWidgetMapperPrivate::currentIdx(), mergeIndexes(), mergeRowLengths(), QTableViewPrivate::selectRow(), and QItemSelectionModel::setCurrentIndex().
QModelIndex QPersistentModelIndex::sibling | ( | int | row, |
int | column | ||
) | const |
Returns the sibling at row and column or an invalid QModelIndex if there is no sibling at this position.
Definition at line 593 of file qabstractitemmodel.cpp.
References QPersistentModelIndexData::index, and QModelIndex::sibling().
Referenced by mergeRowLengths().
|
inlinenoexcept |
Swaps this persistent modelindex with other. This function is very fast and never fails.
Definition at line 189 of file qabstractitemmodel.h.
References d, other(), and qt_ptr_swap().
|
friend |
Definition at line 675 of file qabstractitemmodel.cpp.
|
friend |
Returns a hash of the QPersistentModelIndex index, using seed to seed the calculation.
Definition at line 217 of file qabstractitemmodel.h.
|
related |
Returns a hash of the QPersistentModelIndex index, using seed to seed the calculation.
Definition at line 217 of file qabstractitemmodel.h.
|
friend |
Definition at line 209 of file qabstractitemmodel.h.