From aed1fe0897d82a06397695d18a0fe96cdc1d6619 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 31 Aug 2012 22:51:06 +0000 Subject: [PATCH] 2012-08-31 15:43 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/browse.prg * contrib/hbide/docks.prg * contrib/hbide/hbide.ch * contrib/hbide/hbide.hbp * contrib/hbide/hbqreportsmanager.prg * contrib/hbide/main.prg * contrib/hbide/object.prg + contrib/hbide/parts.prg + Separated: the code to manage IdePARTS effectively and efficiently, in anticipation that many more extensions will be added in future and also some existing components qualifies to fall under the domain of this protocol. --- harbour/ChangeLog | 14 ++ harbour/contrib/hbide/browse.prg | 27 +-- harbour/contrib/hbide/docks.prg | 67 +----- harbour/contrib/hbide/hbide.ch | 5 + harbour/contrib/hbide/hbide.hbp | 1 + harbour/contrib/hbide/hbqreportsmanager.prg | 59 +----- harbour/contrib/hbide/main.prg | 16 +- harbour/contrib/hbide/object.prg | 1 + harbour/contrib/hbide/parts.prg | 219 ++++++++++++++++++++ 9 files changed, 263 insertions(+), 146 deletions(-) create mode 100644 harbour/contrib/hbide/parts.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b84e051677..8f0c11b7aa 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2012-08-31 15:43 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/browse.prg + * contrib/hbide/docks.prg + * contrib/hbide/hbide.ch + * contrib/hbide/hbide.hbp + * contrib/hbide/hbqreportsmanager.prg + * contrib/hbide/main.prg + * contrib/hbide/object.prg + + contrib/hbide/parts.prg + + Separated: the code to manage IdePARTS effectively and efficiently, + in anticipation that many more extensions will be added in future + and also some existing components qualifies to fall under the + domain of this protocol. + 2012-08-31 09:17 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/uisrcmanager.prg ! Fixed: error pertaining to QPalette() reported by Maurizio, thanks. diff --git a/harbour/contrib/hbide/browse.prg b/harbour/contrib/hbide/browse.prg index 33abfeeb86..74ef1589fa 100644 --- a/harbour/contrib/hbide/browse.prg +++ b/harbour/contrib/hbide/browse.prg @@ -73,8 +73,8 @@ /*----------------------------------------------------------------------*/ -#define __dockDbu_dragEnterEvent__ 2011 -#define __dockDbu_dropEvent__ 2012 +#define __dbu_dragEnterEvent__ 2011 +#define __dbu_dropEvent__ 2012 #define __dbStruct_closeEvent__ 2013 #define __fieldsTable_itemSelectionChanged__ 2014 #define __buttonCopyStruct_clicked__ 2015 @@ -192,7 +192,7 @@ CLASS IdeBrowseManager INHERIT IdeObject METHOD create( oIde ) METHOD show() METHOD open( aDbfs ) - METHOD destroy() + METHOD destroy() VIRTUAL METHOD buildToolbar() METHOD execEvent( nEvent, p, p1 ) METHOD addArray( aData, aAttr ) @@ -242,20 +242,16 @@ METHOD IdeBrowseManager:new( oIde ) /*----------------------------------------------------------------------*/ METHOD IdeBrowseManager:create( oIde ) - LOCAL qDock SET DELETED ( ::lDeletedOn ) DEFAULT oIde TO ::oIde ::oIde := oIde - qDock := ::oIde:oEM:oQScintillaDock:oWidget - - qDock:setAcceptDrops( .t. ) - qDock:connect( QEvent_DragEnter, {|p| ::execEvent( __dockDbu_dragEnterEvent__, p ) } ) - qDock:connect( QEvent_Drop , {|p| ::execEvent( __dockDbu_dropEvent__ , p ) } ) - ::qDbu := QWidget() + ::qDbu:setAcceptDrops( .t. ) + ::qDbu:connect( QEvent_DragEnter, {|p| ::execEvent( __dbu_dragEnterEvent__, p ) } ) + ::qDbu:connect( QEvent_Drop , {|p| ::execEvent( __dbu_dropEvent__ , p ) } ) /* Layout applied to dbu widget */ ::qLayout := QGridLayout() @@ -302,15 +298,10 @@ METHOD IdeBrowseManager:create( oIde ) /*----------------------------------------------------------------------*/ -METHOD IdeBrowseManager:destroy() - RETURN Self - -/*----------------------------------------------------------------------*/ - METHOD IdeBrowseManager:showInIdeDBU() ::oQScintillaDock:oWidget:hide() - ::oIde:oStackDbuLayout:addWidget( ::qDbu, 0, 0, 1, 1 ) + ::oParts:addWidget( IDE_PART_DBU, ::qDbu, 0, 0, 1, 1 ) ::qDbu:show() ::qTimer:start() @@ -552,11 +543,11 @@ METHOD IdeBrowseManager:execEvent( nEvent, p, p1 ) ENDIF SWITCH nEvent - CASE __dockDbu_dragEnterEvent__ + CASE __dbu_dragEnterEvent__ p:acceptProposedAction() EXIT - CASE __dockDbu_dropEvent__ + CASE __dbu_dropEvent__ qMime := p:mimeData() IF qMime:hasUrls() qList := qMime:urls() diff --git a/harbour/contrib/hbide/docks.prg b/harbour/contrib/hbide/docks.prg index ff0f007110..0eecab9d2d 100644 --- a/harbour/contrib/hbide/docks.prg +++ b/harbour/contrib/hbide/docks.prg @@ -145,8 +145,6 @@ CLASS IdeDocks INHERIT IdeObject DATA qAct2 DATA cOldView INIT "" - DATA nCurStacksIndex INIT 0 - METHOD new( oIde ) METHOD create( oIde ) METHOD destroy() @@ -209,7 +207,6 @@ CLASS IdeDocks INHERIT IdeObject METHOD buildUISrcDock() METHOD buildSelectedTextToolbar() METHOD showSelectedTextToolbar( oEdit ) - METHOD execIdeStackChanged( nIndex ) ENDCLASS @@ -444,33 +441,7 @@ METHOD IdeDocks:buildDialog() ::oIde:oDa := ::oDlg:drawingArea - /* Stackifying HbIDE : Important to carry this Ide to next levels */ - // - ::oIde:oDALayout := QGridLayout() - ::oIde:oDALayout:setContentsMargins( 0,0,0,0 ) - ::oIde:oDALayout:setHorizontalSpacing( 0 ) - ::oIde:oDALayout:setVerticalSpacing( 0 ) - ::oIde:oDa:setLayout( ::oIde:oDALayout ) - - ::oIde:oIdeStacks := QStackedWidget( ::oIde:oDa:oWidget ) - ::oIde:oDALayout:addWidget( ::oIde:oIdeStacks, 0, 0, 1, 1 ) - - ::oIde:oStackEditor := QWidget( ::oIde:oIdeStacks ) - ::oIde:oIdeStacks:addWidget( ::oIde:oStackEditor ) - - ::oIde:oStackDbu := QWidget( ::oIde:oIdeStacks ) - ::oIde:oIdeStacks:addWidget( ::oIde:oStackDbu ) - ::oIde:oStackDbuLayout := QGridLayout() - ::oIde:oStackDbuLayout:setContentsMargins( 0,0,0,0 ) - ::oIde:oStackDbuLayout:setHorizontalSpacing( 0 ) - ::oIde:oStackDbuLayout:setVerticalSpacing( 0 ) - ::oIde:oStackDbu:setLayout( ::oIde:oStackDbuLayout ) - - ::oIde:oIdeStacks:setCurrentIndex( 0 ) /* By default Editor */ - - ::oIde:oIdeStacks:connect( "currentChanged(int)", {|i| ::execIdeStackChanged( i ) } ) - // - /*----------------------------------------------------------------*/ + ::oParts:buildParts() SetAppWindow( ::oDlg ) @@ -483,21 +454,14 @@ METHOD IdeDocks:buildDialog() /* StatusBar */ ::buildStatusBar() - /* Attach GRID Layout to Editor Area - Futuristic */ - ::oIde:qLayout := QGridLayout() - ::oIde:qLayout:setContentsMargins( 0,0,0,0 ) - ::oIde:qLayout:setHorizontalSpacing( 0 ) - ::oIde:qLayout:setVerticalSpacing( 0 ) - // - ::oIde:oStackEditor:setLayout( ::qLayout ) ::buildMdiToolbar() - ::qLayout:addWidget( ::qMdiToolbar:oWidget , 0, 0, 1, 2 ) + ::oParts:addWidget( IDE_PART_EDITOR, ::qMdiToolbar:oWidget , 0, 0, 1, 2 ) ::buildMdiToolbarLeft() - ::qLayout:addWidget( ::qMdiToolbarL:oWidget , 1, 0, 1, 1 ) + ::oParts:addWidget( IDE_PART_EDITOR, ::qMdiToolbarL:oWidget , 1, 0, 1, 1 ) ::buildStackedWidget() - ::qLayout:addWidget( ::oStackedWidget:oWidget, 1, 1, 1, 1 ) + ::oParts:addWidget( IDE_PART_EDITOR, ::oStackedWidget:oWidget , 1, 1, 1, 1 ) ::buildSearchReplaceWidget() - ::qLayout:addWidget( ::oSearchReplace:oUI:oWidget , 2, 0, 1, 2 ) // Changed + ::oParts:addWidget( IDE_PART_EDITOR, ::oSearchReplace:oUI:oWidget, 2, 0, 1, 2 ) /* Normalize Views */ FOR EACH s IN ::oINI:aViews @@ -573,27 +537,6 @@ METHOD IdeDocks:buildDialog() /*----------------------------------------------------------------------*/ -#define IDE_STACK_EDITOR 0 -#define IDE_STACK_DBU 1 - -METHOD IdeDocks:execIdeStackChanged( nIndex ) - - SWITCH nIndex - CASE IDE_STACK_EDITOR - ::oIde:oSBar:show() - EXIT - CASE IDE_STACK_DBU - ::oIde:oSBar:hide() - ::oBM:showInIdeDBU() - EXIT - ENDSWITCH - - ::nCurStacksIndex := nIndex - - RETURN Self - -/*----------------------------------------------------------------------*/ - METHOD IdeDocks:buildDockWidgets() ::buildProjectTree() diff --git a/harbour/contrib/hbide/hbide.ch b/harbour/contrib/hbide/hbide.ch index e1ca377f5f..3614e48e6a 100644 --- a/harbour/contrib/hbide/hbide.ch +++ b/harbour/contrib/hbide/hbide.ch @@ -144,4 +144,9 @@ #define ACT_CHECKABLE 5 #define ACT_VISINMENU 6 +#define IDE_PART_EDITOR 0 +#define IDE_PART_DBU 1 +#define IDE_PART_REPORTSDESIGNER 2 +#define IDE_PART_CUISCREENDESIGNER 3 + #endif diff --git a/harbour/contrib/hbide/hbide.hbp b/harbour/contrib/hbide/hbide.hbp index e0d6062e8f..a2f23ce60c 100644 --- a/harbour/contrib/hbide/hbide.hbp +++ b/harbour/contrib/hbide/hbide.hbp @@ -27,6 +27,7 @@ hbformat.hbc rddads.hbc main.prg +parts.prg object.prg stylesheets.prg tags.prg diff --git a/harbour/contrib/hbide/hbqreportsmanager.prg b/harbour/contrib/hbide/hbqreportsmanager.prg index 53d4eb009a..d88f0faf12 100644 --- a/harbour/contrib/hbide/hbqreportsmanager.prg +++ b/harbour/contrib/hbide/hbqreportsmanager.prg @@ -244,7 +244,7 @@ CLASS HbqReportsManager METHOD new( qParent ) METHOD create( qParent ) - METHOD destroy() + METHOD destroy() VIRTUAL METHOD execEvent( nEvent, p, p1, p2 ) METHOD buildToolbar() METHOD buildToolbarAlign() @@ -333,61 +333,6 @@ METHOD HbqReportsManager:create( qParent ) /*----------------------------------------------------------------------*/ -METHOD HbqReportsManager:destroy() - - ::qTreeObjects:disconnect( "itemClicked(QTreeWidgetItem*,int)" ) - - ::qParent := NIL - - ::aSources := NIL - ::aPages := NIL - ::qToolbar := NIL - ::qToolbarAlign := NIL - ::qToolbarL := NIL - - ::qLayoutD := NIL - ::qSpliter := NIL - ::qFrameL := NIL - - ::qScene := NIL - - ::qView := NIL - ::qFrameR := NIL - - ::qLayL := NIL - ::qSplL := NIL - - ::qLayR := NIL - - ::qTabL0 := NIL - ::qTabL1 := NIL - ::qTabR1 := NIL - - ::qPageL01 := NIL - ::qPageL02 := NIL - ::qPageL11 := NIL - - ::qTreeObjects := NIL - - ::qPageL12 := NIL - - ::qTreeProp := NIL - ::qEditDesc := NIL - - ::qSplR := NIL - ::qPageR11 := NIL - ::qPageR12 := NIL - ::qPageR13 := NIL - - ::qPageR11Lay := NIL - - ::qTreeData := NIL - ::qPageR11Lay := NIL - - RETURN Self - -/*----------------------------------------------------------------------*/ - METHOD HbqReportsManager:buildDesignReport() ::qLayoutD := QHBoxLayout() @@ -931,7 +876,7 @@ METHOD HbqReportsManager:loadReport( xData ) cBuffer := hb_utf8tostr( hb_memoread( xData ) ) IF !empty( ::qParent ) - ::qParent:setWindowTitle( "HBReportsManager : " + ::cSaved ) + ::qParent:setWindowTitle( "HbReportsManager : " + ::cSaved ) ENDIF ELSE ::cSaved := "" diff --git a/harbour/contrib/hbide/main.prg b/harbour/contrib/hbide/main.prg index 413fddc5d9..dab16617b2 100644 --- a/harbour/contrib/hbide/main.prg +++ b/harbour/contrib/hbide/main.prg @@ -172,6 +172,7 @@ CLASS HbIde DATA oCUI /* CUI Screen Designer Console */ DATA oUiS /* UI Source Writer */ DATA oPWZ /* Project Wizard */ + DATA oParts /* HbIDE Parts Manager */ DATA nRunMode INIT HBIDE_RUN_MODE_INI DATA nAnimantionMode INIT HBIDE_ANIMATION_NONE @@ -192,13 +193,7 @@ CLASS HbIde DATA aHbpOnCmdLine INIT {} DATA aDbfOnCmdLine INIT {} - /* HBQT Objects */ - DATA oIdeStacks - DATA oDALayout - DATA oStackEditor - DATA oStackDbu - DATA oStackDbuLayout - DATA qLayout +// DATA qLayout DATA qTabWidget DATA oTabParent @@ -619,6 +614,9 @@ METHOD HbIde:create( aParams ) /* Set Codec at the Begining - no interface display */ hb_cdpSelect( ::cWrkCodec ) + /* Parts Manager */ + ::oParts := IdeParts():new( Self ):create() + /* Load IDE|User defined Themes */ ::oTH := IdeThemes():new( Self, ::oINI:getThemesFile() ):create() @@ -1004,10 +1002,10 @@ METHOD HbIde:execAction( cKey ) ::oHelpDock:show() EXIT CASE "DBU" - ::oIdeStacks:setCurrentIndex( 1 ) + ::oParts:setStack( 1 ) EXIT CASE "EDITOR" - ::oIdeStacks:setCurrentIndex( 0 ) + ::oParts:setStack( 0 ) EXIT ENDSWITCH diff --git a/harbour/contrib/hbide/object.prg b/harbour/contrib/hbide/object.prg index 108c07ae63..9c6067255a 100644 --- a/harbour/contrib/hbide/object.prg +++ b/harbour/contrib/hbide/object.prg @@ -105,6 +105,7 @@ CLASS IdeObject ACCESS oCUI INLINE ::oIde:oCUI ACCESS oUiS INLINE ::oIde:oUiS ACCESS oPWZ INLINE ::oIde:oPWZ + ACCESS oParts INLINE ::oIde:oParts ACCESS aMeta INLINE ::oIde:aMeta ACCESS aTags INLINE ::oIde:aTags diff --git a/harbour/contrib/hbide/parts.prg b/harbour/contrib/hbide/parts.prg new file mode 100644 index 0000000000..515ffb99ae --- /dev/null +++ b/harbour/contrib/hbide/parts.prg @@ -0,0 +1,219 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2012 Pritpal Bedi + * 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. + * + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* + * EkOnkar + * ( The LORD is ONE ) + * + * Harbour-Qt IDE + * + * Pritpal Bedi + * 31Aug2012 + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "common.ch" +#include "hbclass.ch" +#include "hbqtgui.ch" +#include "hbide.ch" + +/*----------------------------------------------------------------------*/ + +CLASS IdeParts INHERIT IdeObject + + DATA oIde + DATA nCurStacksIndex INIT IDE_PART_EDITOR + + DATA oLayoutDA + DATA oLayoutEditor + DATA oLayoutDbu + + DATA oStackWidget + + DATA oStackEditor + DATA oStackDbu + + DATA oSettings + + METHOD new( oIde ) + METHOD create( oIde ) + METHOD destroy() VIRTUAL + + METHOD buildParts() + METHOD buildLayout( nLayout ) + + METHOD setStack( nIndex ) INLINE ::oStackWidget:setCurrentIndex( nIndex ) + + METHOD execStackIndexChanged( nIndex ) + METHOD addWidget( nPart, oWidget, nFromRow, nFromColumn, nRowSpan, nColumnSpan ) + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD IdeParts:new( oIde ) + + DEFAULT oIde TO ::oIde + ::oIde := oIde + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeParts:create( oIde ) + + DEFAULT oIde TO ::oIde + ::oIde := oIde + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeParts:buildLayout( nLayout ) + LOCAL oLayout + + SWITCH nLayout + CASE 0 + oLayout := QGridLayout() + oLayout:setContentsMargins( 0,0,0,0 ) + oLayout:setHorizontalSpacing( 0 ) + oLayout:setVerticalSpacing( 0 ) + EXIT + CASE 1 /* QHBoxLayout */ + EXIT + CASE 2 /* QVBoxLayout */ + EXIT + ENDSWITCH + + RETURN oLayout + +/*----------------------------------------------------------------------*/ + +METHOD IdeParts:buildParts() + + ::oLayoutDA := ::buildLayout( 0 ) + ::oLayoutDbu := ::buildLayout( 0 ) + ::oLayoutEditor := ::buildLayout( 0 ) + + ::oDa:setLayout( ::oLayoutDA ) + + ::oStackWidget := QStackedWidget( ::oDa:oWidget ) + // + ::oStackEditor := QWidget( ::oStackWidget ) + ::oStackDbu := QWidget( ::oStackWidget ) + // + ::oStackWidget:addWidget( ::oStackEditor ) + ::oStackWidget:addWidget( ::oStackDbu ) + + ::oStackEditor:setLayout( ::oLayoutEditor ) + ::oStackDbu :setLayout( ::oLayoutDbu ) + + ::oLayoutDA:addWidget( ::oStackWidget, 0, 0, 1, 1 ) + + ::oStackWidget:setCurrentIndex( 0 ) + ::oStackWidget:connect( "currentChanged(int)", {|i| ::execStackIndexChanged( i ) } ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeParts:execStackIndexChanged( nIndex ) + + IF ! Empty( ::oSettings ) + ::oDlg:oWidget:restoreState( ::oSettings ) + ENDIF + ::oSettings := ::oDlg:oWidget:saveState() + + SWITCH nIndex + + CASE IDE_PART_EDITOR + ::oIde:oSBar:show() + EXIT + + CASE IDE_PART_DBU + ::oIde:oSBar:hide() + ::oDK:hideAllDocks() + ::oBM:showInIdeDBU() + EXIT + + ENDSWITCH + + ::nCurStacksIndex := nIndex + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeParts:addWidget( nPart, oWidget, nFromRow, nFromColumn, nRowSpan, nColumnSpan ) + + SWITCH nPart + + CASE IDE_PART_EDITOR + ::oLayoutEditor:addWidget( oWidget, nFromRow, nFromColumn, nRowSpan, nColumnSpan ) + EXIT + + CASE IDE_PART_DBU + ::oLayoutDbu:addWidget( oWidget, nFromRow, nFromColumn, nRowSpan, nColumnSpan ) + EXIT + + CASE IDE_PART_REPORTSDESIGNER + EXIT + + ENDSWITCH + + RETURN Self + +/*----------------------------------------------------------------------*/ +