QmlDesigner.StatesEditor: speed up by only updating thumbnails after rewritter transactions are finished

This commit is contained in:
Christiaan Janssen
2010-06-14 18:19:51 +02:00
parent 81c7f4f166
commit 254a51bf5a
2 changed files with 34 additions and 6 deletions

View File

@@ -53,6 +53,8 @@ StatesEditorView::StatesEditorView(StatesEditorModel *editorModel, QObject *pare
m_attachedToModel(false), m_settingSilentState(false) m_attachedToModel(false), m_settingSilentState(false)
{ {
Q_ASSERT(m_editorModel); Q_ASSERT(m_editorModel);
// base state
m_thumbnailsToUpdate.append(false);
} }
void StatesEditorView::setCurrentStateSilent(int index) void StatesEditorView::setCurrentStateSilent(int index)
@@ -118,8 +120,10 @@ void StatesEditorView::removeState(int index)
setCurrentState(0); setCurrentState(0);
m_thumbnailsToUpdate.removeAt(index);
m_modelStates.removeAll(state); m_modelStates.removeAll(state);
state.destroy(); state.destroy();
m_editorModel->removeState(index); m_editorModel->removeState(index);
int newIndex = (index < m_modelStates.count()) ? index : m_modelStates.count() - 1; int newIndex = (index < m_modelStates.count()) ? index : m_modelStates.count() - 1;
@@ -184,6 +188,7 @@ void StatesEditorView::modelAttached(Model *model)
return; return;
m_modelStates.insert(0, baseState()); m_modelStates.insert(0, baseState());
m_thumbnailsToUpdate.insert(0, false);
m_attachedToModel = true; m_attachedToModel = true;
m_editorModel->insertState(0, baseState().name()); m_editorModel->insertState(0, baseState().name());
@@ -340,12 +345,14 @@ void StatesEditorView::nodeOrderChanged(const NodeListProperty &listProperty, co
void StatesEditorView::nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName) void StatesEditorView::nodeInstancePropertyChanged(const ModelNode &node, const QString &propertyName)
{ {
if (!m_settingSilentState) { if (!m_settingSilentState) {
if (QmlModelState(node).isValid()) { QmlModelState state = QmlModelState(node);
startUpdateTimer(modelStateIndex(node) + 1, 0); if (state.isValid())
} else { //a change to the base state update all {
for (int i = 0; i < m_modelStates.count(); ++i) if (m_modelStates.contains(state))
startUpdateTimer(i, 0); m_thumbnailsToUpdate[m_modelStates.indexOf(state)] = true;
} } else //a change to the base state update all
m_thumbnailsToUpdate[0] = true;
} }
QmlModelView::nodeInstancePropertyChanged(node, propertyName); QmlModelView::nodeInstancePropertyChanged(node, propertyName);
@@ -396,6 +403,22 @@ void StatesEditorView::customNotification(const AbstractView * view, const QStri
if (debug) if (debug)
qDebug() << __FUNCTION__; qDebug() << __FUNCTION__;
if (identifier == "__end rewriter transaction__")
{
if (m_thumbnailsToUpdate[0])
{
for (int i = 0; i < m_modelStates.count(); ++i) {
m_thumbnailsToUpdate[i] = false;
startUpdateTimer(i, 0);
}
} else
for (int i = 1; i< m_thumbnailsToUpdate.count(); i++)
if (m_thumbnailsToUpdate[i]) {
m_thumbnailsToUpdate[i] = false;
startUpdateTimer(i,0);
}
}
QmlModelView::customNotification(view, identifier, nodeList, data); QmlModelView::customNotification(view, identifier, nodeList, data);
} }
@@ -504,6 +527,7 @@ void StatesEditorView::insertModelState(int i, const QmlModelState &state)
// For m_modelStates / m_editorModel, i=0 is base state // For m_modelStates / m_editorModel, i=0 is base state
m_modelStates.insert(i+1, state); m_modelStates.insert(i+1, state);
m_editorModel->insertState(i+1, state.name()); m_editorModel->insertState(i+1, state.name());
m_thumbnailsToUpdate.append(false);
} }
void StatesEditorView::removeModelState(const QmlModelState &state) void StatesEditorView::removeModelState(const QmlModelState &state)
@@ -516,6 +540,7 @@ void StatesEditorView::removeModelState(const QmlModelState &state)
int index = m_modelStates.indexOf(state); int index = m_modelStates.indexOf(state);
if (index != -1) { if (index != -1) {
m_modelStates.removeOne(state); m_modelStates.removeOne(state);
m_thumbnailsToUpdate.removeAt(index);
if (m_updateTimerIdList.contains(index)) { if (m_updateTimerIdList.contains(index)) {
killTimer(m_updateTimerIdList[index]); killTimer(m_updateTimerIdList[index]);
@@ -535,6 +560,7 @@ void StatesEditorView::clearModelStates()
const int modelStateCount = m_modelStates.size(); const int modelStateCount = m_modelStates.size();
for (int i=modelStateCount-1; i>=0; --i) { for (int i=modelStateCount-1; i>=0; --i) {
m_modelStates.removeAt(i); m_modelStates.removeAt(i);
m_thumbnailsToUpdate.removeAt(i);
m_editorModel->removeState(i); m_editorModel->removeState(i);
} }
} }

View File

@@ -100,6 +100,8 @@ private:
QmlModelState m_oldRewriterAmendState; QmlModelState m_oldRewriterAmendState;
bool m_attachedToModel; bool m_attachedToModel;
bool m_settingSilentState; bool m_settingSilentState;
QList<bool> m_thumbnailsToUpdate;
}; };
} // namespace Internal } // namespace Internal