diff options
author | Liang Qi <liang.qi@qt.io> | 2019-03-31 12:39:42 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-03-31 12:39:42 +0200 |
commit | 29f01b32f58573b23bd35857376f6f92e15382a3 (patch) | |
tree | b1a044f87e4b18d5ddd779dc1b63161ded1c3d1a /src/corelib/itemmodels/qabstractitemmodel.cpp | |
parent | 300940a6c9eb0f74cefda7d76a5d19f56ec50253 (diff) | |
parent | 0a7302abbc47a0db25f119ee4f5144bbaf0d9d6f (diff) |
Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
src/corelib/configure.json
Change-Id: I93ac67f3bf4844bc7c691183e94bceb922b7b919
Diffstat (limited to 'src/corelib/itemmodels/qabstractitemmodel.cpp')
-rw-r--r-- | src/corelib/itemmodels/qabstractitemmodel.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/corelib/itemmodels/qabstractitemmodel.cpp b/src/corelib/itemmodels/qabstractitemmodel.cpp index abd86f2b49..18f0f6f55f 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.cpp +++ b/src/corelib/itemmodels/qabstractitemmodel.cpp @@ -2355,6 +2355,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, bool wrap = flags & Qt::MatchWrap; bool allHits = (hits == -1); QString text; // only convert to a string if it is needed + const int column = start.column(); QModelIndex p = parent(start); int from = start.row(); int to = rowCount(p); @@ -2362,7 +2363,7 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, // iterates twice if wrapping for (int i = 0; (wrap && i < 2) || (!wrap && i < 1); ++i) { for (int r = from; (r < to) && (allHits || result.count() < hits); ++r) { - QModelIndex idx = index(r, start.column(), p); + QModelIndex idx = index(r, column, p); if (!idx.isValid()) continue; QVariant v = data(idx, role); @@ -2401,10 +2402,13 @@ QModelIndexList QAbstractItemModel::match(const QModelIndex &start, int role, result.append(idx); } } - if (recurse && hasChildren(idx)) { // search the hierarchy - result += match(index(0, idx.column(), idx), role, - (text.isEmpty() ? value : text), - (allHits ? -1 : hits - result.count()), flags); + if (recurse) { + const auto parent = column != 0 ? idx.sibling(idx.row(), 0) : idx; + if (hasChildren(parent)) { // search the hierarchy + result += match(index(0, column, parent), role, + (text.isEmpty() ? value : text), + (allHits ? -1 : hits - result.count()), flags); + } } } // prepare for the next iteration |