diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f13d8d7adc..ed25d0c3ff 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,29 @@ The license applies to all entries newer than 2009-04-28. */ +2010-10-18 00:57 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbqt/qtgui/hbqtgui.hbx + + contrib/hbqt/qtgui/THbQtUI.prg + * contrib/hbqt/qtgui/hbqtgui.hbm + * contrib/hbqt/qtuitools/hbqtuitools.hbm + * contrib/hbqt/qtuitools/hbqtuitools.hbx + - contrib/hbqt/qtuitools/THbQtUI.prg + + contrib/hbqt/qtuitools/THbQtUILoader.prg + * contrib/hbqt/hbqt_hbmk2_plugin.hbs + + Added new HbQtUI class (with temp name HbQtUI2) which + is light version of HbQtUI with no ties to qtuitools/uiloader + components. + New class is inheriting from HBQT root class, it + contains minor optimizations and cleanups. + It works, but it's not yet activated. + * Moved Q__TR() to hbqtgui from hbqtuitools. + ; TODO: Clear all TOFIX/QUESTION/TODO items in THbQtUI.prg. + F.e. user code like hbide makes quite many direct + manipulations on HbQtUI internal variables. This should + pbly be fixed. + ; TODO: Optimize the OnError way of doing things in HbQtUI class. + * Renamed THbQtUI.prg to THbQtUILoader.prg in hbqtuitools. + 2010-10-17 23:35 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbxbp/hbxbp.hbc * contrib/hbide/hbide.hbp diff --git a/harbour/contrib/hbqt/hbqt_hbmk2_plugin.hbs b/harbour/contrib/hbqt/hbqt_hbmk2_plugin.hbs index 497975b965..6ac92a0842 100644 --- a/harbour/contrib/hbqt/hbqt_hbmk2_plugin.hbs +++ b/harbour/contrib/hbqt/hbqt_hbmk2_plugin.hbs @@ -595,32 +595,32 @@ STATIC FUNCTION hbq_gen_ui_prg( cFile, cFuncName ) AAdd( aLinesPRG, "" ) AAdd( aLinesPRG, "FUNCTION " + cFuncName + "( qParent )" ) AAdd( aLinesPRG, " LOCAL oUI" ) - AAdd( aLinesPRG, " LOCAL oWidget" ) - AAdd( aLinesPRG, " LOCAL qObj := { => }" ) + AAdd( aLinesPRG, " LOCAL oRootWidget" ) + AAdd( aLinesPRG, " LOCAL hWidget := { => }" ) AAdd( aLinesPRG, "" ) - AAdd( aLinesPRG, " hb_hCaseMatch( qObj, .F. )" ) + AAdd( aLinesPRG, " hb_hCaseMatch( hWidget, .F. )" ) AAdd( aLinesPRG, "" ) SWITCH cMCls CASE "QDialog" - AAdd( aLinesPRG, " oWidget := QDialog( qParent )" ) + AAdd( aLinesPRG, " oRootWidget := QDialog( qParent )" ) EXIT CASE "QWidget" - AAdd( aLinesPRG, " oWidget := QWidget( qParent )" ) + AAdd( aLinesPRG, " oRootWidget := QWidget( qParent )" ) EXIT CASE "QMainWindow" - AAdd( aLinesPRG, " oWidget := QMainWindow( qParent )" ) + AAdd( aLinesPRG, " oRootWidget := QMainWindow( qParent )" ) EXIT ENDSWITCH AAdd( aLinesPRG, " " ) - AAdd( aLinesPRG, " oWidget:setObjectName( " + STRINGIFY( cMNam ) + " )" ) + AAdd( aLinesPRG, " oRootWidget:setObjectName( " + STRINGIFY( cMNam ) + " )" ) AAdd( aLinesPRG, " " ) - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cMNam ) ) + " ] := oWidget" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cMNam ) ) + " ] := oRootWidget" ) AAdd( aLinesPRG, " " ) FOR EACH item IN aWidgets IF item:__enumIndex() > 1 - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( item[ 2 ] ) ) + " ] := " + StrTran( item[ 4 ], "o[", "qObj[" ) ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( item[ 2 ] ) ) + " ] := " + StrTran( item[ 4 ], "o[", "hWidget[" ) ) ENDIF NEXT AAdd( aLinesPRG, "" ) @@ -645,27 +645,27 @@ STATIC FUNCTION hbq_gen_ui_prg( cFile, cFuncName ) IF "setToolTip(" $ cCmd s := hbq_pullToolTip( cCmd ) - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setToolTip( [" + STRIP_SQ( s ) + "] )" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setToolTip( [" + STRIP_SQ( s ) + "] )" ) ELSEIF "setPlainText(" $ cCmd s := hbq_pullToolTip( cCmd ) - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setPlainText( [" + STRIP_SQ( s ) + "] )" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setPlainText( [" + STRIP_SQ( s ) + "] )" ) ELSEIF "setStyleSheet(" $ cCmd s := hbq_pullToolTip( cCmd ) - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setStyleSheet( [" + STRIP_SQ( s ) + "] )" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setStyleSheet( [" + STRIP_SQ( s ) + "] )" ) ELSEIF "setText(" $ cCmd s := hbq_pullToolTip( cCmd ) IF hbq_pullColumn( cCmd, @n ) - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setText( " + hb_ntos( n ) + ", [" + STRIP_SQ( s ) + "] )" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setText( " + hb_ntos( n ) + ", [" + STRIP_SQ( s ) + "] )" ) ELSE - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setText( [" + STRIP_SQ( s ) + "] )" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setText( [" + STRIP_SQ( s ) + "] )" ) ENDIF ELSEIF "setWhatsThis(" $ cCmd s := hbq_pullToolTip( cCmd ) - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setWhatsThis( [" + STRIP_SQ( s ) + "] )" ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:setWhatsThis( [" + STRIP_SQ( s ) + "] )" ) ELSEIF "header()->" $ cCmd // TODO: how to handle : __qtreeviewitem->header()->setVisible( .F. ) @@ -674,15 +674,19 @@ STATIC FUNCTION hbq_gen_ui_prg( cFile, cFuncName ) // Nothing TO DO ELSE - AAdd( aLinesPRG, " qObj[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:" + StrTran( cCmd, "o[", "qObj[" ) ) + AAdd( aLinesPRG, " hWidget[ " + PAD_30( STRINGIFY( cNam ) ) + " ]:" + StrTran( cCmd, "o[", "hWidget[" ) ) ENDIF NEXT AAdd( aLinesPRG, "" ) + #if 0 + AAdd( aLinesPRG, " oUI := HbQtUI2():new( oRootWidget, hWidget )" ) + #else AAdd( aLinesPRG, " oUI := HbQtUI():new()" ) - AAdd( aLinesPRG, " oUI:qObj := qObj" ) - AAdd( aLinesPRG, " oUI:oWidget := oWidget" ) - AAdd( aLinesPRG, " oUI:pPtr := oWidget:pPtr" ) + AAdd( aLinesPRG, " oUI:qObj := hWidget" ) + AAdd( aLinesPRG, " oUI:oWidget := oRootWidget" ) + AAdd( aLinesPRG, " oUI:pPtr := oRootWidget:pPtr" ) + #endif AAdd( aLinesPRG, "" ) AAdd( aLinesPRG, " RETURN oUI" ) AAdd( aLinesPRG, "" ) diff --git a/harbour/contrib/hbqt/qtgui/THbQtUI.prg b/harbour/contrib/hbqt/qtgui/THbQtUI.prg new file mode 100644 index 0000000000..a5311b68b1 --- /dev/null +++ b/harbour/contrib/hbqt/qtgui/THbQtUI.prg @@ -0,0 +1,154 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * THbQtUI class + * + * Copyright 2010 Pritpal Bedi + * 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. + * + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* + * EkOnkar + * ( The LORD is ONE ) + * + * Harbour Parts HbQtUI Class + * + * Pritpal Bedi + * 28Jan2010 + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "hbclass.ch" +#include "error.ch" + +/*----------------------------------------------------------------------*/ + +/* TODO: Rename HbQtUI2 to final name after finalizing the code. [vszakats] */ + +CREATE CLASS HbQtUI2 INHERIT HbQtObjectHandler + + VAR oWidget /* TOFIX: User code uses this directly. Then rename this to __oRootWidget and make it PROTECTED. */ + VAR qObj INIT { => } /* TOFIX: User code uses this directly. Then rename this to __hWidget and make it PROTECTED. */ + + METHOD new( oRootWidget, hWidget ) + METHOD destroy() + + ERROR HANDLER __OnError( ... ) + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD HbQtUI2:new( oRootWidget, hWidget ) + + ::oWidget := oRootWidget + ::qObj := hWidget + + /* QUESTION: Is this needed? */ + ::pPtr := oRootWidget:pPtr + + RETURN Self + +/*----------------------------------------------------------------------*/ + +/* QUESTION: Is this needed? */ +METHOD HbQtUI2:destroy() + + ::oWidget:close() + ::oWidget := NIL + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD HbQtUI2:__OnError( ... ) + LOCAL cMsg := __GetMessage() + + LOCAL oError + + IF SubStr( cMsg, 1, 1 ) == "_" + cMsg := SubStr( cMsg, 2 ) + ENDIF + + IF Left( cMsg, 2 ) == "Q_" + IF SubStr( cMsg, 3 ) $ ::qObj + RETURN ::qObj[ SubStr( cMsg, 3 ) ] + ELSE + oError := ErrorNew() + + oError:severity := ES_ERROR + oError:genCode := EG_ARG + oError:subSystem := "HBQT" + oError:subCode := 1001 + oError:canRetry := .F. + oError:canDefault := .F. + oError:Args := hb_AParams() + oError:operation := ProcName() + oError:Description := "Control <" + substr( cMsg, 3 ) + "> does not exist" + + Eval( ErrorBlock(), oError ) + ENDIF + ELSEIF ::oWidget:hasValidPointer() /* QUESTION: Why do we need this? */ + RETURN ::oWidget:&cMsg( ... ) + ENDIF + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +FUNCTION q__tr( p1, p2, p3, p4 ) + + HB_SYMBOL_UNUSED( p1 ) + HB_SYMBOL_UNUSED( p3 ) + HB_SYMBOL_UNUSED( p4 ) + + RETURN p2 + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/qtgui/hbqtgui.hbm b/harbour/contrib/hbqt/qtgui/hbqtgui.hbm index dc14071f75..65a21f81f2 100644 --- a/harbour/contrib/hbqt/qtgui/hbqtgui.hbm +++ b/harbour/contrib/hbqt/qtgui/hbqtgui.hbm @@ -23,4 +23,6 @@ hbqt_hbqtableview.h hbqt_errorsys.prg +THbQtUI.prg + ../qtcore/hbqtcore.hbc diff --git a/harbour/contrib/hbqt/qtgui/hbqtgui.hbx b/harbour/contrib/hbqt/qtgui/hbqtgui.hbx index 1246c56ae6..3169867335 100644 --- a/harbour/contrib/hbqt/qtgui/hbqtgui.hbx +++ b/harbour/contrib/hbqt/qtgui/hbqtgui.hbx @@ -1082,6 +1082,7 @@ DYNAMIC QWIZARDFROMPOINTER DYNAMIC QWIZARDPAGE DYNAMIC QWIZARDPAGEFROM DYNAMIC QWIZARDPAGEFROMPOINTER +DYNAMIC Q__TR #ifdef __HBEXTERN__HBQTGUI__REQUEST #uncommand DYNAMIC => EXTERNAL diff --git a/harbour/contrib/hbqt/qtuitools/THbQtUI.prg b/harbour/contrib/hbqt/qtuitools/THbQtUILoader.prg similarity index 99% rename from harbour/contrib/hbqt/qtuitools/THbQtUI.prg rename to harbour/contrib/hbqt/qtuitools/THbQtUILoader.prg index 66461d30a2..6240b7b297 100644 --- a/harbour/contrib/hbqt/qtuitools/THbQtUI.prg +++ b/harbour/contrib/hbqt/qtuitools/THbQtUILoader.prg @@ -727,16 +727,6 @@ STATIC FUNCTION hbq_setObjects( cCmd, aObj_ ) /*----------------------------------------------------------------------*/ -FUNCTION q__tr( p1, p2, p3, p4 ) - - HB_SYMBOL_UNUSED( p1 ) - HB_SYMBOL_UNUSED( p3 ) - HB_SYMBOL_UNUSED( p4 ) - - RETURN p2 - -/*----------------------------------------------------------------------*/ - STATIC FUNCTION hbq_pullText( org_, nFrom ) LOCAL s := "", nLen := len( org_ ) LOCAL a_:= { "setText(", "setPlainText(", "setStyleSheet(", "setWhatsThis(" } diff --git a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm index cc83eb5959..a5717ee8bf 100644 --- a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm +++ b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm @@ -7,6 +7,6 @@ g/filelist.hbm -THbQtUI.prg +THbQtUILoader.prg ../qtgui/hbqtgui.hbc diff --git a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbx b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbx index f14343769b..cd318cd6b4 100644 --- a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbx +++ b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbx @@ -33,7 +33,6 @@ DYNAMIC HB_QUILOADER DYNAMIC QUILOADER DYNAMIC QUILOADERFROM DYNAMIC QUILOADERFROMPOINTER -DYNAMIC Q__TR #ifdef __HBEXTERN__HBQTUITOOLS__REQUEST #uncommand DYNAMIC => EXTERNAL