diff options
author | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-06-29 12:30:57 +0200 |
---|---|---|
committer | Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com> | 2015-07-04 16:41:22 +0000 |
commit | b27c2ed888788f91db33d2ccea962a3815006858 (patch) | |
tree | ceaa5189529bd5284e449ab1bafce8b8b4f71652 /tests/auto/shared | |
parent | 56dfb59237f902cebd480d92912ad572f000e2ba (diff) | |
download | qtquickcontrols-b27c2ed888788f91db33d2ccea962a3815006858.tar.gz |
TreeView: Track model indexes during selection
As we keep track of the previous user-selected row,
it can happen that that row is no longer part of the
TreeModelAdaptor items if the user collapses it or
any of its ancestors (collapsing a node doesn't update
the current selection). This will result on the row
index pointing to the wrong entry in the model (or a
completely invalid one).
Instead, we now track the selection with QModelIndexes
making it more robust to branch expansion and collapse
in the view. We'll still need to account for model changes
which means that, in the future, we should invalidate
the previous user-selected item.
Change-Id: I54ba2582e65515eef95d5f8ad755a8c68568d7ad
Task-number: QTBUG-46891
Reviewed-by: Caroline Chao <caroline.chao@theqtcompany.com>
Diffstat (limited to 'tests/auto/shared')
-rw-r--r-- | tests/auto/shared/testmodel.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/auto/shared/testmodel.h b/tests/auto/shared/testmodel.h index 0bc06757..00e74129 100644 --- a/tests/auto/shared/testmodel.h +++ b/tests/auto/shared/testmodel.h @@ -124,7 +124,7 @@ public: return false; } - Q_INVOKABLE QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const { if (row < 0 || column < 0 || (level(parent) > levels) || column >= cols) return QModelIndex(); @@ -199,7 +199,7 @@ public: emit layoutChanged(parents); } - bool removeRows(int row, int count, const QModelIndex &parent) + Q_INVOKABLE bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()) { beginRemoveRows(parent, row, row + count - 1); Node *n = (Node *)parent.internalPointer(); |