diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp index 15fd745007d..5467dac5719 100644 --- a/src/plugins/diffeditor/diffeditor.cpp +++ b/src/plugins/diffeditor/diffeditor.cpp @@ -663,10 +663,6 @@ void DiffEditor::setupView(IDiffView *view) view->setDocument(m_document.data()); view->setSync(m_sync); - - view->beginOperation(); - view->setDiff(m_document->diffFiles(), m_document->baseDirectory()); - view->endOperation(true); view->setCurrentDiffFileIndex(m_currentDiffFileIndex); m_stackedWidget->setCurrentWidget(view->widget()); diff --git a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp index decb179d219..897ebfa3a8d 100644 --- a/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp +++ b/src/plugins/diffeditor/diffeditorwidgetcontroller.cpp @@ -98,6 +98,11 @@ void DiffEditorWidgetController::setDocument(DiffEditorDocument *document) hideProgress(); } +DiffEditorDocument *DiffEditorWidgetController::document() const +{ + return m_document; +} + void DiffEditorWidgetController::scheduleShowProgress() { m_timer.start(); diff --git a/src/plugins/diffeditor/diffeditorwidgetcontroller.h b/src/plugins/diffeditor/diffeditorwidgetcontroller.h index b5655b5f994..ed9e8200967 100644 --- a/src/plugins/diffeditor/diffeditorwidgetcontroller.h +++ b/src/plugins/diffeditor/diffeditorwidgetcontroller.h @@ -50,6 +50,7 @@ public: explicit DiffEditorWidgetController(QWidget *diffEditorWidget); void setDocument(DiffEditorDocument *document); + DiffEditorDocument *document() const; void patch(bool revert); void jumpToOriginalFile(const QString &fileName, int lineNumber, diff --git a/src/plugins/diffeditor/diffview.cpp b/src/plugins/diffeditor/diffview.cpp index c8f1b8dea96..8ad53395940 100644 --- a/src/plugins/diffeditor/diffview.cpp +++ b/src/plugins/diffeditor/diffview.cpp @@ -25,6 +25,7 @@ #include "diffview.h" +#include "diffeditordocument.h" #include "diffeditoricons.h" #include "unifieddiffeditorwidget.h" #include "sidebysidediffeditorwidget.h" @@ -110,12 +111,16 @@ void UnifiedView::setDocument(DiffEditorDocument *document) { QTC_ASSERT(m_widget, return); m_widget->setDocument(document); + if (document && document->isReloading()) + m_widget->clear(tr("Waiting for data...")); } void UnifiedView::beginOperation() { QTC_ASSERT(m_widget, return); - m_widget->saveState(); + DiffEditorDocument *document = m_widget->diffDocument(); + if (document && !document->isReloading()) + m_widget->saveState(); m_widget->clear(tr("Waiting for data...")); } @@ -169,12 +174,16 @@ void SideBySideView::setDocument(DiffEditorDocument *document) { QTC_ASSERT(m_widget, return); m_widget->setDocument(document); + if (document && document->isReloading()) + m_widget->clear(tr("Waiting for data...")); } void SideBySideView::beginOperation() { QTC_ASSERT(m_widget, return); - m_widget->saveState(); + DiffEditorDocument *document = m_widget->diffDocument(); + if (document && !document->isReloading()) + m_widget->saveState(); m_widget->clear(tr("Waiting for data...")); } diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp index 62d11205c28..40aba5fff86 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.cpp @@ -562,6 +562,19 @@ SideBySideDiffEditorWidget::SideBySideDiffEditorWidget(QWidget *parent) void SideBySideDiffEditorWidget::setDocument(DiffEditorDocument *document) { m_controller.setDocument(document); + clear(); + QList diffFileList; + QString workingDirectory; + if (document) { + diffFileList = document->diffFiles(); + workingDirectory = document->baseDirectory(); + } + setDiff(diffFileList, workingDirectory); +} + +DiffEditorDocument *SideBySideDiffEditorWidget::diffDocument() const +{ + return m_controller.document(); } void SideBySideDiffEditorWidget::clear(const QString &message) diff --git a/src/plugins/diffeditor/sidebysidediffeditorwidget.h b/src/plugins/diffeditor/sidebysidediffeditorwidget.h index 0e65c7eafeb..4fdb97c1544 100644 --- a/src/plugins/diffeditor/sidebysidediffeditorwidget.h +++ b/src/plugins/diffeditor/sidebysidediffeditorwidget.h @@ -54,6 +54,7 @@ public: explicit SideBySideDiffEditorWidget(QWidget *parent = 0); void setDocument(DiffEditorDocument *document); + DiffEditorDocument *diffDocument() const; void setDiff(const QList &diffFileList, const QString &workingDirectory); diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp index de8b8e7adf2..34009eaf868 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.cpp +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.cpp @@ -78,6 +78,19 @@ UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent) void UnifiedDiffEditorWidget::setDocument(DiffEditorDocument *document) { m_controller.setDocument(document); + clear(); + QList diffFileList; + QString workingDirectory; + if (document) { + diffFileList = document->diffFiles(); + workingDirectory = document->baseDirectory(); + } + setDiff(diffFileList, workingDirectory); +} + +DiffEditorDocument *UnifiedDiffEditorWidget::diffDocument() const +{ + return m_controller.document(); } void UnifiedDiffEditorWidget::saveState() @@ -173,7 +186,7 @@ void UnifiedDiffEditorWidget::clear(const QString &message) const bool oldIgnore = m_controller.m_ignoreCurrentIndexChange; m_controller.m_ignoreCurrentIndexChange = true; SelectableTextEditorWidget::clear(); - setDiff(QList(), QString()); + m_controller.m_contextFileData.clear(); setPlainText(message); m_controller.m_ignoreCurrentIndexChange = oldIgnore; } @@ -243,8 +256,8 @@ void UnifiedDiffEditorWidget::setDiff(const QList &diffFileList, { Q_UNUSED(workingDirectory) + clear(); m_controller.m_contextFileData = diffFileList; - showDiff(); } diff --git a/src/plugins/diffeditor/unifieddiffeditorwidget.h b/src/plugins/diffeditor/unifieddiffeditorwidget.h index 19114a6cb03..5ba853e42e4 100644 --- a/src/plugins/diffeditor/unifieddiffeditorwidget.h +++ b/src/plugins/diffeditor/unifieddiffeditorwidget.h @@ -54,6 +54,7 @@ public: UnifiedDiffEditorWidget(QWidget *parent = 0); void setDocument(DiffEditorDocument *document); + DiffEditorDocument *diffDocument() const; void setDiff(const QList &diffFileList, const QString &workingDirectory);