TreeModel: Add a sibling() implementation

The base implementation uses the parent() index, which
in turn accesses the grand parent level. We can save
a few cycles here.

Change-Id: I3c3696118fe7c3d4563ee3cd28981fca62013828
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2017-04-04 12:45:49 +02:00
parent 0a5abdae59
commit 2aab5510ed
2 changed files with 13 additions and 0 deletions

View File

@@ -188,6 +188,7 @@ protected:
QVariant data(const QModelIndex &idx, int role) const override;
QModelIndex index(int, int, const QModelIndex &idx = QModelIndex()) const override;
QModelIndex parent(const QModelIndex &idx) const override;
QModelIndex sibling(int row, int column, const QModelIndex &idx) const override;
Qt::ItemFlags flags(const QModelIndex &idx) const override;
QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
bool hasChildren(const QModelIndex &idx) const override;