Vcs: Make some editor factories proper plugin pimpl members

Change-Id: I7f815c53bac8621b2198c57d7f1d7d4bd43eb282
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2020-02-07 07:51:20 +01:00
parent a44bfdd779
commit b5710099bb
8 changed files with 316 additions and 245 deletions

View File

@@ -71,6 +71,7 @@
using namespace VcsBase;
using namespace Utils;
using namespace std::placeholders;
namespace Mercurial {
namespace Internal {
@@ -95,25 +96,28 @@ private:
MercurialClient *m_client;
};
static const VcsBaseEditorParameters editorParameters[] = {
{
const VcsBaseEditorParameters logEditorParameters {
LogOutput,
Constants::FILELOG_ID,
Constants::FILELOG_DISPLAY_NAME,
Constants::LOGAPP},
{ AnnotateOutput,
Constants::ANNOTATELOG_ID,
Constants::ANNOTATELOG_DISPLAY_NAME,
Constants::ANNOTATEAPP},
{ DiffOutput,
Constants::DIFFLOG_ID,
Constants::DIFFLOG_DISPLAY_NAME,
Constants::DIFFAPP}
Constants::LOGAPP
};
static const VcsBaseSubmitEditorParameters submitEditorParameters = {
const VcsBaseEditorParameters annotateEditorParameters {
AnnotateOutput,
Constants::ANNOTATELOG_ID,
Constants::ANNOTATELOG_DISPLAY_NAME,
Constants::ANNOTATEAPP
};
const VcsBaseEditorParameters diffEditorParameters {
DiffOutput,
Constants::DIFFLOG_ID,
Constants::DIFFLOG_DISPLAY_NAME,
Constants::DIFFAPP
};
const VcsBaseSubmitEditorParameters submitEditorParameters {
Constants::COMMITMIMETYPE,
Constants::COMMIT_ID,
Constants::COMMIT_DISPLAY_NAME,
@@ -190,6 +194,8 @@ private:
void createDirectoryActions(const Core::Context &context);
void createRepositoryActions(const Core::Context &context);
void describe(const QString &source, const QString &id) { m_client.view(source, id); }
// Variables
MercurialSettings m_settings;
MercurialClient m_client{&m_settings};
@@ -216,6 +222,30 @@ private:
QString m_submitRepository;
bool m_submitActionTriggered = false;
VcsSubmitEditorFactory submitEditorFactory {
submitEditorParameters,
[] { return new CommitEditor; },
this
};
VcsEditorFactory logEditorFactory {
&logEditorParameters,
[this] { return new MercurialEditorWidget(&m_client); },
std::bind(&MercurialPluginPrivate::describe, this, _1, _2)
};
VcsEditorFactory annotateEditorFactory {
&annotateEditorParameters,
[this] { return new MercurialEditorWidget(&m_client); },
std::bind(&MercurialPluginPrivate::describe, this, _1, _2)
};
VcsEditorFactory diffEditorFactory {
&diffEditorParameters,
[this] { return new MercurialEditorWidget(&m_client); },
std::bind(&MercurialPluginPrivate::describe, this, _1, _2)
};
};
static MercurialPluginPrivate *dd = nullptr;
@@ -249,15 +279,6 @@ MercurialPluginPrivate::MercurialPluginPrivate()
connect(&m_client, &VcsBaseClient::changed, this, &MercurialPluginPrivate::changed);
connect(&m_client, &MercurialClient::needUpdate, this, &MercurialPluginPrivate::update);
const auto describeFunc = [this](const QString &source, const QString &id) {
m_client.view(source, id);
};
const auto widgetCreator = [this] { return new MercurialEditorWidget(&m_client); };
for (auto &editor : editorParameters)
new VcsEditorFactory(&editor, widgetCreator, describeFunc, this);
new VcsSubmitEditorFactory(submitEditorParameters, [] { return new CommitEditor; }, this, this);
const QString prefix = QLatin1String("hg");
m_commandLocator = new Core::CommandLocator("Mercurial", prefix, prefix, this);
@@ -881,7 +902,7 @@ void MercurialPlugin::testDiffFileResolving_data()
void MercurialPlugin::testDiffFileResolving()
{
VcsBaseEditorWidget::testDiffFileResolving(editorParameters[2].id);
VcsBaseEditorWidget::testDiffFileResolving(diffEditorParameters.id);
}
void MercurialPlugin::testLogResolving()
@@ -901,7 +922,7 @@ void MercurialPlugin::testLogResolving()
"date: Sat Jan 19 04:08:16 2013 +0100\n"
"summary: test-rebase: add another test for rebase with multiple roots\n"
);
VcsBaseEditorWidget::testLogResolving(editorParameters[0].id, data, "18473:692cbda1eb50", "18472:37100f30590f");
VcsBaseEditorWidget::testLogResolving(logEditorParameters.id, data, "18473:692cbda1eb50", "18472:37100f30590f");
}
#endif