From 01620881006984de8d1a8530e6a7108f96dd59c1 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 25 Oct 2010 08:58:09 +0000 Subject: [PATCH] 2010-10-25 01:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/hbqt.h * contrib/hbqt/qtcore/hbqt_hbqslots.cpp + contrib/hbqt/qtcore/hbqt_registersignals.cpp * contrib/hbqt/qtcore/hbqtcore.hbc * contrib/hbqt/qtcore/hbqtcore.hbm * contrib/hbqt/qtcore/hbqtcore.hbx * contrib/hbqt/qtgui/g/QApplication.cpp + contrib/hbqt/qtgui/hbqt_registersignals.cpp * contrib/hbqt/qtgui/hbqtgui.hbm * contrib/hbqt/qtgui/hbqtgui.hbx + contrib/hbqt/qtnetwork/hbqt_registersignals.cpp * contrib/hbqt/qtnetwork/hbqtnetwork.hbm * contrib/hbqt/qtnetwork/hbqtnetwork.hbx + Implemented: module specific signal/slots mechanism. Now each module contains its own signals. The basic patch was forwarded by Viktor, cheer him. * contrib/hbide/idemain.prg + Added: REQUEST __HBQT_REGISTERCORECALLBACKS REQUEST __HBQT_REGISTERGUICALLBACKS REQUEST __HBQT_REGISTERNETWORKCALLBACKS I know this is a hack and can be removed once this new protocol is fine tuned, so, so long. --- harbour/ChangeLog | 25 + harbour/contrib/hbide/idemain.prg | 4 + harbour/contrib/hbqt/qtcore/hbqt.h | 4 + harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp | 725 +++++++----------- .../hbqt/qtcore/hbqt_registersignals.cpp | 335 ++++++++ harbour/contrib/hbqt/qtcore/hbqtcore.hbc | 9 +- harbour/contrib/hbqt/qtcore/hbqtcore.hbm | 1 + harbour/contrib/hbqt/qtcore/hbqtcore.hbx | 1 + harbour/contrib/hbqt/qtgui/g/QApplication.cpp | 2 +- .../hbqt/qtgui/hbqt_registersignals.cpp | 156 ++++ harbour/contrib/hbqt/qtgui/hbqtgui.hbm | 1 + harbour/contrib/hbqt/qtgui/hbqtgui.hbx | 1 + .../hbqt/qtnetwork/hbqt_registersignals.cpp | 136 ++++ .../contrib/hbqt/qtnetwork/hbqtnetwork.hbm | 3 + .../contrib/hbqt/qtnetwork/hbqtnetwork.hbx | 1 + 15 files changed, 950 insertions(+), 454 deletions(-) create mode 100644 harbour/contrib/hbqt/qtcore/hbqt_registersignals.cpp create mode 100644 harbour/contrib/hbqt/qtgui/hbqt_registersignals.cpp create mode 100644 harbour/contrib/hbqt/qtnetwork/hbqt_registersignals.cpp diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f64886ac55..3bbcd5bcfc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,31 @@ The license applies to all entries newer than 2009-04-28. */ +2010-10-25 01:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qtcore/hbqt.h + * contrib/hbqt/qtcore/hbqt_hbqslots.cpp + + contrib/hbqt/qtcore/hbqt_registersignals.cpp + * contrib/hbqt/qtcore/hbqtcore.hbc + * contrib/hbqt/qtcore/hbqtcore.hbm + * contrib/hbqt/qtcore/hbqtcore.hbx + * contrib/hbqt/qtgui/g/QApplication.cpp + + contrib/hbqt/qtgui/hbqt_registersignals.cpp + * contrib/hbqt/qtgui/hbqtgui.hbm + * contrib/hbqt/qtgui/hbqtgui.hbx + + contrib/hbqt/qtnetwork/hbqt_registersignals.cpp + * contrib/hbqt/qtnetwork/hbqtnetwork.hbm + * contrib/hbqt/qtnetwork/hbqtnetwork.hbx + + Implemented: module specific signal/slots mechanism. + Now each module contains its own signals. The basic + patch was forwarded by Viktor, cheer him. + + * contrib/hbide/idemain.prg + + Added: REQUEST __HBQT_REGISTERCORECALLBACKS + REQUEST __HBQT_REGISTERGUICALLBACKS + REQUEST __HBQT_REGISTERNETWORKCALLBACKS + I know this is a hack and can be removed once this new protocol + is fine tuned, so, so long. + 2010-10-24 13:31 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/hbqt_hbqslots.cpp - Disabled: QtNetwork module related signals. diff --git a/harbour/contrib/hbide/idemain.prg b/harbour/contrib/hbide/idemain.prg index ccd5e40515..b27082a658 100644 --- a/harbour/contrib/hbide/idemain.prg +++ b/harbour/contrib/hbide/idemain.prg @@ -86,6 +86,10 @@ REQUEST __HBEXTERN__HBQTCORE__ REQUEST __HBEXTERN__HBQTGUI__ REQUEST __HBEXTERN__HBQTNETWORK__ +REQUEST __HBQT_REGISTERCORECALLBACKS +REQUEST __HBQT_REGISTERGUICALLBACKS +REQUEST __HBQT_REGISTERNETWORKCALLBACKS + /*----------------------------------------------------------------------*/ REQUEST HB_QTGUI diff --git a/harbour/contrib/hbqt/qtcore/hbqt.h b/harbour/contrib/hbqt/qtcore/hbqt.h index de91724e7d..f972ff6794 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt.h +++ b/harbour/contrib/hbqt/qtcore/hbqt.h @@ -83,8 +83,12 @@ typedef struct unsigned int type; } HBQT_GC_T; +typedef void ( * PHBQT_SLOT_FUNC )( PHB_ITEM * codeblock, void ** arguments ); + HB_EXTERN_BEGIN +extern HB_EXPORT void hbqt_slots_register_callback( QByteArray sig, PHBQT_SLOT_FUNC pCallback ); +extern HB_EXPORT void hbqt_slots_unregister_callback( QByteArray sig ); extern HB_EXPORT void * hbqt_gcpointer( int iParam ); extern HB_EXPORT void * hbqt_detachgcpointer( int iParam ); extern HB_EXPORT const HB_GC_FUNCS * hbqt_gcFuncs( void ); diff --git a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp index 73e4c5c212..c01e432b26 100644 --- a/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp +++ b/harbour/contrib/hbqt/qtcore/hbqt_hbqslots.cpp @@ -65,10 +65,12 @@ #include "hbqt_hbqslots.h" -#include - /*----------------------------------------------------------------------*/ +#include + +#if 0 + #include #include #include @@ -77,340 +79,192 @@ #include #include #include +#include -/* TOFIX: QtGui components should not be accessed from this component */ -#include -#include -#include -#include -#include - -#if 0 /* Disabled until dynamic registration protocol is not implemented */ -#include -#include -#include -#include -#endif - -/*----------------------------------------------------------------------*/ - -#define SIG_int "int" // 0 -#define SIG_int_int "int$int" // 1 -#define SIG_int_int_int "int$int$int" // 2 -#define SIG_int_int_int_int "int$int$int$int" // 3 -#define SIG_bool "bool" // 4 -#define SIG_QRect_int "QRect$int" // 5 -#define SIG_QString "QString" // 6 -#define SIG_QModelIndex "QModelIndex" // 7 -#define SIG_QModelIndex_QModelIndex "QModelIndex$QModelIndex" // 8 -#define SIG_QItemSelection_QItemSelection "QItemSelection$QItemSelection" // 9 -#define SIG_QTextCharFormat "QTextCharFormat" // 10 -#define SIG_QFont "QFont" // 11 -#define SIG_QTextCursor "QTextCursor" // 12 -#define SIG_QStringList "QStringList" // 13 -#define SIG_pointer "pointer" // 14 -#define SIG_pointer_pointer "pointer$pointer" // 15 -#define SIG_pointer_int "pointer$int" // 16 -#define SIG_QDate "QDate" // 17 -#define SIG_QDateTime "QDateTime" // 18 -#define SIG_QPoint "QPoint" // 19 -#define SIG_QRectF "QRectF" // 20 -#define SIG_QTime "QTime" // 21 -#define SIG_QUrl "QUrl" // 22 -#define SIG_QModelIndex_int_int "QModelIndex$int$int" // 23 -#define SIG_qint64 "qint64" // 24 -#define SIG_qint64_qint64 "qint64$qint64" // 25 -#define SIG_QTextBlock "QTextBlock" // 26 -#define SIG_QSizeF "QSizeF" // 27 -#define SIG_QColor "QColor" // 28 -#define SIG_double "double" // 29 -#define SIG_QModelIndexList "QModelIndexList" // 30 -#define SIG_QRect "QRect" // 31 -#define SIG_int_QString "int$QString" // 32 -#define SIG_QString_quint16_pointer "QString$quint16$pointer" // 33 -#define SIG_int_bool "int$bool" // 34 -#define SIG_pointer_QString "pointer$QString" // 35 -#define SIG_QString_QString_QString "QString$QString$QString" // 36 -#define SIG_int_int_QRect "int$int$QRect" // 37 -#define SIG_QUrlInfo "QUrlInfo" // 38 -#define SIG_QNetworkRequest "QNetworkRequest" // 39 -#define SIG_QNetworkProxy_pointer "QNetworkProxy$pointer" // 40 -#define SIG_QHttpResponseHeader "QHttpResponseHeader" // 41 - -#define S_G_int 0 -#define S_G_int_int 1 -#define S_G_int_int_int 2 -#define S_G_int_int_int_int 3 -#define S_G_bool 4 -#define S_G_QRect_int 5 -#define S_G_QString 6 -#define S_G_QModelIndex 7 -#define S_G_QModelIndex_QModelIndex 8 -#define S_G_QItemSelection_QItemSelection 9 -#define S_G_QTextCharFormat 10 -#define S_G_QFont 11 -#define S_G_QTextCursor 12 -#define S_G_QStringList 13 -#define S_G_pointer 14 -#define S_G_pointer_pointer 15 -#define S_G_pointer_int 16 -#define S_G_QDate 17 -#define S_G_QDateTime 18 -#define S_G_QPoint 19 -#define S_G_QRectF 20 -#define S_G_QTime 21 -#define S_G_QUrl 22 -#define S_G_QModelIndex_int_int 23 -#define S_G_qint64 24 -#define S_G_qint64_qint64 25 -#define S_G_QTextBlock 26 -#define S_G_QSizeF 27 -#define S_G_QColor 28 -#define S_G_double 29 -#define S_G_QModelIndexList 30 -#define S_G_QRect 31 -#define S_G_int_QString 32 -#define S_G_QString_quint16_pointer 33 -#define S_G_int_bool 34 -#define S_G_pointer_QString 35 -#define S_G_QString_QString_QString 36 -#define S_G_int_int_QRect 37 -#define S_G_QUrlInfo 38 -#define S_G_QNetworkRequest 39 -#define S_G_QNetworkProxy_pointer 40 -#define S_G_QHttpResponseHeader 41 - -/*----------------------------------------------------------------------*/ - -static void hbqt_fireSignal( int paramId, PHB_ITEM * codeBlock, void ** arguments ) +static void hbqt_SlotsExecPointer( PHB_ITEM * codeBlock, void ** arguments ) { - int iArgs; - hb_vmPushEvalSym(); hb_vmPush( codeBlock ); - - switch( paramId ) - { - case S_G_int: - iArgs = 1; - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); - break; - case S_G_int_int: - iArgs = 2; - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - break; - case S_G_int_int_int: - iArgs = 3; - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); - break; - case S_G_int_int_int_int: - iArgs = 4; - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 4 ] ) ); - break; - case S_G_bool: - iArgs = 1; - hb_vmPushLogical( *reinterpret_cast< bool( * ) >( arguments[ 1 ] ) ); - break; - case S_G_QRect_int: - iArgs = 2; - hb_vmPushPointer( new QRect( *reinterpret_cast< QRect( * ) >( arguments[ 1 ] ) ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - break; - case S_G_QString: - { - iArgs = 1; - QString text = *reinterpret_cast< QString( * ) >( arguments[ 1 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - } - break; - case S_G_QModelIndex: - iArgs = 1; - hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QModelIndex_QModelIndex: - iArgs = 2; - hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); - hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 2 ] ) ) ) ); - break; - case S_G_QItemSelection_QItemSelection: - iArgs = 2; - hb_vmPushPointer( new QItemSelection( ( *reinterpret_cast< QItemSelection( * )>( arguments[ 1 ] ) ) ) ); - hb_vmPushPointer( new QItemSelection( ( *reinterpret_cast< QItemSelection( * )>( arguments[ 2 ] ) ) ) ); - break; - case S_G_QTextCharFormat: - iArgs = 1; - hb_vmPushPointer( new QTextCharFormat( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); - break; - case S_G_QFont: - iArgs = 1; - hb_vmPushPointer( new QFont( ( *reinterpret_cast< QFont( * )>( arguments[ 1 ] ) ) ) ); - break; - case S_G_QTextCursor: - iArgs = 1; - hb_vmPushPointer( new QTextCursor( ( *reinterpret_cast< QTextCursor( * )>( arguments[ 1 ] ) ) ) ); - break; - case S_G_QStringList: - iArgs = 1; - hb_vmPushPointer( new QStringList( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); - break; - case S_G_pointer: - iArgs = 1; - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); - break; - case S_G_pointer_pointer: - iArgs = 2; - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 2 ] ) ); - break; - case S_G_pointer_int: - iArgs = 2; - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - break; - case S_G_QDate: - iArgs = 1; - hb_vmPushPointer( new QDate( ( *reinterpret_cast< QDate( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QDateTime: - iArgs = 1; - hb_vmPushPointer( new QDateTime( ( *reinterpret_cast< QDateTime( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QPoint: - iArgs = 1; - hb_vmPushPointer( new QPoint( ( * reinterpret_cast< QPoint( * )>( arguments[ 1 ] ) ) ) ); - break; - case S_G_QRectF: - iArgs = 1; - hb_vmPushPointer( new QRectF( ( *reinterpret_cast< QRectF( * )>( arguments[ 1 ] ) ) ) ); - break; - case S_G_QTime: - iArgs = 1; - hb_vmPushPointer( new QTime( ( *reinterpret_cast< QTime( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QUrl: - iArgs = 1; - hb_vmPushPointer( new QUrl( ( *reinterpret_cast< QUrl( * )>( arguments[ 1 ] ) ) ) ); - break; - - case S_G_QModelIndex_int_int: - iArgs = 3; - hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); - break; - case S_G_qint64: - iArgs = 1; - hb_vmPushInteger( *reinterpret_cast< qint64( * ) >( arguments[ 1 ] ) ); - break; - case S_G_qint64_qint64: - iArgs = 2; - hb_vmPushInteger( *reinterpret_cast< qint64( * ) >( arguments[ 1 ] ) ); - hb_vmPushInteger( *reinterpret_cast< qint64( * ) >( arguments[ 2 ] ) ); - break; - case S_G_QTextBlock: - iArgs = 1; - hb_vmPushPointer( new QTextBlock( ( *reinterpret_cast< QTextBlock( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QSizeF: - iArgs = 1; - hb_vmPushPointer( new QSizeF( ( *reinterpret_cast< QSizeF( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QColor: - iArgs = 1; - hb_vmPushPointer( new QColor( ( *reinterpret_cast< QColor( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_double: - iArgs = 1; - hb_vmPushDouble( *reinterpret_cast< double( * ) >( arguments[ 1 ] ), 4 ); - break; - case S_G_QModelIndexList: - iArgs = 1; - hb_vmPushPointer( new QModelIndexList( ( *reinterpret_cast< QModelIndexList( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QRect: - iArgs = 1; - hb_vmPushPointer( new QRect( ( *reinterpret_cast< QRect( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_int_QString: - { - iArgs = 2; - hb_vmPushInteger( *reinterpret_cast< qint64( * ) >( arguments[ 1 ] ) ); - QString text = *reinterpret_cast< QString( * ) >( arguments[ 2 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - } - break; - case S_G_QString_quint16_pointer: - { - iArgs = 3; - QString text = *reinterpret_cast< QString( * ) >( arguments[ 1 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - hb_vmPushInteger( *reinterpret_cast< quint64( * ) >( arguments[ 2 ] ) ); - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 3 ] ) ); - } - break; - case S_G_int_bool: - iArgs = 2; - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); - hb_vmPushLogical( *reinterpret_cast< bool( * ) >( arguments[ 2 ] ) ); - break; - case S_G_pointer_QString: - { - iArgs = 2; - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); - QString text = *reinterpret_cast< QString( * ) >( arguments[ 2 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - } - break; - case S_G_QString_QString_QString: - { - iArgs = 3; - QString text; - text = *reinterpret_cast< QString( * ) >( arguments[ 1 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - text = *reinterpret_cast< QString( * ) >( arguments[ 2 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - text = *reinterpret_cast< QString( * ) >( arguments[ 3 ] ); - hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); - } - break; - case S_G_int_int_QRect: - iArgs = 3; - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); - hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); - hb_vmPushPointer( new QRect( ( *reinterpret_cast< QRect( * ) >( arguments[ 1 ] ) ) ) ); - break; - #if 0 /* Disabled until dynamic registration is implemented */ - case S_G_QUrlInfo: - iArgs = 1; - hb_vmPushPointer( new QUrlInfo( ( *reinterpret_cast< QUrlInfo( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QNetworkRequest: - iArgs = 1; - hb_vmPushPointer( new QNetworkRequest( ( *reinterpret_cast< QNetworkRequest( * ) >( arguments[ 1 ] ) ) ) ); - break; - case S_G_QNetworkProxy_pointer: - iArgs = 2; - hb_vmPushPointer( new QNetworkProxy( ( *reinterpret_cast< QNetworkProxy( * ) >( arguments[ 1 ] ) ) ) ); - hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 2 ] ) ); - break; - case S_G_QHttpResponseHeader: - iArgs = 1; - hb_vmPushPointer( new QHttpResponseHeader( ( *reinterpret_cast< QHttpResponseHeader( * ) >( arguments[ 1 ] ) ) ) ); - break; - #endif - } - - hb_vmSend( iArgs ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); + hb_vmSend( 1 ); } +static void hbqt_SlotsExecPointerPointer( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecPointerInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecBool( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushLogical( *reinterpret_cast< bool( * ) >( arguments[ 1 ] ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecIntIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); + hb_vmSend( 3 ); +} + +static void hbqt_SlotsExecIntIntIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 4 ] ) ); + hb_vmSend( 4 ); +} + +static void hbqt_SlotsExecString( PHB_ITEM * codeBlock, void ** arguments ) +{ + QString text = *reinterpret_cast< QString( * ) >( arguments[ 1 ] ); + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecModel( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecModelModel( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 2 ] ) ) ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecStringList( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QStringList( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQUrl( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QUrl( ( *reinterpret_cast< QUrl( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQDate( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QDate( ( *reinterpret_cast< QDate( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQDateTime( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QDateTime( ( *reinterpret_cast< QDateTime( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQTime( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QTime( ( *reinterpret_cast< QTime( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQRectF( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QRectF( ( *reinterpret_cast< QRectF( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} +#endif /*----------------------------------------------------------------------*/ +static QList s_argCombinations; +static QList s_pCallback; + +void hbqt_slots_register_callback( QByteArray sig, PHBQT_SLOT_FUNC pCallback ) +{ + HB_TRACE( HB_TR_DEBUG, ( "callback %s", ( char * ) sig.data() ) ); + + if( ! sig.isEmpty() && pCallback ) + { + int iIndex = s_argCombinations.indexOf( sig ); + + if( iIndex == -1 ) + { + s_argCombinations << sig; + s_pCallback << pCallback; + } + else + { + s_pCallback[ iIndex ] = pCallback; + } + } +} + +void hbqt_slots_unregister_callback( QByteArray sig ) +{ + if( ! sig.isEmpty() ) + { + int iIndex = s_argCombinations.indexOf( sig ); + + if( iIndex > -1 ) + { + s_pCallback.removeAt( iIndex ); + } + } +} + static int connect_signal( QString signal, QObject * object, HBQSlots * t_slots ) { HB_TRACE( HB_TR_DEBUG, ( "connect_signal: %s", ( char * ) signal.toAscii().data() ) ); @@ -462,121 +316,11 @@ static bool disconnect_signal( QObject * object, QString signal ) { return false; } -// HB_TRACE( HB_TR_DEBUG, ( " signalId %d ", signalId ) ); return QMetaObject::disconnect( object, signalId, 0, 0 ); } /*----------------------------------------------------------------------*/ -static void hbqt_SlotsProxy( HBQSlots * t_slots, int id, QObject * object, void ** arguments ) -{ - static QList< QByteArray > argCombinations; - - if( argCombinations.size() == 0 ) - { - argCombinations << - SIG_int << - SIG_int_int << - SIG_int_int_int << - SIG_int_int_int_int << - SIG_bool << - SIG_QRect_int << - SIG_QString << - SIG_QModelIndex << - SIG_QModelIndex_QModelIndex << - SIG_QItemSelection_QItemSelection << - SIG_QTextCharFormat << - SIG_QFont << - SIG_QTextCursor << - SIG_QStringList << - SIG_pointer << - SIG_pointer_pointer << - SIG_pointer_int << - SIG_QDate << - SIG_QDateTime << - SIG_QPoint << - SIG_QRectF << - SIG_QTime << - SIG_QUrl << - SIG_QModelIndex_int_int << - SIG_qint64 << - SIG_qint64_qint64 << - SIG_QTextBlock << - SIG_QSizeF << - SIG_QColor << - SIG_double << - SIG_QModelIndexList << - SIG_QRect << - SIG_QRect_int << - SIG_int_QString << - SIG_QString_quint16_pointer << - SIG_int_bool << - SIG_pointer_QString << - SIG_QString_QString_QString << - SIG_int_int_QRect << - SIG_QUrlInfo << - SIG_QNetworkRequest << - SIG_QNetworkProxy_pointer << - SIG_QHttpResponseHeader << - "xxxyyyzzz" ; /* Just for line break */ - } - - const QMetaMethod meta = object->metaObject()->method( id ); - - HB_TRACE( HB_TR_DEBUG, ( "SlotsProxy signature %s", meta.signature() ) ); - - QList arrayOfTypes = meta.parameterTypes(); - - int parameterCount = arrayOfTypes.size(); - QStringList parList; - - for( int i = 0; i < parameterCount; i++ ) - { - if( arrayOfTypes.at( i ).contains( "::" ) ) // if includes :: is a enum -> int - { - parList += "int"; - } - else - { - if( arrayOfTypes.at( i ).contains( "*" ) ) // if includes * is a pointer -> pointer - { - parList += "pointer"; - } - else - { - parList += arrayOfTypes.at( i ); - } - } - } - - QByteArray paramString = parList.join( "$" ).toAscii(); - HB_TRACE( HB_TR_DEBUG, ( " SlotsProxy parList %s ", (char * ) paramString.data() ) ); - - if( object ) - { - char cSlotName[ 20 ]; - sprintf( cSlotName, "SLOT_%d", id ); - int i = object->property( cSlotName ).toInt(); - - if( i > 0 && i <= t_slots->listBlock.size() && hb_vmRequestReenter() ) - { - if( parameterCount == 0 ) - { - hb_vmEvalBlockV( t_slots->listBlock.at( i - 1 ), 0 ); - } - else - { - int paramId = argCombinations.indexOf( paramString ); - - HB_TRACE( HB_TR_DEBUG, ( " params=%s, paramId=%d", ( char * ) paramString.data(), paramId ) ); - - hbqt_fireSignal( paramId, ( PHB_ITEM * ) t_slots->listBlock.at( i - 1 ), arguments ); - } - hb_vmRequestRestore(); - } - } -} - HBQSlots::HBQSlots( QObject* parent ) : QObject( parent ) { } @@ -601,15 +345,96 @@ HBQSlots::~HBQSlots() 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; - } - // Q_ASSERT(id < slotList.size()); + id = QObject::qt_metacall( c, id, arguments ); - hbqt_SlotsProxy( this, id, sender(), arguments ); - return -1; + if( id < 0 || c != QMetaObject::InvokeMetaMethod ) + return id; + + // Q_ASSERT(id < slotList.size()); + + /* Register core slot handlers */ + if( s_argCombinations.size() == 0 ) + { + #if 0 + hbqt_slots_register_callback( "int" , hbqt_SlotsExecInt ); + hbqt_slots_register_callback( "int$int" , hbqt_SlotsExecIntInt ); + hbqt_slots_register_callback( "int$int$int" , hbqt_SlotsExecIntIntInt ); + hbqt_slots_register_callback( "int$int$int$int" , hbqt_SlotsExecIntIntIntInt ); + hbqt_slots_register_callback( "bool" , hbqt_SlotsExecBool ); + hbqt_slots_register_callback( "pointer" , hbqt_SlotsExecPointer ); + hbqt_slots_register_callback( "pointer$pointer" , hbqt_SlotsExecPointerPointer ); + hbqt_slots_register_callback( "pointer$int" , hbqt_SlotsExecPointerInt ); + hbqt_slots_register_callback( "QDate" , hbqt_SlotsExecQDate ); + hbqt_slots_register_callback( "QDateTime" , hbqt_SlotsExecQDateTime ); + hbqt_slots_register_callback( "QModelIndex" , hbqt_SlotsExecModel ); + hbqt_slots_register_callback( "QModelIndex$QModelIndex" , hbqt_SlotsExecModelModel ); + hbqt_slots_register_callback( "QRectF" , hbqt_SlotsExecQRectF ); + hbqt_slots_register_callback( "QString" , hbqt_SlotsExecString ); + hbqt_slots_register_callback( "QStringList" , hbqt_SlotsExecStringList ); + hbqt_slots_register_callback( "QTime" , hbqt_SlotsExecQTime ); + hbqt_slots_register_callback( "QUrl" , hbqt_SlotsExecQUrl ); + #endif + } + + QObject * object = sender(); + const QMetaMethod meta = object->metaObject()->method( id ); + QList arrayOfTypes = meta.parameterTypes(); + int parameterCount = arrayOfTypes.size(); + QStringList parList; + + HB_TRACE( HB_TR_DEBUG, ( "SlotsProxy signature %s", meta.signature() ) ); + + for( int i = 0; i < parameterCount; i++ ) + { + if( arrayOfTypes.at( i ).contains( "::" ) ) // if includes :: is a enum -> int + { + parList += "int"; + } + else + { + if( arrayOfTypes.at( i ).contains( "*" ) ) // if includes * is a pointer -> pointer + { + parList += "pointer"; + } + else + { + parList += arrayOfTypes.at( i ); // + } + } + } + + QByteArray paramString = parList.join( "$" ).toAscii(); + HB_TRACE( HB_TR_DEBUG, ( " SlotsProxy parList %s ", ( char * ) paramString.data() ) ); + + if( object ) + { + char cSlotName[ 20 ]; + sprintf( cSlotName, "SLOT_%d", id ); + int i = object->property( cSlotName ).toInt(); + + if( i > 0 && i <= this->listBlock.size() && hb_vmRequestReenter() ) + { + if( parameterCount == 0 ) + { + hb_vmEvalBlockV( this->listBlock.at( i - 1 ), 0 ); + } + else + { + int paramId = s_argCombinations.indexOf( paramString ); + PHBQT_SLOT_FUNC pCallback; + + HB_TRACE( HB_TR_DEBUG, ( " params=%s, paramId=%d", ( char *) paramString.data(), paramId ) ); + + pCallback = s_pCallback.at( paramId ); + if( pCallback ) + { + pCallback( ( PHB_ITEM * ) this->listBlock.at( i - 1 ), arguments ); + } + } + hb_vmRequestRestore(); + } + } + return -1; } /*----------------------------------------------------------------------*/ @@ -646,8 +471,12 @@ HB_FUNC( __HBQT_SLOTS_CONNECT ) } } } - if ( !bRet ) - hb_errRT_BASE( EG_ARG, 1100, NULL, "CONNECT", HB_ERR_ARGS_BASEPARAMS ); + + if( ! bRet ) + { + hb_errRT_BASE( EG_ARG, 1100, NULL, "CONNECT", HB_ERR_ARGS_BASEPARAMS ); + } + hb_retl( bRet ); } diff --git a/harbour/contrib/hbqt/qtcore/hbqt_registersignals.cpp b/harbour/contrib/hbqt/qtcore/hbqt_registersignals.cpp new file mode 100644 index 0000000000..cfc3e8eee7 --- /dev/null +++ b/harbour/contrib/hbqt/qtcore/hbqt_registersignals.cpp @@ -0,0 +1,335 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Marcos Antonio Gambeta (marcosgambeta at gmail dot com) + * Copyright 2009 Pritpal Bedi (pritpal@vouchcac.com) + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * Copyright 2010 Francesco Perillo () + * www - http://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 "hbqt.h" + +#include "hbapiitm.h" +#include "hbstack.h" +#include "hbvm.h" +#include "hbinit.h" + +#if QT_VERSION >= 0x040500 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/*----------------------------------------------------------------------*/ + +static void hbqt_SlotsExecPointer( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecPointerPointer( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecPointerInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecBool( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushLogical( *reinterpret_cast< bool( * ) >( arguments[ 1 ] ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecDouble( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushDouble( *reinterpret_cast< double( * ) >( arguments[ 1 ] ), 4 ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecIntIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); + hb_vmSend( 3 ); +} + +static void hbqt_SlotsExecIntIntIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 1 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 4 ] ) ); + hb_vmSend( 4 ); +} + +static void hbqt_SlotsExecString( PHB_ITEM * codeBlock, void ** arguments ) +{ + QString text = *reinterpret_cast< QString( * ) >( arguments[ 1 ] ); + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushString( text.toAscii().data(), text.toAscii().length() ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecModel( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecModelModel( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 2 ] ) ) ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecStringList( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QStringList( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQPoint( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QPoint( ( *reinterpret_cast< QPoint( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQUrl( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QUrl( ( *reinterpret_cast< QUrl( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQDate( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QDate( ( *reinterpret_cast< QDate( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQDateTime( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QDateTime( ( *reinterpret_cast< QDateTime( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQTime( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QTime( ( *reinterpret_cast< QTime( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQRectF( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QRectF( ( *reinterpret_cast< QRectF( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQRectInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QRect( ( *reinterpret_cast< QRect( * )>( arguments[ 1 ] ) ) ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecQRect( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QRect( ( *reinterpret_cast< QRect( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQSizeF( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QSizeF( ( *reinterpret_cast< QSizeF( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecModelIndexIntInt( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QModelIndex( ( *reinterpret_cast< QModelIndex( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 2 ] ) ); + hb_vmPushInteger( *reinterpret_cast< int( * ) >( arguments[ 3 ] ) ); + hb_vmSend( 3 ); +} + +static void hbqt_SlotsExecModelIndexList( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QModelIndexList( ( *reinterpret_cast< QModelIndexList( * ) >( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +/*----------------------------------------------------------------------*/ + +static void hbqt_registerCallbacks( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + hbqt_slots_register_callback( "qint64" , hbqt_SlotsExecInt ); + hbqt_slots_register_callback( "qint64$qint64" , hbqt_SlotsExecIntInt ); + hbqt_slots_register_callback( "int" , hbqt_SlotsExecInt ); + hbqt_slots_register_callback( "int$int" , hbqt_SlotsExecIntInt ); + hbqt_slots_register_callback( "int$int$int" , hbqt_SlotsExecIntIntInt ); + hbqt_slots_register_callback( "int$int$int$int" , hbqt_SlotsExecIntIntIntInt ); + hbqt_slots_register_callback( "bool" , hbqt_SlotsExecBool ); + hbqt_slots_register_callback( "double" , hbqt_SlotsExecDouble ); + hbqt_slots_register_callback( "pointer" , hbqt_SlotsExecPointer ); + hbqt_slots_register_callback( "pointer$pointer" , hbqt_SlotsExecPointerPointer ); + hbqt_slots_register_callback( "pointer$int" , hbqt_SlotsExecPointerInt ); + hbqt_slots_register_callback( "QDate" , hbqt_SlotsExecQDate ); + hbqt_slots_register_callback( "QDateTime" , hbqt_SlotsExecQDateTime ); + hbqt_slots_register_callback( "QModelIndex" , hbqt_SlotsExecModel ); + hbqt_slots_register_callback( "QModelIndex$int$int" , hbqt_SlotsExecModelIndexIntInt ); + hbqt_slots_register_callback( "QModelIndexList" , hbqt_SlotsExecModelIndexList ); + hbqt_slots_register_callback( "QModelIndex$QModelIndex" , hbqt_SlotsExecModelModel ); + hbqt_slots_register_callback( "QPoint" , hbqt_SlotsExecQPoint ); + hbqt_slots_register_callback( "QRect$int" , hbqt_SlotsExecQRectInt ); + hbqt_slots_register_callback( "QRect" , hbqt_SlotsExecQRect ); + hbqt_slots_register_callback( "QRectF" , hbqt_SlotsExecQRectF ); + hbqt_slots_register_callback( "QSizeF" , hbqt_SlotsExecQSizeF ); + hbqt_slots_register_callback( "QString" , hbqt_SlotsExecString ); + hbqt_slots_register_callback( "QStringList" , hbqt_SlotsExecStringList ); + hbqt_slots_register_callback( "QTime" , hbqt_SlotsExecQTime ); + hbqt_slots_register_callback( "QUrl" , hbqt_SlotsExecQUrl ); +} + +HB_CALL_ON_STARTUP_BEGIN( _hb_hbqtcore_register_init_ ) + hb_vmAtInit( hbqt_registerCallbacks, NULL ); +HB_CALL_ON_STARTUP_END( _hb_hbqtcore_register_init_ ) + +#if defined( HB_PRAGMA_STARTUP ) + #pragma startup _hb_hbqtcore_register_init_ +#elif defined( HB_DATASEG_STARTUP ) + #define HB_DATASEG_BODY HB_DATASEG_FUNC( _hb_hbqtcore_register_init_ ) + #include "hbiniseg.h" +#endif + +/*----------------------------------------------------------------------*/ + +HB_FUNC( __HBQT_REGISTERCORECALLBACKS ) +{ + hbqt_registerCallbacks( NULL ); +} + +#endif diff --git a/harbour/contrib/hbqt/qtcore/hbqtcore.hbc b/harbour/contrib/hbqt/qtcore/hbqtcore.hbc index de9f9ae59b..7b6f3b4435 100644 --- a/harbour/contrib/hbqt/qtcore/hbqtcore.hbc +++ b/harbour/contrib/hbqt/qtcore/hbqtcore.hbc @@ -11,11 +11,10 @@ incpaths=. g libs=../hbqt_common.hbc -# TOFIX: QtGui is needed by hbqt_hbqslots.cpp. This dependency should be removed. {!HB_STATIC_QT}libs=hbqtcore${__HB_DYN__} -{!HB_STATIC_QT&(allwin|os2)}libs=QtCore4 QtGui4 -{!HB_STATIC_QT&(linux|symbian)}libs=QtCore QtGui -{!HB_STATIC_QT&darwin}libs=/Library/Frameworks/QtCore.framework/QtCore /Library/Frameworks/QtGui.framework/QtGui +{!HB_STATIC_QT&(allwin|os2)}libs=QtCore4 +{!HB_STATIC_QT&(linux|symbian)}libs=QtCore +{!HB_STATIC_QT&darwin}libs=/Library/Frameworks/QtCore.framework/QtCore {HB_STATIC_QT&allwin}libs=hbqtcores${__HB_DYN__} {HB_STATIC_QT&linux}libs=hbqtcore -{HB_STATIC_QT&(allwin|linux)}libs=QtCore QtGui +{HB_STATIC_QT&(allwin|linux)}libs=QtCore diff --git a/harbour/contrib/hbqt/qtcore/hbqtcore.hbm b/harbour/contrib/hbqt/qtcore/hbqtcore.hbm index b92ceef723..551a806f39 100644 --- a/harbour/contrib/hbqt/qtcore/hbqtcore.hbm +++ b/harbour/contrib/hbqt/qtcore/hbqtcore.hbm @@ -7,6 +7,7 @@ g/filelist.hbm +hbqt_registersignals.cpp hbqt_pointer.cpp hbqt_version.cpp diff --git a/harbour/contrib/hbqt/qtcore/hbqtcore.hbx b/harbour/contrib/hbqt/qtcore/hbqtcore.hbx index a3d4d7a3a9..a1a36a7cf4 100644 --- a/harbour/contrib/hbqt/qtcore/hbqtcore.hbx +++ b/harbour/contrib/hbqt/qtcore/hbqtcore.hbx @@ -227,6 +227,7 @@ DYNAMIC __HBQT_EVENTS_DISCONNECT DYNAMIC __HBQT_EVENTS_NEW DYNAMIC __HBQT_ISPOINTER DYNAMIC __HBQT_PTR +DYNAMIC __HBQT_REGISTERCORECALLBACKS DYNAMIC __HBQT_SLOTS_CONNECT DYNAMIC __HBQT_SLOTS_DISCONNECT DYNAMIC __HBQT_SLOTS_NEW diff --git a/harbour/contrib/hbqt/qtgui/g/QApplication.cpp b/harbour/contrib/hbqt/qtgui/g/QApplication.cpp index cfca4e23ce..65fc3857f3 100644 --- a/harbour/contrib/hbqt/qtgui/g/QApplication.cpp +++ b/harbour/contrib/hbqt/qtgui/g/QApplication.cpp @@ -178,7 +178,7 @@ static void hbqtgui_Exit( void * cargo ) static void hbqtgui_Init( void * cargo ) { HB_SYMBOL_UNUSED( cargo ); - +HB_TRACE( HB_TR_ALWAYS, ( "static void hbqtgui_Init( void * cargo )" ) ); s_argc = hb_cmdargARGC(); s_argv = hb_cmdargARGV(); diff --git a/harbour/contrib/hbqt/qtgui/hbqt_registersignals.cpp b/harbour/contrib/hbqt/qtgui/hbqt_registersignals.cpp new file mode 100644 index 0000000000..531fe443b4 --- /dev/null +++ b/harbour/contrib/hbqt/qtgui/hbqt_registersignals.cpp @@ -0,0 +1,156 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Marcos Antonio Gambeta (marcosgambeta at gmail dot com) + * Copyright 2009 Pritpal Bedi (pritpal@vouchcac.com) + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * Copyright 2010 Francesco Perillo () + * www - http://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 "hbqt.h" + +#include "hbapiitm.h" +#include "hbstack.h" +#include "hbvm.h" +#include "hbinit.h" + +#if QT_VERSION >= 0x040500 + +#include +#include +#include +#include +#include +#include + +/*----------------------------------------------------------------------*/ + +static void hbqt_SlotsExecQColor( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QColor( ( *reinterpret_cast< QColor( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecItemSelItemSel( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QItemSelection( ( *reinterpret_cast< QItemSelection( * )>( arguments[ 1 ] ) ) ) ); + hb_vmPushPointer( new QItemSelection( ( *reinterpret_cast< QItemSelection( * )>( arguments[ 2 ] ) ) ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecQTextCharFormat( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QTextCharFormat( ( *reinterpret_cast( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQFont( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QFont( ( *reinterpret_cast< QFont( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQTextCursor( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QTextCursor( ( *reinterpret_cast< QTextCursor( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQTextBlock( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QTextBlock( ( *reinterpret_cast< QTextBlock( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +/*----------------------------------------------------------------------*/ + +static void hbqt_registerCallbacks( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + hbqt_slots_register_callback( "QColor" , hbqt_SlotsExecQColor ); + hbqt_slots_register_callback( "QFont" , hbqt_SlotsExecQFont ); + hbqt_slots_register_callback( "QItemSelection$QItemSelection" , hbqt_SlotsExecItemSelItemSel ); + hbqt_slots_register_callback( "QTextBlock" , hbqt_SlotsExecQTextBlock ); + hbqt_slots_register_callback( "QTextCharFormat" , hbqt_SlotsExecQTextCharFormat ); + hbqt_slots_register_callback( "QTextCursor" , hbqt_SlotsExecQTextCursor ); +} + +HB_CALL_ON_STARTUP_BEGIN( _hb_hbqtgui_register_init_ ) + hb_vmAtInit( hbqt_registerCallbacks, NULL ); +HB_CALL_ON_STARTUP_END( _hb_hbqtgui_register_init_ ) + +#if defined( HB_PRAGMA_STARTUP ) + #pragma startup _hb_hbqtgui_register_init_ +#elif defined( HB_DATASEG_STARTUP ) + #define HB_DATASEG_BODY HB_DATASEG_FUNC( _hb_hbqtgui_register_init_ ) + #include "hbiniseg.h" +#endif + +/*----------------------------------------------------------------------*/ + +HB_FUNC( __HBQT_REGISTERGUICALLBACKS ) +{ + hbqt_registerCallbacks( NULL ); +} + +#endif diff --git a/harbour/contrib/hbqt/qtgui/hbqtgui.hbm b/harbour/contrib/hbqt/qtgui/hbqtgui.hbm index 65a21f81f2..696525f227 100644 --- a/harbour/contrib/hbqt/qtgui/hbqtgui.hbm +++ b/harbour/contrib/hbqt/qtgui/hbqtgui.hbm @@ -7,6 +7,7 @@ g/filelist.hbm +hbqt_registersignals.cpp hbqt_hbqabstractitemmodel.cpp hbqt_hbqgraphicsitem.cpp hbqt_hbqgraphicsscene.cpp diff --git a/harbour/contrib/hbqt/qtgui/hbqtgui.hbx b/harbour/contrib/hbqt/qtgui/hbqtgui.hbx index 8826f8014c..37cb6ae75e 100644 --- a/harbour/contrib/hbqt/qtgui/hbqtgui.hbx +++ b/harbour/contrib/hbqt/qtgui/hbqtgui.hbx @@ -818,6 +818,7 @@ DYNAMIC QWIZARDFROMPOINTER DYNAMIC QWIZARDPAGE DYNAMIC QWIZARDPAGEFROMPOINTER DYNAMIC Q__TR +DYNAMIC __HBQT_REGISTERGUICALLBACKS #ifdef __HBEXTERN__HBQTGUI__REQUEST #uncommand DYNAMIC => EXTERNAL diff --git a/harbour/contrib/hbqt/qtnetwork/hbqt_registersignals.cpp b/harbour/contrib/hbqt/qtnetwork/hbqt_registersignals.cpp new file mode 100644 index 0000000000..196fc95cfe --- /dev/null +++ b/harbour/contrib/hbqt/qtnetwork/hbqt_registersignals.cpp @@ -0,0 +1,136 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Marcos Antonio Gambeta (marcosgambeta at gmail dot com) + * Copyright 2009 Pritpal Bedi (pritpal@vouchcac.com) + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * Copyright 2010 Francesco Perillo () + * www - http://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 "hbqt.h" + +#include "hbapiitm.h" +#include "hbstack.h" +#include "hbvm.h" +#include "hbinit.h" + +#if QT_VERSION >= 0x040500 + +#include +#include +#include +#include + +/*----------------------------------------------------------------------*/ + +static void hbqt_SlotsExecQHttpResponseHeader( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QHttpResponseHeader( ( *reinterpret_cast< QHttpResponseHeader( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQNetworkProxyPointer( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QNetworkProxy( ( *reinterpret_cast< QNetworkProxy( * )>( arguments[ 1 ] ) ) ) ); + hb_vmPushPointer( *reinterpret_cast< void*( * )>( arguments[ 2 ] ) ); + hb_vmSend( 2 ); +} + +static void hbqt_SlotsExecQNetworkRequest( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QNetworkRequest( ( *reinterpret_cast< QNetworkRequest( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +static void hbqt_SlotsExecQUrlInfo( PHB_ITEM * codeBlock, void ** arguments ) +{ + hb_vmPushEvalSym(); + hb_vmPush( codeBlock ); + hb_vmPushPointer( new QUrlInfo( ( *reinterpret_cast< QUrlInfo( * )>( arguments[ 1 ] ) ) ) ); + hb_vmSend( 1 ); +} + +/*----------------------------------------------------------------------*/ + +static void hbqt_registerCallbacks( void * cargo ) +{ + HB_SYMBOL_UNUSED( cargo ); + + hbqt_slots_register_callback( "QHttpResponseHeader" , hbqt_SlotsExecQHttpResponseHeader ); + hbqt_slots_register_callback( "QNetworkProxy$pointer" , hbqt_SlotsExecQNetworkProxyPointer ); + hbqt_slots_register_callback( "QNetworkRequest" , hbqt_SlotsExecQNetworkRequest ); + hbqt_slots_register_callback( "QUrlInfo" , hbqt_SlotsExecQUrlInfo ); +} + +HB_CALL_ON_STARTUP_BEGIN( _hb_hbqtnetwork_register_init_ ) + hb_vmAtInit( hbqt_registerCallbacks, NULL ); +HB_CALL_ON_STARTUP_END( _hb_hbqtnetwork_register_init_ ) + +#if defined( HB_PRAGMA_STARTUP ) + #pragma startup _hb_hbqtnetwork_register_init_ +#elif defined( HB_DATASEG_STARTUP ) + #define HB_DATASEG_BODY HB_DATASEG_FUNC( _hb_hbqtnetwork_register_init_ ) + #include "hbiniseg.h" +#endif + +/*----------------------------------------------------------------------*/ + +HB_FUNC( __HBQT_REGISTERNETWORKCALLBACKS ) +{ + hbqt_registerCallbacks( NULL ); +} + +#endif diff --git a/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbm b/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbm index 508104dda7..ae86bd00a0 100644 --- a/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbm +++ b/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbm @@ -7,4 +7,7 @@ g/filelist.hbm +hbqt_registersignals.cpp + ../qtcore/hbqtcore.hbc + diff --git a/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbx b/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbx index 19575e980e..54c784a4be 100644 --- a/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbx +++ b/harbour/contrib/hbqt/qtnetwork/hbqtnetwork.hbx @@ -46,6 +46,7 @@ DYNAMIC QHTTPRESPONSEHEADER DYNAMIC QHTTPRESPONSEHEADERFROMPOINTER DYNAMIC QNETWORKREQUEST DYNAMIC QNETWORKREQUESTFROMPOINTER +DYNAMIC __HBQT_REGISTERNETWORKCALLBACKS #ifdef __HBEXTERN__HBQTNETWORK__REQUEST #uncommand DYNAMIC => EXTERNAL