2011-12-20 16:55 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbqt/qtgui/qth/QItemSelection.qth
  * contrib/hbqt/qtgui/qth/QItemSelectionModel.qth
    + Enforced: methods with QModelIndexList => QList< QModelIndex ).

  * contrib/hbqt/qtgui/qth/QWidget.qth
    ! Fixed: to honor QModelIndexList cast.
    + Added: building blocks to create classes with their protected 
       methods. The constructor methods are valid for only QWidget 
       class and this code will be replaced with real-code soon.
       Still I am looking for how to include resultant .cpp in final 
       binaries. Till then this code stays as is.

    Viktor: can you look into new methods and fix the logic from hbmk2's 
            point of view ? 
             qqwidget.h is created ok.
             moc_qqwidget.cpp is created ok.
               moc_qqwidget.o  is missing.
             QWidget.cpp is compiled fine.
               But when compiling demoqt.prg, it reports missing 
               vtable for QQWidget which is because moc_qqwidget.cpp 
               is not being linked.
            To invoke, in QWidget.qth, set PaintEvent = YES and 
            rebuild QWidget.*.
This commit is contained in:
Pritpal Bedi
2011-12-21 01:08:02 +00:00
parent 8f661a9ffe
commit a581793c31
5 changed files with 194 additions and 19 deletions

View File

@@ -16,7 +16,32 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-12-20 13:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
2011-12-20 16:55 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbqt/qtgui/qth/QItemSelection.qth
* contrib/hbqt/qtgui/qth/QItemSelectionModel.qth
+ Enforced: methods with QModelIndexList => QList< QModelIndex ).
* contrib/hbqt/qtgui/qth/QWidget.qth
! Fixed: to honor QModelIndexList cast.
+ Added: building blocks to create classes with their protected
methods. The constructor methods are valid for only QWidget
class and this code will be replaced with real-code soon.
Still I am looking for how to include resultant .cpp in final
binaries. Till then this code stays as is.
Viktor: can you look into new methods and fix the logic from hbmk2's
point of view ?
qqwidget.h is created ok.
moc_qqwidget.cpp is created ok.
moc_qqwidget.o is missing.
QWidget.cpp is compiled fine.
But when compiling demoqt.prg, it reports missing
vtable for QQWidget which is because moc_qqwidget.cpp
is not being linked.
To invoke, in QWidget.qth, set PaintEvent = YES and
rebuild QWidget.*.
2011-12-20 13:03 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* src/rdd/usrrdd/rdds/arrayrdd.prg
! formatting/cleanup, removed unncessary e"" string
! replaced '='/'!=' operator on strings with ==. It's most probably

View File

