diff options
-rw-r--r-- | src/plugins/bazaar/bazaarplugin.cpp | 48 | ||||
-rw-r--r-- | src/plugins/clearcase/clearcaseplugin.cpp | 60 | ||||
-rw-r--r-- | src/plugins/cvs/cvsplugin.cpp | 75 | ||||
-rw-r--r-- | src/plugins/fossil/fossilplugin.cpp | 49 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 100 | ||||
-rw-r--r-- | src/plugins/mercurial/mercurialplugin.cpp | 48 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.cpp | 58 | ||||
-rw-r--r-- | src/plugins/subversion/subversionplugin.cpp | 34 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.cpp | 23 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.h | 7 |
10 files changed, 199 insertions, 303 deletions
diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index a3b9c22d0c6..14046d738f0 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -89,27 +89,6 @@ const char COMMIT[] = "Bazaar.Action.Commit"; const char UNCOMMIT[] = "Bazaar.Action.UnCommit"; const char CREATE_REPOSITORY[] = "Bazaar.Action.CreateRepository"; -const VcsBaseEditorParameters logEditorParameters { - LogOutput, // type - Constants::FILELOG_ID, // id - Constants::FILELOG_DISPLAY_NAME, // display name - Constants::LOGAPP // mime type -}; - -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 -}; - class RevertDialog : public QDialog { public: @@ -220,23 +199,32 @@ public: FilePath m_submitRepository; - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, // type + Constants::FILELOG_ID, // id + Constants::FILELOG_DISPLAY_NAME, // display name + Constants::LOGAPP,// mime type [] { return new BazaarEditorWidget; }, std::bind(&BazaarPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory annotateEditorFactory { - &annotateEditorParameters, + VcsEditorFactory annotateEditorFactory {{ + AnnotateOutput, + Constants::ANNOTATELOG_ID, + Constants::ANNOTATELOG_DISPLAY_NAME, + Constants::ANNOTATEAPP, [] { return new BazaarEditorWidget; }, std::bind(&BazaarPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory diffEditorFactory { - &diffEditorParameters, + VcsEditorFactory diffEditorFactory {{ + DiffOutput, + Constants::DIFFLOG_ID, + Constants::DIFFLOG_DISPLAY_NAME, + Constants::DIFFAPP, [] { return new BazaarEditorWidget; }, std::bind(&BazaarPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; }; class UnCommitDialog : public QDialog diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 56949f65621..f07c2348592 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -99,26 +99,9 @@ const char CMD_ID_UPDATE_VIEW[] = "ClearCase.UpdateView"; const char CMD_ID_CHECKIN_ALL[] = "ClearCase.CheckInAll"; const char CMD_ID_STATUS[] = "ClearCase.Status"; -const VcsBaseEditorParameters logEditorParameters { - LogOutput, - "ClearCase File Log Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "ClearCase File Log Editor"), // display_name - "text/vnd.qtcreator.clearcase.log" -}; - -const VcsBaseEditorParameters annotateEditorParameters { - AnnotateOutput, - "ClearCase Annotation Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "ClearCase Annotation Editor"), // display_name - "text/vnd.qtcreator.clearcase.annotation" -}; - -const VcsBaseEditorParameters diffEditorParameters { - DiffOutput, - "ClearCase Diff Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "ClearCase Diff Editor"), // display_name - "text/x-patch" -}; +const char LOG_EDITOR_ID[] = "ClearCase File Log Editor"; +const char ANNOTATION_EDITOR_ID[] = "ClearCase Annotation Editor"; +const char DIFF_EDITOR_ID[] = "ClearCase Diff Editor"; static QString debugCodec(const QTextCodec *c) { @@ -311,23 +294,32 @@ public: ClearCaseSettingsPage m_settingsPage; - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, + LOG_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "ClearCase File Log Editor"), // display_name + "text/vnd.qtcreator.clearcase.log", [] { return new ClearCaseEditorWidget; }, std::bind(&ClearCasePluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory annotateEditorFactory { - &annotateEditorParameters, + VcsEditorFactory annotateEditorFactory {{ + AnnotateOutput, + ANNOTATION_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "ClearCase Annotation Editor"), // display_name + "text/vnd.qtcreator.clearcase.annotation", [] { return new ClearCaseEditorWidget; }, std::bind(&ClearCasePluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory diffEditorFactory { - &diffEditorParameters, + VcsEditorFactory diffEditorFactory {{ + DiffOutput, + DIFF_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "ClearCase Diff Editor"), // display_name + "text/x-patch", [] { return new ClearCaseEditorWidget; }, std::bind(&ClearCasePluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; #ifdef WITH_TESTS bool m_fakeClearTool = false; @@ -1218,7 +1210,7 @@ void ClearCasePluginPrivate::ccDiffWithPred(const FilePath &workingDir, const QS diffname = QDir::toNativeSeparators(files.first()); } const QString title = QString::fromLatin1("cc diff %1").arg(diffname); - IEditor *editor = showOutputInEditor(title, result, diffEditorParameters.id, source, codec); + IEditor *editor = showOutputInEditor(title, result, DIFF_EDITOR_ID, source, codec); setWorkingDirectory(editor, workingDir); VcsBaseEditor::tagEditor(editor, tag); auto diffEditorWidget = qobject_cast<ClearCaseEditorWidget *>(editor->widget()); @@ -1299,7 +1291,7 @@ void ClearCasePluginPrivate::diffActivity() } m_diffPrefix.clear(); const QString title = QString::fromLatin1("%1.patch").arg(activity); - IEditor *editor = showOutputInEditor(title, result, diffEditorParameters.id, + IEditor *editor = showOutputInEditor(title, result, DIFF_EDITOR_ID, FilePath::fromString(activity), nullptr); setWorkingDirectory(editor, topLevel); } @@ -1461,7 +1453,7 @@ void ClearCasePluginPrivate::history(const FilePath &workingDir, const QString title = QString::fromLatin1("cc history %1").arg(id); const FilePath source = VcsBaseEditor::getSource(workingDir, files); IEditor *newEditor = showOutputInEditor(title, result.cleanedStdOut(), - logEditorParameters.id, source, codec); + LOG_EDITOR_ID, source, codec); VcsBaseEditor::tagEditor(newEditor, tag); if (enableAnnotationContextMenu) VcsBaseEditor::getVcsBaseEditor(newEditor)->setFileLogAnnotateEnabled(true); @@ -1564,7 +1556,7 @@ void ClearCasePluginPrivate::vcsAnnotateHelper(const FilePath &workingDir, const EditorManager::activateEditor(editor); } else { const QString title = QString::fromLatin1("cc annotate %1").arg(id); - IEditor *newEditor = showOutputInEditor(title, res, annotateEditorParameters.id, source, codec); + IEditor *newEditor = showOutputInEditor(title, res, ANNOTATION_EDITOR_ID, source, codec); VcsBaseEditor::tagEditor(newEditor, tag); VcsBaseEditor::gotoLineOfEditor(newEditor, lineNumber); } @@ -1598,7 +1590,7 @@ void ClearCasePluginPrivate::vcsDescribe(const FilePath &source, const QString & EditorManager::activateEditor(editor); } else { const QString title = QString::fromLatin1("cc describe %1").arg(id); - IEditor *newEditor = showOutputInEditor(title, description, diffEditorParameters.id, source, codec); + IEditor *newEditor = showOutputInEditor(title, description, DIFF_EDITOR_ID, source, codec); VcsBaseEditor::tagEditor(newEditor, tag); } } diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 61851d9e4ee..387e74e18fe 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -90,33 +90,10 @@ const char CVS_SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.cvs.submit"; const char CVSCOMMITEDITOR_ID[] = "CVS Commit Editor"; const char CVSCOMMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Commit Editor"); -const VcsBaseEditorParameters commandLogEditorParameters { - OtherContent, - "CVS Command Log Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Command Log Editor"), // display name - "text/vnd.qtcreator.cvs.commandlog" -}; - -const VcsBaseEditorParameters logEditorParameters { - LogOutput, - "CVS File Log Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS File Log Editor"), // display name - "text/vnd.qtcreator.cvs.log" -}; - -const VcsBaseEditorParameters annotateEditorParameters { - AnnotateOutput, - "CVS Annotation Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Annotation Editor"), // display name - "text/vnd.qtcreator.cvs.annotation" -}; - -const VcsBaseEditorParameters diffEditorParameters { - DiffOutput, - "CVS Diff Editor", // id - QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Diff Editor"), // display name - "text/x-patch" -}; +const char CVS_COMMANDLOG_EDITOR_ID[] = "CVS Command Log Editor"; +const char CVS_FILELOG_EDITOR_ID[] = "CVS File Log Editor"; +const char CVS_ANNOTATION_EDITOR_ID[] = "CVS Annotation Editor"; +const char CVS_DIFF_EDITOR_ID[] = "CVS Diff Editor"; static inline bool messageBoxQuestion(const QString &title, const QString &question) { @@ -312,29 +289,41 @@ private: QAction *m_menuAction = nullptr; public: - VcsEditorFactory commandLogEditorFactory { - &commandLogEditorParameters, + VcsEditorFactory commandLogEditorFactory {{ + OtherContent, + CVS_COMMANDLOG_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Command Log Editor"), // display name + "text/vnd.qtcreator.cvs.commandlog", [] { return new CvsEditorWidget; }, std::bind(&CvsPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, + CVS_FILELOG_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS File Log Editor"), // display name + "text/vnd.qtcreator.cvs.log", [] { return new CvsEditorWidget; }, std::bind(&CvsPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory annotateEditorFactory { - &annotateEditorParameters, + VcsEditorFactory annotateEditorFactory {{ + AnnotateOutput, + CVS_ANNOTATION_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Annotation Editor"), // display name + "text/vnd.qtcreator.cvs.annotation", [] { return new CvsEditorWidget; }, std::bind(&CvsPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory diffEditorFactory { - &diffEditorParameters, + VcsEditorFactory diffEditorFactory {{ + DiffOutput, + CVS_DIFF_EDITOR_ID, + QT_TRANSLATE_NOOP("QtC::VcsBase", "CVS Diff Editor"), // display name + "text/x-patch", [] { return new CvsEditorWidget; }, std::bind(&CvsPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; }; Utils::Id CvsPluginPrivate::id() const @@ -965,7 +954,7 @@ void CvsPluginPrivate::filelog(const FilePath &workingDir, } else { const QString title = QString::fromLatin1("cvs log %1").arg(id); IEditor *newEditor = showOutputInEditor(title, response.cleanedStdOut(), - logEditorParameters.id, source, codec); + CVS_FILELOG_EDITOR_ID, source, codec); VcsBaseEditor::tagEditor(newEditor, tag); if (enableAnnotationContextMenu) VcsBaseEditor::getVcsBaseEditor(newEditor)->setFileLogAnnotateEnabled(true); @@ -1105,7 +1094,7 @@ void CvsPluginPrivate::annotate(const FilePath &workingDir, const QString &file, } else { const QString title = QString::fromLatin1("cvs annotate %1").arg(id); IEditor *newEditor = showOutputInEditor(title, response.cleanedStdOut(), - annotateEditorParameters.id, source, codec); + CVS_ANNOTATION_EDITOR_ID, source, codec); VcsBaseEditor::tagEditor(newEditor, tag); VcsBaseEditor::gotoLineOfEditor(newEditor, lineNumber); } @@ -1119,7 +1108,7 @@ bool CvsPluginPrivate::status(const FilePath &topLevel, const QString &file, con const auto response = runCvs(topLevel, args); const bool ok = response.result() == ProcessResult::FinishedWithSuccess; if (ok) { - showOutputInEditor(title, response.cleanedStdOut(), commandLogEditorParameters.id, + showOutputInEditor(title, response.cleanedStdOut(), CVS_COMMANDLOG_EDITOR_ID, topLevel, nullptr); } return ok; @@ -1284,7 +1273,7 @@ bool CvsPluginPrivate::describe(const FilePath &repositoryPath, setDiffBaseDirectory(editor, repositoryPath); } else { const QString title = QString::fromLatin1("cvs describe %1").arg(commitId); - IEditor *newEditor = showOutputInEditor(title, output, diffEditorParameters.id, + IEditor *newEditor = showOutputInEditor(title, output, CVS_DIFF_EDITOR_ID, FilePath::fromString(entries.front().file), codec); VcsBaseEditor::tagEditor(newEditor, commitId); setDiffBaseDirectory(newEditor, repositoryPath); diff --git a/src/plugins/fossil/fossilplugin.cpp b/src/plugins/fossil/fossilplugin.cpp index 46924462580..40138f281ba 100644 --- a/src/plugins/fossil/fossilplugin.cpp +++ b/src/plugins/fossil/fossilplugin.cpp @@ -77,28 +77,6 @@ protected: } }; -const VcsBaseEditorParameters fileLogParameters { - LogOutput, - Constants::FILELOG_ID, - Constants::FILELOG_DISPLAY_NAME, - Constants::LOGAPP -}; - -const VcsBaseEditorParameters annotateLogParameters { - AnnotateOutput, - Constants::ANNOTATELOG_ID, - Constants::ANNOTATELOG_DISPLAY_NAME, - Constants::ANNOTATEAPP -}; - -const VcsBaseEditorParameters diffParameters { - DiffOutput, - Constants::DIFFLOG_ID, - Constants::DIFFLOG_DISPLAY_NAME, - Constants::DIFFAPP -}; - - class FossilPluginPrivate final : public VersionControlBase { public: @@ -171,23 +149,32 @@ public: bool pullOrPush(SyncMode mode); // Variables - VcsEditorFactory fileLogFactory { - &fileLogParameters, + VcsEditorFactory fileLogFactory {{ + LogOutput, + Constants::FILELOG_ID, + Constants::FILELOG_DISPLAY_NAME, + Constants::LOGAPP, [] { return new FossilEditorWidget; }, std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory annotateLogFactory { - &annotateLogParameters, + VcsEditorFactory annotateLogFactory {{ + AnnotateOutput, + Constants::ANNOTATELOG_ID, + Constants::ANNOTATELOG_DISPLAY_NAME, + Constants::ANNOTATEAPP, [] { return new FossilEditorWidget; }, std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory diffFactory { - &diffParameters, + VcsEditorFactory diffFactory {{ + DiffOutput, + Constants::DIFFLOG_ID, + Constants::DIFFLOG_DISPLAY_NAME, + Constants::DIFFAPP, [] { return new FossilEditorWidget; }, std::bind(&FossilPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; CommandLocator *m_commandLocator = nullptr; ActionContainer *m_fossilContainer = nullptr; diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index d72b397f6e0..c3ac447c570 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -132,48 +132,6 @@ public: static const QVersionNumber minimumRequiredVersion{1, 9}; -const VcsBaseEditorParameters svnLogEditorParameters { - OtherContent, - Git::Constants::GIT_SVN_LOG_EDITOR_ID, - Git::Constants::GIT_SVN_LOG_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.git.svnlog" -}; - -const VcsBaseEditorParameters logEditorParameters { - LogOutput, - Git::Constants::GIT_LOG_EDITOR_ID, - Git::Constants::GIT_LOG_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.git.log" -}; - -const VcsBaseEditorParameters reflogEditorParameters { - LogOutput, - Git::Constants::GIT_REFLOG_EDITOR_ID, - Git::Constants::GIT_REFLOG_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.git.reflog" -}; - -const VcsBaseEditorParameters blameEditorParameters { - AnnotateOutput, - Git::Constants::GIT_BLAME_EDITOR_ID, - Git::Constants::GIT_BLAME_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.git.annotation" -}; - -const VcsBaseEditorParameters commitTextEditorParameters { - OtherContent, - Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID, - Git::Constants::GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.git.commit" -}; - -const VcsBaseEditorParameters rebaseEditorParameters { - OtherContent, - Git::Constants::GIT_REBASE_EDITOR_ID, - Git::Constants::GIT_REBASE_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.git.rebase" -}; - // GitPlugin class GitPluginPrivate final : public VersionControlBase @@ -366,41 +324,59 @@ public: GitGrep gitGrep; - VcsEditorFactory svnLogEditorFactory { - &svnLogEditorParameters, + VcsEditorFactory svnLogEditorFactory {{ + OtherContent, + Git::Constants::GIT_SVN_LOG_EDITOR_ID, + Git::Constants::GIT_SVN_LOG_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.git.svnlog", [] { return new GitEditorWidget; }, std::bind(&GitPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, + Git::Constants::GIT_LOG_EDITOR_ID, + Git::Constants::GIT_LOG_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.git.log", [] { return new GitLogEditorWidgetT<GitEditorWidget>; }, std::bind(&GitPluginPrivate::vcsDescribe, this, _1, _2) - }; - - VcsEditorFactory reflogEditorFactory { - &reflogEditorParameters, - [] { return new GitLogEditorWidgetT<GitReflogEditorWidget>; }, + }}; + + VcsEditorFactory reflogEditorFactory {{ + LogOutput, + Git::Constants::GIT_REFLOG_EDITOR_ID, + Git::Constants::GIT_REFLOG_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.git.reflog", + [] { return new GitLogEditorWidgetT<GitReflogEditorWidget>; }, std::bind(&GitPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory blameEditorFactory { - &blameEditorParameters, + VcsEditorFactory blameEditorFactory {{ + AnnotateOutput, + Git::Constants::GIT_BLAME_EDITOR_ID, + Git::Constants::GIT_BLAME_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.git.annotation", [] { return new GitEditorWidget; }, std::bind(&GitPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory commitTextEditorFactory { - &commitTextEditorParameters, + VcsEditorFactory commitTextEditorFactory {{ + OtherContent, + Git::Constants::GIT_COMMIT_TEXT_EDITOR_ID, + Git::Constants::GIT_COMMIT_TEXT_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.git.commit", [] { return new GitEditorWidget; }, std::bind(&GitPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory rebaseEditorFactory { - &rebaseEditorParameters, + VcsEditorFactory rebaseEditorFactory {{ + OtherContent, + Git::Constants::GIT_REBASE_EDITOR_ID, + Git::Constants::GIT_REBASE_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.git.rebase", [] { return new GitEditorWidget; }, std::bind(&GitPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; }; static GitPluginPrivate *dd = nullptr; diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 081a7a5e41c..bd691d47e4c 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -67,27 +67,6 @@ protected: } }; -const VcsBaseEditorParameters logEditorParameters { - LogOutput, - Constants::FILELOG_ID, - Constants::FILELOG_DISPLAY_NAME, - Constants::LOGAPP -}; - -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 -}; - class MercurialPluginPrivate final : public VcsBase::VersionControlBase { public: @@ -180,23 +159,32 @@ private: FilePath m_submitRepository; public: - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, + Constants::FILELOG_ID, + Constants::FILELOG_DISPLAY_NAME, + Constants::LOGAPP, [this] { return new MercurialEditorWidget; }, std::bind(&MercurialPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory annotateEditorFactory { - &annotateEditorParameters, + VcsEditorFactory annotateEditorFactory {{ + AnnotateOutput, + Constants::ANNOTATELOG_ID, + Constants::ANNOTATELOG_DISPLAY_NAME, + Constants::ANNOTATEAPP, [this] { return new MercurialEditorWidget; }, std::bind(&MercurialPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory diffEditorFactory { - &diffEditorParameters, + VcsEditorFactory diffEditorFactory {{ + DiffOutput, + Constants::DIFFLOG_ID, + Constants::DIFFLOG_DISPLAY_NAME, + Constants::DIFFAPP, [this] { return new MercurialEditorWidget; }, std::bind(&MercurialPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; }; static MercurialPluginPrivate *dd = nullptr; diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 23d6071d7d5..7bca24a7be7 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -128,27 +128,6 @@ struct PerforceResponse QString stdErr; }; -const VcsBaseEditorParameters logEditorParameters { - LogOutput, - PERFORCE_LOG_EDITOR_ID, - PERFORCE_LOG_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.p4.log" -}; - -const VcsBaseEditorParameters annotateEditorParameters { - AnnotateOutput, - PERFORCE_ANNOTATION_EDITOR_ID, - PERFORCE_ANNOTATION_EDITOR_DISPLAY_NAME, - "text/vnd.qtcreator.p4.annotation" -}; - -const VcsBaseEditorParameters diffEditorParameters { - DiffOutput, - PERFORCE_DIFF_EDITOR_ID, - PERFORCE_DIFF_EDITOR_DISPLAY_NAME, - "text/x-patch" -}; - // Flags for runP4Cmd. enum RunFlags { @@ -324,23 +303,32 @@ public: ManagedDirectoryCache m_managedDirectoryCache; - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, + PERFORCE_LOG_EDITOR_ID, + PERFORCE_LOG_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.p4.log", [] { return new PerforceEditorWidget; }, std::bind(&PerforcePluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory annotateEditorFactory { - &annotateEditorParameters, + VcsEditorFactory annotateEditorFactory {{ + AnnotateOutput, + PERFORCE_ANNOTATION_EDITOR_ID, + PERFORCE_ANNOTATION_EDITOR_DISPLAY_NAME, + "text/vnd.qtcreator.p4.annotation", [] { return new PerforceEditorWidget; }, std::bind(&PerforcePluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory diffEditorFactory { - &diffEditorParameters, + VcsEditorFactory diffEditorFactory {{ + DiffOutput, + PERFORCE_DIFF_EDITOR_ID, + PERFORCE_DIFF_EDITOR_DISPLAY_NAME, + "text/x-patch", [] { return new PerforceEditorWidget; }, std::bind(&PerforcePluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; }; static PerforcePluginPrivate *dd = nullptr; @@ -827,7 +815,7 @@ void PerforcePluginPrivate::annotate(const FilePath &workingDir, if (lineNumber < 1) lineNumber = VcsBaseEditor::lineNumberOfCurrentEditor(); IEditor *ed = showOutputInEditor(Tr::tr("p4 annotate %1").arg(id), - result.stdOut, annotateEditorParameters.id, + result.stdOut, PERFORCE_ANNOTATION_EDITOR_ID, source, codec); VcsBaseEditor::gotoLineOfEditor(ed, lineNumber); } @@ -878,7 +866,7 @@ void PerforcePluginPrivate::filelog(const FilePath &workingDir, const QString &f if (!result.error) { const FilePath source = VcsBaseEditor::getSource(workingDir, fileName); IEditor *editor = showOutputInEditor(Tr::tr("p4 filelog %1").arg(id), result.stdOut, - logEditorParameters.id, source, codec); + PERFORCE_LOG_EDITOR_ID, source, codec); if (enableAnnotationContextMenu) VcsBaseEditor::getVcsBaseEditor(editor)->setFileLogAnnotateEnabled(true); } @@ -900,7 +888,7 @@ void PerforcePluginPrivate::changelists(const FilePath &workingDir, const QStrin if (!result.error) { const FilePath source = VcsBaseEditor::getSource(workingDir, fileName); IEditor *editor = showOutputInEditor(Tr::tr("p4 changelists %1").arg(id), result.stdOut, - logEditorParameters.id, source, codec); + PERFORCE_LOG_EDITOR_ID, source, codec); VcsBaseEditor::gotoLineOfEditor(editor, 1); } } @@ -1376,7 +1364,7 @@ void PerforcePluginPrivate::p4Diff(const PerforceDiffParameters &p) } // Create new editor IEditor *editor = showOutputInEditor(Tr::tr("p4 diff %1").arg(id), result.stdOut, - diffEditorParameters.id, + PERFORCE_DIFF_EDITOR_ID, VcsBaseEditor::getSource(p.workingDir, p.files), codec); VcsBaseEditor::tagEditor(editor, tag); @@ -1400,7 +1388,7 @@ void PerforcePluginPrivate::vcsDescribe(const FilePath &source, const QString &n const PerforceResponse result = runP4Cmd(settings().topLevel(), args, CommandToWindow|StdErrToWindow|ErrorToWindow, {}, {}, codec); if (!result.error) - showOutputInEditor(Tr::tr("p4 describe %1").arg(n), result.stdOut, diffEditorParameters.id, source, codec); + showOutputInEditor(Tr::tr("p4 describe %1").arg(n), result.stdOut, PERFORCE_DIFF_EDITOR_ID, source, codec); } void PerforcePluginPrivate::cleanCommitMessageFile() diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index c70df10640d..a5f146bf3d6 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -85,20 +85,6 @@ const char CMD_ID_UPDATE[] = "Subversion.Update"; const char CMD_ID_COMMIT_PROJECT[] = "Subversion.CommitProject"; const char CMD_ID_DESCRIBE[] = "Subversion.Describe"; -const VcsBaseEditorParameters logEditorParameters { - LogOutput, - Constants::SUBVERSION_LOG_EDITOR_ID, - Constants::SUBVERSION_LOG_EDITOR_DISPLAY_NAME, - Constants::SUBVERSION_LOG_MIMETYPE -}; - -const VcsBaseEditorParameters blameEditorParameters { - AnnotateOutput, - Constants::SUBVERSION_BLAME_EDITOR_ID, - Constants::SUBVERSION_BLAME_EDITOR_DISPLAY_NAME, - Constants::SUBVERSION_BLAME_MIMETYPE -}; - static inline QString debugCodec(const QTextCodec *c) { return c ? QString::fromLatin1(c->name()) : QString::fromLatin1("Null codec"); @@ -276,17 +262,23 @@ private: QAction *m_menuAction = nullptr; public: - VcsEditorFactory logEditorFactory { - &logEditorParameters, + VcsEditorFactory logEditorFactory {{ + LogOutput, + Constants::SUBVERSION_LOG_EDITOR_ID, + Constants::SUBVERSION_LOG_EDITOR_DISPLAY_NAME, + Constants::SUBVERSION_LOG_MIMETYPE, [] { return new SubversionEditorWidget; }, std::bind(&SubversionPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; - VcsEditorFactory blameEditorFactory { - &blameEditorParameters, + VcsEditorFactory blameEditorFactory {{ + AnnotateOutput, + Constants::SUBVERSION_BLAME_EDITOR_ID, + Constants::SUBVERSION_BLAME_EDITOR_DISPLAY_NAME, + Constants::SUBVERSION_BLAME_MIMETYPE, [] { return new SubversionEditorWidget; }, std::bind(&SubversionPluginPrivate::vcsDescribe, this, _1, _2) - }; + }}; }; @@ -853,7 +845,7 @@ void SubversionPluginPrivate::vcsAnnotateHelper(const FilePath &workingDir, cons } else { const QString title = QString::fromLatin1("svn annotate %1").arg(id); IEditor *newEditor = showOutputInEditor(title, response.cleanedStdOut(), - blameEditorParameters.id, source, codec); + Constants::SUBVERSION_BLAME_EDITOR_ID, source, codec); VcsBaseEditor::tagEditor(newEditor, tag); VcsBaseEditor::gotoLineOfEditor(newEditor, lineNumber); } diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 729ee682c4d..9dcee6e31c7 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1653,30 +1653,27 @@ IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag) \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) +VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters ¶meters) { - setId(parameters->id); - setDisplayName(Tr::tr(parameters->displayName)); - if (QLatin1String(parameters->mimeType) != QLatin1String(DiffEditor::Constants::DIFF_EDITOR_MIMETYPE)) - addMimeType(QLatin1String(parameters->mimeType)); + 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)); + auto document = new TextDocument(parameters.id); + document->setMimeType(QLatin1String(parameters.mimeType)); document->setSuspendAllowed(false); return document; }); - setEditorWidgetCreator([parameters=*parameters, editorWidgetCreator, describeFunc] { - auto widget = editorWidgetCreator(); + setEditorWidgetCreator([parameters] { + auto widget = parameters.editorWidgetCreator(); auto editorWidget = Aggregation::query<VcsBaseEditorWidget>(widget); - editorWidget->setDescribeFunc(describeFunc); + editorWidget->setDescribeFunc(parameters.describeFunc); editorWidget->setParameters(parameters); return widget; }); diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h index b2a9a80cb32..703e49324d4 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.h +++ b/src/plugins/vcsbase/vcsbaseeditor.h @@ -45,6 +45,8 @@ public: const char *id; const char *displayName; const char *mimeType; + std::function<QWidget *()> editorWidgetCreator; + std::function<void (const Utils::FilePath &, const QString &)> describeFunc; }; class VCSBASE_EXPORT DiffChunk @@ -289,10 +291,7 @@ public: class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory { public: - VcsEditorFactory(const VcsBaseEditorParameters *parameters, - const EditorWidgetCreator editorWidgetCreator, - std::function<void(const Utils::FilePath &, const QString &)> describeFunc); - + explicit VcsEditorFactory(const VcsBaseEditorParameters ¶meters); ~VcsEditorFactory(); }; |