Commit dd6bf41b authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner.StatesEditor: Optimize updating

parent 5739193f
......@@ -148,12 +148,10 @@ void StatesEditorModel::insertState(int stateIndex)
}
}
void StatesEditorModel::updateState(int updateIndex)
void StatesEditorModel::updateState(int beginIndex, int endIndex)
{
if (updateIndex >= 0) {
QModelIndex modelIndex = index(updateIndex, 0);
emit dataChanged(modelIndex, modelIndex);
}
if (beginIndex >= 0 && endIndex >= 0)
emit dataChanged(index(beginIndex, 0), index(endIndex, 0));
}
void StatesEditorModel::removeState(int stateIndex)
......
......@@ -64,7 +64,7 @@ public:
void insertState(int stateIndex);
void removeState(int stateIndex);
void updateState(int stateIndex);
void updateState(int beginIndex, int endIndex);
Q_INVOKABLE void renameState(int nodeId, const QString &newName);
void emitChangedToState(int n);
......
......@@ -247,14 +247,6 @@ void StatesEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>
void StatesEditorView::variantPropertiesChanged(const QList<VariantProperty> &propertyList, PropertyChangeFlags /*propertyChange*/)
{
foreach (const VariantProperty &property, propertyList) {
if (property.name() == "name" && property.parentModelNode().hasParentProperty()) {
NodeAbstractProperty parentProperty = property.parentModelNode().parentProperty();
if (parentProperty.name() == "states" && parentProperty.parentModelNode().isRootNode()) {
m_statesEditorModel->updateState(parentProperty.indexOf(property.parentModelNode()) + 1);
}
}
}
}
......@@ -338,15 +330,24 @@ void StatesEditorView::customNotification(const AbstractView * view, const QStri
{
if (identifier == "__instance preview image changed__") {
int minimumIndex = 10000;
int maximumIndex = -1;
foreach(const ModelNode &node, nodeList) {
if (node.isRootNode()) {
m_statesEditorModel->updateState(0);
minimumIndex = qMin(minimumIndex, 0);
maximumIndex = qMax(maximumIndex, 0);
} else {
int index = rootStateGroup().allStates().indexOf(QmlModelState(node)) + 1;
if (index > 0)
m_statesEditorModel->updateState(index);
if (index > 0) {
minimumIndex = qMin(minimumIndex, index);
maximumIndex = qMax(maximumIndex, index);
}
}
}
if (maximumIndex >= 0)
m_statesEditorModel->updateState(minimumIndex, maximumIndex);
} else {
QmlModelView::customNotification(view, identifier, nodeList, imageList);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment