From aca7461f3dde46b5660a0c84d18bbfe063259122 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 22 Jun 2010 21:32:18 +0000 Subject: [PATCH] 2010-06-22 14:27 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/THbQtUI.prg % Little more syncronization. + Added: method ::connect(). It is identical to :signal() But for uniformity with other hbXBP and hbIDE classes this method name seems appropriate. % Reworked: method create(). Now both types of implementations, viz., .ui and .uic will be entertained with one creator. oUI := HbQtUI():new( "MainWindow.ui" ):create() oUI := HbQtUI():new( "MainWindow.uic" ):create() with do the job. :build() is still active but will be depricated. --- harbour/ChangeLog | 12 +++++++++ harbour/contrib/hbqt/THbQtUI.prg | 43 +++++++++++++++++++++++++------- 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d8b1576a82..074f2c1d3f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,18 @@ The license applies to all entries newer than 2009-04-28. */ +2010-06-22 14:27 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/THbQtUI.prg + % Little more syncronization. + + Added: method ::connect(). It is identical to :signal() + But for uniformity with other hbXBP and hbIDE classes + this method name seems appropriate. + % Reworked: method create(). Now both types of implementations, + viz., .ui and .uic will be entertained with one creator. + oUI := HbQtUI():new( "MainWindow.ui" ):create() + oUI := HbQtUI():new( "MainWindow.uic" ):create() + with do the job. :build() is still active but will be depricated. + 2010-06-22 23:17 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/macro/macrolex.c * Added casts to pacify long-time msvc warnings. diff --git a/harbour/contrib/hbqt/THbQtUI.prg b/harbour/contrib/hbqt/THbQtUI.prg index b53526075d..e30580f488 100644 --- a/harbour/contrib/hbqt/THbQtUI.prg +++ b/harbour/contrib/hbqt/THbQtUI.prg @@ -81,6 +81,8 @@ CLASS HbQtUI DATA oWidget DATA cMainWidgetName + DATA cLoadingMode INIT "" + DATA qObj INIT hb_hash() DATA widgets INIT {} DATA aCommands INIT {} @@ -97,6 +99,7 @@ CLASS HbQtUI METHOD event( cWidget, nEvent, bBlock ) METHOD signal( cWidget, cSignal, bBlock ) + METHOD connect( cWidget, cSignal, bBlock ) METHOD loadWidgets() METHOD loadContents( cUiFull ) METHOD loadUI( cUiFull, qParent ) @@ -119,6 +122,7 @@ METHOD HbQtUI:new( cFile, qParent ) /*----------------------------------------------------------------------*/ METHOD HbQtUI:create( cFile, qParent ) + LOCAL cExt DEFAULT cFile TO ::cFile DEFAULT qParent TO ::qParent @@ -127,14 +131,24 @@ METHOD HbQtUI:create( cFile, qParent ) ::qParent := qParent IF !empty( ::cFile ) .AND. hb_fileExists( ::cFile ) - hb_hCaseMatch( ::qObj, .f. ) + hb_fNameSplit( cFile, , , @cExt ) - ::loadContents( ::cFile, ::qParent ) + IF lower( cExt ) == ".uic" + ::cLoadingMode := "uic" + ::build( ::cFile, ::qParent ) - ::oWidget := ::loadUI( ::cFile, ::qParent ) + ELSE + ::cLoadingMode := "ui" - IF !empty( ::oWidget ) - ::loadWidgets() + hb_hCaseMatch( ::qObj, .f. ) + + ::loadContents( ::cFile, ::qParent ) + + ::oWidget := ::loadUI( ::cFile, ::qParent ) + + IF !empty( ::oWidget ) + ::loadWidgets() + ENDIF ENDIF ENDIF @@ -161,7 +175,6 @@ METHOD HbQtUI:destroy() i := a_:__enumIndex() IF i > 0 IF type( a_[ 3 ] ) == "UI" -//HB_TRACE( HB_TR_ALWAYS, 400, i, pad( a_[ 1 ], 20 ), pad( a_[ 2 ], 20 ), iif( i > 1, pad( ::widgets[ i - 1, 1 ],20 ), NIL ), i, len( ::widgets ) ) ::qObj[ a_[ 2 ] ] := NIL ENDIF ENDIF @@ -186,6 +199,12 @@ METHOD HbQtUI:event( cWidget, nEvent, bBlock ) /*----------------------------------------------------------------------*/ +METHOD HbQtUI:connect( cWidget, cSignal, bBlock ) + + RETURN ::signal( cWidget, cSignal, bBlock ) + +/*----------------------------------------------------------------------*/ + METHOD HbQtUI:signal( cWidget, cSignal, bBlock ) IF hb_hHasKey( ::qObj, cWidget ) @@ -299,7 +318,11 @@ METHOD HbQtUI:OnError( ... ) ENDIF IF left( cMsg, 2 ) == "Q_" - xReturn := ::qObj[ substr( cMsg, 3 ) ] + IF hb_hHasKey( ::qObj, substr( cMsg, 3 ) ) + xReturn := ::qObj[ substr( cMsg, 3 ) ] + ELSE + MsgBox( "Control < " + substr( cMsg, 3 ) + " > does not exists!" ) + ENDIF ELSE xReturn := ::oWidget:&cMsg( ... ) ENDIF @@ -319,6 +342,8 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ::cFile := cFileOrBuffer ::qParent := qParent + ::cLoadingMode := "uic" + IF empty( ::cFile ) RETURN Self ENDIF @@ -347,7 +372,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) hbq_stripFront( @cMCls, "(" ) hbq_stripRear( @cMNam, ")" ) // -// HB_TRACE( HB_TR_ALWAYS, "Widget ", pad( cMNam, 20 ), pad( cMCls, 20 ), cMCls+"():new()" ) + // HB_TRACE( HB_TR_ALWAYS, "Widget ", pad( cMNam, 20 ), pad( cMCls, 20 ), cMCls+"():new()" ) // Validator Constructor aadd( ::widgets, { cMCls, cMNam, cMCls+"()", cMCls+"():new()" } ) @@ -541,7 +566,7 @@ METHOD HbQtUI:build( cFileOrBuffer, qParent ) ELSE cBlock := "{|o,v| o[v]:" + cCmd + "}" -//HB_TRACE( HB_TR_ALWAYS, pad( a_[ 1 ], 20 ), cBlock ) + * HB_TRACE( HB_TR_ALWAYS, pad( a_[ 1 ], 20 ), cBlock, 0, cNam ) bBlock := &( cBlock ) eval( bBlock, ::qObj, cNam )