2010-07-20 18:30 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)

* contrib/hbxbp/xbpbrowse.prg
    + Added: constructs to allow context menu.

  * contrib/hbide/idebrowse.prg
  * contrib/hbide/idemisc.prg
    + Implemented: context menu on a browser.
      Context menu has three options:
        1. Set to Natural Order.
        2. Set to Indexed Order -> presents further menu of index definitions.
        3. Scroll to Column -> presents menu to select a column.
      More actions are scheduled to go inside this menu.
This commit is contained in:
Pritpal Bedi
2010-07-21 01:34:36 +00:00
parent 68b37e192b
commit 5e34363254
4 changed files with 87 additions and 7 deletions

View File

@@ -16,6 +16,19 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-07-20 18:30 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com)
* contrib/hbxbp/xbpbrowse.prg
+ Added: constructs to allow context menu.
* contrib/hbide/idebrowse.prg
* contrib/hbide/idemisc.prg
+ Implemented: context menu on a browser.
Context menu has three options:
1. Set to Natural Order.
2. Set to Indexed Order -> presents further menu of index definitions.
3. Scroll to Column -> presents menu to select a column.
More actions are scheduled to go inside this menu.
2010-07-20 17:53 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/make.hbs
* Internal renames, cleaned debug stuff, comments.

View File

@@ -1244,6 +1244,10 @@ CLASS IdeBrowse INHERIT IdeObject
DATA xSearch
DATA lInSearch INIT .f.
DATA aMenu INIT {}
DATA aIdx INIT {}
DATA aFlds INIT {}
METHOD new( oIde, oManager, oPanel, aInfo )
METHOD create( oIde, oManager, oPanel, aInfo )
METHOD configure()
@@ -1270,10 +1274,10 @@ CLASS IdeBrowse INHERIT IdeObject
METHOD ordName( nOrder )
METHOD IndexKey( nOrder )
METHOD IndexKeyValue( nOrder )
METHOD setOrder( nOrder )
METHOD refreshAll()
METHOD getIndexInfo()
METHOD setIndex( cIndex )
METHOD setOrder( nOrder )
ACCESS numIndexes() INLINE len( ::aIndex )
METHOD dispInfo()
@@ -1285,6 +1289,7 @@ CLASS IdeBrowse INHERIT IdeObject
METHOD populateForm()
METHOD fetchAlias( cTable )
METHOD saveField( nField, x )
METHOD toColumn( nIndex )
ENDCLASS
@@ -1490,6 +1495,8 @@ METHOD IdeBrowse:buildBrowser()
oXbpBrowse:goPosBlock := {|n| ::goto( n ) }
oXbpBrowse:phyPosBlock := {| | ::recNo() }
oXbpBrowse:hbContextMenu := {|mp1| ::execEvent( "browser_contextMenu", mp1 ) }
/* Form View */
::qForm := QWidget():new()
::qFLayout := QFormLayout():new()
@@ -1561,6 +1568,7 @@ METHOD IdeBrowse:buildMdiWindow()
/*------------------------------------------------------------------------*/
METHOD IdeBrowse:execEvent( cEvent, p, p1 )
LOCAL cIndex, a_, cPmt
HB_SYMBOL_UNUSED( p )
HB_SYMBOL_UNUSED( p1 )
@@ -1614,6 +1622,35 @@ METHOD IdeBrowse:execEvent( cEvent, p, p1 )
ENDIF
EXIT
CASE "browser_contextMenu"
IF empty( ::aMenu )
::getIndexInfo()
FOR EACH cIndex IN ::aIndex
aadd( ::aIdx, hbide_indexArray( Self, cIndex, cIndex:__enumIndex() ) )
NEXT
aadd( ::aMenu, { "Set to Natural Order", {|| ::setOrder( 0 ) } } )
aadd( ::aMenu, { "" } )
IF ! empty( ::aIdx )
aadd( ::aMenu, { ::aIdx, "Set to Indexed Order" } )
aadd( ::aMenu, { "" } )
ENDIF
FOR EACH a_ IN ::aStruct
cPmt := a_[ 1 ] + " " + a_[ 2 ] + " " + hb_ntos( a_[ 3 ] )
aadd( ::aFlds, hbide_fieldsArray( Self, cPmt, a_:__enumIndex() ) )
NEXT
aadd( ::aMenu, { ::aFlds, "Scroll to Column..." } )
ENDIF
hbide_execPopup( ::aMenu, p, ::qMdi )
EXIT
CASE "browser_ScrollToColumn"
EXIT
ENDSWITCH
#if 0
@@ -1628,6 +1665,16 @@ METHOD IdeBrowse:execEvent( cEvent, p, p1 )
/*----------------------------------------------------------------------*/
STATIC FUNCTION hbide_fieldsArray( obj, cPmt, nIndex )
RETURN { cPmt, {|| obj:toColumn( nIndex ) } }
/*----------------------------------------------------------------------*/
STATIC FUNCTION hbide_indexArray( obj, cIndex, nOrder )
RETURN { cIndex, {|| obj:setOrder( nOrder ) } }
/*----------------------------------------------------------------------*/
METHOD IdeBrowse:dispInfo()
IF !empty( ::qMdi )
@@ -1922,6 +1969,17 @@ METHOD IdeBrowse:refreshAll()
/*----------------------------------------------------------------------*/
METHOD IdeBrowse:toColumn( nIndex )
::oBrw:colPos := nIndex
::oBrw:refreshAll()
::oBrw:forceStable()
::oBrw:setCurrentIndex( .t. )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD IdeBrowse:goToAsk()
LOCAL nRec
@@ -1971,7 +2029,7 @@ METHOD IdeBrowse:setOrder( nOrder )
IF ::nType == BRW_TYPE_DBF
( ::cAlias )->( DbSetOrder( nOrder ) )
::dispInfo()
::refreshAll()
ENDIF
RETURN NIL

