Gerrit: Simplify loop in setRemoteBranches

Change-Id: I9f32080c15ca48a2eb9feb1693eabcc1d8f20dd5
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-02-12 15:07:48 +02:00
committed by Orgad Shaneh
parent 53b4da93a2
commit 9fd5c44f4b

View File

@@ -221,22 +221,19 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
bool blocked = m_ui->targetBranchComboBox->blockSignals(true); bool blocked = m_ui->targetBranchComboBox->blockSignals(true);
m_ui->targetBranchComboBox->clear(); m_ui->targetBranchComboBox->clear();
const QString remoteName = selectedRemoteName();
int i = 0; int i = 0;
bool excluded = false; bool excluded = false;
for (RemoteBranchesMap::const_iterator it = m_remoteBranches.constBegin(), foreach (const BranchDate &bd, m_remoteBranches.values(remoteName)) {
end = m_remoteBranches.constEnd(); const bool isSuggested = bd.first == m_suggestedRemoteBranch;
it != end; ++it) { if (includeOld || isSuggested || !bd.second.isValid()
if (it.key() == selectedRemoteName()) { || bd.second.daysTo(QDate::currentDate()) <= 60) {
const BranchDate &bd = it.value(); m_ui->targetBranchComboBox->addItem(bd.first);
const bool isSuggested = bd.first == m_suggestedRemoteBranch; if (isSuggested)
if (includeOld || bd.second.daysTo(QDate::currentDate()) <= 60 || isSuggested) { m_ui->targetBranchComboBox->setCurrentIndex(i);
m_ui->targetBranchComboBox->addItem(bd.first); ++i;
if (isSuggested) } else {
m_ui->targetBranchComboBox->setCurrentIndex(i); excluded = true;
++i;
} else {
excluded = true;
}
} }
} }
if (excluded) if (excluded)