Get rid of Q_FOREACH
ClosedPublic

Authored by tbaumgart on Dec 4 2017, 8:22 PM.

Details

Summary

Get rid of a Q_FOREACH usage in the new ledger view

Test Plan

Compile, run tests, use new ledger view, check balances on transactions

Diff Detail

Repository
R261 KMyMoney
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
tbaumgart requested review of this revision.Dec 4 2017, 8:22 PM
tbaumgart created this revision.
tbaumgart updated this revision to Diff 23468.Dec 4 2017, 8:41 PM

Improve indentation

broulik added a subscriber: broulik.Dec 5 2017, 1:04 PM

You probably want to be porting to range-based for loop for (foo : bar) instead. Why all these unrelated auto changes?

kmymoney/views/ledgerview.cpp
77

Make indexes const and then do

for (const auto &index : indexes) {
wojnilowicz accepted this revision.Dec 5 2017, 3:20 PM
wojnilowicz added inline comments.
kmymoney/views/ledgerview.cpp
77

foreach and Q_FOREACH are essentially the same but written the other way. It's possible to do here as broulik says, because it'll save us porting effort in very distant future.
It's even better to replace
indexes
variable with
filterModel->match(start, (int)eLedgerModel::Role::AccountId, account.id(), -1)
in loop, as container here has const size.
It's all up to you, becasue it seems as cosmetic change to me.

This revision is now accepted and ready to land.Dec 5 2017, 3:20 PM
tbaumgart updated this revision to Diff 23515.Dec 5 2017, 3:23 PM

Use range-based for loop instead of foreach

This revision was automatically updated to reflect the committed changes.