Make persistent code folding and auto-collapse of the license header work together

This commit is contained in:
mae
2010-03-15 13:16:40 +01:00
parent 9ccd2f15e0
commit f30627b48e
2 changed files with 9 additions and 6 deletions

View File

@@ -1282,8 +1282,7 @@ void EditorManager::restoreEditorState(IEditor *editor)
{ {
QTC_ASSERT(editor, return); QTC_ASSERT(editor, return);
QString fileName = editor->file()->fileName(); QString fileName = editor->file()->fileName();
if (m_d->m_editorStates.contains(fileName)) editor->restoreState(m_d->m_editorStates.value(fileName).toByteArray());
editor->restoreState(m_d->m_editorStates.value(fileName).toByteArray());
} }
bool EditorManager::saveEditor(IEditor *editor) bool EditorManager::saveEditor(IEditor *editor)

View File

@@ -609,8 +609,6 @@ bool BaseTextEditor::open(const QString &fileName)
{ {
if (d->m_document->open(fileName)) { if (d->m_document->open(fileName)) {
moveCursor(QTextCursor::Start); moveCursor(QTextCursor::Start);
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
setReadOnly(d->m_document->hasDecodingError()); setReadOnly(d->m_document->hasDecodingError());
return true; return true;
} }
@@ -1531,8 +1529,6 @@ void BaseTextEditor::memorizeCursorPosition()
void BaseTextEditor::restoreCursorPosition() void BaseTextEditor::restoreCursorPosition()
{ {
restoreState(d->m_tempState); restoreState(d->m_tempState);
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
} }
QByteArray BaseTextEditor::saveState() const QByteArray BaseTextEditor::saveState() const
@@ -1567,6 +1563,11 @@ QByteArray BaseTextEditor::saveState() const
bool BaseTextEditor::restoreState(const QByteArray &state) bool BaseTextEditor::restoreState(const QByteArray &state)
{ {
if (state.isEmpty()) {
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
return false;
}
int version; int version;
int vval; int vval;
int hval; int hval;
@@ -1588,6 +1589,9 @@ bool BaseTextEditor::restoreState(const QByteArray &state)
if (block.isValid()) if (block.isValid())
TextBlockUserData::doCollapse(block, false); TextBlockUserData::doCollapse(block, false);
} }
} else {
if (d->m_displaySettings.m_autoFoldFirstComment)
d->collapseLicenseHeader();
} }
d->m_lastCursorChangeWasInteresting = false; // avoid adding last position to history d->m_lastCursorChangeWasInteresting = false; // avoid adding last position to history