forked from qt-creator/qt-creator
DiffEditor: Hide DiffEditor definition in .cpp
And use the new factory setup scheme. Change-Id: I9b220e9995f82edc25e7cc43dbdbbbbcdac3cfd3 Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -8,7 +8,6 @@ add_qtc_plugin(DiffEditor
|
|||||||
diffeditorconstants.h
|
diffeditorconstants.h
|
||||||
diffeditorcontroller.cpp diffeditorcontroller.h
|
diffeditorcontroller.cpp diffeditorcontroller.h
|
||||||
diffeditordocument.cpp diffeditordocument.h
|
diffeditordocument.cpp diffeditordocument.h
|
||||||
diffeditorfactory.cpp diffeditorfactory.h
|
|
||||||
diffeditoricons.h
|
diffeditoricons.h
|
||||||
diffeditorplugin.cpp diffeditorplugin.h
|
diffeditorplugin.cpp diffeditorplugin.h
|
||||||
diffeditorwidgetcontroller.cpp diffeditorwidgetcontroller.h
|
diffeditorwidgetcontroller.cpp diffeditorwidgetcontroller.h
|
||||||
|
@@ -2,6 +2,8 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "diffeditor.h"
|
#include "diffeditor.h"
|
||||||
|
|
||||||
|
#include "diffenums.h"
|
||||||
#include "diffeditorconstants.h"
|
#include "diffeditorconstants.h"
|
||||||
#include "diffeditordocument.h"
|
#include "diffeditordocument.h"
|
||||||
#include "diffeditoricons.h"
|
#include "diffeditoricons.h"
|
||||||
@@ -10,6 +12,9 @@
|
|||||||
|
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/idocument.h>
|
||||||
|
#include <coreplugin/editormanager/ieditor.h>
|
||||||
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
#include <coreplugin/minisplitter.h>
|
#include <coreplugin/minisplitter.h>
|
||||||
|
|
||||||
#include <texteditor/displaysettings.h>
|
#include <texteditor/displaysettings.h>
|
||||||
@@ -22,6 +27,7 @@
|
|||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/fileutils.h>
|
||||||
|
#include <utils/guard.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
@@ -123,6 +129,69 @@ void DescriptionEditorWidget::applyFontSettings()
|
|||||||
|
|
||||||
///////////////////////////////// DiffEditor //////////////////////////////////
|
///////////////////////////////// DiffEditor //////////////////////////////////
|
||||||
|
|
||||||
|
class DiffEditor : public Core::IEditor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DiffEditor(DiffEditorDocument *doc);
|
||||||
|
~DiffEditor() override;
|
||||||
|
|
||||||
|
Core::IEditor *duplicate() override;
|
||||||
|
Core::IDocument *document() const override;
|
||||||
|
QWidget *toolBar() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DiffEditor();
|
||||||
|
void setDocument(std::shared_ptr<DiffEditorDocument> doc);
|
||||||
|
|
||||||
|
void documentHasChanged();
|
||||||
|
void toggleDescription();
|
||||||
|
void updateDescription();
|
||||||
|
void contextLineCountHasChanged(int lines);
|
||||||
|
void ignoreWhitespaceHasChanged();
|
||||||
|
void prepareForReload();
|
||||||
|
void reloadHasFinished(bool success);
|
||||||
|
void currentIndexChanged(int index);
|
||||||
|
void setCurrentDiffFileIndex(int index);
|
||||||
|
void documentStateChanged();
|
||||||
|
|
||||||
|
void toggleSync();
|
||||||
|
|
||||||
|
IDiffView *loadSettings();
|
||||||
|
void saveSetting(const Utils::Key &key, const QVariant &value) const;
|
||||||
|
void updateEntryToolTip();
|
||||||
|
void showDiffView(IDiffView *view);
|
||||||
|
void updateDiffEditorSwitcher();
|
||||||
|
void addView(IDiffView *view);
|
||||||
|
IDiffView *currentView() const;
|
||||||
|
void setCurrentView(IDiffView *view);
|
||||||
|
IDiffView *nextView();
|
||||||
|
void setupView(IDiffView *view);
|
||||||
|
|
||||||
|
std::shared_ptr<DiffEditorDocument> m_document;
|
||||||
|
DescriptionEditorWidget *m_descriptionWidget = nullptr;
|
||||||
|
UnifiedView *m_unifiedView = nullptr;
|
||||||
|
SideBySideView *m_sideBySideView = nullptr;
|
||||||
|
QStackedWidget *m_stackedWidget = nullptr;
|
||||||
|
QList<IDiffView *> m_views;
|
||||||
|
QToolBar *m_toolBar = nullptr;
|
||||||
|
QComboBox *m_entriesComboBox = nullptr;
|
||||||
|
QSpinBox *m_contextSpinBox = nullptr;
|
||||||
|
QAction *m_contextSpinBoxAction = nullptr;
|
||||||
|
QAction *m_toggleSyncAction = nullptr;
|
||||||
|
QAction *m_whitespaceButtonAction = nullptr;
|
||||||
|
QAction *m_toggleDescriptionAction = nullptr;
|
||||||
|
QAction *m_reloadAction = nullptr;
|
||||||
|
QAction *m_contextLabelAction = nullptr;
|
||||||
|
QAction *m_viewSwitcherAction = nullptr;
|
||||||
|
QPair<QString, QString> m_currentFileChunk;
|
||||||
|
int m_currentViewIndex = -1;
|
||||||
|
int m_currentDiffFileIndex = -1;
|
||||||
|
int m_descriptionHeight = 8;
|
||||||
|
Utils::Guard m_ignoreChanges;
|
||||||
|
bool m_sync = false;
|
||||||
|
bool m_showDescription = true;
|
||||||
|
};
|
||||||
|
|
||||||
DiffEditor::DiffEditor()
|
DiffEditor::DiffEditor()
|
||||||
{
|
{
|
||||||
// Editor:
|
// Editor:
|
||||||
@@ -599,6 +668,23 @@ void DiffEditor::showDiffView(IDiffView *view)
|
|||||||
setupView(view);
|
setupView(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace DiffEditor::Internal
|
class DiffEditorFactory : public Core::IEditorFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DiffEditorFactory()
|
||||||
|
{
|
||||||
|
setId(Constants::DIFF_EDITOR_ID);
|
||||||
|
setDisplayName(Tr::tr("Diff Editor"));
|
||||||
|
addMimeType(Constants::DIFF_EDITOR_MIMETYPE);
|
||||||
|
setEditorCreator([] { return new DiffEditor(new DiffEditorDocument); });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void setupDiffEditorFactory()
|
||||||
|
{
|
||||||
|
static DiffEditorFactory theDiffEditorFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // DiffEditor::Internal
|
||||||
|
|
||||||
#include "diffeditor.moc"
|
#include "diffeditor.moc"
|
||||||
|
@@ -3,90 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "diffenums.h"
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/ieditor.h>
|
|
||||||
#include <coreplugin/idocument.h>
|
|
||||||
#include <utils/guard.h>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QComboBox;
|
|
||||||
class QSpinBox;
|
|
||||||
class QToolBar;
|
|
||||||
class QStackedWidget;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace DiffEditor::Internal {
|
namespace DiffEditor::Internal {
|
||||||
|
|
||||||
class DescriptionEditorWidget;
|
void setupDiffEditorFactory();
|
||||||
class DiffEditorDocument;
|
|
||||||
class IDiffView;
|
|
||||||
class UnifiedView;
|
|
||||||
class SideBySideView;
|
|
||||||
|
|
||||||
class DiffEditor : public Core::IEditor
|
} // DiffEditor::Internal
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
DiffEditor(DiffEditorDocument *doc);
|
|
||||||
~DiffEditor() override;
|
|
||||||
|
|
||||||
Core::IEditor *duplicate() override;
|
|
||||||
Core::IDocument *document() const override;
|
|
||||||
QWidget *toolBar() override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
DiffEditor();
|
|
||||||
void setDocument(std::shared_ptr<DiffEditorDocument> doc);
|
|
||||||
|
|
||||||
void documentHasChanged();
|
|
||||||
void toggleDescription();
|
|
||||||
void updateDescription();
|
|
||||||
void contextLineCountHasChanged(int lines);
|
|
||||||
void ignoreWhitespaceHasChanged();
|
|
||||||
void prepareForReload();
|
|
||||||
void reloadHasFinished(bool success);
|
|
||||||
void currentIndexChanged(int index);
|
|
||||||
void setCurrentDiffFileIndex(int index);
|
|
||||||
void documentStateChanged();
|
|
||||||
|
|
||||||
void toggleSync();
|
|
||||||
|
|
||||||
IDiffView *loadSettings();
|
|
||||||
void saveSetting(const Utils::Key &key, const QVariant &value) const;
|
|
||||||
void updateEntryToolTip();
|
|
||||||
void showDiffView(IDiffView *view);
|
|
||||||
void updateDiffEditorSwitcher();
|
|
||||||
void addView(IDiffView *view);
|
|
||||||
IDiffView *currentView() const;
|
|
||||||
void setCurrentView(IDiffView *view);
|
|
||||||
IDiffView *nextView();
|
|
||||||
void setupView(IDiffView *view);
|
|
||||||
|
|
||||||
std::shared_ptr<DiffEditorDocument> m_document;
|
|
||||||
DescriptionEditorWidget *m_descriptionWidget = nullptr;
|
|
||||||
UnifiedView *m_unifiedView = nullptr;
|
|
||||||
SideBySideView *m_sideBySideView = nullptr;
|
|
||||||
QStackedWidget *m_stackedWidget = nullptr;
|
|
||||||
QList<IDiffView *> m_views;
|
|
||||||
QToolBar *m_toolBar = nullptr;
|
|
||||||
QComboBox *m_entriesComboBox = nullptr;
|
|
||||||
QSpinBox *m_contextSpinBox = nullptr;
|
|
||||||
QAction *m_contextSpinBoxAction = nullptr;
|
|
||||||
QAction *m_toggleSyncAction = nullptr;
|
|
||||||
QAction *m_whitespaceButtonAction = nullptr;
|
|
||||||
QAction *m_toggleDescriptionAction = nullptr;
|
|
||||||
QAction *m_reloadAction = nullptr;
|
|
||||||
QAction *m_contextLabelAction = nullptr;
|
|
||||||
QAction *m_viewSwitcherAction = nullptr;
|
|
||||||
QPair<QString, QString> m_currentFileChunk;
|
|
||||||
int m_currentViewIndex = -1;
|
|
||||||
int m_currentDiffFileIndex = -1;
|
|
||||||
int m_descriptionHeight = 8;
|
|
||||||
Utils::Guard m_ignoreChanges;
|
|
||||||
bool m_sync = false;
|
|
||||||
bool m_showDescription = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace DiffEditor::Internal
|
|
||||||
|
@@ -24,8 +24,6 @@ QtcPlugin {
|
|||||||
"diffeditorcontroller.h",
|
"diffeditorcontroller.h",
|
||||||
"diffeditordocument.cpp",
|
"diffeditordocument.cpp",
|
||||||
"diffeditordocument.h",
|
"diffeditordocument.h",
|
||||||
"diffeditorfactory.cpp",
|
|
||||||
"diffeditorfactory.h",
|
|
||||||
"diffeditorplugin.cpp",
|
"diffeditorplugin.cpp",
|
||||||
"diffeditorplugin.h",
|
"diffeditorplugin.h",
|
||||||
"diffeditorwidgetcontroller.cpp",
|
"diffeditorwidgetcontroller.cpp",
|
||||||
|
@@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#include "diffeditorfactory.h"
|
|
||||||
#include "diffeditor.h"
|
|
||||||
#include "diffeditorconstants.h"
|
|
||||||
#include "diffeditordocument.h"
|
|
||||||
#include "diffeditortr.h"
|
|
||||||
|
|
||||||
#include <QCoreApplication>
|
|
||||||
|
|
||||||
using namespace Core;
|
|
||||||
using namespace Utils;
|
|
||||||
|
|
||||||
namespace DiffEditor::Internal {
|
|
||||||
|
|
||||||
DiffEditorFactory::DiffEditorFactory()
|
|
||||||
{
|
|
||||||
setId(Constants::DIFF_EDITOR_ID);
|
|
||||||
setDisplayName(Tr::tr("Diff Editor"));
|
|
||||||
addMimeType(Constants::DIFF_EDITOR_MIMETYPE);
|
|
||||||
setEditorCreator([] { return new DiffEditor(new DiffEditorDocument); });
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace DiffEditor::Internal
|
|
@@ -1,16 +0,0 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
|
||||||
|
|
||||||
namespace DiffEditor::Internal {
|
|
||||||
|
|
||||||
class DiffEditorFactory : public Core::IEditorFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DiffEditorFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace DiffEditor::Internal
|
|
@@ -5,7 +5,7 @@
|
|||||||
#include "diffeditorconstants.h"
|
#include "diffeditorconstants.h"
|
||||||
#include "diffeditorcontroller.h"
|
#include "diffeditorcontroller.h"
|
||||||
#include "diffeditordocument.h"
|
#include "diffeditordocument.h"
|
||||||
#include "diffeditorfactory.h"
|
#include "diffeditor.h"
|
||||||
#include "diffeditortr.h"
|
#include "diffeditortr.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
@@ -412,12 +412,13 @@ public:
|
|||||||
QAction *m_diffCurrentFileAction = nullptr;
|
QAction *m_diffCurrentFileAction = nullptr;
|
||||||
QAction *m_diffOpenFilesAction = nullptr;
|
QAction *m_diffOpenFilesAction = nullptr;
|
||||||
|
|
||||||
DiffEditorFactory m_editorFactory;
|
|
||||||
DiffEditorServiceImpl m_service;
|
DiffEditorServiceImpl m_service;
|
||||||
};
|
};
|
||||||
|
|
||||||
DiffEditorPluginPrivate::DiffEditorPluginPrivate()
|
DiffEditorPluginPrivate::DiffEditorPluginPrivate()
|
||||||
{
|
{
|
||||||
|
setupDiffEditorFactory();
|
||||||
|
|
||||||
//register actions
|
//register actions
|
||||||
ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
ActionContainer *toolsContainer = ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
||||||
toolsContainer->insertGroup(Core::Constants::G_TOOLS_DEBUG, Constants::G_TOOLS_DIFF);
|
toolsContainer->insertGroup(Core::Constants::G_TOOLS_DEBUG, Constants::G_TOOLS_DIFF);
|
||||||
|
Reference in New Issue
Block a user