forked from qt-creator/qt-creator
Gerrit: Make sure there's only one GerritParameters object
Later to be renamed to GerritSettings, and possibly using aspects. Change-Id: Idd3d9d3de4f9827478129fe210abfa7b80cff84d Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
#include <QCheckBox>
|
||||
#include <QFormLayout>
|
||||
|
||||
using namespace Utils;
|
||||
|
||||
namespace Gerrit::Internal {
|
||||
|
||||
class GerritOptionsWidget : public Core::IOptionsPageWidget
|
||||
@@ -70,24 +72,26 @@ public:
|
||||
httpsCheckBox,
|
||||
onChanged] {
|
||||
GerritParameters &s = gerritSettings();
|
||||
GerritParameters newParameters;
|
||||
newParameters.server = GerritServer(hostLineEdit->text().trimmed(),
|
||||
static_cast<unsigned short>(portSpinBox->value()),
|
||||
userLineEdit->text().trimmed(),
|
||||
GerritServer::Ssh);
|
||||
newParameters.ssh = sshChooser->filePath();
|
||||
newParameters.curl = curlChooser->filePath();
|
||||
newParameters.https = httpsCheckBox->isChecked();
|
||||
|
||||
if (newParameters != s) {
|
||||
if (s.ssh == newParameters.ssh)
|
||||
newParameters.portFlag = s.portFlag;
|
||||
else
|
||||
newParameters.setPortFlagBySshType();
|
||||
s = newParameters;
|
||||
s.toSettings();
|
||||
emit onChanged();
|
||||
}
|
||||
GerritServer server(hostLineEdit->text().trimmed(),
|
||||
static_cast<unsigned short>(portSpinBox->value()),
|
||||
userLineEdit->text().trimmed(),
|
||||
GerritServer::Ssh);
|
||||
FilePath ssh = sshChooser->filePath();
|
||||
FilePath curl = curlChooser->filePath();
|
||||
bool https = httpsCheckBox->isChecked();
|
||||
|
||||
if (server == s.server && ssh == s.ssh && curl == s.curl && https == s.https)
|
||||
return;
|
||||
|
||||
s.server = server;
|
||||
s.ssh = ssh;
|
||||
s.curl = curl;
|
||||
s.https = https;
|
||||
if (s.ssh != ssh)
|
||||
s.setPortFlagBySshType();
|
||||
s.toSettings();
|
||||
emit onChanged();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -89,11 +89,6 @@ GerritParameters::GerritParameters()
|
||||
{
|
||||
}
|
||||
|
||||
bool GerritParameters::equals(const GerritParameters &rhs) const
|
||||
{
|
||||
return server == rhs.server && ssh == rhs.ssh && curl == rhs.curl && https == rhs.https;
|
||||
}
|
||||
|
||||
void GerritParameters::toSettings() const
|
||||
{
|
||||
QtcSettings *s = ICore::settings();
|
||||
|
||||
@@ -12,26 +12,22 @@ namespace Gerrit::Internal {
|
||||
class GerritParameters
|
||||
{
|
||||
public:
|
||||
GerritParameters();
|
||||
|
||||
bool isValid() const;
|
||||
bool equals(const GerritParameters &rhs) const;
|
||||
void toSettings() const;
|
||||
void saveQueries() const;
|
||||
void fromSettings();
|
||||
void setPortFlagBySshType();
|
||||
|
||||
friend bool operator==(const GerritParameters &p1, const GerritParameters &p2)
|
||||
{ return p1.equals(p2); }
|
||||
friend bool operator!=(const GerritParameters &p1, const GerritParameters &p2)
|
||||
{ return !p1.equals(p2); }
|
||||
|
||||
GerritServer server;
|
||||
Utils::FilePath ssh;
|
||||
Utils::FilePath curl;
|
||||
QStringList savedQueries;
|
||||
bool https = true;
|
||||
QString portFlag;
|
||||
|
||||
private:
|
||||
friend GerritParameters &gerritSettings();
|
||||
GerritParameters();
|
||||
};
|
||||
|
||||
GerritParameters &gerritSettings();
|
||||
|
||||
Reference in New Issue
Block a user