View File

@@ -111,6 +111,7 @@ FUNCTION hbide_setIde( oIde )
FUNCTION hbide_execPopup( aPops, aqPos, qParent )
LOCAL i, qPop, qPoint, qAct, cAct, xRet, pAct, a_, qSub, b_
LOCAL qSub_:={}
qPop := QMenu():new( iif( hb_isObject( qParent ), qParent, NIL ) )
qPop:setStyleSheet( GetStyleSheet( "QMenuPop", hbide_setIde():nAnimantionMode ) )
@@ -129,6 +130,7 @@ FUNCTION hbide_execPopup( aPops, aqPos, qParent )
NEXT
qSub:setTitle( aPops[ i,2 ] )
qPop:addMenu( qSub )
aadd( qSub_, qSub )
ELSE
qPop:addAction( aPops[ i, 1 ] )
ENDIF

View File

@@ -137,6 +137,7 @@
#define __ev_headersec_resized__ 121 /* Header Section Resized */
#define __ev_footersec_resized__ 122 /* Footer Section Resized */
#define __ev_frame_resized__ 2001
#define __ev_contextMenuRequested__ 2002
/*----------------------------------------------------------------------*/
@@ -675,13 +676,15 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible )
::oTableView:setSelectionMode( QAbstractItemView_SingleSelection )
::oTableView:setSelectionBehavior( iif( ::cursorMode == XBPBRW_CURSOR_ROW, QAbstractItemView_SelectRows, QAbstractItemView_SelectItems ) )
::oTableView:setAlternatingRowColors( .t. )
::oTableView:setContextMenuPolicy( Qt_CustomContextMenu )
/* Connect Keyboard Events */
::connect( ::oTableView, "keyPressEvent()" , {|p | ::execSlot( __ev_keypress__ , p ) } )
::connect( ::oTableView, "mousePressEvent()" , {|p | ::execSlot( __ev_mousepress__ , p ) } )
::connect( ::oTableView, "mouseDoubleClickEvent()" , {|p | ::execSlot( __ev_xbpBrw_itemSelected__, p ) } )
::connect( ::oTableView, "wheelEvent()" , {|p | ::execSlot( __ev_wheel__ , p ) } )
::connect( ::oTableView, "scrollContentsBy(int,int)" , {|p,p1| ::execSlot( __ev_horzscroll_via_qt__ , p, p1 ) } )
::connect( ::oTableView, "keyPressEvent()" , {|p | ::execSlot( __ev_keypress__ , p ) } )
::connect( ::oTableView, "mousePressEvent()" , {|p | ::execSlot( __ev_mousepress__ , p ) } )
::connect( ::oTableView, "mouseDoubleClickEvent()" , {|p | ::execSlot( __ev_xbpBrw_itemSelected__ , p ) } )
::connect( ::oTableView, "wheelEvent()" , {|p | ::execSlot( __ev_wheel__ , p ) } )
::connect( ::oTableView, "scrollContentsBy(int,int)" , {|p,p1| ::execSlot( __ev_horzscroll_via_qt__ , p, p1 ) } )
::connect( ::oTableView, "customContextMenuRequested(QPoint)", {|p | ::execSlot( __ev_contextMenuRequested__, p ) } )
/* Finetune Horizontal Scrollbar */
::oTableView:setHorizontalScrollBarPolicy( Qt_ScrollBarAlwaysOff )
@@ -796,6 +799,10 @@ METHOD XbpBrowse:execSlot( nEvent, p1, p2, p3 )
HB_SYMBOL_UNUSED( p2 )
DO CASE
CASE nEvent == __ev_contextMenuRequested__
oPoint := QPoint():from( ::oTableView:mapToGlobal( p1 ) )
::hbContextMenu( { oPoint:x(), oPoint:y() } )
CASE nEvent == 1401 // "editor_commitData"
qWidget := QLineEdit():from( p1 )
cTxt := qWidget:text()