For many years I would randomly see one of my email folders become
unselectable, often my inbox, for no apparent reason. And if it was
actually selected when this happened, then switching to another folder
would select both (not being able to unselect the now-unselectable one),
showing the merged view in the messagelist.
Only apparent solution was a kmail restart.
I finally found what triggered all this: Ctrl+X !
Cut collections were marked as selectable, but not enabled, which
effectively made them unselectable.
New solution: leaving flags untouched in the model, and simply changing
the text color in the delegate, for cut collections.
This makes cut collections still fully work, just like you can fully
interact with cut files in a file manager.
I wonder if we want to do the same with cut items, but I'm not sure where
the delegate(s) are, and how to catch them all. The risk of accidentally
cutting is much lower with items anyway (Ctrl+Alt+X).
Also, this code came from the fix for bug 213466, which was about items
in the first place (not collections).