MCPcopy Create free account
hub / github.com/NetHack/NetHack / snapToGrid

Method snapToGrid

outdated/win/Qt3/qt3tableview.cpp:1107–1126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1105*/
1106
1107void 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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected