2009-11-23 17:21 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* contrib/hbide/hbide.hbp
  * contrib/hbide/hbide.prg
  + contrib/hbide/idemisc.prg
    ! Implemented to execute context sensitive popups.
      Right click on <Funtions List> right-hand area.

  * contrib/hbxbp/xbpdialog.prg
  * contrib/hbxbp/xbplistbox.prg
  * contrib/hbxbp/xbptreeview.prg
  * contrib/hbxbp/xbpwindow.prg
    + Neccessary constructs to honour context menu requests.
This commit is contained in:
Pritpal Bedi
2009-11-24 01:25:05 +00:00
parent 2053cdaf47
commit e59e5767ba
8 changed files with 195 additions and 34 deletions

View File

@@ -17,6 +17,19 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-11-23 17:21 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/hbide.hbp
* contrib/hbide/hbide.prg
+ contrib/hbide/idemisc.prg
! Implemented to execute context sensitive popups.
Right click on <Funtions List> right-hand area.
* contrib/hbxbp/xbpdialog.prg
* contrib/hbxbp/xbplistbox.prg
* contrib/hbxbp/xbptreeview.prg
* contrib/hbxbp/xbpwindow.prg
+ Neccessary constructs to honour context menu requests.
2009-11-23 22:49 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* utils/hbmk2/hbmk2.prg
! Fixed to use '-ofilename' to spec C compiler object

View File

@@ -13,6 +13,7 @@
hbide.prg
idestylesheets.prg
idetags.prg
idemisc.prg
freadlin.c
ideparseexpr.c

View File

