forked from qt-creator/qt-creator
Vcs: Move VcsEditorFactory closer to its product
Change-Id: Iaf2e6bdb4f04f0f1314ca7725feb63394a693511 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -30,7 +30,6 @@
|
|||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseclient.h>
|
#include <vcsbase/vcsbaseclient.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
|
|||||||
@@ -39,7 +39,6 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
#include <vcsbase/vcsbasesubmiteditor.h>
|
#include <vcsbase/vcsbasesubmiteditor.h>
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
#include "cvstr.h"
|
#include "cvstr.h"
|
||||||
#include "cvsutils.h"
|
#include "cvsutils.h"
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseclient.h>
|
#include <vcsbase/vcsbaseclient.h>
|
||||||
#include <vcsbase/vcsbaseclientsettings.h>
|
#include <vcsbase/vcsbaseclientsettings.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <utils/layoutbuilder.h>
|
#include <utils/layoutbuilder.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseclient.h>
|
#include <vcsbase/vcsbaseclient.h>
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
#include <vcsbase/vcsbaseplugin.h>
|
#include <vcsbase/vcsbaseplugin.h>
|
||||||
|
|||||||
@@ -52,7 +52,6 @@
|
|||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
#include <utils/utilsicons.h>
|
#include <utils/utilsicons.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/cleandialog.h>
|
#include <vcsbase/cleandialog.h>
|
||||||
#include <vcsbase/submitfilemodel.h>
|
#include <vcsbase/submitfilemodel.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
#include <vcsbase/vcscommand.h>
|
#include <vcsbase/vcscommand.h>
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsbaseeditorconfig.h>
|
#include <vcsbase/vcsbaseeditorconfig.h>
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
|
|||||||
@@ -33,7 +33,6 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsbaseplugin.h>
|
#include <vcsbase/vcsbaseplugin.h>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ add_qtc_plugin(VcsBase
|
|||||||
PLUGIN_RECOMMENDS CodePaster CppEditor
|
PLUGIN_RECOMMENDS CodePaster CppEditor
|
||||||
SOURCES
|
SOURCES
|
||||||
baseannotationhighlighter.cpp baseannotationhighlighter.h
|
baseannotationhighlighter.cpp baseannotationhighlighter.h
|
||||||
basevcseditorfactory.cpp basevcseditorfactory.h
|
|
||||||
cleandialog.cpp cleandialog.h
|
cleandialog.cpp cleandialog.h
|
||||||
commonvcssettings.cpp commonvcssettings.h
|
commonvcssettings.cpp commonvcssettings.h
|
||||||
diffandloghighlighter.cpp diffandloghighlighter.h
|
diffandloghighlighter.cpp diffandloghighlighter.h
|
||||||
|
|||||||
@@ -1,65 +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 "basevcseditorfactory.h"
|
|
||||||
|
|
||||||
#include "vcsbaseeditor.h"
|
|
||||||
#include "vcsbasetr.h"
|
|
||||||
|
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
|
||||||
#include <texteditor/textdocument.h>
|
|
||||||
|
|
||||||
#include <diffeditor/diffeditorconstants.h>
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
|
||||||
#include <utils/qtcassert.h>
|
|
||||||
|
|
||||||
#include <QStringList>
|
|
||||||
|
|
||||||
using namespace TextEditor;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
\class VcsBase::BaseVCSEditorFactory
|
|
||||||
|
|
||||||
\brief The BaseVCSEditorFactory class is the base class for editor
|
|
||||||
factories creating instances of VcsBaseEditor subclasses.
|
|
||||||
|
|
||||||
\sa VcsBase::VcsBaseEditorWidget
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace VcsBase {
|
|
||||||
|
|
||||||
VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
|
||||||
// Force copy, see QTCREATORBUG-13218
|
|
||||||
const EditorWidgetCreator editorWidgetCreator,
|
|
||||||
std::function<void (const Utils::FilePath &, const QString &)> describeFunc)
|
|
||||||
{
|
|
||||||
setId(parameters->id);
|
|
||||||
setDisplayName(Tr::tr(parameters->displayName));
|
|
||||||
if (QLatin1String(parameters->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE))
|
|
||||||
addMimeType(QLatin1String(parameters->mimeType));
|
|
||||||
|
|
||||||
setEditorActionHandlers(TextEditorActionHandler::None);
|
|
||||||
setDuplicatedSupported(false);
|
|
||||||
|
|
||||||
setDocumentCreator([parameters] {
|
|
||||||
auto document = new TextDocument(parameters->id);
|
|
||||||
document->setMimeType(QLatin1String(parameters->mimeType));
|
|
||||||
document->setSuspendAllowed(false);
|
|
||||||
return document;
|
|
||||||
});
|
|
||||||
|
|
||||||
setEditorWidgetCreator([parameters, editorWidgetCreator, describeFunc] {
|
|
||||||
auto widget = editorWidgetCreator();
|
|
||||||
auto editorWidget = Aggregation::query<VcsBaseEditorWidget>(widget);
|
|
||||||
editorWidget->setDescribeFunc(describeFunc);
|
|
||||||
editorWidget->setParameters(parameters);
|
|
||||||
return widget;
|
|
||||||
});
|
|
||||||
|
|
||||||
setEditorCreator([] { return new VcsBaseEditor(); });
|
|
||||||
setMarksVisible(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
VcsEditorFactory::~VcsEditorFactory() = default;
|
|
||||||
|
|
||||||
} // namespace VcsBase
|
|
||||||
@@ -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
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "vcsbase_global.h"
|
|
||||||
|
|
||||||
#include <texteditor/texteditor.h>
|
|
||||||
|
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
namespace VcsBase {
|
|
||||||
class VcsBaseEditorParameters;
|
|
||||||
|
|
||||||
class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
|
||||||
const EditorWidgetCreator editorWidgetCreator,
|
|
||||||
std::function<void(const Utils::FilePath &, const QString &)> describeFunc);
|
|
||||||
|
|
||||||
~VcsEditorFactory();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace VcsBase
|
|
||||||
@@ -21,8 +21,6 @@ QtcPlugin {
|
|||||||
files: [
|
files: [
|
||||||
"baseannotationhighlighter.cpp",
|
"baseannotationhighlighter.cpp",
|
||||||
"baseannotationhighlighter.h",
|
"baseannotationhighlighter.h",
|
||||||
"basevcseditorfactory.cpp",
|
|
||||||
"basevcseditorfactory.h",
|
|
||||||
"cleandialog.cpp",
|
"cleandialog.cpp",
|
||||||
"cleandialog.h",
|
"cleandialog.h",
|
||||||
"commonvcssettings.cpp",
|
"commonvcssettings.cpp",
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
#include "vcsbaseeditor.h"
|
#include "vcsbaseeditor.h"
|
||||||
|
|
||||||
#include "baseannotationhighlighter.h"
|
#include "baseannotationhighlighter.h"
|
||||||
#include "basevcseditorfactory.h"
|
|
||||||
#include "diffandloghighlighter.h"
|
#include "diffandloghighlighter.h"
|
||||||
#include "vcsbaseeditorconfig.h"
|
#include "vcsbaseeditorconfig.h"
|
||||||
#include "vcsbaseplugin.h"
|
#include "vcsbaseplugin.h"
|
||||||
@@ -19,6 +18,8 @@
|
|||||||
|
|
||||||
#include <cpaster/codepasterservice.h>
|
#include <cpaster/codepasterservice.h>
|
||||||
|
|
||||||
|
#include <diffeditor/diffeditorconstants.h>
|
||||||
|
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
|
|
||||||
#include <projectexplorer/editorconfiguration.h>
|
#include <projectexplorer/editorconfiguration.h>
|
||||||
@@ -26,6 +27,7 @@
|
|||||||
#include <projectexplorer/projectexplorer.h>
|
#include <projectexplorer/projectexplorer.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
|
|
||||||
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
#include <texteditor/textdocument.h>
|
#include <texteditor/textdocument.h>
|
||||||
#include <texteditor/textdocumentlayout.h>
|
#include <texteditor/textdocumentlayout.h>
|
||||||
#include <texteditor/syntaxhighlighterrunner.h>
|
#include <texteditor/syntaxhighlighterrunner.h>
|
||||||
@@ -1643,6 +1645,49 @@ IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class VcsBase::VcsEditorFactory
|
||||||
|
|
||||||
|
\brief The VcsEditorFactory class is the base class for editor
|
||||||
|
factories creating instances of VcsBaseEditor subclasses.
|
||||||
|
|
||||||
|
\sa VcsBase::VcsBaseEditorWidget
|
||||||
|
*/
|
||||||
|
|
||||||
|
VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
||||||
|
// Force copy, see QTCREATORBUG-13218
|
||||||
|
const EditorWidgetCreator editorWidgetCreator,
|
||||||
|
std::function<void (const Utils::FilePath &, const QString &)> describeFunc)
|
||||||
|
{
|
||||||
|
setId(parameters->id);
|
||||||
|
setDisplayName(Tr::tr(parameters->displayName));
|
||||||
|
if (QLatin1String(parameters->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE))
|
||||||
|
addMimeType(QLatin1String(parameters->mimeType));
|
||||||
|
|
||||||
|
setEditorActionHandlers(TextEditorActionHandler::None);
|
||||||
|
setDuplicatedSupported(false);
|
||||||
|
|
||||||
|
setDocumentCreator([parameters] {
|
||||||
|
auto document = new TextDocument(parameters->id);
|
||||||
|
document->setMimeType(QLatin1String(parameters->mimeType));
|
||||||
|
document->setSuspendAllowed(false);
|
||||||
|
return document;
|
||||||
|
});
|
||||||
|
|
||||||
|
setEditorWidgetCreator([parameters, editorWidgetCreator, describeFunc] {
|
||||||
|
auto widget = editorWidgetCreator();
|
||||||
|
auto editorWidget = Aggregation::query<VcsBaseEditorWidget>(widget);
|
||||||
|
editorWidget->setDescribeFunc(describeFunc);
|
||||||
|
editorWidget->setParameters(parameters);
|
||||||
|
return widget;
|
||||||
|
});
|
||||||
|
|
||||||
|
setEditorCreator([] { return new VcsBaseEditor(); });
|
||||||
|
setMarksVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
VcsEditorFactory::~VcsEditorFactory() = default;
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
|
|||||||
@@ -286,6 +286,16 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
VcsEditorFactory(const VcsBaseEditorParameters *parameters,
|
||||||
|
const EditorWidgetCreator editorWidgetCreator,
|
||||||
|
std::function<void(const Utils::FilePath &, const QString &)> describeFunc);
|
||||||
|
|
||||||
|
~VcsEditorFactory();
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(VcsBase::DiffChunk)
|
Q_DECLARE_METATYPE(VcsBase::DiffChunk)
|
||||||
|
|||||||
Reference in New Issue
Block a user