Commit 9fd5c44f authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

Gerrit: Simplify loop in setRemoteBranches



Change-Id: I9f32080c15ca48a2eb9feb1693eabcc1d8f20dd5
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 53b4da93
......@@ -221,22 +221,19 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
bool blocked = m_ui->targetBranchComboBox->blockSignals(true);
m_ui->targetBranchComboBox->clear();
const QString remoteName = selectedRemoteName();
int i = 0;
bool excluded = false;
for (RemoteBranchesMap::const_iterator it = m_remoteBranches.constBegin(),
end = m_remoteBranches.constEnd();
it != end; ++it) {
if (it.key() == selectedRemoteName()) {
const BranchDate &bd = it.value();
const bool isSuggested = bd.first == m_suggestedRemoteBranch;
if (includeOld || bd.second.daysTo(QDate::currentDate()) <= 60 || isSuggested) {
m_ui->targetBranchComboBox->addItem(bd.first);
if (isSuggested)
m_ui->targetBranchComboBox->setCurrentIndex(i);
++i;
} else {
excluded = true;
}
foreach (const BranchDate &bd, m_remoteBranches.values(remoteName)) {
const bool isSuggested = bd.first == m_suggestedRemoteBranch;
if (includeOld || isSuggested || !bd.second.isValid()
|| bd.second.daysTo(QDate::currentDate()) <= 60) {
m_ui->targetBranchComboBox->addItem(bd.first);
if (isSuggested)
m_ui->targetBranchComboBox->setCurrentIndex(i);
++i;
} else {
excluded = true;
}
}
if (excluded)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment