At the moment selecting cells doesn't really work as noted in #4277, but that is just because a drag selection gets canceled if the cursor goes within 5 pixels of any corner of any cell.
But when cell selection does work, I think that the current solution of using the TableView's Model and ModelIndexes to select cells has some issues in its natural state as Model selection doesn't conform to the cell selection rules. For example, if you hold control and draw a circle in Spreadsheet, everything within the circle will be selected, rather than just a rectangle from where the selection started and where the mouse currently is.
There will also be issues in the future when we can't tell where one selection ends and another selection begins. For example, when implementing the ability to extend selections we have to set the cursor to a crosshair when the cursor is close to the bottom right of a selection block, which will be difficult if selections are just a HashTable of Positions and there could be multiple selections in that HashTable. The same goes for dragging a selection to move its contents elsewhere.
I have created a Range class which is just a start and end position (start is always top-left of the selection, and end is always the bottom-right). Each Sheet simply has HashTable of Ranges, it is very easy to check that a Position or ModelIndex is selected. I am having some issues with the TableCellPainter's paint() method not getting called by the TableView's mousedown and mouseup events. I'm also not sure what internal functions may be broken by not using the builtin ModelSelection system, if there are any problems both systems could be run simultaneously.
@alimpfard Let me know what you think of the idea.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too