summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-02-05 09:27:26 +0100
committerhjk <hjk@qt.io>2020-02-06 07:03:44 +0000
commit7f37c503db291d031770701cd0b912405597dbb7 (patch)
treeb20a9480011e16bc7c72bce627d182f9a62b7b1d
parentc17767c78ebc6b3d3b66e4d78d46b0eef4ac003f (diff)
downloadqt-creator-7f37c503db291d031770701cd0b912405597dbb7.tar.gz
Vcs: Move responsibility to set editor parameters to editor factory
So it doesn't need to be named twice in the editor factory setup. This intentially includes a de-optimiztion: storing the parameters by value, not by pointer. That's more natural, does not need to keep the parameters alive on the caller side, and it's uncritical in this context. Change-Id: I92867d3f2f75c38911ae82d3eeb4759cba71b723 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
-rw-r--r--src/plugins/bazaar/bazaarplugin.cpp4
-rw-r--r--src/plugins/bazaar/commiteditor.cpp4
-rw-r--r--src/plugins/bazaar/commiteditor.h2
-rw-r--r--src/plugins/clearcase/clearcaseplugin.cpp3
-rw-r--r--src/plugins/clearcase/clearcasesubmiteditor.cpp4
-rw-r--r--src/plugins/clearcase/clearcasesubmiteditor.h2
-rw-r--r--src/plugins/cvs/cvsplugin.cpp3
-rw-r--r--src/plugins/cvs/cvssubmiteditor.cpp4
-rw-r--r--src/plugins/cvs/cvssubmiteditor.h4
-rw-r--r--src/plugins/git/gitplugin.cpp3
-rw-r--r--src/plugins/git/gitsubmiteditor.cpp4
-rw-r--r--src/plugins/git/gitsubmiteditor.h2
-rw-r--r--src/plugins/mercurial/commiteditor.cpp4
-rw-r--r--src/plugins/mercurial/commiteditor.h2
-rw-r--r--src/plugins/mercurial/mercurialplugin.cpp3
-rw-r--r--src/plugins/perforce/perforceplugin.cpp3
-rw-r--r--src/plugins/perforce/perforcesubmiteditor.cpp4
-rw-r--r--src/plugins/perforce/perforcesubmiteditor.h2
-rw-r--r--src/plugins/subversion/subversionplugin.cpp3
-rw-r--r--src/plugins/subversion/subversionsubmiteditor.cpp4
-rw-r--r--src/plugins/subversion/subversionsubmiteditor.h2
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.cpp13
-rw-r--r--src/plugins/vcsbase/basevcssubmiteditorfactory.h2
-rw-r--r--src/plugins/vcsbase/submiteditorfile.cpp7
-rw-r--r--src/plugins/vcsbase/submiteditorfile.h3
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.cpp37
-rw-r--r--src/plugins/vcsbase/vcsbasesubmiteditor.h8
27 files changed, 66 insertions, 70 deletions
diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp
index 7e14db5186..d05fad97c9 100644
--- a/src/plugins/bazaar/bazaarplugin.cpp
+++ b/src/plugins/bazaar/bazaarplugin.cpp
@@ -204,8 +204,8 @@ public:
OptionsPage m_optionsPage{[this] { configurationChanged(); }, &m_settings};
VcsSubmitEditorFactory m_submitEditorFactory {
- &submitEditorParameters,
- [] { return new CommitEditor(&submitEditorParameters); },
+ submitEditorParameters,
+ [] { return new CommitEditor; },
this
};
Core::CommandLocator *m_commandLocator = nullptr;
diff --git a/src/plugins/bazaar/commiteditor.cpp b/src/plugins/bazaar/commiteditor.cpp
index 3460bbc303..1f8fcfa1a0 100644
--- a/src/plugins/bazaar/commiteditor.cpp
+++ b/src/plugins/bazaar/commiteditor.cpp
@@ -35,8 +35,8 @@
using namespace Bazaar::Internal;
-CommitEditor::CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) :
- VcsBase::VcsBaseSubmitEditor(parameters, new BazaarCommitWidget)
+CommitEditor::CommitEditor() :
+ VcsBase::VcsBaseSubmitEditor(new BazaarCommitWidget)
{
document()->setPreferredDisplayName(tr("Commit Editor"));
}
diff --git a/src/plugins/bazaar/commiteditor.h b/src/plugins/bazaar/commiteditor.h
index a6b090f791..6e44d5ca55 100644
--- a/src/plugins/bazaar/commiteditor.h
+++ b/src/plugins/bazaar/commiteditor.h
@@ -41,7 +41,7 @@ class CommitEditor : public VcsBase::VcsBaseSubmitEditor
Q_OBJECT
public:
- explicit CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
+ CommitEditor();
void setFields(const QString &repositoryRoot, const BranchInfo &branch,
const QString &userName, const QString &email,
diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp
index 254b628172..7e97a2e1e7 100644
--- a/src/plugins/clearcase/clearcaseplugin.cpp
+++ b/src/plugins/clearcase/clearcaseplugin.cpp
@@ -439,8 +439,7 @@ ClearCasePluginPrivate::ClearCasePluginPrivate()
new ClearCaseSettingsPage(this);
- new VcsSubmitEditorFactory(&submitParameters,
- []() { return new ClearCaseSubmitEditor(&submitParameters); }, this);
+ new VcsSubmitEditorFactory(submitParameters, [] { return new ClearCaseSubmitEditor; }, this);
// any editor responds to describe (when clicking a version)
const auto describeFunc = [this](const QString &source, const QString &changeNr) {
diff --git a/src/plugins/clearcase/clearcasesubmiteditor.cpp b/src/plugins/clearcase/clearcasesubmiteditor.cpp
index eed9cf193c..6973e36602 100644
--- a/src/plugins/clearcase/clearcasesubmiteditor.cpp
+++ b/src/plugins/clearcase/clearcasesubmiteditor.cpp
@@ -33,8 +33,8 @@
using namespace ClearCase::Internal;
-ClearCaseSubmitEditor::ClearCaseSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) :
- VcsBase::VcsBaseSubmitEditor(parameters, new ClearCaseSubmitEditorWidget)
+ClearCaseSubmitEditor::ClearCaseSubmitEditor() :
+ VcsBase::VcsBaseSubmitEditor(new ClearCaseSubmitEditorWidget)
{
document()->setPreferredDisplayName(tr("ClearCase Check In"));
}
diff --git a/src/plugins/clearcase/clearcasesubmiteditor.h b/src/plugins/clearcase/clearcasesubmiteditor.h
index 90b9dd1a00..322e2de0f9 100644
--- a/src/plugins/clearcase/clearcasesubmiteditor.h
+++ b/src/plugins/clearcase/clearcasesubmiteditor.h
@@ -38,7 +38,7 @@ class ClearCaseSubmitEditor : public VcsBase::VcsBaseSubmitEditor
Q_OBJECT
public:
- explicit ClearCaseSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
+ ClearCaseSubmitEditor();
static QString fileFromStatusLine(const QString &statusLine);
diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp
index 17a18c1d02..de59c20580 100644
--- a/src/plugins/cvs/cvsplugin.cpp
+++ b/src/plugins/cvs/cvsplugin.cpp
@@ -518,8 +518,7 @@ CvsPluginPrivate::CvsPluginPrivate()
new CvsSettingsPage([this] { configurationChanged(); }, &m_settings, this);
- new VcsSubmitEditorFactory(&submitParameters,
- []() { return new CvsSubmitEditor(&submitParameters); }, this);
+ new VcsSubmitEditorFactory(submitParameters, [] { return new CvsSubmitEditor; }, this);
const auto describeFunc = [this](const QString &source, const QString &changeNr) {
QString errorMessage;
diff --git a/src/plugins/cvs/cvssubmiteditor.cpp b/src/plugins/cvs/cvssubmiteditor.cpp
index 5cbae05b4f..7188dfe526 100644
--- a/src/plugins/cvs/cvssubmiteditor.cpp
+++ b/src/plugins/cvs/cvssubmiteditor.cpp
@@ -31,8 +31,8 @@
using namespace Cvs::Internal;
using namespace VcsBase;
-CvsSubmitEditor::CvsSubmitEditor(const VcsBaseSubmitEditorParameters *parameters) :
- VcsBaseSubmitEditor(parameters, new SubmitEditorWidget),
+CvsSubmitEditor::CvsSubmitEditor() :
+ VcsBase::VcsBaseSubmitEditor(new SubmitEditorWidget),
m_msgAdded(tr("Added")),
m_msgRemoved(tr("Removed")),
m_msgModified(tr("Modified"))
diff --git a/src/plugins/cvs/cvssubmiteditor.h b/src/plugins/cvs/cvssubmiteditor.h
index e4d99986b2..49511ce9a9 100644
--- a/src/plugins/cvs/cvssubmiteditor.h
+++ b/src/plugins/cvs/cvssubmiteditor.h
@@ -38,13 +38,13 @@ class CvsSubmitEditor : public VcsBase::VcsBaseSubmitEditor
Q_OBJECT
public:
+ CvsSubmitEditor();
+
enum State { LocallyAdded, LocallyModified, LocallyRemoved };
// A list of state indicators and file names.
typedef QPair<State, QString> StateFilePair;
typedef QList<StateFilePair> StateFilePairs;
- explicit CvsSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
-
void setStateList(const StateFilePairs &statusOutput);
private:
diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp
index 7216bfc773..d22f3ee741 100644
--- a/src/plugins/git/gitplugin.cpp
+++ b/src/plugins/git/gitplugin.cpp
@@ -367,8 +367,7 @@ GitPluginPrivate::GitPluginPrivate()
for (int i = 0; i < editorCount; i++)
new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc, this);
- new VcsSubmitEditorFactory(&submitParameters,
- []() { return new GitSubmitEditor(&submitParameters); }, this);
+ new VcsSubmitEditorFactory(submitParameters, [] { return new GitSubmitEditor; }, this);
const QString prefix = "git";
m_commandLocator = new CommandLocator("Git", prefix, prefix, this);
diff --git a/src/plugins/git/gitsubmiteditor.cpp b/src/plugins/git/gitsubmiteditor.cpp
index d1043b033a..726ce80c25 100644
--- a/src/plugins/git/gitsubmiteditor.cpp
+++ b/src/plugins/git/gitsubmiteditor.cpp
@@ -98,8 +98,8 @@ CommitDataFetchResult CommitDataFetchResult::fetch(CommitType commitType, const
* option for staged files. So, we sort apart the diff file lists
* according to a type flag we add to the model. */
-GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters) :
- VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget)
+GitSubmitEditor::GitSubmitEditor() :
+ VcsBaseSubmitEditor(new GitSubmitEditorWidget)
{
connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected);
connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit);
diff --git a/src/plugins/git/gitsubmiteditor.h b/src/plugins/git/gitsubmiteditor.h
index 55dbcf4de3..99c6ea81e9 100644
--- a/src/plugins/git/gitsubmiteditor.h
+++ b/src/plugins/git/gitsubmiteditor.h
@@ -55,7 +55,7 @@ class GitSubmitEditor : public VcsBase::VcsBaseSubmitEditor
Q_OBJECT
public:
- explicit GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
+ GitSubmitEditor();
~GitSubmitEditor() override;
void setCommitData(const CommitData &);
diff --git a/src/plugins/mercurial/commiteditor.cpp b/src/plugins/mercurial/commiteditor.cpp
index 3a2bdb2a1d..84abca3982 100644
--- a/src/plugins/mercurial/commiteditor.cpp
+++ b/src/plugins/mercurial/commiteditor.cpp
@@ -36,8 +36,8 @@ using namespace VcsBase;
namespace Mercurial {
namespace Internal {
-CommitEditor::CommitEditor(const VcsBaseSubmitEditorParameters *parameters) :
- VcsBaseSubmitEditor(parameters, new MercurialCommitWidget)
+CommitEditor::CommitEditor() :
+ VcsBaseSubmitEditor(new MercurialCommitWidget)
{
document()->setPreferredDisplayName(tr("Commit Editor"));
}
diff --git a/src/plugins/mercurial/commiteditor.h b/src/plugins/mercurial/commiteditor.h
index 2d977f7bd7..27fa527425 100644
--- a/src/plugins/mercurial/commiteditor.h
+++ b/src/plugins/mercurial/commiteditor.h
@@ -42,7 +42,7 @@ class CommitEditor : public VcsBase::VcsBaseSubmitEditor
Q_OBJECT
public:
- explicit CommitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
+ CommitEditor();
void setFields(const QFileInfo &repositoryRoot, const QString &branch,
const QString &userName, const QString &email,
diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp
index 8a905e2425..2ab9402b18 100644
--- a/src/plugins/mercurial/mercurialplugin.cpp
+++ b/src/plugins/mercurial/mercurialplugin.cpp
@@ -256,8 +256,7 @@ MercurialPluginPrivate::MercurialPluginPrivate()
for (auto &editor : editorParameters)
new VcsEditorFactory(&editor, widgetCreator, describeFunc, this);
- new VcsSubmitEditorFactory(&submitEditorParameters,
- []() { return new CommitEditor(&submitEditorParameters); }, this);
+ new VcsSubmitEditorFactory(submitEditorParameters, [] { return new CommitEditor; }, this);
const QString prefix = QLatin1String("hg");
m_commandLocator = new Core::CommandLocator("Mercurial", prefix, prefix, this);
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index 0f42638e6a..7f128d13d2 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -381,8 +381,7 @@ PerforcePluginPrivate::PerforcePluginPrivate()
m_settings.fromSettings(ICore::settings());
// Editor factories
- new VcsSubmitEditorFactory(&submitParameters,
- []() { return new PerforceSubmitEditor(&submitParameters); }, this);
+ new VcsSubmitEditorFactory(submitParameters, [] { return new PerforceSubmitEditor; }, this);
const auto describeFunc = [this](const QString &source, const QString &n) {
describe(source, n);
diff --git a/src/plugins/perforce/perforcesubmiteditor.cpp b/src/plugins/perforce/perforcesubmiteditor.cpp
index 29b72462b0..596a9c32e0 100644
--- a/src/plugins/perforce/perforcesubmiteditor.cpp
+++ b/src/plugins/perforce/perforcesubmiteditor.cpp
@@ -36,8 +36,8 @@ namespace Internal {
enum { FileSpecRole = Qt::UserRole + 1 };
-PerforceSubmitEditor::PerforceSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) :
- VcsBaseSubmitEditor(parameters, new PerforceSubmitEditorWidget),
+PerforceSubmitEditor::PerforceSubmitEditor() :
+ VcsBaseSubmitEditor(new PerforceSubmitEditorWidget),
m_fileModel(new VcsBase::SubmitFileModel(this))
{
document()->setPreferredDisplayName(tr("Perforce Submit"));
diff --git a/src/plugins/perforce/perforcesubmiteditor.h b/src/plugins/perforce/perforcesubmiteditor.h
index dc43eeeab7..568822c538 100644
--- a/src/plugins/perforce/perforcesubmiteditor.h
+++ b/src/plugins/perforce/perforcesubmiteditor.h
@@ -50,7 +50,7 @@ class PerforceSubmitEditor : public VcsBase::VcsBaseSubmitEditor
Q_OBJECT
public:
- explicit PerforceSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
+ PerforceSubmitEditor();
/* The p4 submit starts with all opened files. Restrict
* it to the current project files in question. */
diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp
index dbdc47fd06..7a6fb59386 100644
--- a/src/plugins/subversion/subversionplugin.cpp
+++ b/src/plugins/subversion/subversionplugin.cpp
@@ -388,8 +388,7 @@ SubversionPluginPrivate::SubversionPluginPrivate()
using namespace Core::Constants;
Context context(SUBVERSION_CONTEXT);
- new VcsSubmitEditorFactory(&submitParameters,
- []() { return new SubversionSubmitEditor(&submitParameters); }, this);
+ new VcsSubmitEditorFactory(submitParameters, [] { return new SubversionSubmitEditor; }, this);
const auto describeFunc = [this](const QString &source, const QString &id) {
describe(source, id);
diff --git a/src/plugins/subversion/subversionsubmiteditor.cpp b/src/plugins/subversion/subversionsubmiteditor.cpp
index 55f5f472d8..442d73de0e 100644
--- a/src/plugins/subversion/subversionsubmiteditor.cpp
+++ b/src/plugins/subversion/subversionsubmiteditor.cpp
@@ -32,8 +32,8 @@
using namespace Subversion::Internal;
-SubversionSubmitEditor::SubversionSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters) :
- VcsBase::VcsBaseSubmitEditor(parameters, new VcsBase::SubmitEditorWidget)
+SubversionSubmitEditor::SubversionSubmitEditor() :
+ VcsBase::VcsBaseSubmitEditor(new VcsBase::SubmitEditorWidget)
{
document()->setPreferredDisplayName(tr("Subversion Submit"));
setDescriptionMandatory(false);
diff --git a/src/plugins/subversion/subversionsubmiteditor.h b/src/plugins/subversion/subversionsubmiteditor.h
index a08a9eaf0f..3878d828c4 100644
--- a/src/plugins/subversion/subversionsubmiteditor.h
+++ b/src/plugins/subversion/subversionsubmiteditor.h
@@ -36,7 +36,7 @@ class SubversionSubmitEditor : public VcsBase::VcsBaseSubmitEditor
{
Q_OBJECT
public:
- explicit SubversionSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
+ SubversionSubmitEditor();
static QString fileFromStatusLine(const QString &statusLine);
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
index f278b8a0eb..e99637f32b 100644
--- a/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.cpp
@@ -41,22 +41,23 @@ const char SUBMIT[] = "Vcs.Submit";
const char DIFF_SELECTED[] = "Vcs.DiffSelectedFiles";
VcsSubmitEditorFactory::VcsSubmitEditorFactory
- (const VcsBaseSubmitEditorParameters *parameters,
+ (const VcsBaseSubmitEditorParameters &parameters,
const EditorCreator &editorCreator,
VcsBasePluginPrivate *plugin)
: IEditorFactory(plugin)
{
- setId(parameters->id);
- setDisplayName(QLatin1String(parameters->displayName));
- addMimeType(parameters->mimeType);
+ setId(parameters.id);
+ setDisplayName(QLatin1String(parameters.displayName));
+ addMimeType(parameters.mimeType);
- setEditorCreator([this, editorCreator] {
+ setEditorCreator([this, editorCreator, parameters] {
VcsBaseSubmitEditor *editor = editorCreator();
+ editor->setParameters(parameters);
editor->registerActions(m_undoAction, m_redoAction, m_submitAction, m_diffAction);
return editor;
});
- Context context(parameters->id);
+ Context context(parameters.id);
m_undoAction = new QAction(tr("&Undo"), this);
ActionManager::registerAction(m_undoAction, Core::Constants::UNDO, context);
diff --git a/src/plugins/vcsbase/basevcssubmiteditorfactory.h b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
index da648eeb17..133d9fd0ff 100644
--- a/src/plugins/vcsbase/basevcssubmiteditorfactory.h
+++ b/src/plugins/vcsbase/basevcssubmiteditorfactory.h
@@ -47,7 +47,7 @@ class VCSBASE_EXPORT VcsSubmitEditorFactory : public Core::IEditorFactory
public:
typedef std::function<VcsBaseSubmitEditor *()> EditorCreator;
- VcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters *parameters,
+ VcsSubmitEditorFactory(const VcsBaseSubmitEditorParameters &parameters,
const EditorCreator &editorCreator,
VcsBasePluginPrivate *plugin);
diff --git a/src/plugins/vcsbase/submiteditorfile.cpp b/src/plugins/vcsbase/submiteditorfile.cpp
index e7e5d01e15..2ea545c047 100644
--- a/src/plugins/vcsbase/submiteditorfile.cpp
+++ b/src/plugins/vcsbase/submiteditorfile.cpp
@@ -42,13 +42,10 @@ using namespace Utils;
submit editor files.
*/
-SubmitEditorFile::SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters, VcsBaseSubmitEditor *parent) :
- Core::IDocument(parent),
+SubmitEditorFile::SubmitEditorFile(VcsBaseSubmitEditor *editor) :
m_modified(false),
- m_editor(parent)
+ m_editor(editor)
{
- setId(parameters->id);
- setMimeType(QLatin1String(parameters->mimeType));
setTemporary(true);
connect(m_editor, &VcsBaseSubmitEditor::fileContentsChanged,
this, &Core::IDocument::contentsChanged);
diff --git a/src/plugins/vcsbase/submiteditorfile.h b/src/plugins/vcsbase/submiteditorfile.h
index 1030eb46c1..de326c6101 100644
--- a/src/plugins/vcsbase/submiteditorfile.h
+++ b/src/plugins/vcsbase/submiteditorfile.h
@@ -37,8 +37,7 @@ namespace Internal {
class SubmitEditorFile : public Core::IDocument
{
public:
- explicit SubmitEditorFile(const VcsBaseSubmitEditorParameters *parameters,
- VcsBaseSubmitEditor *parent = nullptr);
+ explicit SubmitEditorFile(VcsBaseSubmitEditor *editor);
OpenResult open(QString *errorString, const QString &fileName,
const QString &realFileName) override;
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
index db5513c456..3dec0aeaef 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.cpp
@@ -134,16 +134,15 @@ static inline QString submitMessageCheckScript()
class VcsBaseSubmitEditorPrivate
{
public:
- VcsBaseSubmitEditorPrivate(const VcsBaseSubmitEditorParameters *parameters,
- SubmitEditorWidget *editorWidget,
+ VcsBaseSubmitEditorPrivate(SubmitEditorWidget *editorWidget,
VcsBaseSubmitEditor *q);
SubmitEditorWidget *m_widget;
QToolBar *m_toolWidget = nullptr;
- const VcsBaseSubmitEditorParameters *m_parameters;
+ VcsBaseSubmitEditorParameters m_parameters;
QString m_displayName;
QString m_checkScriptWorkingDirectory;
- SubmitEditorFile *m_file;
+ SubmitEditorFile m_file;
QPointer<QAction> m_diffAction;
QPointer<QAction> m_submitAction;
@@ -151,12 +150,9 @@ public:
NickNameDialog *m_nickNameDialog = nullptr;
};
-VcsBaseSubmitEditorPrivate::VcsBaseSubmitEditorPrivate(const VcsBaseSubmitEditorParameters *parameters,
- SubmitEditorWidget *editorWidget,
+VcsBaseSubmitEditorPrivate::VcsBaseSubmitEditorPrivate(SubmitEditorWidget *editorWidget,
VcsBaseSubmitEditor *q) :
- m_widget(editorWidget),
- m_parameters(parameters),
- m_file(new SubmitEditorFile(parameters, q))
+ m_widget(editorWidget), m_file(q)
{
auto completer = new QCompleter(q);
completer->setCaseSensitivity(Qt::CaseSensitive);
@@ -165,15 +161,22 @@ VcsBaseSubmitEditorPrivate::VcsBaseSubmitEditorPrivate(const VcsBaseSubmitEditor
m_widget->descriptionEdit()->setCompletionLengthThreshold(4);
}
-VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *parameters,
- SubmitEditorWidget *editorWidget) :
- d(new VcsBaseSubmitEditorPrivate(parameters, editorWidget, this))
+VcsBaseSubmitEditor::VcsBaseSubmitEditor(SubmitEditorWidget *editorWidget)
{
+ d = new VcsBaseSubmitEditorPrivate(editorWidget, this);
+}
+
+void VcsBaseSubmitEditor::setParameters(const VcsBaseSubmitEditorParameters &parameters)
+{
+ d->m_parameters = parameters;
+ d->m_file.setId(parameters.id);
+ d->m_file.setMimeType(QLatin1String(parameters.mimeType));
+
setWidget(d->m_widget);
- document()->setPreferredDisplayName(QCoreApplication::translate("VCS", d->m_parameters->displayName));
+ document()->setPreferredDisplayName(QCoreApplication::translate("VCS", d->m_parameters.displayName));
// Message font according to settings
- CompletingTextEdit *descriptionEdit = editorWidget->descriptionEdit();
+ CompletingTextEdit *descriptionEdit = d->m_widget->descriptionEdit();
const TextEditor::FontSettings fs = TextEditor::TextEditorSettings::fontSettings();
const QTextCharFormat tf = fs.toTextCharFormat(TextEditor::C_TEXT);
descriptionEdit->setFont(tf.font());
@@ -187,7 +190,7 @@ VcsBaseSubmitEditor::VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *pa
pal.setBrush(QPalette::HighlightedText, selectionFormat.foreground());
descriptionEdit->setPalette(pal);
- d->m_file->setModified(false);
+ d->m_file.setModified(false);
// We are always clean to prevent the editor manager from asking to save.
connect(d->m_widget, &SubmitEditorWidget::diffSelected,
@@ -338,7 +341,7 @@ void VcsBaseSubmitEditor::setLineWrapWidth(int w)
Core::IDocument *VcsBaseSubmitEditor::document() const
{
- return d->m_file;
+ return &d->m_file;
}
QString VcsBaseSubmitEditor::checkScriptWorkingDirectory() const
@@ -453,7 +456,7 @@ QStringList VcsBaseSubmitEditor::rowsToFiles(const QList<int> &rows) const
void VcsBaseSubmitEditor::slotDiffSelectedVcsFiles(const QList<int> &rawList)
{
- if (d->m_parameters->diffType == VcsBaseSubmitEditorParameters::DiffRows)
+ if (d->m_parameters.diffType == VcsBaseSubmitEditorParameters::DiffRows)
emit diffSelectedRows(rawList);
else
emit diffSelectedFiles(rowsToFiles(rawList));
diff --git a/src/plugins/vcsbase/vcsbasesubmiteditor.h b/src/plugins/vcsbase/vcsbasesubmiteditor.h
index 30fd82e694..8e60e39ff7 100644
--- a/src/plugins/vcsbase/vcsbasesubmiteditor.h
+++ b/src/plugins/vcsbase/vcsbasesubmiteditor.h
@@ -68,8 +68,7 @@ class VCSBASE_EXPORT VcsBaseSubmitEditor : public Core::IEditor
Q_PROPERTY(bool emptyFileListEnabled READ isEmptyFileListEnabled WRITE setEmptyFileListEnabled DESIGNABLE true)
protected:
- explicit VcsBaseSubmitEditor(const VcsBaseSubmitEditorParameters *parameters,
- SubmitEditorWidget *editorWidget);
+ explicit VcsBaseSubmitEditor(SubmitEditorWidget *editorWidget);
public:
// Register the actions with the submit editor widget.
@@ -144,6 +143,9 @@ protected:
bool isDescriptionMandatory() const;
private:
+ friend class VcsSubmitEditorFactory; // for setParameters()
+ void setParameters(const VcsBaseSubmitEditorParameters &parameters);
+
void slotDiffSelectedVcsFiles(const QList<int> &rawList);
void slotCheckSubmitMessage();
void slotInsertNickName();
@@ -155,7 +157,7 @@ private:
bool runSubmitMessageCheckScript(const QString &script, QString *errorMessage) const;
QString promptForNickName();
- VcsBaseSubmitEditorPrivate *d;
+ VcsBaseSubmitEditorPrivate *d = nullptr;
friend class Internal::SubmitEditorFile; // for the file contents
};