@@ -99,16 +99,6 @@ PROCEDURE Main( cProjectOrSource )
/*----------------------------------------------------------------------*/
PROCEDURE AppSys()
RETURN
/*----------------------------------------------------------------------*/
PROCEDURE JustACall()
RETURN
/*----------------------------------------------------------------------*/
CLASS HbIde
DATA mp1, mp2, oXbp, nEvent
@@ -173,6 +163,7 @@ CLASS HbIde
METHOD buildTabPage()
METHOD buildProjectTree()
METHOD manageFuncContext()
METHOD buildFuncList()
METHOD buildBottomArea()
METHOD buildCompileResults()
@@ -776,7 +767,7 @@ METHOD HbIde:buildDialog()
::oDlg := XbpDialog():new( , , {10,10}, {1100,700}, , .f. )
::oDlg:icon := s_resPath + "vr.png" //"hbide.ico"
::oDlg:icon := s_resPath + "vr.png" // "hbide.png"
::oDlg:title := "Harbour-Qt IDE"
::oDlg:create()
@@ -794,7 +785,7 @@ METHOD HbIde:gotoFunction( mp1, mp2, oListBox )
mp1 := oListBox:getData()
mp2 := oListBox:getItem( mp1 )
//IF ( n := ascan( ::aTags, {|e| mp2 == e[ 2 ] + " " + e[ 5 ] } ) ) > 0
IF ( n := ascan( ::aTags, {|e_| mp2 == e_[ 7 ] } ) ) > 0
cAnchor := trim( ::aText[ ::aTags[ n,3 ] ] )
IF !( ::aTabs[ ::nCurTab, 2 ]:find( cAnchor, QTextDocument_FindCaseSensitively ) )
@@ -805,6 +796,21 @@ METHOD HbIde:gotoFunction( mp1, mp2, oListBox )
/*----------------------------------------------------------------------*/
METHOD HbIde:manageFuncContext( mp1 )
LOCAL aPops := {}
aadd( aPops, { 'Comment out' , {|| NIL } } )
aadd( aPops, { 'Reformat' , {|| NIL } } )
aadd( aPops, { 'Print' , {|| NIL } } )
aadd( aPops, { 'Delete' , {|| NIL } } )
aadd( aPops, { 'Move to another source', {|| NIL } } )
ExecPopup( aPops, mp1 )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD HbIde:buildFuncList()
::oDockR := XbpWindow():new( ::oDa )
@@ -815,11 +821,16 @@ METHOD HbIde:buildFuncList()
::oDockR:oWidget:setWindowTitle( "Module Function List" )
::oDockR:oWidget:setMinimumWidth( 100 )
::oDockR:oWidget:setMaximumWidth( 150 )
::oDockR:oWidget:setFocusPolicy( Qt_NoFocus )
::oFuncList := XbpListBox():new( ::oDockR ):create( , , { 0,0 }, { 100,400 }, , .t. )
::oFuncList:setStyleSheet( GetStyleSheet( "QListView" ) )
::oFuncList:setColorBG( GraMakeRGBColor( { 210,120,220 } ) )
::oFuncList:ItemMarked := {|mp1, mp2, oXbp| ::gotoFunction( mp1, mp2, oXbp ) }
//::oFuncList:ItemMarked := {|mp1, mp2, oXbp| ::gotoFunction( mp1, mp2, oXbp ) }
::oFuncList:ItemSelected := {|mp1, mp2, oXbp| ::gotoFunction( mp1, mp2, oXbp ) }
/* Harbour Extension : prefixed with "hb" */
::oFuncList:hbContextMenu := {|mp1, mp2, oXbp| ::manageFuncContext( mp1, mp2, oXbp ) }
::oFuncList:oWidget:setEditTriggers( QAbstractItemView_NoEditTriggers )
::oDockR:oWidget:setWidget( QT_PTROFXBP( ::oFuncList ) )
@@ -854,6 +865,7 @@ METHOD HbIde:buildCompileResults()
::oDockB:oWidget:setWindowTitle( "Compile Results" )
::oDockB:oWidget:setMinimumHeight( 75 )
::oDockB:oWidget:setMaximumHeight( 100 )
::oDockB:oWidget:setFocusPolicy( Qt_NoFocus )
::oCompileResult := XbpMLE():new( ::oDockB ):create( , , { 0,0 }, { 100,400 }, , .t. )
::oDockB:oWidget:setWidget( QT_PTROFXBP( ::oCompileResult ) )
@@ -875,6 +887,7 @@ METHOD HbIde:buildLinkResults()
::oDockB1:oWidget:setWindowTitle( "Link Results" )
::oDockB1:oWidget:setMinimumHeight( 75 )
::oDockB1:oWidget:setMaximumHeight( 100 )
::oDockB1:oWidget:setFocusPolicy( Qt_NoFocus )
::oLinkResult := XbpMLE():new( ::oDockB1 ):create( , , { 0,0 }, { 100, 400 }, , .t. )
::oDockB1:oWidget:setWidget( QT_PTROFXBP( ::oLinkResult ) )
@@ -896,6 +909,7 @@ METHOD HbIde:buildOutputResults()
::oDockB2:oWidget:setWindowTitle( "Output Console" )
::oDockB2:oWidget:setMinimumHeight( 75 )
::oDockB2:oWidget:setMaximumHeight( 100 )
::oDockB2:oWidget:setFocusPolicy( Qt_NoFocus )
::oOutputResult := XbpMLE():new( ::oDockB2 ):create( , , { 0,0 }, { 100, 400 }, , .t. )
::oDockB2:oWidget:setWidget( QT_PTROFXBP( ::oOutputResult ) )
@@ -907,14 +921,6 @@ METHOD HbIde:buildOutputResults()
/*----------------------------------------------------------------------*/
STATIC FUNCTION MenuAddSep( oMenu )
oMenu:addItem( { NIL, NIL, XBPMENUBAR_MIS_SEPARATOR, NIL } )
RETURN nil
/*----------------------------------------------------------------------*/
METHOD HbIde:CreateTags()
LOCAL aSumData := ""
LOCAL cComments, aSummary, i, cPath, cSource, cExt

View File

