Save / restore state in diff editor when reloading

Task-number: QTCREATORBUG-12650
Change-Id: I0bb25ed39f8a15dd5da798ebf0ce72898a2e3b3d
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
This commit is contained in:
jkobus
2014-07-11 12:55:31 +02:00
committed by Jarek Kobus
parent b97c9d731e
commit 87b5db5562
7 changed files with 83 additions and 10 deletions

View File

@@ -134,6 +134,10 @@ void UnifiedDiffEditorWidget::setDiffEditorGuiController(
this, SLOT(clearAll(QString)));
disconnect(m_controller, SIGNAL(diffFilesChanged(QList<FileData>,QString)),
this, SLOT(setDiff(QList<FileData>,QString)));
disconnect(m_controller, SIGNAL(saveStateRequested()),
this, SLOT(saveStateRequested()));
disconnect(m_controller, SIGNAL(restoreStateRequested()),
this, SLOT(restoreStateRequested()));
disconnect(m_guiController, SIGNAL(currentDiffFileIndexChanged(int)),
this, SLOT(setCurrentDiffFileIndex(int)));
@@ -149,6 +153,10 @@ void UnifiedDiffEditorWidget::setDiffEditorGuiController(
this, SLOT(clearAll(QString)));
connect(m_controller, SIGNAL(diffFilesChanged(QList<FileData>,QString)),
this, SLOT(setDiff(QList<FileData>,QString)));
connect(m_controller, SIGNAL(saveStateRequested()),
this, SLOT(saveStateRequested()));
connect(m_controller, SIGNAL(restoreStateRequested()),
this, SLOT(restoreStateRequested()));
connect(m_guiController, SIGNAL(currentDiffFileIndexChanged(int)),
this, SLOT(setCurrentDiffFileIndex(int)));
@@ -158,6 +166,23 @@ void UnifiedDiffEditorWidget::setDiffEditorGuiController(
}
}
void UnifiedDiffEditorWidget::saveStateRequested()
{
if (!m_state.isNull())
return;
m_state = saveState();
}
void UnifiedDiffEditorWidget::restoreStateRequested()
{
if (m_state.isNull())
return;
restoreState(m_state);
m_state.clear();
}
DiffEditorGuiController *UnifiedDiffEditorWidget::diffEditorGuiController() const
{
return m_guiController;