This is an initial attempt. There's a few edge cases I need to deal with, but I just want to be sure I'm on the right track first.
This turned into something way more complicated than I originally thought.
The right/bottom corners will have an empty area where icons should be touching.
I drew a few rectangles in FolderItemDelegate to demonstrate.
With the patch applied:
This creates a real/floating point cellWidth/cellHeight if the column count isn't divisible. If we floor the extraWidth/extraHeight, we'll still have a margin in the below and to the right. If we ceiled it, it would probably cause a scrollbar. I honestly don't trust floating points to not cause a scrollbar anyways though, but we can't set a cellSize for individual cells, so we can't use integers to solve this.