Fix crashes and ghost items when using the filter bar
Instead of using a mutable iterator, loop over a const copy list of the visible items.
This fixes the latest problems with the filter bar and
effectively reverts !85 (merged) but using explicit copy instead
of qAsConst
(see discussion there).
About the bug explicitely, the problem with using an iterator is that we're deleting items from m_visibleItems while iterating, and the iterator ending gets confused in some corner cases, with two bad effects:
- The iterator turns around and goes through some items twice: those indexes get duplicated in itemsToMove, causing crashes in later assertion
- The iterator ends before covering all of the visible items that should be removed: then we get leftover "ghost" items.
Edited by Ismael Asensio