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 /src/controls/Private/qquicktreemodeladaptor_p.h | |
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 'src/controls/Private/qquicktreemodeladaptor_p.h')
-rw-r--r-- | src/controls/Private/qquicktreemodeladaptor_p.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/controls/Private/qquicktreemodeladaptor_p.h b/src/controls/Private/qquicktreemodeladaptor_p.h index 8059f681..2297c365 100644 --- a/src/controls/Private/qquicktreemodeladaptor_p.h +++ b/src/controls/Private/qquicktreemodeladaptor_p.h @@ -89,12 +89,12 @@ public: const QModelIndex &mapToModel(const QModelIndex &index) const; Q_INVOKABLE QModelIndex mapRowToModelIndex(int row) const; - Q_INVOKABLE QItemSelection selectionForRowRange(int from, int to) const; + Q_INVOKABLE QItemSelection selectionForRowRange(const QModelIndex &fromIndex, const QModelIndex &toIndex) const; void showModelTopLevelItems(bool doInsertRows = true); void showModelChildItems(const TreeItem &parent, int start, int end, bool doInsertRows = true, bool doExpandPendingRows = true); - int itemIndex(const QModelIndex &index); + int itemIndex(const QModelIndex &index) const; void expandPendingRows(bool doInsertRows = true); int lastChildIndex(const QModelIndex &index); void removeVisibleRows(int startIndex, int endIndex, bool doRemoveRows = true); @@ -152,7 +152,7 @@ private: QList<TreeItem> m_items; QSet<QPersistentModelIndex> m_expandedItems; QList<TreeItem *> m_itemsToExpand; - int m_lastItemIndex; + mutable int m_lastItemIndex; }; QT_END_NAMESPACE |