summaryrefslogtreecommitdiffstats
path: root/src/corelib/itemmodels/qabstractitemmodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp')
-rw-r--r--src/corelib/itemmodels/qabstractitemmodel.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp
index 4a266e4891..5f6fcc6fd9 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.cpp
+++ b/src/corelib/itemmodels/qabstractitemmodel.cpp
@@ -1394,19 +1394,6 @@ QAbstractItemModel::~QAbstractItemModel()
d_func()->invalidatePersistentIndexes();
}
-/*!
- \fn QModelIndex QAbstractItemModel::sibling(int row, int column, const QModelIndex &index) const
-
- Returns the sibling at \a row and \a column for the item at \a index, or an
- invalid QModelIndex if there is no sibling at that location.
-
- sibling() is just a convenience function that finds the item's parent, and
- uses it to retrieve the index of the child item in the specified \a row and
- \a column.
-
- \sa index(), QModelIndex::row(), QModelIndex::column()
-*/
-
/*!
\fn int QAbstractItemModel::rowCount(const QModelIndex &parent) const
@@ -1657,6 +1644,25 @@ bool QAbstractItemModel::hasChildren(const QModelIndex &parent) const
return (rowCount(parent) > 0) && (columnCount(parent) > 0);
}
+/*!
+ \fn QModelIndex QAbstractItemModel::sibling(int row, int column, const QModelIndex &index) const
+
+ Returns the sibling at \a row and \a column for the item at \a index, or an
+ invalid QModelIndex if there is no sibling at that location.
+
+ sibling() is just a convenience function that finds the item's parent, and
+ uses it to retrieve the index of the child item in the specified \a row and
+ \a column.
+
+ This method can optionally be overridden for implementation-specific optimization.
+
+ \sa index(), QModelIndex::row(), QModelIndex::column()
+*/
+QModelIndex QAbstractItemModel::sibling(int row, int column, const QModelIndex &idx) const
+{
+ return (row == idx.row() && column == idx.column()) ? idx : index(row, column, parent(idx));
+}
+
/*!
Returns a map with values for all predefined roles in the model for the