Skip to content

Commit 5e058e7

Browse files
author
Philip Kaufmann
committed
[Qt] constify foreach uses where possible
- this doesn't replace BOOST_FOREACH, it just makes used arguments const where possible
1 parent d0a10c1 commit 5e058e7

File tree

4 files changed

+9
-14
lines changed

4 files changed

+9
-14
lines changed

src/qt/addressbookpage.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,7 @@ void AddressBookPage::done(int retval)
254254
// Figure out which address was selected, and return it
255255
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);
256256

257-
foreach (QModelIndex index, indexes)
258-
{
257+
foreach (const QModelIndex& index, indexes) {
259258
QVariant address = table->model()->data(index);
260259
returnValue = address.toString();
261260
}

src/qt/clientmodel.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int ClientModel::getNumConnections(unsigned int flags) const
5353
return vNodes.size();
5454

5555
int nNum = 0;
56-
BOOST_FOREACH(CNode* pnode, vNodes)
57-
if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
58-
nNum++;
56+
BOOST_FOREACH(const CNode* pnode, vNodes)
57+
if (flags & (pnode->fInbound ? CONNECTIONS_IN : CONNECTIONS_OUT))
58+
nNum++;
5959

6060
return nNum;
6161
}

src/qt/coincontroldialog.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
118118
// (un)select all
119119
connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked()));
120120

121-
// change coin control first column label due Qt4 bug.
121+
// change coin control first column label due Qt4 bug.
122122
// see https://github.com/bitcoin/bitcoin/issues/5716
123123
ui->treeWidget->headerItem()->setText(COLUMN_CHECKBOX, QString());
124124

@@ -492,8 +492,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
492492
coinControl->ListSelected(vCoinControl);
493493
model->getOutputs(vCoinControl, vOutputs);
494494

495-
BOOST_FOREACH(const COutput& out, vOutputs)
496-
{
495+
BOOST_FOREACH(const COutput& out, vOutputs) {
497496
// unselect already spent, very unlikely scenario, this could happen
498497
// when selected are spent elsewhere, like rpc or another computer
499498
uint256 txhash = out.tx->GetHash();
@@ -691,8 +690,7 @@ void CoinControlDialog::updateView()
691690
map<QString, vector<COutput> > mapCoins;
692691
model->listCoins(mapCoins);
693692

694-
BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins)
695-
{
693+
BOOST_FOREACH(const PAIRTYPE(QString, vector<COutput>)& coins, mapCoins) {
696694
QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem();
697695
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
698696
QString sWalletAddress = coins.first;
@@ -719,8 +717,7 @@ void CoinControlDialog::updateView()
719717
double dPrioritySum = 0;
720718
int nChildren = 0;
721719
int nInputSum = 0;
722-
BOOST_FOREACH(const COutput& out, coins.second)
723-
{
720+
BOOST_FOREACH(const COutput& out, coins.second) {
724721
int nInputSize = 0;
725722
nSum += out.tx->vout[out.i].nValue;
726723
nChildren++;

src/qt/receivecoinsdialog.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,7 @@ void ReceiveCoinsDialog::on_showRequestButton_clicked()
185185
return;
186186
QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();
187187

188-
foreach (QModelIndex index, selection)
189-
{
188+
foreach (const QModelIndex& index, selection) {
190189
on_recentRequestsView_doubleClicked(index);
191190
}
192191
}

0 commit comments

Comments
 (0)