Abdelrazak Younes a écrit :
I see that qttableview in current lyx code is exactly the same as the one in my local Qt3Win tree except for the include of <config.h> and the test on HAVE_LIMITS_H. This change was done at revision 9876 by Angus with the following log:

Consistent use of preprocessor guards;
include <config.h> in .C files, not .h ones;
licence blurb.

This class was supposed to be obsoleted after Qt3.0 but I see that it is in my Qt3Win tree. Is it also there on the official Qt3 distribution? If yes, we should just use it and remove the copy from src/frontends/qt3/

This is yes apparently but as stated in <http://doc.trolltech.com/3.3/porting.html#20> the class is probably not compiled in the library.

By the way, there is not any explanation as to why testing for HAVE_LIMITS_H have been introduced in svn history. I think it is again a gettext need. I guess it is OK if I revert qttableview to the official version without the macro test, isn't it?

The following patch do so and removes limits.h from pch.h (they are just a bunch of macro anyway so there is _no_ need to precompile it).

Abdel.
Index: moc/pch.h
===================================================================
--- moc/pch.h   (revision 13796)
+++ moc/pch.h   (working copy)
@@ -15,9 +15,6 @@
 #include <algorithm>
 #include <cmath>
 #include <iomanip>
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
 #include <map>
 #include <sstream>
 #include <stack>
Index: pch.h
===================================================================
--- pch.h       (revision 13796)
+++ pch.h       (working copy)
@@ -15,9 +15,6 @@
 #include <algorithm>
 #include <cmath>
 #include <iomanip>
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
 #include <map>
 #include <sstream>
 #include <stack>
Index: qttableview.C
===================================================================
--- qttableview.C       (revision 13796)
+++ qttableview.C       (working copy)
@@ -1,36 +1,24 @@
 /**********************************************************************
-** $Id: qttableview.C,v 1.7 2005/04/26 10:30:22 leeming Exp $
+** $Id: qttableview.cpp,v 1.1.1.9 2005/09/22 12:53:59 chehrlic Exp $
 **
 ** Implementation of QtTableView class
 **
 ** Created : 941115
 **
-** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
+** Copyright (C) 1992-2005 Trolltech AS.  All rights reserved.
 **
 ** This file contains a class moved out of the Qt GUI Toolkit API. It
 ** may be used, distributed and modified without limitation.
 **
 **********************************************************************/
 
-#include <config.h>
-
 #include "qttableview.h"
 #ifndef QT_NO_QTTABLEVIEW
 #include "qscrollbar.h"
 #include "qpainter.h"
+#include "qdrawutil.h"
+#include <limits.h>
 
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
-
-/* Added by J. Levon for compilation with Qt 2.3.1 */
-#ifndef Q_CHECK_PTR
-#define Q_CHECK_PTR CHECK_PTR
-#endif
-#ifndef Q_ASSERT
-#define Q_ASSERT ASSERT
-#endif
-
 enum ScrollBarDirtyFlags {
     verGeometry          = 0x01,
     verSteps     = 0x02,
@@ -67,7 +55,7 @@
 
 
 // NOT REVISED
-/*!
+/*
   \class QtTableView qttableview.h
   \brief The QtTableView class provides an abstract base for tables.
 
@@ -135,7 +123,7 @@
 */
 
 
-/*!
+/*
   Constructs a table view.  The \a parent, \a name and \f arguments
   are passed to the QFrame constructor.
 
@@ -176,7 +164,7 @@
     inSbUpdate          = FALSE;
 }
 
-/*!
+/*
   Destroys the table view.
 */
 
@@ -188,7 +176,7 @@
 }
 
 
-/*!
+/*
   \internal
   Reimplements QWidget::setBackgroundColor() for binary compatibility.
   \sa setPalette()
@@ -199,7 +187,7 @@
     QWidget::setBackgroundColor( c );
 }
 
-/*!\reimp
+/*\reimp
 */
 
 void QtTableView::setPalette( const QPalette &p )
@@ -207,7 +195,7 @@
     QWidget::setPalette( p );
 }
 
-/*!\reimp
+/*\reimp
 */
 
 void QtTableView::show()
@@ -217,12 +205,12 @@
 }
 
 
-/*!
+/*
   \overload void QtTableView::repaint( bool erase )
   Repaints the entire view.
 */
 
