Editor: Update layout accordingly when restoring state

Whenever blocks are folded/unfoled we need to request a layout update.

Task-number: QTCREATORBUG-6666
Change-Id: I123b99c697a034cb04871bc41f42eac4f39895a2
Reviewed-by: Daniel Teske <daniel.teske@nokia.com>
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
Reviewed-by: Leandro Melo <leandro.melo@nokia.com>
This commit is contained in:
Leandro Melo
2011-12-09 17:36:42 +01:00
parent 8f20646309
commit eed9ab2901

View File

@@ -2206,10 +2206,20 @@ bool BaseTextEditorWidget::restoreState(const QByteArray &state)
QList<int> collapsedBlocks;
stream >> collapsedBlocks;
QTextDocument *doc = document();
bool layoutChanged = false;
foreach(int blockNumber, collapsedBlocks) {
QTextBlock block = doc->findBlockByNumber(qMax(0, blockNumber));
if (block.isValid())
if (block.isValid()) {
BaseTextDocumentLayout::doFoldOrUnfold(block, false);
layoutChanged = true;
}
}
if (layoutChanged) {
BaseTextDocumentLayout *documentLayout =
qobject_cast<BaseTextDocumentLayout*>(doc->documentLayout());
QTC_ASSERT(documentLayout, return false);
documentLayout->requestUpdate();
documentLayout->emitDocumentSizeChanged();
}
} else {
if (d->m_displaySettings.m_autoFoldFirstComment)