2012-06-13 13:59 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

- contrib/hbqt/qtcore/hbqt_obj.prg
    - Deleted: hbQT already has a super class HBQTOBJECTHANDELLER 
       and concerned protocol is embedded into that.

  * contrib/hbqt/qtcore/hbqt_hbqevents.cpp
  * contrib/hbqt/qtcore/hbqt_hbqevents.h
    ! Changed: constructor without a parent.
       In certain situations under current protocol, this had 
       a overhead where destructor on this object was not being 
       called at appropriate time.

  * contrib/hbqt/qtcore/hbqt_hbqslots.cpp
  * contrib/hbqt/qtcore/hbqt_hbqslots.h
    ! Formatting.

  * contrib/hbqt/qtcore/hbqt_misc.prg

  * contrib/hbqt/qtcore/hbqtcore.hbm
  * contrib/hbqt/qtcore/hbqtcore.hbx
    - Deleted: hbqt_obj.prg

  * contrib/hbqt/qtcore/qth/HBQEvents.qth
    - Deleted: un-used variables.
This commit is contained in:
Pritpal Bedi
2012-06-13 21:09:44 +00:00
parent 61ec2cb4d7
commit c3198f6128
10 changed files with 131 additions and 186 deletions

View File

@@ -16,6 +16,31 @@
The license applies to all entries newer than 2009-04-28.
*/
2012-06-13 13:59 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
- contrib/hbqt/qtcore/hbqt_obj.prg
- Deleted: hbQT already has a super class HBQTOBJECTHANDELLER
and concerned protocol is embedded into that.
* contrib/hbqt/qtcore/hbqt_hbqevents.cpp
* contrib/hbqt/qtcore/hbqt_hbqevents.h
! Changed: constructor without a parent.
In certain situations under current protocol, this had
a overhead where destructor on this object was not being
called at appropriate time.
* contrib/hbqt/qtcore/hbqt_hbqslots.cpp
* contrib/hbqt/qtcore/hbqt_hbqslots.h
! Formatting.
* contrib/hbqt/qtcore/hbqt_misc.prg
* contrib/hbqt/qtcore/hbqtcore.hbm
* contrib/hbqt/qtcore/hbqtcore.hbx
- Deleted: hbqt_obj.prg
* contrib/hbqt/qtcore/qth/HBQEvents.qth
- Deleted: un-used variables.
2012-06-13 22:55 UTC+0200 Viktor Szakats (harbour syenar.net)
- contrib/hbamf/hbref.c
* contrib/hbamf/amfdec.c

View File

