forked from qt-creator/qt-creator
Git: Make Gerrit settings handling more similar to others
Use a singleton for the main settings, don't pass it around as shared pointer. Change-Id: I5c32679452ad631998a688afc9a6e2b154bf3a5d Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -39,20 +39,17 @@
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static const int maxTitleWidth = 350;
|
static const int maxTitleWidth = 350;
|
||||||
|
|
||||||
GerritDialog::GerritDialog(const std::shared_ptr<GerritParameters> &p,
|
GerritDialog::GerritDialog(const std::shared_ptr<GerritServer> &s,
|
||||||
const std::shared_ptr<GerritServer> &s,
|
|
||||||
const FilePath &repository,
|
const FilePath &repository,
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_parameters(p)
|
|
||||||
, m_server(s)
|
, m_server(s)
|
||||||
, m_filterModel(new QSortFilterProxyModel(this))
|
, m_filterModel(new QSortFilterProxyModel(this))
|
||||||
, m_model(new GerritModel(p, this))
|
, m_model(new GerritModel(this))
|
||||||
, m_queryModel(new QStringListModel(this))
|
, m_queryModel(new QStringListModel(this))
|
||||||
{
|
{
|
||||||
setWindowTitle(Git::Tr::tr("Gerrit"));
|
setWindowTitle(Git::Tr::tr("Gerrit"));
|
||||||
@@ -95,9 +92,8 @@ GerritDialog::GerritDialog(const std::shared_ptr<GerritParameters> &p,
|
|||||||
auto queryLabel = new QLabel(Git::Tr::tr("&Query:"), changesGroup);
|
auto queryLabel = new QLabel(Git::Tr::tr("&Query:"), changesGroup);
|
||||||
queryLabel->setBuddy(m_queryLineEdit);
|
queryLabel->setBuddy(m_queryLineEdit);
|
||||||
|
|
||||||
m_remoteComboBox->setParameters(m_parameters);
|
|
||||||
m_remoteComboBox->setFallbackEnabled(true);
|
m_remoteComboBox->setFallbackEnabled(true);
|
||||||
m_queryModel->setStringList(m_parameters->savedQueries);
|
m_queryModel->setStringList(gerritSettings().savedQueries);
|
||||||
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
m_filterModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
|
||||||
m_filterModel->setSourceModel(m_model);
|
m_filterModel->setSourceModel(m_model);
|
||||||
m_filterModel->setFilterRole(GerritModel::FilterRole);
|
m_filterModel->setFilterRole(GerritModel::FilterRole);
|
||||||
@@ -210,11 +206,11 @@ void GerritDialog::updateCompletions(const QString &query)
|
|||||||
{
|
{
|
||||||
if (query.isEmpty())
|
if (query.isEmpty())
|
||||||
return;
|
return;
|
||||||
QStringList &queries = m_parameters->savedQueries;
|
QStringList &queries = gerritSettings().savedQueries;
|
||||||
queries.removeAll(query);
|
queries.removeAll(query);
|
||||||
queries.prepend(query);
|
queries.prepend(query);
|
||||||
m_queryModel->setStringList(queries);
|
m_queryModel->setStringList(queries);
|
||||||
m_parameters->saveQueries(Core::ICore::settings());
|
gerritSettings().saveQueries();
|
||||||
}
|
}
|
||||||
|
|
||||||
GerritDialog::~GerritDialog() = default;
|
GerritDialog::~GerritDialog() = default;
|
||||||
@@ -300,7 +296,7 @@ void GerritDialog::updateRemotes(bool forceReload)
|
|||||||
m_remoteComboBox->setRepository(m_repository);
|
m_remoteComboBox->setRepository(m_repository);
|
||||||
if (m_repository.isEmpty() || !m_repository.isDir())
|
if (m_repository.isEmpty() || !m_repository.isDir())
|
||||||
return;
|
return;
|
||||||
*m_server = m_parameters->server;
|
*m_server = gerritSettings().server;
|
||||||
m_remoteComboBox->updateRemotes(forceReload);
|
m_remoteComboBox->updateRemotes(forceReload);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,5 +356,4 @@ void GerritDialog::setProgressIndicatorVisible(bool v)
|
|||||||
m_progressIndicator->setVisible(v);
|
m_progressIndicator->setVisible(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -26,12 +26,10 @@ class ProgressIndicator;
|
|||||||
class TreeView;
|
class TreeView;
|
||||||
} // Utils
|
} // Utils
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GerritChange;
|
class GerritChange;
|
||||||
class GerritModel;
|
class GerritModel;
|
||||||
class GerritParameters;
|
|
||||||
class GerritRemoteChooser;
|
class GerritRemoteChooser;
|
||||||
class GerritServer;
|
class GerritServer;
|
||||||
|
|
||||||
@@ -39,8 +37,7 @@ class GerritDialog : public QDialog
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit GerritDialog(const std::shared_ptr<GerritParameters> &p,
|
explicit GerritDialog(const std::shared_ptr<GerritServer> &s,
|
||||||
const std::shared_ptr<GerritServer> &s,
|
|
||||||
const Utils::FilePath &repository,
|
const Utils::FilePath &repository,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
~GerritDialog() override;
|
~GerritDialog() override;
|
||||||
@@ -75,7 +72,6 @@ private:
|
|||||||
QPushButton *addActionButton(const QString &text, const std::function<void ()> &buttonSlot);
|
QPushButton *addActionButton(const QString &text, const std::function<void ()> &buttonSlot);
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
|
|
||||||
const std::shared_ptr<GerritParameters> m_parameters;
|
|
||||||
const std::shared_ptr<GerritServer> m_server;
|
const std::shared_ptr<GerritServer> m_server;
|
||||||
QSortFilterProxyModel *m_filterModel;
|
QSortFilterProxyModel *m_filterModel;
|
||||||
GerritModel *m_model;
|
GerritModel *m_model;
|
||||||
@@ -99,5 +95,4 @@ private:
|
|||||||
Utils::FancyLineEdit *m_queryLineEdit;
|
Utils::FancyLineEdit *m_queryLineEdit;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "gerritmodel.h"
|
#include "gerritmodel.h"
|
||||||
|
#include "gerritparameters.h"
|
||||||
#include "../gitclient.h"
|
#include "../gitclient.h"
|
||||||
#include "../gittr.h"
|
#include "../gittr.h"
|
||||||
|
|
||||||
@@ -32,8 +33,7 @@ enum { debug = 0 };
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const GerritApproval &a)
|
QDebug operator<<(QDebug d, const GerritApproval &a)
|
||||||
{
|
{
|
||||||
@@ -64,11 +64,9 @@ QDebug operator<<(QDebug d, const GerritChange &c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format default Url for a change
|
// Format default Url for a change
|
||||||
static inline QString defaultUrl(const std::shared_ptr<GerritParameters> &p,
|
static QString defaultUrl(const GerritServer &server, int gerritNumber)
|
||||||
const GerritServer &server,
|
|
||||||
int gerritNumber)
|
|
||||||
{
|
{
|
||||||
QString result = QLatin1String(p->https ? "https://" : "http://");
|
QString result = QLatin1String(gerritSettings().https ? "https://" : "http://");
|
||||||
result += server.host;
|
result += server.host;
|
||||||
result += '/';
|
result += '/';
|
||||||
result += QString::number(gerritNumber);
|
result += QString::number(gerritNumber);
|
||||||
@@ -208,7 +206,6 @@ class QueryContext : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QueryContext(const QString &query,
|
QueryContext(const QString &query,
|
||||||
const std::shared_ptr<GerritParameters> &p,
|
|
||||||
const GerritServer &server,
|
const GerritServer &server,
|
||||||
QObject *parent = nullptr);
|
QObject *parent = nullptr);
|
||||||
|
|
||||||
@@ -236,22 +233,21 @@ private:
|
|||||||
enum { timeOutMS = 30000 };
|
enum { timeOutMS = 30000 };
|
||||||
|
|
||||||
QueryContext::QueryContext(const QString &query,
|
QueryContext::QueryContext(const QString &query,
|
||||||
const std::shared_ptr<GerritParameters> &p,
|
|
||||||
const GerritServer &server,
|
const GerritServer &server,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
m_process.setUseCtrlCStub(true);
|
m_process.setUseCtrlCStub(true);
|
||||||
if (server.type == GerritServer::Ssh) {
|
if (server.type == GerritServer::Ssh) {
|
||||||
m_binary = p->ssh;
|
m_binary = gerritSettings().ssh;
|
||||||
if (server.port)
|
if (server.port)
|
||||||
m_arguments << p->portFlag << QString::number(server.port);
|
m_arguments << gerritSettings().portFlag << QString::number(server.port);
|
||||||
m_arguments << server.hostArgument() << "gerrit"
|
m_arguments << server.hostArgument() << "gerrit"
|
||||||
<< "query" << "--dependencies"
|
<< "query" << "--dependencies"
|
||||||
<< "--current-patch-set"
|
<< "--current-patch-set"
|
||||||
<< "--format=JSON" << query;
|
<< "--format=JSON" << query;
|
||||||
} else {
|
} else {
|
||||||
m_binary = p->curl;
|
m_binary = gerritSettings().curl;
|
||||||
const QString url = server.url(GerritServer::RestUrl) + "/changes/?q="
|
const QString url = server.url(GerritServer::RestUrl) + "/changes/?q="
|
||||||
+ QString::fromUtf8(QUrl::toPercentEncoding(query))
|
+ QString::fromUtf8(QUrl::toPercentEncoding(query))
|
||||||
+ "&o=CURRENT_REVISION&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS";
|
+ "&o=CURRENT_REVISION&o=DETAILED_LABELS&o=DETAILED_ACCOUNTS";
|
||||||
@@ -338,9 +334,8 @@ void QueryContext::timeout()
|
|||||||
m_timer.start();
|
m_timer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
GerritModel::GerritModel(const std::shared_ptr<GerritParameters> &p, QObject *parent)
|
GerritModel::GerritModel(QObject *parent)
|
||||||
: QStandardItemModel(0, ColumnCount, parent)
|
: QStandardItemModel(0, ColumnCount, parent)
|
||||||
, m_parameters(p)
|
|
||||||
{
|
{
|
||||||
QStringList headers; // Keep in sync with GerritChange::toHtml()
|
QStringList headers; // Keep in sync with GerritChange::toHtml()
|
||||||
headers << "#" << Git::Tr::tr("Subject") << Git::Tr::tr("Owner")
|
headers << "#" << Git::Tr::tr("Subject") << Git::Tr::tr("Owner")
|
||||||
@@ -460,7 +455,7 @@ void GerritModel::refresh(const std::shared_ptr<GerritServer> &server, const QSt
|
|||||||
realQuery += QString(" (owner:%1 OR reviewer:%1)").arg(user);
|
realQuery += QString(" (owner:%1 OR reviewer:%1)").arg(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_query = new QueryContext(realQuery, m_parameters, *m_server, this);
|
m_query = new QueryContext(realQuery, *m_server, this);
|
||||||
connect(m_query, &QueryContext::resultRetrieved, this, &GerritModel::resultRetrieved);
|
connect(m_query, &QueryContext::resultRetrieved, this, &GerritModel::resultRetrieved);
|
||||||
connect(m_query, &QueryContext::errorText, this, &GerritModel::errorText);
|
connect(m_query, &QueryContext::errorText, this, &GerritModel::errorText);
|
||||||
connect(m_query, &QueryContext::finished, this, &GerritModel::queryFinished);
|
connect(m_query, &QueryContext::finished, this, &GerritModel::queryFinished);
|
||||||
@@ -731,8 +726,7 @@ static GerritChangePtr parseRestOutput(const QJsonObject &object, const GerritSe
|
|||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool parseOutput(const std::shared_ptr<GerritParameters> ¶meters,
|
static bool parseOutput(const GerritServer &server,
|
||||||
const GerritServer &server,
|
|
||||||
const QByteArray &output,
|
const QByteArray &output,
|
||||||
QList<GerritChangePtr> &result)
|
QList<GerritChangePtr> &result)
|
||||||
{
|
{
|
||||||
@@ -775,7 +769,7 @@ static bool parseOutput(const std::shared_ptr<GerritParameters> ¶meters,
|
|||||||
: parseRestOutput(object, server));
|
: parseRestOutput(object, server));
|
||||||
if (change->isValid()) {
|
if (change->isValid()) {
|
||||||
if (change->url.isEmpty()) // No "canonicalWebUrl" is in gerrit.config.
|
if (change->url.isEmpty()) // No "canonicalWebUrl" is in gerrit.config.
|
||||||
change->url = defaultUrl(parameters, server, change->number);
|
change->url = defaultUrl(server, change->number);
|
||||||
result.push_back(change);
|
result.push_back(change);
|
||||||
} else {
|
} else {
|
||||||
const QByteArray jsonObject = QJsonDocument(object).toJson();
|
const QByteArray jsonObject = QJsonDocument(object).toJson();
|
||||||
@@ -844,7 +838,7 @@ bool gerritChangeLessThan(const GerritChangePtr &c1, const GerritChangePtr &c2)
|
|||||||
void GerritModel::resultRetrieved(const QByteArray &output)
|
void GerritModel::resultRetrieved(const QByteArray &output)
|
||||||
{
|
{
|
||||||
QList<GerritChangePtr> changes;
|
QList<GerritChangePtr> changes;
|
||||||
setState(parseOutput(m_parameters, *m_server, output, changes) ? Ok : Error);
|
setState(parseOutput(*m_server, output, changes) ? Ok : Error);
|
||||||
|
|
||||||
// Populate a hash with indices for faster access.
|
// Populate a hash with indices for faster access.
|
||||||
QHash<int, int> numberIndexHash;
|
QHash<int, int> numberIndexHash;
|
||||||
@@ -910,7 +904,6 @@ void GerritModel::queryFinished()
|
|||||||
emit refreshStateChanged(false);
|
emit refreshStateChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|
||||||
#include "gerritmodel.moc"
|
#include "gerritmodel.moc"
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gerritparameters.h"
|
|
||||||
#include "gerritserver.h"
|
#include "gerritserver.h"
|
||||||
|
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
class QueryContext;
|
class QueryContext;
|
||||||
|
|
||||||
class GerritApproval {
|
class GerritApproval {
|
||||||
@@ -78,7 +77,7 @@ public:
|
|||||||
GerritChangeRole = Qt::UserRole + 2,
|
GerritChangeRole = Qt::UserRole + 2,
|
||||||
SortRole = Qt::UserRole + 3
|
SortRole = Qt::UserRole + 3
|
||||||
};
|
};
|
||||||
GerritModel(const std::shared_ptr<GerritParameters> &, QObject *parent = nullptr);
|
GerritModel(QObject *parent = nullptr);
|
||||||
~GerritModel() override;
|
~GerritModel() override;
|
||||||
|
|
||||||
QVariant data(const QModelIndex &index, int role) const override;
|
QVariant data(const QModelIndex &index, int role) const override;
|
||||||
@@ -110,11 +109,9 @@ private:
|
|||||||
const QString &serverPrefix) const;
|
const QString &serverPrefix) const;
|
||||||
QList<QStandardItem *> changeToRow(const GerritChangePtr &c) const;
|
QList<QStandardItem *> changeToRow(const GerritChangePtr &c) const;
|
||||||
|
|
||||||
const std::shared_ptr<GerritParameters> m_parameters;
|
|
||||||
std::shared_ptr<GerritServer> m_server;
|
std::shared_ptr<GerritServer> m_server;
|
||||||
QueryContext *m_query = nullptr;
|
QueryContext *m_query = nullptr;
|
||||||
QueryState m_state = Idle;
|
QueryState m_state = Idle;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -23,31 +23,30 @@ namespace Gerrit::Internal {
|
|||||||
class GerritOptionsWidget : public Core::IOptionsPageWidget
|
class GerritOptionsWidget : public Core::IOptionsPageWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GerritOptionsWidget(const std::shared_ptr<GerritParameters> &p,
|
GerritOptionsWidget(const std::function<void()> &onChanged)
|
||||||
const std::function<void()> &onChanged)
|
|
||||||
: m_parameters(p)
|
|
||||||
{
|
{
|
||||||
auto hostLineEdit = new QLineEdit(p->server.host);
|
const GerritParameters &s = gerritSettings();
|
||||||
|
auto hostLineEdit = new QLineEdit(s.server.host);
|
||||||
|
|
||||||
auto userLineEdit = new QLineEdit(p->server.user.userName);
|
auto userLineEdit = new QLineEdit(s.server.user.userName);
|
||||||
|
|
||||||
auto sshChooser = new Utils::PathChooser;
|
auto sshChooser = new Utils::PathChooser;
|
||||||
sshChooser->setFilePath(p->ssh);
|
sshChooser->setFilePath(s.ssh);
|
||||||
sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
sshChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||||
sshChooser->setCommandVersionArguments({"-V"});
|
sshChooser->setCommandVersionArguments({"-V"});
|
||||||
sshChooser->setHistoryCompleter("Git.SshCommand.History");
|
sshChooser->setHistoryCompleter("Git.SshCommand.History");
|
||||||
|
|
||||||
auto curlChooser = new Utils::PathChooser;
|
auto curlChooser = new Utils::PathChooser;
|
||||||
curlChooser->setFilePath(p->curl);
|
curlChooser->setFilePath(s.curl);
|
||||||
curlChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
curlChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||||
curlChooser->setCommandVersionArguments({"-V"});
|
curlChooser->setCommandVersionArguments({"-V"});
|
||||||
|
|
||||||
auto portSpinBox = new QSpinBox(this);
|
auto portSpinBox = new QSpinBox(this);
|
||||||
portSpinBox->setRange(1, 65535);
|
portSpinBox->setRange(1, 65535);
|
||||||
portSpinBox->setValue(p->server.port);
|
portSpinBox->setValue(s.server.port);
|
||||||
|
|
||||||
auto httpsCheckBox = new QCheckBox(Git::Tr::tr("HTTPS"));
|
auto httpsCheckBox = new QCheckBox(Git::Tr::tr("HTTPS"));
|
||||||
httpsCheckBox->setChecked(p->https);
|
httpsCheckBox->setChecked(s.https);
|
||||||
httpsCheckBox->setToolTip(Git::Tr::tr(
|
httpsCheckBox->setToolTip(Git::Tr::tr(
|
||||||
"Determines the protocol used to form a URL in case\n"
|
"Determines the protocol used to form a URL in case\n"
|
||||||
"\"canonicalWebUrl\" is not configured in the file\n"
|
"\"canonicalWebUrl\" is not configured in the file\n"
|
||||||
@@ -63,14 +62,14 @@ public:
|
|||||||
Git::Tr::tr("P&rotocol:"), httpsCheckBox
|
Git::Tr::tr("P&rotocol:"), httpsCheckBox
|
||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
setOnApply([this,
|
setOnApply([hostLineEdit,
|
||||||
hostLineEdit,
|
|
||||||
userLineEdit,
|
userLineEdit,
|
||||||
sshChooser,
|
sshChooser,
|
||||||
curlChooser,
|
curlChooser,
|
||||||
portSpinBox,
|
portSpinBox,
|
||||||
httpsCheckBox,
|
httpsCheckBox,
|
||||||
onChanged] {
|
onChanged] {
|
||||||
|
GerritParameters &s = gerritSettings();
|
||||||
GerritParameters newParameters;
|
GerritParameters newParameters;
|
||||||
newParameters.server = GerritServer(hostLineEdit->text().trimmed(),
|
newParameters.server = GerritServer(hostLineEdit->text().trimmed(),
|
||||||
static_cast<unsigned short>(portSpinBox->value()),
|
static_cast<unsigned short>(portSpinBox->value()),
|
||||||
@@ -80,31 +79,27 @@ public:
|
|||||||
newParameters.curl = curlChooser->filePath();
|
newParameters.curl = curlChooser->filePath();
|
||||||
newParameters.https = httpsCheckBox->isChecked();
|
newParameters.https = httpsCheckBox->isChecked();
|
||||||
|
|
||||||
if (newParameters != *m_parameters) {
|
if (newParameters != s) {
|
||||||
if (m_parameters->ssh == newParameters.ssh)
|
if (s.ssh == newParameters.ssh)
|
||||||
newParameters.portFlag = m_parameters->portFlag;
|
newParameters.portFlag = s.portFlag;
|
||||||
else
|
else
|
||||||
newParameters.setPortFlagBySshType();
|
newParameters.setPortFlagBySshType();
|
||||||
*m_parameters = newParameters;
|
s = newParameters;
|
||||||
m_parameters->toSettings(Core::ICore::settings());
|
s.toSettings();
|
||||||
emit onChanged();
|
emit onChanged();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
|
||||||
const std::shared_ptr<GerritParameters> &m_parameters;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// GerritOptionsPage
|
// GerritOptionsPage
|
||||||
|
|
||||||
GerritOptionsPage::GerritOptionsPage(const std::shared_ptr<GerritParameters> &p,
|
GerritOptionsPage::GerritOptionsPage(const std::function<void()> &onChanged)
|
||||||
const std::function<void()> &onChanged)
|
|
||||||
{
|
{
|
||||||
setId("Gerrit");
|
setId("Gerrit");
|
||||||
setDisplayName(Git::Tr::tr("Gerrit"));
|
setDisplayName(Git::Tr::tr("Gerrit"));
|
||||||
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
||||||
setWidgetCreator([p, onChanged] { return new GerritOptionsWidget(p, onChanged); });
|
setWidgetCreator([onChanged] { return new GerritOptionsWidget(onChanged); });
|
||||||
}
|
}
|
||||||
|
|
||||||
} // Gerrit::Internal
|
} // Gerrit::Internal
|
||||||
|
|||||||
@@ -7,13 +7,10 @@
|
|||||||
|
|
||||||
namespace Gerrit::Internal {
|
namespace Gerrit::Internal {
|
||||||
|
|
||||||
class GerritParameters;
|
|
||||||
|
|
||||||
class GerritOptionsPage : public Core::IOptionsPage
|
class GerritOptionsPage : public Core::IOptionsPage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GerritOptionsPage(const std::shared_ptr<GerritParameters> &p,
|
explicit GerritOptionsPage(const std::function<void()> &onChanged);
|
||||||
const std::function<void()> &onChanged);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Gerrit::Internal
|
} // Gerrit::Internal
|
||||||
|
|||||||
@@ -4,6 +4,8 @@
|
|||||||
#include "gerritparameters.h"
|
#include "gerritparameters.h"
|
||||||
#include "gerritplugin.h"
|
#include "gerritplugin.h"
|
||||||
|
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/commandline.h>
|
#include <utils/commandline.h>
|
||||||
#include <utils/datafromprocess.h>
|
#include <utils/datafromprocess.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
@@ -14,10 +16,10 @@
|
|||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
|
|
||||||
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
const char settingsGroupC[] = "Gerrit";
|
const char settingsGroupC[] = "Gerrit";
|
||||||
const char hostKeyC[] = "Host";
|
const char hostKeyC[] = "Host";
|
||||||
@@ -91,8 +93,9 @@ bool GerritParameters::equals(const GerritParameters &rhs) const
|
|||||||
return server == rhs.server && ssh == rhs.ssh && curl == rhs.curl && https == rhs.https;
|
return server == rhs.server && ssh == rhs.ssh && curl == rhs.curl && https == rhs.https;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritParameters::toSettings(QtcSettings *s) const
|
void GerritParameters::toSettings() const
|
||||||
{
|
{
|
||||||
|
QtcSettings *s = ICore::settings();
|
||||||
s->beginGroup(settingsGroupC);
|
s->beginGroup(settingsGroupC);
|
||||||
s->setValue(hostKeyC, server.host);
|
s->setValue(hostKeyC, server.host);
|
||||||
s->setValue(userKeyC, server.user.userName);
|
s->setValue(userKeyC, server.user.userName);
|
||||||
@@ -104,15 +107,17 @@ void GerritParameters::toSettings(QtcSettings *s) const
|
|||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritParameters::saveQueries(QtcSettings *s) const
|
void GerritParameters::saveQueries() const
|
||||||
{
|
{
|
||||||
|
QtcSettings *s = ICore::settings();
|
||||||
s->beginGroup(settingsGroupC);
|
s->beginGroup(settingsGroupC);
|
||||||
s->setValue(savedQueriesKeyC, savedQueries.join(','));
|
s->setValue(savedQueriesKeyC, savedQueries.join(','));
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritParameters::fromSettings(const QtcSettings *s)
|
void GerritParameters::fromSettings()
|
||||||
{
|
{
|
||||||
|
QtcSettings *s = ICore::settings();
|
||||||
const Key rootKey = Key(settingsGroupC) + '/';
|
const Key rootKey = Key(settingsGroupC) + '/';
|
||||||
server.host = s->value(rootKey + hostKeyC, GerritServer::defaultHost()).toString();
|
server.host = s->value(rootKey + hostKeyC, GerritServer::defaultHost()).toString();
|
||||||
server.user.userName = s->value(rootKey + userKeyC, QString()).toString();
|
server.user.userName = s->value(rootKey + userKeyC, QString()).toString();
|
||||||
@@ -134,5 +139,10 @@ bool GerritParameters::isValid() const
|
|||||||
return !server.host.isEmpty() && !server.user.userName.isEmpty() && !ssh.isEmpty();
|
return !server.host.isEmpty() && !server.user.userName.isEmpty() && !ssh.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
GerritParameters &gerritSettings()
|
||||||
} // namespace Gerrit
|
{
|
||||||
|
static GerritParameters theGerritSettings;
|
||||||
|
return theGerritSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Gerrit::Internal
|
||||||
|
|||||||
@@ -7,10 +7,7 @@
|
|||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
namespace Utils { class QtcSettings; }
|
namespace Gerrit::Internal {
|
||||||
|
|
||||||
namespace Gerrit {
|
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GerritParameters
|
class GerritParameters
|
||||||
{
|
{
|
||||||
@@ -19,9 +16,9 @@ public:
|
|||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
bool equals(const GerritParameters &rhs) const;
|
bool equals(const GerritParameters &rhs) const;
|
||||||
void toSettings(Utils::QtcSettings *) const;
|
void toSettings() const;
|
||||||
void saveQueries(Utils::QtcSettings *) const;
|
void saveQueries() const;
|
||||||
void fromSettings(const Utils::QtcSettings *);
|
void fromSettings();
|
||||||
void setPortFlagBySshType();
|
void setPortFlagBySshType();
|
||||||
|
|
||||||
friend bool operator==(const GerritParameters &p1, const GerritParameters &p2)
|
friend bool operator==(const GerritParameters &p1, const GerritParameters &p2)
|
||||||
@@ -37,5 +34,6 @@ public:
|
|||||||
QString portFlag;
|
QString portFlag;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
GerritParameters &gerritSettings();
|
||||||
} // namespace Gerrit
|
|
||||||
|
} // Gerrit::Internal
|
||||||
|
|||||||
@@ -153,13 +153,11 @@ void FetchContext::checkout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
GerritPlugin::GerritPlugin()
|
GerritPlugin::GerritPlugin()
|
||||||
: m_parameters(new GerritParameters)
|
: m_server(new GerritServer)
|
||||||
, m_server(new GerritServer)
|
|
||||||
{
|
{
|
||||||
m_parameters->fromSettings(ICore::settings());
|
gerritSettings().fromSettings();
|
||||||
|
|
||||||
m_gerritOptionsPage = new GerritOptionsPage(m_parameters,
|
m_gerritOptionsPage = new GerritOptionsPage([this] {
|
||||||
[this] {
|
|
||||||
if (m_dialog)
|
if (m_dialog)
|
||||||
m_dialog->scheduleUpdateRemotes();
|
m_dialog->scheduleUpdateRemotes();
|
||||||
});
|
});
|
||||||
@@ -206,7 +204,7 @@ void GerritPlugin::addToLocator(CommandLocator *locator)
|
|||||||
void GerritPlugin::push(const FilePath &topLevel)
|
void GerritPlugin::push(const FilePath &topLevel)
|
||||||
{
|
{
|
||||||
// QScopedPointer is required to delete the dialog when leaving the function
|
// QScopedPointer is required to delete the dialog when leaving the function
|
||||||
GerritPushDialog dialog(topLevel, m_reviewers, m_parameters, ICore::dialogParent());
|
GerritPushDialog dialog(topLevel, m_reviewers, ICore::dialogParent());
|
||||||
|
|
||||||
const QString initErrorMessage = dialog.initErrorMessage();
|
const QString initErrorMessage = dialog.initErrorMessage();
|
||||||
if (!initErrorMessage.isEmpty()) {
|
if (!initErrorMessage.isEmpty()) {
|
||||||
@@ -231,13 +229,13 @@ static FilePath currentRepository()
|
|||||||
void GerritPlugin::openView()
|
void GerritPlugin::openView()
|
||||||
{
|
{
|
||||||
if (m_dialog.isNull()) {
|
if (m_dialog.isNull()) {
|
||||||
while (!m_parameters->isValid()) {
|
while (!gerritSettings().isValid()) {
|
||||||
QMessageBox::warning(Core::ICore::dialogParent(), Git::Tr::tr("Error"),
|
QMessageBox::warning(Core::ICore::dialogParent(), Git::Tr::tr("Error"),
|
||||||
Git::Tr::tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory."));
|
Git::Tr::tr("Invalid Gerrit configuration. Host, user and ssh binary are mandatory."));
|
||||||
if (!ICore::showOptionsDialog("Gerrit"))
|
if (!ICore::showOptionsDialog("Gerrit"))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
GerritDialog *gd = new GerritDialog(m_parameters, m_server, currentRepository(), ICore::dialogParent());
|
GerritDialog *gd = new GerritDialog(m_server, currentRepository(), ICore::dialogParent());
|
||||||
gd->setModal(false);
|
gd->setModal(false);
|
||||||
ICore::registerWindow(gd, Context("Git.Gerrit"));
|
ICore::registerWindow(gd, Context("Git.Gerrit"));
|
||||||
connect(gd, &GerritDialog::fetchDisplay, this,
|
connect(gd, &GerritDialog::fetchDisplay, this,
|
||||||
@@ -287,7 +285,7 @@ void GerritPlugin::fetch(const std::shared_ptr<GerritChange> &change, int mode)
|
|||||||
|
|
||||||
FilePath repository;
|
FilePath repository;
|
||||||
bool verifiedRepository = false;
|
bool verifiedRepository = false;
|
||||||
if (m_dialog && m_parameters && m_dialog->repositoryPath().exists())
|
if (m_dialog && m_dialog->repositoryPath().exists())
|
||||||
repository = m_dialog->repositoryPath();
|
repository = m_dialog->repositoryPath();
|
||||||
|
|
||||||
if (!repository.isEmpty()) {
|
if (!repository.isEmpty()) {
|
||||||
|
|||||||
@@ -17,12 +17,10 @@ class CommandLocator;
|
|||||||
|
|
||||||
namespace VcsBase { class VcsBasePluginState; }
|
namespace VcsBase { class VcsBasePluginState; }
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GerritChange;
|
class GerritChange;
|
||||||
class GerritDialog;
|
class GerritDialog;
|
||||||
class GerritParameters;
|
|
||||||
class GerritServer;
|
class GerritServer;
|
||||||
class GerritOptionsPage;
|
class GerritOptionsPage;
|
||||||
|
|
||||||
@@ -54,7 +52,6 @@ private:
|
|||||||
Utils::FilePath findLocalRepository(const QString &project, const QString &branch) const;
|
Utils::FilePath findLocalRepository(const QString &project, const QString &branch) const;
|
||||||
void fetch(const std::shared_ptr<GerritChange> &change, int mode);
|
void fetch(const std::shared_ptr<GerritChange> &change, int mode);
|
||||||
|
|
||||||
std::shared_ptr<GerritParameters> m_parameters;
|
|
||||||
std::shared_ptr<GerritServer> m_server;
|
std::shared_ptr<GerritServer> m_server;
|
||||||
QPointer<GerritDialog> m_dialog;
|
QPointer<GerritDialog> m_dialog;
|
||||||
Core::Command *m_gerritCommand = nullptr;
|
Core::Command *m_gerritCommand = nullptr;
|
||||||
@@ -63,5 +60,4 @@ private:
|
|||||||
GerritOptionsPage *m_gerritOptionsPage = nullptr;
|
GerritOptionsPage *m_gerritOptionsPage = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -25,8 +25,7 @@
|
|||||||
|
|
||||||
using namespace Git::Internal;
|
using namespace Git::Internal;
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static const int ReasonableDistance = 100;
|
static const int ReasonableDistance = 100;
|
||||||
|
|
||||||
@@ -108,7 +107,6 @@ void GerritPushDialog::initRemoteBranches()
|
|||||||
|
|
||||||
GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir,
|
GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir,
|
||||||
const QString &reviewerList,
|
const QString &reviewerList,
|
||||||
std::shared_ptr<GerritParameters> parameters,
|
|
||||||
QWidget *parent)
|
QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, m_localBranchComboBox(new BranchComboBox)
|
, m_localBranchComboBox(new BranchComboBox)
|
||||||
@@ -154,7 +152,6 @@ GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir,
|
|||||||
}.attachTo(this);
|
}.attachTo(this);
|
||||||
|
|
||||||
m_remoteComboBox->setRepository(workingDir);
|
m_remoteComboBox->setRepository(workingDir);
|
||||||
m_remoteComboBox->setParameters(parameters);
|
|
||||||
m_remoteComboBox->setAllowDups(true);
|
m_remoteComboBox->setAllowDups(true);
|
||||||
|
|
||||||
auto delegate = new PushItemDelegate(m_commitView);
|
auto delegate = new PushItemDelegate(m_commitView);
|
||||||
@@ -419,5 +416,4 @@ QString GerritPushDialog::reviewers() const
|
|||||||
return m_reviewersLineEdit->text();
|
return m_reviewersLineEdit->text();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -19,11 +19,9 @@ QT_END_NAMESPACE
|
|||||||
|
|
||||||
namespace Git::Internal { class LogChangeWidget; }
|
namespace Git::Internal { class LogChangeWidget; }
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class BranchComboBox;
|
class BranchComboBox;
|
||||||
class GerritParameters;
|
|
||||||
class GerritRemoteChooser;
|
class GerritRemoteChooser;
|
||||||
|
|
||||||
class GerritPushDialog : public QDialog
|
class GerritPushDialog : public QDialog
|
||||||
@@ -32,7 +30,7 @@ class GerritPushDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
GerritPushDialog(const Utils::FilePath &workingDir, const QString &reviewerList,
|
GerritPushDialog(const Utils::FilePath &workingDir, const QString &reviewerList,
|
||||||
std::shared_ptr<GerritParameters> parameters, QWidget *parent);
|
QWidget *parent);
|
||||||
|
|
||||||
QString selectedCommit() const;
|
QString selectedCommit() const;
|
||||||
QString selectedRemoteName() const;
|
QString selectedRemoteName() const;
|
||||||
@@ -76,6 +74,4 @@ private:
|
|||||||
bool m_currentSupportsWip = false;
|
bool m_currentSupportsWip = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // Gerrit::Internal
|
||||||
} // namespace Internal
|
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -51,11 +51,6 @@ void GerritRemoteChooser::setRepository(const FilePath &repository)
|
|||||||
m_repository = repository;
|
m_repository = repository;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritRemoteChooser::setParameters(std::shared_ptr<GerritParameters> parameters)
|
|
||||||
{
|
|
||||||
m_parameters = parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GerritRemoteChooser::setFallbackEnabled(bool value)
|
void GerritRemoteChooser::setFallbackEnabled(bool value)
|
||||||
{
|
{
|
||||||
m_enableFallback = value;
|
m_enableFallback = value;
|
||||||
@@ -79,7 +74,7 @@ bool GerritRemoteChooser::setCurrentRemote(const QString &remoteName)
|
|||||||
|
|
||||||
bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!m_repository.isEmpty() || !m_parameters, return false);
|
QTC_ASSERT(!m_repository.isEmpty(), return false);
|
||||||
m_updatingRemotes = true;
|
m_updatingRemotes = true;
|
||||||
m_remoteComboBox->clear();
|
m_remoteComboBox->clear();
|
||||||
m_remotes.clear();
|
m_remotes.clear();
|
||||||
@@ -88,12 +83,12 @@ bool GerritRemoteChooser::updateRemotes(bool forceReload)
|
|||||||
Git::Internal::gitClient().synchronousRemotesList(m_repository, &errorMessage);
|
Git::Internal::gitClient().synchronousRemotesList(m_repository, &errorMessage);
|
||||||
for (auto mapIt = remotesList.cbegin(), end = remotesList.cend(); mapIt != end; ++mapIt) {
|
for (auto mapIt = remotesList.cbegin(), end = remotesList.cend(); mapIt != end; ++mapIt) {
|
||||||
GerritServer server;
|
GerritServer server;
|
||||||
if (!server.fillFromRemote(mapIt.value(), *m_parameters, forceReload))
|
if (!server.fillFromRemote(mapIt.value(), forceReload))
|
||||||
continue;
|
continue;
|
||||||
addRemote(server, mapIt.key());
|
addRemote(server, mapIt.key());
|
||||||
}
|
}
|
||||||
if (m_enableFallback)
|
if (m_enableFallback)
|
||||||
addRemote(m_parameters->server, Git::Tr::tr("Fallback"));
|
addRemote(gerritSettings().server, Git::Tr::tr("Fallback"));
|
||||||
m_remoteComboBox->setEnabled(m_remoteComboBox->count() > 1);
|
m_remoteComboBox->setEnabled(m_remoteComboBox->count() > 1);
|
||||||
m_updatingRemotes = false;
|
m_updatingRemotes = false;
|
||||||
handleRemoteChanged();
|
handleRemoteChanged();
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
namespace Gerrit {
|
namespace Gerrit {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GerritParameters;
|
|
||||||
|
|
||||||
class GerritRemoteChooser : public QWidget
|
class GerritRemoteChooser : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -25,7 +23,6 @@ class GerritRemoteChooser : public QWidget
|
|||||||
public:
|
public:
|
||||||
GerritRemoteChooser(QWidget *parent = nullptr);
|
GerritRemoteChooser(QWidget *parent = nullptr);
|
||||||
void setRepository(const Utils::FilePath &repository);
|
void setRepository(const Utils::FilePath &repository);
|
||||||
void setParameters(std::shared_ptr<GerritParameters> parameters);
|
|
||||||
void setFallbackEnabled(bool value);
|
void setFallbackEnabled(bool value);
|
||||||
void setAllowDups(bool value);
|
void setAllowDups(bool value);
|
||||||
bool setCurrentRemote(const QString &remoteName);
|
bool setCurrentRemote(const QString &remoteName);
|
||||||
@@ -43,7 +40,6 @@ private:
|
|||||||
void handleRemoteChanged();
|
void handleRemoteChanged();
|
||||||
|
|
||||||
Utils::FilePath m_repository;
|
Utils::FilePath m_repository;
|
||||||
std::shared_ptr<GerritParameters> m_parameters;
|
|
||||||
QComboBox *m_remoteComboBox = nullptr;
|
QComboBox *m_remoteComboBox = nullptr;
|
||||||
QToolButton *m_resetRemoteButton = nullptr;
|
QToolButton *m_resetRemoteButton = nullptr;
|
||||||
bool m_updatingRemotes = false;
|
bool m_updatingRemotes = false;
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ using namespace Git::Internal;
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
using namespace VcsBase;
|
using namespace VcsBase;
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
static const char defaultHostC[] = "codereview.qt-project.org";
|
static const char defaultHostC[] = "codereview.qt-project.org";
|
||||||
static const char accountUrlC[] = "/accounts/self";
|
static const char accountUrlC[] = "/accounts/self";
|
||||||
@@ -115,9 +114,7 @@ QString GerritServer::url(UrlType urlType) const
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GerritServer::fillFromRemote(const QString &remote,
|
bool GerritServer::fillFromRemote(const QString &remote, bool forceReload)
|
||||||
const GerritParameters ¶meters,
|
|
||||||
bool forceReload)
|
|
||||||
{
|
{
|
||||||
const GitRemote r(remote);
|
const GitRemote r(remote);
|
||||||
if (!r.isValid)
|
if (!r.isValid)
|
||||||
@@ -136,11 +133,11 @@ bool GerritServer::fillFromRemote(const QString &remote,
|
|||||||
return false;
|
return false;
|
||||||
host = r.host;
|
host = r.host;
|
||||||
port = r.port;
|
port = r.port;
|
||||||
user.userName = r.userName.isEmpty() ? parameters.server.user.userName : r.userName;
|
user.userName = r.userName.isEmpty() ? gerritSettings().server.user.userName : r.userName;
|
||||||
if (type == GerritServer::Ssh) {
|
if (type == GerritServer::Ssh) {
|
||||||
return resolveVersion(parameters, forceReload);
|
return resolveVersion(forceReload);
|
||||||
}
|
}
|
||||||
curlBinary = parameters.curl;
|
curlBinary = gerritSettings().curl;
|
||||||
if (curlBinary.isEmpty() || !curlBinary.exists())
|
if (curlBinary.isEmpty() || !curlBinary.exists())
|
||||||
return false;
|
return false;
|
||||||
const StoredHostValidity validity = forceReload ? Invalid : loadSettings();
|
const StoredHostValidity validity = forceReload ? Invalid : loadSettings();
|
||||||
@@ -152,7 +149,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
|
|||||||
// (can be http://example.net/review)
|
// (can be http://example.net/review)
|
||||||
ascendPath();
|
ascendPath();
|
||||||
if (resolveRoot()) {
|
if (resolveRoot()) {
|
||||||
if (!resolveVersion(parameters, forceReload))
|
if (!resolveVersion(forceReload))
|
||||||
return false;
|
return false;
|
||||||
saveSettings(Valid);
|
saveSettings(Valid);
|
||||||
return true;
|
return true;
|
||||||
@@ -161,7 +158,7 @@ bool GerritServer::fillFromRemote(const QString &remote,
|
|||||||
case NotGerrit:
|
case NotGerrit:
|
||||||
return false;
|
return false;
|
||||||
case Valid:
|
case Valid:
|
||||||
return resolveVersion(parameters, false);
|
return resolveVersion(false);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -307,8 +304,9 @@ bool GerritServer::resolveRoot()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
bool GerritServer::resolveVersion(bool forceReload)
|
||||||
{
|
{
|
||||||
|
const GerritParameters &p = gerritSettings();
|
||||||
QtcSettings *settings = Core::ICore::settings();
|
QtcSettings *settings = Core::ICore::settings();
|
||||||
const Key fullVersionKey = "Gerrit/" + keyFromString(host) + '/' + versionKey;
|
const Key fullVersionKey = "Gerrit/" + keyFromString(host) + '/' + versionKey;
|
||||||
version = settings->value(fullVersionKey).toString();
|
version = settings->value(fullVersionKey).toString();
|
||||||
@@ -346,5 +344,4 @@ bool GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
@@ -5,10 +5,7 @@
|
|||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
namespace Gerrit {
|
namespace Gerrit::Internal {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
class GerritParameters;
|
|
||||||
|
|
||||||
class GerritUser
|
class GerritUser
|
||||||
{
|
{
|
||||||
@@ -52,7 +49,7 @@ public:
|
|||||||
static QString defaultHost();
|
static QString defaultHost();
|
||||||
QString hostArgument() const;
|
QString hostArgument() const;
|
||||||
QString url(UrlType urlType = DefaultUrl) const;
|
QString url(UrlType urlType = DefaultUrl) const;
|
||||||
bool fillFromRemote(const QString &remote, const GerritParameters ¶meters, bool forceReload);
|
bool fillFromRemote(const QString &remote, bool forceReload);
|
||||||
int testConnection();
|
int testConnection();
|
||||||
QStringList curlArguments() const;
|
QStringList curlArguments() const;
|
||||||
|
|
||||||
@@ -72,8 +69,7 @@ private:
|
|||||||
bool setupAuthentication();
|
bool setupAuthentication();
|
||||||
bool ascendPath();
|
bool ascendPath();
|
||||||
bool resolveRoot();
|
bool resolveRoot();
|
||||||
bool resolveVersion(const GerritParameters &p, bool forceReload);
|
bool resolveVersion(bool forceReload);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // Gerrit::Internal
|
||||||
} // namespace Gerrit
|
|
||||||
|
|||||||
Reference in New Issue
Block a user