diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 5d7f7e50cf..3e249a849f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,25 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-22 18:51 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbxbp/xbpbrowse.prg + + Changed: width of the columns : maximum of data or header. + + * contrib/hbide/idebrowse.prg + * contrib/hbide/idemisc.prg + + Implemented: ideDBU - left-toolbar icons. + Append, Delete, Lock, Gotop, GoBottom, ToFirstColumn, ToLastColumn, Search. + + + Implemented: ideDBU - context menu: + > Scroll to... Opens a input dialog to fetch fieldname ( case insensitive ). + Any first characters will scroll the browser to + make that column visible. Vey handy especially in + tables with lot of fields. + > Search in Field Opens input dialog to fetch a value to be searched + sequentially on the highlighted field. This option is + available in any state of the table, indexed or natural order. + > Form View Triggers the form-view scrollable widget visible. + 2010-07-22 10:15 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/hbpprocess.prg + Added: :waitForFinished() method. diff --git a/harbour/contrib/hbide/idebrowse.prg b/harbour/contrib/hbide/idebrowse.prg index 823ec0b85b..3d6ce61fb7 100644 --- a/harbour/contrib/hbide/idebrowse.prg +++ b/harbour/contrib/hbide/idebrowse.prg @@ -576,6 +576,49 @@ METHOD IdeBrowseManager:execEvent( cEvent, p, p1 ) ENDIF EXIT + CASE "buttonAppendRecord_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:append() + ENDIF + EXIT + CASE "buttonDelRecord_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:delete( .t. ) + ENDIF + EXIT + CASE "buttonLockRecord_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:lock() + ENDIF + EXIT + CASE "buttonGoTop_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:goTop() + ENDIF + EXIT + CASE "buttonGoBottom_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:goBottom() + ENDIF + EXIT + CASE "buttonScrollToFirst_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:toColumn( 1 ) + ENDIF + EXIT + CASE "buttonScrollToLast_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:toColumn( len( ::oCurBrw:aStruct ) ) + ENDIF + EXIT + CASE "buttonSearchInTable_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:searchAsk() + ENDIF + EXIT + CASE "buttonZaptable_clicked" + EXIT + ENDSWITCH RETURN Self @@ -843,7 +886,8 @@ METHOD IdeBrowseManager:buildLeftToolbar() STATIC qSize - qSize := QSize():new( 20,20 ) + //qSize := QSize():new( 20,20 ) + qSize := QSize():new( 16,16 ) ::qToolBarL := QToolbar():new() ::qToolBarL:setOrientation( Qt_Vertical ) @@ -851,15 +895,18 @@ METHOD IdeBrowseManager:buildLeftToolbar() ::qToolbarL:setMaximumWidth( 24 ) ::qToolbarL:setStyleSheet( GetStyleSheet( "QToolBar", ::nAnimantionMode ) ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_add" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_remove" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_lock" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_up" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_down" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_previous", "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_next" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_search" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) - ::buildToolButton( ::qToolbarL, { "Append a record", "database_process" , "clicked()", {|| ::execEvent( "buttonAppend_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, { "Append a record" , "database_add" , "clicked()", {|| ::execEvent( "buttonAppendRecord_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, { "Delete a record" , "database_remove" , "clicked()", {|| ::execEvent( "buttonDelRecord_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, { "Lock/Unlock Record" , "database_lock" , "clicked()", {|| ::execEvent( "buttonLockRecord_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, {} ) + ::buildToolButton( ::qToolbarL, { "Goto Top" , "database_up" , "clicked()", {|| ::execEvent( "buttonGoTop_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, { "Goto Bottom" , "database_down" , "clicked()", {|| ::execEvent( "buttonGoBottom_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, { "Scroll to First Column", "database_previous", "clicked()", {|| ::execEvent( "buttonScrollToFirst_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, { "Scroll to Last Column" , "database_next" , "clicked()", {|| ::execEvent( "buttonScrollToLast_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, {} ) + ::buildToolButton( ::qToolbarL, { "Search in Table" , "database_search" , "clicked()", {|| ::execEvent( "buttonSearchInTable_clicked" ) }, .f. } ) + ::buildToolButton( ::qToolbarL, {} ) + ::buildToolButton( ::qToolbarL, { "Zap Table" , "database_process" , "clicked()", {|| ::execEvent( "buttonZaptable_clicked" ) }, .f. } ) RETURN Self @@ -1274,6 +1321,7 @@ CLASS IdeBrowse INHERIT IdeObject DATA aIdx INIT {} DATA aFlds INIT {} DATA aSeek INIT {} + DATA aToFld INIT {} METHOD new( oIde, oManager, oPanel, aInfo ) METHOD create( oIde, oManager, oPanel, aInfo ) @@ -1293,9 +1341,10 @@ CLASS IdeBrowse INHERIT IdeObject METHOD goTop() METHOD goBottom() METHOD goTo( nRec ) + METHOD lock() METHOD goToAsk() METHOD append() - METHOD delete() + METHOD delete( lAsk ) METHOD recall() METHOD recNo() METHOD lastRec() @@ -1311,8 +1360,8 @@ CLASS IdeBrowse INHERIT IdeObject ACCESS numIndexes() INLINE len( ::aIndex ) METHOD dispInfo() - METHOD search( cSearch, lSoft, lLast ) - METHOD searchAsk() + METHOD search( cSearch, lSoft, lLast, nMode ) + METHOD searchAsk( nMode ) METHOD seekAsk( nMode ) METHOD next() METHOD previous() @@ -1320,8 +1369,9 @@ CLASS IdeBrowse INHERIT IdeObject METHOD populateForm() METHOD fetchAlias( cTable ) METHOD saveField( nField, x ) - METHOD toColumn( nIndex ) + METHOD toColumn( ncIndex ) METHOD getSome( cType, cFor ) + METHOD buildContextMenu() ENDCLASS @@ -1438,7 +1488,7 @@ METHOD IdeBrowse:create( oIde, oManager, oPanel, aInfo ) ::oBrw:keyboard := {|mp1,mp2| ::execEvent( "browse_keyboard", mp1, mp2 ) } ::qTimer := QTimer():new() - ::qTimer:setInterval( 10 ) + ::qTimer:setInterval( 5 ) ::connect( ::qTimer, "timeout()", {|| ::execEvent( "timer_timeout" ) } ) RETURN Self @@ -1651,7 +1701,6 @@ METHOD IdeBrowse:configure() /*------------------------------------------------------------------------*/ METHOD IdeBrowse:execEvent( cEvent, p, p1 ) - LOCAL cIndex, a_, cPmt, nZeros HB_SYMBOL_UNUSED( p ) HB_SYMBOL_UNUSED( p1 ) @@ -1707,50 +1756,8 @@ METHOD IdeBrowse:execEvent( cEvent, p, p1 ) CASE "browser_contextMenu" IF empty( ::aMenu ) - IF len( ::aIndex ) > 0 - aadd( ::aMenu, { "Set to Natural Order", {|| ::setOrder( 0 ) } } ) - aadd( ::aMenu, { "" } ) - ENDIF - - /* Indexed Order */ - ::getIndexInfo() - FOR EACH cIndex IN ::aIndex - aadd( ::aIdx, hbide_indexArray( Self, cIndex, cIndex:__enumIndex() ) ) - NEXT - IF ! empty( ::aIdx ) - aadd( ::aMenu, { ::aIdx, "Set to Indexed Order" } ) - aadd( ::aMenu, { "" } ) - ENDIF - - /* Column Scrolling */ - nZeros := iif( len( ::aStruct ) < 10, 1, iif( len( ::aStruct ) < 100, 2, 3 ) ) - FOR EACH a_ IN ::aStruct - cPmt := strzero( a_:__enumIndex(), nZeros ) + " " + a_[ 2 ] + " . " + a_[ 1 ] - aadd( ::aFlds, hbide_fieldsArray( Self, cPmt, a_:__enumIndex() ) ) - NEXT - aadd( ::aMenu, { ::aFlds, "Scroll to Column" } ) - aadd( ::aMenu, { "" } ) - - /* Seeks */ - aadd( ::aSeek, { "Seek" , {|| ::seekAsk( 0 ) } } ) - aadd( ::aSeek, { "Seek Soft" , {|| ::seekAsk( 1 ) } } ) - aadd( ::aSeek, { "Seek Last" , {|| ::seekAsk( 2 ) } } ) - aadd( ::aMenu, { ::aSeek, "Seek..." } ) - aadd( ::aMenu, { "" } ) - - /* Navigation */ - aadd( ::aMenu, { "Go Top" , {|| ::goTop() } } ) - aadd( ::aMenu, { "Go Bottom" , {|| ::goBottom() } } ) - aadd( ::aMenu, { "Goto Record", {|| ::gotoAsk() } } ) - aadd( ::aMenu, { "" } ) - - /* Manipulation */ - aadd( ::aMenu, { "Append Blank" , {|| ::append() } } ) - aadd( ::aMenu, { "Delete Record" , {|| ::delete() } } ) - aadd( ::aMenu, { "Recall Deleted", {|| ::recall() } } ) - + ::buildContextMenu() ENDIF - hbide_execPopup( ::aMenu, p, ::qMdi ) EXIT @@ -1771,6 +1778,62 @@ METHOD IdeBrowse:execEvent( cEvent, p, p1 ) /*----------------------------------------------------------------------*/ +METHOD IdeBrowse:buildContextMenu() + LOCAL a_, cPmt, nZeros, cIndex + + IF len( ::aIndex ) > 0 + aadd( ::aMenu, { "Set to Natural Order", {|| ::setOrder( 0 ) } } ) + aadd( ::aMenu, { "" } ) + ENDIF + + /* Indexed Order */ + ::getIndexInfo() + FOR EACH cIndex IN ::aIndex + aadd( ::aIdx, hbide_indexArray( Self, cIndex, cIndex:__enumIndex() ) ) + NEXT + IF ! empty( ::aIdx ) + aadd( ::aMenu, { ::aIdx, "Set to Indexed Order" } ) + aadd( ::aMenu, { "" } ) + ENDIF + + /* Column Scrolling */ + nZeros := iif( len( ::aStruct ) < 10, 1, iif( len( ::aStruct ) < 100, 2, 3 ) ) + FOR EACH a_ IN ::aStruct + cPmt := strzero( a_:__enumIndex(), nZeros ) + " " + a_[ 2 ] + " . " + a_[ 1 ] + aadd( ::aFlds, hbide_fieldsArray( Self, cPmt, a_:__enumIndex() ) ) + NEXT + aadd( ::aMenu, { ::aFlds, "Scroll to Column" } ) + aadd( ::aMenu, { "Scroll to ...", {|v| v := ( QInputDialog():new() ):getText( , "Field Name" ), ::toColumn( v ) } } ) + aadd( ::aMenu, { "" } ) + + /* Seeks */ + aadd( ::aSeek, { "Seek" , {|| ::seekAsk( 0 ) } } ) + aadd( ::aSeek, { "Seek Soft" , {|| ::seekAsk( 1 ) } } ) + aadd( ::aSeek, { "Seek Last" , {|| ::seekAsk( 2 ) } } ) + aadd( ::aMenu, { ::aSeek, "Seek..." } ) + aadd( ::aMenu, { "Search in Field", {|| ::searchAsk( 1 ) } } ) + aadd( ::aMenu, { "" } ) + + /* Navigation */ + aadd( ::aMenu, { "Go Top" , {|| ::goTop() } } ) + aadd( ::aMenu, { "Go Bottom" , {|| ::goBottom() } } ) + aadd( ::aMenu, { "Goto Record", {|| ::gotoAsk() } } ) + aadd( ::aMenu, { "" } ) + + /* Manipulation */ + aadd( ::aMenu, { "Append Blank" , {|| ::append() } } ) + aadd( ::aMenu, { "Delete Record" , {|| ::delete( .t. ) } } ) + aadd( ::aMenu, { "Recall Deleted", {|| ::recall() } } ) + aadd( ::aMenu, { "" } ) + + /* Miscellaneous */ + aadd( ::aMenu, { "Form View", {|| ::oManager:execEvent( "buttonShowForm_clicked" ) } } ) + + + RETURN Self + +/*----------------------------------------------------------------------*/ + STATIC FUNCTION hbide_fieldsArray( obj, cPmt, nIndex ) RETURN { cPmt, {|| obj:toColumn( nIndex ) } } @@ -1983,23 +2046,37 @@ METHOD IdeBrowse:seekAsk( nMode ) /*------------------------------------------------------------------------*/ -METHOD IdeBrowse:searchAsk() +METHOD IdeBrowse:searchAsk( nMode ) LOCAL xValue, cFor - xValue := iif( ::indexOrd() > 0, ::indexKeyValue(), eval( ::oBrw:getColumn( ::oBrw:colPos ):block ) ) - cFor := iif( ::indexOrd() > 0, "Indexed: " + ::indexKey(), ::aStruct[ ::oBrw:colPos, 1 ] ) + DEFAULT nMode TO 0 - ::search( ::getSome( valtype( xValue ), cFor ), .f., .f. ) + IF nMode == 0 + xValue := iif( ::indexOrd() > 0, ::indexKeyValue(), eval( ::oBrw:getColumn( ::oBrw:colPos ):block ) ) + cFor := iif( ::indexOrd() > 0, "Indexed: " + ::indexKey(), ::aStruct[ ::oBrw:colPos, 1 ] ) + ELSEIF nMode == 1 + xValue := eval( ::oBrw:getColumn( ::oBrw:colPos ):block ) + cFor := ::aStruct[ ::oBrw:colPos, 1 ] + ENDIF + + ::search( ::getSome( valtype( xValue ), cFor ), .f., .f., nMode ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD IdeBrowse:search( cSearch, lSoft, lLast ) +METHOD IdeBrowse:search( cSearch, lSoft, lLast, nMode ) LOCAL nRec + DEFAULT nMode TO 0 + + IF ::lInSearch + ::qTimer:stop() + ::lInSearch := .f. + ENDIF + IF ::nType == BRW_TYPE_DBF - IF ! empty( cSearch ) + IF nMode == 0 IF ( ::cAlias )->( IndexOrd() ) > 0 DEFAULT lLast TO .f. @@ -2014,13 +2091,14 @@ METHOD IdeBrowse:search( cSearch, lSoft, lLast ) MsgBox( "Could not find: " + cSearch ) ENDIF ELSE - IF ::lInSearch - ::qTimer:stop() - ENDIF ::xSearch := cSearch ::lInSearch := .t. ::qTimer:start() ENDIF + ELSE + ::xSearch := cSearch + ::lInSearch := .t. + ::qTimer:start() ENDIF ELSE // Ascan @@ -2041,7 +2119,19 @@ METHOD IdeBrowse:refreshAll() /*----------------------------------------------------------------------*/ -METHOD IdeBrowse:toColumn( nIndex ) +METHOD IdeBrowse:toColumn( ncIndex ) + LOCAL nIndex + + IF valtype( ncIndex ) == "C" + ncIndex := upper( ncIndex ) + nIndex := ascan( ::aStruct, {|e_| e_[ 1 ] = ncIndex } ) + ELSE + nIndex := ncIndex + ENDIF + + IF empty( nIndex ) + RETURN Self + ENDIF ::oBrw:colPos := nIndex ::oBrw:refreshAll() @@ -2052,6 +2142,20 @@ METHOD IdeBrowse:toColumn( nIndex ) /*----------------------------------------------------------------------*/ +METHOD IdeBrowse:lock() + + IF ::nType == BRW_TYPE_DBF + IF ! ( ::cAlias )->( DbrLock() ) + MsgBox( "Record could not been locked" ) + ENDIF + ELSE + MsgBox( "Record can not be locked" ) + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeBrowse:goToAsk() LOCAL nRec @@ -2232,7 +2336,15 @@ METHOD IdeBrowse:append() /*------------------------------------------------------------------------*/ -METHOD IdeBrowse:delete() +METHOD IdeBrowse:delete( lAsk ) + + DEFAULT lAsk TO .t. + + IF lAsk + IF ! hbide_getYesNo( "Delete Record ?", , "Deletion Process" ) + RETURN Self + ENDIF + ENDIF IF ::nType == BRW_TYPE_DBF IF ( ::cAlias )->( DbRLock() ) diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index a46355b03f..bbed2d0206 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -2129,7 +2129,7 @@ FUNCTION hbide_getUI( cUI, qParent ) FUNCTION hbide_request() - REQUEST HBDbfModel + REQUEST HBQAbstractItemModel REQUEST HBEvents REQUEST HBQMainWindow REQUEST HBQPlainTextEdit diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index 625f70ca93..cc79dca976 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -1539,6 +1539,7 @@ METHOD doConfigure() CLASS XbpBrowse LOCAL lHeadSep, lFootSep LOCAL nMaxCellH := 0 LOCAL nViewH, i, xVal, oFontMetrics, n, nLeftWidth + LOCAL nwVal, nwHead ::nConfigure := 0 @@ -1728,8 +1729,14 @@ METHOD doConfigure() CLASS XbpBrowse ::oFooterView:resizeSection( i-1, ::columns[ i ]:nColWidth ) ELSE xVal := transform( eval( ::columns[ i ]:block ), ::columns[ i ]:picture ) - ::oHeaderView:resizeSection( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) - ::oFooterView:resizeSection( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) + + nwVal := oFontMetrics:width( xVal, -1 ) + nwHead := oFontMetrics:width( ::columns[ i ]:heading(), -1 ) + + ::oHeaderView:resizeSection( i-1, max( nwVal, nwHead ) + 8 ) + ::oFooterView:resizeSection( i-1, max( nwVal, nwHead ) + 8 ) + * ::oHeaderView:resizeSection( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) + * ::oFooterView:resizeSection( i-1, oFontMetrics:width( xVal, -1 ) + 8 ) ENDIF NEXT @@ -1741,8 +1748,12 @@ METHOD doConfigure() CLASS XbpBrowse ::oLeftFooterView:resizeSection( n-1, ::columns[ i ]:nColWidth ) ELSE xVal := transform( eval( ::columns[ i ]:block ), ::columns[ i ]:picture ) - ::oLeftHeaderView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) - ::oLeftFooterView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) + nwVal := oFontMetrics:width( xVal, -1 ) + nwHead := oFontMetrics:width( ::columns[ i ]:heading(), -1 ) + ::oLeftHeaderView:resizeSection( n-1, max( nwVal, nwHead ) + 8 ) + ::oLeftFooterView:resizeSection( n-1, max( nwVal, nwHead ) + 8 ) + * ::oLeftHeaderView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) + * ::oLeftFooterView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) ENDIF nLeftWidth += ::oLeftHeaderView:sectionSize( n-1 ) NEXT @@ -1758,8 +1769,12 @@ METHOD doConfigure() CLASS XbpBrowse ::oRightFooterView:resizeSection( n-1, ::columns[ i ]:nColWidth ) ELSE xVal := transform( eval( ::columns[ i ]:block ), ::columns[ i ]:picture ) - ::oRightHeaderView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) - ::oRightFooterView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) + nwVal := oFontMetrics:width( xVal, -1 ) + nwHead := oFontMetrics:width( ::columns[ i ]:heading(), -1 ) + ::oRightHeaderView:resizeSection( n-1, max( nwVal, nwHead ) + 8 ) + ::oRightFooterView:resizeSection( n-1, max( nwVal, nwHead ) + 8 ) + * ::oRightHeaderView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) + * ::oRightFooterView:resizeSection( n-1, oFontMetrics:width( xVal, -1 ) + 8 ) ENDIF nLeftWidth += ::oRightHeaderView:sectionSize( n-1 ) NEXT