forked from qt-creator/qt-creator
DiffEditor: Preserve source for state recovery
Task-number: QTCREATORBUG-10126 Change-Id: I707e7cdac84c91d52c5661718ac48e3d79fc7c91 Reviewed-by: Petar Perisin <petar.perisin@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
18bba097bd
commit
f29ce3d9b9
@@ -890,6 +890,16 @@ QTextCodec *DiffEditorWidget::codec() const
|
||||
return const_cast<QTextCodec *>(m_leftEditor->codec());
|
||||
}
|
||||
|
||||
QString DiffEditorWidget::source() const
|
||||
{
|
||||
return m_source;
|
||||
}
|
||||
|
||||
void DiffEditorWidget::setSource(const QString &source)
|
||||
{
|
||||
m_source = source;
|
||||
}
|
||||
|
||||
BaseTextEditorWidget *DiffEditorWidget::leftEditor() const
|
||||
{
|
||||
return m_leftEditor;
|
||||
|
||||
@@ -58,6 +58,7 @@ struct FileData;
|
||||
|
||||
class DIFFEDITOR_EXPORT DiffEditorWidget : public QWidget
|
||||
{
|
||||
Q_PROPERTY(QString source READ source WRITE setSource)
|
||||
Q_OBJECT
|
||||
public:
|
||||
struct DiffFileInfo {
|
||||
@@ -83,6 +84,9 @@ public:
|
||||
void setDiff(const QList<DiffFilesContents> &diffFileList, const QString &workingDirectory = QString());
|
||||
QTextCodec *codec() const;
|
||||
|
||||
QString source() const;
|
||||
void setSource(const QString &source);
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
void testAssemblyRows();
|
||||
#endif // WITH_TESTS
|
||||
@@ -151,6 +155,7 @@ private:
|
||||
bool m_syncScrollBars;
|
||||
|
||||
bool m_foldingBlocker;
|
||||
QString m_source;
|
||||
|
||||
QTextCharFormat m_fileLineFormat;
|
||||
QTextCharFormat m_chunkLineFormat;
|
||||
|
||||
@@ -997,13 +997,17 @@ DiffEditor::DiffEditor *GitClient::findExistingDiffEditor(const char *registerDy
|
||||
}
|
||||
|
||||
DiffEditor::DiffEditor *GitClient::createDiffEditor(const char *registerDynamicProperty,
|
||||
const QString &dynamicPropertyValue, const QString &titlePattern, const Core::Id editorId) const
|
||||
const QString &dynamicPropertyValue,
|
||||
const QString &source,
|
||||
const QString &titlePattern,
|
||||
const Core::Id editorId) const
|
||||
{
|
||||
QString title = titlePattern;
|
||||
DiffEditor::DiffEditor *diffEditor = qobject_cast<DiffEditor::DiffEditor *>(
|
||||
Core::EditorManager::openEditorWithContents(editorId, &title, m_msgWait.toUtf8()));
|
||||
QTC_ASSERT(diffEditor, return 0);
|
||||
diffEditor->document()->setProperty(registerDynamicProperty, dynamicPropertyValue);
|
||||
diffEditor->editorWidget()->setSource(source);
|
||||
|
||||
Core::EditorManager::activateEditor(diffEditor);
|
||||
return diffEditor;
|
||||
@@ -1068,6 +1072,7 @@ void GitClient::diff(const QString &workingDirectory,
|
||||
DiffEditor::DiffEditor *diffEditor = findExistingDiffEditor(propertyName, workingDirectory);
|
||||
if (!diffEditor) {
|
||||
newEditor = diffEditor = createDiffEditor(propertyName,
|
||||
workingDirectory,
|
||||
workingDirectory,
|
||||
title,
|
||||
DiffEditor::Constants::DIFF_EDITOR_ID);
|
||||
@@ -1188,6 +1193,7 @@ void GitClient::diff(const QString &workingDirectory,
|
||||
DiffEditor::DiffEditor *diffEditor = findExistingDiffEditor(propertyName, sourceFile);
|
||||
if (!diffEditor) {
|
||||
newEditor = diffEditor = createDiffEditor(propertyName,
|
||||
sourceFile,
|
||||
sourceFile,
|
||||
title,
|
||||
DiffEditor::Constants::DIFF_EDITOR_ID);
|
||||
@@ -1252,6 +1258,7 @@ void GitClient::diffBranch(const QString &workingDirectory,
|
||||
if (!diffEditor) {
|
||||
newEditor = diffEditor = createDiffEditor(propertyName,
|
||||
branchName,
|
||||
workingDirectory,
|
||||
title,
|
||||
DiffEditor::Constants::DIFF_EDITOR_ID);
|
||||
}
|
||||
@@ -1413,6 +1420,7 @@ void GitClient::show(const QString &source, const QString &id,
|
||||
if (!diffEditor) {
|
||||
newEditor = diffEditor = createDiffEditor(propertyName,
|
||||
id,
|
||||
source,
|
||||
title,
|
||||
DiffEditor::Constants::DIFF_SHOW_EDITOR_ID);
|
||||
}
|
||||
|
||||
@@ -367,6 +367,7 @@ private:
|
||||
VcsBase::VcsBaseEditorParameterWidget *configWidget) const;
|
||||
DiffEditor::DiffEditor *createDiffEditor(const char *registerDynamicProperty,
|
||||
const QString &dynamicPropertyValue,
|
||||
const QString &source,
|
||||
const QString &titlePattern,
|
||||
const Core::Id editorId) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user