Gerrit: Add a button for server revalidation

Change-Id: I0ef823aa562093e5e3d63bc2766ab1a95ae259d5
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
This commit is contained in:
Orgad Shaneh
2017-03-13 17:17:40 +02:00
committed by Orgad Shaneh
parent c1d013437f
commit db16f265c9
5 changed files with 21 additions and 6 deletions

View File

@@ -37,6 +37,7 @@
#include <utils/hostosinfo.h>
#include <utils/progressindicator.h>
#include <utils/qtcassert.h>
#include <utils/utilsicons.h>
#include <utils/theme/theme.h>
#include <QCompleter>
@@ -110,6 +111,10 @@ GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
connect(m_ui->treeView, &QAbstractItemView::activated,
this, &GerritDialog::slotActivated);
m_ui->resetRemoteButton->setIcon(Utils::Icons::RESET_TOOLBAR.icon());
connect(m_ui->resetRemoteButton, &QToolButton::clicked,
this, [this] { updateRemotes(true); });
m_displayButton = addActionButton(tr("&Show"), [this]() { slotFetchDisplay(); });
m_cherryPickButton = addActionButton(tr("Cherry &Pick"), [this]() { slotFetchCherryPick(); });
m_checkoutButton = addActionButton(tr("C&heckout"), [this]() { slotFetchCheckout(); });
@@ -225,7 +230,7 @@ void GerritDialog::remoteChanged()
slotRefresh();
}
void GerritDialog::updateRemotes()
void GerritDialog::updateRemotes(bool forceReload)
{
m_ui->remoteComboBox->clear();
if (m_repository.isEmpty() || !QFileInfo(m_repository).isDir())
@@ -239,7 +244,7 @@ void GerritDialog::updateRemotes()
while (mapIt.hasNext()) {
mapIt.next();
GerritServer server;
if (!server.fillFromRemote(mapIt.value(), *m_parameters))
if (!server.fillFromRemote(mapIt.value(), *m_parameters, forceReload))
continue;
addRemote(server, mapIt.key());
}

View File

@@ -76,7 +76,7 @@ private:
void slotFetchCheckout();
void slotRefresh();
void remoteChanged();
void updateRemotes();
void updateRemotes(bool forceReload = false);
void addRemote(const GerritServer &server, const QString &name);
void manageProgressIndicator();

View File

@@ -65,6 +65,13 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="resetRemoteButton">
<property name="toolTip">
<string>Refresh Remote Servers</string>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -118,7 +118,9 @@ QString GerritServer::url(UrlType urlType) const
return res;
}
bool GerritServer::fillFromRemote(const QString &remote, const GerritParameters &parameters)
bool GerritServer::fillFromRemote(const QString &remote,
const GerritParameters &parameters,
bool forceReload)
{
const GitRemote r(remote);
if (!r.isValid)
@@ -143,7 +145,8 @@ bool GerritServer::fillFromRemote(const QString &remote, const GerritParameters
curlBinary = parameters.curl;
if (curlBinary.isEmpty() || !QFile::exists(curlBinary))
return false;
switch (loadSettings()) {
const StoredHostValidity validity = forceReload ? Invalid : loadSettings();
switch (validity) {
case Invalid:
rootPath = r.path;
// Strip the last part of the path, which is always the repo name

View File

@@ -74,7 +74,7 @@ public:
static QString defaultHost();
QString hostArgument() const;
QString url(UrlType urlType = DefaultUrl) const;
bool fillFromRemote(const QString &remote, const GerritParameters &parameters);
bool fillFromRemote(const QString &remote, const GerritParameters &parameters, bool forceReload);
StoredHostValidity loadSettings();
void saveSettings(StoredHostValidity validity) const;
int testConnection();