Replace foreach with ranged for and set QT_NO_FOREACH


Make containers const where they obviously should be, iterate over
references where it's clearly possible.

Cherry-pick of 2c8c5dca44aba5612cc67b04dd3c7e5fc4919b19.

Change-Id: Ie55a58873b48bbb60ac49790db612f85777e6ceb
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
commitda870b829cc860ca394af836733dbcc002016061
parent7c00aa7aa1476fc45adc5abf54185545ecc4c14e
authorVolker Hilsheimer <volker.hilsheimer@qt.io>
committerVolker Hilsheimer <volker.hilsheimer@qt.io>
commit timeTue, 26 Jul 2022 08:34:51 +0000