@@ -107,18 +107,26 @@ void hbqt_events_unregister_createobj( QEvent::Type eventtype )
/*----------------------------------------------------------------------*/
HBQEvents::HBQEvents( QObject * object ) : QObject()
HBQEvents::HBQEvents() : QObject()
{
if( object )
{
object->installEventFilter( this );
}
}
HBQEvents::~HBQEvents()
{
}
void HBQEvents::hbInstallEventFilter( PHB_ITEM pObj )
{
if( hb_itemType( pObj ) & HB_IT_OBJECT )
{
QObject * object = ( QObject * ) hbqt_get_ptr( pObj );
if( object )
{
object->installEventFilter( this );
}
}
}
int HBQEvents::hbConnect( PHB_ITEM pObj, int event, PHB_ITEM bBlock )
{
HB_TRACE( HB_TR_DEBUG, ( "HBQEvents::hbConnect( %i )", event ) );

View File

@@ -68,12 +68,12 @@ class HBQEvents: public QObject
Q_OBJECT
public:
HBQEvents( QObject * parent = 0 );
HBQEvents();
~HBQEvents();
QList<PHB_ITEM> listBlock;
int hbConnect( PHB_ITEM pObj, int iEvent, PHB_ITEM bBlock );
int hbDisconnect( PHB_ITEM pObj, int iEvent );
void hbInstallEventFilter( PHB_ITEM pObj );
protected:
bool eventFilter( QObject * obj, QEvent * event );

View File

@@ -106,14 +106,13 @@ void hbqt_slots_unregister_callback( QByteArray sig )
/*----------------------------------------------------------------------*/
// HBQSlots::HBQSlots( PHB_ITEM pObj ) : QObject()
HBQSlots::HBQSlots() : QObject()
{
}
HBQSlots::~HBQSlots()
{
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::~HBQSlots()" ) );
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::~HBQSlots()" ) );
}
int HBQSlots::hbConnect( PHB_ITEM pObj, char * pszSignal, PHB_ITEM bBlock )
@@ -184,29 +183,28 @@ int HBQSlots::hbDisconnect( PHB_ITEM pObj, char * pszSignal )
QObject * object = ( QObject * ) hbqt_get_ptr( pObj );
if( object )
{
QString signal = pszSignal;
QByteArray theSignal = signal.toAscii();
QString signal = pszSignal;
QByteArray theSignal = signal.toAscii();
int signalId = object->metaObject()->indexOfSignal( QMetaObject::normalizedSignature( theSignal ) );
if( signalId != -1 )
int signalId = object->metaObject()->indexOfSignal( QMetaObject::normalizedSignature( theSignal ) );
if( signalId != -1 )
{
if( QMetaObject::disconnect( object, signalId, 0, 0 ) )
{
if( QMetaObject::disconnect( object, signalId, 0, 0 ) )
{
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbDisconnect( %s ) %i", pszSignal, i ) );
nResult = 0;
}
else
nResult = 5;
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbDisconnect( %s ) %i", pszSignal, i ) );
nResult = 0;
}
else
nResult = 4;
nResult = 5;
}
else
nResult = 4;
if( nResult == 0 )
{
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbDisConnect( %s ) signalId=%i, %p", pszSignal, signalId, object ) );
hbqt_bindDelSlot( pObj, signalId, NULL );
}
if( nResult == 0 )
{
HB_TRACE( HB_TR_DEBUG, ( "HBQSlots::hbDisConnect( %s ) signalId=%i, %p", pszSignal, signalId, object ) );
hbqt_bindDelSlot( pObj, signalId, NULL );
}
}
else
nResult = 2;
@@ -223,73 +221,73 @@ int HBQSlots::qt_metacall( QMetaObject::Call c, int id, void ** arguments )
QObject * object = sender();
if( object )
{
QByteArray paramString;
const QMetaMethod meta = object->metaObject()->method( id );
QList<QByteArray> arrayOfTypes = meta.parameterTypes();
int parameterCount = arrayOfTypes.size();
QStringList pList;
QByteArray paramString;
const QMetaMethod meta = object->metaObject()->method( id );
QList<QByteArray> arrayOfTypes = meta.parameterTypes();
int parameterCount = arrayOfTypes.size();
QStringList pList;
if( parameterCount > 0 )
if( parameterCount > 0 )
{
char szParams[ 20 ];
hb_snprintf( szParams, sizeof( szParams ), "PARAM_%d", id );
paramString = object->property( szParams ).toByteArray();
char szPList[ 20 ];
hb_snprintf( szPList, sizeof( szPList ), "PLIST_%d", id );
pList = object->property( szPList ).toStringList();
if( paramString.isNull() )
{
char szParams[ 20 ];
hb_snprintf( szParams, sizeof( szParams ), "PARAM_%d", id );
paramString = object->property( szParams ).toByteArray();
QStringList parList;
HB_TRACE( HB_TR_DEBUG, ( "SlotsProxy signature %s", meta.signature() ) );
char szPList[ 20 ];
hb_snprintf( szPList, sizeof( szPList ), "PLIST_%d", id );
pList = object->property( szPList ).toStringList();
if( paramString.isNull() )
for( int i = 0; i < parameterCount; i++ )
{
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( arrayOfTypes.at( i ).contains( "::" ) )
{
parList += "int";
pList += "int";
}
else
{
parList += arrayOfTypes.at( i ).trimmed() ;
pList += arrayOfTypes.at( i ).trimmed().toUpper();
}
}
paramString = parList.join( "$" ).toAscii();
object->setProperty( szParams, paramString );
object->setProperty( szPList, pList );
HB_TRACE( HB_TR_DEBUG, ( " SlotsProxy parList %s ", ( char * ) paramString.data() ) );
}
}
if( hb_vmRequestReenter() )
{
PHB_ITEM hbObject = hbqt_bindGetHbObjectByQtObject( object );
PHB_ITEM p = hbqt_bindGetSlots( hbObject, id );
hb_itemRelease( hbObject );
if( p )
{
if( parameterCount == 0 )
{
hb_evalBlock0( hb_arrayGetItemPtr( p, 1 ) );
parList += "int";
pList += "int";
}
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 );
}
parList += arrayOfTypes.at( i ).trimmed() ;
pList += arrayOfTypes.at( i ).trimmed().toUpper();
}
hb_itemRelease( p );
}
hb_vmRequestRestore();
paramString = parList.join( "$" ).toAscii();
object->setProperty( szParams, paramString );
object->setProperty( szPList, pList );
HB_TRACE( HB_TR_DEBUG, ( " SlotsProxy parList %s ", ( char * ) paramString.data() ) );
}
}
if( hb_vmRequestReenter() )
{
PHB_ITEM hbObject = hbqt_bindGetHbObjectByQtObject( object );
PHB_ITEM p = hbqt_bindGetSlots( hbObject, id );
hb_itemRelease( hbObject );
if( p )
{
if( parameterCount == 0 )
{
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();
}
}
return -1;
}

