DiffEditor: Remove m_controller member

Not needed, we can just get the controller from the document at any time

Change-Id: I4a4ad9e3e343a147096e46406b9175b3f52f31a6
Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-01-30 11:36:02 +01:00
parent e5cb8b1cd8
commit d195807cc0
2 changed files with 24 additions and 23 deletions

View File

@@ -210,7 +210,6 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc)
, m_sideBySideEditor(0) , m_sideBySideEditor(0)
, m_unifiedEditor(0) , m_unifiedEditor(0)
, m_currentEditor(0) , m_currentEditor(0)
, m_controller(0)
, m_guiController(0) , m_guiController(0)
, m_toolBar(0) , m_toolBar(0)
, m_entriesComboBox(0) , m_entriesComboBox(0)
@@ -238,24 +237,24 @@ DiffEditor::DiffEditor(const QSharedPointer<DiffEditorDocument> &doc)
setWidget(splitter); setWidget(splitter);
m_controller = m_document->controller(); DiffEditorController *control = controller();
m_guiController = new DiffEditorGuiController(m_controller, this); m_guiController = new DiffEditorGuiController(control, this);
connect(m_descriptionWidget, &Internal::DescriptionEditorWidget::requestBranchList, connect(m_descriptionWidget, &Internal::DescriptionEditorWidget::requestBranchList,
m_controller, &DiffEditorController::expandBranchesRequested); control, &DiffEditorController::expandBranchesRequested);
connect(m_controller, &DiffEditorController::cleared, this, &DiffEditor::slotCleared); connect(control, &DiffEditorController::cleared, this, &DiffEditor::slotCleared);
connect(m_controller, &DiffEditorController::diffFilesChanged, connect(control, &DiffEditorController::diffFilesChanged,
this, &DiffEditor::slotDiffFilesChanged); this, &DiffEditor::slotDiffFilesChanged);
connect(m_controller, &DiffEditorController::descriptionChanged, connect(control, &DiffEditorController::descriptionChanged,
this, &DiffEditor::slotDescriptionChanged); this, &DiffEditor::slotDescriptionChanged);
connect(m_controller, &DiffEditorController::descriptionEnablementChanged, connect(control, &DiffEditorController::descriptionEnablementChanged,
this, &DiffEditor::slotDescriptionVisibilityChanged); this, &DiffEditor::slotDescriptionVisibilityChanged);
connect(m_guiController, &DiffEditorGuiController::descriptionVisibilityChanged, connect(m_guiController, &DiffEditorGuiController::descriptionVisibilityChanged,
this, &DiffEditor::slotDescriptionVisibilityChanged); this, &DiffEditor::slotDescriptionVisibilityChanged);
connect(m_guiController, &DiffEditorGuiController::currentDiffFileIndexChanged, connect(m_guiController, &DiffEditorGuiController::currentDiffFileIndexChanged,
this, &DiffEditor::activateEntry); this, &DiffEditor::activateEntry);
slotDescriptionChanged(m_controller->description()); slotDescriptionChanged(control->description());
slotDescriptionVisibilityChanged(); slotDescriptionVisibilityChanged();
showDiffEditor(readCurrentDiffEditorSetting()); showDiffEditor(readCurrentDiffEditorSetting());
@@ -303,6 +302,8 @@ QWidget *DiffEditor::toolBar()
if (m_toolBar) if (m_toolBar)
return m_toolBar; return m_toolBar;
DiffEditorController *control = controller();
// Create // Create
m_toolBar = createToolBar(m_sideBySideEditor); m_toolBar = createToolBar(m_sideBySideEditor);
@@ -319,7 +320,7 @@ QWidget *DiffEditor::toolBar()
QToolButton *whitespaceButton = new QToolButton(m_toolBar); QToolButton *whitespaceButton = new QToolButton(m_toolBar);
whitespaceButton->setText(tr("Ignore Whitespace")); whitespaceButton->setText(tr("Ignore Whitespace"));
whitespaceButton->setCheckable(true); whitespaceButton->setCheckable(true);
whitespaceButton->setChecked(m_controller->isIgnoreWhitespace()); whitespaceButton->setChecked(control->isIgnoreWhitespace());
m_whitespaceButtonAction = m_toolBar->addWidget(whitespaceButton); m_whitespaceButtonAction = m_toolBar->addWidget(whitespaceButton);
QLabel *contextLabel = new QLabel(m_toolBar); QLabel *contextLabel = new QLabel(m_toolBar);
@@ -329,7 +330,7 @@ QWidget *DiffEditor::toolBar()
QSpinBox *contextSpinBox = new QSpinBox(m_toolBar); QSpinBox *contextSpinBox = new QSpinBox(m_toolBar);
contextSpinBox->setRange(1, 100); contextSpinBox->setRange(1, 100);
contextSpinBox->setValue(m_controller->contextLinesNumber()); contextSpinBox->setValue(control->contextLinesNumber());
contextSpinBox->setFrame(false); contextSpinBox->setFrame(false);
contextSpinBox->setSizePolicy(QSizePolicy::Minimum, contextSpinBox->setSizePolicy(QSizePolicy::Minimum,
QSizePolicy::Expanding); // Mac Qt5 QSizePolicy::Expanding); // Mac Qt5
@@ -361,12 +362,12 @@ QWidget *DiffEditor::toolBar()
updateDiffEditorSwitcher(); updateDiffEditorSwitcher();
connect(whitespaceButton, &QToolButton::clicked, connect(whitespaceButton, &QToolButton::clicked,
m_controller, &DiffEditorController::setIgnoreWhitespace); control, &DiffEditorController::setIgnoreWhitespace);
connect(m_controller, &DiffEditorController::ignoreWhitespaceChanged, connect(control, &DiffEditorController::ignoreWhitespaceChanged,
whitespaceButton, &QToolButton::setChecked); whitespaceButton, &QToolButton::setChecked);
connect(contextSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), connect(contextSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged),
m_controller, &DiffEditorController::setContextLinesNumber); control, &DiffEditorController::setContextLinesNumber);
connect(m_controller, &DiffEditorController::contextLinesNumberChanged, connect(control, &DiffEditorController::contextLinesNumberChanged,
contextSpinBox, &QSpinBox::setValue); contextSpinBox, &QSpinBox::setValue);
connect(toggleSync, &QAbstractButton::clicked, connect(toggleSync, &QAbstractButton::clicked,
m_guiController, &DiffEditorGuiController::setHorizontalScrollBarSynchronization); m_guiController, &DiffEditorGuiController::setHorizontalScrollBarSynchronization);
@@ -375,10 +376,10 @@ QWidget *DiffEditor::toolBar()
connect(m_diffEditorSwitcher, &QAbstractButton::clicked, connect(m_diffEditorSwitcher, &QAbstractButton::clicked,
this, &DiffEditor::slotDiffEditorSwitched); this, &DiffEditor::slotDiffEditorSwitched);
connect(reloadButton, &QAbstractButton::clicked, connect(reloadButton, &QAbstractButton::clicked,
m_controller, &DiffEditorController::requestReload); control, &DiffEditorController::requestReload);
connect(m_controller, &DiffEditorController::reloaderChanged, connect(control, &DiffEditorController::reloaderChanged,
this, &DiffEditor::slotReloaderChanged); this, &DiffEditor::slotReloaderChanged);
connect(m_controller, &DiffEditorController::contextLinesNumberEnablementChanged, connect(control, &DiffEditorController::contextLinesNumberEnablementChanged,
this, &DiffEditor::slotReloaderChanged); this, &DiffEditor::slotReloaderChanged);
return m_toolBar; return m_toolBar;
@@ -386,7 +387,7 @@ QWidget *DiffEditor::toolBar()
DiffEditorController *DiffEditor::controller() const DiffEditorController *DiffEditor::controller() const
{ {
return m_controller; return m_document->controller();
} }
void DiffEditor::updateEntryToolTip() void DiffEditor::updateEntryToolTip()
@@ -478,7 +479,7 @@ void DiffEditor::slotDescriptionChanged(const QString &description)
void DiffEditor::slotDescriptionVisibilityChanged() void DiffEditor::slotDescriptionVisibilityChanged()
{ {
const bool enabled = m_controller->isDescriptionEnabled(); const bool enabled = controller()->isDescriptionEnabled();
const bool visible = m_guiController->isDescriptionVisible(); const bool visible = m_guiController->isDescriptionVisible();
m_descriptionWidget->setVisible(visible && enabled); m_descriptionWidget->setVisible(visible && enabled);
@@ -497,8 +498,9 @@ void DiffEditor::slotDescriptionVisibilityChanged()
void DiffEditor::slotReloaderChanged() void DiffEditor::slotReloaderChanged()
{ {
const DiffEditorReloader *reloader = m_controller->reloader(); DiffEditorController *control = controller();
const bool contextVisible = m_controller->isContextLinesNumberEnabled(); const DiffEditorReloader *reloader = control->reloader();
const bool contextVisible = control->isContextLinesNumberEnabled();
m_whitespaceButtonAction->setVisible(reloader); m_whitespaceButtonAction->setVisible(reloader);
m_contextLabelAction->setVisible(reloader && contextVisible); m_contextLabelAction->setVisible(reloader && contextVisible);

View File

@@ -102,7 +102,6 @@ private:
SideBySideDiffEditorWidget *m_sideBySideEditor; SideBySideDiffEditorWidget *m_sideBySideEditor;
UnifiedDiffEditorWidget *m_unifiedEditor; UnifiedDiffEditorWidget *m_unifiedEditor;
QWidget *m_currentEditor; QWidget *m_currentEditor;
DiffEditorController *m_controller;
DiffEditorGuiController *m_guiController; DiffEditorGuiController *m_guiController;
QToolBar *m_toolBar; QToolBar *m_toolBar;
QComboBox *m_entriesComboBox; QComboBox *m_entriesComboBox;