From f6aacb1393891d04897e65b07dee8a657ea4c317 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 28 Sep 2010 23:59:32 +0000 Subject: [PATCH] 2010-09-28 16:58 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpbrowse.prg * contrib/hbxbp/xbptreeview.prg ! Code normalized. --- harbour/ChangeLog | 5 ++ harbour/contrib/hbxbp/xbpbrowse.prg | 102 +++++++++++++++++++------- harbour/contrib/hbxbp/xbptreeview.prg | 52 ++++++++++--- 3 files changed, 119 insertions(+), 40 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 773546a9b1..f9f3666ac8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,11 @@ The license applies to all entries newer than 2009-04-28. */ +2010-09-28 16:58 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbxbp/xbpbrowse.prg + * contrib/hbxbp/xbptreeview.prg + ! Code normalized. + 2010-09-28 19:26 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/qtcore/hbqt_base.cpp * contrib/hbqt/qtgui/THbQtUI.prg diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index df2557beab..6fcd73d823 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -449,6 +449,8 @@ EXPORTED: METHOD getCurrentIndex() INLINE ::oDbfModel:index( ::rowPos - 1, ::colPos - 1 ) ACCESS getDbfModel() INLINE ::oDbfModel METHOD openPersistentEditor() + METHOD connect() + METHOD disconnect() METHOD setFocus() INLINE ::oTableView:setFocus() @@ -529,6 +531,76 @@ METHOD XbpBrowse:destroy() /*----------------------------------------------------------------------*/ +METHOD XbpBrowse:connect() + + ::oLeftView : connect( "mousePressEvent()" , {|p| ::execSlot( __ev_mousepress_on_frozen__, p ) } ) + ::oLeftHeaderView : connect( "sectionPressed(int)" , {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) + ::oLeftFooterView : connect( "sectionPressed(int)" , {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) + + ::oRightView : connect( "mousePressEvent()" , {|p| ::execSlot( __ev_mousepress_on_frozen__, p ) } ) + ::oRightHeaderView : connect( "sectionPressed(int)" , {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) + ::oRightFooterView : connect( "sectionPressed(int)" , {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) + + ::oTableView : connect( "keyPressEvent()" , {|p | ::execSlot( __ev_keypress__ , p ) } ) + ::oTableView : connect( "mousePressEvent()" , {|p | ::execSlot( __ev_mousepress__ , p ) } ) + ::oTableView : connect( "mouseDoubleClickEvent()" , {|p | ::execSlot( __ev_xbpBrw_itemSelected__ , p ) } ) + ::oTableView : connect( "wheelEvent()" , {|p | ::execSlot( __ev_wheel__ , p ) } ) + ::oTableView : connect( "scrollContentsBy(int,int)" , {|p,p1| ::execSlot( __ev_horzscroll_via_qt__ , p, p1 ) } ) + ::oTableView : connect( "customContextMenuRequested(QPoint)", {|p | ::execSlot( __ev_contextMenuRequested__, p ) } ) + + ::oHScrollBar : connect( "actionTriggered(int)" , {|i| ::execSlot( __ev_horzscroll_slidermoved__ , i ) } ) + ::oHScrollBar : connect( "sliderReleased()" , {|i| ::execSlot( __ev_horzscroll_sliderreleased__, i ) } ) + + ::oVScrollBar : connect( "actionTriggered(int)" , {|i| ::execSlot( __ev_vertscroll_via_user__ , i ) } ) + ::oVScrollBar : connect( "sliderReleased()" , {|i| ::execSlot( __ev_vertscroll_sliderreleased__, i ) } ) + + ::oHeaderView : connect( "sectionPressed(int)" , {|i | ::execSlot( __ev_columnheader_pressed__, i ) } ) + ::oHeaderView : connect( "sectionResized(int,int,int)" , {|i,i1,i2| ::execSlot( __ev_headersec_resized__ , i, i1, i2 ) } ) + + ::oWidget : connect( QEvent_Resize , {|| ::execSlot( __ev_frame_resized__ ) } ) + + ::qDelegate : connect( "closeEditor(QWidget,int)" , {|p,p1| ::execSlot( __editor_closeEditor__, p, p1 ) } ) + ::qDelegate : connect( "commitData(QWidget)" , {|p | ::execSlot( __editor_commitData__ , p ) } ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpBrowse:disconnect() + + ::oLeftView : disconnect( "mousePressEvent()" ) + ::oLeftHeaderView : disconnect( "sectionPressed(int)" ) + ::oLeftFooterView : disconnect( "sectionPressed(int)" ) + + ::oRightView : disconnect( "mousePressEvent()" ) + ::oRightHeaderView : disconnect( "sectionPressed(int)" ) + ::oRightFooterView : disconnect( "sectionPressed(int)" ) + + ::oTableView : disconnect( "keyPressEvent()" ) + ::oTableView : disconnect( "mousePressEvent()" ) + ::oTableView : disconnect( "mouseDoubleClickEvent()" ) + ::oTableView : disconnect( "wheelEvent()" ) + ::oTableView : disconnect( "scrollContentsBy(int,int)" ) + ::oTableView : disconnect( "customContextMenuRequested(QPoint)" ) + + ::oHScrollBar : disconnect( "actionTriggered(int)" ) + ::oHScrollBar : disconnect( "sliderReleased()" ) + + ::oVScrollBar : disconnect( "actionTriggered(int)" ) + ::oVScrollBar : disconnect( "sliderReleased()" ) + + ::oHeaderView : disconnect( "sectionPressed(int)" ) + ::oHeaderView : disconnect( "sectionResized(int,int,int)" ) + + ::oWidget : disconnect( QEvent_Resize ) + + ::qDelegate : disconnect( "closeEditor(QWidget,int)" ) + ::qDelegate : disconnect( "commitData(QWidget)" ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + /* Just to retain TBrowse functionality: in the future */ METHOD new( nTop, nLeft, nBottom, nRight ) CLASS XbpBrowse @@ -599,10 +671,6 @@ METHOD XbpBrowse:buildLeftFreeze() // //::oLeftFooterView:hide() - ::oLeftView :connect( "mousePressEvent()" , {|p| ::execSlot( __ev_mousepress_on_frozen__, p ) } ) - ::oLeftHeaderView:connect( "sectionPressed(int)", {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) - ::oLeftFooterView:connect( "sectionPressed(int)", {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) - RETURN Self /*----------------------------------------------------------------------*/ @@ -645,10 +713,6 @@ METHOD XbpBrowse:buildRightFreeze() ::oRightFooterView:setModel( ::oRightFooterModel ) - ::oRightView :connect( "mousePressEvent()" , {|p| ::execSlot( __ev_mousepress_on_frozen__, p ) } ) - ::oRightHeaderView:connect( "sectionPressed(int)", {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) - ::oRightFooterView:connect( "sectionPressed(int)", {|i| ::execSlot( __ev_mousepress_on_frozen__, i ) } ) - RETURN Self /*----------------------------------------------------------------------*/ @@ -676,29 +740,17 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oTableView:setAlternatingRowColors( .t. ) ::oTableView:setContextMenuPolicy( Qt_CustomContextMenu ) - /* Connect Keyboard Events */ - ::oTableView:connect( "keyPressEvent()" , {|p | ::execSlot( __ev_keypress__ , p ) } ) - ::oTableView:connect( "mousePressEvent()" , {|p | ::execSlot( __ev_mousepress__ , p ) } ) - ::oTableView:connect( "mouseDoubleClickEvent()" , {|p | ::execSlot( __ev_xbpBrw_itemSelected__ , p ) } ) - ::oTableView:connect( "wheelEvent()" , {|p | ::execSlot( __ev_wheel__ , p ) } ) - ::oTableView:connect( "scrollContentsBy(int,int)" , {|p,p1| ::execSlot( __ev_horzscroll_via_qt__ , p, p1 ) } ) - ::oTableView:connect( "customContextMenuRequested(QPoint)", {|p | ::execSlot( __ev_contextMenuRequested__, p ) } ) - /* Finetune Horizontal Scrollbar */ ::oTableView:setHorizontalScrollBarPolicy( Qt_ScrollBarAlwaysOff ) // ::oHScrollBar := QScrollBar() ::oHScrollBar:setOrientation( Qt_Horizontal ) - ::oHScrollBar:connect( "actionTriggered(int)" , {|i| ::execSlot( __ev_horzscroll_slidermoved__ , i ) } ) - ::oHScrollBar:connect( "sliderReleased()" , {|i| ::execSlot( __ev_horzscroll_sliderreleased__, i ) } ) /* Replace Vertical Scrollbar with our own */ ::oTableView:setVerticalScrollBarPolicy( Qt_ScrollBarAlwaysOff ) // ::oVScrollBar := QScrollBar() ::oVScrollBar:setOrientation( Qt_Vertical ) - ::oVScrollBar:connect( "actionTriggered(int)" , {|i| ::execSlot( __ev_vertscroll_via_user__ , i ) } ) - ::oVScrollBar:connect( "sliderReleased()" , {|i| ::execSlot( __ev_vertscroll_sliderreleased__, i ) } ) /* Veritical Header because of Performance boost */ ::oVHeaderView := ::oTableView:verticalHeader() @@ -707,9 +759,6 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /* Horizontal Header Fine Tuning */ ::oHeaderView := ::oTableView:horizontalHeader() ::oHeaderView:setHighlightSections( .F. ) - // - ::oHeaderView:connect( "sectionPressed(int)" , {|i | ::execSlot( __ev_columnheader_pressed__, i ) } ) - ::oHeaderView:connect( "sectionResized(int,int,int)" , {|i,i1,i2| ::execSlot( __ev_headersec_resized__ , i, i1, i2 ) } ) /* .DBF Manipulation Model */ ::oDbfModel := HBQAbstractItemModel( {|t,role,x,y| ::supplyInfo( 141, t, role, x, y ) } ) @@ -766,8 +815,6 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /* Viewport */ ::oViewport := ::oTableView:viewport() - ::oWidget:connect( QEvent_Resize, {|| ::execSlot( __ev_frame_resized__ ) } ) - qRect := ::oWidget:geometry() ::oWidget:setGeometry( qRect ) @@ -775,14 +822,13 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::qDelegate := QItemDelegate() ::oTableView:setItemDelegate( ::qDelegate ) - ::qDelegate:connect( "closeEditor(QWidget,int)", {|p,p1| ::execSlot( __editor_closeEditor__, p, p1 ) } ) - ::qDelegate:connect( "commitData(QWidget)" , {|p | ::execSlot( __editor_commitData__ , p ) } ) - //::oTableView:setEditTriggers( QAbstractItemView_AllEditTriggers ) //::oTableView:setEditTriggers( QAbstractItemView_DoubleClicked ) //::oTableView:setEditTriggers( QAbstractItemView_SelectedClicked ) ::oTableView:setEditTriggers( QAbstractItemView_AnyKeyPressed ) + ::connect() + ::postCreate() RETURN Self diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg index 4ee7fb86e5..715eb842e7 100644 --- a/harbour/contrib/hbxbp/xbptreeview.prg +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -93,6 +93,8 @@ CLASS XbpTreeView INHERIT XbpWindow, XbpDataRef METHOD setStyle() METHOD itemFromPos( aPos ) + METHOD connect() + METHOD disconnect() DATA sl_itemCollapsed DATA sl_itemExpanded @@ -158,17 +160,7 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oRootItem:oWidget := ::oWidget:invisibleRootItem() -* ::oWidget:connect( "currentItemChanged(QTWItem)" , {|p1| ::execSlot( "currentItemChanged(QTWItem)", p1 ) } ) -* ::oWidget:connect( "itemActivated(QTWItem)" , {|p1| ::execSlot( "itemActivated(QTWItem)" , p1 ) } ) -* ::oWidget:connect( "itemChanged(QTWItem)" , {|p1| ::execSlot( "itemChanged(QTWItem)" , p1 ) } ) - ::oWidget:connect( "itemClicked(QTWItem)" , {|p1| ::execSlot( "itemClicked(QTWItem)" , p1 ) } ) - ::oWidget:connect( "itemCollapsed(QTWItem)" , {|p1| ::execSlot( "itemCollapsed(QTWItem)" , p1 ) } ) - ::oWidget:connect( "itemDoubleClicked(QTWItem)" , {|p1| ::execSlot( "itemDoubleClicked(QTWItem)" , p1 ) } ) - ::oWidget:connect( "itemEntered(QTWItem)" , {|p1| ::execSlot( "itemEntered(QTWItem)" , p1 ) } ) - ::oWidget:connect( "itemExpanded(QTWItem)" , {|p1| ::execSlot( "itemExpanded(QTWItem)" , p1 ) } ) -* ::oWidget:connect( "itemPressed(QTWItem)" , {|p1| ::execSlot( "itemPressed(QTWItem)" , p1 ) } ) -* ::oWidget:connect( "itemSelectionChanged()" , {|p1| ::execSlot( "itemSelectionChanged()" , p1 ) } ) - ::oWidget:connect( "customContextMenuRequested(QPoint)", {|p1| ::execSlot( "customContextMenuRequested(QPoint)", p1 ) } ) + ::connect() ::setPosAndSize() IF ::visible @@ -196,7 +188,7 @@ METHOD XbpTreeView:execSlot( cSlot, p ) LOCAL n, qPt, qItem, oItem, qPos IF hb_isPointer( p ) - IF ( n := ascan( ::aItems, {|o| hbqt_IsEqualGcQtPointer( o:oWidget:pPtr, p ) } ) ) > 0 + IF ( n := ascan( ::aItems, {|o| iif( empty( o ), .f., hbqt_IsEqualGcQtPointer( o:oWidget:pPtr, p ) ) } ) ) > 0 oItem := ::aItems[ n ] ENDIF ENDIF @@ -269,6 +261,42 @@ METHOD XbpTreeView:destroy() /*----------------------------------------------------------------------*/ +METHOD XbpTreeView:connect() + +* ::oWidget:connect( "currentItemChanged(QTWItem)" , {|p1| ::execSlot( "currentItemChanged(QTWItem)", p1 ) } ) +* ::oWidget:connect( "itemActivated(QTWItem)" , {|p1| ::execSlot( "itemActivated(QTWItem)" , p1 ) } ) +* ::oWidget:connect( "itemChanged(QTWItem)" , {|p1| ::execSlot( "itemChanged(QTWItem)" , p1 ) } ) + ::oWidget:connect( "itemClicked(QTWItem)" , {|p1| ::execSlot( "itemClicked(QTWItem)" , p1 ) } ) + ::oWidget:connect( "itemCollapsed(QTWItem)" , {|p1| ::execSlot( "itemCollapsed(QTWItem)" , p1 ) } ) + ::oWidget:connect( "itemDoubleClicked(QTWItem)" , {|p1| ::execSlot( "itemDoubleClicked(QTWItem)" , p1 ) } ) + ::oWidget:connect( "itemEntered(QTWItem)" , {|p1| ::execSlot( "itemEntered(QTWItem)" , p1 ) } ) + ::oWidget:connect( "itemExpanded(QTWItem)" , {|p1| ::execSlot( "itemExpanded(QTWItem)" , p1 ) } ) +* ::oWidget:connect( "itemPressed(QTWItem)" , {|p1| ::execSlot( "itemPressed(QTWItem)" , p1 ) } ) +* ::oWidget:connect( "itemSelectionChanged()" , {|p1| ::execSlot( "itemSelectionChanged()" , p1 ) } ) + ::oWidget:connect( "customContextMenuRequested(QPoint)", {|p1| ::execSlot( "customContextMenuRequested(QPoint)", p1 ) } ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:disconnect() + +* ::oWidget:disconnect( "currentItemChanged(QTWItem)" ) +* ::oWidget:disconnect( "itemActivated(QTWItem)" ) +* ::oWidget:disconnect( "itemChanged(QTWItem)" ) + ::oWidget:disconnect( "itemClicked(QTWItem)" ) + ::oWidget:disconnect( "itemCollapsed(QTWItem)" ) + ::oWidget:disconnect( "itemDoubleClicked(QTWItem)" ) + ::oWidget:disconnect( "itemEntered(QTWItem)" ) + ::oWidget:disconnect( "itemExpanded(QTWItem)" ) +* ::oWidget:disconnect( "itemPressed(QTWItem)" ) +* ::oWidget:disconnect( "itemSelectionChanged()" ) + ::oWidget:disconnect( "customContextMenuRequested(QPoint)" ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD XbpTreeView:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible )