2012-06-14 14:43 UTC+0200 Francesco Perillo ( fperillo at gmail.com )
* contrib/hbqt/qtcore/hbqt_pointer.cpp
* contrib/hbqt/qtcore/hbqt_hbqslots.cpp
* contrib/hbqt/qtcore/hbqt_misc.prg
* Moved: all slots related functions from hbqt_pointer to hbqt_hbqslots
.cpp.
- Removed: __pSlots variable and use of harbour class HBQSlots
Partially implemented hbqt_disconnect function
hbqt_connect now also accepts harbour style
(qtObject, signal, codeblock).
It is the preferred way of making a signal/slot connection...
- contrib/hbqt/qtcore/qth/HBQSlots.qth
* contrib/hbqt/qtcore/qth/filelist.hbm
* removed generated harbour HBQSlots class
This commit is contained in:
@@ -16,6 +16,20 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2012-06-14 14:43 UTC+0200 Francesco Perillo ( fperillo at gmail.com )
|
||||
* contrib/hbqt/qtcore/hbqt_pointer.cpp
|
||||
* contrib/hbqt/qtcore/hbqt_hbqslots.cpp
|
||||
* contrib/hbqt/qtcore/hbqt_misc.prg
|
||||
* Moved: all slots related functions from hbqt_pointer to hbqt_hbqslots.cpp.
|
||||
- Removed: __pSlots variable and use of harbour class HBQSlots
|
||||
Partially implemented hbqt_disconnect function
|
||||
hbqt_connect now also accepts harbour style (qtObject, signal, codeblock).
|
||||
It is the preferred way of making a signal/slot connection...
|
||||
|
||||
- contrib/hbqt/qtcore/qth/HBQSlots.qth
|
||||
* contrib/hbqt/qtcore/qth/filelist.hbm
|
||||
* removed generated harbour HBQSlots class
|
||||
|
||||
2012-06-14 15:20 UTC+0200 Viktor Szakats (vszakats syenar.net)
|
||||
* package/winuni/mpkg_win_uni.bat
|
||||
* package/winuni/mpkg_win_uni.nsi
|
||||
|
||||
@@ -57,21 +57,21 @@
|
||||
#include "hbqt.h"
|
||||
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
#if QT_VERSION >= 0x040500
|
||||
|
||||
#include "hbqt_hbqslots.h"
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
static QList<QByteArray> s_argCombinations;
|
||||
static QList<PHBQT_SLOT_FUNC> s_pCallback;
|
||||
|
||||
static HBQSlots * receiverSlot = NULL;
|
||||
|
||||
void hbqt_slots_register_callback( QByteArray sig, PHBQT_SLOT_FUNC pCallback )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "callback %s", ( char * ) sig.data() ) );
|
||||
@@ -112,7 +112,7 @@ HBQSlots::HBQSlots() : QObject()
|
||||
|
||||
HBQSlots::~HBQSlots()
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::~HBQSlots()" ) );
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "HBQSlots::~HBQSlots()" ) );
|
||||
}
|
||||
|
||||
int HBQSlots::hbConnect( PHB_ITEM pObj, char * pszSignal, PHB_ITEM bBlock )
|
||||
@@ -121,56 +121,53 @@ int HBQSlots::hbConnect( PHB_ITEM pObj, char * pszSignal, PHB_ITEM bBlock )
|
||||
|
||||
int nResult = 1;
|
||||
|
||||
if( true )
|
||||
QObject * object = ( QObject * ) hbqt_get_ptr( pObj );
|
||||
if( object )
|
||||
{
|
||||
QObject * object = ( QObject * ) hbqt_get_ptr( pObj );
|
||||
if( object )
|
||||
if( hb_itemType( bBlock ) & HB_IT_BLOCK )
|
||||
{
|
||||
if( hb_itemType( bBlock ) & HB_IT_BLOCK )
|
||||
int i = object->property( pszSignal ).toInt();
|
||||
if( i == 0 )
|
||||
{
|
||||
int i = object->property( pszSignal ).toInt();
|
||||
if( i == 0 )
|
||||
QString signal = pszSignal;
|
||||
QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() );
|
||||
|
||||
if( QMetaObject::checkConnectArgs( theSignal, theSignal ) )
|
||||
{
|
||||
QString signal = pszSignal;
|
||||
QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() );
|
||||
|
||||
if( QMetaObject::checkConnectArgs( theSignal, theSignal ) )
|
||||
int signalId = object->metaObject()->indexOfSignal( theSignal );
|
||||
if( signalId != -1 )
|
||||
{
|
||||
int signalId = object->metaObject()->indexOfSignal( theSignal );
|
||||
if( signalId != -1 )
|
||||
int slotId = object->metaObject()->indexOfMethod( theSignal );
|
||||
if( slotId != -1 )
|
||||
{
|
||||
int slotId = object->metaObject()->indexOfMethod( theSignal );
|
||||
if( slotId != -1 )
|
||||
if( QMetaObject::connect( object, signalId, this, slotId + QObject::staticMetaObject.methodCount(), Qt::AutoConnection ) )
|
||||
{
|
||||
if( QMetaObject::connect( object, signalId, this, slotId + QObject::staticMetaObject.methodCount(), Qt::AutoConnection ) )
|
||||
{
|
||||
nResult = 0;
|
||||
nResult = 0;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbConnect( %s ) signalId=%i, %p", pszSignal, signalId, object ) );
|
||||
hbqt_bindAddSlot( pObj, signalId, bBlock );
|
||||
}
|
||||
else
|
||||
nResult = 8;
|
||||
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbConnect( %s ) signalId=%i, %p", pszSignal, signalId, object ) );
|
||||
hbqt_bindAddSlot( pObj, signalId, bBlock );
|
||||
}
|
||||
else
|
||||
nResult = 7;
|
||||
nResult = 8;
|
||||
}
|
||||
else
|
||||
nResult = 6;
|
||||
nResult = 7;
|
||||
}
|
||||
else
|
||||
nResult = 5;
|
||||
nResult = 6;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nResult = 3;
|
||||
else
|
||||
nResult = 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
nResult = 2;
|
||||
{
|
||||
nResult = 3;
|
||||
}
|
||||
}
|
||||
HB_TRACE( HB_TR_DEBUG, ( "HBQT_SLOTS_CONNECT returns: %d", nResult ) );
|
||||
else
|
||||
nResult = 2;
|
||||
|
||||
return nResult;
|
||||
}
|
||||
|
||||
@@ -191,7 +188,7 @@ int HBQSlots::hbDisconnect( PHB_ITEM pObj, char * pszSignal )
|
||||
{
|
||||
if( QMetaObject::disconnect( object, signalId, 0, 0 ) )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbDisconnect( %s ) %i", pszSignal, i ) );
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "HBQSlots::hbDisconnect( %s ) signalId=%d", pszSignal, signalId ) );
|
||||
nResult = 0;
|
||||
}
|
||||
else
|
||||
@@ -212,12 +209,26 @@ int HBQSlots::hbDisconnect( PHB_ITEM pObj, char * pszSignal )
|
||||
return nResult;
|
||||
}
|
||||
|
||||
int HBQSlots::hbDisconnectAll( PHB_ITEM pObj )
|
||||
{
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "DISCONNECTALL" ) );
|
||||
|
||||
QObject * object = ( QObject * ) hbqt_get_ptr( pObj );
|
||||
if( object )
|
||||
{
|
||||
QObject::disconnect();
|
||||
return HB_TRUE;
|
||||
}
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "qt_metacall" ) );
|
||||
QObject * object = sender();
|
||||
if( object )
|
||||
{
|
||||
@@ -260,7 +271,7 @@ int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments )
|
||||
|
||||
object->setProperty( szPList, pList );
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( " SlotsProxy parList %s ", ( char * ) paramString.data() ) );
|
||||
HB_TRACE( HB_TR_ALWAYS, ( " SlotsProxy parList %s ", ( char * ) paramString.data() ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -292,6 +303,173 @@ int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments )
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int hbqt_QtConnect( QObject *sender, const char * pszSignal, QObject *receiver, const char * pszSlot )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "_Connect %s with slot %s", pszSignal, pszSlot ) );
|
||||
|
||||
int nResult = 1;
|
||||
|
||||
if( sender && receiver )
|
||||
{
|
||||
QString signal = pszSignal;
|
||||
QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() );
|
||||
QString slot = pszSlot;
|
||||
QByteArray theSlot = QMetaObject::normalizedSignature( slot.toAscii() );
|
||||
|
||||
if( QMetaObject::checkConnectArgs( theSignal, theSlot ) )
|
||||
{
|
||||
int signalId = sender->metaObject()->indexOfSignal( theSignal );
|
||||
if( signalId != -1 )
|
||||
{
|
||||
int slotId = receiver->metaObject()->indexOfMethod( theSlot );
|
||||
if( slotId != -1 )
|
||||
{
|
||||
if( QMetaObject::connect( sender, signalId, receiver, slotId, Qt::AutoConnection ) )
|
||||
{
|
||||
nResult = 0;
|
||||
HB_TRACE( HB_TR_DEBUG, ( "SIGNAL2SLOT ok" ) );
|
||||
}
|
||||
else
|
||||
nResult = 8;
|
||||
}
|
||||
else
|
||||
nResult = 7;
|
||||
}
|
||||
else
|
||||
nResult = 6;
|
||||
}
|
||||
else
|
||||
nResult = 5;
|
||||
}
|
||||
else
|
||||
nResult = 9; // Qt objects not active
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "_Connect returns: %d", nResult ) );
|
||||
return nResult;
|
||||
}
|
||||
|
||||
int hbqt_QtDisconnect( QObject *sender, const char * pszSignal, QObject *receiver, const char * pszSlot )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hbqt_QtDisconnect %s with slot %s", pszSignal, pszSlot ) );
|
||||
|
||||
int nResult = 1;
|
||||
|
||||
if( sender && receiver )
|
||||
{
|
||||
QString signal = pszSignal;
|
||||
QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() );
|
||||
QString slot = pszSlot;
|
||||
QByteArray theSlot = QMetaObject::normalizedSignature( slot.toAscii() );
|
||||
|
||||
if( QMetaObject::checkConnectArgs( theSignal, theSlot ) )
|
||||
{
|
||||
int signalId = sender->metaObject()->indexOfSignal( theSignal );
|
||||
if( signalId != -1 )
|
||||
{
|
||||
int slotId = receiver->metaObject()->indexOfMethod( theSlot );
|
||||
if( slotId != -1 )
|
||||
{
|
||||
if( QMetaObject::disconnect( sender, signalId, receiver, slotId ) )
|
||||
{
|
||||
nResult = 0;
|
||||
HB_TRACE( HB_TR_DEBUG, ( "SIGNAL2SLOT ok" ) );
|
||||
}
|
||||
else
|
||||
nResult = 8;
|
||||
}
|
||||
else
|
||||
nResult = 7;
|
||||
}
|
||||
else
|
||||
nResult = 6;
|
||||
}
|
||||
else
|
||||
nResult = 5;
|
||||
}
|
||||
else
|
||||
nResult = 9; // Qt objects not active
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hbqt_QtDisconnect returns: %d", nResult ) );
|
||||
return nResult;
|
||||
}
|
||||
|
||||
/* HBQT_CONNECT handles now two types of connection, one Qt based, one HB based:
|
||||
|
||||
Qt: HBQT_CONNECT( object, signal, object, string )
|
||||
HB: HBQT_CONNECT( object, signal, codeblock )
|
||||
*/
|
||||
HB_FUNC( HBQT_CONNECT )
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if( hb_pcount() == 4 && HB_ISCHAR( 2 ) && HB_ISCHAR( 4 ) && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) && hbqt_par_isDerivedFrom( 3, "QOBJECT" ) )
|
||||
{
|
||||
void * pText01 = NULL;
|
||||
void * pText02 = NULL;
|
||||
ret = hbqt_QtConnect( ( QObject* ) hbqt_par_ptr( 1 ), hb_parstr_utf8( 2, &pText01, NULL ), ( QObject* ) hbqt_par_ptr( 3 ), hb_parstr_utf8( 4, &pText02, NULL ) );
|
||||
hb_strfree( pText01 );
|
||||
hb_strfree( pText02 );
|
||||
}
|
||||
else if( hb_pcount() == 3 && HB_ISCHAR( 2 ) && HB_ISBLOCK( 3 ) && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) )
|
||||
{
|
||||
void * pText01 = NULL;
|
||||
ret = receiverSlot->hbConnect( hb_param( 1, HB_IT_OBJECT ), ( char * ) hb_parstr_utf8( 2, &pText01, NULL ), hb_param( 3, HB_IT_BLOCK ) );
|
||||
hb_strfree( pText01 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
hb_retni( ret );
|
||||
}
|
||||
|
||||
HB_FUNC( HBQT_DISCONNECT )
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if( hb_pcount() == 2 && HB_ISCHAR( 2 ) && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) )
|
||||
{
|
||||
void * pText01 = NULL;
|
||||
ret = receiverSlot->hbDisconnect( hb_param( 1, HB_IT_OBJECT ), (char *) hb_parstr_utf8( 2, &pText01, NULL ) ) == 0;
|
||||
hb_strfree( pText01 );
|
||||
}
|
||||
else
|
||||
{
|
||||
hb_errRT_BASE( EG_ARG, 9999, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
hb_retni( ret );
|
||||
}
|
||||
|
||||
static void hbqt_lib_init( void * cargo )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "Slots: hbqt_lib_init" ) );
|
||||
if( receiverSlot == NULL )
|
||||
receiverSlot = new HBQSlots;
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "Slots: hbqt_lib_init" ) );
|
||||
}
|
||||
|
||||
static void hbqt_lib_exit( void* cargo )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( cargo );
|
||||
HB_TRACE( HB_TR_ALWAYS, ( "Exiting slots lib" ) );
|
||||
|
||||
if( receiverSlot )
|
||||
delete receiverSlot;
|
||||
}
|
||||
|
||||
HB_CALL_ON_STARTUP_BEGIN( _hbqtslots_init_ )
|
||||
hb_vmAtInit( hbqt_lib_init, NULL );
|
||||
hb_vmAtExit( hbqt_lib_exit, NULL );
|
||||
HB_CALL_ON_STARTUP_END( _hbqtslots_init_ )
|
||||
|
||||
#if defined( HB_PRAGMA_STARTUP )
|
||||
#pragma startup _hbqtslots_init_
|
||||
#elif defined( HB_DATASEG_STARTUP )
|
||||
#define HB_DATASEG_BODY HB_DATASEG_FUNC( _hbqtslots_init_ )
|
||||
#include "hbiniseg.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -76,6 +76,7 @@ public:
|
||||
|
||||
int hbConnect( PHB_ITEM obj, char * pszSignal, PHB_ITEM block );
|
||||
int hbDisconnect( PHB_ITEM obj, char * pszSignal );
|
||||
int hbDisconnectAll( PHB_ITEM obj );
|
||||
|
||||
int qt_metacall( QMetaObject::Call call, int id, void **arguments );
|
||||
};
|
||||
|
||||
@@ -58,24 +58,25 @@
|
||||
|
||||
CREATE CLASS HbQtObjectHandler
|
||||
|
||||
/* QUESTION: _three_ different lists for events? two for slots? Is this needed? */
|
||||
/* ANSWER : these variables hold the objects which capture and fire the relative signal/event */
|
||||
/* __pSlots removed */
|
||||
|
||||
VAR __pSlots PROTECTED
|
||||
/* __pEvents is used for event handling */
|
||||
VAR __pEvents PROTECTED
|
||||
|
||||
VAR __hEvents PROTECTED INIT { => }
|
||||
|
||||
VAR __Slots /* TOFIX: add PROTECTED or clean this mess ANS: It is like this by design, cannot be made PROTECTED */
|
||||
VAR __Events /* TOFIX: add PROTECTED or clean this mess */
|
||||
/* The following two variables are PUBLIC */
|
||||
VAR __Slots
|
||||
VAR __Events
|
||||
|
||||
METHOD connect( cnEvent, bBlock )
|
||||
METHOD disconnect( cnEvent )
|
||||
METHOD disconnectAll()
|
||||
METHOD setSlots()
|
||||
METHOD setEvents()
|
||||
|
||||
DESTRUCTOR __destroy()
|
||||
ERROR HANDLER onError()
|
||||
ERROR HANDLER onError( cMsg )
|
||||
|
||||
ENDCLASS
|
||||
|
||||
@@ -103,10 +104,14 @@ METHOD HbQtObjectHandler:setEvents()
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbQtObjectHandler:onError()
|
||||
LOCAL cMsg := __GetMessage()
|
||||
METHOD HbQtObjectHandler:onError( cMsg )
|
||||
LOCAL oError
|
||||
LOCAL nCallStack := 1
|
||||
|
||||
IF ! hb_isChar( cMsg )
|
||||
cMsg := __GetMessage()
|
||||
nCallStack := 0
|
||||
ENDIF
|
||||
IF SubStr( cMsg, 1, 1 ) == "_"
|
||||
cMsg := SubStr( cMsg, 2 )
|
||||
ENDIF
|
||||
@@ -121,7 +126,7 @@ METHOD HbQtObjectHandler:onError()
|
||||
oError:canRetry := .F.
|
||||
oError:canDefault := .F.
|
||||
oError:Args := hb_AParams()
|
||||
oError:operation := ProcName()
|
||||
oError:operation := ProcName( nCallStack )
|
||||
oError:Description := cMsg
|
||||
|
||||
Eval( ErrorBlock(), oError )
|
||||
@@ -134,6 +139,7 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock )
|
||||
LOCAL nResult
|
||||
|
||||
IF ! __objDerivedFrom( Self, "QOBJECT" )
|
||||
HB_TRACE( HB_TR_ALWAYS, "REFUSED CONNECT ", Self:className() )
|
||||
RETURN .f.
|
||||
ENDIF
|
||||
|
||||
@@ -145,18 +151,14 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock )
|
||||
IF HB_ISNUMERIC( ::__hEvents[ cnEvent ] )
|
||||
::__pEvents:hbDisconnect( Self, cnEvent )
|
||||
ELSE
|
||||
::__pSlots:hbDisconnect( Self, cnEvent )
|
||||
hbqt_disconnect( Self, cnEvent )
|
||||
ENDIF
|
||||
hb_hDel( ::__hEvents, cnEvent )
|
||||
ENDIF
|
||||
|
||||
SWITCH ValType( cnEvent )
|
||||
CASE "C"
|
||||
IF Empty( ::__pSlots )
|
||||
::__pSlots := HBQSlots()
|
||||
ENDIF
|
||||
nResult := ::__pSlots:hbconnect( Self, cnEvent, bBlock )
|
||||
|
||||
nResult := hbqt_connect( Self, cnEvent, bBlock )
|
||||
SWITCH nResult
|
||||
CASE 0
|
||||
::__hEvents[ cnEvent ] := cnEvent
|
||||
@@ -171,6 +173,7 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock )
|
||||
::__pEvents := HBQEvents()
|
||||
::__pEvents:hbInstallEventFilter( Self )
|
||||
ENDIF
|
||||
HB_TRACE( HB_TR_ALWAYS, " _HbQtObjectHandler:connect valtype __pEvents object=", Self:className() )
|
||||
nResult := ::__pEvents:hbConnect( Self, cnEvent, bBlock )
|
||||
|
||||
SWITCH nResult
|
||||
@@ -187,62 +190,72 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock )
|
||||
|
||||
ENDSWITCH
|
||||
|
||||
HB_TRACE( HB_TR_ALWAYS, "Errore in connect " + hb_ntos( nResult ) )
|
||||
|
||||
__hbqt_error( 1200 + nResult )
|
||||
RETURN .F.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbQtObjectHandler:disconnectAll()
|
||||
RETURN .T.
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
METHOD HbQtObjectHandler:disconnect( cnEvent )
|
||||
LOCAL nResult := 0
|
||||
|
||||
IF ! __objDerivedFrom( Self, "QOBJECT" )
|
||||
RETURN .f.
|
||||
RETURN .F.
|
||||
ENDIF
|
||||
|
||||
IF ! hb_hHasKey( ::__hEvents, cnEvent )
|
||||
RETURN .f.
|
||||
ENDIF
|
||||
|
||||
SWITCH ValType( cnEvent )
|
||||
CASE "C"
|
||||
IF ! empty( ::__pSlots )
|
||||
nResult := ::__pSlots:hbDisconnect( Self, cnEvent )
|
||||
ENDIF
|
||||
IF PCOUNT() == 0
|
||||
// ::disconnectAll()
|
||||
RETURN .T.
|
||||
ELSE
|
||||
SWITCH ValType( cnEvent )
|
||||
CASE "C"
|
||||
nResult := hbqt_disconnect( Self, cnEvent )
|
||||
|
||||
SWITCH nResult
|
||||
CASE 0
|
||||
CASE 4 /* signal not found in object */
|
||||
CASE 5 /* disconnect failure */
|
||||
SWITCH nResult
|
||||
CASE 0
|
||||
CASE 4 /* signal not found in object */
|
||||
CASE 5 /* disconnect failure */
|
||||
hb_hDel( ::__hEvents, cnEvent )
|
||||
RETURN .T.
|
||||
CASE 1 /* wrong slot container, no connect was called yet */
|
||||
CASE 2 /* object has been already freed */
|
||||
CASE 3 /* event not found */
|
||||
RETURN .F.
|
||||
ENDSWITCH
|
||||
EXIT
|
||||
RETURN .T.
|
||||
CASE 1 /* wrong slot container, no connect was called yet */
|
||||
CASE 2 /* object has been already freed */
|
||||
CASE 3 /* event not found */
|
||||
RETURN .F.
|
||||
ENDSWITCH
|
||||
EXIT
|
||||
|
||||
CASE "N"
|
||||
IF ! empty( ::__pEvents )
|
||||
nResult := ::__pEvents:hbdisconnect( Self, cnEvent )
|
||||
ENDIF
|
||||
CASE "N"
|
||||
IF ! empty( ::__pEvents )
|
||||
nResult := ::__pEvents:hbdisconnect( Self, cnEvent )
|
||||
ENDIF
|
||||
|
||||
SWITCH nResult
|
||||
CASE 0
|
||||
SWITCH nResult
|
||||
CASE 0
|
||||
hb_hDel( ::__hEvents, cnEvent )
|
||||
RETURN .T.
|
||||
CASE -3 /* event not found */
|
||||
CASE -2 /* event not found */
|
||||
CASE -1 /* event not found */
|
||||
RETURN .F.
|
||||
RETURN .T.
|
||||
CASE -3 /* event not found */
|
||||
CASE -2 /* event not found */
|
||||
CASE -1 /* event not found */
|
||||
RETURN .F.
|
||||
ENDSWITCH
|
||||
EXIT
|
||||
|
||||
OTHERWISE
|
||||
nResult := 99
|
||||
|
||||
ENDSWITCH
|
||||
EXIT
|
||||
|
||||
OTHERWISE
|
||||
nResult := 99
|
||||
|
||||
ENDSWITCH
|
||||
|
||||
ENDIF
|
||||
HB_TRACE( HB_TR_ALWAYS, "Errore in disconnect nResult="+str(nResult) )
|
||||
__hbqt_error( 1300 + nResult )
|
||||
RETURN .F.
|
||||
|
||||
@@ -250,7 +263,7 @@ METHOD HbQtObjectHandler:disconnect( cnEvent )
|
||||
|
||||
METHOD HbQtObjectHandler:__destroy()
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, " __destroy()", __objDerivedFrom( Self, "QOBJECT" ), __objGetClsName( Self ) )
|
||||
HB_TRACE( HB_TR_ALWAYS, " _destroy()", __objDerivedFrom( Self, "QOBJECT" ), __objGetClsName( Self ) )
|
||||
|
||||
__hbqt_destroy( Self )
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ PHB_ITEM hbqt_defineClassBegin( const char * pszClsName, PHB_ITEM s_oClass, cons
|
||||
/* array with parent classes (at least ONE) */
|
||||
hb_arrayNew( pSuper, 0 );
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ("%s: dCB 3", pszClsName ) );
|
||||
HB_TRACE( HB_TR_ALWAYS, ("%s: dCB 3", pszClsName ) );
|
||||
|
||||
while( pszParentClsStr[ nPos++ ] )
|
||||
{
|
||||
@@ -241,67 +241,13 @@ HB_BOOL hbqt_par_isDerivedFrom( int iParam, const char * pszClsName )
|
||||
return HB_FALSE;
|
||||
}
|
||||
|
||||
int hbqt_QtConnect( QObject *sender, const char * pszSignal, QObject *receiver, const char * pszSlot )
|
||||
HB_FUNC( HBQT_REALCLASS )
|
||||
{
|
||||
HB_TRACE( HB_TR_DEBUG, ( "_Connect %s with slot %s", pszSignal, pszSlot ) );
|
||||
void * oObject;
|
||||
|
||||
int nResult = 1;
|
||||
oObject = hbqt_par_ptr( 1 );
|
||||
|
||||
if( sender && receiver )
|
||||
{
|
||||
QString signal = pszSignal;
|
||||
QByteArray theSignal = QMetaObject::normalizedSignature( signal.toAscii() );
|
||||
QString slot = pszSlot;
|
||||
QByteArray theSlot = QMetaObject::normalizedSignature( slot.toAscii() );
|
||||
|
||||
if( QMetaObject::checkConnectArgs( theSignal, theSlot ) )
|
||||
{
|
||||
int signalId = sender->metaObject()->indexOfSignal( theSignal );
|
||||
if( signalId != -1 )
|
||||
{
|
||||
int slotId = receiver->metaObject()->indexOfMethod( theSlot );
|
||||
if( slotId != -1 )
|
||||
{
|
||||
if( QMetaObject::connect( sender, signalId, receiver, slotId, Qt::AutoConnection ) )
|
||||
{
|
||||
nResult = 0;
|
||||
HB_TRACE( HB_TR_DEBUG, ( "SIGNAL2SLOT ok" ) );
|
||||
}
|
||||
else
|
||||
nResult = 8;
|
||||
}
|
||||
else
|
||||
nResult = 7;
|
||||
}
|
||||
else
|
||||
nResult = 6;
|
||||
}
|
||||
else
|
||||
nResult = 5;
|
||||
}
|
||||
else
|
||||
nResult = 9; // Qt objects not active
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "_Connect returns: %d", nResult ) );
|
||||
return nResult;
|
||||
}
|
||||
|
||||
HB_FUNC( HBQT_CONNECT )
|
||||
{
|
||||
HB_BOOL ret = HB_FALSE;
|
||||
|
||||
if( hb_pcount() == 4 && HB_ISCHAR( 2 ) && HB_ISCHAR( 4 ) && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) && hbqt_par_isDerivedFrom( 3, "QOBJECT" ) )
|
||||
{
|
||||
void * pText01 = NULL;
|
||||
void * pText02 = NULL;
|
||||
if( hbqt_QtConnect( ( QObject* ) hbqt_par_ptr( 1 ), hb_parstr_utf8( 2, &pText01, NULL ), ( QObject* ) hbqt_par_ptr( 3 ), hb_parstr_utf8( 4, &pText02, NULL ) ) == 0 )
|
||||
{
|
||||
ret = HB_TRUE;
|
||||
}
|
||||
hb_strfree( pText01 );
|
||||
hb_strfree( pText02 );
|
||||
}
|
||||
hb_retl( ret );
|
||||
hb_retc( ( ( QObject * ) oObject )->metaObject()->className() ) ;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Qt wrapper generator control file
|
||||
*
|
||||
* Copyright 2009-2012 Pritpal Bedi <bedipritpal@hotmail.com>
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* See COPYING for licensing terms.
|
||||
*/
|
||||
|
||||
<CLASS>
|
||||
QObject =
|
||||
Inherit = QObject
|
||||
Type =
|
||||
New =
|
||||
</CLASS>
|
||||
|
||||
<SUBCLASS>
|
||||
</SUBCLASS>
|
||||
|
||||
<DOC>
|
||||
</DOC>
|
||||
|
||||
<CODE>
|
||||
#include <QtCore/QObject>
|
||||
#include "hbqt_hbqslots.h"
|
||||
|
||||
/*
|
||||
* HBQSlots ()
|
||||
* ~HBQSlots ()
|
||||
*/
|
||||
HB_FUNC( QT_HBQSLOTS )
|
||||
{
|
||||
__HB_RETPTRGC__( new HBQSlots() );
|
||||
}
|
||||
</CODE>
|
||||
|
||||
<ENUMS>
|
||||
</ENUMS>
|
||||
|
||||
<PROTOS>
|
||||
int hbConnect( PHB_ITEM obj, char * event, PHB_ITEM block )
|
||||
int hbDisconnect( PHB_ITEM obj, char * event )
|
||||
</PROTOS>
|
||||
|
||||
<SLOTS>
|
||||
</SLOTS>
|
||||
|
||||
<SIGNALS>
|
||||
</SIGNALS>
|
||||
@@ -7,7 +7,6 @@
|
||||
-pflag=-qthdocdir=../doc/
|
||||
|
||||
HBQEvents.qth
|
||||
HBQSlots.qth
|
||||
HBQString.qth
|
||||
|
||||
# QAbstractEventDispatcher.qth
|
||||
|
||||
@@ -180,9 +180,7 @@ PROCEDURE ExecOneMore()
|
||||
oWnd:setStatusBar( oSBar )
|
||||
oSBar:showMessage( "Harbour-QT Statusbar Ready!" )
|
||||
|
||||
oWnd:connect( QEvent_Close , {|| lExit := .t. } )
|
||||
oEventLoop := QEventLoop( oWnd )
|
||||
|
||||
DO WHILE .t.
|
||||
oEventLoop:processEvents()
|
||||
IF lExit
|
||||
@@ -195,7 +193,7 @@ PROCEDURE ExecOneMore()
|
||||
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
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user