Gerrit: Use current top level as default repository

* Remove repository setting
* Disable Gerrit menu entry if there is no top level

Change-Id: Ie3f4ca36ae4e7b350034dea7a0de52382da94e90
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2014-04-02 23:36:16 +03:00
committed by Orgad Shaneh
parent f7db3258b4
commit 0eb363f959
7 changed files with 7 additions and 26 deletions

View File

@@ -197,17 +197,9 @@ QString GerritDialog::repositoryPath() const
return m_repositoryChooser->path();
}
void GerritDialog::displayRepositoryPath()
void GerritDialog::setCurrentPath(const QString &path)
{
QTC_ASSERT(m_parameters, return);
if (m_repositoryChooser->path().isEmpty())
m_repositoryChooser->setPath(m_parameters->repositoryPath);
}
void GerritDialog::showEvent(QShowEvent *event)
{
displayRepositoryPath();
QDialog::showEvent(event);
m_repositoryChooser->setPath(path);
}
QPushButton *GerritDialog::addActionButton(const QString &text, const char *buttonSlot)

View File

@@ -80,6 +80,7 @@ public:
QWidget *parent = 0);
~GerritDialog();
QString repositoryPath() const;
void setCurrentPath(const QString &path);
signals:
void fetchDisplay(const QSharedPointer<Gerrit::Internal::GerritChange> &);
@@ -90,9 +91,6 @@ public slots:
void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
void fetchFinished();
protected:
void showEvent(QShowEvent *event);
private slots:
void slotCurrentChanged();
void slotDoubleClicked(const QModelIndex &);
@@ -101,7 +99,6 @@ private slots:
void slotFetchCherryPick();
void slotFetchCheckout();
void slotRefresh();
void displayRepositoryPath();
private:
const QStandardItem *itemAt(const QModelIndex &i, int column = 0) const;

View File

@@ -89,7 +89,6 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
, m_hostLineEdit(new QLineEdit(this))
, m_userLineEdit(new QLineEdit(this))
, m_sshChooser(new Utils::PathChooser)
, m_repositoryChooser(new Utils::PathChooser)
, m_portSpinBox(new QSpinBox(this))
, m_httpsCheckBox(new QCheckBox(tr("HTTPS")))
{
@@ -101,9 +100,6 @@ GerritOptionsWidget::GerritOptionsWidget(QWidget *parent)
m_sshChooser->setCommandVersionArguments(QStringList(QLatin1String("-V")));
m_sshChooser->setHistoryCompleter(QLatin1String("Git.SshCommand.History"));
formLayout->addRow(tr("&ssh:"), m_sshChooser);
formLayout->addRow(tr("&Repository:"), m_repositoryChooser);
m_repositoryChooser->setToolTip(tr("Default repository where patches will be applied."));
m_repositoryChooser->setHistoryCompleter(QLatin1String("Git.RepoDir.History"));
m_portSpinBox->setMinimum(1);
m_portSpinBox->setMaximum(65535);
formLayout->addRow(tr("&Port:"), m_portSpinBox);
@@ -120,7 +116,6 @@ GerritParameters GerritOptionsWidget::parameters() const
result.host = m_hostLineEdit->text().trimmed();
result.user = m_userLineEdit->text().trimmed();
result.ssh = m_sshChooser->path();
result.repositoryPath = m_repositoryChooser->path();
result.port = m_portSpinBox->value();
result.https = m_httpsCheckBox->isChecked();
return result;
@@ -131,7 +126,6 @@ void GerritOptionsWidget::setParameters(const GerritParameters &p)
m_hostLineEdit->setText(p.host);
m_userLineEdit->setText(p.user);
m_sshChooser->setPath(p.ssh);
m_repositoryChooser->setPath(p.repositoryPath);
m_portSpinBox->setValue(p.port);
m_httpsCheckBox->setChecked(p.https);
}

View File

@@ -61,7 +61,6 @@ private:
QLineEdit *m_hostLineEdit;
QLineEdit *m_userLineEdit;
Utils::PathChooser *m_sshChooser;
Utils::PathChooser *m_repositoryChooser;
QSpinBox *m_portSpinBox;
QCheckBox *m_httpsCheckBox;
};

View File

@@ -50,7 +50,6 @@ static const char userKeyC[] = "User";
static const char portKeyC[] = "Port";
static const char portFlagKeyC[] = "PortFlag";
static const char sshKeyC[] = "Ssh";
static const char repositoryKeyC[] = "RepoPath";
static const char httpsKeyC[] = "Https";
static const char defaultHostC[] = "codereview.qt-project.org";
static const char defaultSshC[] = "ssh";
@@ -120,7 +119,7 @@ QString GerritParameters::sshHostArgument() const
bool GerritParameters::equals(const GerritParameters &rhs) const
{
return port == rhs.port && host == rhs.host && user == rhs.user
&& ssh == rhs.ssh && https == rhs.https && repositoryPath == rhs.repositoryPath;
&& ssh == rhs.ssh && https == rhs.https;
}
void GerritParameters::toSettings(QSettings *s) const
@@ -131,7 +130,6 @@ void GerritParameters::toSettings(QSettings *s) const
s->setValue(QLatin1String(portKeyC), port);
s->setValue(QLatin1String(portFlagKeyC), portFlag);
s->setValue(QLatin1String(sshKeyC), ssh);
s->setValue(QLatin1String(repositoryKeyC), repositoryPath);
s->setValue(QLatin1String(httpsKeyC), https);
s->endGroup();
}
@@ -149,7 +147,6 @@ void GerritParameters::fromSettings(const QSettings *s)
host = s->value(rootKey + QLatin1String(hostKeyC), QLatin1String(defaultHostC)).toString();
user = s->value(rootKey + QLatin1String(userKeyC), QString()).toString();
ssh = s->value(rootKey + QLatin1String(sshKeyC), QString()).toString();
repositoryPath = s->value(rootKey + QLatin1String(repositoryKeyC), QString()).toString();
port = s->value(rootKey + QLatin1String(portKeyC), QVariant(int(defaultPort))).toInt();
portFlag = s->value(rootKey + QLatin1String(portFlagKeyC), QLatin1String(defaultPortFlag)).toString();
savedQueries = s->value(rootKey + QLatin1String(savedQueriesKeyC), QString()).toString()

View File

@@ -55,7 +55,6 @@ public:
unsigned short port;
QString user;
QString ssh;
QString repositoryPath;
QStringList savedQueries;
bool https;
QString portFlag;

View File

@@ -301,6 +301,7 @@ bool GerritPlugin::initialize(ActionContainer *ac)
void GerritPlugin::updateActions(bool hasTopLevel)
{
m_gerritCommand->action()->setEnabled(hasTopLevel);
m_pushToGerritPair.first->setEnabled(hasTopLevel);
}
@@ -377,6 +378,8 @@ void GerritPlugin::openView()
connect(this, SIGNAL(fetchFinished()), gd, SLOT(fetchFinished()));
m_dialog = gd;
}
if (!m_dialog->isVisible())
m_dialog->setCurrentPath(GitPlugin::instance()->currentState().topLevel());
const Qt::WindowStates state = m_dialog->windowState();
if (state & Qt::WindowMinimized)
m_dialog->setWindowState(state & ~Qt::WindowMinimized);