Optimize QAbstractItemModel::sibling a bit.

QModelIndex::sibling has a simliar optimization.

Change-Id: Ic0717d480ba0d46a4c0c88064bc9eda4c4ffe6f6
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
bb10
Stephen Kelly 2012-08-22 16:11:20 +02:00 committed by Qt by Nokia
parent d45ef22158
commit 9f821f384b
1 changed files with 1 additions and 1 deletions

View File

@ -172,7 +172,7 @@ public:
virtual QModelIndex parent(const QModelIndex &child) const = 0;
inline QModelIndex sibling(int row, int column, const QModelIndex &idx) const
{ return index(row, column, parent(idx)); }
{ return (row == idx.row() && column == idx.column()) ? idx : index(row, column, parent(idx)); }
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const = 0;
virtual int columnCount(const QModelIndex &parent = QModelIndex()) const = 0;