-/*!
+/*
   Repaints the table view directly by calling paintEvent() directly
   unless updates are disabled.
 
@@ -259,20 +247,20 @@
     eraseInPaint = FALSE;
 }
 
-/*!
+/*
   \overload void QtTableView::repaint( const QRect &r, bool erase )
   Replaints rectangle \a r. If \a erase is TRUE draws the background
   using the palette's background.
 */
 
 
-/*!
+/*
   \fn int QtTableView::numRows() const
   Returns the number of rows in the table.
   \sa numCols(), setNumRows()
 */
 
-/*!
+/*
   Sets the number of rows of the table to \a rows (must be non-negative).
   Does not change topCell().
 
@@ -308,13 +296,13 @@
     updateFrameSize();
 }
 
-/*!
+/*
   \fn int QtTableView::numCols() const
   Returns the number of columns in the table.
   \sa numRows(), setNumCols()
 */
 
-/*!
+/*
   Sets the number of columns of the table to \a cols (must be non-negative).
   Does not change leftCell().
 
@@ -346,14 +334,14 @@
 }
 
 
-/*!
+/*
   \fn int QtTableView::topCell() const
   Returns the index of the first row in the table that is visible in
   the view.  The index of the first row is 0.
   \sa leftCell(), setTopCell()
 */
 
-/*!
+/*
   Scrolls the table so that \a row becomes the top row.
   The index of the very first row is 0.
   \sa setYOffset(), setTopLeftCell(), setLeftCell()
@@ -365,14 +353,14 @@
     return;
 }
 
-/*!
+/*
   \fn int QtTableView::leftCell() const
   Returns the index of the first column in the table that is visible in
   the view.  The index of the very leftmost column is 0.
   \sa topCell(), setLeftCell()
 */
 
-/*!
+/*
   Scrolls the table so that \a col becomes the leftmost
   column.  The index of the leftmost column is 0.
   \sa setXOffset(), setTopLeftCell(), setTopCell()
@@ -384,7 +372,7 @@
     return;
 }
 
-/*!
+/*
   Scrolls the table so that the cell at row \a row and colum \a
   col becomes the top-left cell in the view.  The cell at the extreme
   top left of the table is at position (0,0).
@@ -422,7 +410,7 @@
 }
 
 
-/*!
+/*
   \fn int QtTableView::xOffset() const
 
   Returns the x coordinate in \e table coordinates of the pixel that is
@@ -430,7 +418,7 @@
 
   \sa setXOffset(), yOffset(), leftCell() */
 
-/*!
+/*
   Scrolls the table so that \a x becomes the leftmost pixel in the view.
   The \a x parameter is in \e table coordinates.
 
@@ -445,7 +433,7 @@
     setOffset( x, yOffset() );
 }
 
-/*!
+/*
   \fn int QtTableView::yOffset() const
 
   Returns the y coordinate in \e table coordinates of the pixel that is
@@ -455,7 +443,7 @@
 */
 
 
-/*!
+/*
   Scrolls the table so that \a y becomes the top pixel in the view.
   The \a y parameter is in \e table coordinates.
 
@@ -470,7 +458,7 @@
     setOffset( xOffset(), y );
 }
 
-/*!
+/*
   Scrolls the table so that \a (x,y) becomes the top-left pixel
   in the view. Parameters \a (x,y) are in \e table coordinates.
 
@@ -552,7 +540,7 @@
 }
 
 
-/*!
+/*
   \overload int QtTableView::cellWidth() const
 
   Returns the column width in pixels.  Returns 0 if the columns have
@@ -561,7 +549,7 @@
   \sa setCellWidth(), cellHeight()
 */
 
-/*!
+/*
   Returns the width of column \a col in pixels.
 
   This function is virtual and must be reimplemented by subclasses that
@@ -577,7 +565,7 @@
 }
 
 
-/*!
+/*
   Sets the width in pixels of the table cells to \a cellWidth.
 
   Setting it to 0 means that the column width is variable.  When
@@ -606,7 +594,7 @@
 
 }
 
-/*!
+/*
   \overload int QtTableView::cellHeight() const
 
   Returns the row height, in pixels.  Returns 0 if the rows have
@@ -616,7 +604,7 @@
 */
 
 
-/*!
+/*
   Returns the height of row \a row in pixels.
 
   This function is virtual and must be reimplemented by subclasses that
@@ -631,7 +619,7 @@
     return cellH;
 }
 
-/*!
+/*
   Sets the height in pixels of the table cells to \a cellHeight.
 
   Setting it to 0 means that the row height is variable.  When set
@@ -659,7 +647,7 @@
 }
 
 
-/*!
+/*
   Returns the total width of the table in pixels.
 
   This function is virtual and should be reimplemented by subclasses that
@@ -682,7 +670,7 @@
     }
 }
 
-/*!
+/*
   Returns the total height of the table in pixels.
 
   This function is virtual and should be reimplemented by subclasses that
@@ -707,7 +695,7 @@
 }
 
 
-/*!
+/*
   \fn uint QtTableView::tableFlags() const
 
   Returns the union of the table flags that are currently set.
@@ -715,7 +703,7 @@
   \sa setTableFlags(), clearTableFlags(), testTableFlags()
 */
 
-/*!
+/*
   \fn bool QtTableView::testTableFlags( uint f ) const
 
   Returns TRUE if any of the table flags in \a f are currently set,
@@ -724,7 +712,7 @@
   \sa setTableFlags(), clearTableFlags(), tableFlags()
 */
 
-/*!
+/*
   Sets the table flags to \a f.
 
   If a flag setting changes the appearance of the table, the table is
@@ -841,7 +829,7 @@
 
 }
 
-/*!
+/*
   Clears the \link setTableFlags() table flags\endlink that are set
   in \a f.
 
@@ -911,7 +899,7 @@
 }
 
 
-/*!
+/*
   \fn bool QtTableView::autoUpdate() const
 
   Returns TRUE if the view updates itself automatically whenever it
@@ -920,7 +908,7 @@
   \sa setAutoUpdate()
 */
 
-/*!
+/*
   Sets the auto-update option of the table view to \a enable.
 
   If \a enable is TRUE (this is the default), the view updates itself
@@ -955,7 +943,7 @@
 }
 
 
-/*!
+/*
   Repaints the cell at row \a row, column \a col if it is inside the view.
 
   If \a erase is TRUE, the relevant part of the view is cleared to the
@@ -978,7 +966,7 @@
 }
 
 
-/*!
+/*
   \fn QRect QtTableView::cellUpdateRect() const
 
   This function should be called only from the paintCell() function in
@@ -988,7 +976,7 @@
 
 */
 
-/*!
+/*
   Returns the rectangle that is the actual table, excluding any
   frame, in \e widget coordinates.
 */
@@ -999,7 +987,7 @@
 }
 
 
-/*!
+/*
   Returns the index of the last (bottom) row in the view.
   The index of the first row is 0.
 
@@ -1026,7 +1014,7 @@
     return row;
 }
 
-/*!
+/*
   Returns the index of the last (right) column in the view.
   The index of the first column is 0.
 
@@ -1053,7 +1041,7 @@
     return col;
 }
 
-/*!
+/*
   Returns TRUE if \a row is at least partially visible.
   \sa colIsVisible()
 */
@@ -1063,7 +1051,7 @@
     return rowYPos( row, 0 );
 }
 
-/*!
+/*
   Returns TRUE if \a col is at least partially visible.
   \sa rowIsVisible()
 */
@@ -1074,7 +1062,7 @@
 }
 
 