View File

@@ -73,7 +73,6 @@ public:
HBQSlots( );
~HBQSlots();
QList<PHB_ITEM> listBlock;
int hbConnect( PHB_ITEM obj, char * pszSignal, PHB_ITEM block );
int hbDisconnect( PHB_ITEM obj, char * pszSignal );

View File

@@ -54,20 +54,19 @@
#include "error.ch"
#include "hbtrace.ch"
#define QEvent_Paint 12
/*----------------------------------------------------------------------*/
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 */
VAR __pSlots PROTECTED
VAR __pEvents PROTECTED
VAR __hEvents PROTECTED INIT { => }
VAR __Slots /* TOFIX: add PROTECTED or clean this mess */
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 */
METHOD connect( cnEvent, bBlock )
@@ -154,7 +153,7 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock )
SWITCH ValType( cnEvent )
CASE "C"
IF Empty( ::__pSlots )
::__pSlots := HBQSlots( Self )
::__pSlots := HBQSlots()
ENDIF
nResult := ::__pSlots:hbconnect( Self, cnEvent, bBlock )
@@ -168,27 +167,19 @@ METHOD HbQtObjectHandler:connect( cnEvent, bBlock )
EXIT
CASE "N"
IF cnEvent == QEvent_Paint
IF __objHasMethod( Self, "HBSETEVENTBLOCK" )
::hbSetEventBlock( QEvent_Paint, bBlock )
RETURN .T.
ELSE
RETURN .F.
ENDIF
ELSE
IF Empty( ::__pEvents )
::__pEvents := HBQEvents( Self )
ENDIF
nResult := ::__pEvents:hbConnect( Self, cnEvent, bBlock )
SWITCH nResult
CASE 0
::__hEvents[ cnEvent ] := cnEvent
RETURN .T.
CASE -3 /* bBlock not supplied */
RETURN .F.
ENDSWITCH
IF Empty( ::__pEvents )
::__pEvents := HBQEvents()
::__pEvents:hbInstallEventFilter( Self )
ENDIF
nResult := ::__pEvents:hbConnect( Self, cnEvent, bBlock )
SWITCH nResult
CASE 0
::__hEvents[ cnEvent ] := cnEvent
RETURN .T.
CASE -3 /* bBlock not supplied */
RETURN .F.
ENDSWITCH
EXIT
OTHERWISE

View File

@@ -1,66 +0,0 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* QT wrapper source code
*
* Copyright 2012 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* 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 "hbclass.ch"
CREATE CLASS HBQT_BASEOBJECT
VAR __Childs INIT {}
VAR __Slots
METHOD Init()
ENDCLASS
METHOD Init()
::__Slots := {=>}
hb_HDefault( ::__Slots, {} )
RETURN Self

View File

@@ -20,7 +20,6 @@ hbqt_bind.cpp
hbqt_destroyer.cpp
hbqt_misc.prg
hbqt_obj.prg
hbqt_hbqevents.h
hbqt_destroyer.h

View File

@@ -29,11 +29,8 @@ DYNAMIC HBQEVENTS
DYNAMIC HBQSLOTS
DYNAMIC HBQSTRING
DYNAMIC HBQTOBJECTHANDLER
DYNAMIC HBQT_BASEOBJECT
DYNAMIC HBQT_CONNECT
DYNAMIC HBQT_ISEQUAL
DYNAMIC HBQT_ISOBJECT
DYNAMIC HBQT_PROMOTEWIDGET
DYNAMIC HB_HBQEVENTS
DYNAMIC HB_HBQSLOTS
DYNAMIC HB_HBQSTRING

View File

@@ -36,14 +36,7 @@ New =
*/
HB_FUNC( QT_HBQEVENTS )
{
if( hb_pcount() == 1 && hbqt_par_isDerivedFrom( 1, "QOBJECT" ) )
{
__HB_RETPTRGC__( new HBQEvents( hbqt_par_QObject( 1 ) ) );
}
else
{
__HB_RETPTRGC__( new HBQEvents() );
}
__HB_RETPTRGC__( new HBQEvents() );
}
</CODE>
@@ -54,6 +47,7 @@ HB_FUNC( QT_HBQEVENTS )
<PROTOS>
int hbConnect( PHB_ITEM obj, int event, PHB_ITEM block )
int hbDisconnect( PHB_ITEM obj, int event )
void hbInstallEventFilter( PHB_ITEM obj )
</PROTOS>
<SLOTS>