Commit 6c8edcf9 authored by Thomas Hartmann's avatar Thomas Hartmann

QmlDesigner.rewriter: bugfix for components

Simplifying synchronisation of m_componentEndOffset. Fixes several
rewriting issues.

Change-Id: I53a7f4ae8af1acb05e4daff6afdeec9522d35a79
Reviewed-on: http://codereview.qt.nokia.com/2572Reviewed-by: default avatarThomas Hartmann <Thomas.Hartmann@nokia.com>
parent 46f8a8ca
......@@ -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
......
Markdown is supported
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