-/*!
+/*
   \internal
   Called when both scroll bars are active at the same time. Covers the
   bottom left corner between the two scroll bars with an empty widget.
@@ -1088,8 +1076,8 @@
        Q_CHECK_PTR( cornerSquare );
        cornerSquare->setGeometry( maxViewX() + frameWidth() + 1,
                                   maxViewY() + frameWidth() + 1,
-                                  VSBEXT,
-                                HSBEXT);
+                                   VSBEXT,
+                                 HSBEXT);
     }
     if ( autoUpdate() && cornerSquare ) {
        if ( enable )
@@ -1100,7 +1088,7 @@
 }
 
 
-/*!
+/*
   \internal
   Scroll the view to a position such that:
 
@@ -1135,7 +1123,7 @@
     setTopLeftCell( newYCell, newXCell );  //row,column
 }
 
-/*!
+/*
   \internal
   This internal slot is connected to the horizontal scroll bar's
   QScrollBar::valueChanged() signal.
@@ -1156,7 +1144,7 @@
     setOffset( val, yOffs, FALSE );
 }
 
-/*!
+/*
   \internal
   This internal slot is connected to the horizontal scroll bar's
   QScrollBar::sliderMoved() signal.
@@ -1176,7 +1164,7 @@
     }
 }
 
-/*!
+/*
   \internal
   This internal slot is connected to the horizontal scroll bar's
   QScrollBar::sliderReleased() signal.
@@ -1189,7 +1177,7 @@
        snapToGrid( TRUE, FALSE );
 }
 
-/*!
+/*
   \internal
   This internal slot is connected to the vertical scroll bar's
   QScrollBar::valueChanged() signal.
@@ -1210,7 +1198,7 @@
     setOffset( xOffs, val, FALSE );
 }
 
-/*!
+/*
   \internal
   This internal slot is connected to the vertical scroll bar's
   QScrollBar::sliderMoved() signal.
@@ -1230,7 +1218,7 @@
     }
 }
 
-/*!
+/*
   \internal
   This internal slot is connected to the vertical scroll bar's
   QScrollBar::sliderReleased() signal.
@@ -1244,7 +1232,7 @@
 }
 
 
-/*!
+/*
   This virtual function is called before painting of table cells
   is started. It can be reimplemented by subclasses that want to
   to set up the painter in a special way and that do not want to
@@ -1255,7 +1243,7 @@
 {
 }
 
-/*!
+/*
   \fn void QtTableView::paintCell( QPainter *p, int row, int col )
 
   This pure virtual function is called to paint the single cell at \a
@@ -1274,7 +1262,7 @@
   \sa paintEvent(), setTableFlags() */
 
 
-/*!
+/*
   Handles paint events, \a e, for the table view.
 
   Calls paintCell() for the cells that needs to be repainted.
@@ -1293,7 +1281,7 @@
 
     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() );
@@ -1310,8 +1298,7 @@
 
     int firstRow = findRow( updateR.y() );
     int firstCol = findCol( updateR.x() );
-    int        xStart;
-    int yStart;
+    int         xStart, yStart;
     if ( !colXPos( firstCol, &xStart ) || !rowYPos( firstRow, &yStart ) ) {
        paint.eraseRect( updateR ); // erase area outside cells but in view
        return;
@@ -1321,7 +1308,7 @@
     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();
@@ -1418,7 +1405,7 @@
     }
 }
 
-/*!\reimp
+/*\reimp
 */
 void QtTableView::resizeEvent( QResizeEvent * )
 {
@@ -1432,7 +1419,7 @@
 }
 
 
-/*!
+/*
   Redraws all visible cells in the table view.
 */
 
@@ -1441,7 +1428,7 @@
     repaint( viewRect() );
 }
 
-/*!
+/*
   Returns a pointer to the vertical scroll bar mainly so you can
   connect() to its signals.  Note that the scroll bar works in pixel
   values; use findRow() to translate to cell numbers.
@@ -1455,7 +1442,7 @@
 #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 );
@@ -1472,7 +1459,7 @@
     return vScrollBar;
 }
 
-/*!
+/*
   Returns a pointer to the horizontal scroll bar mainly so you can
   connect() to its signals. Note that the scroll bar works in pixel
   values; use findCol() to translate to cell numbers.
@@ -1503,7 +1490,7 @@
     return hScrollBar;
 }
 
-/*!
+/*
   Enables or disables the horizontal scroll bar, as required by
   setAutoUpdate() and the \link setTableFlags() table flags\endlink.
 */
@@ -1542,7 +1529,7 @@
 }
 
 
-/*!
+/*
   Enables or disables the vertical scroll bar, as required by
   setAutoUpdate() and the \link setTableFlags() table flags\endlink.
 */
@@ -1676,7 +1663,7 @@
 }
 
 
