From b29513aa5b63c3abfef79e928bc803f471663eb4 Mon Sep 17 00:00:00 2001 From: Jarek Kobus Date: Wed, 23 Nov 2016 11:20:12 +0100 Subject: [PATCH] Display "Waiting for data" properly Display "Waiting for data" instead of "No differences" when creating new instance of an editor for the same document (e.g. by splitting the view) during document reload. Change-Id: If254006de3914ad4416c7405874e8cbea57ddd8d Reviewed-by: Tobias Hunger --- src/plugins/diffeditor/diffeditor.cpp | 4 ---- .../diffeditor/diffeditorwidgetcontroller.cpp | 5 +++++ .../diffeditor/diffeditorwidgetcontroller.h | 1 + src/plugins/diffeditor/diffview.cpp | 13 +++++++++++-- .../diffeditor/sidebysidediffeditorwidget.cpp | 13 +++++++++++++ .../diffeditor/sidebysidediffeditorwidget.h | 1 + .../diffeditor/unifieddiffeditorwidget.cpp | 17 +++++++++++++++-- .../diffeditor/unifieddiffeditorwidget.h | 1 + 8 files changed, 47 insertions(+), 8 deletions(-) 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);