diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c7439fa2e9..6e32ed600a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,34 @@ The license applies to all entries newer than 2009-04-28. */ +2012-06-13 01:15 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/hbqreportsmanager.prg + * contrib/hbide/ideharbourhelp.prg + * contrib/hbide/ideskeletons.prg + * contrib/hbide/ideuisrcmanager.prg + - Removed: all calls to :hasAValidPointer(). + + * contrib/hbqt/qtcore/hbqt_bind.cpp + + Added: more debug code to view what happens when + appln exits. + + * contrib/hbqt/qtcore/hbqt_hbqevents.cpp + * contrib/hbqt/qtcore/hbqt_hbqevents.h + * contrib/hbqt/qtcore/hbqt_hbqslots.cpp + * contrib/hbqt/qtcore/qth/HBQEvents.qth + ! Synchronized: per QObject standards. + + * contrib/hbqt/qtgui/qth/QStringListModel.qth + ! Fixed: wrong if/else if constructs. + + * contrib/hbqt/qtcore/hbqt_misc.prg + * contrib/hbqt/qtgui/THbQtUI.prg + - Removed: the use of :pPtr variable plus method :hasValidPointer(). + + * contrib/hbqt/tests/demoqt.prg + ! Reworked: to adapt to revamped hbQT where variable is not needed + to hold the built widget if parent is provided or is :connect()ed. + 2012-06-13 01:48 UTC+0200 Viktor Szakats (harbour syenar.net) * utils/hbmk2/hbmk2.prg * further cleaned *HB_INSTALL* variable usage diff --git a/harbour/contrib/hbide/hbqreportsmanager.prg b/harbour/contrib/hbide/hbqreportsmanager.prg index f973725f21..1e66cd2404 100644 --- a/harbour/contrib/hbide/hbqreportsmanager.prg +++ b/harbour/contrib/hbide/hbqreportsmanager.prg @@ -579,7 +579,7 @@ HB_TRACE( HB_TR_DEBUG, "QEvent_GraphicsSceneDrop", 1000, p1:dropAction() ) EXIT CASE "QEvent_MouseMoveMenu" - IF empty( ::qPos ) .OR. empty( ::qAct ) .OR. ! ::qAct:hasValidPointer() + IF empty( ::qPos ) .OR. empty( ::qAct ) EXIT ENDIF @@ -1118,7 +1118,7 @@ METHOD HbqReportsManager:contextMenuScene( p1 ) aadd( aAct, qMenu:addAction( "Refresh" ) ) aadd( aAct, qMenu:addAction( "Zoom+" ) ) - IF ( qAct := qMenu:exec( p1:screenPos() ) ):hasValidPointer() + IF ! empty( qAct := qMenu:exec( p1:screenPos() ) ) SWITCH qAct:text() CASE "Refresh" EXIT @@ -1140,7 +1140,7 @@ METHOD HbqReportsManager:contextMenuItem( p1, p2 ) aadd( aAct, qMenu:addAction( "Cut" ) ) aadd( aAct, qMenu:addAction( "Copy" ) ) - IF ( qAct := qMenu:exec( p1:screenPos() ) ):hasValidPointer() + IF ! empty( qAct := qMenu:exec( p1:screenPos() ) ) SWITCH qAct:text() CASE "Cut" EXIT @@ -1858,16 +1858,15 @@ METHOD HqrGraphicsItem:execEvent( cEvent, p, p1, p2 ) /*----------------------------------------------------------------------*/ METHOD HqrGraphicsItem:contextMenu( p1, p2 ) - LOCAL qMenu, qAct, aAct := {} + LOCAL qMenu, qAct HB_SYMBOL_UNUSED( p2 ) qMenu := QMenu() - aadd( aAct, qMenu:addAction( "Cut" ) ) - aadd( aAct, qMenu:addAction( "Copy" ) ) + qMenu:addAction( "Cut" ) + qMenu:addAction( "Copy" ) - qAct := qMenu:exec( p1:screenPos() ) - IF qAct:hasValidPointer() + IF ! empty( qAct := qMenu:exec( p1:screenPos() ) ) SWITCH qAct:text() CASE "Cut" EXIT diff --git a/harbour/contrib/hbide/ideharbourhelp.prg b/harbour/contrib/hbide/ideharbourhelp.prg index 8c4d757f65..4e5ef66359 100644 --- a/harbour/contrib/hbide/ideharbourhelp.prg +++ b/harbour/contrib/hbide/ideharbourhelp.prg @@ -581,7 +581,7 @@ METHOD IdeHarbourHelp:execEvent( nMode, p, p1 ) CASE "buttonUp_clicked" IF ::nCurInHist > 1 .AND. ::nCurInHist <= len( ::aHistory ) - IF ( qTWItem := ::oUI:q_treeDoc:itemAbove( ::oUI:q_treeDoc:currentItem( 0 ) ) ):hasValidPointer() + IF ! empty( qTWItem := ::oUI:q_treeDoc:itemAbove( ::oUI:q_treeDoc:currentItem( 0 ) ) ) ::oUI:q_treeDoc:setCurrentItem( qTWItem, 0 ) ENDIF ENDIF diff --git a/harbour/contrib/hbide/ideskeletons.prg b/harbour/contrib/hbide/ideskeletons.prg index 5555ba209f..5c18974785 100644 --- a/harbour/contrib/hbide/ideskeletons.prg +++ b/harbour/contrib/hbide/ideskeletons.prg @@ -353,7 +353,7 @@ METHOD IdeSkeletons:selectByMenuAndPostText( qEdit ) aadd( aAct, qMenu:addAction( a_[ 1 ] ) ) NEXT - IF ( qAct := qMenu:exec( qEdit:mapToGlobal( QPoint( qRect:x(), qRect:y() ) ) ) ):hasValidPointer() + IF ! empty( qAct := qMenu:exec( qEdit:mapToGlobal( QPoint( qRect:x(), qRect:y() ) ) ) ) IF !empty( cText := ::getText( qAct:text() ) ) ::postText( qEdit, cText ) ENDIF diff --git a/harbour/contrib/hbide/ideuisrcmanager.prg b/harbour/contrib/hbide/ideuisrcmanager.prg index 91f31d41f0..1fd479d5d0 100644 --- a/harbour/contrib/hbide/ideuisrcmanager.prg +++ b/harbour/contrib/hbide/ideuisrcmanager.prg @@ -1054,7 +1054,7 @@ METHOD IdeUISrcManager:buildClassSkeleton( cCls, cUiName ) aadd( aSrc, '' ) aadd( aSrc, ' Eval( ErrorBlock(), oError )' ) aadd( aSrc, ' ENDIF' ) - aadd( aSrc, ' ELSEIF ::oUI:oWidget:hasValidPointer()' ) + aadd( aSrc, ' ELSEIF ! empty( ::oUI:oWidget )' ) aadd( aSrc, ' RETURN ::oUI:oWidget:&cMsg( ... )' ) aadd( aSrc, ' ENDIF' ) aadd( aSrc, '' ) diff --git a/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp b/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp index 64706bc45f..51500bc91f 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_bind.cpp @@ -366,7 +366,7 @@ void hbqt_bindDestroyHbObject( PHB_ITEM pObject ) bind->fDeleting = false; } hb_xfree( bind ); - HB_TRACE( HB_TR_DEBUG, ( " HARBOUR_DESTROYED_NO_PARENTED_%s( %p )", classname, obj ) ); + HB_TRACE( HB_TR_DEBUG, ( " HARBOUR_DESTROYED_NO_PARENT_%s( %p )", classname, obj ) ); } } } @@ -419,15 +419,11 @@ void hbqt_bindDestroyQtObject( void * qtObject ) { if( bind->qtObject == qtObject ) { - HB_TRACE( HB_TR_DEBUG, ( "..............QT_DESTROY_BEGINS( %p ).............. %s fDeleting = %s", qtObject, bind->szClassName, bind->fDeleting ? "YES" : "NO" ) ); + HB_TRACE( HB_TR_DEBUG, ( "..............QT_DESTROYING( %p ).............. %s ... fDeleting=%s", qtObject, bind->szClassName, bind->fDeleting ? "YES" : "NO" ) ); * bind_ptr = bind->next; if( ! bind->fDeleting ) { - PHB_ITEM pObj = hbqt_bindGetHbObjectBYqtObject( bind->qtObject ); - hbqt_bindDelSlots( pObj ); - hbqt_bindDelEvents( pObj ); - hb_itemRelease( pObj ); hb_xfree( bind ); } break; @@ -438,60 +434,6 @@ void hbqt_bindDestroyQtObject( void * qtObject ) } -/* this function has to be executed from HBQT object destructor - * with Self parameter: - * __hbqt_destroy( Self ) - * alternatively it can be used directly as destructor method. - */ -HB_FUNC( __HBQT_DESTROY ) -{ -#if 1 - PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT ); - if( pObject == NULL ) - pObject = hb_stackSelfItem(); - if( pObject ) - hbqt_bindDestroyHbObject( pObject ); -#else - PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT ); - if( pObject ) - hbqt_bindDestroyHbObject( pObject ); -#endif -} - -HB_FUNC( HBQT_PROMOTEWIDGET2 ) -{ - if( hbqt_par_isDerivedFrom( 1, "QWIDGET" ) && HB_ISCHAR( 2 ) ) - { - void * qtObject = hbqt_bindGetQtObject( hb_param( 1, HB_IT_OBJECT ) ); - if ( qtObject ) - { - hbqt_bindDestroyQtObject( qtObject ); - - const char * pText01 = hb_parc( 2 ); - char test[ HB_SYMBOL_NAME_LEN + 1 ]; - hb_snprintf( test, sizeof( test ), "HB_%s", pText01 ); - - hb_itemReturnRelease( hbqt_bindGetHbObject( NULL, qtObject, test, NULL, HBQT_BIT_QOBJECT ) ); - } - } -} - -HB_FUNC( HBQT_ITEMSONGLOBALLIST ) -{ - int i = 0; - PHBQT_BIND bind; - - HBQT_BIND_LOCK - bind = s_hbqt_binds; - while( bind ) - { - i++; - bind = bind->next; - } - HBQT_BIND_UNLOCK - hb_retni( i ); -} - void hbqt_bindSetOwner( void * qtObject, HB_BOOL fOwner ) { PHBQT_BIND bind; @@ -513,71 +455,6 @@ void hbqt_bindSetOwner( void * qtObject, HB_BOOL fOwner ) HBQT_BIND_UNLOCK } -void hbqt_bindAddChild( PHB_ITEM pObject, PHB_ITEM pChild ) -{ -#ifdef HBQT_BIND_DEBUG - QObject * qtParent = hbqt_bindGetQtObject( pObject ); - QObject * qtChild = hbqt_bindGetQtObject( pChild ); - - if( qtParent == NULL || qtChild == NULL || - HBQT_PARENT( qtChild ) != qtParent ) - { - hb_errRT_BASE( EG_BOUND, 4001, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); - return; - } -#endif - - if( hb_vmRequestReenter() ) - { - PHB_ITEM pArray; - - hb_vmPushDynSym( s_dynsym___CHILDS ); - hb_vmPush( pObject ); - hb_vmSend( 0 ); - pArray = hb_stackReturnItem(); - if( hb_vmRequestQuery() == 0 ) - { - if( HB_IS_ARRAY( pArray ) ) - hb_arrayAdd( pArray, pChild ); - else - hb_errRT_BASE( EG_BOUND, 4002, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); - } - hb_vmRequestRestore(); - } -} - -void hbqt_bindDelChild( PHB_ITEM pObject, PHB_ITEM pChild ) -{ -#ifdef HBQT_BIND_DEBUG - QObject * qtParent = hbqt_bindGetQtObject( pObject ); - QObject * qtChild = hbqt_bindGetQtObject( pChild ); - - if( qtParent == NULL || qtChild == NULL || - HBQT_PARENT( qtChild ) != NULL ) - { - hb_errRT_BASE( EG_BOUND, 4003, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); - return; - } -#endif - - if( hb_vmRequestReenter() ) - { - hb_vmPushDynSym( s_dynsym___CHILDS ); - hb_vmPush( pObject ); - hb_vmSend( 0 ); - if( hb_vmRequestQuery() == 0 ) - { - PHB_ITEM pArray = hb_stackReturnItem(); - if( hb_arrayDel( pArray, hb_arrayScan( pArray, pChild, - NULL, NULL, HB_TRUE ) ) ) - hb_arraySize( pArray, hb_arrayLen( pArray ) - 1 ); - else - hb_errRT_BASE( EG_BOUND, 4004, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); - } - hb_vmRequestRestore(); - } -} - void hbqt_bindAddSlot( PHB_ITEM pSenderObject, int iSignalid, PHB_ITEM pCode ) { if( HB_IS_BLOCK( pCode ) && hb_vmRequestReenter() ) @@ -778,7 +655,7 @@ void hbqt_bindDelEvents( PHB_ITEM pSenderObject ) PHB_ITEM hbqt_bindGetEvents( PHB_ITEM pSenderObject, int iEventId ) { - PHB_ITEM pSlots = NULL; + PHB_ITEM pEvents = NULL; if( hb_vmRequestReenter() ) { @@ -794,15 +671,147 @@ PHB_ITEM hbqt_bindGetEvents( PHB_ITEM pSenderObject, int iEventId ) hb_stackPop(); if( pArray && HB_IS_ARRAY( pArray ) && hb_arrayLen( pArray ) > 0 ) - pSlots = hb_itemNew( pArray ); + pEvents = hb_itemNew( pArray ); } hb_vmRequestRestore(); } - return pSlots; + return pEvents; +} + +void hbqt_bindAddChild( PHB_ITEM pObject, PHB_ITEM pChild ) +{ +#ifdef HBQT_BIND_DEBUG + QObject * qtParent = hbqt_bindGetQtObject( pObject ); + QObject * qtChild = hbqt_bindGetQtObject( pChild ); + + if( qtParent == NULL || qtChild == NULL || + HBQT_PARENT( qtChild ) != qtParent ) + { + hb_errRT_BASE( EG_BOUND, 4001, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + return; + } +#endif + + if( hb_vmRequestReenter() ) + { + PHB_ITEM pArray; + + hb_vmPushDynSym( s_dynsym___CHILDS ); + hb_vmPush( pObject ); + hb_vmSend( 0 ); + pArray = hb_stackReturnItem(); + if( hb_vmRequestQuery() == 0 ) + { + if( HB_IS_ARRAY( pArray ) ) + hb_arrayAdd( pArray, pChild ); + else + hb_errRT_BASE( EG_BOUND, 4002, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } + hb_vmRequestRestore(); + } +} + +void hbqt_bindDelChild( PHB_ITEM pObject, PHB_ITEM pChild ) +{ +#ifdef HBQT_BIND_DEBUG + QObject * qtParent = hbqt_bindGetQtObject( pObject ); + QObject * qtChild = hbqt_bindGetQtObject( pChild ); + + if( qtParent == NULL || qtChild == NULL || + HBQT_PARENT( qtChild ) != NULL ) + { + hb_errRT_BASE( EG_BOUND, 4003, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + return; + } +#endif + + if( hb_vmRequestReenter() ) + { + hb_vmPushDynSym( s_dynsym___CHILDS ); + hb_vmPush( pObject ); + hb_vmSend( 0 ); + if( hb_vmRequestQuery() == 0 ) + { + PHB_ITEM pArray = hb_stackReturnItem(); + if( hb_arrayDel( pArray, hb_arrayScan( pArray, pChild, + NULL, NULL, HB_TRUE ) ) ) + hb_arraySize( pArray, hb_arrayLen( pArray ) - 1 ); + else + hb_errRT_BASE( EG_BOUND, 4004, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); + } + hb_vmRequestRestore(); + } +} + +/* this function has to be executed from HBQT object destructor + * with Self parameter: + * __hbqt_destroy( Self ) + * alternatively it can be used directly as destructor method. + */ +HB_FUNC( __HBQT_DESTROY ) +{ +#if 1 + PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT ); + if( pObject == NULL ) + pObject = hb_stackSelfItem(); + if( pObject ) + hbqt_bindDestroyHbObject( pObject ); +#else + PHB_ITEM pObject = hb_param( 1, HB_IT_OBJECT ); + if( pObject ) + hbqt_bindDestroyHbObject( pObject ); +#endif +} + +HB_FUNC( HBQT_PROMOTEWIDGET2 ) +{ + if( hbqt_par_isDerivedFrom( 1, "QWIDGET" ) && HB_ISCHAR( 2 ) ) + { + void * qtObject = hbqt_bindGetQtObject( hb_param( 1, HB_IT_OBJECT ) ); + if ( qtObject ) + { + hbqt_bindDestroyQtObject( qtObject ); + + const char * pText01 = hb_parc( 2 ); + char test[ HB_SYMBOL_NAME_LEN + 1 ]; + hb_snprintf( test, sizeof( test ), "HB_%s", pText01 ); + + hb_itemReturnRelease( hbqt_bindGetHbObject( NULL, qtObject, test, NULL, HBQT_BIT_QOBJECT ) ); + } + } +} + +int __hbqt_bindItemsInGlobalList( void ) +{ + int i = 0; + PHBQT_BIND bind; + + HBQT_BIND_LOCK + bind = s_hbqt_binds; + while( bind ) + { + i++; + HB_TRACE( HB_TR_DEBUG, ( "_____OnExit______( %p, %s )", bind->qtObject, bind->szClassName ) ); + bind = bind->next; + } + HBQT_BIND_UNLOCK + return i; +} + +HB_FUNC( __HBQT_ITEMSINGLOBALLIST ) +{ + hb_retni( __hbqt_bindItemsInGlobalList() ); +} + +static void hbqt_bind_exit( void* cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + HB_TRACE( HB_TR_DEBUG, ( "Exiting with %d Items in Global List", __hbqt_bindItemsInGlobalList() ) ); } HB_CALL_ON_STARTUP_BEGIN( _hbqt_bind_init_ ) hb_vmAtInit( hbqt_bind_init, NULL ); + hb_vmAtExit( hbqt_bind_exit, NULL ); HB_CALL_ON_STARTUP_END( _hbqt_bind_init_ ) #if defined( HB_PRAGMA_STARTUP ) diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp index c511fd5f61..86d0519455 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.cpp @@ -107,15 +107,11 @@ void hbqt_events_unregister_createobj( QEvent::Type eventtype ) /*----------------------------------------------------------------------*/ -HBQEvents::HBQEvents( PHB_ITEM pObj ) : QObject() +HBQEvents::HBQEvents( QObject * object ) : QObject() { - if( pObj ) + if( object ) { - QObject * object = ( QObject * ) hbqt_get_ptr( pObj ); - if( object ) - { - object->installEventFilter( this ); - } + object->installEventFilter( this ); } } @@ -169,14 +165,14 @@ bool HBQEvents::eventFilter( QObject * object, QEvent * event ) if( eventId > -1 && hb_vmRequestReenter() ) { - PHB_ITEM p = hbqt_bindGetEvents( hbqt_bindGetHbObjectBYqtObject( object ), eventtype ); - if( p ) + PHB_ITEM pArray = hbqt_bindGetEvents( hbqt_bindGetHbObjectBYqtObject( object ), eventtype ); + if( pArray ) { PHB_ITEM pItem = hbqt_bindGetHbObject( NULL, ( void * ) event, ( s_lstCreateObj.at( eventId ) ), NULL, HBQT_BIT_NONE ); - stopTheEventChain = ( bool ) hb_itemGetL( hb_vmEvalBlockV( hb_arrayGetItemPtr( p, 1 ), 1, pItem ) ); + stopTheEventChain = ( bool ) hb_itemGetL( hb_vmEvalBlockV( hb_arrayGetItemPtr( pArray, 1 ), 1, pItem ) ); hb_itemRelease( pItem ); + hb_itemRelease( pArray ); } - hb_itemRelease( p ); hb_vmRequestRestore(); } if( eventtype == QEvent::Close ) diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h index eb02170278..23add62b63 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqevents.h @@ -68,7 +68,7 @@ class HBQEvents: public QObject Q_OBJECT public: - HBQEvents( PHB_ITEM pObj ); + HBQEvents( QObject * parent = 0 ); ~HBQEvents(); QList listBlock; diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp index 821c35a15d..31f0ba2aa1 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp @@ -234,7 +234,6 @@ int HBQSlots::hbDisconnect( PHB_ITEM pObj, char * pszSignal ) int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments ) { id = QObject::qt_metacall( c, id, arguments ); - if( id < 0 || c != QMetaObject::InvokeMetaMethod ) return id; @@ -292,24 +291,23 @@ int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments ) if( hb_vmRequestReenter() ) { - if( parameterCount == 0 ) + PHB_ITEM p = hbqt_bindGetSlots( hbqt_bindGetHbObjectBYqtObject( object ), id ); + if( p ) { - PHB_ITEM p = hbqt_bindGetSlots( hbqt_bindGetHbObjectBYqtObject( object ), id ); - hb_evalBlock0( hb_arrayGetItemPtr( p, 1 ) ); - hb_itemRelease( p ); - } - else - { - int paramId = s_argCombinations.indexOf( paramString ); - PHBQT_SLOT_FUNC pCallback; - - pCallback = s_pCallback.at( paramId ); - if( pCallback ) + if( parameterCount == 0 ) { - PHB_ITEM p = hbqt_bindGetSlots( hbqt_bindGetHbObjectBYqtObject( object ), id ); - pCallback( ( PHB_ITEM * ) hb_arrayGetItemPtr( p, 1 ), arguments, pList ); - hb_itemRelease( p ); - } + hb_evalBlock0( hb_arrayGetItemPtr( p, 1 ) ); + } + else + { + int paramId = s_argCombinations.indexOf( paramString ); + PHBQT_SLOT_FUNC pCallback = s_pCallback.at( paramId ); + if( pCallback ) + { + pCallback( ( PHB_ITEM * ) hb_arrayGetItemPtr( p, 1 ), arguments, pList ); + } + } + hb_itemRelease( p ); } hb_vmRequestRestore(); } diff --git a/harbour/contrib/hbqt/qtcore/hbqt_misc.prg b/harbour/contrib/hbqt/qtcore/hbqt_misc.prg index 74c64ebc3e..83bec9f60e 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_misc.prg +++ b/harbour/contrib/hbqt/qtcore/hbqt_misc.prg @@ -60,8 +60,6 @@ CREATE CLASS HbQtObjectHandler - VAR pPtr /* TODO: Rename to __pPtr */ - VAR __pSlots PROTECTED VAR __pEvents PROTECTED @@ -70,8 +68,6 @@ CREATE CLASS HbQtObjectHandler VAR __Slots VAR __Events - METHOD hasValidPointer() - METHOD connect( cnEvent, bBlock ) METHOD disconnect( cnEvent ) METHOD setSlots() @@ -104,11 +100,6 @@ METHOD HbQtObjectHandler:setEvents() RETURN Self -/*----------------------------------------------------------------------*/ -/* TOBE: deleted */ -METHOD HbQtObjectHandler:hasValidPointer() - RETURN __hbqt_isPointer( ::pPtr ) - /*----------------------------------------------------------------------*/ METHOD HbQtObjectHandler:onError() diff --git a/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth b/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth index a997a34c7e..10dabcf918 100644 --- a/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth +++ b/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth @@ -36,7 +36,14 @@ New = */ HB_FUNC( QT_HBQEVENTS ) { - __HB_RETPTRGC__( new HBQEvents( hb_param( 1, HB_IT_OBJECT ) ) ); + if( hb_pcount() == 1 && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) ) + { + __HB_RETPTRGC__( new HBQEvents( hbqt_par_QObject( 1 ) ) ); + } + else + { + __HB_RETPTRGC__( new HBQEvents() ); + } } diff --git a/harbour/contrib/hbqt/qtgui/THbQtUI.prg b/harbour/contrib/hbqt/qtgui/THbQtUI.prg index c6cfe3dc28..f9e8191c12 100644 --- a/harbour/contrib/hbqt/qtgui/THbQtUI.prg +++ b/harbour/contrib/hbqt/qtgui/THbQtUI.prg @@ -91,9 +91,6 @@ METHOD HbQtUI:new( oRootWidget, hWidget ) ::oWidget := oRootWidget ::qObj := hWidget - /* QUESTION: Is this needed? */ - ::pPtr := oRootWidget:pPtr - RETURN Self /*----------------------------------------------------------------------*/ @@ -147,7 +144,7 @@ METHOD HbQtUI:__OnError( ... ) Eval( ErrorBlock(), oError ) ENDIF - ELSEIF ::oWidget:hasValidPointer() /* QUESTION: Why do we need this? */ + ELSEIF ! empty( ::oWidget ) RETURN ::oWidget:&cMsg( ... ) ENDIF diff --git a/harbour/contrib/hbqt/qtgui/qth/QStringListModel.qth b/harbour/contrib/hbqt/qtgui/qth/QStringListModel.qth index 7543fbde50..d75e9e4621 100644 --- a/harbour/contrib/hbqt/qtgui/qth/QStringListModel.qth +++ b/harbour/contrib/hbqt/qtgui/qth/QStringListModel.qth @@ -31,11 +31,11 @@ HB_FUNC( QT_QSTRINGLISTMODEL ) { __HB_RETPTRGC__( new QStringListModel( hbqt_par_QObject( 1 ) ) ); } - if( hb_pcount() == 1 && hbqt_par_isDerivedFrom( 1, "QSTRINGLIST" ) ) + else if( hb_pcount() == 1 && hbqt_par_isDerivedFrom( 1, "QSTRINGLIST" ) ) { __HB_RETPTRGC__( new QStringListModel( *hbqt_par_QStringList( 1 ) ) ); } - if( hb_pcount() == 2 && hbqt_par_isDerivedFrom( 1, "QSTRINGLIST" ) && hbqt_par_isDerivedFrom( 2, "QOBJECT" ) ) + else if( hb_pcount() == 2 && hbqt_par_isDerivedFrom( 1, "QSTRINGLIST" ) && hbqt_par_isDerivedFrom( 2, "QOBJECT" ) ) { __HB_RETPTRGC__( new QStringListModel( *hbqt_par_QStringList( 1 ), hbqt_par_QObject( 2 ) ) ); } diff --git a/harbour/contrib/hbqt/tests/demoqt.prg b/harbour/contrib/hbqt/tests/demoqt.prg index 2051953f63..fa846a2af6 100644 --- a/harbour/contrib/hbqt/tests/demoqt.prg +++ b/harbour/contrib/hbqt/tests/demoqt.prg @@ -81,9 +81,8 @@ FUNCTION My_Events( e ) /*----------------------------------------------------------------------*/ PROCEDURE Main() - Local oLabel, oBtn, oDA, oWnd, oProg, oSBar - LOCAL aMenu, aTool, aGrid, aTabs, aList - + Local oBtn, oDA, oWnd, oSBar, oAct, aMenu, aTool, aTabs + hbqt_errorsys() oWnd := QMainWindow() @@ -104,32 +103,41 @@ PROCEDURE Main() oWnd:setStatusBar( oSBar ) oSBar:showMessage( "Harbour-QT Statusbar Ready!" ) - oLabel := Build_Label( oDA, { 30,190 }, { 300, 30 } ) - oBtn := Build_PushButton( oDA, { 30,240 }, { 100,50 } ) - aGrid := Build_Grid( oDA, { 30, 30 }, { 450,150 } ) + Build_Grid( oDA, { 30, 30 }, { 450,150 } ) + Build_ProgressBar( oDA, { 30,300 }, { 200,30 } ) + Build_ListBox( oDA, { 310,240 }, { 150, 100 } ) + Build_Label( oDA, { 30,190 }, { 300, 30 } ) + aTabs := Build_Tabs( oDA, { 510, 5 }, { 360, 400 } ) - oProg := Build_ProgressBar( oDA, { 30,300 }, { 200,30 } ) - aList := Build_ListBox( oDA, { 310,240 }, { 150, 100 } ) - + oBtn := Build_PushButton( oDA, { 30,240 }, { 100,50 } ) oBtn:setStyleSheet( "background: #a00fff;" ) - oBtn:connect( QEvent_Enter, {|oEvent| RePaintHover( oEvent, oBtn, QEvent_Enter ) } ) - oBtn:connect( QEvent_Leave, {|oEvent| RePaintHover( oEvent, oBtn, QEvent_Leave ) } ) -// oBtn:connect( QEvent_Paint, {|oEvent,oPainter| RePaint( oEvent, oPainter, oBtn ) } ) - oWnd:connect( QEvent_KeyPress, {|e| My_Events( e ) } ) - oWnd:connect( QEvent_Close, {|| QApplication():quit() } ) + oWnd:connect( QEvent_Close , {|| QApplication():quit() } ) + oWnd:Show() - QApplication():exec() - oBtn:disconnect( "clicked()" ) - oBtn := NIL - - HB_TRACE( HB_TR_DEBUG, ".............. E X I T I N G ...................", valtype( oLabel ) ) - xReleaseMemory( { oBtn, oLabel, oProg, oSBar, aGrid, aList, aMenu, aTool, aTabs, oDA, oWnd } ) + oWnd:disconnect( QEvent_KeyPress ) + oWnd:disconnect( QEvent_Close ) + oBtn:disconnect( "clicked()" ) + + FOR EACH oAct IN aMenu + oAct:disconnect( "triggered(bool)" ) + NEXT + FOR EACH oAct IN aTool + oAct:disconnect( "triggered(bool)" ) + NEXT + + aTabs[ 1,1 ]:disconnect( "returnPressed()" ) + aTabs[ 1,2 ]:disconnect( "currentIndexChanged(int)" ) + aTabs[ 1,3 ]:disconnect( "stateChanged(int)" ) + aTabs[ 1,4 ]:disconnect( "clicked()" ) + + HB_TRACE( HB_TR_DEBUG, ".............. E X I T I N G ..................." ) + xReleaseMemory( { oBtn, aMenu, aTool, aTabs, oDA, oWnd } ) RETURN /*----------------------------------------------------------------------*/ @@ -193,23 +201,23 @@ PROCEDURE ExecOneMore() oEventLoop := 0 xReleaseMemory( { oBtn, oLabel, oProg, oSBar, aGrid, aList, aMenu, aTool, aTabs, oDA, oWnd, oEventLoop } ) - + HB_TRACE( HB_TR_DEBUG, " " ) + HB_TRACE( HB_TR_DEBUG, ".............. E X I T I N G one more dialog ..................." ) + HB_TRACE( HB_TR_DEBUG, " " ) + RETURN /*----------------------------------------------------------------------*/ STATIC FUNCTION Build_MenuBar( oWnd ) - LOCAL oMenuBar, oMenu1, oMenu2, oAM1, oAM2 + LOCAL oMenuBar, oMenu1, oMenu2 LOCAL oActNew, oActOpen, oActSave, oActExit LOCAL oActColors, oActFonts, oActPgSetup, oActPreview, oActWiz, oActWeb, oActOther - LOCAL oS1, oS2, oS3, oS4, oS5 - oMenuBar := QMenuBar() - oMenuBar:resize( oWnd:width(), 25 ) + oMenuBar := QMenuBar( oWnd ) - oMenu1 := QMenu() + oMenu1 := QMenu( oMenuBar ) oMenu1:setTitle( "&File" ) - oMenu1:connect( QEvent_Paint, {|oEvent,oPainter| MenuRePaint( oEvent, oPainter, oMenu1 ) } ) oActNew := QAction( oMenu1 ) oActNew:setText( "&New" ) @@ -220,19 +228,19 @@ STATIC FUNCTION Build_MenuBar( oWnd ) oActOpen := oMenu1:addAction( QIcon( hb_dirBase() + "open.png" ), "&Open" ) oActOpen:connect( "triggered(bool)", {|w,l| FileDialog( "Open" , w, l ) } ) - oS1 := oMenu1:addSeparator() + oMenu1:addSeparator() oActSave := oMenu1:addAction( QIcon( hb_dirBase() + "save.png" ), "&Save" ) oActSave:connect( "triggered(bool)", {|w,l| FileDialog( "Save" , w, l ) } ) - oS2 := oMenu1:addSeparator() + oMenu1:addSeparator() oActExit := oMenu1:addAction( "E&xit" ) oActExit:connect( "triggered(bool)", {|| QApplication():quit() } ) - oAM1 := oMenuBar:addMenu( oMenu1 ) + oMenuBar:addMenu( oMenu1 ) - oMenu2 := QMenu() + oMenu2 := QMenu( oMenuBar ) oMenu2:setTitle( "&Dialogs" ) oActColors := oMenu2:addAction( "&Colors" ) @@ -241,7 +249,7 @@ STATIC FUNCTION Build_MenuBar( oWnd ) oActFonts := oMenu2:addAction( "&Fonts" ) oActFonts:connect( "triggered(bool)", {|w,l| Dialogs( "Fonts", w, l ) } ) - oS3 := oMenu2:addSeparator() + oMenu2:addSeparator() oActPgSetup := oMenu2:addAction( "&PageSetup" ) oActPgSetup:connect( "triggered(bool)", {|w,l| Dialogs( "PageSetup", w, l ) } ) @@ -249,7 +257,7 @@ STATIC FUNCTION Build_MenuBar( oWnd ) oActPreview := oMenu2:addAction( "P&review" ) oActPreview:connect( "triggered(bool)", {|w,l| Dialogs( "Preview", w, l ) } ) - oS4 := oMenu2:addSeparator() + oMenu2:addSeparator() oActWiz := oMenu2:addAction( "&Wizard" ) oActWiz:connect( "triggered(bool)", {|w,l| Dialogs( "Wizard", w, l ) } ) @@ -257,26 +265,25 @@ STATIC FUNCTION Build_MenuBar( oWnd ) oActWeb := oMenu2:addAction( "W&ebPage" ) oActWeb:connect( "triggered(bool)", {|w,l| Dialogs( "WebPage", w, l ) } ) - oS5 := oMenu2:addSeparator() + oMenu2:addSeparator() oActOther := oMenu2:addAction( "&Another Dialog" ) oActOther:connect( "triggered(bool)", {|| ExecOneMore() } ) - oAM2 := oMenuBar:addMenu( oMenu2 ) + oMenuBar:addMenu( oMenu2 ) oWnd:setMenuBar( oMenuBar ) - RETURN { oMenu1, oMenu2, oMenuBar, oActNew, oActOpen, oActSave, oActExit, ; - oActColors, oActFonts, oActPgSetup, oActPreview, oActWiz, oActWeb, ; - oActOther, oS1, oS2, oS3, oS4, oS5, oAM1, oAM2 } + RETURN { oActNew, oActOpen, oActSave, oActExit, oActColors, oActFonts, ; + oActPgSetup, oActPreview, oActWiz, oActWeb, oActOther } /*----------------------------------------------------------------------*/ STATIC FUNCTION Build_ToolBar( oWnd ) - LOCAL oTB, oActNew, oActOpen, oActSave, oS1 + LOCAL oTB, oActNew, oActOpen, oActSave /* Create a Toolbar Object */ - oTB := QToolBar() + oTB := QToolBar( oWnd ) /* Create an action */ oActNew := QAction( oWnd ) @@ -296,7 +303,7 @@ STATIC FUNCTION Build_ToolBar( oWnd ) /* Attach Action with Toolbar */ oTB:addAction( oActOpen ) - oS1 := oTB:addSeparator() + oTB:addSeparator() /* Create another action */ oActSave := QAction( oWnd ) @@ -310,7 +317,7 @@ STATIC FUNCTION Build_ToolBar( oWnd ) /* Add this toolbar with main window */ oWnd:addToolBar( oTB ) - RETURN { oActNew, oActOpen, oActSave, oTB, oS1 } + RETURN { oActNew, oActOpen, oActSave } /*----------------------------------------------------------------------*/ @@ -361,12 +368,12 @@ STATIC FUNCTION Build_Grid( oWnd, aPos, aSize ) // oGrid:Show() - RETURN { oBrushBackItem0x0, oBrushForeItem0x0, oGridItem0x0, oGrid } + RETURN {} /*----------------------------------------------------------------------*/ STATIC FUNCTION Build_Tabs( oWnd, aPos, aSize ) - LOCAL oTabWidget, oTab1, oTab2, oTab3, aTree, aCntl, aText + LOCAL oTabWidget, oTab1, oTab2, oTab3, aCtrls oTabWidget := QTabWidget( oWnd ) @@ -382,14 +389,11 @@ STATIC FUNCTION Build_Tabs( oWnd, aPos, aSize ) oTabWidget:ReSize( aSize[ 1 ], aSize[ 2 ] ) oTabWidget:show() - aTree := Build_Treeview( oTab1 ) - aadd( aTree, oTab1 ) - aCntl := Build_Controls( oTab2 ) - aadd( aCntl, oTab2 ) - aText := Build_TextBox( oTab3 ) - aadd( aText, oTab3 ) + Build_Treeview( oTab1 ) + aCtrls := Build_Controls( oTab2 ) + Build_TextBox( oTab3 ) - RETURN { aCntl, aTree, aText, oTabWidget } + RETURN { aCtrls } /*----------------------------------------------------------------------*/ @@ -399,13 +403,13 @@ STATIC FUNCTION Build_TreeView( oWnd ) oTV := QTreeView( oWnd ) oTV:setMouseTracking( .t. ) * oTV:connect( "hovered()", {|i| HB_TRACE( HB_TR_DEBUG, ( "oTV:hovered" ) } ) - oDirModel := QDirModel() + oDirModel := QDirModel( oTV ) oTV:setModel( oDirModel ) oTV:move( 5, 7 ) oTV:resize( 345, 365 ) OTV:show() - RETURN { oDirModel, oTV } + RETURN NIL /*----------------------------------------------------------------------*/ @@ -413,11 +417,8 @@ STATIC FUNCTION Build_ListBox( oWnd, aPos, aSize ) LOCAL oListBox, oStrList, oStrModel oListBox := QListView( oWnd ) - oListBox:setMouseTracking( .t. ) -* oListBox:connect( "hovered()", {|i| HB_TRACE( HB_TR_DEBUG, ( "oListBox:hovered" ) } ) oStrList := QStringList() - oStrList:append( "India" ) oStrList:append( "United States" ) oStrList:append( "England" ) @@ -427,15 +428,14 @@ STATIC FUNCTION Build_ListBox( oWnd, aPos, aSize ) oStrList:append( "China" ) oStrList:sort() - oStrModel := QStringListModel() - oStrModel:setStringList( oStrList ) - + oStrModel := QStringListModel( oStrList, oListBox ) + oListBox:setModel( oStrModel ) oListBox:Move( aPos[ 1 ], aPos[ 2 ] ) oListBox:ReSize( aSize[ 1 ], aSize[ 2 ] ) oListBox:Show() - RETURN { oStrList, oStrModel, oListBox } + RETURN NIL /*----------------------------------------------------------------------*/ @@ -449,7 +449,7 @@ STATIC FUNCTION Build_TextBox( oWnd ) oTextBox:setPlainText( "This is Harbour QT implementation" ) oTextBox:Show() - RETURN oTextBox + RETURN NIL /*----------------------------------------------------------------------*/ @@ -493,7 +493,7 @@ STATIC FUNCTION Build_Controls( oWnd ) oRadioButton:ReSize( 345, 30 ) oRadioButton:Show() - RETURN { oEdit, oComboBox, oCheckBox, oSpinBox, oRadioButton } + RETURN { oEdit, oComboBox, oCheckBox, oRadioButton } /*----------------------------------------------------------------------*/ @@ -507,7 +507,7 @@ STATIC FUNCTION Build_ProgressBar( oWnd, aPos, aSize ) oProgressBar:ReSize( aSize[ 1 ], aSize[ 2 ] ) oProgressBar:Show() - RETURN oProgressBar + RETURN NIL /*----------------------------------------------------------------------*/ @@ -521,7 +521,7 @@ STATIC FUNCTION Build_Label( oWnd, aPos, aSize ) oLabel:ReSize( aSize[ 1 ], aSize[ 2 ] ) oLabel:Show() - RETURN oLabel + RETURN NIL /*----------------------------------------------------------------------*/