From bf251d5bd706e7bb0cf95f2d718f64891f887644 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 29 Jun 2010 02:09:39 +0000 Subject: [PATCH] 2010-06-28 19:04 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpbrowse.prg % Rearrangement of code. Was calculating rows console based. * contrib/hbide/idedocks.prg % Minor. * contrib/hbide/idebrowse.prg + Implemented: browse and corresponding form view of a table, wrapped inside splitters. Multiple tables are presented in vertical splitters and form view is presented in horizontal splitter. ; NOTE: still work in progress. But proof of concept is already working. --- harbour/ChangeLog | 15 +++ harbour/contrib/hbide/idebrowse.prg | 58 +++++++++- harbour/contrib/hbide/idedocks.prg | 1 - harbour/contrib/hbxbp/xbpbrowse.prg | 169 +++++++++++++++------------- 4 files changed, 157 insertions(+), 86 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index df9dc01834..82b55560c8 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,21 @@ The license applies to all entries newer than 2009-04-28. */ +2010-06-28 19:04 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbxbp/xbpbrowse.prg + % Rearrangement of code. Was calculating rows console based. + + * contrib/hbide/idedocks.prg + % Minor. + + * contrib/hbide/idebrowse.prg + + Implemented: browse and corresponding form view of a table, + wrapped inside splitters. + Multiple tables are presented in vertical splitters + and form view is presented in horizontal splitter. + ; NOTE: still work in progress. But proof of concept is + already working. + 2010-06-28 21:37 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbformat/Makefile * utils/hbi18n/Makefile diff --git a/harbour/contrib/hbide/idebrowse.prg b/harbour/contrib/hbide/idebrowse.prg index f149694f25..5f9767e6ae 100644 --- a/harbour/contrib/hbide/idebrowse.prg +++ b/harbour/contrib/hbide/idebrowse.prg @@ -95,6 +95,7 @@ CLASS IdeBrowseManager INHERIT IdeObject DATA aItems INIT {} DATA oPanel DATA qLayout + DATA qVSplitter METHOD new( oIde ) METHOD create( oIde ) @@ -128,6 +129,10 @@ METHOD IdeBrowseManager:create( oIde ) ::qLayout:setContentsMargins( 0,0,0,0 ) ::qLayout:setSpacing( 2 ) + ::qVSplitter := QSplitter():new() + ::qVSplitter:setOrientation( Qt_Vertical ) + ::qLayout:addWidget( ::qVSplitter ) + RETURN Self /*----------------------------------------------------------------------*/ @@ -169,7 +174,7 @@ METHOD IdeBrowseManager:addTable( cFileDBF, cAlias, nRow, nCol ) oBrw:cAlias := cAlias oBrw:create() - ::qLayout:addWidget( oBrw:oWnd:oWidget ) + ::qVSplitter:addWidget( oBrw:oWnd:oWidget ) aadd( ::aItems, oBrw ) @@ -186,6 +191,10 @@ CLASS IdeBrowse INHERIT IdeObject DATA oWnd DATA oBrw DATA qLayout + DATA qForm + DATA qFLayout + DATA qSplitter + DATA aForm INIT {} DATA nType INIT BRW_TYPE_DBF DATA cAlias INIT "" @@ -217,6 +226,7 @@ CLASS IdeBrowse INHERIT IdeObject METHOD next() METHOD previous() METHOD activated() + METHOD buildForm() ENDCLASS @@ -287,6 +297,10 @@ METHOD IdeBrowse:create( oIde ) ::buildBrowser() ::buildColumns() + ::buildForm() + + ::oBrw:configure() + ::oBrw:forceStable() RETURN Self @@ -294,6 +308,7 @@ METHOD IdeBrowse:create( oIde ) METHOD IdeBrowse:activated() +HB_TRACE( HB_TR_ALWAYS, "ACTIVATED" ) ::oQScintillaDock:oWidget:setWindowTitle( ::cTable ) RETURN Self @@ -305,18 +320,24 @@ METHOD IdeBrowse:buildBrowser() oWnd := XbpWindow():new() oWnd:oWidget := QWidget():new() - //oWnd:oWidget:resize( 600,300 ) - //oWnd:oWidget:setWindowFlags( Qt_Sheet ) - qLayout := QVBoxLayout():new() + qLayout := QHBoxLayout():new() oWnd:oWidget:setLayout( qLayout ) qLayout:setContentsMargins( 0,0,0,0 ) qLayout:setSpacing( 2 ) + ::qSplitter := QSplitter():new() + ::qSplitter:setOrientation( Qt_Horizontal ) + + qLayout:addWidget( ::qSplitter ) + + /* Browse View */ oXbpBrowse := XbpBrowse():new():create( oWnd, , { 0,0 }, oWnd:currentSize() ) oXbpBrowse:setFontCompoundName( "10.Courier" ) - qLayout:addWidget( oXbpBrowse:oWidget ) + ::qSplitter:addWidget( oXbpBrowse:oWidget ) + + //qLayout:addWidget( oXbpBrowse:oWidget ) oXbpBrowse:cursorMode := ::nCursorType @@ -331,9 +352,15 @@ METHOD IdeBrowse:buildBrowser() oXbpBrowse:goPosBlock := {|n| ::goto( n ) } oXbpBrowse:phyPosBlock := {| | ::recNo() } - //oXbpBrowse:connectEvent( oXbpBrowse:oWidget, QEvent_FocusIn, {|| ::execE} ) oXbpBrowse:setInputFocus := {|| ::activated() } + /* Form View */ + ::qForm := QWidget():new() + ::qFLayout := QFormLayout():new() + ::qForm:setLayout( ::qFLayout ) + + ::qSplitter:addWidget( ::qForm ) + ::qLayout := qLayout ::oWnd := oWnd ::oBrw := oXbpBrowse @@ -342,6 +369,25 @@ METHOD IdeBrowse:buildBrowser() /*----------------------------------------------------------------------*/ +METHOD IdeBrowse:buildForm() + LOCAL a_, qLbl, qEdit + + IF ::nType == BRW_TYPE_DBF + FOR EACH a_ IN ::aStruct + qLbl := QLabel():new() + qLbl:setText( a_[ 1 ] ) + qEdit := QLineEdit():new() + ::qFLayout:addRow( qLbl, qEdit ) + aadd( ::aForm, { qLbl, qEdit } ) + NEXT + ELSE + + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeBrowse:dataLink( nField ) LOCAL bBlock diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index ecd6bc204b..41f8184fec 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -231,7 +231,6 @@ METHOD IdeDocks:buildDialog() ::oIde:oDlg := XbpDialog():new() ::oDlg:icon := hbide_image( "hbide" ) ::oDlg:title := "Harbour IDE" -// ::oDlg:qtObject := HbQtUI():new( hbide_uic( "mainwindow" ) ):build() ::oDlg:qtObject := hbide_getUI( "mainwindow" ) ::oDlg:create( , , , , , .f. ) diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index 4d2815a697..429edca082 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -436,6 +436,7 @@ EXPORTED: DATA nRightFrozen INIT 0 METHOD destroy() + METHOD countRows() ENDCLASS @@ -556,6 +557,7 @@ METHOD XbpBrowse:buildRightFreeze() /*----------------------------------------------------------------------*/ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + LOCAL qRect ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) @@ -660,10 +662,16 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ENDIF ::oParent:AddChild( SELF ) + ::oFooterView:hide() + /* Viewport */ ::oViewport:configure( ::oTableView:viewport() ) - ::oFooterView:hide() + ::oWidget:installEventFilter( ::pEvents ) + ::connectEvent( ::oWidget, QEvent_Resize, {|| ::execSlot( 2001 ) } ) + + qRect := QRect():from( ::oWidget:geometry() ) + ::oWidget:setGeometry( qRect ) RETURN Self @@ -898,6 +906,12 @@ METHOD XbpBrowse:execSlot( nEvent, p1, p2, p3 ) CASE nEvent == 122 /* Footer Section Resized */ ::oHeaderView:resizeSection( p1, p3 ) + CASE nEvent == 2001 + ::oHeaderView:resizeSection( 0, ::oHeaderView:sectionSize( 0 )+1 ) + ::oHeaderView:resizeSection( 0, ::oHeaderView:sectionSize( 0 )-1 ) + ::nConfigure := 9 + ::doConfigure() + ENDCASE RETURN Self @@ -1341,6 +1355,37 @@ METHOD XbpBrowse:setLeftFrozen( aColFrozens ) /*----------------------------------------------------------------------*/ +METHOD countRows() CLASS XbpBrowse + LOCAL nHHdr, nHFtr, nHCell, nHView, nHAvl + + nHHdr := nHFtr := nHCell := 0 +HB_TRACE( HB_TR_ALWAYS, 0, ::nRowsInView ) + IF .t. + nHView := ::oViewport:height() + + IF ::oHeaderView:isVisible() + aeval( ::columns, {|o| nHHdr := max( nHHdr, o:hHeight ) } ) + ENDIF + + IF ::oFooterView:isVisible() + aeval( ::columns, {|o| nHFtr := max( nHFtr, o:fHeight ) } ) + ENDIF + + /* Data Rows */ + aeval( ::columns, {|o| nHCell := max( nHCell, o:dHeight ) } ) + + nHAvl := nHView - nHHdr - nHFtr + + ::nRowsInView := Int( nHAvl / nHCell ) + IF ( nHAvl % nHCell ) > ( nHCell / 2 ) + ::nRowsInView++ + ENDIF + ENDIF +HB_TRACE( HB_TR_ALWAYS, 1, ::nRowsInView ) + RETURN ::nRowsInView + +/*----------------------------------------------------------------------*/ + METHOD doConfigure() CLASS XbpBrowse LOCAL oCol LOCAL aCol, aVal, aValA @@ -1378,28 +1423,6 @@ METHOD doConfigure() CLASS XbpBrowse nWidth := 256 ENDIF - #if 0 - cColSep := oCol:colSep - IF cColSep == NIL - cColSep := ::cColSep - ENDIF - - cHeadSep := oCol:headSep - IF !ISCHARACTER( cHeadSep ) .OR. cHeadSep == "" - cHeadSep := ::cHeadSep - IF !ISCHARACTER( cHeadSep ) - cHeadSep := "" - ENDIF - ENDIF - - cFootSep := oCol:footSep - IF !ISCHARACTER( cFootSep ) .OR. cFootSep == "" - cFootSep := ::cFootSep - IF !ISCHARACTER( cFootSep ) - cFootSep := "" - ENDIF - ENDIF - #endif cColSep := "" cHeadSep := "" cFootSep := "" @@ -1500,62 +1523,6 @@ METHOD doConfigure() CLASS XbpBrowse ENDIF NEXT - nRowCount := ::rowCount - IF nRowCount == 0 - _GENLIMITRTE() - ENDIF - - /* create new record buffer */ - ASize( ::aCellStatus , nRowCount ) - ASize( ::aDispStatus , nRowCount ) - ASize( ::aCellValues , nRowCount ) - ASize( ::aCellValuesA, nRowCount ) - ASize( ::aCellColors , nRowCount ) - AFill( ::aCellStatus , .F. ) - AFill( ::aDispStatus , .T. ) - FOR EACH aVal, aValA, aCol IN ::aCellValues, ::aCellValuesA, ::aCellColors - IF aVal == NIL - aVal := Array( nColCount ) - ELSE - ASize( aVal, nColCount ) - ENDIF - IF aValA == NIL - aValA := Array( nColCount ) - ELSE - ASize( aValA, nColCount ) - ENDIF - IF aCol == NIL - aCol := Array( nColCount ) - ELSE - ASize( aCol, nColCount ) - ENDIF - NEXT - - ::lStable := .F. - ::lFrames := .T. - - /* Clipper does not set refreshAll flag in Configure */ - /* ::lRefresh := .T. */ - - ::nLastRow := nRowCount - ::nLastScroll := 0 - - /* CA-Cl*pper update visible columns here but without - * colPos repositioning. [druzus] - */ - #if 0 - _SETVISIBLE( ::aColData, _TBR_COORD( ::n_Right ) - _TBR_COORD( ::n_Left ) + 1, ; - @::nFrozen, @::nLeftVisible, @::nRightVisible ) - #endif - - ::nLastPos := 0 - - IF ::nRowPos > nRowCount - ::nRowPos := nRowCount - ELSEIF ::nRowPos < 1 - ::nRowPos := 1 - ENDIF - /* Qt Specifics follows */ // IF !( ::lHScroll ) @@ -1691,6 +1658,50 @@ METHOD doConfigure() CLASS XbpBrowse ENDIF NEXT + + nRowCount := ::rowCount + IF nRowCount == 0 + _GENLIMITRTE() + ENDIF + + /* create new record buffer */ + ASize( ::aCellStatus , nRowCount ) + ASize( ::aDispStatus , nRowCount ) + ASize( ::aCellValues , nRowCount ) + ASize( ::aCellValuesA, nRowCount ) + ASize( ::aCellColors , nRowCount ) + AFill( ::aCellStatus , .F. ) + AFill( ::aDispStatus , .T. ) + FOR EACH aVal, aValA, aCol IN ::aCellValues, ::aCellValuesA, ::aCellColors + IF aVal == NIL + aVal := Array( nColCount ) + ELSE + ASize( aVal, nColCount ) + ENDIF + IF aValA == NIL + aValA := Array( nColCount ) + ELSE + ASize( aValA, nColCount ) + ENDIF + IF aCol == NIL + aCol := Array( nColCount ) + ELSE + ASize( aCol, nColCount ) + ENDIF + NEXT + + ::lStable := .F. + ::lFrames := .T. + ::nLastRow := nRowCount + ::nLastScroll := 0 + ::nLastPos := 0 + IF ::nRowPos > nRowCount + ::nRowPos := nRowCount + ELSEIF ::nRowPos < 1 + ::nRowPos := 1 + ENDIF + + ::setHorzScrollBarRange() /* Inform Qt about number of rows and columns browser implements */