diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5c4cdb4ada..2ba430871f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,22 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-08-03 18:00 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/generator/qt45.qtp + + * contrib/hbqt/qth/QAbstractItemModel.qth + + contrib/hbqt/qth/QFontMetrics.qth + * contrib/hbqt/qth/QSize.qth + + * contrib/hbqt/hbqt_slots.cpp + * contrib/hbqt/Makefile_gen + * contrib/hbqt/QAbstractItemModel.cpp + + contrib/hbqt/QFontMetrics.cpp + * contrib/hbqt/QSize.cpp + * contrib/hbqt/TQAbstractItemModel.prg + * contrib/hbqt/TQFontMetrics.prg + + Added one more class and updated others. + 2009-08-04 01:25 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * include/hbdefs.h ! Further tweaked HB_STRICT_ALIGNMENT detection by using diff --git a/harbour/contrib/hbqt/Makefile_gen b/harbour/contrib/hbqt/Makefile_gen index e41cdb9998..26468d6ba0 100644 --- a/harbour/contrib/hbqt/Makefile_gen +++ b/harbour/contrib/hbqt/Makefile_gen @@ -61,6 +61,7 @@ CPP_SOURCES=\ QFontDialog.cpp \ QFontInfo.cpp \ QFormLayout.cpp \ + QFontMetrics.cpp \ QFrame.cpp \ QFtp.cpp \ QGradient.cpp \ @@ -285,6 +286,7 @@ PRG_SOURCES=\ TQFontDatabase.prg \ TQFontDialog.prg \ TQFontInfo.prg \ + TQFontMetrics.prg \ TQFormLayout.prg \ TQFrame.prg \ TQFtp.prg \ diff --git a/harbour/contrib/hbqt/QAbstractItemModel.cpp b/harbour/contrib/hbqt/QAbstractItemModel.cpp index a118a097fc..5c8b4aa1b0 100644 --- a/harbour/contrib/hbqt/QAbstractItemModel.cpp +++ b/harbour/contrib/hbqt/QAbstractItemModel.cpp @@ -100,6 +100,11 @@ HB_FUNC( QT_HBDBFMODEL_RESET ) hbqt_par_HbDbfModel( 1 )->reset(); } +HB_FUNC( QT_HBDBFMODEL_INDEX ) +{ + hb_retptr( new QModelIndex( hbqt_par_HbDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ) ); +} + /* * DESTRUCTOR diff --git a/harbour/contrib/hbqt/QFontMetrics.cpp b/harbour/contrib/hbqt/QFontMetrics.cpp new file mode 100644 index 0000000000..c436d84a8c --- /dev/null +++ b/harbour/contrib/hbqt/QFontMetrics.cpp @@ -0,0 +1,324 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Pritpal Bedi + * + * Copyright 2009 Marcos Antonio Gambeta + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + +#include "hbapi.h" +#include "hbqt.h" + +/*----------------------------------------------------------------------*/ +#if QT_VERSION >= 0x040500 +/*----------------------------------------------------------------------*/ + + +#include + + +/* + * QFontMetrics ( const QFont & font ) + * QFontMetrics ( const QFont & font, QPaintDevice * paintdevice ) + * QFontMetrics ( const QFontMetrics & fm ) + * ~QFontMetrics () + */ +HB_FUNC( QT_QFONTMETRICS ) +{ + if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( ( QFontMetrics* ) new QFontMetrics( *hbqt_par_QFontMetrics( 1 ) ) ); + } + else if( hb_pcount() == 2 && HB_ISCHAR( 1 ) && HB_ISPOINTER( 2 ) ) + { + if( hbqt_par_QString( 1 ) == ( QString ) "QFont" ) + { + hb_retptr( ( QFontMetrics* ) new QFontMetrics( *hbqt_par_QFont( 2 ) ) ); + } + } + else if( hb_pcount() == 2 && HB_ISPOINTER( 1 ) && HB_ISPOINTER( 2 ) ) + { + hb_retptr( ( QFontMetrics* ) new QFontMetrics( *hbqt_par_QFont( 1 ), hbqt_par_QPaintDevice( 2 ) ) ); + } +} + +/* + * DESTRUCTOR + */ +HB_FUNC( QT_QFONTMETRICS_DESTROY ) +{ + hbqt_par_QFontMetrics( 1 )->~QFontMetrics(); +} + +/* + * int ascent () const + */ +HB_FUNC( QT_QFONTMETRICS_ASCENT ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->ascent() ); +} + +/* + * int averageCharWidth () const + */ +HB_FUNC( QT_QFONTMETRICS_AVERAGECHARWIDTH ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->averageCharWidth() ); +} + +/* + * QRect boundingRect ( QChar ch ) const + */ +HB_FUNC( QT_QFONTMETRICS_BOUNDINGRECT ) +{ + hb_retptr( new QRect( hbqt_par_QFontMetrics( 1 )->boundingRect( hb_parni( 2 ) ) ) ); +} + +/* + * QRect boundingRect ( const QString & text ) const + */ +HB_FUNC( QT_QFONTMETRICS_BOUNDINGRECT_1 ) +{ + hb_retptr( new QRect( hbqt_par_QFontMetrics( 1 )->boundingRect( hbqt_par_QString( 2 ) ) ) ); +} + +/* + * QRect boundingRect ( int x, int y, int width, int height, int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) const + */ +HB_FUNC( QT_QFONTMETRICS_BOUNDINGRECT_2 ) +{ + int iTabArray = 0; + + hb_retptr( new QRect( hbqt_par_QFontMetrics( 1 )->boundingRect( hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), hb_parni( 6 ), hbqt_par_QString( 7 ), hb_parni( 8 ), &iTabArray ) ) ); + + hb_storni( iTabArray, 9 ); +} + +/* + * QRect boundingRect ( const QRect & rect, int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) const + */ +HB_FUNC( QT_QFONTMETRICS_BOUNDINGRECT_3 ) +{ + int iTabArray = 0; + + hb_retptr( new QRect( hbqt_par_QFontMetrics( 1 )->boundingRect( *hbqt_par_QRect( 2 ), hb_parni( 3 ), hbqt_par_QString( 4 ), hb_parni( 5 ), &iTabArray ) ) ); + + hb_storni( iTabArray, 6 ); +} + +/* + * int descent () const + */ +HB_FUNC( QT_QFONTMETRICS_DESCENT ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->descent() ); +} + +/* + * QString elidedText ( const QString & text, Qt::TextElideMode mode, int width, int flags = 0 ) const + */ +HB_FUNC( QT_QFONTMETRICS_ELIDEDTEXT ) +{ + hb_retc( hbqt_par_QFontMetrics( 1 )->elidedText( hbqt_par_QString( 2 ), ( Qt::TextElideMode ) hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ) ).toLatin1().data() ); +} + +/* + * int height () const + */ +HB_FUNC( QT_QFONTMETRICS_HEIGHT ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->height() ); +} + +/* + * bool inFont ( QChar ch ) const + */ +HB_FUNC( QT_QFONTMETRICS_INFONT ) +{ + hb_retl( hbqt_par_QFontMetrics( 1 )->inFont( hb_parni( 2 ) ) ); +} + +/* + * int leading () const + */ +HB_FUNC( QT_QFONTMETRICS_LEADING ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->leading() ); +} + +/* + * int leftBearing ( QChar ch ) const + */ +HB_FUNC( QT_QFONTMETRICS_LEFTBEARING ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->leftBearing( hb_parni( 2 ) ) ); +} + +/* + * int lineSpacing () const + */ +HB_FUNC( QT_QFONTMETRICS_LINESPACING ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->lineSpacing() ); +} + +/* + * int lineWidth () const + */ +HB_FUNC( QT_QFONTMETRICS_LINEWIDTH ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->lineWidth() ); +} + +/* + * int maxWidth () const + */ +HB_FUNC( QT_QFONTMETRICS_MAXWIDTH ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->maxWidth() ); +} + +/* + * int minLeftBearing () const + */ +HB_FUNC( QT_QFONTMETRICS_MINLEFTBEARING ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->minLeftBearing() ); +} + +/* + * int minRightBearing () const + */ +HB_FUNC( QT_QFONTMETRICS_MINRIGHTBEARING ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->minRightBearing() ); +} + +/* + * int overlinePos () const + */ +HB_FUNC( QT_QFONTMETRICS_OVERLINEPOS ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->overlinePos() ); +} + +/* + * int rightBearing ( QChar ch ) const + */ +HB_FUNC( QT_QFONTMETRICS_RIGHTBEARING ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->rightBearing( hb_parni( 2 ) ) ); +} + +/* + * QSize size ( int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) const + */ +HB_FUNC( QT_QFONTMETRICS_SIZE ) +{ + int iTabArray = 0; + + hb_retptr( new QSize( hbqt_par_QFontMetrics( 1 )->size( hb_parni( 2 ), hbqt_par_QString( 3 ), hb_parni( 4 ), &iTabArray ) ) ); + + hb_storni( iTabArray, 5 ); +} + +/* + * int strikeOutPos () const + */ +HB_FUNC( QT_QFONTMETRICS_STRIKEOUTPOS ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->strikeOutPos() ); +} + +/* + * QRect tightBoundingRect ( const QString & text ) const + */ +HB_FUNC( QT_QFONTMETRICS_TIGHTBOUNDINGRECT ) +{ + hb_retptr( new QRect( hbqt_par_QFontMetrics( 1 )->tightBoundingRect( hbqt_par_QString( 2 ) ) ) ); +} + +/* + * int underlinePos () const + */ +HB_FUNC( QT_QFONTMETRICS_UNDERLINEPOS ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->underlinePos() ); +} + +/* + * int width ( const QString & text, int len = -1 ) const + */ +HB_FUNC( QT_QFONTMETRICS_WIDTH ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->width( hbqt_par_QString( 2 ), ( HB_ISNUM( 3 ) ? hb_parni( 3 ) : -1 ) ) ); +} + +/* + * int width ( QChar ch ) const + */ +HB_FUNC( QT_QFONTMETRICS_WIDTH_1 ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->width( hb_parni( 2 ) ) ); +} + +/* + * int xHeight () const + */ +HB_FUNC( QT_QFONTMETRICS_XHEIGHT ) +{ + hb_retni( hbqt_par_QFontMetrics( 1 )->xHeight() ); +} + + +/*----------------------------------------------------------------------*/ +#endif /* #if QT_VERSION >= 0x040500 */ +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbqt/QSize.cpp b/harbour/contrib/hbqt/QSize.cpp index 3da097ef7f..0efc268506 100644 --- a/harbour/contrib/hbqt/QSize.cpp +++ b/harbour/contrib/hbqt/QSize.cpp @@ -74,6 +74,10 @@ HB_FUNC( QT_QSIZE ) { hb_retptr( ( QSize* ) new QSize( hb_parni( 1 ), hb_parni( 2 ) ) ); } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( ( QSize* ) new QSize( *hbqt_par_QSize( 1 ) ) ); + } else { hb_retptr( ( QSize* ) new QSize() ); diff --git a/harbour/contrib/hbqt/TQAbstractItemModel.prg b/harbour/contrib/hbqt/TQAbstractItemModel.prg index a0091dbca7..7ec5923220 100644 --- a/harbour/contrib/hbqt/TQAbstractItemModel.prg +++ b/harbour/contrib/hbqt/TQAbstractItemModel.prg @@ -131,6 +131,7 @@ CREATE CLASS HbDbfModel INHERIT QAbstractItemModel METHOD New( bBlock ) INLINE ::pPtr := Qt_HbDbfModel( bBlock ), Self METHOD Reset() INLINE Qt_HbDbfModel_reset( ::pPtr ) + METHOD Index( nRow, nCol ) INLINE Qt_HbDbfModel_index( ::pPtr, nRow, nCol, 0 ) ENDCLASS diff --git a/harbour/contrib/hbqt/TQFontMetrics.prg b/harbour/contrib/hbqt/TQFontMetrics.prg new file mode 100644 index 0000000000..6059495018 --- /dev/null +++ b/harbour/contrib/hbqt/TQFontMetrics.prg @@ -0,0 +1,119 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Pritpal Bedi + * + * Copyright 2009 Marcos Antonio Gambeta + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ + + +#include "hbclass.ch" + + +CREATE CLASS QFontMetrics + + VAR pParent + VAR pPtr + + METHOD New() + METHOD Configure( xObject ) + METHOD Destroy() INLINE Qt_QFontMetrics_destroy( ::pPtr ) + + METHOD ascent() INLINE Qt_QFontMetrics_ascent( ::pPtr ) + METHOD averageCharWidth() INLINE Qt_QFontMetrics_averageCharWidth( ::pPtr ) + METHOD boundingRect( nCh ) INLINE Qt_QFontMetrics_boundingRect( ::pPtr, nCh ) + METHOD boundingRect_1( cText ) INLINE Qt_QFontMetrics_boundingRect_1( ::pPtr, cText ) + METHOD boundingRect_2( nX, nY, nWidth, nHeight, nFlags, cText, nTabStops, nTabArray ) INLINE Qt_QFontMetrics_boundingRect_2( ::pPtr, nX, nY, nWidth, nHeight, nFlags, cText, nTabStops, nTabArray ) + METHOD boundingRect_3( pRect, nFlags, cText, nTabStops, nTabArray ) INLINE Qt_QFontMetrics_boundingRect_3( ::pPtr, pRect, nFlags, cText, nTabStops, nTabArray ) + METHOD descent() INLINE Qt_QFontMetrics_descent( ::pPtr ) + METHOD elidedText( cText, nMode, nWidth, nFlags ) INLINE Qt_QFontMetrics_elidedText( ::pPtr, cText, nMode, nWidth, nFlags ) + METHOD height() INLINE Qt_QFontMetrics_height( ::pPtr ) + METHOD inFont( nCh ) INLINE Qt_QFontMetrics_inFont( ::pPtr, nCh ) + METHOD leading() INLINE Qt_QFontMetrics_leading( ::pPtr ) + METHOD leftBearing( nCh ) INLINE Qt_QFontMetrics_leftBearing( ::pPtr, nCh ) + METHOD lineSpacing() INLINE Qt_QFontMetrics_lineSpacing( ::pPtr ) + METHOD lineWidth() INLINE Qt_QFontMetrics_lineWidth( ::pPtr ) + METHOD maxWidth() INLINE Qt_QFontMetrics_maxWidth( ::pPtr ) + METHOD minLeftBearing() INLINE Qt_QFontMetrics_minLeftBearing( ::pPtr ) + METHOD minRightBearing() INLINE Qt_QFontMetrics_minRightBearing( ::pPtr ) + METHOD overlinePos() INLINE Qt_QFontMetrics_overlinePos( ::pPtr ) + METHOD rightBearing( nCh ) INLINE Qt_QFontMetrics_rightBearing( ::pPtr, nCh ) + METHOD size( nFlags, cText, nTabStops, nTabArray ) INLINE Qt_QFontMetrics_size( ::pPtr, nFlags, cText, nTabStops, nTabArray ) + METHOD strikeOutPos() INLINE Qt_QFontMetrics_strikeOutPos( ::pPtr ) + METHOD tightBoundingRect( cText ) INLINE Qt_QFontMetrics_tightBoundingRect( ::pPtr, cText ) + METHOD underlinePos() INLINE Qt_QFontMetrics_underlinePos( ::pPtr ) + METHOD width( cText, nLen ) INLINE Qt_QFontMetrics_width( ::pPtr, cText, nLen ) + METHOD width_1( nCh ) INLINE Qt_QFontMetrics_width_1( ::pPtr, nCh ) + METHOD xHeight() INLINE Qt_QFontMetrics_xHeight( ::pPtr ) + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD New( ... ) CLASS QFontMetrics + + ::pPtr := Qt_QFontMetrics( ... ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD Configure( xObject ) CLASS QFontMetrics + + IF hb_isObject( xObject ) + ::pPtr := xObject:pPtr + ELSEIF hb_isPointer( xObject ) + ::pPtr := xObject + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbqt/generator/qt45.qtp b/harbour/contrib/hbqt/generator/qt45.qtp index d3e9a60202..a1cbf87694 100644 --- a/harbour/contrib/hbqt/generator/qt45.qtp +++ b/harbour/contrib/hbqt/generator/qt45.qtp @@ -63,6 +63,7 @@ QFontComboBox.qth QFontDatabase.qth QFontDialog.qth QFontInfo.qth +QFontMetrics.qth QFormLayout.qth QFrame.qth QFtp.qth diff --git a/harbour/contrib/hbqt/hbqt_slots.cpp b/harbour/contrib/hbqt/hbqt_slots.cpp index 5a217a8b1d..8165b3bdaa 100644 --- a/harbour/contrib/hbqt/hbqt_slots.cpp +++ b/harbour/contrib/hbqt/hbqt_slots.cpp @@ -63,7 +63,7 @@ #include "hbqt_slots.h" -//#include //////////////////////////////////////////////////// +#include //////////////////////////////////////////////////// #include #include @@ -1629,6 +1629,15 @@ QModelIndex HbTableView::navigate( int cursorAction ) } /*----------------------------------------------------------------------*/ +#if 0 +Qt_DisplayRole 0 Qt_FontRole 6 +Qt_DecorationRole 1 Qt_TextAlignmentRole 7 +Qt_EditRole 2 Qt_BackgroundRole 8 +Qt_ToolTipRole 3 Qt_ForegroundRole 9 +Qt_StatusTipRole 4 Qt_CheckStateRole 10 +Qt_WhatsThisRole 5 Qt_SizeHintRole 13 +#endif + #define HBQT_BRW_CELLVALUE 1001 #define HBQT_BRW_COLCOUNT 1002 #define HBQT_BRW_ROWCOUNT 1003 @@ -1686,91 +1695,85 @@ Qt::ItemFlags HbDbfModel::flags( const QModelIndex & index ) const QVariant HbDbfModel::data( const QModelIndex & index, int role ) const { - // char str[ 50 ]; hb_snprintf( str, sizeof( str ), "data - row=%i col=%i role=%i", index.row(), index.column(), role ); OutputDebugString( str ); +//char str[ 50 ]; hb_snprintf( str, sizeof( str ), "data - row=%i col=%i role=%i", index.row(), index.column(), role ); OutputDebugString( str ); if( !index.isValid() ) - return QVariant(); + return( QVariant() ); - if( role == Qt::SizeHintRole ) + switch( role ) { - int iHeight = fetchRole( block, HBQT_BRW_DATHEIGHT, index.row()+1, index.column()+1 ).toInt(); - return( QSize( 20, iHeight ) ); + case Qt::SizeHintRole: + { + int iHeight = fetchRole( block, HBQT_BRW_DATHEIGHT, index.row()+1, index.column()+1 ).toInt(); + return( QSize( 20, iHeight ) ); + } + case Qt::TextAlignmentRole: + { + return( fetchRole( block, HBQT_BRW_DATALIGN, index.row()+1, index.column()+1 ) ); + } + case Qt::BackgroundRole: + { + int iClr = fetchRole( block, HBQT_BRW_DATBGCOLOR, index.row()+1, index.column()+1 ).toInt(); + if( iClr < 25 ) + return( QColor( ( Qt::GlobalColor ) iClr ) ); + else + return( QColor( ( QRgb ) iClr ) ); + } + case Qt::ForegroundRole: + { + int iClr = fetchRole( block, HBQT_BRW_DATFGCOLOR, index.row()+1, index.column()+1 ).toInt(); + if( iClr < 25 ) + return( QColor( ( Qt::GlobalColor ) iClr ) ); + else + return( QColor( ( QRgb ) iClr ) ); + } + case Qt::DisplayRole: + { + return( fetchRole( block, HBQT_BRW_CELLVALUE, index.row()+1, index.column()+1 ) ); + } } - if( role == Qt::TextAlignmentRole ) - { - return( fetchRole( block, HBQT_BRW_DATALIGN, index.row()+1, index.column()+1 ) ); - } - if( role == Qt::BackgroundRole ) - { - int iClr = fetchRole( block, HBQT_BRW_DATBGCOLOR, index.row()+1, index.column()+1 ).toInt(); - if( iClr < 25 ) - return( QColor( ( Qt::GlobalColor ) iClr ) ); - else - return( QColor( ( QRgb ) iClr ) ); - } - if( role == Qt::ForegroundRole ) - { - int iClr = fetchRole( block, HBQT_BRW_DATFGCOLOR, index.row()+1, index.column()+1 ).toInt(); - if( iClr < 25 ) - return( QColor( ( Qt::GlobalColor ) iClr ) ); - else - return( QColor( ( QRgb ) iClr ) ); - } - if( role != Qt::DisplayRole ) - { - return QVariant(); - } - return fetchRole( block, HBQT_BRW_CELLVALUE, index.row()+1, index.column()+1 ); + return( QVariant() ); } QVariant HbDbfModel::headerData( int section, Qt::Orientation orientation, int role ) const { - // char str[ 50 ]; hb_snprintf( str, sizeof( str ), "headerData - section=%i orient=%i role=%i", section, orientation, role ); OutputDebugString( str ); - #if 0 - Qt_DisplayRole 0 - Qt_DecorationRole 1 - Qt_EditRole 2 - Qt_ToolTipRole 3 - Qt_StatusTipRole 4 - Qt_WhatsThisRole 5 - - Qt_FontRole 6 - Qt_TextAlignmentRole 7 - Qt_BackgroundRole 8 - Qt_ForegroundRole 9 - Qt_CheckStateRole 10 - Qt_SizeHintRole 13 - #endif +//char str[ 50 ]; hb_snprintf( str, sizeof( str ), "headerData - section=%i orient=%i role=%i", section, orientation, role ); OutputDebugString( str ); if( orientation == Qt::Horizontal ) { - if( role == Qt::TextAlignmentRole ) + switch( role ) { - return( fetchRole( block, HBQT_BRW_COLALIGN, 0, section+1 ).toInt() ); - } - if( role == Qt::SizeHintRole ) - { - int iHeight = fetchRole( block, HBQT_BRW_COLHEIGHT, 0, section+1 ).toInt(); - return( QSize( 20, iHeight ) ); - } - if( role == Qt::BackgroundRole ) - { - int iClr = fetchRole( block, HBQT_BRW_COLBGCOLOR, 0, section+1 ).toInt(); - if( iClr < 25 ) - return( QColor( ( Qt::GlobalColor ) iClr ) ); - else - return( QColor( ( QRgb ) iClr ) ); - } - if( role == Qt::ForegroundRole ) - { - int iClr = fetchRole( block, HBQT_BRW_COLFGCOLOR, 0, section+1 ).toInt(); - if( iClr < 25 ) - return( QColor( ( Qt::GlobalColor ) iClr ) ); - else - return( QColor( ( QRgb ) iClr ) ); - } - if( role == Qt::DisplayRole ) - { - return( fetchRole( block, HBQT_BRW_COLHEADER, 0, section+1 ) ); + case Qt::TextAlignmentRole: + { + return( fetchRole( block, HBQT_BRW_COLALIGN, 0, section+1 ).toInt() ); + } + case Qt::SizeHintRole: + { + int iHeight = fetchRole( block, HBQT_BRW_COLHEIGHT, 0, section+1 ).toInt(); + return( QSize( 20, iHeight ) ); + } + case Qt::BackgroundRole: + { + int iClr = fetchRole( block, HBQT_BRW_COLBGCOLOR, 0, section+1 ).toInt(); + if( iClr < 25 ) + return( QColor( ( Qt::GlobalColor ) iClr ) ); + else + return( QColor( ( QRgb ) iClr ) ); + } + case Qt::ForegroundRole: + { + int iClr = fetchRole( block, HBQT_BRW_COLFGCOLOR, 0, section+1 ).toInt(); + if( iClr < 25 ) + return( QColor( ( Qt::GlobalColor ) iClr ) ); + else + return( QColor( ( QRgb ) iClr ) ); + } + case Qt::DisplayRole: + { + return( fetchRole( block, HBQT_BRW_COLHEADER, 0, section+1 ) ); + } + case Qt::FontRole: + case Qt::DecorationRole: + break; } } @@ -1804,14 +1807,10 @@ int HbDbfModel::columnCount( const QModelIndex & /*parent = QModelIndex()*/ ) co QModelIndex HbDbfModel::index( int row, int column, const QModelIndex & parent ) const { - // char str[ 50 ]; hb_snprintf( str, sizeof( str ), "index: row=%i col=%i", row, column ); OutputDebugString( str ); +//char str[ 50 ]; hb_snprintf( str, sizeof( str ), "index: row=%i col=%i", row, column ); OutputDebugString( str ); + HB_SYMBOL_UNUSED( parent ); - return createIndex( row, column, row * column ); - - if( !hasIndex( row, column, parent ) ) - return QModelIndex(); - - return QModelIndex(); + return( createIndex( row, column, row * column ) ); } QModelIndex HbDbfModel::parent( const QModelIndex & /* child */ ) const diff --git a/harbour/contrib/hbqt/qth/QAbstractItemModel.qth b/harbour/contrib/hbqt/qth/QAbstractItemModel.qth index c64a19e5fa..6a4d37a0ca 100644 --- a/harbour/contrib/hbqt/qth/QAbstractItemModel.qth +++ b/harbour/contrib/hbqt/qth/QAbstractItemModel.qth @@ -65,6 +65,7 @@ CREATE CLASS HbDbfModel INHERIT QAbstractItemModel METHOD New( bBlock ) INLINE ::pPtr := Qt_HbDbfModel( bBlock ), Self METHOD Reset() INLINE Qt_HbDbfModel_reset( ::pPtr ) + METHOD Index( nRow, nCol ) INLINE Qt_HbDbfModel_index( ::pPtr, nRow, nCol, 0 ) ENDCLASS @@ -95,6 +96,11 @@ HB_FUNC( QT_HBDBFMODEL_RESET ) hbqt_par_HbDbfModel( 1 )->reset(); } +HB_FUNC( QT_HBDBFMODEL_INDEX ) +{ + hb_retptr( new QModelIndex( hbqt_par_HbDbfModel( 1 )->index( hb_parni( 2 ), hb_parni( 3 ), QModelIndex() ) ) ); +} + diff --git a/harbour/contrib/hbqt/qth/QFontMetrics.qth b/harbour/contrib/hbqt/qth/QFontMetrics.qth new file mode 100644 index 0000000000..10d830ed2a --- /dev/null +++ b/harbour/contrib/hbqt/qth/QFontMetrics.qth @@ -0,0 +1,141 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT Source Generator for Harbour + * + * Copyright 2009 Pritpal Bedi + * www - http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ +; +; Header File to Generate QT Wrapper Sources +; + + +Inherits = +Type = PlainObject +New = + + + +oFontMetrics := QFontMetrics():new( pQFontMetrics ) +oFontMetrics := QFontMetrics():new( "QFont", pQFont ) +oFontMetrics := QFontMetrics():new( pQFont, pQPaintDevice ) + + + +#include + + +/* + * QFontMetrics ( const QFont & font ) + * QFontMetrics ( const QFont & font, QPaintDevice * paintdevice ) + * QFontMetrics ( const QFontMetrics & fm ) + * ~QFontMetrics () + */ +HB_FUNC( QT_QFONTMETRICS ) +{ + if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( ( QFontMetrics* ) new QFontMetrics( *hbqt_par_QFontMetrics( 1 ) ) ); + } + else if( hb_pcount() == 2 && HB_ISCHAR( 1 ) && HB_ISPOINTER( 2 ) ) + { + if( hbqt_par_QString( 1 ) == ( QString ) "QFont" ) + { + hb_retptr( ( QFontMetrics* ) new QFontMetrics( *hbqt_par_QFont( 2 ) ) ); + } + } + else if( hb_pcount() == 2 && HB_ISPOINTER( 1 ) && HB_ISPOINTER( 2 ) ) + { + hb_retptr( ( QFontMetrics* ) new QFontMetrics( *hbqt_par_QFont( 1 ), hbqt_par_QPaintDevice( 2 ) ) ); + } +} + + + + + + +int ascent () const +int averageCharWidth () const +QRect boundingRect ( QChar ch ) const +QRect boundingRect ( const QString & text ) const +QRect boundingRect ( int x, int y, int width, int height, int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) const +QRect boundingRect ( const QRect & rect, int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) const +int descent () const +QString elidedText ( const QString & text, Qt::TextElideMode mode, int width, int flags = 0 ) const +int height () const +bool inFont ( QChar ch ) const +int leading () const +int leftBearing ( QChar ch ) const +int lineSpacing () const +int lineWidth () const +int maxWidth () const +int minLeftBearing () const +int minRightBearing () const +int overlinePos () const +int rightBearing ( QChar ch ) const +QSize size ( int flags, const QString & text, int tabStops = 0, int * tabArray = 0 ) const +int strikeOutPos () const +QRect tightBoundingRect ( const QString & text ) const +int underlinePos () const +int width ( const QString & text, int len = -1 ) const +int width ( QChar ch ) const +int xHeight () const + + + + + + + + + + + + + diff --git a/harbour/contrib/hbqt/qth/QSize.qth b/harbour/contrib/hbqt/qth/QSize.qth index 13b1ff135a..24196ac4b6 100644 --- a/harbour/contrib/hbqt/qth/QSize.qth +++ b/harbour/contrib/hbqt/qth/QSize.qth @@ -61,6 +61,7 @@ New = oSize := QSize():new() +oSize := QSize():new( pSize ) oSize := QSize():new( nWidth, nHeight ) @@ -78,6 +79,10 @@ HB_FUNC( QT_QSIZE ) { hb_retptr( ( QSize* ) new QSize( hb_parni( 1 ), hb_parni( 2 ) ) ); } + else if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( ( QSize* ) new QSize( *hbqt_par_QSize( 1 ) ) ); + } else { hb_retptr( ( QSize* ) new QSize() );