summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qabstractitemmodel.cpp
diff options
context:
space:
mode:
authorAndre Somers <andre.somers@kdab.com>2018-01-03 10:24:06 +0100
committerAndre Somers <andre.somers@kdab.com>2018-01-12 15:12:53 +0000
commitabbd26f553f9c96649a23b71b1580a23933ba5ac (patch)
treea0e067305c7263d54dc778400e0c864d177a328a /src/corelib/itemmodels/qabstractitemmodel.cpp
parent7157d04d6e2ee024519b3bdea1203a26e2cd41b8 (diff)
Add QModelIndex::siblingAtColumn and ::siblingAtRow
Data in item models is most often organized in rows, where each column contains an attribute of the item represented by the row. Often when sibling is used, it is to request another piece of data from the same row. Having a specialized version makes this easier and less awkward to do, simplifying auto sibling = index.sibling(index.row(), columnOfInterest); to auto sibling = index.siblingAtColumn(columnOfInterest); For symmetry reasons, siblingAtRow(rowOfInterest) was also added. Change-Id: Ib203b2cdb16154cbb2680d16fb5c6a7538f33d07 Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io> Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index af87f56255..758ac4bba6 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -1108,7 +1108,27 @@ void QAbstractItemModel::resetInternalData()
Returns the sibling at \a row and \a column. If there is no sibling at this
position, an invalid QModelIndex is returned.
- \sa parent()
+ \sa parent(), siblingAtColumn(), siblingAtRow()
+*/
+
+/*!
+ \fn QModelIndex QModelIndex::siblingAtColumn(int column) const
+
+ Returns the sibling at \a column for the current row. If there is no sibling
+ at this position, an invalid QModelIndex is returned.
+
+ \sa sibling(), siblingAtRow()
+ \since 5.11
+*/
+
+/*!
+ \fn QModelIndex QModelIndex::siblingAtRow(int row) const
+
+ Returns the sibling at \a row for the current column. If there is no sibling
+ at this position, an invalid QModelIndex is returned.
+
+ \sa sibling(), siblingAtColumn()
+ \since 5.11
*/
/*!