]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/qt2/qttableview.C
better selection and scrolling behaviour
[lyx.git] / src / frontends / qt2 / qttableview.C
index c26bd5181dfe0584c6348e05d05e60d10a74f2f3..9cf3eb513596c79414b54ea52091e4bd7ce665a0 100644 (file)
@@ -1,5 +1,5 @@
 /**********************************************************************
-** $Id: qttableview.C,v 1.1 2001/12/01 02:24:27 levon Exp $
+** $Id: qttableview.C,v 1.4 2002/11/04 00:15:54 larsbj Exp $
 **
 ** Implementation of QtTableView class
 **
@@ -12,6 +12,8 @@
 **
 **********************************************************************/
 
+#include <config.h>
+
 #include "qttableview.h"
 #ifndef QT_NO_QTTABLEVIEW
 #include "qscrollbar.h"
@@ -25,7 +27,7 @@
 #endif
 #ifndef Q_ASSERT
 #define Q_ASSERT ASSERT
-#endif 
+#endif
 
 enum ScrollBarDirtyFlags {
     verGeometry          = 0x01,
@@ -1084,8 +1086,8 @@ void QtTableView::coverCornerSquare( bool enable )
        Q_CHECK_PTR( cornerSquare );
        cornerSquare->setGeometry( maxViewX() + frameWidth() + 1,
                                   maxViewY() + frameWidth() + 1,
-                                   VSBEXT,
-                                 HSBEXT);
+                                  VSBEXT,
+                                HSBEXT);
     }
     if ( autoUpdate() && cornerSquare ) {
        if ( enable )
@@ -1289,7 +1291,7 @@ void QtTableView::paintEvent( QPaintEvent *e )
 
     if ( !contentsRect().contains( updateR, TRUE  ) ) {// update frame ?
        drawFrame( &paint );
-       if ( updateR.left() < frameWidth() )            //###
+       if ( updateR.left() < frameWidth() )            //###
            updateR.setLeft( frameWidth() );
        if ( updateR.top() < frameWidth() )
            updateR.setTop( frameWidth() );
@@ -1306,7 +1308,8 @@ void QtTableView::paintEvent( QPaintEvent *e )
 
     int firstRow = findRow( updateR.y() );
     int firstCol = findCol( updateR.x() );
-    int         xStart, yStart;
+    int        xStart;
+    int yStart;
     if ( !colXPos( firstCol, &xStart ) || !rowYPos( firstRow, &yStart ) ) {
        paint.eraseRect( updateR ); // erase area outside cells but in view
        return;
@@ -1316,7 +1319,7 @@ void QtTableView::paintEvent( QPaintEvent *e )
     int          row   = firstRow;
     int          col;
     int          yPos  = yStart;
-    int          xPos = maxX+1; // in case the while() is empty
+    int          xPos = maxX + 1; // in case the while() is empty
     int          nextX;
     int          nextY;
     QRect winR = viewRect();
@@ -1450,7 +1453,7 @@ QScrollBar *QtTableView::verticalScrollBar() const
 #ifndef QT_NO_CURSOR
        sb->setCursor( arrowCursor );
 #endif
-        sb->resize( sb->sizeHint() ); // height is irrelevant
+       sb->resize( sb->sizeHint() ); // height is irrelevant
        Q_CHECK_PTR(sb);
        sb->setTracking( FALSE );
        sb->setFocusPolicy( NoFocus );
@@ -1847,8 +1850,8 @@ int QtTableView::minViewY() const
 int QtTableView::maxViewX() const
 {
     return width() - 1 - frameWidth()
-        - (tFlags & Tbl_vScrollBar ? VSBEXT
-           : 0);
+       - (tFlags & Tbl_vScrollBar ? VSBEXT
+          : 0);
 }
 
 
@@ -1863,8 +1866,8 @@ int QtTableView::maxViewX() const
 int QtTableView::maxViewY() const
 {
     return height() - 1 - frameWidth()
-        - (tFlags & Tbl_hScrollBar ? HSBEXT
-           : 0);
+       - (tFlags & Tbl_hScrollBar ? HSBEXT
+          : 0);
 }
 
 
@@ -1997,8 +2000,8 @@ void QtTableView::updateScrollBars( uint f )
     if ( testTableFlags(Tbl_hScrollBar) && (sbDirty & horMask) != 0 ) {
        if ( sbDirty & horGeometry )
            hScrollBar->setGeometry( 0,height() - HSBEXT,
-                                     viewWidth() + frameWidth()*2,
-                                   HSBEXT);
+                                    viewWidth() + frameWidth()*2,
+                                  HSBEXT);
 
        if ( sbDirty & horSteps ) {
            if ( cellW )
@@ -2021,8 +2024,8 @@ void QtTableView::updateScrollBars( uint f )
     if ( testTableFlags(Tbl_vScrollBar) && (sbDirty & verMask) != 0 ) {
        if ( sbDirty & verGeometry )
            vScrollBar->setGeometry( width() - VSBEXT, 0,
-                                     VSBEXT,
-                                     viewHeight() + frameWidth()*2 );
+                                    VSBEXT,
+                                    viewHeight() + frameWidth()*2 );
 
        if ( sbDirty & verSteps ) {
            if ( cellH )
@@ -2054,16 +2057,16 @@ void QtTableView::updateScrollBars( uint f )
 void QtTableView::updateFrameSize()
 {
     int rw = width()  - ( testTableFlags(Tbl_vScrollBar) ?
-                          VSBEXT : 0 );
+                         VSBEXT : 0 );
     int rh = height() - ( testTableFlags(Tbl_hScrollBar) ?
-                          HSBEXT : 0 );
+                         HSBEXT : 0 );
     if ( rw < 0 )
        rw = 0;
     if ( rh < 0 )
        rh = 0;
 
     if ( autoUpdate() ) {
-        int fh = frameRect().height();
+       int fh = frameRect().height();
        int fw = frameRect().width();
        setFrameRect( QRect(0,0,rw,rh) );
 
@@ -2102,7 +2105,7 @@ int QtTableView::maxXOffset()
                int pos = tw;
                int nextCol = nCols - 1;
                int nextCellWidth = cellWidth( nextCol );
-               while( nextCol > 0 && pos > goal + nextCellWidth ) {
+               while ( nextCol > 0 && pos > goal + nextCellWidth ) {
                    pos -= nextCellWidth;
                    nextCellWidth = cellWidth( --nextCol );
                }
@@ -2148,7 +2151,7 @@ int QtTableView::maxYOffset()
                int pos = th;
                int nextRow = nRows - 1;
                int nextCellHeight = cellHeight( nextRow );
-               while( nextRow > 0 && pos > goal + nextCellHeight ) {
+               while ( nextRow > 0 && pos > goal + nextCellHeight ) {
                    pos -= nextCellHeight;
                    nextCellHeight = cellHeight( --nextRow );
                }