Fix bug 434513: Item not selected after creating it
Fix bug 434513 where a newly created item on the desktop is not selected right after creating it like in Dolphin. My fix also changed the moving behavior slightly: Before my fix, when icons are moved they get deselected automatically when dropped. This behavior was weird in my opinion and also diverges from the behavior of Dolphin. Now when items are dropped they stay selected which is also the case in Dolphin (when dropping files from somewhere else).
Also whenever the internal selection model of the foldermodel gets changed a signal is emitted, which causes the currentIndex of the gridview to be updated (if the folderview is a containment). This prevents bugs where the visual selection (the internal selection model of foldermodel) and the real currentIndex of the gridview go out of sync.
This new behaviour also fixes a bug where hitting escape to deselect all selected items cleared the visual selection but did not reset the currentIndex. So after hitting espace one still could rename a file with F2 for example.
I also tried to fix an other bug in my second commit: Sometimes the selection frame around a item is visible twice. I also saw this bug before my fix, but my fix made it way more likely to appear. Whenever an item with a long name that wraps is moved to another position on the desktop, this bug appears. I'm still not exactly sure why this bug happens. The loader which loads the frame was only active when the state wasn't any of "hovered", "selected", "selected and hovered". When just leaving the active property as true, the bug disappears. But this is not an optimal solution as the frame of every item is now loaded at any time (why use an Loader if it is always activated anyway?). So this solution is still not optimal and I couldn't figure out why at the end there are always two instances of the frame loaded. If anyone has an idea why this happens or how this problem could be solved otherwise, that would be greatly appreciated.
The moving/positioning/selecting code in general feels kind of error prone. Maybe it would be good to find a new system here in future that is more maintainable.