summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2016-06-16 16:06:18 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2016-06-17 06:38:24 +0000
commite74a307388d1c1f872dc27bb137ae2e7f1e1693f (patch)
tree42ba038edbfebd1e9a2830be92beddf1d7444cbe
parent28098fadf5e2fe83af7efeb3eb7f83812c1d4237 (diff)
Keep tree view scroll position when model is reset
Change-Id: Idf2adb94a1d80edba022545d7d1637c0c4cdd6e5 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Titta Heikkala <titta.heikkala@qt.io>
-rw-r--r--editorlib/qml/EntityTree.qml7
-rw-r--r--editorlib/src/editorsceneitemmodel.cpp2
-rw-r--r--editorlib/src/editorsceneitemmodel.h1
3 files changed, 10 insertions, 0 deletions
diff --git a/editorlib/qml/EntityTree.qml b/editorlib/qml/EntityTree.qml
index b220bad..8a8549e 100644
--- a/editorlib/qml/EntityTree.qml
+++ b/editorlib/qml/EntityTree.qml
@@ -182,6 +182,7 @@ Item {
property bool sceneRootSelected: true
property bool cameraSelected: true
property bool groupSelected: true
+ property real preResetContentY: 0
onExpanded: {
model.addExpandedItem(index)
@@ -200,6 +201,12 @@ Item {
entityTreeView.selection.setCurrentIndex(selectIndex,
ItemSelectionModel.SelectCurrent)
}
+ onModelAboutToBeReset: {
+ entityTreeView.preResetContentY = entityTreeView.flickableItem.contentY
+ }
+ onResetComplete: {
+ entityTreeView.flickableItem.contentY = entityTreeView.preResetContentY
+ }
}
itemDelegate: FocusScope {
diff --git a/editorlib/src/editorsceneitemmodel.cpp b/editorlib/src/editorsceneitemmodel.cpp
index c8c2346..ae5a2da 100644
--- a/editorlib/src/editorsceneitemmodel.cpp
+++ b/editorlib/src/editorsceneitemmodel.cpp
@@ -277,6 +277,8 @@ void EditorSceneItemModel::resetModel()
// Select scene root after reset, unless multiselecting
if (!m_scene->multiSelection())
emit selectIndex(sceneEntityIndex());
+
+ emit resetComplete();
}
EditorSceneItem *EditorSceneItemModel::editorSceneItemFromIndex(const QModelIndex &index) const
diff --git a/editorlib/src/editorsceneitemmodel.h b/editorlib/src/editorsceneitemmodel.h
index eee5c68..aef98e9 100644
--- a/editorlib/src/editorsceneitemmodel.h
+++ b/editorlib/src/editorsceneitemmodel.h
@@ -105,6 +105,7 @@ signals:
void expandItems(const QModelIndexList &items);
void selectIndex(const QModelIndex &selectIndex);
void importEntityInProgressChanged(bool importInProgress);
+ void resetComplete();
private slots:
void handleEntityNameChange();