From 7a3a4a1bef723c0d2563cc932273502fcfae7815 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 15 Mar 2012 17:38:07 +0000 Subject: [PATCH] 2012-03-15 10:31 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/idemain.prg * contrib/hbide/idesources.prg * contrib/hbide/ideuisrcmanager.prg + Implemented: click on a .ui note in will open the dock containing .ui widget. + Implemented: modifying a "cls_*ui.prg" in the editor will refresh the related .ui in the "UI Src Manager> if it is already opened there. This facilitates the 2-way editing of event methods. --- harbour/ChangeLog | 10 ++ harbour/contrib/hbide/idemain.prg | 10 +- harbour/contrib/hbide/idesources.prg | 16 +- harbour/contrib/hbide/ideuisrcmanager.prg | 171 +++++++++++++++++----- 4 files changed, 159 insertions(+), 48 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 67f642f043..7503444456 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,16 @@ The license applies to all entries newer than 2009-04-28. */ +2012-03-15 10:31 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/idemain.prg + * contrib/hbide/idesources.prg + * contrib/hbide/ideuisrcmanager.prg + + Implemented: click on a .ui note in will open + the dock containing .ui widget. + + Implemented: modifying a "cls_*ui.prg" in the editor will + refresh the related .ui in the "UI Src Manager> if it is already + opened there. This facilitates the 2-way editing of event methods. + 2012-03-14 02:14 UTC+0100 Viktor Szakats (harbour syenar.net) * contrib/hbqt/tests/ideui.hbp ! fixed non-portable local system dependent option. diff --git a/harbour/contrib/hbide/idemain.prg b/harbour/contrib/hbide/idemain.prg index 0f8ac697ff..fc0b4fb622 100644 --- a/harbour/contrib/hbide/idemain.prg +++ b/harbour/contrib/hbide/idemain.prg @@ -1356,7 +1356,7 @@ METHOD HbIde:updateProjectTree( aPrj ) /*----------------------------------------------------------------------*/ METHOD HbIde:manageItemSelected( oXbpTreeItem ) - LOCAL n, cHbp + LOCAL n, cHbp, cSource, cExt IF oXbpTreeItem == ::oProjRoot n := -1 @@ -1375,7 +1375,13 @@ METHOD HbIde:manageItemSelected( oXbpTreeItem ) ::oPM:loadProperties( cHbp, .f., .t., .f. ) CASE ::aProjData[ n, TRE_TYPE ] == "Source File" - ::oSM:editSource( hbide_stripFilter( ::aProjData[ n, TRE_ORIGINAL ] ) ) + cSource := hbide_stripFilter( ::aProjData[ n, TRE_ORIGINAL ] ) + hb_fNameSplit( cSource, , , @cExt ) + IF lower( cExt ) == ".ui" + ::oUiS:openUi( cSource ) + ELSE + ::oSM:editSource( cSource ) + ENDIF CASE ::aProjData[ n, TRE_TYPE ] == "Opened Source" ::oEM:setSourceVisible( ::aProjData[ n, TRE_DATA ] ) diff --git a/harbour/contrib/hbide/idesources.prg b/harbour/contrib/hbide/idesources.prg index 036ceb5ec0..5e4166edaa 100644 --- a/harbour/contrib/hbide/idesources.prg +++ b/harbour/contrib/hbide/idesources.prg @@ -213,7 +213,7 @@ METHOD IdeSourcesManager:editSource( cSourceFile, nPos, nHPos, nVPos, cTheme, cV */ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs ) LOCAL oEdit, lNew, cBuffer, qDocument, nIndex, cSource, cFileTemp - LOCAL cFileToSave, cFile, cExt, cNewFile, oItem + LOCAL cFileToSave, cPath, cFile, cExt, cNewFile, oItem DEFAULT nTab TO ::oEM:getTabCurrent() DEFAULT lAs TO .F. @@ -256,7 +256,7 @@ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs ) RETURN .F. ENDIF - hb_fNameSplit( cFileToSave, , @cFile, @cExt ) + hb_fNameSplit( cFileToSave, @cPath, @cFile, @cExt ) IF lNew oEdit:sourceFile := cFileToSave @@ -286,6 +286,10 @@ METHOD IdeSourcesManager:saveSource( nTab, lCancel, lAs ) cFileTemp := hbide_pathToOSPath( oEdit:cPath + oEdit:cFile + oEdit:cExt + ".tmp" ) ferase( cFileTemp ) + + IF left( lower( cFile ), 4 ) == "cls_" + ::oUiS:reloadIfOpen( lower( cPath ) + lower( substr( cFile, 5 ) ) + ".ui" ) + ENDIF ENDIF ENDIF @@ -298,7 +302,7 @@ METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled, lAsk ) DEFAULT nTab TO ::oEM:getTabCurrent() DEFAULT lAsk TO .t. - + IF !empty( oEditor := ::oEM:getEditorByTabPosition( nTab ) ) DEFAULT lCanCancel TO .F. @@ -315,11 +319,11 @@ METHOD IdeSourcesManager:closeSource( nTab, lCanCancel, lCanceled, lAsk ) lSave := ( n == QMessageBox_Yes ) ELSE - IF lAsk + IF lAsk lSave := hbide_getYesNo( oEditor:oTab:Caption, "has been modified, save this source?", 'Save?' ) - ELSE + ELSE lSave := .t. - ENDIF + ENDIF ENDIF IF lSave .AND. !( ::saveSource( nTab, @lCanceled ) ) diff --git a/harbour/contrib/hbide/ideuisrcmanager.prg b/harbour/contrib/hbide/ideuisrcmanager.prg index 028c372240..89c30785bf 100644 --- a/harbour/contrib/hbide/ideuisrcmanager.prg +++ b/harbour/contrib/hbide/ideuisrcmanager.prg @@ -155,6 +155,8 @@ CLASS IdeUISrcManager INHERIT IdeObject METHOD buildToolbar() METHOD buildToolButton( qToolbar, aBtn ) METHOD buildStatusPanels() + METHOD openUi( cUI ) + METHOD reloadIfOpen( cUI ) METHOD buildUiWidget( cUI ) METHOD buildWidget( cBuffer, cPath, cName, cExt, aPrg ) METHOD runHbmk2( cUI ) @@ -166,8 +168,8 @@ CLASS IdeUISrcManager INHERIT IdeObject METHOD outputText( cText ) METHOD loadActions( oWidget, cName ) METHOD exposeAction() - METHOD loadMethod( cObjName, cAction ) - METHOD saveMethod( cObjName, cAction ) + METHOD loadMethod() + METHOD saveMethod() METHOD buildClassSkeleton( cCls, cUiName ) METHOD getCurrentSlot() @@ -249,6 +251,7 @@ METHOD IdeUISrcManager:show() ::qFrame := QFrame() ::qHBLayout := QHBoxLayout() + ::qHBLayout:setContentsMargins( 0, 0, 0, 0 ) ::qFrame:setLayout( ::qHBLayout ) ::qSplitter:addWidget( ::qFrame ) @@ -323,15 +326,17 @@ METHOD IdeUISrcManager:execEvent( cEvent, p, p1 ) CASE "child_object" IF empty( ::qCurrent ) .OR. ! ( ::qCurrent == p ) - IF ! empty( ::cCurAction ) - ::saveMethod( ::qCurrent:objectName(), ::cCurAction ) - ENDIF + ::saveMethod() + ::qCurrent := p + ::cCurAction := "" +msgbox( "212" ) ::qFocus:setWidget( p ) ::aStatusPnls[ PNL_OBJECTS ]:setText( "OBJ: " + p1 + "" ) ::aStatusPnls[ PNL_TYPE ]:setText( "CLASS: " + lower(__objGetClsName( p ) ) + "" ) p:clearFocus() ::loadActions( p, p1 ) +msgbox( "212000" ) ENDIF EXIT @@ -346,27 +351,38 @@ METHOD IdeUISrcManager:execEvent( cEvent, p, p1 ) METHOD IdeUISrcManager:getCurrentSlot() LOCAL cCls := __objGetClsName( ::qCurrent ) - + SWITCH ::cCurAction CASE "Activated" IF cCls == "QTOOLBUTTON" .OR. "QPUSHBUTTON" RETURN "clicked()" - ENDIF - EXIT + ENDIF + EXIT CASE "Icon" /* just */ - EXIT - ENDSWITCH - + EXIT + ENDSWITCH + RETURN "" - + /*----------------------------------------------------------------------*/ -METHOD IdeUISrcManager:saveMethod( cObjName, cAction ) +METHOD IdeUISrcManager:saveMethod() LOCAL cSrc, n, n0, n1, n2, n3, cMtd, i, aSrc, cSearch, cSlot - LOCAL cMethod := cObjName + "_" + upper( left( cAction,1 ) ) + lower( substr( cAction, 2 ) ) + LOCAL cMethod, cObjName, cAction - cMtd := "METHOD " + ::cClsPrefix + ::cName + ":" + cMethod + "( ... )" - cSrc := ::qEdit:toPlainText() + IF empty( ::qCurrent ) + RETURN Self + ENDIF + + cObjName := ::qCurrent:objectName() + cAction := ::cCurAction + IF empty( cAction ) .OR. ! ::qEdit:document():isModified() + RETURN Self + ENDIF + + cMethod := cObjName + "_" + upper( left( cAction,1 ) ) + lower( substr( cAction, 2 ) ) + cMtd := "METHOD " + ::cClsPrefix + ::cName + ":" + cMethod + "( ... )" + cSrc := ::qEdit:toPlainText() n0 := ascan( ::aSource, {|e| "" $ e } ) n1 := ascan( ::aSource, {|e| "" $ e } ) @@ -411,21 +427,37 @@ METHOD IdeUISrcManager:saveMethod( cObjName, cAction ) ENDIF IF ! empty( cSlot := ::getCurrentSlot() ) + // Connections n0 := ascan( ::aSource, {|e| "" $ e } ) - n1 := ascan( ::aSource, {|e| "" $ e } ) + n1 := ascan( ::aSource, {|e| "" $ e }, n0 ) cSearch := '::oUI:qObj[ "' + cObjName + '" ]' n2 := ascan( ::aSource, {|e| cSearch $ e }, n0+1, n1-n0-1 ) IF empty( cSrc ) IF n2 > 0 hb_adel( ::aSource, n2, .t. ) - ENDIF + ENDIF ELSE IF n2 == 0 hb_ains( ::aSource, n0+1, ' ::oUI:qObj[ "' + cObjName + '" ]:connect( "' + cSlot + '", {|...| ::' + cMethod + '( ... ) } )' ) - ENDIF + ENDIF ENDIF - ENDIF - + // Disconnections + n0 := ascan( ::aSource, {|e| "" $ e } ) + n1 := ascan( ::aSource, {|e| "" $ e }, n0 ) + cSearch := '::oUI:qObj[ "' + cObjName + '" ]' + n2 := ascan( ::aSource, {|e| cSearch $ e }, n0+1, n1-n0-1 ) + IF empty( cSrc ) + IF n2 > 0 + hb_adel( ::aSource, n2, .t. ) + ENDIF + ELSE + IF n2 == 0 + hb_ains( ::aSource, n0+1, ' ::oUI:qObj[ "' + cObjName + '" ]:disconnect( "' + cSlot + '" )' ) + ENDIF + ENDIF + + ENDIF + ::qEdit:document():clear() ::buildSource() /* Temporary */ @@ -433,9 +465,17 @@ METHOD IdeUISrcManager:saveMethod( cObjName, cAction ) /*----------------------------------------------------------------------*/ -METHOD IdeUISrcManager:loadMethod( cObjName, cAction ) +METHOD IdeUISrcManager:loadMethod() LOCAL cSrc := "", n0, n1, n2, n3, cMtd, i - LOCAL cMethod := cObjName + "_" + upper( left( cAction,1 ) ) + lower( substr( cAction, 2 ) ) + LOCAL cObjName, cAction, cMethod + + IF empty( ::qCurrent ) + RETURN Self + ENDIF + + cObjName := ::qCurrent:objectName() + cAction := ::cCurAction + cMethod := cObjName + "_" + upper( left( cAction,1 ) ) + lower( substr( cAction, 2 ) ) n0 := ascan( ::aSource, {|e| "" $ e } ) n1 := ascan( ::aSource, {|e| "" $ e } ) @@ -464,29 +504,30 @@ METHOD IdeUISrcManager:exposeAction() RETURN Self ENDIF - IF ! empty( ::cCurAction ) - ::saveMethod( ::qCurrent:objectName(), ::cCurAction ) - ENDIF + ::saveMethod() + ::cCurAction := cText SWITCH __objGetClsName( ::qCurrent ) CASE "QPUSHBUTTON" CASE "QTOOLBUTTON" - SWITCH cText + SWITCH ::cCurAction + CASE "Activated" - ::qEdit:setPlainText( ::loadMethod( ::qCurrent:objectName(), "Activated" ) ) + ::qEdit:setPlainText( ::loadMethod() ) ::qEdit:setFocus() EXIT + CASE "Icon" - ::qEdit:setPlainText( ::loadMethod( ::qCurrent:objectName(), "Icon" ) ) + ::qEdit:setPlainText( ::loadMethod() ) ::qEdit:setFocus() EXIT + ENDSWITCH EXIT ENDSWITCH - ::cCurAction := cText RETURN Self /*----------------------------------------------------------------------*/ @@ -523,6 +564,8 @@ METHOD IdeUISrcManager:checkUpdates() METHOD IdeUISrcManager:clear() + ::qCurrent := NIL + ::cCurAction := "" ::qEdit:document():clear() ::qTree:clear() @@ -530,7 +573,6 @@ METHOD IdeUISrcManager:clear() ::aPrg := {} ::qFocus := NIL ::qFocus := QFocusFrame() - ::qFocus:setStyleSheet( "border: 2px red;" ) IF ! empty( ::pHrb ) hb_hrbUnload( ::pHrb ) @@ -550,6 +592,56 @@ METHOD IdeUISrcManager:clear() ::cSrcFile := "" ::aSource := {} + ::cPath := "" + ::cName := "" + ::cExt := "" + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeUISrcManager:reloadIfOpen( cUI ) + LOCAL cPath, cName, cExt + //LOCAL cObjName, cAction, qList + + cUI := hbide_pathToOSPath( lower( cUI ) ) + hb_fNameSplit( cUI, @cPath, @cName, @cExt ) + IF ::cPath == cPath .AND. ::cName == cName +#if 0 + IF ! empty( ::qCurrent ) + cObjName := ::qCurrent:objectName() + cAction := ::cCurAction + ENDIF +#endif + + ::openUi( cUI ) + +#if 0 + IF ! empty( cObjName ) +msgbox( cObjName ) + ::execEvent( "child_object", ::oUI:qObj[ cObjName ], cObjName ) +msgbox( cObjName ) + IF ! empty( cAction ) + qList := ::qTree:findItems( cAction, Qt_MatchExactly, 0 ) +msgbox( hb_ntos( qList:size() ) ) + ::qTree:setCurrentItem( qList:at( 0 ) ) + msgbox( cObjName +" : "+ cAction ) + ENDIF + ENDIF +#endif + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeUISrcManager:openUi( cUI ) + + ::show() + ::oIde:oUiSrcDock:show() + ::clear() + ::buildUiWidget( cUI ) + RETURN Self /*----------------------------------------------------------------------*/ @@ -662,8 +754,8 @@ METHOD IdeUISrcManager:runHbmk2( cUI ) hb_fNameSplit( cUI, @cPath, @cName, @cExt ) - aadd( aHbp, "-hbraw" ) - aadd( aHbp, "-trace" ) + aadd( aHbp, "-hbraw" ) + aadd( aHbp, "-trace" ) aadd( aHbp0, "-q" ) aadd( aHbp0, "-info" ) @@ -672,7 +764,7 @@ METHOD IdeUISrcManager:runHbmk2( cUI ) aadd( aHbp0, "-hblib" ) aadd( aHbp0, "-workdir=" + cPath ) aadd( aHbp0, "hbqt.hbc" ) - aadd( aHbp0, cUI ) + aadd( aHbp0, cUI ) ::oOutputResult:oWidget:clear() @@ -709,7 +801,7 @@ METHOD IdeUISrcManager:runHbmk2( cUI ) IF hb_fileExists( cBatch ) cBuf := memoread( cBatch ) cBuf += "SET " + hb_eol() - cBuf += hb_eol() + cExeHbMk2 + " " + cHbpFileName + " " + cCmdParams + hb_eol() + cBuf += cExeHbMk2 + " " + cHbpFileName + " " + cCmdParams + hb_eol() hb_memowrit( cBatch, cBuf ) ENDIF // @@ -868,7 +960,7 @@ METHOD IdeUISrcManager:buildSource() METHOD IdeUISrcManager:buildClassSkeleton( cCls, cUiName ) LOCAL aSrc := {} LOCAL cClsC := cCls + ":" - + aadd( aSrc, '/*' ) aadd( aSrc, ' * $Id$' ) aadd( aSrc, '' ) @@ -992,12 +1084,11 @@ METHOD IdeUISrcManager:buildClassSkeleton( cCls, cUiName ) aadd( aSrc, ' RETURN Self' ) aadd( aSrc, '' ) aadd( aSrc, '/*----------------------------------------------------------------------*/' ) - aadd( aSrc, '/* . Do not edit code in this section! */' ) + aadd( aSrc, '/* . Do not edit method names in this section, but can edit method body! */' ) aadd( aSrc, '/* */' ) aadd( aSrc, '/*----------------------------------------------------------------------*/' ) aadd( aSrc, '' ) - RETURN aSrc - + RETURN aSrc + /*----------------------------------------------------------------------*/ - \ No newline at end of file