forked from qt-creator/qt-creator
VCS: Replace describe slots with lambdas
Change-Id: I05ca25aad8be43fdfa15d3fb5eaaa9bf753ee79f Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
565aed03a2
commit
5832f52cee
@@ -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());
|
||||
|
||||
|
||||
@@ -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); }));
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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); }));
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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); }));
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user