Skip to content

Commit

Permalink
[Qt] constify foreach uses where possible
Browse files Browse the repository at this point in the history
- this doesn't replace BOOST_FOREACH, it just makes used arguments const
  where possible
  • Loading branch information
Philip Kaufmann committed Jul 7, 2015
1 parent d0a10c1 commit 5e058e7
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/qt/addressbookpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,7 @@ void AddressBookPage::done(int retval)
// Figure out which address was selected, and return it
QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address);

foreach (QModelIndex index, indexes)
{
foreach (const QModelIndex& index, indexes) {
QVariant address = table->model()->data(index);
returnValue = address.toString();
}
Expand Down
6 changes: 3 additions & 3 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ int ClientModel::getNumConnections(unsigned int flags) const
return vNodes.size();

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

return nNum;
}
Expand Down
11 changes: 4 additions & 7 deletions src/qt/coincontroldialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) :
// (un)select all
connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked()));

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

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

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

BOOST_FOREACH(PAIRTYPE(QString, vector<COutput>) coins, mapCoins)
{
BOOST_FOREACH(const PAIRTYPE(QString, vector<COutput>)& coins, mapCoins) {
QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem();
itemWalletAddress->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked);
QString sWalletAddress = coins.first;
Expand All @@ -719,8 +717,7 @@ void CoinControlDialog::updateView()
double dPrioritySum = 0;
int nChildren = 0;
int nInputSum = 0;
BOOST_FOREACH(const COutput& out, coins.second)
{
BOOST_FOREACH(const COutput& out, coins.second) {
int nInputSize = 0;
nSum += out.tx->vout[out.i].nValue;
nChildren++;
Expand Down
3 changes: 1 addition & 2 deletions src/qt/receivecoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,7 @@ void ReceiveCoinsDialog::on_showRequestButton_clicked()
return;
QModelIndexList selection = ui->recentRequestsView->selectionModel()->selectedRows();

foreach (QModelIndex index, selection)
{
foreach (const QModelIndex& index, selection) {
on_recentRequestsView_doubleClicked(index);
}
}
Expand Down

0 comments on commit 5e058e7

Please sign in to comment.