Gerrit: Minor cleanup

* Remove unused member
* Inline function that is used only once
* Replace slots with lambdas

Change-Id: I6887b115463c9aac24d4c3dfe6a70357c9068973
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2017-01-14 22:51:47 +02:00
committed by Orgad Shaneh
parent 22ac7534a5
commit 5035807f89
5 changed files with 8 additions and 34 deletions

View File

@@ -239,7 +239,6 @@ private:
void errorTermination(const QString &msg); void errorTermination(const QString &msg);
void terminate(); void terminate();
const QSharedPointer<GerritParameters> m_parameters;
const QStringList m_queries; const QStringList m_queries;
QProcess m_process; QProcess m_process;
QTimer m_timer; QTimer m_timer;
@@ -257,10 +256,9 @@ QueryContext::QueryContext(const QStringList &queries,
const QSharedPointer<GerritParameters> &p, const QSharedPointer<GerritParameters> &p,
QObject *parent) QObject *parent)
: QObject(parent) : QObject(parent)
, m_parameters(p)
, m_queries(queries) , m_queries(queries)
, m_currentQuery(0) , m_currentQuery(0)
, m_baseArguments(p->baseCommandArguments()) , m_baseArguments({ p->ssh, p->portFlag, QString::number(p->port), p->sshHostArgument(), "gerrit" })
{ {
connect(&m_process, &QProcess::readyReadStandardError, connect(&m_process, &QProcess::readyReadStandardError,
this, &QueryContext::readyReadStandardError); this, &QueryContext::readyReadStandardError);

View File

@@ -86,11 +86,6 @@ GerritParameters::GerritParameters()
{ {
} }
QStringList GerritParameters::baseCommandArguments() const
{
return { ssh, portFlag, QString::number(port), sshHostArgument(), "gerrit" };
}
QString GerritParameters::sshHostArgument() const QString GerritParameters::sshHostArgument() const
{ {
return user.isEmpty() ? host : (user + '@' + host); return user.isEmpty() ? host : (user + '@' + host);

View File

@@ -37,7 +37,6 @@ class GerritParameters
public: public:
GerritParameters(); GerritParameters();
QStringList baseCommandArguments() const;
QString sshHostArgument() const; QString sshHostArgument() const;
bool isValid() const; bool isValid() const;
bool equals(const GerritParameters &rhs) const; bool equals(const GerritParameters &rhs) const;

View File

@@ -96,8 +96,6 @@ public:
const QSharedPointer<GerritParameters> &p, const QSharedPointer<GerritParameters> &p,
FetchMode fm, QObject *parent = 0); FetchMode fm, QObject *parent = 0);
~FetchContext(); ~FetchContext();
public slots:
void start(); void start();
private: private:
@@ -359,9 +357,12 @@ void GerritPlugin::openView()
} }
GerritDialog *gd = new GerritDialog(m_parameters, ICore::mainWindow()); GerritDialog *gd = new GerritDialog(m_parameters, ICore::mainWindow());
gd->setModal(false); gd->setModal(false);
connect(gd, &GerritDialog::fetchDisplay, this, &GerritPlugin::fetchDisplay); connect(gd, &GerritDialog::fetchDisplay, this,
connect(gd, &GerritDialog::fetchCherryPick, this, &GerritPlugin::fetchCherryPick); [this](const QSharedPointer<GerritChange> &change) { fetch(change, FetchDisplay); });
connect(gd, &GerritDialog::fetchCheckout, this, &GerritPlugin::fetchCheckout); connect(gd, &GerritDialog::fetchCherryPick, this,
[this](const QSharedPointer<GerritChange> &change) { fetch(change, FetchCherryPick); });
connect(gd, &GerritDialog::fetchCheckout, this,
[this](const QSharedPointer<GerritChange> &change) { fetch(change, FetchCheckout); });
connect(this, &GerritPlugin::fetchStarted, gd, &GerritDialog::fetchStarted); connect(this, &GerritPlugin::fetchStarted, gd, &GerritDialog::fetchStarted);
connect(this, &GerritPlugin::fetchFinished, gd, &GerritDialog::fetchFinished); connect(this, &GerritPlugin::fetchFinished, gd, &GerritDialog::fetchFinished);
m_dialog = gd; m_dialog = gd;
@@ -391,21 +392,6 @@ QString GerritPlugin::branch(const QString &repository)
return GitPlugin::client()->synchronousCurrentLocalBranch(repository); return GitPlugin::client()->synchronousCurrentLocalBranch(repository);
} }
void GerritPlugin::fetchDisplay(const QSharedPointer<GerritChange> &change)
{
fetch(change, FetchDisplay);
}
void GerritPlugin::fetchCherryPick(const QSharedPointer<GerritChange> &change)
{
fetch(change, FetchCherryPick);
}
void GerritPlugin::fetchCheckout(const QSharedPointer<GerritChange> &change)
{
fetch(change, FetchCheckout);
}
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode) void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
{ {
// Locate git. // Locate git.
@@ -442,8 +428,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
remote.chop(4); remote.chop(4);
if (remote.contains(m_parameters->host) && remote.endsWith(change->project) if (remote.contains(m_parameters->host) && remote.endsWith(change->project)
&& QFile::exists(repository + '/' + submoduleData.dir)) { && QFile::exists(repository + '/' + submoduleData.dir)) {
repository = QDir::cleanPath(repository + '/' repository = QDir::cleanPath(repository + '/' + submoduleData.dir);
+ submoduleData.dir);
verifiedRepository = true; verifiedRepository = true;
break; break;
} }

View File

@@ -63,9 +63,6 @@ public:
void addToLocator(Core::CommandLocator *locator); void addToLocator(Core::CommandLocator *locator);
void push(const QString &topLevel); void push(const QString &topLevel);
void fetchDisplay(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
void fetchCherryPick(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
void updateActions(bool hasTopLevel); void updateActions(bool hasTopLevel);
signals: signals: