Logo Search packages:      
Sourcecode: qps version File versions

void QtTableView::setOffset ( int  x,
int  y,
bool  updateScrBars = TRUE 
) [protected, virtual]

Scrolls the table so that (x,y) becomes the top-left pixel in the view. Parameters (x,y) are in table coordinates.

The interaction with Tbl_snapTo*Grid is tricky. If updateScrBars is TRUE, the scroll bars are updated.

See also:
xOffset(), yOffset(), setXOffset(), setYOffset(), setTopLeftCell()

Definition at line 472 of file qttableview.C.

References autoUpdate(), cellHeight(), cellWidth(), maxXOffset(), maxYOffset(), scroll(), testTableFlags(), and updateScrollBars().

Referenced by clearTableFlags(), horSbSliding(), horSbValue(), resizeEvent(), setTopLeftCell(), setXOffset(), setYOffset(), updateTableSize(), verSbSliding(), and verSbValue().

{
    if ( (!testTableFlags(Tbl_snapToHGrid) || xCellDelta == 0) &&
       (!testTableFlags(Tbl_snapToVGrid) || yCellDelta == 0) &&
       (x == xOffs && y == yOffs) )
      return;

    if ( x < 0 )
      x = 0;
    if ( y < 0 )
      y = 0;

    if ( cellW ) {
      if ( x > maxXOffset() )
          x = maxXOffset();
      xCellOffs = x / cellW;
      if ( !testTableFlags(Tbl_snapToHGrid) ) {
          xCellDelta    = (short)(x % cellW);
      } else {
          x       = xCellOffs*cellW;
          xCellDelta    = 0;
      }
    } else {
      int xn=0, xcd=0, col = 0;
      while ( col < nCols-1 && x >= xn+(xcd=cellWidth(col)) ) {
          xn += xcd;
          col++;
      }
      xCellOffs = col;
      if ( testTableFlags(Tbl_snapToHGrid) ) {
          xCellDelta = 0;
          x = xn;
      } else {
          xCellDelta = (short)(x-xn);
      }
    }
    if ( cellH ) {
      if ( y > maxYOffset() )
          y = maxYOffset();
      yCellOffs = y / cellH;
      if ( !testTableFlags(Tbl_snapToVGrid) ) {
          yCellDelta    = (short)(y % cellH);
      } else {
          y       = yCellOffs*cellH;
          yCellDelta    = 0;
      }
    } else {
      int yn=0, yrd=0, row=0;
      while ( row < nRows-1 && y >= yn+(yrd=cellHeight(row)) ) {
          yn += yrd;
          row++;
      }
      yCellOffs = row;
      if ( testTableFlags(Tbl_snapToVGrid) ) {
          yCellDelta = 0;
          y = yn;
      } else {
          yCellDelta = (short)(y-yn);
      }
    }
    int dx = (x - xOffs);
    int dy = (y - yOffs);
    xOffs = x;
    yOffs = y;
    if ( autoUpdate() && isVisible() )
      scroll( dx, dy );
    if ( updateScrBars )
      updateScrollBars( verValue | horValue );
}


Generated by  Doxygen 1.6.0   Back to index