diff --git a/harbour/ChangeLog b/harbour/ChangeLog index bb73c01cda..2c34af6290 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,47 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-16 02:52 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/doc/en/class_hbqplaintextedit.txt + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + * contrib/hbqt/hbqt_hbqplaintextedit.h + * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + * contrib/hbqt/qtgui/THBQPlainTextEdit.prg + * contrib/hbqt/qth/HBQPlainTextEdit.qth + + Added: :hbSelectAll() method. + + * contrib/hbxbp/xbpbrowse.prg + ! Minor. + + + contrib/hbide/fetchdate.ui + + Added: dialog to fetch a date value. It also employs calender widget. + + * contrib/hbide/ideedit.prg + ! Fixed: many artifacts related to selection behaviour. + + * contrib/hbide/idemisc.prg + * contrib/hbide/idebrowse.prg + + Implemented: search in the current browser. + Search is available in two modes: + + 1. When table has some index active : DbSeek() is performed. + The value to seek is based on the type returned by valtype( &( IndexKey() ) ). + 2. When table has no active index: sequential search is performed. + The value of search is based on the current highlighted cell. + + Input dialog is presented depending upon the search variable type. + Sequential search is a slow process but there is no alternative to that. + Sequential search is initiated from the current record downwards and terminated + either on oBrw:hitBottom is encountered or value is found. + + Icon: ideDBU toolbar-serach Hotkey: CTRL+F + + + Implemented: goto record. It is straight forward. DbGoto( nRecord ) is issued. + + Icon: ideDBU toolbar-goto record Hotkey: CTRL+G + + Please forward your opinions. + 2010-07-16 08:16 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbqt/tests/testqaim.prg ! Two fixes reported by Tamas and Bacco respectively. diff --git a/harbour/contrib/hbide/fetchdate.ui b/harbour/contrib/hbide/fetchdate.ui new file mode 100644 index 0000000000..4b4bf16db2 --- /dev/null +++ b/harbour/contrib/hbide/fetchdate.ui @@ -0,0 +1,71 @@ + + + DialogDate + + + + 0 + 0 + 194 + 104 + + + + Fetch a date + + + + + 14 + 30 + 161 + 22 + + + + true + + + + + + 14 + 68 + 75 + 24 + + + + OK + + + + + + 102 + 68 + 75 + 24 + + + + Cancel + + + + + + 14 + 8 + 159 + 16 + + + + Select a date + + + + + + diff --git a/harbour/contrib/hbide/idebrowse.prg b/harbour/contrib/hbide/idebrowse.prg index 4a3827e565..7be8f8d1d7 100644 --- a/harbour/contrib/hbide/idebrowse.prg +++ b/harbour/contrib/hbide/idebrowse.prg @@ -498,6 +498,18 @@ METHOD IdeBrowseManager:execEvent( cEvent, p, p1, p2 ) ::populateFieldData() EXIT + CASE "buttonFind_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:searchAsk() + ENDIF + EXIT + + CASE "buttonGoto_clicked" + IF !empty( ::oCurBrw ) + ::oCurBrw:gotoAsk() + ENDIF + EXIT + ENDSWITCH #if 0 @@ -718,7 +730,11 @@ METHOD IdeBrowseManager:buildToolbar() ::buildToolButton( { "Close current table", "dc_delete" , "clicked()", {|| ::execEvent( "buttonClose_clicked" ) }, .f. } ) ::buildToolButton( {} ) ::buildToolButton( { "Table Structure" , "dbstruct" , "clicked()", {|| ::execEvent( "buttonDbStruct_clicked" ) }, .f. } ) + ::buildToolButton( {} ) ::buildIndexButton() + ::buildToolButton( { "Search in table" , "find" , "clicked()", {|| ::execEvent( "buttonFind_clicked" ) }, .f. } ) + ::buildToolButton( { "Goto record" , "gotoline" , "clicked()", {|| ::execEvent( "buttonGoto_clicked" ) }, .f. } ) + ::buildToolButton( {} ) RETURN Self @@ -1057,6 +1073,8 @@ CLASS IdeBrowse INHERIT IdeObject DATA qForm DATA qFLayout DATA qSplitter + DATA qTimer + DATA aForm INIT {} DATA oManager DATA oPanel @@ -1082,6 +1100,9 @@ CLASS IdeBrowse INHERIT IdeObject DATA qClose DATA aIndex INIT {} + DATA xSearch + DATA lInSearch INIT .f. + METHOD new( oIde, oManager, oPanel, aInfo ) METHOD create( oIde, oManager, oPanel, aInfo ) METHOD configure() @@ -1106,6 +1127,7 @@ CLASS IdeBrowse INHERIT IdeObject METHOD indexOrd() METHOD ordName( nOrder ) METHOD IndexKey( nOrder ) + METHOD IndexKeyValue( nOrder ) METHOD setOrder( nOrder ) METHOD refreshAll() METHOD getIndexInfo() @@ -1151,7 +1173,7 @@ METHOD IdeBrowse:create( oIde, oManager, oPanel, aInfo ) aSize( ::aInfo, TBL_VRBLS ) - DEFAULT ::aInfo[ TBL_PANEL ] TO ::oPanel:cName + DEFAULT ::aInfo[ TBL_PANEL ] TO ::oPanel:cPanel DEFAULT ::aInfo[ TBL_NAME ] TO "" DEFAULT ::aInfo[ TBL_ALIAS ] TO "" DEFAULT ::aInfo[ TBL_DRIVER ] TO ::oManager:qRddCombo:currentText() @@ -1219,13 +1241,17 @@ METHOD IdeBrowse:create( oIde, oManager, oPanel, aInfo ) ::oBrw:colPos := val( aInfo[ TBL_COLPOS ] ) ::oBrw:forceStable() ::setOrder( val( aInfo[ TBL_INDEX ] ) ) - ::goto( val( aInfo[ TBL_RECORD ] ) ) + ::goto( max( 1, val( aInfo[ TBL_RECORD ] ) ) ) ::oBrw:refreshAll() ::oBrw:forceStable() ::oBrw:navigate := {|mp1,mp2| ::execEvent( "browse_navigate", mp1, mp2 ) } ::oBrw:keyboard := {|mp1,mp2| ::execEvent( "browse_keyboard", mp1, mp2 ) } + ::qTimer := QTimer():new() + ::qTimer:setInterval( 10 ) + ::connect( ::qTimer, "timeout()", {|| ::execEvent( "timer_timeout" ) } ) + RETURN Self /*----------------------------------------------------------------------*/ @@ -1356,6 +1382,16 @@ METHOD IdeBrowse:execEvent( cEvent, p, p1 ) ENDIF EXIT + CASE "timer_timeout" + ::oBrw:down() + IF ::oBrw:hitBottom + ::qTimer:stop() + ENDIF + IF eval( ::oBrw:getColumn( ::oBrw:colPos ):block ) == ::xSearch + ::qTimer:stop() + ENDIF + EXIT + ENDSWITCH RETURN Self @@ -1569,12 +1605,33 @@ METHOD IdeBrowse:previous() /*----------------------------------------------------------------------*/ METHOD IdeBrowse:searchAsk() - LOCAL cSearch + LOCAL xValue, xSearch, nOrd, cFor - IF !empty( cSearch := hbide_fetchAString( ::oWnd:oWidget, "", ::aStruct[ ::oBrw:colPos, 1 ], "Search" ) ) - ::search( cSearch ) + IF ( nOrd := ::indexOrd() ) > 0 + xValue := ::indexKeyValue() + ELSE + xValue := eval( ::oBrw:getColumn( ::oBrw:colPos ):block ) ENDIF + cFor := iif( nOrd > 0, "Indexed: " + ::indexKey(), ::aStruct[ ::oBrw:colPos, 1 ] ) + + SWITCH valtype( xValue ) + CASE 'C' + IF !empty( xSearch := ( QInputDialog():new() ):getText( ::oWnd:oWidget, "Search for?", cFor ) ) + ::search( xSearch ) + ENDIF + EXIT + CASE 'N' + xSearch := ( QInputDialog():new() ):getDouble( ::oWnd:oWidget, "Search for?", cFor, ; + 0, -2147483647, 2147483647, iif( nOrd > 0, 3, ::aStruct[ ::oBrw:colPos, 4 ] ) ) + ::search( xSearch ) + EXIT + CASE 'D' + xSearch := hbide_fetchADate( ::oWnd:oWidget, "Search for?", cFor ) + ::search( xSearch ) + EXIT + ENDSWITCH + RETURN Self /*----------------------------------------------------------------------*/ @@ -1594,7 +1651,12 @@ METHOD IdeBrowse:search( cSearch ) MsgBox( "Could not find: " + cSearch ) ENDIF ELSE - // Sequential search + IF ::lInSearch + ::qTimer:stop() + ENDIF + ::xSearch := cSearch + ::lInSearch := .t. + ::qTimer:start() ENDIF ENDIF ELSE @@ -1610,6 +1672,7 @@ METHOD IdeBrowse:refreshAll() ::oBrw:refreshAll() ::oBrw:forceStable() ::oBrw:setCurrentIndex( .t. ) + ::dispInfo() RETURN Self @@ -1618,7 +1681,7 @@ METHOD IdeBrowse:refreshAll() METHOD IdeBrowse:goToAsk() LOCAL nRec - IF ! empty( nRec := ( QInputDialog():new() ):getInt( , "Goto", "Record_# ?", , ::recno() ) ) + IF ! empty( nRec := ( QInputDialog():new() ):getInt( , "Goto", "Record_# ?", ::recno(), 1, ::lastrec() ) ) ::goto( nRec ) ::refreshAll() ENDIF @@ -1750,6 +1813,17 @@ METHOD IdeBrowse:ordName( nOrder ) /*----------------------------------------------------------------------*/ +METHOD IdeBrowse:indexKeyValue( nOrder ) + LOCAL xValue + + IF ::nType == BRW_TYPE_DBF + xValue := ( ::cAlias )->( &( IndexKey( nOrder ) ) ) + ENDIF + + RETURN xValue + +/*------------------------------------------------------------------------*/ + METHOD IdeBrowse:indexKey( nOrder ) DEFAULT nOrder TO ::indexOrd() diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index f620de7ad1..9b88f5d778 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -994,13 +994,14 @@ METHOD IdeEdit:deleteBlockContents( aCord ) nW := nR - nL IF nW == 0 .AND. k == Qt_Key_Backspace - FOR i := nT TO nB - cLine := ::getLine( i + 1 ) - cLine := pad( substr( cLine, 1, nL - 1 ), nL - 1 ) + substr( cLine, nL + 1 ) - hbide_qReplaceLine( qCursor, i, cLine ) - NEXT - hbide_qPositionCursor( qCursor, nB, nR - 1 ) - + IF nSelMode == selectionMode_column + FOR i := nT TO nB + cLine := ::getLine( i + 1 ) + cLine := pad( substr( cLine, 1, nL - 1 ), nL - 1 ) + substr( cLine, nL + 1 ) + hbide_qReplaceLine( qCursor, i, cLine ) + NEXT + hbide_qPositionCursor( qCursor, nB, nR - 1 ) + ENDIF ELSE IF k == Qt_Key_Delete .OR. k == Qt_Key_X IF nSelMode == selectionMode_column @@ -1416,7 +1417,7 @@ METHOD IdeEdit:paste() /*----------------------------------------------------------------------*/ METHOD IdeEdit:selectAll() - ::qEdit:selectAll() + ::qEdit:hbSelectAll() RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/idemisc.prg b/harbour/contrib/hbide/idemisc.prg index 23e66de171..bfc65e51f2 100644 --- a/harbour/contrib/hbide/idemisc.prg +++ b/harbour/contrib/hbide/idemisc.prg @@ -1217,12 +1217,49 @@ FUNCTION hbide_getOS() /*----------------------------------------------------------------------*/ +FUNCTION hbide_fetchADate( qParent, cTitle, cPrompt, dDefault ) + LOCAL qDate, oUI, pSlots, nRet + + DEFAULT cTitle TO "A Date Value" + DEFAULT cPrompt TO "What" + + pSlots := hbxbp_getSlotsPtr() + + oUI := hbide_getUI( "fetchdate", qParent ) + + oUI:setWindowTitle( cTitle ) + oUI:q_labelPrompt:setText( cPrompt ) + IF dDefault != NIL + qDate := QDate():new() + qDate:setYear( year( dDefault ) ) + qDate:setMonth( month( dDefault ) ) + qDate:setDay( day( dDefault ) ) + oUI:q_editDate:setDate( qDate ) + ENDIF + + Qt_Slots_connect( pSlots, oUI:q_buttonOk , "clicked()", {|| oUI:done( 1 ) } ) + Qt_Slots_connect( pSlots, oUI:q_buttonCancel, "clicked()", {|| oUI:done( 0 ) } ) + + nRet := oUI:exec() + + Qt_Slots_disconnect( pSlots, oUI:q_buttonOk ) + Qt_Slots_disconnect( pSlots, oUI:q_buttonCancel ) + + IF nRet == 1 + qDate := QDate():from( oUI:q_editDate:date() ) + RETURN stod( strzero( qDate:year(), 4 ) + strzero( qDate:month(),2 ) + strzero( qDate:day(), 2 ) ) + ENDIF + + RETURN NIL + +/*------------------------------------------------------------------------*/ + FUNCTION hbide_fetchAString( qParent, cDefault, cWhat, cTitle ) LOCAL qGo DEFAULT cDefault TO "" DEFAULT cWhat TO "" - DEFAULT cTitle TO "A String Value Please" + DEFAULT cTitle TO "A String Value" qGo := QInputDialog():new( qParent ) qGo:setTextValue( cDefault ) @@ -2062,6 +2099,9 @@ FUNCTION hbide_getUI( cUI, qParent ) CASE "dbstruct" oUI := iif( nModeUI == UI_MODE_FUNC, hbqtui_DbStruct( qParent ), NIL ) EXIT + CASE "fetchdate" + oUI := iif( nModeUI == UI_MODE_FUNC, hbqtui_FetchDate( qParent ), NIL ) + EXIT ENDSWITCH IF empty( oUI ) diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index ecaebcbe5d..c4e9eee646 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -79,6 +79,7 @@ :hbTogglePersistentSelection() -> NIL :hbHorzRulerVisible( lVisible ) -> NIL :hbSetProtoStyle( cCss ) -> NIL + :hbSelectAll() -> NIL $DESCRIPTION$ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index a9085b61de..ffaa3a8a9c 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -392,6 +392,21 @@ void HBQPlainTextEdit::hbClearSelection() /*----------------------------------------------------------------------*/ +void HBQPlainTextEdit::hbSelectAll() +{ + setCursorWidth( 1 ); + + rowBegins = 0; + rowEnds = document()->blockCount(); + columnBegins = 0; + columnEnds = 0; + + emit selectionChanged(); + repaint(); +} + +/*----------------------------------------------------------------------*/ + void HBQPlainTextEdit::hbHitTest( const QPoint & pt ) { QTextCursor ct = cursorForPosition( QPoint( 2,2 ) ); @@ -1041,31 +1056,25 @@ bool HBQPlainTextEdit::hbKeyPressSelectionByApplication( QKeyEvent * event ) bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) { - bool ctrl = event->modifiers() & Qt::ControlModifier; - bool shift = event->modifiers() & Qt::ShiftModifier; - if( ctrl && shift ) - return false; - int k = event->key(); - if( ctrl && event->text().isEmpty() ) - { - #if 0 - event->ignore(); - return true; - #endif + bool ctrl = event->modifiers() & Qt::ControlModifier; + bool shift = event->modifiers() & Qt::ShiftModifier; + if( ctrl && shift && ! isNavableKey( k ) ) { + return false; + } + + if( ctrl && event->text().isEmpty() && ! isNavableKey( k ) ) { return false; } if( ctrl && ( k == Qt::Key_C || k == Qt::Key_V || k == Qt::Key_X || - k == Qt::Key_A || k == Qt::Key_Z || k == Qt::Key_Y ) ) - { + k == Qt::Key_A || k == Qt::Key_Z || k == Qt::Key_Y ) ) { event->ignore(); return true; } - if( isSelectionByApplication ) - { + if( isSelectionByApplication ) { return hbKeyPressSelectionByApplication( event ); } @@ -1104,7 +1113,7 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) repaint(); } - QKeyEvent * ev = new QKeyEvent( event->type(), event->key(), Qt::NoModifier, event->text() ); + QKeyEvent * ev = new QKeyEvent( event->type(), event->key(), ctrl ? Qt::ControlModifier : Qt::NoModifier, event->text() ); keyPressEvent( ev ); return true; } @@ -1243,13 +1252,15 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) event->accept(); return true; } - else if( ! ctrl && k == Qt::Key_Delete && columnBegins >= 0 && selectionState > 0 && ( selectionMode == selectionMode_stream || selectionMode == selectionMode_line ) ) + else if( ! ctrl && ( k == Qt::Key_Backspace || k == Qt::Key_Delete ) && columnBegins >= 0 && selectionState > 0 && ( selectionMode == selectionMode_stream || selectionMode == selectionMode_line ) ) { - hbCut( k ); + hbCut( Qt::Key_Delete ); repaint(); selectionState = 0; - event->accept(); - return true; + if( k == Qt::Key_Delete ){ + event->accept(); + return true; + } } else if( ! ctrl && k >= ' ' && k < 127 && columnBegins >= 0 && selectionMode == selectionMode_stream ) //selectionState > 0 { diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index d460696579..903efc7924 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -213,6 +213,7 @@ public slots: void hbTogglePersistentSelection(); void hbHorzRulerVisible( bool visible ) { hbUpdateHorzRulerHeight( visible ? 20 : 0 ); }; void hbSetProtoStyle( const QString & css = "" ); + void hbSelectAll(); private slots: void hbSlotCursorPositionChanged(); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 55152bda56..6dc8a4e962 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -876,6 +876,20 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETPROTOSTYLE ) } } +/* + * void hbSelectAll() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSELECTALL ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbSelectAll(); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSELECTALL FP=( p )->hbSelectAll(); p is NULL" ) ); + } +} + /*----------------------------------------------------------------------*/ #endif /* #if QT_VERSION >= 0x040500 */ diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg index 406ab8a707..5412c52645 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -118,6 +118,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbTogglePersistentSelection() METHOD hbHorzRulerVisible( lVisible ) METHOD hbSetProtoStyle( cCss ) + METHOD hbSelectAll() ENDCLASS @@ -334,3 +335,7 @@ METHOD HBQPlainTextEdit:hbHorzRulerVisible( lVisible ) METHOD HBQPlainTextEdit:hbSetProtoStyle( cCss ) RETURN Qt_HBQPlainTextEdit_hbSetProtoStyle( ::pPtr, cCss ) + +METHOD HBQPlainTextEdit:hbSelectAll() + RETURN Qt_HBQPlainTextEdit_hbSelectAll( ::pPtr ) + diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index df3627dcb4..c85aeb4a42 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -149,6 +149,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbTogglePersistentSelection() void hbHorzRulerVisible( bool visible ) void hbSetProtoStyle( const QString & css ) + void hbSelectAll() diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index 98c194c06d..dbe0ad8548 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -657,6 +657,7 @@ METHOD XbpBrowse:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oTableView:setGridStyle( ::gridStyle ) /* to be based on column definition */ ::oTableView:setSelectionMode( QAbstractItemView_SingleSelection ) ::oTableView:setSelectionBehavior( IF( ::cursorMode == XBPBRW_CURSOR_ROW, QAbstractItemView_SelectRows, QAbstractItemView_SelectItems ) ) + ::oTableView:setAlternatingRowColors( .t. ) /* Connect Keyboard Events */ ::connect( ::oTableView, "keyPressEvent()" , {|p | ::execSlot( __ev_keypress__ , p ) } )