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 <QCheckBox>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Gerrit::Internal {
|
namespace Gerrit::Internal {
|
||||||
|
|
||||||
class GerritOptionsWidget : public Core::IOptionsPageWidget
|
class GerritOptionsWidget : public Core::IOptionsPageWidget
|
||||||
@@ -70,24 +72,26 @@ public:
|
|||||||
httpsCheckBox,
|
httpsCheckBox,
|
||||||
onChanged] {
|
onChanged] {
|
||||||
GerritParameters &s = gerritSettings();
|
GerritParameters &s = gerritSettings();
|
||||||
GerritParameters newParameters;
|
|
||||||
newParameters.server = GerritServer(hostLineEdit->text().trimmed(),
|
GerritServer server(hostLineEdit->text().trimmed(),
|
||||||
static_cast<unsigned short>(portSpinBox->value()),
|
static_cast<unsigned short>(portSpinBox->value()),
|
||||||
userLineEdit->text().trimmed(),
|
userLineEdit->text().trimmed(),
|
||||||
GerritServer::Ssh);
|
GerritServer::Ssh);
|
||||||
newParameters.ssh = sshChooser->filePath();
|
FilePath ssh = sshChooser->filePath();
|
||||||
newParameters.curl = curlChooser->filePath();
|
FilePath curl = curlChooser->filePath();
|
||||||
newParameters.https = httpsCheckBox->isChecked();
|
bool https = httpsCheckBox->isChecked();
|
||||||
|
|
||||||
if (newParameters != s) {
|
if (server == s.server && ssh == s.ssh && curl == s.curl && https == s.https)
|
||||||
if (s.ssh == newParameters.ssh)
|
return;
|
||||||
newParameters.portFlag = s.portFlag;
|
|
||||||
else
|
s.server = server;
|
||||||
newParameters.setPortFlagBySshType();
|
s.ssh = ssh;
|
||||||
s = newParameters;
|
s.curl = curl;
|
||||||
|
s.https = https;
|
||||||
|
if (s.ssh != ssh)
|
||||||
|
s.setPortFlagBySshType();
|
||||||
s.toSettings();
|
s.toSettings();
|
||||||
emit onChanged();
|
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
|
void GerritParameters::toSettings() const
|
||||||
{
|
{
|
||||||
QtcSettings *s = ICore::settings();
|
QtcSettings *s = ICore::settings();
|
||||||
|
|||||||
@@ -12,26 +12,22 @@ namespace Gerrit::Internal {
|
|||||||
class GerritParameters
|
class GerritParameters
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GerritParameters();
|
|
||||||
|
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
bool equals(const GerritParameters &rhs) const;
|
|
||||||
void toSettings() const;
|
void toSettings() const;
|
||||||
void saveQueries() const;
|
void saveQueries() const;
|
||||||
void fromSettings();
|
void fromSettings();
|
||||||
void setPortFlagBySshType();
|
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;
|
GerritServer server;
|
||||||
Utils::FilePath ssh;
|
Utils::FilePath ssh;
|
||||||
Utils::FilePath curl;
|
Utils::FilePath curl;
|
||||||
QStringList savedQueries;
|
QStringList savedQueries;
|
||||||
bool https = true;
|
bool https = true;
|
||||||
QString portFlag;
|
QString portFlag;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend GerritParameters &gerritSettings();
|
||||||
|
GerritParameters();
|
||||||
};
|
};
|
||||||
|
|
||||||
GerritParameters &gerritSettings();
|
GerritParameters &gerritSettings();
|
||||||
|
|||||||
Reference in New Issue
Block a user