diff options
author | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2011-08-03 15:58:23 +0200 |
---|---|---|
committer | Thomas Hartmann <Thomas.Hartmann@nokia.com> | 2011-08-03 16:00:42 +0200 |
commit | 6c8edcf99ed0cd77a3667e61417a224461060ab7 (patch) | |
tree | ea5ba08140fb397d1f5400a57281d26199363797 | |
parent | 46f8a8ca14b46023c69b491c0ae1f7b5b6dcd538 (diff) |
QmlDesigner.rewriter: bugfix for components
Simplifying synchronisation of m_componentEndOffset. Fixes several
rewriting issues.
Change-Id: I53a7f4ae8af1acb05e4daff6afdeec9522d35a79
Reviewed-on: http://codereview.qt.nokia.com/2572
Reviewed-by: Thomas Hartmann <Thomas.Hartmann@nokia.com>
-rw-r--r-- | src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp b/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp index 71e6a89dc1..0655dcc942 100644 --- a/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp +++ b/src/plugins/qmldesigner/designercore/model/componenttextmodifier.cpp @@ -39,7 +39,6 @@ ComponentTextModifier::ComponentTextModifier(TextModifier *originalModifier, int m_componentEndOffset(componentEndOffset), m_rootStartOffset(rootStartOffset) { - connect(m_originalModifier, SIGNAL(replaced(int, int, int)), this, SLOT(contentsChange(int,int,int))); connect(m_originalModifier, SIGNAL(textChanged()), this, SIGNAL(textChanged())); connect(m_originalModifier, SIGNAL(replaced(int, int, int)), this, SIGNAL(replaced(int, int, int))); @@ -73,16 +72,26 @@ int ComponentTextModifier::indentDepth() const void ComponentTextModifier::startGroup() { m_originalModifier->startGroup(); + m_startLength = m_originalModifier->text().length(); } void ComponentTextModifier::flushGroup() { m_originalModifier->flushGroup(); + + uint textLength = m_originalModifier->text().length(); + m_componentEndOffset += (textLength - m_startLength); + m_startLength = textLength; + } void ComponentTextModifier::commitGroup() { m_originalModifier->commitGroup(); + + uint textLength = m_originalModifier->text().length(); + m_componentEndOffset += (textLength - m_startLength); + m_startLength = textLength; } QTextDocument *ComponentTextModifier::textDocument() const @@ -119,21 +128,8 @@ void ComponentTextModifier::reactivateChangeSignals() m_originalModifier->reactivateChangeSignals(); } -void ComponentTextModifier::contentsChange(int position, int charsRemoved, int charsAdded) +void ComponentTextModifier::contentsChange(int /*position*/, int /*charsRemoved*/, int /*charsAdded*/) { - const int diff = charsAdded - charsRemoved; - - if (position < m_rootStartOffset) { - m_rootStartOffset += diff; - } - - if (position < m_componentStartOffset) { - m_componentStartOffset += diff; - } - - if (position < m_componentEndOffset) { - m_componentEndOffset += diff; - } } QmlJS::Snapshot ComponentTextModifier::getSnapshot() const |