| 1105 | */ |
| 1106 | |
| 1107 | void QtTableView::snapToGrid( bool horizontal, bool vertical ) |
| 1108 | { |
| 1109 | int newXCell = -1; |
| 1110 | int newYCell = -1; |
| 1111 | if ( horizontal && xCellDelta != 0 ) { |
| 1112 | int w = cellW ? cellW : cellWidth( xCellOffs ); |
| 1113 | if ( xCellDelta >= w/2 ) |
| 1114 | newXCell = xCellOffs + 1; |
| 1115 | else |
| 1116 | newXCell = xCellOffs; |
| 1117 | } |
| 1118 | if ( vertical && yCellDelta != 0 ) { |
| 1119 | int h = cellH ? cellH : cellHeight( yCellOffs ); |
| 1120 | if ( yCellDelta >= h/2 ) |
| 1121 | newYCell = yCellOffs + 1; |
| 1122 | else |
| 1123 | newYCell = yCellOffs; |
| 1124 | } |
| 1125 | setTopLeftCell( newYCell, newXCell ); //row,column |
| 1126 | } |
| 1127 | |
| 1128 | /*! |
| 1129 | \internal |
nothing calls this directly
no outgoing calls
no test coverage detected