From ee48139899961314e12441dcdb637669cda01287 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 26 Nov 2009 03:05:18 +0000 Subject: [PATCH] 2009-11-25 18:53 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbide/hbide.prg * contrib/hbide/ideactions.prg * contrib/hbqt/generator/qt45.qtp * contrib/hbqt/hbqt.ch * contrib/hbqt/hbqt.h * contrib/hbqt/hbqt.hbc * contrib/hbqt/hbqt_destruct.cpp * contrib/hbqt/hbqt_garbage.h * contrib/hbqt/qtcore/filelist.mk + contrib/hbqt/qtcore/QUiLoader.cpp + contrib/hbqt/qtcore/TQUiLoader.prg + contrib/hbqt/qth/QUiLoader.qth * contrib/hbxbp/xbpcombobox.prg * contrib/hbxbp/xbpparthandler.prg * contrib/hbxbp/xbppushbutton.prg * contrib/hbxbp/xbpwindow.prg * contrib/hbide/resources/finddialog.ui + Implemented some very basic support for "Qt Creator" designer created .ui forms. + Based on above implementation hbide now supports "Find" operation. It is set to search "Harbour" at present and is scheduled to be perfected this week-end. --- harbour/ChangeLog | 28 ++ harbour/contrib/hbide/hbide.prg | 80 ++++-- harbour/contrib/hbide/ideactions.prg | 4 +- harbour/contrib/hbide/resources/finddialog.ui | 268 ++++++++++++++++++ harbour/contrib/hbqt/generator/qt45.qtp | 1 + harbour/contrib/hbqt/hbqt.ch | 33 +++ harbour/contrib/hbqt/hbqt.h | 1 + harbour/contrib/hbqt/hbqt.hbc | 2 +- harbour/contrib/hbqt/hbqt_destruct.cpp | 7 + harbour/contrib/hbqt/hbqt_garbage.h | 2 + harbour/contrib/hbqt/qtcore/QUiLoader.cpp | 266 +++++++++++++++++ harbour/contrib/hbqt/qtcore/TQUiLoader.prg | 160 +++++++++++ harbour/contrib/hbqt/qtcore/filelist.mk | 2 + harbour/contrib/hbqt/qth/QUiLoader.qth | 113 ++++++++ harbour/contrib/hbxbp/xbpcombobox.prg | 33 +++ harbour/contrib/hbxbp/xbpparthandler.prg | 11 + harbour/contrib/hbxbp/xbppushbutton.prg | 35 ++- harbour/contrib/hbxbp/xbpwindow.prg | 10 +- 18 files changed, 1018 insertions(+), 38 deletions(-) create mode 100644 harbour/contrib/hbide/resources/finddialog.ui create mode 100644 harbour/contrib/hbqt/qtcore/QUiLoader.cpp create mode 100644 harbour/contrib/hbqt/qtcore/TQUiLoader.prg create mode 100644 harbour/contrib/hbqt/qth/QUiLoader.qth diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 83765b4a04..80afd23fce 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,34 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-11-25 18:53 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbide/hbide.prg + * contrib/hbide/ideactions.prg + + * contrib/hbqt/generator/qt45.qtp + + * contrib/hbqt/hbqt.ch + * contrib/hbqt/hbqt.h + * contrib/hbqt/hbqt.hbc + * contrib/hbqt/hbqt_destruct.cpp + * contrib/hbqt/hbqt_garbage.h + + * contrib/hbqt/qtcore/filelist.mk + + + contrib/hbqt/qtcore/QUiLoader.cpp + + contrib/hbqt/qtcore/TQUiLoader.prg + + contrib/hbqt/qth/QUiLoader.qth + + * contrib/hbxbp/xbpcombobox.prg + * contrib/hbxbp/xbpparthandler.prg + * contrib/hbxbp/xbppushbutton.prg + * contrib/hbxbp/xbpwindow.prg + + * contrib/hbide/resources/finddialog.ui + + Implemented some very basic support for "Qt Creator" designer created .ui forms. + + Based on above implementation hbide now supports "Find" operation. It is set to + search "Harbour" at present and is scheduled to be perfected this week-end. + 2009-11-26 03:45 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbapi.h * harbour/include/hbvm.h diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index 539f2d2a28..f234b5d00e 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -121,6 +121,7 @@ CLASS HbIde DATA qSplitterL DATA qSplitterR DATA qTabWidget + DATA qFindDlg ACCESS qCurEdit INLINE iif( ::getCurrentTab() > 0, ::aTabs[ ::getCurrentTab(), 2 ], NIL ) /* XBP Objects */ @@ -290,8 +291,6 @@ METHOD HbIde:create( cProjectOrSource ) ::qSplitter:show() #endif - ::loadUI( "newproject" ) - ::oDlg:setPos( { 100, 60 } ) /* Editor's Font */ @@ -323,12 +322,22 @@ METHOD HbIde:create( cProjectOrSource ) ::closeAllSources() EXIT - ELSEIF ( ::nEvent == xbeP_Keyboard .and. ::mp1 == xbeK_ESC ) - ::closeSource() - IF ::qTabWidget:count() == 0 - ::oDockR:hide() - ::lDockRVisible := .f. - ENDIF + ELSEIF ::nEvent == xbeP_Keyboard + DO CASE + + CASE ::mp1 == xbeK_ESC + ::closeSource() + IF ::qTabWidget:count() == 0 + ::oDockR:hide() + ::lDockRVisible := .f. + ENDIF + + CASE ::mp1 == xbeK_CTRL_F + IF !empty( ::qCurEdit ) + ::loadUI( "finddialog" ) + ENDIF + + ENDCASE ENDIF ::oXbp:handleEvent( ::nEvent, ::mp1, ::mp2 ) @@ -350,22 +359,17 @@ METHOD HbIde:executeAction( cKey ) CASE cKey == "Exit" PostAppEvent( xbeP_Close, NIL, NIL, ::oDlg ) - CASE cKey == "NewProject" ::fetchProjectProperties( .t. ) - CASE cKey == "Open" IF !empty( cFile := ::selectSource( "open" ) ) ::oProjRoot:addItem( cFile ) ::editSource( cFile ) ENDIF - CASE cKey == "Save" ::saveSource( ::getCurrentTab(), .f. ) - CASE cKey == "Close" ::closeSource() - CASE cKey == "Undo" IF !empty( ::qCurEdit ) ::qCurEdit:undo() @@ -390,6 +394,10 @@ METHOD HbIde:executeAction( cKey ) IF !empty( ::qCurEdit ) ::qCurEdit:selectAll() ENDIF + CASE cKey == "Find" + IF !empty( ::qCurEdit ) + ::loadUI( "finddialog" ) + ENDIF CASE cKey == "ToUpper" ::convertSelection( cKey ) CASE cKey == "ToLower" @@ -404,7 +412,6 @@ METHOD HbIde:executeAction( cKey ) IF !empty( ::qCurEdit ) ::qCurEdit:zoomOut() ENDIF - CASE cKey == "11" IF ::lDockBVisible ::oDockB:hide() @@ -417,7 +424,6 @@ METHOD HbIde:executeAction( cKey ) ::oDockB2:show() ::lDockBVisible := .t. ENDIF - CASE cKey == "12" IF ::lDockRVisible ::oDockR:hide() @@ -426,6 +432,8 @@ METHOD HbIde:executeAction( cKey ) ENDIF ::lDockRVisible := !( ::lDockRVisible ) + CASE cKey == "Compile" + ENDCASE ::manageFocusInEditor() @@ -1098,24 +1106,36 @@ METHOD HbIde:fetchProjectProperties( lNewProject ) /*----------------------------------------------------------------------*/ METHOD HbIde:loadUI( cUi ) + LOCAL qUiLoader, qFile, cUiFull - HB_SYMBOL_UNUSED( cUi ) + STATIC oPBFind, oPBRepl, oPBClose, qFind, qRepl - #if 0 - LOCAL qUiLoader, qStrList - LOCAL cUiFull := s_resPath + cUi + ".ui" + IF ::qFindDlg == NIL + cUiFull := s_resPath + cUi + ".ui" + qFile := QFile():new( cUiFull ) + IF qFile:open( 1 ) + qUiLoader := QUiLoader():new() + ::qFindDlg := QDialog():configure( qUiLoader:load( QT_PTROF( qFile ), QT_PTROFXBP( ::oDlg ) ) ) + qFile:close() + ::qFindDlg:setWindowFlags( Qt_Sheet ) + // + oPBFind := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonFind" ) ) + oPBFind:activate := {|| ::qCurEdit:find( "Harbour" ) } - HBXBP_DEBUG( 0, cUiFull ) - qUiLoader := QUiLoader():new() - HBXBP_DEBUG( 1 ) - qUiLoader:load( cUiFull, QT_PTROFXBP( ::oDlg ) ) - HBXBP_DEBUG( 2 ) - qStrList := QStringList():configure( qUiLoader:availableWidgets() ) - HBXBP_DEBUG( 3 ) - HBXBP_DEBUG( qStrList:count() ) - HBXBP_DEBUG( 4 ) - HBXBP_DEBUG( qUiLoader:workingDirectory() ) - #endif + oPBRepl := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonReplace" ) ) + oPBRepl:activate := {|| ::qCurEdit:find( "something" ) } + + oPBClose := XbpPushButton():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "buttonClose" ) ) + oPBClose:activate := {|| ::qFindDlg:hide() /*done( 1 )*/ } + + qFind := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboFindWhat" ) ) + qRepl := XbpComboBox():new():createFromQtPtr( , , , , , , Qt_findChild( QT_PTROF( ::qFindDlg ), "comboReplaceWith" ) ) + + JustACall( qFind, qRepl ) + ENDIF + ENDIF + + ::qFindDlg:show() RETURN Self diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index c377719bbf..27e6bb7b22 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -107,8 +107,8 @@ FUNCTION buildToolBar( oWnd, oIde ) oTBar:addItem( "Select All" , cResPath + "selectall.png" , , , , , "SelectAll" ) oTBar:addItem( "Column/Stream Selection" , cResPath + "stream.png" , , , , , "19" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) - oTBar:addItem( "Find" , cResPath + "find.png" , , , , , "20" ) - oTBar:addItem( "Search" , cResPath + "search.png" , , , , , "21" ) + oTBar:addItem( "Find" , cResPath + "find.png" , , , , , "Find" ) + oTBar:addItem( "Search" , cResPath + "search.png" , , , , , "Search" ) oTBar:addItem( , , , , , XBPTOOLBAR_BUTTON_SEPARATOR ) oTBar:addItem( "Place/Remove Mark" , cResPath + "placeremovemark.png", , , , , "22" ) oTBar:addItem( "Goto Mark" , cResPath + "gotomark.png" , , , , , "23" ) diff --git a/harbour/contrib/hbide/resources/finddialog.ui b/harbour/contrib/hbide/resources/finddialog.ui new file mode 100644 index 0000000000..4830a6662f --- /dev/null +++ b/harbour/contrib/hbide/resources/finddialog.ui @@ -0,0 +1,268 @@ + + + DialogFind + + + + 0 + 0 + 463 + 212 + + + + Find and Replace + + + + true + + + + 12 + 12 + 353 + 189 + + + + + + + + + 10 + 16 + 71 + 16 + + + + Find what: + + + + + + 10 + 132 + 71 + 16 + + + + Replace with: + + + + + + 90 + 40 + 81 + 19 + + + + Match case + + + + + + 260 + 40 + 71 + 19 + + + + List only + + + + + + 88 + 68 + 161 + 49 + + + + + + + + + 12 + 4 + 141 + 19 + + + + Start from cursor position + + + + + + 12 + 24 + 141 + 19 + + + + Entire file + + + + + + + 260 + 68 + 81 + 49 + + + + + + + + + 10 + 4 + 41 + 19 + + + + up + + + + + + 10 + 24 + 51 + 19 + + + + Down + + + + + + + 88 + 12 + 253 + 22 + + + + true + + + + + + 88 + 128 + 253 + 22 + + + + true + + + + + + 88 + 160 + 71 + 19 + + + + Global + + + + + + 248 + 160 + 89 + 19 + + + + No prompting + + + + + + + 376 + 24 + 75 + 24 + + + + Find + + + false + + + true + + + + + + 376 + 140 + 75 + 24 + + + + Replace + + + false + + + false + + + + + + 376 + 172 + 75 + 24 + + + + Close + + + + + + diff --git a/harbour/contrib/hbqt/generator/qt45.qtp b/harbour/contrib/hbqt/generator/qt45.qtp index bf791b2ebd..18b844ff8c 100644 --- a/harbour/contrib/hbqt/generator/qt45.qtp +++ b/harbour/contrib/hbqt/generator/qt45.qtp @@ -260,6 +260,7 @@ QTranslator.qth QTreeView.qth QTreeWidget.qth QTreeWidgetItem.qth +;QUiLoader.qth QUrl.qth QValidator.qth QVariant.qth diff --git a/harbour/contrib/hbqt/hbqt.ch b/harbour/contrib/hbqt/hbqt.ch index 498f4288ec..d0969aa434 100644 --- a/harbour/contrib/hbqt/hbqt.ch +++ b/harbour/contrib/hbqt/hbqt.ch @@ -2169,6 +2169,39 @@ #define QTextDocument_StyleSheetResource 3 // The resource contains CSS. #define QTextDocument_UserResource 100 // The first available value for user defined resource types. +// This enum describes the errors that may be returned by the error() function. +#define QFile_NoError 0 // No error occurred. +#define QFile_ReadError 1 // An error occurred when reading from the file. +#define QFile_WriteError 2 // An error occurred when writing to the file. +#define QFile_FatalError 3 // A fatal error occurred. +#define QFile_ResourceError 4 // +#define QFile_OpenError 5 // The file could not be opened. +#define QFile_AbortError 6 // The operation was aborted. +#define QFile_TimeOutError 7 // A timeout occurred. +#define QFile_UnspecifiedError 8 // An unspecified error occurred. +#define QFile_RemoveError 9 // The file could not be removed. +#define QFile_RenameError 10 // The file could not be renamed. +#define QFile_PositionError 11 // The position in the file could not be changed. +#define QFile_ResizeError 12 // The file could not be resized. +#define QFile_PermissionsError 13 // The file could not be accessed. +#define QFile_CopyError 14 // The file could not be copied. + +#define QFile_NoOptions 0 // No options. + +// This enum is used by the permission() function to report the permissions and ownership of a file. The values may be OR-ed together to test multiple permissions and ownership values. +#define QFile_ReadOwner 0x4000 // The file is readable by the owner of the file. +#define QFile_WriteOwner 0x2000 // The file is writable by the owner of the file. +#define QFile_ExeOwner 0x1000 // The file is executable by the owner of the file. +#define QFile_ReadUser 0x0400 // The file is readable by the user. +#define QFile_WriteUser 0x0200 // The file is writable by the user. +#define QFile_ExeUser 0x0100 // The file is executable by the user. +#define QFile_ReadGroup 0x0040 // The file is readable by the group. +#define QFile_WriteGroup 0x0020 // The file is writable by the group. +#define QFile_ExeGroup 0x0010 // The file is executable by the group. +#define QFile_ReadOther 0x0004 // The file is readable by anyone. +#define QFile_WriteOther 0x0002 // The file is writable by anyone. +#define QFile_ExeOther 0x0001 // The file is executable by anyone. + /*----------------------------------------------------------------------*/ #define _HBQT_CH diff --git a/harbour/contrib/hbqt/hbqt.h b/harbour/contrib/hbqt/hbqt.h index 18fc00d091..50fbd88687 100644 --- a/harbour/contrib/hbqt/hbqt.h +++ b/harbour/contrib/hbqt/hbqt.h @@ -350,6 +350,7 @@ const HB_GC_FUNCS * gcFuncs( void ); #define hbqt_par_QTreeView( n ) ( ( QTreeView * ) hbqt_gcpointer( n ) ) #define hbqt_par_QTreeWidget( n ) ( ( QTreeWidget * ) hbqt_gcpointer( n ) ) #define hbqt_par_QTreeWidgetItem( n ) ( ( QTreeWidgetItem * ) hbqt_gcpointer( n ) ) +#define hbqt_par_QUiLoader( n ) ( ( QUiLoader * ) hbqt_gcpointer( n ) ) #define hbqt_par_QUrl( n ) ( ( QUrl * ) hbqt_gcpointer( n ) ) #define hbqt_par_QValidator( n ) ( ( QValidator * ) hbqt_gcpointer( n ) ) #define hbqt_par_QVariant( n ) ( ( QVariant * ) hbqt_gcpointer( n ) ) diff --git a/harbour/contrib/hbqt/hbqt.hbc b/harbour/contrib/hbqt/hbqt.hbc index 1ecb00ef7a..958a783c92 100644 --- a/harbour/contrib/hbqt/hbqt.hbc +++ b/harbour/contrib/hbqt/hbqt.hbc @@ -10,7 +10,7 @@ libs=hbqt libs=hbqtcore hbqtgui hbqtnetwork {win}libs=version shlwapi -{allwin}libs=QtCore4 QtGui4 QtNetwork4 +{allwin}libs=QtCore4 QtGui4 QtNetwork4 QtUiTools {linux}libs=QtCore QtGui QtNetwork {darwin}libs=/Library/Frameworks/QtCore.framework/QtCore {darwin}libs=/Library/Frameworks/QtGui.framework/QtGui diff --git a/harbour/contrib/hbqt/hbqt_destruct.cpp b/harbour/contrib/hbqt/hbqt_destruct.cpp index 57bed118ce..3b0e22e2b5 100644 --- a/harbour/contrib/hbqt/hbqt_destruct.cpp +++ b/harbour/contrib/hbqt/hbqt_destruct.cpp @@ -66,6 +66,8 @@ #if QT_VERSION >= 0x040500 +#include + static int s_iObjectReleaseMethod = HBQT_RELEASE_WITH_DELETE_LATER; /*----------------------------------------------------------------------*/ @@ -131,6 +133,11 @@ HB_FUNC( HBQT_QTPTR_FROM_GCPOINTER ) } } +HB_FUNC( QT_FINDCHILD ) +{ + hb_retptr( ( QObject * ) hbqt_par_QObject( 1 )->findChild< QObject * >( hbqt_par_QString( 2 ) ) ); +} + #if defined( __HB_DEBUG__ ) #if defined( HB_OS_WIN ) diff --git a/harbour/contrib/hbqt/hbqt_garbage.h b/harbour/contrib/hbqt/hbqt_garbage.h index 2d441d243b..1fc1c2cb1b 100644 --- a/harbour/contrib/hbqt/hbqt_garbage.h +++ b/harbour/contrib/hbqt/hbqt_garbage.h @@ -254,6 +254,7 @@ extern QT_G_FUNC( release_QTranslator ); extern QT_G_FUNC( release_QTreeView ); extern QT_G_FUNC( release_QTreeWidget ); extern QT_G_FUNC( release_QTreeWidgetItem ); +extern QT_G_FUNC( release_QUiLoader ); extern QT_G_FUNC( release_QUrl ); extern QT_G_FUNC( release_QValidator ); extern QT_G_FUNC( release_QVariant ); @@ -522,6 +523,7 @@ extern void * gcAllocate_QTranslator( void * pObj ); extern void * gcAllocate_QTreeView( void * pObj ); extern void * gcAllocate_QTreeWidget( void * pObj ); extern void * gcAllocate_QTreeWidgetItem( void * pObj ); +extern void * gcAllocate_QUiLoader( void * pObj ); extern void * gcAllocate_QUrl( void * pObj ); extern void * gcAllocate_QValidator( void * pObj ); extern void * gcAllocate_QVariant( void * pObj ); diff --git a/harbour/contrib/hbqt/qtcore/QUiLoader.cpp b/harbour/contrib/hbqt/qtcore/QUiLoader.cpp new file mode 100644 index 0000000000..a0a1aeed8e --- /dev/null +++ b/harbour/contrib/hbqt/qtcore/QUiLoader.cpp @@ -0,0 +1,266 @@ +/* + * $Id$ + */ + +/* -------------------------------------------------------------------- */ +/* WARNING: Automatically generated source file. DO NOT EDIT! */ +/* Instead, edit corresponding .qth file, */ +/* or the generator tool itself, and run regenarate. */ +/* -------------------------------------------------------------------- */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Pritpal Bedi + * + * Copyright 2009 Marcos Antonio Gambeta + * www - http://www.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 "hbapi.h" +#include "../hbqt.h" + +/*----------------------------------------------------------------------*/ +#if QT_VERSION >= 0x040500 +/*----------------------------------------------------------------------*/ + +#include + +#include +#include +#include + +/* + * QUiLoader ( QObject * parent = 0 ) + * virtual ~QUiLoader () + */ + +typedef struct +{ + void * ph; + QT_G_FUNC_PTR func; + QPointer< QUiLoader > pq; +} QGC_POINTER_QUiLoader; + +QT_G_FUNC( release_QUiLoader ) +{ + QGC_POINTER_QUiLoader * p = ( QGC_POINTER_QUiLoader * ) Cargo; + + HB_TRACE( HB_TR_DEBUG, ( "release_QUiLoader p=%p", p)); + HB_TRACE( HB_TR_DEBUG, ( "release_QUiLoader ph=%p pq=%p", p->ph, (void *)(p->pq))); + + if( p && p->ph && p->pq ) + { + const QMetaObject * m = ( ( QObject * ) p->ph )->metaObject(); + if( ( QString ) m->className() != ( QString ) "QObject" ) + { + ( ( QUiLoader * ) p->ph )->~QUiLoader(); + p->ph = NULL; + HB_TRACE( HB_TR_DEBUG, ( "release_QUiLoader Object deleted!" ) ); + #if defined(__debug__) + just_debug( " YES release_QUiLoader %i B %i KB", ( int ) hb_xquery( 1001 ), hb_getMemUsed() ); + #endif + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "release_QUiLoader Object Name Missing!" ) ); + #if defined(__debug__) + just_debug( " NO release_QUiLoader" ); + #endif + } + } + else + { + HB_TRACE( HB_TR_DEBUG, ( "release_QUiLoader Object Allready deleted!" ) ); + #if defined(__debug__) + just_debug( " DEL release_QUiLoader" ); + #endif + } +} + +void * gcAllocate_QUiLoader( void * pObj ) +{ + QGC_POINTER_QUiLoader * p = ( QGC_POINTER_QUiLoader * ) hb_gcAllocate( sizeof( QGC_POINTER_QUiLoader ), gcFuncs() ); + + p->ph = pObj; + p->func = release_QUiLoader; + new( & p->pq ) QPointer< QUiLoader >( ( QUiLoader * ) pObj ); + #if defined(__debug__) + just_debug( " new_QUiLoader %i B %i KB", ( int ) hb_xquery( 1001 ), hb_getMemUsed() ); + #endif + return( p ); +} + +HB_FUNC( QT_QUILOADER ) +{ + void * pObj = NULL; + + if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + pObj = new QUiLoader( hbqt_par_QObject( 1 ) ) ; + } + else + { + pObj = new QUiLoader() ; + } + + hb_retptrGC( gcAllocate_QUiLoader( pObj ) ); +} +/* + * void addPluginPath ( const QString & path ) + */ +HB_FUNC( QT_QUILOADER_ADDPLUGINPATH ) +{ + hbqt_par_QUiLoader( 1 )->addPluginPath( hbqt_par_QString( 2 ) ); +} + +/* + * QStringList availableLayouts () const + */ +HB_FUNC( QT_QUILOADER_AVAILABLELAYOUTS ) +{ + hb_retptrGC( gcAllocate_QStringList( new QStringList( hbqt_par_QUiLoader( 1 )->availableLayouts() ) ) ); +} + +/* + * QStringList availableWidgets () const + */ +HB_FUNC( QT_QUILOADER_AVAILABLEWIDGETS ) +{ + hb_retptrGC( gcAllocate_QStringList( new QStringList( hbqt_par_QUiLoader( 1 )->availableWidgets() ) ) ); +} + +/* + * void clearPluginPaths () + */ +HB_FUNC( QT_QUILOADER_CLEARPLUGINPATHS ) +{ + hbqt_par_QUiLoader( 1 )->clearPluginPaths(); +} + +/* + * virtual QAction * createAction ( QObject * parent = 0, const QString & name = QString() ) + */ +HB_FUNC( QT_QUILOADER_CREATEACTION ) +{ + hb_retptr( ( QAction* ) hbqt_par_QUiLoader( 1 )->createAction( hbqt_par_QObject( 2 ), hbqt_par_QString( 3 ) ) ); +} + +/* + * virtual QActionGroup * createActionGroup ( QObject * parent = 0, const QString & name = QString() ) + */ +HB_FUNC( QT_QUILOADER_CREATEACTIONGROUP ) +{ + hb_retptr( ( QActionGroup* ) hbqt_par_QUiLoader( 1 )->createActionGroup( hbqt_par_QObject( 2 ), hbqt_par_QString( 3 ) ) ); +} + +/* + * virtual QLayout * createLayout ( const QString & className, QObject * parent = 0, const QString & name = QString() ) + */ +HB_FUNC( QT_QUILOADER_CREATELAYOUT ) +{ + hb_retptr( ( QLayout* ) hbqt_par_QUiLoader( 1 )->createLayout( hbqt_par_QString( 2 ), hbqt_par_QObject( 3 ), hbqt_par_QString( 4 ) ) ); +} + +/* + * virtual QWidget * createWidget ( const QString & className, QWidget * parent = 0, const QString & name = QString() ) + */ +HB_FUNC( QT_QUILOADER_CREATEWIDGET ) +{ + hb_retptr( ( QWidget* ) hbqt_par_QUiLoader( 1 )->createWidget( hbqt_par_QString( 2 ), hbqt_par_QWidget( 3 ), hbqt_par_QString( 4 ) ) ); +} + +/* + * bool isLanguageChangeEnabled () const + */ +HB_FUNC( QT_QUILOADER_ISLANGUAGECHANGEENABLED ) +{ + hb_retl( hbqt_par_QUiLoader( 1 )->isLanguageChangeEnabled() ); +} + +/* + * QWidget * load ( QIODevice * device, QWidget * parentWidget = 0 ) + */ +HB_FUNC( QT_QUILOADER_LOAD ) +{ + hb_retptr( ( QWidget* ) hbqt_par_QUiLoader( 1 )->load( hbqt_par_QIODevice( 2 ), hbqt_par_QWidget( 3 ) ) ); +} + +/* + * QStringList pluginPaths () const + */ +HB_FUNC( QT_QUILOADER_PLUGINPATHS ) +{ + hb_retptrGC( gcAllocate_QStringList( new QStringList( hbqt_par_QUiLoader( 1 )->pluginPaths() ) ) ); +} + +/* + * void setLanguageChangeEnabled ( bool enabled ) + */ +HB_FUNC( QT_QUILOADER_SETLANGUAGECHANGEENABLED ) +{ + hbqt_par_QUiLoader( 1 )->setLanguageChangeEnabled( hb_parl( 2 ) ); +} + +/* + * void setWorkingDirectory ( const QDir & dir ) + */ +HB_FUNC( QT_QUILOADER_SETWORKINGDIRECTORY ) +{ + hbqt_par_QUiLoader( 1 )->setWorkingDirectory( *hbqt_par_QDir( 2 ) ); +} + +/* + * QDir workingDirectory () const + */ +HB_FUNC( QT_QUILOADER_WORKINGDIRECTORY ) +{ + hb_retptrGC( gcAllocate_QDir( new QDir( hbqt_par_QUiLoader( 1 )->workingDirectory() ) ) ); +} + + +/*----------------------------------------------------------------------*/ +#endif /* #if QT_VERSION >= 0x040500 */ +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/qtcore/TQUiLoader.prg b/harbour/contrib/hbqt/qtcore/TQUiLoader.prg new file mode 100644 index 0000000000..ea3625665d --- /dev/null +++ b/harbour/contrib/hbqt/qtcore/TQUiLoader.prg @@ -0,0 +1,160 @@ +/* + * $Id$ + */ + +/* -------------------------------------------------------------------- */ +/* WARNING: Automatically generated source file. DO NOT EDIT! */ +/* Instead, edit corresponding .qth file, */ +/* or the generator tool itself, and run regenarate. */ +/* -------------------------------------------------------------------- */ + +/* + * Harbour Project source code: + * QT wrapper main header + * + * Copyright 2009 Pritpal Bedi + * + * Copyright 2009 Marcos Antonio Gambeta + * www - http://www.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 QUiLoader INHERIT QObject + + VAR pPtr + + METHOD new() + METHOD configure( xObject ) + + METHOD addPluginPath( cPath ) + METHOD availableLayouts() + METHOD availableWidgets() + METHOD clearPluginPaths() + METHOD createAction( pParent, cName ) + METHOD createActionGroup( pParent, cName ) + METHOD createLayout( cClassName, pParent, cName ) + METHOD createWidget( cClassName, pParent, cName ) + METHOD isLanguageChangeEnabled() + METHOD load( pDevice, pParentWidget ) + METHOD pluginPaths() + METHOD setLanguageChangeEnabled( lEnabled ) + METHOD setWorkingDirectory( pDir ) + METHOD workingDirectory() + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD QUiLoader:new( pParent ) + ::pPtr := Qt_QUiLoader( pParent ) + RETURN Self + + +METHOD QUiLoader:configure( xObject ) + IF hb_isObject( xObject ) + ::pPtr := xObject:pPtr + ELSEIF hb_isPointer( xObject ) + ::pPtr := xObject + ENDIF + RETURN Self + + +METHOD QUiLoader:addPluginPath( cPath ) + RETURN Qt_QUiLoader_addPluginPath( ::pPtr, cPath ) + + +METHOD QUiLoader:availableLayouts() + RETURN Qt_QUiLoader_availableLayouts( ::pPtr ) + + +METHOD QUiLoader:availableWidgets() + RETURN Qt_QUiLoader_availableWidgets( ::pPtr ) + + +METHOD QUiLoader:clearPluginPaths() + RETURN Qt_QUiLoader_clearPluginPaths( ::pPtr ) + + +METHOD QUiLoader:createAction( pParent, cName ) + RETURN Qt_QUiLoader_createAction( ::pPtr, pParent, cName ) + + +METHOD QUiLoader:createActionGroup( pParent, cName ) + RETURN Qt_QUiLoader_createActionGroup( ::pPtr, pParent, cName ) + + +METHOD QUiLoader:createLayout( cClassName, pParent, cName ) + RETURN Qt_QUiLoader_createLayout( ::pPtr, cClassName, pParent, cName ) + + +METHOD QUiLoader:createWidget( cClassName, pParent, cName ) + RETURN Qt_QUiLoader_createWidget( ::pPtr, cClassName, pParent, cName ) + + +METHOD QUiLoader:isLanguageChangeEnabled() + RETURN Qt_QUiLoader_isLanguageChangeEnabled( ::pPtr ) + + +METHOD QUiLoader:load( pDevice, pParentWidget ) + RETURN Qt_QUiLoader_load( ::pPtr, pDevice, pParentWidget ) + + +METHOD QUiLoader:pluginPaths() + RETURN Qt_QUiLoader_pluginPaths( ::pPtr ) + + +METHOD QUiLoader:setLanguageChangeEnabled( lEnabled ) + RETURN Qt_QUiLoader_setLanguageChangeEnabled( ::pPtr, lEnabled ) + + +METHOD QUiLoader:setWorkingDirectory( pDir ) + RETURN Qt_QUiLoader_setWorkingDirectory( ::pPtr, pDir ) + + +METHOD QUiLoader:workingDirectory() + RETURN Qt_QUiLoader_workingDirectory( ::pPtr ) + diff --git a/harbour/contrib/hbqt/qtcore/filelist.mk b/harbour/contrib/hbqt/qtcore/filelist.mk index b72550862f..345bcd3c32 100644 --- a/harbour/contrib/hbqt/qtcore/filelist.mk +++ b/harbour/contrib/hbqt/qtcore/filelist.mk @@ -54,6 +54,7 @@ CPP_SOURCES := \ QTimer.cpp \ QTranslator.cpp \ QUrl.cpp \ + QUiLoader.cpp \ QVariant.cpp \ @@ -103,6 +104,7 @@ PRG_SOURCES := \ TQTime.prg \ TQTimer.prg \ TQTranslator.prg \ + TQUiLoader.prg \ TQUrl.prg \ TQVariant.prg \ diff --git a/harbour/contrib/hbqt/qth/QUiLoader.qth b/harbour/contrib/hbqt/qth/QUiLoader.qth new file mode 100644 index 0000000000..d050ceca12 --- /dev/null +++ b/harbour/contrib/hbqt/qth/QUiLoader.qth @@ -0,0 +1,113 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * QT Source Generator for Harbour + * + * Copyright 2009 Pritpal Bedi + * www - http://www.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. + * + */ +/*----------------------------------------------------------------------*/ +; +; Header File to Generate QT Wrapper Sources +; + + +Inherits = QObject +Type = Core +New = + + + +#include +#include +#include + +/* + * QUiLoader ( QObject * parent = 0 ) + * virtual ~QUiLoader () + */ +HB_FUNC( QT_QUILOADER ) +{ + if( hb_pcount() == 1 && HB_ISPOINTER( 1 ) ) + { + hb_retptr( new QUiLoader( hbqt_par_QObject( 1 ) ) ); + } + else + { + hb_retptr( new QUiLoader() ); + } +} + + + + + + +void addPluginPath ( const QString & path ) +QStringList availableLayouts () const +QStringList availableWidgets () const +void clearPluginPaths () +virtual QAction * createAction ( QObject * parent = 0, const QString & name = QString() ) +virtual QActionGroup * createActionGroup ( QObject * parent = 0, const QString & name = QString() ) +virtual QLayout * createLayout ( const QString & className, QObject * parent = 0, const QString & name = QString() ) +virtual QWidget * createWidget ( const QString & className, QWidget * parent = 0, const QString & name = QString() ) +bool isLanguageChangeEnabled () const +QWidget * load ( QIODevice * device, QWidget * parentWidget = 0 ) +QStringList pluginPaths () const +void setLanguageChangeEnabled ( bool enabled ) +void setWorkingDirectory ( const QDir & dir ) +QDir workingDirectory () const + + + + + + + + + + + diff --git a/harbour/contrib/hbxbp/xbpcombobox.prg b/harbour/contrib/hbxbp/xbpcombobox.prg index 9ee0fde489..5dc222fd47 100644 --- a/harbour/contrib/hbxbp/xbpcombobox.prg +++ b/harbour/contrib/hbxbp/xbpcombobox.prg @@ -81,6 +81,7 @@ CLASS XbpComboBox INHERIT XbpWindow METHOD new() METHOD create() + METHOD createFromQtPtr() METHOD configure() VIRTUAL METHOD destroy() METHOD exeBlock() @@ -162,6 +163,38 @@ METHOD XbpComboBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ +METHOD XbpComboBox:createFromQtPtr( oParent, oOwner, aPos, aSize, aPresParams, lVisible, pQtObject ) + + ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + IF hb_isPointer( pQtObject ) + ::oWidget := QComboBox() + ::oWidget:pPtr := pQtObject + + ELSE + ::oSLE := XbpSLE():new():create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + ::oLB := XbpListBox():new():create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::oWidget := QComboBox():New( ::pParent ) + ::setPosAndSize() + IF ::visible + ::show() + ENDIF + ::oWidget:setLineEdit( ::XbpSLE:oWidget:pPtr ) + ::oWidget:setEditable( ::XbpSLE:editable ) + ::oWidget:setFrame( ::XbpSLE:border ) + + ENDIF + + ::connect( ::pWidget, "highlighted(int)" , {|o,i| ::exeBlock( 1,i,o ) } ) + ::connect( ::pWidget, "activated(int)" , {|o,i| ::exeBlock( 2,i,o ) } ) + //::connect( ::pWidget, "currentIndexChanged(int)", {|o,i| ::exeBlock( 2,i,o ) } ) + + ::AddAsChild( SELF ) + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD XbpComboBox:destroy() ::xbpWindow:destroy() diff --git a/harbour/contrib/hbxbp/xbpparthandler.prg b/harbour/contrib/hbxbp/xbpparthandler.prg index 5290fdbbd8..e30fb76fa2 100644 --- a/harbour/contrib/hbxbp/xbpparthandler.prg +++ b/harbour/contrib/hbxbp/xbpparthandler.prg @@ -86,6 +86,7 @@ CLASS XbpPartHandler METHOD status() METHOD addChild( oXbp ) + METHOD addAsChild() METHOD childFromName( nNameId ) METHOD childList() METHOD delChild( oXbp ) @@ -175,6 +176,16 @@ METHOD addChild( oXbp ) CLASS XbpPartHandler /*----------------------------------------------------------------------*/ +METHOD addAsChild() CLASS XbpPartHandler + + IF !empty( ::oParent ) + ::oParent:addChild( Self ) + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD childFromName( nNameId ) CLASS XbpPartHandler LOCAL i, oXbp diff --git a/harbour/contrib/hbxbp/xbppushbutton.prg b/harbour/contrib/hbxbp/xbppushbutton.prg index 8e6419749a..abceb3e4b4 100644 --- a/harbour/contrib/hbxbp/xbppushbutton.prg +++ b/harbour/contrib/hbxbp/xbppushbutton.prg @@ -88,6 +88,7 @@ CLASS XbpPushButton INHERIT XbpWindow METHOD new() METHOD create() + METHOD createFromQtPtr() METHOD configure() METHOD destroy() @@ -117,8 +118,6 @@ METHOD XbpPushButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ::oWidget := QPushButton():new( QT_PTROF( ::oParent:oWidget ) ) - ::Connect( QT_PTROF( ::oWidget ), "clicked()", {|| ::exeBlock() } ) - ::setPosAndSize() IF ::visible ::oWidget:show() @@ -130,11 +129,43 @@ METHOD XbpPushButton:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ::oWidget:setDefault( .t. ) ENDIF + ::Connect( QT_PTROF( ::oWidget ), "clicked()", {|| ::exeBlock() } ) + ::oParent:AddChild( SELF ) RETURN Self /*----------------------------------------------------------------------*/ +METHOD XbpPushButton:createFromQtPtr( oParent, oOwner, aPos, aSize, aPresParams, lVisible, pQtObject ) + + ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + IF hb_isPointer( pQtObject ) + ::oWidget := QPushButton() + ::oWidget:pPtr := pQtObject + + ELSE + ::oWidget := QPushButton():new( QT_PTROF( ::oParent:oWidget ) ) + ::setPosAndSize() + IF ::visible + ::oWidget:show() + ENDIF + + ::setCaption( ::caption ) + + IF ::default + ::oWidget:setDefault( .t. ) + ENDIF + + ENDIF + + ::Connect( QT_PTROF( ::oWidget ), "clicked()", {|| ::exeBlock() } ) + + ::addAsChild() + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD XbpPushButton:exeBlock() IF hb_isBlock( ::sl_lbClick ) diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index 32838c2793..188dc5c3fe 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -143,6 +143,7 @@ EXPORTED: /* LIFE CYCLE */ METHOD init() METHOD create() + METHOD createFromQtPtr() VIRTUAL METHOD configure() METHOD destroy() @@ -324,6 +325,9 @@ METHOD XbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::aSize := aSize ::visible := lVisible + /* Important : 25 Nov 2009 */ + // DEFAULT ::oParent TO SetAppWindow() + ::XbpPartHandler:create( oParent, oOwner ) IF !empty( aPresParams ) @@ -731,8 +735,8 @@ METHOD XbpWindow:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible METHOD XbpWindow:destroy() LOCAL cXbp := __ObjGetClsName( self ) -HBXBP_DEBUG( ". " ) -HBXBP_DEBUG( ThreadID(),"Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ), memory( 1001 ), hbqt_getMemUsed() ) +//HBXBP_DEBUG( ". " ) +//HBXBP_DEBUG( ThreadID(),"Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ), memory( 1001 ), hbqt_getMemUsed() ) IF cXbp == "XBPDIALOG" SetEventLoop( NIL ) @@ -769,7 +773,7 @@ HBXBP_DEBUG( ThreadID(),"Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(:: ::oWidget:pPtr := 0 ::oWidget := NIL -HBXBP_DEBUG( ThreadID()," Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ), memory( 1001 ), hbqt_getMemUsed() ) +//HBXBP_DEBUG( ThreadID()," Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::cargo),'',str(::cargo) ), memory( 1001 ), hbqt_getMemUsed() ) RETURN NIL