@@ -0,0 +1,112 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* 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.
*
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*
* EkOnkar
* ( The LORD is ONE )
*
* Harbour-Qt IDE
*
* Pritpal Bedi <pritpal@vouchcac.com>
* 23Nov2009
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#include "common.ch"
#include "xbp.ch"
/*----------------------------------------------------------------------*/
PROCEDURE AppSys()
RETURN
/*----------------------------------------------------------------------*/
PROCEDURE JustACall()
RETURN
/*----------------------------------------------------------------------*/
FUNCTION ExecPopup( aPops, aPos )
LOCAL i, qPop, qPoint, qAct, nAct, cAct, xRet
qPop := QMenu():new()
FOR i := 1 TO len( aPops )
qPop:addAction( aPops[ i, 1 ] )
NEXT
qPoint := QPoint():new( aPos[ 1 ], aPos[ 2 ] )
qAct := QAction():configure( qPop:exec_1( QT_PTROF( qPoint ) ) )
IF !empty( cAct := qAct:text() )
IF ( nAct := ascan( aPops, {|e_| e_[ 1 ] == cAct } ) ) > 0
xRet := eval( aPops[ nAct,2 ] )
ENDIF
ENDIF
RETURN xRet
/*----------------------------------------------------------------------*/
FUNCTION MenuAddSep( oMenu )
oMenu:addItem( { NIL, NIL, XBPMENUBAR_MIS_SEPARATOR, NIL } )
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -294,7 +294,7 @@ METHOD XbpDrawingArea:create( oParent, oOwner, aPos, aSize, aPresParams, lVisibl
::oWidget := QWidget():new()
::oWidget:setMouseTracking( .T. )
::oWidget:setFocusPolicy( 2 )
::oWidget:setFocusPolicy( Qt_StrongFocus )
::setQtProperty() /* Using it for one-to-one style sheet management */

View File

@@ -146,6 +146,7 @@ CLASS XbpListBox INHERIT XbpWindow, XbpDataRef
METHOD getCurItem() INLINE ::getItem( ::nCurSelected )
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpListBox:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
@@ -175,6 +176,11 @@ METHOD XbpListBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::oWidget := QListView():New( ::pParent )
/* Window Events */
::oWidget:installEventFilter( SetEventFilter() )
Qt_Connect_Event( ::pWidget, QEvent_ContextMenu, {|o,e| ::exeBlock( 4, e, o ) } )
/* Signal-slots */
::Connect( ::pWidget, "clicked(QModelIndex)" , {|o,i| ::exeBlock( 1,i,o ) } )
::Connect( ::pWidget, "doubleClicked(QModelIndex)", {|o,i| ::exeBlock( 2,i,o ) } )
::Connect( ::pWidget, "entered(QModelIndex)" , {|o,i| ::exeBlock( 3,i,o ) } )
@@ -188,8 +194,6 @@ METHOD XbpListBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
IF ::visible
::show()
ENDIF
//::setStyle()
::oParent:AddChild( SELF )
RETURN Self
@@ -199,8 +203,7 @@ METHOD XbpListBox:exeBlock( nMode, pModel )
LOCAL oModel
IF hb_isPointer( pModel )
oModel := QModelIndex():new()
oModel:pPtr := pModel
oModel := QModelIndex():configure( pModel )
::nCurSelected := oModel:row()+1
::sl_editBuffer := oModel:row()+1
ENDIF
@@ -212,6 +215,11 @@ METHOD XbpListBox:exeBlock( nMode, pModel )
IF hb_isBlock( ::sl_itemSelected )
eval( ::sl_itemSelected, NIL, NIL, self )
ENDIF
ELSEIF nMode == 4 /* Context Menu */
IF hb_isBlock( ::hb_contextMenu )
oModel := QContextMenuEvent():configure( pModel )
eval( ::hb_contextMenu, { oModel:globalX(), oModel:globalY() }, NIL, Self )
ENDIF
ENDIF
RETURN nil

View File

@@ -167,6 +167,9 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
oW:pPtr := ::oWidget:invisibleRootItem()
::oRootItem:oWidget := oW
/* Window Events */
::oWidget:installEventFilter( SetEventFilter() )
Qt_Connect_Event( ::pWidget, QEvent_ContextMenu, {|o,e| ::exeBlock( 4, e, o ) } )
//::connect( ::pWidget, "currentItemChanged(QTWItem)" , {|o,p1,p2| ::exeBlock( 1, p1, p2, o ) } )
//::connect( ::pWidget, "itemActivated(QTWItem)" , {|o,p1,p2| ::exeBlock( 2, p1, p2, o ) } )
@@ -183,7 +186,6 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
IF ::visible
::show()
ENDIF
// ::setStyle()
::oParent:AddChild( SELF )
RETURN Self
@@ -196,8 +198,6 @@ METHOD XbpTreeView:ExeBlock( nMsg, p1, p2 )
HB_SYMBOL_UNUSED( p1 )
HB_SYMBOL_UNUSED( p2 )
//HBXBP_DEBUG( hb_ntos( nMsg ) )
IF hb_isPointer( p1 )
IF ( n := ascan( ::aItems, {|o| o:oWidget:pPtr == p1 } ) ) > 0
oItem := ::aItems[ n ]
@@ -250,12 +250,10 @@ METHOD XbpTreeView:destroy()
::disconnect()
FOR i := len( ::aItems ) TO 1 step -1
//HBXBP_DEBUG( i, __ObjGetClsName( ::aItems[ i ] ) )
aeval( ::aItems[ i ]:aChilds, {|e,j| e := e, ::aItems[ i ]:aChilds[ j ] := NIL } )
::aItems[ i ]:oWidget:pPtr := 0
NEXT
::aItems := NIL
//::oRootItem:oWidget:pPtr := 0 // No need as it is a pointer from Qt
::sl_itemCollapsed := NIL
::sl_itemExpanded := NIL

View File

@@ -137,6 +137,8 @@ CLASS XbpWindow INHERIT XbpPartHandler
DATA sl_setDisplayFocus
DATA sl_killDisplayFocus
DATA hb_contextMenu
EXPORTED:
/* LIFE CYCLE */
METHOD init()
@@ -277,6 +279,8 @@ EXPORTED:
METHOD clearSlots()
DATA aPP
METHOD hbContextMenu SETGET
ENDCLASS
/*----------------------------------------------------------------------*/
@@ -429,6 +433,8 @@ METHOD XbpWindow:connectWindowEvents()
::connectEvent( ::pWidget, QEvent_WhatsThis , {|o,e| ::grabEvent( QEvent_WhatsThis , e, o ) } )
::connectEvent( ::pWidget, QEvent_KeyPress , {|o,e| ::grabEvent( QEvent_KeyPress , e, o ) } )
::connectEvent( ::pWidget, QEvent_ContextMenu , {|o,e| ::grabEvent( QEvent_ContextMenu , e, o ) } )
RETURN Self
/*----------------------------------------------------------------------*/
@@ -483,6 +489,11 @@ METHOD XbpWindow:grabEvent( nEvent, pEvent, oXbp )
SetAppEvent( xbeM_RbDblClick, { oEvent:x(), oEvent:y() }, NIL, self )
ENDCASE
EXIT
CASE QEvent_ContextMenu //
oEvent := QContextMenuEvent():configure( pEvent )
//SetAppEvent( xbeM_Context, { oEvent:globalX(), oEvent:globalY() }, NIL, self )
::hbContextMenu( { oEvent:globalX(), oEvent:globalY() } )
EXIT
CASE QEvent_Enter // :enter()
IF ( ::lTrack )
oEvent := QMouseEvent():configure( pEvent )
@@ -727,10 +738,7 @@ HBXBP_DEBUG( ThreadID(),"Destroy: "+pad(__ObjGetClsName( self ),12)+ IF(empty(::
SetEventLoop( NIL )
::oEventLoop:exit( 0 )
::oEventLoop:pPtr := 0
//::oWidget:removeEventFilter( SetEventFilter() )
SetAppWindow( XbpObject():new() )
::oMenu := NIL
ENDIF
@@ -1802,6 +1810,21 @@ METHOD XbpWindow:dragDrop( xParam, xParam1 )
/*----------------------------------------------------------------------*/
METHOD XbpWindow:hbContextMenu( xParam )
if hb_isBlock( ::hb_contextMenu )
eval( ::hb_contextMenu, xParam, NIL, Self )
RETURN NIL
endif
if hb_isBlock( xParam )
::hb_contextMenu := xParam
endif
RETURN ::hb_contextMenu
/*----------------------------------------------------------------------*/
METHOD XbpWindow:Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
DEFAULT oParent TO ::oParent