diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2015-01-29 12:02:10 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2015-02-05 18:31:21 +0000 |
commit | f246e380c373e74ff8a039c7ae057da6c0e6e395 (patch) | |
tree | 331060b777133b1a6cbbc1fdbd84242d00ac3b4f /src/corelib/itemmodels/qabstractitemmodel.cpp | |
parent | 91ee17dce350790b53653c197ebafef670150f8e (diff) |
QAbstractTableModel/QAbstractListModel: reimplement sibling()
This basically inlines the call to parent(), which unconditionally
returns QModelIndex().
The change is binary compatible, because even though we newly
override a previously non-overridden virtual method, it doesn't
matter whether old code still calls the base class' method, as
the new implementation is semantically equivalent, at least if
subclasses don't inherit parent() (but why would they).
[ChangeLog][QtCore][Important Behavior Changes] QAbstractTableModel
and QAbstractListModel now reimplement sibling() to avoid calling
parent() (which returns a constant). Subclasses of these models
that override parent(), will likely also need to override sibling()
now.
Change-Id: I9e0cb5622a6d3826e40acaf0e0cd3fdea85cba2d
Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index 88e39f9441..43b51bcaf5 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -3345,6 +3345,14 @@ QModelIndex QAbstractTableModel::parent(const QModelIndex &) const return QModelIndex(); } +/*! + \reimp +*/ +QModelIndex QAbstractTableModel::sibling(int row, int column, const QModelIndex &) const +{ + return index(row, column); +} + bool QAbstractTableModel::hasChildren(const QModelIndex &parent) const { if (parent.model() == this || !parent.isValid()) @@ -3488,6 +3496,14 @@ QModelIndex QAbstractListModel::parent(const QModelIndex & /* index */) const /*! \reimp +*/ +QModelIndex QAbstractListModel::sibling(int row, int column, const QModelIndex &) const +{ + return index(row, column); +} + +/*! + \reimp */ Qt::ItemFlags QAbstractListModel::flags(const QModelIndex &index) const { |