summaryrefslogtreecommitdiff
path: root/src/plugins/diffeditor/diffeditor.cpp
diff options
context:
space:
mode:
authorjkobus <jaroslaw.kobus@digia.com>2014-02-11 13:00:35 +0100
committerJarek Kobus <jaroslaw.kobus@digia.com>2014-02-18 13:46:49 +0100
commit73cf43f32370d8986b4c06511b95771582cc421d (patch)
tree1506c433ca50511420c0332b2b9f432a180ccbb3 /src/plugins/diffeditor/diffeditor.cpp
parent84e8a79c814dc6e788cad9643d0e225c7a92e76d (diff)
downloadqt-creator-73cf43f32370d8986b4c06511b95771582cc421d.tar.gz
Add DiffEditorManager, refactoring.
GitDiffSwitcher operates now on IDocument. GitDiffHandler operates now on DiffEditorController. "source" property now attached to editor's document (VcsBasePlugin). Change-Id: Ie2570a597b8b992ac1dc33b9179eca459c8a751a Reviewed-by: Tobias Hunger <tobias.hunger@digia.com> Reviewed-by: Jarek Kobus <jaroslaw.kobus@digia.com>
Diffstat (limited to 'src/plugins/diffeditor/diffeditor.cpp')
-rw-r--r--src/plugins/diffeditor/diffeditor.cpp104
1 files changed, 45 insertions, 59 deletions
diff --git a/src/plugins/diffeditor/diffeditor.cpp b/src/plugins/diffeditor/diffeditor.cpp
index 682abc27b9..6e23f0558f 100644
--- a/src/plugins/diffeditor/diffeditor.cpp
+++ b/src/plugins/diffeditor/diffeditor.cpp
@@ -118,7 +118,7 @@ void DescriptionEditorWidget::setDisplaySettings(const DisplaySettings &ds)
DiffEditor::DiffEditor()
: IEditor(0)
- , m_document(new Internal::DiffEditorDocument(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE)))
+ , m_document(new DiffEditorDocument(QLatin1String(Constants::DIFF_EDITOR_MIMETYPE)))
, m_descriptionWidget(0)
, m_diffWidget(0)
, m_diffEditorController(0)
@@ -163,9 +163,13 @@ void DiffEditor::ctor()
m_descriptionWidget->setCodeStyle(TextEditorSettings::codeStyle());
m_descriptionWidget->baseTextDocument()->setFontSettings(TextEditorSettings::fontSettings());
- m_diffEditorController = m_document->diffEditorController();
+ m_diffEditorController = m_document->controller();
m_diffWidget->setDiffEditorController(m_diffEditorController);
+ connect(m_diffEditorController, SIGNAL(cleared(QString)),
+ this, SLOT(slotCleared(QString)));
+ connect(m_diffEditorController, SIGNAL(diffContentsChanged(QList<DiffEditorController::DiffFilesContents>,QString)),
+ this, SLOT(slotDiffContentsChanged(QList<DiffEditorController::DiffFilesContents>,QString)));
connect(m_diffEditorController, SIGNAL(currentDiffFileIndexChanged(int)),
this, SLOT(activateEntry(int)));
connect(m_diffEditorController, SIGNAL(descriptionChanged(QString)),
@@ -209,11 +213,6 @@ Core::Id DiffEditor::id() const
return Constants::DIFF_EDITOR_ID;
}
-QTextCodec *DiffEditor::codec() const
-{
- return m_diffWidget->codec();
-}
-
static QToolBar *createToolBar(const QWidget *someWidget)
{
// Create
@@ -275,24 +274,50 @@ QWidget *DiffEditor::toolBar()
m_toggleDescriptionAction = m_toolBar->addWidget(toggleDescription);
slotDescriptionVisibilityChanged();
- if (m_diffEditorController) {
- connect(whitespaceButton, SIGNAL(clicked(bool)),
- m_diffEditorController, SLOT(setIgnoreWhitespaces(bool)));
- connect(contextSpinBox, SIGNAL(valueChanged(int)),
- m_diffEditorController, SLOT(setContextLinesNumber(int)));
- connect(toggleSync, SIGNAL(clicked(bool)),
- m_diffEditorController, SLOT(setHorizontalScrollBarSynchronization(bool)));
- connect(toggleDescription, SIGNAL(clicked(bool)),
- m_diffEditorController, SLOT(setDescriptionVisible(bool)));
- // TODO: synchronize in opposite direction too
- }
+ connect(whitespaceButton, SIGNAL(clicked(bool)),
+ m_diffEditorController, SLOT(setIgnoreWhitespaces(bool)));
+ connect(contextSpinBox, SIGNAL(valueChanged(int)),
+ m_diffEditorController, SLOT(setContextLinesNumber(int)));
+ connect(toggleSync, SIGNAL(clicked(bool)),
+ m_diffEditorController, SLOT(setHorizontalScrollBarSynchronization(bool)));
+ connect(toggleDescription, SIGNAL(clicked(bool)),
+ m_diffEditorController, SLOT(setDescriptionVisible(bool)));
+ // TODO: synchronize in opposite direction too
return m_toolBar;
}
-void DiffEditor::setDiff(const QList<DiffEditorController::DiffFilesContents> &diffFileList,
- const QString &workingDirectory)
+DiffEditorController * DiffEditor::controller() const
+{
+ return m_diffEditorController;
+}
+
+void DiffEditor::updateEntryToolTip()
+{
+ const QString &toolTip = m_entriesComboBox->itemData(
+ m_entriesComboBox->currentIndex(), Qt::ToolTipRole).toString();
+ m_entriesComboBox->setToolTip(toolTip);
+}
+
+void DiffEditor::entryActivated(int index)
{
+ updateEntryToolTip();
+ m_diffEditorController->setCurrentDiffFileIndex(index);
+}
+
+void DiffEditor::slotCleared(const QString &message)
+{
+ Q_UNUSED(message)
+
+ m_entriesComboBox->clear();
+ updateEntryToolTip();
+}
+
+void DiffEditor::slotDiffContentsChanged(const QList<DiffEditorController::DiffFilesContents> &diffFileList,
+ const QString &workingDirectory)
+{
+ Q_UNUSED(workingDirectory)
+
m_entriesComboBox->clear();
const int count = diffFileList.count();
for (int i = 0; i < count; i++) {
@@ -331,42 +356,6 @@ void DiffEditor::setDiff(const QList<DiffEditorController::DiffFilesContents> &d
m_entriesComboBox->setItemData(m_entriesComboBox->count() - 1, itemToolTip, Qt::ToolTipRole);
}
updateEntryToolTip();
- if (m_diffEditorController)
- m_diffEditorController->setDiffContents(diffFileList, workingDirectory);
-}
-
-void DiffEditor::setDescription(const QString &description)
-{
- if (m_diffEditorController)
- m_diffEditorController->setDescription(description);
-}
-
-void DiffEditor::setDescriptionEnabled(bool on)
-{
- if (m_diffEditorController)
- m_diffEditorController->setDescriptionEnabled(on);
-}
-
-void DiffEditor::clear(const QString &message)
-{
- m_entriesComboBox->clear();
- updateEntryToolTip();
- if (m_diffEditorController)
- m_diffEditorController->clear(message);
-}
-
-void DiffEditor::updateEntryToolTip()
-{
- const QString &toolTip = m_entriesComboBox->itemData(
- m_entriesComboBox->currentIndex(), Qt::ToolTipRole).toString();
- m_entriesComboBox->setToolTip(toolTip);
-}
-
-void DiffEditor::entryActivated(int index)
-{
- updateEntryToolTip();
- if (m_diffEditorController)
- m_diffEditorController->setCurrentDiffFileIndex(index);
}
void DiffEditor::activateEntry(int index)
@@ -384,9 +373,6 @@ void DiffEditor::slotDescriptionChanged(const QString &description)
void DiffEditor::slotDescriptionVisibilityChanged()
{
- if (!m_diffEditorController)
- return;
-
const bool visible = m_diffEditorController->isDescriptionVisible();
const bool enabled = m_diffEditorController->isDescriptionEnabled();