Gerrit: Polish push to gerrit dialog

Make the UI a bit nicer and simplify the code to find remotes.

Task-number: QTCREATORBUG-13718
Change-Id: I3b973fee30061232188c9aed3ad95abc8f8f095d
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Tobias Hunger
2015-02-04 17:20:14 +01:00
committed by Orgad Shaneh
parent 98ccd012af
commit 4caee9fcbf
2 changed files with 159 additions and 162 deletions

View File

@@ -121,15 +121,7 @@ void GerritPushDialog::initRemoteBranches()
QStringList remotes = m_remoteBranches.keys();
remotes.removeDuplicates();
m_ui->remoteComboBox->addItems(remotes);
const int remoteCount = m_ui->remoteComboBox->count();
if (remoteCount < 1) {
return;
} else if (remoteCount == 1) {
m_ui->remoteLabel->hide();
m_ui->remoteComboBox->hide();
} else {
connect(m_ui->remoteComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setRemoteBranches()));
}
m_ui->remoteComboBox->setEnabled(remotes.count() > 1);
}
GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent) :
@@ -141,8 +133,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
m_client = GitPlugin::instance()->gitClient();
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
m_ui->setupUi(this);
m_ui->repositoryLabel->setText(tr("<b>Local repository:</b> %1").arg(
QDir::toNativeSeparators(workingDir)));
m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir));
PushItemDelegate *delegate = new PushItemDelegate(m_ui->commitView);
delegate->setParent(this);
@@ -153,10 +144,11 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
return;
m_ui->localBranchComboBox->init(workingDir);
connect(m_ui->localBranchComboBox, SIGNAL(currentIndexChanged(int)),
this, SLOT(updateCommits(int)));
connect(m_ui->localBranchComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &GerritPushDialog::updateCommits);
connect(m_ui->targetBranchComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setChangeRange()));
connect(m_ui->targetBranchComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &GerritPushDialog::setChangeRange);
updateCommits(m_ui->localBranchComboBox->currentIndex());
setRemoteBranches();
@@ -166,6 +158,9 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev
m_ui->reviewersLineEdit->setValidator(noSpaceValidator);
m_ui->topicLineEdit->setValidator(noSpaceValidator);
connect(m_ui->remoteComboBox, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
this, &GerritPushDialog::setRemoteBranches);
m_isValid = true;
}