forked from qt-creator/qt-creator
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 <tobias.hunger@qt.io>
This commit is contained in:
@@ -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());
|
||||
|
@@ -98,6 +98,11 @@ void DiffEditorWidgetController::setDocument(DiffEditorDocument *document)
|
||||
hideProgress();
|
||||
}
|
||||
|
||||
DiffEditorDocument *DiffEditorWidgetController::document() const
|
||||
{
|
||||
return m_document;
|
||||
}
|
||||
|
||||
void DiffEditorWidgetController::scheduleShowProgress()
|
||||
{
|
||||
m_timer.start();
|
||||
|
@@ -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,
|
||||
|
@@ -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..."));
|
||||
}
|
||||
|
||||
|
@@ -562,6 +562,19 @@ SideBySideDiffEditorWidget::SideBySideDiffEditorWidget(QWidget *parent)
|
||||
void SideBySideDiffEditorWidget::setDocument(DiffEditorDocument *document)
|
||||
{
|
||||
m_controller.setDocument(document);
|
||||
clear();
|
||||
QList<FileData> 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)
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
explicit SideBySideDiffEditorWidget(QWidget *parent = 0);
|
||||
|
||||
void setDocument(DiffEditorDocument *document);
|
||||
DiffEditorDocument *diffDocument() const;
|
||||
|
||||
void setDiff(const QList<FileData> &diffFileList,
|
||||
const QString &workingDirectory);
|
||||
|
@@ -78,6 +78,19 @@ UnifiedDiffEditorWidget::UnifiedDiffEditorWidget(QWidget *parent)
|
||||
void UnifiedDiffEditorWidget::setDocument(DiffEditorDocument *document)
|
||||
{
|
||||
m_controller.setDocument(document);
|
||||
clear();
|
||||
QList<FileData> 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<FileData>(), QString());
|
||||
m_controller.m_contextFileData.clear();
|
||||
setPlainText(message);
|
||||
m_controller.m_ignoreCurrentIndexChange = oldIgnore;
|
||||
}
|
||||
@@ -243,8 +256,8 @@ void UnifiedDiffEditorWidget::setDiff(const QList<FileData> &diffFileList,
|
||||
{
|
||||
Q_UNUSED(workingDirectory)
|
||||
|
||||
clear();
|
||||
m_controller.m_contextFileData = diffFileList;
|
||||
|
||||
showDiff();
|
||||
}
|
||||
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
UnifiedDiffEditorWidget(QWidget *parent = 0);
|
||||
|
||||
void setDocument(DiffEditorDocument *document);
|
||||
DiffEditorDocument *diffDocument() const;
|
||||
|
||||
void setDiff(const QList<FileData> &diffFileList,
|
||||
const QString &workingDirectory);
|
||||
|
Reference in New Issue
Block a user