@@ -316,7 +316,7 @@ FUNCTION hbmk2_plugin_qt( hbmk2 )
IF lBuildIt
IF ! hbmk2[ "lDONTEXEC" ]
IF ! qth_to_src( cSrc, cDstCPP, cDstDOC, hbmk2[ "vars" ][ "qtmodule" ], hbmk2[ "vars" ][ "qtver" ] )
IF ! qth_to_src( cSrc, cDstCPP, cDstDOC, hbmk2[ "vars" ][ "qtmodule" ], hbmk2[ "vars" ][ "qtver" ], hbmk2 )
IF ! hbmk2[ "lIGNOREERROR" ]
cRetVal := "error"
EXIT
@@ -1013,10 +1013,10 @@ STATIC FUNCTION hbqtui_stripRear( /* @ */ cString, cTkn )
/*======================================================================*/
STATIC FUNCTION qth_to_src( cQTHFileName, cCPPFileName, cDOCFileName, cQtModule, cQtVer )
STATIC FUNCTION qth_to_src( cQTHFileName, cCPPFileName, cDOCFileName, cQtModule, cQtVer, hbmk2 )
LOCAL oSrc
oSrc := HbQtSource():new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileName )
oSrc := HbQtSource():new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileName, hbmk2 )
oSrc:build()
RETURN .T.
@@ -1025,6 +1025,7 @@ STATIC FUNCTION qth_to_src( cQTHFileName, cCPPFileName, cDOCFileName, cQtModule,
CREATE CLASS HbQtSource
VAR hbmk2
VAR cCPPFileName, cDOCFileName
VAR hRef
@@ -1072,10 +1073,16 @@ CREATE CLASS HbQtSource
VAR cIntLong INIT "qint32,quint32,QRgb"
VAR cIntLongLong INIT "qint64,quint64,qlonglong,qulonglong,ulong"
METHOD new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileName )
VAR lPaintEvent INIT .f.
VAR lBuildExtended INIT .f.
METHOD new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileName, hbmk2 )
METHOD parseProto( cProto, fBody_ )
METHOD parseVariables( cProto )
METHOD build()
METHOD exploreExtensions()
METHOD buildExtendedSource( txt_ )
METHOD buildExtendedHeader()
METHOD getConstructor()
METHOD getConstructorW()
METHOD buildCppCode( oMtd )
@@ -1086,11 +1093,11 @@ CREATE CLASS HbQtSource
METHOD getReturnAsList( oMtd, FP, cPrefix )
METHOD getReturnMethod( oMtd, lAddRet )
ENDCLASS
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD HbQtSource:new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileName )
METHOD HbQtSource:new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileName, hbmk2 )
LOCAL cQth, s, n, i, n1, b_, tmp, cOrg, fBody_
LOCAL f
@@ -1108,13 +1115,15 @@ METHOD HbQtSource:new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileNa
hb_fNameSplit( cQTHFileName,, @tmp )
::hbmk2 := hbmk2
::cCPPFileName := cCPPFileName
::cDOCFileName := cDOCFileName
::cQtModule := cQtModule
::cQtVer := cQtVer
::cQtModule := cQtModule
::cQtVer := cQtVer
::cQtObject := tmp
::cQtObject := tmp
cQth := hb_MemoRead( cQTHFileName )
@@ -1134,6 +1143,9 @@ METHOD HbQtSource:new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileNa
NEXT
ENDIF
/* Explore if protected methods are to be implemented */
::exploreExtensions()
/* Reassign class level version information */
IF ( n := AScan( ::cls_, {|e_| upper( e_[ 1 ] ) == "VERSION" } ) ) > 0
IF ! Empty( ::cls_[ n, 2 ] )
@@ -1190,7 +1202,7 @@ METHOD HbQtSource:new( cQtModule, cQtVer, cQTHFileName, cCPPFileName, cDOCFileNa
::enums_:= hbqtgen_PullOutSection( @cQth, "ENUMS" )
::enum_:= {}
FOR EACH s IN ::enums_
IF "enum " $ s .or. "flags " $ s
IF "enum " $ s .OR. "flags " $ s
b_:= hb_ATokens( AllTrim( s ), " " )
AAdd( ::enum_, b_[ 2 ] )
ENDIF
@@ -1361,14 +1373,18 @@ METHOD HbQtSource:build()
AAdd( aLine, "" )
AAdd( aLine, "HB_FUNC_EXTERN( __HB" + Upper( ::cQtModule ) + " );" )
FOR EACH s IN ::hRef
AAdd( aLine, "HB_FUNC_EXTERN( HB_" + Upper( s:__enumKey() ) + " );" )
IF ! ( s:__enumKey() == "QModelIndexList" )
AAdd( aLine, "HB_FUNC_EXTERN( HB_" + Upper( s:__enumKey() ) + " );" )
ENDIF
NEXT
AAdd( aLine, "" )
AAdd( aLine, "void _hb_force_link_" + ::cQtObject +"( void )" )
AAdd( aLine, "{" )
AAdd( aLine, " HB_FUNC_EXEC( __HB" + Upper( ::cQtModule ) + " );" )
FOR EACH s IN ::hRef
AAdd( aLine, " HB_FUNC_EXEC( HB_" + Upper( s:__enumKey() ) + " );" )
IF ! ( s:__enumKey() == "QModelIndexList" )
AAdd( aLine, " HB_FUNC_EXEC( HB_" + Upper( s:__enumKey() ) + " );" )
ENDIF
NEXT
AAdd( aLine, "}" )
AAdd( aLine, "" )
@@ -1402,6 +1418,8 @@ METHOD HbQtSource:build()
FOR EACH s IN ::hRef
IF s:__enumKey() == "QList" /* TOFIX: Ugly hack */
tmp := s:__enumKey() + "< void * >"
ELSEIF s:__enumKey() == "QModelIndexList" /* TOFIX: Ugly hack */
tmp := "QList< QModelIndex >"
ELSE
tmp := s:__enumKey()
ENDIF
@@ -1426,6 +1444,8 @@ METHOD HbQtSource:build()
AAdd( aLine, "" )
ENDIF
::buildExtendedSource( aLine ) /* Insert protected functions */
AAdd( aLine, "typedef struct" )
AAdd( aLine, "{" )
IF ::isObject
@@ -1646,6 +1666,9 @@ METHOD HbQtSource:build()
/* Build Document File */
::buildDOC()
/* Build Protected Events Implimentation */
::buildExtendedHeader()
/* Distribute in specific lib subfolder */
hbqtgen_CreateTarget( ::cCPPFileName, aLine )
@@ -1653,6 +1676,131 @@ METHOD HbQtSource:build()
/*----------------------------------------------------------------------*/
METHOD HbQtSource:exploreExtensions()
LOCAL n
IF ( n := AScan( ::cls_, {|e_| Upper( e_[ 1 ] ) $ "PAINTEVENT" } ) ) > 0
IF ! Empty( ::cls_[ n,2 ] )
::lPaintEvent := .t.
ENDIF
ENDIF
// check other events
// Test IF extended code is TO be built
IF ::lPaintEvent // .OR. ::lOtherEvent
::lBuildExtended := .t.
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD HbQtSource:buildExtendedSource( txt_ )
IF ! ::lBuildExtended
RETURN Self
ENDIF
AAdd( txt_, ' ' )
AAdd( txt_, '#include "qqwidget.h" ' )
AAdd( txt_, ' ' )
AAdd( txt_, 'QQWidget::QQWidget( QWidget * parent, Qt::WindowFlags f ) : QWidget( parent, f )' )
AAdd( txt_, '{ ' )
AAdd( txt_, ' pPaintBlock = NULL; ' )
AAdd( txt_, '} ' )
AAdd( txt_, 'QQWidget::~QQWidget() ' )
AAdd( txt_, '{ ' )
AAdd( txt_, ' if( pPaintBlock ) ' )
AAdd( txt_, ' { ' )
AAdd( txt_, ' hb_itemRelease( pPaintBlock ); ' )
AAdd( txt_, ' pPaintBlock = NULL; ' )
AAdd( txt_, ' } ' )
AAdd( txt_, '} ' )
AAdd( txt_, 'void QQWidget::hbSetEventBlock( int event, PHB_ITEM pBlock ) ' )
AAdd( txt_, '{ ' )
AAdd( txt_, ' switch( event ) ' )
AAdd( txt_, ' { ' )
AAdd( txt_, ' case QEvent::Paint: ' )
AAdd( txt_, ' { ' )
AAdd( txt_, ' if( pPaintBlock ) ' )
AAdd( txt_, ' { ' )
AAdd( txt_, ' hb_itemRelease( pPaintBlock ); ' )
AAdd( txt_, ' } ' )
AAdd( txt_, ' pPaintBlock = hb_itemNew( pBlock ); ' )
AAdd( txt_, ' hb_gcUnlock( pPaintBlock ); ' )
AAdd( txt_, ' break; ' )
AAdd( txt_, ' } ' )
AAdd( txt_, ' } ' )
AAdd( txt_, '} ' )
AAdd( txt_, 'void QQWidget::paintEvent( QPaintEvent * event ) ' )
AAdd( txt_, '{ ' )
AAdd( txt_, ' bool bEventHandelled = false; ' )
AAdd( txt_, ' if( pPaintBlock ) ' )
AAdd( txt_, ' { ' )
AAdd( txt_, ' PHB_ITEM p0 = hb_itemPutNI( NULL, QEvent::Paint ); ' )
AAdd( txt_, ' PHB_ITEM p1 = hb_itemNew( hbqt_create_objectGC( hbqt_gcAllocate_QPaintEvent( event, false ), "hb_QPaintEvent" ) ); ' )
AAdd( txt_, ' bEventHandelled = hb_vmEvalBlockV( pPaintBlock, 2, p0, p1 ); ' )
AAdd( txt_, ' hb_itemRelease( p0 ); ' )
AAdd( txt_, ' hb_itemRelease( p1 ); ' )
AAdd( txt_, ' } ' )
AAdd( txt_, ' if( ! bEventHandelled ) ' )
AAdd( txt_, ' { ' )
AAdd( txt_, ' QWidget::paintEvent( event ); ' )
AAdd( txt_, ' } ' )
AAdd( txt_, '} ' )
AAdd( txt_, ' ' )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD HbQtSource:buildExtendedHeader()
LOCAL cPath, txt_
IF ! ::lBuildExtended
RETURN Self
ENDIF
txt_:= {}
aadd( txt_, ' ' )
aadd( txt_, 'HB_EXTERN_BEGIN ' )
AAdd( txt_, 'extern HB_EXPORT void * hbqt_gcAllocate_QPaintEvent( void * pObj, bool bNew );' )
aadd( txt_, 'HB_EXTERN_END ' )
aadd( txt_, ' ' )
aadd( txt_, '#include <QtGui/QWidget> ' )
aadd( txt_, '#include <QtGui/QPaintEvent> ' )
aadd( txt_, ' ' )
aadd( txt_, 'class QQWidget : public QWidget ' )
aadd( txt_, '{ ' )
aadd( txt_, ' Q_OBJECT ' )
aadd( txt_, ' ' )
aadd( txt_, 'public: ' )
aadd( txt_, ' QQWidget( QWidget * parent = 0, Qt::WindowFlags f = 0 ); ' )
aadd( txt_, ' virtual ~QQWidget(); ' )
aadd( txt_, ' ' )
aadd( txt_, ' void hbSetEventBlock( int event, PHB_ITEM pBlock ); ' )
aadd( txt_, ' ' )
aadd( txt_, ' PHB_ITEM pPaintBlock; ' )
aadd( txt_, ' void paintEvent ( QPaintEvent * event ); ' )
aadd( txt_, '}; ' )
aadd( txt_, ' ' )
aeval( txt_, {|e,i| txt_[ i ] := trim( e ) } )
hb_fNameSplit( ::cCPPFileName, @cPath )
hbqtgen_CreateTarget( cPath + "q" + lower( ::cQtObject ) + ".h", txt_ )
aadd( ::hbmk2[ "vars" ][ "aMOC_Src" ], cPath + "q" + lower( ::cQtObject ) + ".h" )
aadd( ::hbmk2[ "vars" ][ "aMOC_Dst" ], cPath + "moc_q" + lower( ::cQtObject ) + ".cpp" )
hbmk2_AddInput_CPP( ::hbmk2, cPath + "moc_q" + lower( ::cQtObject ) + ".cpp" )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD HbQtSource:getConstructor()
LOCAL i, s, aLine := {}

View File

@@ -37,7 +37,7 @@ HB_FUNC( QT_QITEMSELECTION )
<PROTOS>
bool contains ( const QModelIndex & index ) const
// QModelIndexList indexes () const
QList< QModelIndex > indexes () const
void merge ( const QItemSelection & other, QItemSelectionModel::SelectionFlags command )
void select ( const QModelIndex & topLeft, const QModelIndex & bottomRight )

View File

@@ -50,9 +50,9 @@ bool isRowSelected ( int row, const QModelIndex & parent ) const
bool isSelected ( const QModelIndex & index ) const
const QAbstractItemModel * model () const
bool rowIntersectsSelection ( int row, const QModelIndex & parent ) const
// QModelIndexList selectedColumns ( int row = 0 ) const
// QModelIndexList selectedIndexes () const
// QModelIndexList selectedRows ( int column = 0 ) const
QList< QModelIndex > selectedColumns ( int row = 0 ) const
QList< QModelIndex > selectedIndexes () const
QList< QModelIndex > selectedRows ( int column = 0 ) const
const QItemSelection selection () const
</PROTOS>

View File

@@ -12,8 +12,10 @@
*/
<CLASS>
Inherit = QObject, QPaintDevice
New = pParent, nFlags
Inherit = QObject, QPaintDevice
New = pParent, nFlags
PaintEvent =
</CLASS>
<CODE>