Port away from foreach
Reviewers: Plasma, bshah, dvratil
Reviewed By: Plasma, bshah
Differential Revision: https://phabricator.kde.org/D24218