// the keystroke delay and a start offset, both in frames
QStringList values = params.at( 2 ).split( ";" );
int interval = qMax( 0, ( ( int ) position - values.at( 1 ).toInt()) / values.at( 0 ).toInt() );
- QTextDocument *td = new QTextDocument( params.at( 1 ).left( interval ) );
- td->setDefaultFont( titem->font() );
- td->setDefaultTextOption( titem->document()->defaultTextOption() );
- td->setTextWidth( titem->document()->textWidth() );
- titem->setDocument( td );
+ QTextCursor cursor = titem->textCursor();
+ cursor.movePosition(QTextCursor::EndOfBlock);
+ // get the font format
+ QTextCharFormat format = cursor.charFormat();
+ cursor.select(QTextCursor::Document);
+ QString txt = params.at( 1 ).left( interval );
+ // If the string to insert is empty, insert a space so that we don't loose
+ // formatting infos for the next iterations
+ cursor.insertText(txt.isEmpty() ? " " : txt, format);
}
}
}