diff options
| author | Filippo Cucchetto <filippocucchetto@gmail.com> | 2015-03-22 20:09:35 +0100 |
|---|---|---|
| committer | Filippo Cucchetto <filippocucchetto@gmail.com> | 2015-04-14 12:03:57 +0000 |
| commit | ded73ee2ae8aa333894ab11ce2297e755ec03f3e (patch) | |
| tree | 05433347251c7a4da248dd45e6d2ec1ffe86d7dd /src | |
| parent | 2c1141c62d9cc1043a5b488fdb6b752402fb8553 (diff) | |
Fix TreeView missing visualization of expander image on insert or remove
The current implementation doesn't emit the datachanged signal on the
hasChildren role during insertion or remove of rows. This could cause the
missing visualization of the expander images in the view. This happen
when a new row is inserted inside a leaf node or when a previously not leaf
node becomes a leaf because its last child has been removed.
Change-Id: I4145cb6bd58fe2efeb38c5c14f10657d956fc6ed
Reviewed-by: Filippo Cucchetto <filippocucchetto@gmail.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/controls/Private/qquicktreemodeladaptor.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/controls/Private/qquicktreemodeladaptor.cpp b/src/controls/Private/qquicktreemodeladaptor.cpp index 5ab8467e4..dacae676b 100644 --- a/src/controls/Private/qquicktreemodeladaptor.cpp +++ b/src/controls/Private/qquicktreemodeladaptor.cpp @@ -608,6 +608,9 @@ void QQuickTreeModelAdaptor::modelRowsInserted(const QModelIndex & parent, int s TreeItem item; int parentRow = itemIndex(parent); if (parentRow >= 0) { + const QModelIndex& parentIndex = index(parentRow); + QVector<int> changedRole(1, HasChildrenRole); + emit dataChanged(parentIndex, parentIndex, changedRole); item = m_items.at(parentRow); if (!item.expanded) { ASSERT_CONSISTENCY(); @@ -645,6 +648,12 @@ void QQuickTreeModelAdaptor::modelRowsAboutToBeRemoved(const QModelIndex & paren void QQuickTreeModelAdaptor::modelRowsRemoved(const QModelIndex & parent, int start, int end) { qDebug() << "modelRowsRemoved" << parent << "start" << start << "end" << end; + int parentRow = itemIndex(parent); + if (parentRow >= 0) { + const QModelIndex& parentIndex = index(parentRow); + QVector<int> changedRole(1, HasChildrenRole); + emit dataChanged(parentIndex, parentIndex, changedRole); + } ASSERT_CONSISTENCY(); } |
