From e52b65be0c944393d3b78e66610baa33ec3117a8 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Wed, 23 May 2012 01:18:00 +0000 Subject: [PATCH] 2012-05-22 18:11 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbptoolbar.prg ! Fixed: one regression based on recent hbQT mem leak fixes. * contrib/hbide/ideedit.prg * Fixed: recursively attching self to some instance variable. * Normalized: code. * contrib/hbide/ideactions.prg * contrib/hbide/idemisc.prg * Fixed: some lost actions resulting after recent hbQT changes. NOTE: more are left still, stay tuned. --- harbour/ChangeLog | 13 ++ harbour/contrib/hbide/ideactions.prg | 5 +- harbour/contrib/hbide/ideedit.prg | 192 +++++++++++++-------------- harbour/contrib/hbide/idemisc.prg | 10 +- harbour/contrib/hbxbp/xbptoolbar.prg | 2 +- 5 files changed, 116 insertions(+), 106 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index c3ffc22359..9e0844c672 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,19 @@ The license applies to all entries newer than 2009-04-28. */ +2012-05-22 18:11 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbxbp/xbptoolbar.prg + ! Fixed: one regression based on recent hbQT mem leak fixes. + + * contrib/hbide/ideedit.prg + * Fixed: recursively attching self to some instance variable. + * Normalized: code. + + * contrib/hbide/ideactions.prg + * contrib/hbide/idemisc.prg + * Fixed: some lost actions resulting after recent hbQT changes. + NOTE: more are left still, stay tuned. + 2012-05-22 14:13 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpfiledialog.prg * Fixed: how :connect()/:disconnect() was applied. diff --git a/harbour/contrib/hbide/ideactions.prg b/harbour/contrib/hbide/ideactions.prg index 2405669750..83905ef18f 100644 --- a/harbour/contrib/hbide/ideactions.prg +++ b/harbour/contrib/hbide/ideactions.prg @@ -79,7 +79,8 @@ CLASS IdeActions INHERIT IdeObject DATA hActions INIT { => } - + DATA oActToolsBtn + METHOD new( oIde ) METHOD create( oIde ) METHOD destroy() @@ -354,7 +355,7 @@ METHOD IdeActions:buildToolBar() oTBar:addItem( ::getAction( "TB_Rebuild" ), , , , , , "Rebuild" ) oTBar:addItem( ::getAction( "TB_RebuildLaunch" ), , , , , , "RebuildLaunch" ) oTBar:addItem( , , , , , nSep ) - oTBar:oWidget:addWidget( ::oIde:oTM:buildToolsButton() ) + ::oActToolsBtn := oTBar:oWidget:addWidget( ::oIde:oTM:buildToolsButton() ) ::oIde:oMainToolbar := oTBar diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 870961b4c1..b455e01356 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -140,10 +140,10 @@ CLASS IdeEdit INHERIT IdeObject METHOD new( oIde, oEditor, nMode ) METHOD create( oIde, oEditor, nMode ) METHOD destroy() - METHOD execEvent( nMode, oEdit, p, p1 ) + METHOD execEvent( nMode, p, p1 ) METHOD execKeyEvent( nMode, nEvent, p, p1 ) - METHOD connectEditSignals( oEdit ) - METHOD disconnectEditSignals( oEdit ) + METHOD connectEditSignals() + METHOD disconnectEditSignals() METHOD reload() METHOD redo() @@ -305,7 +305,7 @@ METHOD IdeEdit:create( oIde, oEditor, nMode ) ::qEdit:hbBookMarks( nBlock ) NEXT - ::connectEditSignals( Self ) + ::connectEditSignals() ::qEdit:connect( QEvent_KeyPress , {|p| ::execKeyEvent( 101, QEvent_KeyPress, p ) } ) ::qEdit:connect( QEvent_Wheel , {|p| ::execKeyEvent( 102, QEvent_Wheel , p ) } ) @@ -318,51 +318,7 @@ METHOD IdeEdit:create( oIde, oEditor, nMode ) ::qTimer := QTimer() ::qTimer:setInterval( 2000 ) - ::qTimer:connect( "timeout()", {|| ::execEvent( timerTimeout, Self ) } ) - - RETURN Self - -/*----------------------------------------------------------------------*/ - -METHOD IdeEdit:zoom( nKey ) - - DEFAULT nKey TO 0 - - IF nKey == 1 - IF ::currentPointSize + 1 < 30 - ::currentPointSize++ - ENDIF - - ELSEIF nKey == -1 - IF ::currentPointSize - 1 > 3 - ::currentPointSize-- - ENDIF - - ELSEIF nKey == 0 - ::currentPointSize := ::pointSize - - ELSEIF nKey >= 3 .AND. nKey <= 30 - ::currentPointSize := nKey - - ELSE - RETURN Self - - ENDIF - - ::setFont() - - RETURN Self - -/*----------------------------------------------------------------------*/ - -METHOD IdeEdit:setFont() - - ::qFont := QFont() - ::qFont:setFamily( ::fontFamily ) - ::qFont:setFixedPitch( .t. ) - ::qFont:setPointSize( ::currentPointSize ) - - ::qEdit:setFont( ::qFont ) + ::qTimer:connect( "timeout()", {|| ::execEvent( timerTimeout ) } ) RETURN Self @@ -374,6 +330,8 @@ METHOD IdeEdit:destroy() ::oSourceThumbnailDock:oWidget:hide() ENDIF + ::oEditor := NIL + ::qTimer:disconnect( "timeout()" ) IF ::qTimer:isActive() ::qTimer:stop() @@ -387,99 +345,94 @@ METHOD IdeEdit:destroy() ::qEdit:disconnect( QEvent_Resize ) ::qEdit:disconnect( QEvent_MouseButtonDblClick ) - ::disconnectEditSignals( Self ) + ::disconnectEditSignals() ::qEdit := NIL ::qFont := NIL - RETURN Self + RETURN NIL /*----------------------------------------------------------------------*/ -METHOD IdeEdit:disconnectEditSignals( oEdit ) - HB_SYMBOL_UNUSED( oEdit ) +METHOD IdeEdit:disconnectEditSignals() - oEdit:qEdit:disConnect( "customContextMenuRequested(QPoint)" ) - oEdit:qEdit:disConnect( "textChanged()" ) - oEdit:qEdit:disConnect( "selectionChanged()" ) - oEdit:qEdit:disConnect( "cursorPositionChanged()" ) - oEdit:qEdit:disConnect( "copyAvailable(bool)" ) + ::qEdit:disConnect( "customContextMenuRequested(QPoint)" ) + ::qEdit:disConnect( "textChanged()" ) + ::qEdit:disConnect( "selectionChanged()" ) + ::qEdit:disConnect( "cursorPositionChanged()" ) + ::qEdit:disConnect( "copyAvailable(bool)" ) #if 0 - oEdit:qEdit:disConnect( "updateRequest(QRect,int)" ) - oEdit:qEdit:disConnect( "modificationChanged(bool)" ) - oEdit:qEdit:disConnect( "redoAvailable(bool)" ) - oEdit:qEdit:disConnect( "undoAvailable(bool)" ) + ::qEdit:disConnect( "updateRequest(QRect,int)" ) + ::qEdit:disConnect( "modificationChanged(bool)" ) + ::qEdit:disConnect( "redoAvailable(bool)" ) + ::qEdit:disConnect( "undoAvailable(bool)" ) #endif - RETURN Self + RETURN NIL /*----------------------------------------------------------------------*/ -METHOD IdeEdit:connectEditSignals( oEdit ) +METHOD IdeEdit:connectEditSignals() - HB_SYMBOL_UNUSED( oEdit ) - - oEdit:qEdit:connect( "customContextMenuRequested(QPoint)", {|p | ::execEvent( 1, oEdit, p ) } ) - oEdit:qEdit:connect( "textChanged()" , {| | ::execEvent( 2, oEdit, ) } ) - oEdit:qEdit:connect( "selectionChanged()" , {|p | ::execEvent( 6, oEdit, p ) } ) - oEdit:qEdit:connect( "cursorPositionChanged()" , {| | ::execEvent( 9, oEdit, ) } ) - oEdit:qEdit:connect( "copyAvailable(bool)" , {|p | ::execEvent( 3, oEdit, p ) } ) + ::qEdit:connect( "customContextMenuRequested(QPoint)", {|p | ::execEvent( 1, p ) } ) + ::qEdit:connect( "textChanged()" , {| | ::execEvent( 2, ) } ) + ::qEdit:connect( "selectionChanged()" , {|p | ::execEvent( 6, p ) } ) + ::qEdit:connect( "cursorPositionChanged()" , {| | ::execEvent( 9, ) } ) + ::qEdit:connect( "copyAvailable(bool)" , {|p | ::execEvent( 3, p ) } ) #if 0 - oEdit:qEdit:connect( "updateRequest(QRect,int)" , {|p,p1| ::execEvent( updateRequest, oEdit, p, p1 ) } ) - oEdit:qEdit:connect( "modificationChanged(bool)" , {|p | ::execEvent( 4, oEdit, p ) } ) - oEdit:qEdit:connect( "redoAvailable(bool)" , {|p | ::execEvent( 5, oEdit, p ) } ) - oEdit:qEdit:connect( "undoAvailable(bool)" , {|p | ::execEvent( 7, oEdit, p ) } ) + ::qEdit:connect( "updateRequest(QRect,int)" , {|p,p1| ::execEvent( updateRequest, p, p1 ) } ) + ::qEdit:connect( "modificationChanged(bool)" , {|p | ::execEvent( 4, p ) } ) + ::qEdit:connect( "redoAvailable(bool)" , {|p | ::execEvent( 5, p ) } ) + ::qEdit:connect( "undoAvailable(bool)" , {|p | ::execEvent( 7, p ) } ) #endif - - RETURN Self + + RETURN NIL /*----------------------------------------------------------------------*/ -METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) - LOCAL qAct, n, qEdit, oo, qCursor, cProto, nRows, nCols, cAct +METHOD IdeEdit:execEvent( nMode, p, p1 ) + LOCAL qAct, n, qCursor, cProto, nRows, nCols, cAct HB_SYMBOL_UNUSED( p1 ) IF ::lQuitting - RETURN Self + RETURN NIL ENDIF - qEdit := oEdit:qEdit - qCursor := qEdit:textCursor() - oEdit:nCurLineNo := qCursor:blockNumber() + qCursor := ::qEdit:textCursor() + ::nCurLineNo := qCursor:blockNumber() SWITCH nMode CASE customContextMenuRequested ::oEM:aActions[ 17, 2 ]:setEnabled( !empty( qCursor:selectedText() ) ) - n := ascan( ::oEditor:aEdits, {|o| o == oEdit } ) + n := ascan( ::oEditor:aEdits, {|o| o == Self } ) ::oEM:aActions[ 18, 2 ]:setEnabled( len( ::oEditor:aEdits ) == 0 .OR. ::oEditor:nSplOrient == -1 .OR. ::oEditor:nSplOrient == 1 ) ::oEM:aActions[ 19, 2 ]:setEnabled( len( ::oEditor:aEdits ) == 0 .OR. ::oEditor:nSplOrient == -1 .OR. ::oEditor:nSplOrient == 2 ) ::oEM:aActions[ 21, 2 ]:setEnabled( n > 0 ) - IF ! ( qAct := ::oEM:qContextMenu:exec( qEdit:mapToGlobal( p ) ) ):hasValidPointer() + IF ! ( qAct := ::oEM:qContextMenu:exec( ::qEdit:mapToGlobal( p ) ) ):hasValidPointer() RETURN Self ENDIF cAct := strtran( qAct:text(), "&", "" ) SWITCH cAct CASE "Split Horizontally" - ::oEditor:split( 1, oEdit ) + ::oEditor:split( 1, Self ) EXIT CASE "Split Vertically" - ::oEditor:split( 2, oEdit ) + ::oEditor:split( 2, Self ) EXIT CASE "Close Split Window" IF n > 0 /* 1 == Main Edit */ - oo := ::oEditor:aEdits[ n ] hb_adel( ::oEditor:aEdits, n, .t. ) - oo:destroy( .f. ) ::oEditor:qCqEdit := ::oEditor:qEdit ::oEditor:qCoEdit := ::oEditor:oEdit + ::destroy() ::oIde:manageFocusInEditor() ENDIF EXIT @@ -525,17 +478,16 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) ENDSWITCH EXIT - CASE textChanged //HB_TRACE( HB_TR_DEBUG, "textChanged()" ) - ::oEditor:setTabImage( qEdit ) + ::oEditor:setTabImage( ::qEdit ) EXIT CASE selectionChanged //HB_TRACE( HB_TR_DEBUG, "selectionChanged()" ) - ::oEditor:qCqEdit := qEdit - ::oEditor:qCoEdit := oEdit + ::oEditor:qCqEdit := ::qEdit + ::oEditor:qCoEdit := Self /* Book Marks reach-out buttons */ ::relayMarkButtons() @@ -556,16 +508,16 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) ::unHighlight() IF hb_isObject( ::oEditor:qHiliter ) - ::oEditor:qHiliter:hbSetEditor( qEdit ) - qEdit:hbSetHighlighter( ::oEditor:qHiliter ) - qEdit:hbHighlightPage() + ::oEditor:qHiliter:hbSetEditor( ::qEdit ) + ::qEdit:hbSetHighlighter( ::oEditor:qHiliter ) + ::qEdit:hbHighlightPage() ENDIF EXIT CASE cursorPositionChanged //HB_TRACE( HB_TR_DEBUG, "cursorPositionChanged()", ::nProtoLine, ::nProtoCol, ::isSuspended, ::getLineNo(), ::getColumnNo(), ::cProto ) - ::oEditor:dispEditInfo( qEdit ) + ::oEditor:dispEditInfo( ::qEdit ) ::handlePreviousWord( ::lUpdatePrevWord ) ::handleCurrentIndent() @@ -613,7 +565,7 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) #endif ENDSWITCH - RETURN Nil + RETURN NIL /*----------------------------------------------------------------------*/ @@ -761,6 +713,50 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) /*----------------------------------------------------------------------*/ +METHOD IdeEdit:zoom( nKey ) + + DEFAULT nKey TO 0 + + IF nKey == 1 + IF ::currentPointSize + 1 < 30 + ::currentPointSize++ + ENDIF + + ELSEIF nKey == -1 + IF ::currentPointSize - 1 > 3 + ::currentPointSize-- + ENDIF + + ELSEIF nKey == 0 + ::currentPointSize := ::pointSize + + ELSEIF nKey >= 3 .AND. nKey <= 30 + ::currentPointSize := nKey + + ELSE + RETURN Self + + ENDIF + + ::setFont() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:setFont() + + ::qFont := QFont() + ::qFont:setFamily( ::fontFamily ) + ::qFont:setFixedPitch( .t. ) + ::qFont:setPointSize( ::currentPointSize ) + + ::qEdit:setFont( ::qFont ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:highlightPage() IF hb_isObject( ::oEditor:qHiliter ) diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index 2bf3f26dbe..615b4e60cc 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -126,17 +126,17 @@ FUNCTION hbide_setProjectTitle( cTitle ) /*----------------------------------------------------------------------*/ FUNCTION hbide_execPopup( aPops, aqPos, qParent ) - LOCAL i, qPop, qPoint, qAct, cAct, xRet, a_, qSub, b_, qSub_:={} + LOCAL i, qPop, qPoint, qAct, cAct, xRet, a_, qSub, b_, qSub_:={}, qAct_:={} qPop := QMenu( iif( hb_isObject( qParent ), qParent, NIL ) ) qPop:setStyleSheet( GetStyleSheet( "QMenuPop", hbide_setIde():nAnimantionMode ) ) FOR i := 1 TO len( aPops ) IF empty( aPops[ i,1 ] ) - qPop:addSeparator() + aadd( qAct_, qPop:addSeparator() ) ELSE IF hb_isObject( aPops[ i, 1 ] ) - qPop:addAction( aPops[ i, 1 ] ) + aadd( qAct_, qPop:addAction( aPops[ i, 1 ] ) ) ELSEIF hb_isArray( aPops[ i, 1 ] ) /* Sub-menu */ qSub := QMenu( qPop ) qSub:setStyleSheet( GetStyleSheet( "QMenuPop", hbide_setIde():nAnimantionMode ) ) @@ -144,10 +144,10 @@ FUNCTION hbide_execPopup( aPops, aqPos, qParent ) qSub:addAction( a_[ 1 ] ) NEXT qSub:setTitle( aPops[ i,2 ] ) - qPop:addMenu( qSub ) + aadd( qAct_, qPop:addMenu( qSub ) ) aadd( qSub_, qSub ) ELSE - qPop:addAction( aPops[ i, 1 ] ) + aadd( qAct_, qPop:addAction( aPops[ i, 1 ] ) ) ENDIF ENDIF NEXT diff --git a/harbour/contrib/hbxbp/xbptoolbar.prg b/harbour/contrib/hbxbp/xbptoolbar.prg index 8e1c6d41e5..3b5467791c 100644 --- a/harbour/contrib/hbxbp/xbptoolbar.prg +++ b/harbour/contrib/hbxbp/xbptoolbar.prg @@ -246,7 +246,7 @@ METHOD XbpToolbar:addItem( cCaption, xImage, xDisabledImage, xHotImage, cDLL, nS oBtn:command := 100 + oBtn:index IF nStyle == XBPTOOLBAR_BUTTON_SEPARATOR - ::oWidget:addSeparator() + oBtn:oAction := ::oWidget:addSeparator() ELSE IF isAction