diff options
author | Orgad Shaneh <orgad.shaneh@audiocodes.com> | 2016-11-26 21:52:49 +0200 |
---|---|---|
committer | Orgad Shaneh <orgads@gmail.com> | 2016-11-28 09:38:12 +0000 |
commit | 5832f52ceefb9ee19842af4513ae00ee7d311e31 (patch) | |
tree | 0ed1a117b154151354b2d4b7036dde81ffe7b0ac /src/plugins | |
parent | 565aed03a24e315847421272d582b7fd3b7ff04d (diff) | |
download | qt-creator-5832f52ceefb9ee19842af4513ae00ee7d311e31.tar.gz |
VCS: Replace describe slots with lambdas
Change-Id: I05ca25aad8be43fdfa15d3fb5eaaa9bf753ee79f
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/bazaar/bazaarclient.h | 2 | ||||
-rw-r--r-- | src/plugins/bazaar/bazaarplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/clearcase/clearcaseplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/clearcase/clearcaseplugin.h | 4 | ||||
-rw-r--r-- | src/plugins/cvs/cvsplugin.cpp | 15 | ||||
-rw-r--r-- | src/plugins/cvs/cvsplugin.h | 3 | ||||
-rw-r--r-- | src/plugins/git/gitclient.h | 2 | ||||
-rw-r--r-- | src/plugins/git/gitplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/mercurial/mercurialclient.h | 1 | ||||
-rw-r--r-- | src/plugins/mercurial/mercurialplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/perforce/perforceplugin.h | 3 | ||||
-rw-r--r-- | src/plugins/subversion/subversionplugin.cpp | 6 | ||||
-rw-r--r-- | src/plugins/subversion/subversionplugin.h | 6 | ||||
-rw-r--r-- | src/plugins/vcsbase/basevcseditorfactory.cpp | 6 | ||||
-rw-r--r-- | src/plugins/vcsbase/basevcseditorfactory.h | 5 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseclient.h | 7 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.cpp | 14 | ||||
-rw-r--r-- | src/plugins/vcsbase/vcsbaseeditor.h | 5 |
19 files changed, 52 insertions, 57 deletions
diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h index 96f6a97a80..aa18bcc8a3 100644 --- a/src/plugins/bazaar/bazaarclient.h +++ b/src/plugins/bazaar/bazaarclient.h @@ -55,8 +55,6 @@ public: bool isVcsDirectory(const Utils::FileName &fileName) const; QString findTopLevelForFile(const QFileInfo &file) const; bool managesFile(const QString &workingDirectory, const QString &fileName) const; - -public slots: void view(const QString &source, const QString &id, const QStringList &extraOptions = QStringList()); diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp index f8516d9778..49b0d9f4af 100644 --- a/src/plugins/bazaar/bazaarplugin.cpp +++ b/src/plugins/bazaar/bazaarplugin.cpp @@ -160,11 +160,13 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag addAutoReleasedObject(new OptionsPage(vcsCtrl)); - static const char *describeSlot = SLOT(view(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &id) { + m_client->view(source, id); + }; const int editorCount = sizeof(editorParameters) / sizeof(VcsBaseEditorParameters); const auto widgetCreator = []() { return new BazaarEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_client, describeSlot)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters, []() { return new CommitEditor(&submitEditorParameters); })); diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index ee1f1779bb..892d8c79c6 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -432,11 +432,13 @@ bool ClearCasePlugin::initialize(const QStringList & /*arguments */, QString *er []() { return new ClearCaseSubmitEditor(&submitParameters); })); // any editor responds to describe (when clicking a version) - static const char *describeSlot = SLOT(describe(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &changeNr) { + describe(source, changeNr); + }; const int editorCount = sizeof(editorParameters)/sizeof(VcsBaseEditorParameters); const auto widgetCreator = []() { return new ClearCaseEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); const QString description = QLatin1String("ClearCase"); const QString prefix = QLatin1String("cc"); diff --git a/src/plugins/clearcase/clearcaseplugin.h b/src/plugins/clearcase/clearcaseplugin.h index a3c93c4c2c..dcd8bca1ec 100644 --- a/src/plugins/clearcase/clearcaseplugin.h +++ b/src/plugins/clearcase/clearcaseplugin.h @@ -168,6 +168,7 @@ public: const QString &revision = QString(), int lineNumber = -1) const; bool newActivity(); void updateStreamAndView(); + void describe(const QString &source, const QString &changeNr); protected: void updateActions(VcsBase::VcsBasePlugin::ActionState) override; @@ -194,9 +195,6 @@ private slots: void testVcsStatusDynamicNotManaged(); #endif -public slots: - void describe(const QString &source, const QString &changeNr); - private: void annotateVersion(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber); void syncSlot(); diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 06c25a4270..c697b0427e 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -212,11 +212,15 @@ bool CvsPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new CvsSubmitEditor(&submitParameters); })); - static const char *describeSlotC = SLOT(slotDescribe(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &changeNr) { + QString errorMessage; + if (!describe(source, changeNr, &errorMessage)) + VcsOutputWindow::appendError(errorMessage); + }; const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]); const auto widgetCreator = []() { return new CvsEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlotC)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); const QString prefix = QLatin1String("cvs"); m_commandLocator = new CommandLocator("CVS", prefix, prefix); @@ -964,13 +968,6 @@ void CvsPlugin::updateRepository() } -void CvsPlugin::slotDescribe(const QString &source, const QString &changeNr) -{ - QString errorMessage; - if (!describe(source, changeNr, &errorMessage)) - VcsOutputWindow::appendError(errorMessage); -} - bool CvsPlugin::describe(const QString &file, const QString &changeNr, QString *errorMessage) { diff --git a/src/plugins/cvs/cvsplugin.h b/src/plugins/cvs/cvsplugin.h index 86567c4511..c3e2b1a456 100644 --- a/src/plugins/cvs/cvsplugin.h +++ b/src/plugins/cvs/cvsplugin.h @@ -90,9 +90,6 @@ public slots: void vcsAnnotate(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber); -private slots: - void slotDescribe(const QString &source, const QString &changeNr); - #ifdef WITH_TESTS void testDiffFileResolving_data(); void testDiffFileResolving(); diff --git a/src/plugins/git/gitclient.h b/src/plugins/git/gitclient.h index 5261d5afb8..5f768ea87a 100644 --- a/src/plugins/git/gitclient.h +++ b/src/plugins/git/gitclient.h @@ -321,8 +321,6 @@ public: static QString msgNoChangedFiles(); static QString msgNoCommits(bool includeRemote); - -public slots: void show(const QString &source, const QString &id, const QString &name = QString()); private: diff --git a/src/plugins/git/gitplugin.cpp b/src/plugins/git/gitplugin.cpp index 9049828235..71476bb940 100644 --- a/src/plugins/git/gitplugin.cpp +++ b/src/plugins/git/gitplugin.cpp @@ -285,11 +285,13 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage) addAutoReleasedObject(new SettingsPage(versionControl())); addAutoReleasedObject(new GitGrep); - static const char *describeSlot = SLOT(show(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &id) { + m_gitClient->show(source, id); + }; const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]); const auto widgetCreator = []() { return new GitEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_gitClient, describeSlot)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new GitSubmitEditor(&submitParameters); })); diff --git a/src/plugins/mercurial/mercurialclient.h b/src/plugins/mercurial/mercurialclient.h index 2692b4bfd6..e3763439a3 100644 --- a/src/plugins/mercurial/mercurialclient.h +++ b/src/plugins/mercurial/mercurialclient.h @@ -73,7 +73,6 @@ public: bool isVcsDirectory(const Utils::FileName &fileName) const; QString findTopLevelForFile(const QFileInfo &file) const override; -public slots: void view(const QString &source, const QString &id, const QStringList &extraOptions = QStringList()) override; diff --git a/src/plugins/mercurial/mercurialplugin.cpp b/src/plugins/mercurial/mercurialplugin.cpp index 29b2095af1..4acc63fa4c 100644 --- a/src/plugins/mercurial/mercurialplugin.cpp +++ b/src/plugins/mercurial/mercurialplugin.cpp @@ -129,11 +129,13 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * connect(m_client, SIGNAL(changed(QVariant)), versionControl(), SLOT(changed(QVariant))); connect(m_client, &MercurialClient::needUpdate, this, &MercurialPlugin::update); - static const char *describeSlot = SLOT(view(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &id) { + m_client->view(source, id); + }; const int editorCount = sizeof(editorParameters)/sizeof(editorParameters[0]); const auto widgetCreator = []() { return new MercurialEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, m_client, describeSlot)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); addAutoReleasedObject(new VcsSubmitEditorFactory(&submitEditorParameters, []() { return new CommitEditor(&submitEditorParameters); })); diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 53f6284280..2861ad9526 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -197,11 +197,13 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new PerforceSubmitEditor(&submitParameters); })); - static const char *describeSlot = SLOT(describe(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &n) { + describe(source, n); + }; const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]); const auto widgetCreator = []() { return new PerforceEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); const QString prefix = QLatin1String("p4"); m_commandLocator = new CommandLocator("Perforce", prefix, prefix); diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h index 616a1f5204..7c840b9a16 100644 --- a/src/plugins/perforce/perforceplugin.h +++ b/src/plugins/perforce/perforceplugin.h @@ -99,8 +99,9 @@ public: bool quiet, QString *errorMessage); -public slots: void describe(const QString &source, const QString &n); + +public slots: void vcsAnnotate(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber); diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 2abc041d12..bdc7654d9e 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -224,11 +224,13 @@ bool SubversionPlugin::initialize(const QStringList & /*arguments */, QString *e addAutoReleasedObject(new VcsSubmitEditorFactory(&submitParameters, []() { return new SubversionSubmitEditor(&submitParameters); })); - static const char *describeSlot = SLOT(describe(QString,QString)); + const auto describeFunc = [this](const QString &source, const QString &id) { + describe(source, id); + }; const int editorCount = sizeof(editorParameters) / sizeof(editorParameters[0]); const auto widgetCreator = []() { return new SubversionEditorWidget; }; for (int i = 0; i < editorCount; i++) - addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, this, describeSlot)); + addAutoReleasedObject(new VcsEditorFactory(editorParameters + i, widgetCreator, describeFunc)); const QString prefix = QLatin1String("svn"); m_commandLocator = new CommandLocator("Subversion", prefix, prefix); diff --git a/src/plugins/subversion/subversionplugin.h b/src/plugins/subversion/subversionplugin.h index 3c614eeb7c..f9312cbcd4 100644 --- a/src/plugins/subversion/subversionplugin.h +++ b/src/plugins/subversion/subversionplugin.h @@ -94,13 +94,13 @@ public: SubversionResponse runSvn(const QString &workingDir, const QStringList &arguments, int timeOutS, unsigned flags, QTextCodec *outputCodec = 0) const; + void describe(const QString &source, const QString &changeNr); + void vcsAnnotate(const QString &workingDir, const QString &file, + const QString &revision = QString(), int lineNumber = -1); public slots: void annotateVersion(const QString &workingDirectory, const QString &file, const QString &revision, int lineNumber); - void describe(const QString &source, const QString &changeNr); - void vcsAnnotate(const QString &workingDir, const QString &file, - const QString &revision = QString(), int lineNumber = -1); #ifdef WITH_TESTS private slots: diff --git a/src/plugins/vcsbase/basevcseditorfactory.cpp b/src/plugins/vcsbase/basevcseditorfactory.cpp index a8aa8a1bfb..8b183e5c01 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.cpp +++ b/src/plugins/vcsbase/basevcseditorfactory.cpp @@ -52,7 +52,7 @@ namespace VcsBase { VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters, // Force copy, see QTCREATORBUG-13218 const EditorWidgetCreator editorWidgetCreator, - QObject *describeReceiver, const char *describeSlot) + std::function<void(const QString &, const QString &)> describeFunc) { setProperty("VcsEditorFactoryName", QByteArray(parameters->id)); setId(parameters->id); @@ -71,9 +71,9 @@ VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters, return document; }); - setEditorWidgetCreator([this, parameters, editorWidgetCreator, describeReceiver, describeSlot]() -> TextEditorWidget* { + setEditorWidgetCreator([this, parameters, editorWidgetCreator, describeFunc]() -> TextEditorWidget * { auto widget = qobject_cast<VcsBaseEditorWidget *>(editorWidgetCreator()); - widget->setDescribeSlot(describeReceiver, describeSlot); + widget->setDescribeFunc(describeFunc); widget->setParameters(parameters); return widget; }); diff --git a/src/plugins/vcsbase/basevcseditorfactory.h b/src/plugins/vcsbase/basevcseditorfactory.h index 555f4bafc0..8c2b8cbdf6 100644 --- a/src/plugins/vcsbase/basevcseditorfactory.h +++ b/src/plugins/vcsbase/basevcseditorfactory.h @@ -29,6 +29,8 @@ #include <texteditor/texteditor.h> +#include <functional> + namespace VcsBase { class VcsBaseEditor; class VcsBaseEditorParameters; @@ -40,8 +42,7 @@ class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory public: VcsEditorFactory(const VcsBaseEditorParameters *parameters, const EditorWidgetCreator editorWidgetCreator, - QObject *describeReceiver, - const char *describeSlot); + std::function<void(const QString &, const QString &)> describeFunc); static VcsBaseEditor *createEditorById(const char *id); }; diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index d693a4357e..4e830bdc66 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -194,15 +194,14 @@ public: virtual QString findTopLevelForFile(const QFileInfo &file) const = 0; + virtual void view(const QString &source, const QString &id, + const QStringList &extraOptions = QStringList()); + signals: void parsedStatus(const QList<VcsBase::VcsBaseClient::StatusItem> &statusList); // Passes on changed signals from VcsJob to Control void changed(const QVariant &v); -public slots: - virtual void view(const QString &source, const QString &id, - const QStringList &extraOptions = QStringList()); - protected: enum VcsCommandTag { diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index b179923112..30cd8eb6a6 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -159,8 +159,6 @@ void VcsBaseEditor::finalizeInitialization() auto widget = qobject_cast<VcsBaseEditorWidget *>(editorWidget()); QTC_ASSERT(widget, return); // Pass on signals. - connect(widget, &VcsBaseEditorWidget::describeRequested, - this, &VcsBaseEditor::describeRequested); connect(widget, &VcsBaseEditorWidget::annotateRevisionRequested, this, &VcsBaseEditor::annotateRevisionRequested); } @@ -568,8 +566,7 @@ public: bool m_configurationAdded = false; QList<AbstractTextCursorHandler *> m_textCursorHandlers; QPointer<VcsCommand> m_command; - QObject *m_describeReceiver = nullptr; - const char *m_describeSlot = nullptr; + VcsBaseEditorWidget::DescribeFunc m_describeFunc = nullptr; Utils::ProgressIndicator *m_progressIndicator = nullptr; bool m_fileLogAnnotateEnabled = false; bool m_mouseDragging = false; @@ -713,17 +710,14 @@ int VcsBaseEditorWidget::lineNumberDigits() const return digits; } -void VcsBaseEditorWidget::setDescribeSlot(QObject *describeReceiver, const char *describeSlot) +void VcsBaseEditorWidget::setDescribeFunc(DescribeFunc describeFunc) { - d->m_describeReceiver = describeReceiver; - d->m_describeSlot = describeSlot; + d->m_describeFunc = describeFunc; } void VcsBaseEditorWidget::finalizeInitialization() { - if (d->m_describeReceiver) - connect(this, SIGNAL(describeRequested(QString,QString)), d->m_describeReceiver, d->m_describeSlot); - + connect(this, &VcsBaseEditorWidget::describeRequested, this, d->m_describeFunc); init(); } diff --git a/src/plugins/vcsbase/vcsbaseeditor.h b/src/plugins/vcsbase/vcsbaseeditor.h index 4b765e1f53..b1dc7f1ba9 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.h +++ b/src/plugins/vcsbase/vcsbaseeditor.h @@ -128,7 +128,6 @@ public: const QString &revision = QString()); void finalizeInitialization() override; signals: - void describeRequested(const QString &source, const QString &change); void annotateRevisionRequested(const QString &workingDirectory, const QString &file, const QString &change, int line); }; @@ -158,9 +157,11 @@ protected: int lineNumberDigits() const override; public: + typedef std::function<void(const QString &, const QString &)> DescribeFunc; + void finalizeInitialization() override; // FIXME: Consolidate these into finalizeInitialization - void setDescribeSlot(QObject *describeReceiver, const char *describeSlot); + void setDescribeFunc(DescribeFunc describeFunc); // void virtual void init(); // |