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>
This commit is contained in:
parent
91ee17dce3
commit
f246e380c3
@ -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())
|
||||
@ -3486,6 +3494,14 @@ QModelIndex QAbstractListModel::parent(const QModelIndex & /* index */) const
|
||||
return QModelIndex();
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
QModelIndex QAbstractListModel::sibling(int row, int column, const QModelIndex &) const
|
||||
{
|
||||
return index(row, column);
|
||||
}
|
||||
|
||||
/*!
|
||||
\reimp
|
||||
*/
|
||||
|
@ -417,6 +417,7 @@ public:
|
||||
~QAbstractTableModel();
|
||||
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
|
||||
|
||||
@ -442,6 +443,7 @@ public:
|
||||
~QAbstractListModel();
|
||||
|
||||
QModelIndex index(int row, int column = 0, const QModelIndex &parent = QModelIndex()) const Q_DECL_OVERRIDE;
|
||||
QModelIndex sibling(int row, int column, const QModelIndex &idx) const Q_DECL_OVERRIDE;
|
||||
bool dropMimeData(const QMimeData *data, Qt::DropAction action,
|
||||
int row, int column, const QModelIndex &parent) Q_DECL_OVERRIDE;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user