From 267ba8b63e0fbf02cde4d2709397ed0e12f34ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kundr=C3=A1t?= Date: Mon, 24 Mar 2014 19:17:43 +0100 Subject: QAbstractProxyModel::sibling: treat row/column as offsets within the proxy Qt5 allows QAIM subclasses to reimplement the sibling() method. Unfortunately, the default QAbstractProxyModel's reimplementation differs in behavior to what the Qt4 version was doing. In particular, the Qt4 version used to use the row and column as positions within the proxy model, while the Qt5 version mistakenly does this at the level of source model. This is arguably broken; the caller asks for a sibling of the proxy index, not for a sibling within the proxy model. This change makes the QAPM::sibling work explicitly in the same way as the Qt4 code behaved. The reimplementation of QAbstractProxyModel::sibling was introduced in 9dfba89c28bbff3316cb7aed6c07f90c0f2d5a22. It was subsequently fixed with commit 999109866dbd350a29cc70815d0c772545c85746 not to return indexes from the source model, but the logic was still different from the Qt4 version. [ChangeLog][QtCore][QAbstractProxyModel] Fixed QAbstractProxyModel::sibling to work in the same manner as the Qt4 code used to behave. Previously, Qt5's implementation would treat the row and column as positions in the source model instead of a position in the proxy itself. Followup-to 9dfba89c28bbff3316cb7aed6c07f90c0f2d5a22 and 999109866dbd350a29cc70815d0c772545c85746 Change-Id: Ia25027b2ad9e4777ba28de2d2226d48f8cccf587 Reviewed-by: Olivier Goffart Reviewed-by: Mark Brand Reviewed-by: Stephen Kelly --- src/corelib/itemmodels/qabstractproxymodel.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/itemmodels/qabstractproxymodel.cpp b/src/corelib/itemmodels/qabstractproxymodel.cpp index d435c4bcf5..2f1f4921f7 100644 --- a/src/corelib/itemmodels/qabstractproxymodel.cpp +++ b/src/corelib/itemmodels/qabstractproxymodel.cpp @@ -377,8 +377,7 @@ bool QAbstractProxyModel::hasChildren(const QModelIndex &parent) const */ QModelIndex QAbstractProxyModel::sibling(int row, int column, const QModelIndex &idx) const { - Q_D(const QAbstractProxyModel); - return mapFromSource(d->model->sibling(row, column, mapToSource(idx))); + return index(row, column, idx.parent()); } /*! -- cgit v1.2.3