-/*!
+/*
   Returns the index of the row at position \a yPos, where \a yPos is in
   \e widget coordinates.  Returns -1 if \a yPos is outside the valid
   range.
@@ -1696,7 +1683,7 @@
 }
 
 
-/*!
+/*
   Returns the index of the column at position \a xPos, where \a xPos is
   in \e widget coordinates.  Returns -1 if \a xPos is outside the valid
   range.
@@ -1716,7 +1703,7 @@
 }
 
 
-/*!
+/*
   Computes the position in the widget of row \a row.
 
   Returns TRUE and stores the result in \a *yPos (in \e widget
@@ -1756,7 +1743,7 @@
 }
 
 
-/*!
+/*
   Computes the position in the widget of column \a col.
 
   Returns TRUE and stores the result in \a *xPos (in \e widget
@@ -1795,7 +1782,7 @@
 }
 
 
-/*!
+/*
   Moves the visible area of the table right by \a xPixels and
   down by \a yPixels pixels.  Both may be negative.
 
@@ -1815,7 +1802,7 @@
 }
 
 
-/*!
+/*
   Returns the leftmost pixel of the table view in \e view
   coordinates. This excludes the frame and any header.
 
@@ -1828,7 +1815,7 @@
 }
 
 
-/*!
+/*
   Returns the top pixel of the table view in \e view
   coordinates. This excludes the frame and any header.
 
@@ -1841,7 +1828,7 @@
 }
 
 
-/*!
+/*
   Returns the rightmost pixel of the table view in \e view
   coordinates. This excludes the frame and any scroll bar, but
   includes blank pixels to the right of the visible table data.
@@ -1852,12 +1839,12 @@
 int QtTableView::maxViewX() const
 {
     return width() - 1 - frameWidth()
-       - (tFlags & Tbl_vScrollBar ? VSBEXT
-          : 0);
+        - (tFlags & Tbl_vScrollBar ? VSBEXT
+           : 0);
 }
 
 
-/*!
+/*
   Returns the bottom pixel of the table view in \e view
   coordinates. This excludes the frame and any scroll bar, but
   includes blank pixels below the visible table data.
@@ -1868,12 +1855,12 @@
 int QtTableView::maxViewY() const
 {
     return height() - 1 - frameWidth()
-       - (tFlags & Tbl_hScrollBar ? HSBEXT
-          : 0);
+        - (tFlags & Tbl_hScrollBar ? HSBEXT
+           : 0);
 }
 
 
-/*!
+/*
   Returns the width of the table view, as such, in \e view
   coordinates.  This does not include any header, scroll bar or frame,
   but it does include background pixels to the right of the table data.
@@ -1887,7 +1874,7 @@
 }
 
 
-/*!
+/*
   Returns the height of the table view, as such, in \e view
   coordinates.  This does not include any header, scroll bar or frame,
   but it does include background pixels below the table data.
@@ -1954,7 +1941,7 @@
 }
 
 
-/*!
+/*
   \fn void QtTableView::updateScrollBars()
 
   Updates the scroll bars' contents and presence to match the table's
@@ -1963,7 +1950,7 @@
   \sa setTableFlags()
 */
 
-/*!
+/*
   Updates the scroll bars' contents and presence to match the table's
   state \c or \a f.
 
@@ -2002,8 +1989,8 @@
     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 )
@@ -2026,8 +2013,8 @@
     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 )
@@ -2059,16 +2046,16 @@
 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) );
 
@@ -2080,7 +2067,7 @@
 }
 
 
-/*!
+/*
   Returns the maximum horizontal offset within the table of the
   view's left edge in \e table coordinates.
 
@@ -2107,7 +2094,7 @@
                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 );
                }
@@ -2126,7 +2113,7 @@
 }
 
 
-/*!
+/*
   Returns the maximum vertical offset within the table of the
   view's top edge in \e table coordinates.
 
@@ -2153,7 +2140,7 @@
                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 );
                }
@@ -2172,7 +2159,7 @@
 }
 
 
-/*!
+/*
   Returns the index of the last column, which may be at the left edge
   of the view.
 
@@ -2198,7 +2185,7 @@
 }
 
 
-/*!
+/*
   Returns the index of the last row, which may be at the top edge of
   the view.
 
@@ -2259,7 +2246,7 @@
 }
 
 
-/*!
+/*
   Updates the scroll bars and internal state.
 
   Call this function when the table view's total size is changed;
Index: qttableview.h
===================================================================
--- qttableview.h       (revision 13796)
+++ qttableview.h       (working copy)
@@ -1,11 +1,11 @@
 /**********************************************************************
-** $Id: qttableview.h,v 1.1 2001/12/01 02:24:27 levon Exp $
+** $Id: qttableview.h,v 1.1.1.8 2005/09/22 12:53:59 chehrlic Exp $
 **
 ** Definition of QtTableView class
 **
 ** Created : 941115
 **
-** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
+** Copyright (C) 1992-2005 Trolltech AS.  All rights reserved.
 **
 ** This file contains a class moved out of the Qt GUI Toolkit API. It
 ** may be used, distributed and modified without limitation.

Reply via email to