diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2ae12b22e0..d2c0ef4640 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,43 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-24 18:27 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qth/HBQPlainTextEdit.qth + * contrib/hbqt/qtgui/THBQPlainTextEdit.prg + * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + * contrib/hbqt/doc/en/class_hbqplaintextedit.txt + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + * contrib/hbqt/hbqt_hbqplaintextedit.h + + Added: one more method call. + + * contrib/hbide/idebrowse.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + + Implemented: for + FIELD-> and someAlias-> table fields for tables opened in ideDBU. + + How it Works: + 1. Open few tables in ideDBU. + 2. In some editor instance type "FIELD->" + It will set the field completion mode ON. + 3. type some letter starting a field, say, "a" + Code completion dialog will open with all fields + starting with "a" contained in all the tables opened. + 4. To get list of all fields in all tables, + after typing FIELD-> type "x" and then press back space. + 5. To get field completions for a particular alias, + type "that_Particular_alias->" and then some letter. + 6. To get all fields in an alias type "alias" then "->" then "x" then press "backspace". + + Presentation: + FIELD-> FieldName ( TableName ) FieldsOrdinalNumber, FieldType, FieldLength, DecPlaces + => + SaleAmount ( Invoice ) 13, N, 12, 2 + + Invoice-> FieldName FieldsOrdinalNumber, FieldType, FieldLength, DecPlaces + => + SaleAmount 13, N, 12, 2 + 2010-07-24 13:23 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/hbqt_hbqabstractitemmodel.cpp * contrib/hbxbp/xbpbrowse.prg diff --git a/harbour/contrib/hbide/idebrowse.prg b/harbour/contrib/hbide/idebrowse.prg index 7981b3b244..56281b86ea 100644 --- a/harbour/contrib/hbide/idebrowse.prg +++ b/harbour/contrib/hbide/idebrowse.prg @@ -178,6 +178,7 @@ CLASS IdeBrowseManager INHERIT IdeObject METHOD buildTablesButton() METHOD showTablesTree() METHOD fetchFldsList( cAlias ) + METHOD getBrowserByAlias( cAlias ) ENDCLASS @@ -346,14 +347,48 @@ METHOD IdeBrowseManager:create( oIde ) /*----------------------------------------------------------------------*/ METHOD IdeBrowseManager:fetchFldsList( cAlias ) - LOCAL aFlds := { "System","Latin" } + LOCAL aFlds := {}, cA, oBrw, a_, oPanel, aBrw - HB_SYMBOL_UNUSED( cAlias ) + cA := upper( cAlias ) + + SWITCH cA + CASE "FIELD" + FOR EACH oPanel IN ::aPanels + FOR EACH aBrw IN oPanel:aBrowsers + oBrw := aBrw[ SUB_BROWSER ] + FOR EACH a_ IN oBrw:aStruct + aadd( aFlds, pad( a_[ 1 ], 10 ) + " (" + padc( oBrw:cTableOnly, 12 ) + ")" + str( a_:__enumIndex(),3,0 ) + ", " + a_[ 2 ] + ", " + str( a_[ 3 ],3,0 ) + ", " + hb_ntos( a_[ 4 ] ) ) + NEXT + NEXT + NEXT + EXIT + OTHERWISE + IF ! empty( oBrw := ::getBrowserByAlias( cA ) ) + FOR EACH a_ IN oBrw:aStruct + aadd( aFlds, pad( a_[ 1 ], 10 ) + " ( " + str( a_:__enumIndex(),3,0 ) + ", " + a_[ 2 ] + ", " + str( a_[ 3 ],3,0 ) + ", " + hb_ntos( a_[ 4 ] ) + " )" ) + NEXT + ENDIF + EXIT + ENDSWITCH RETURN aFlds /*------------------------------------------------------------------------*/ +METHOD IdeBrowseManager:getBrowserByAlias( cAlias ) + LOCAL oPanel, aBrw + + FOR EACH oPanel IN ::aPanels + FOR EACH aBrw IN oPanel:aBrowsers + IF aBrw[ SUB_BROWSER ]:cAlias == cAlias + RETURN aBrw[ SUB_BROWSER ] + ENDIF + NEXT + NEXT + RETURN NIL + +/*------------------------------------------------------------------------*/ + METHOD IdeBrowseManager:dispStatusInfo() ::aStatusPnls[ PNL_PANELS ]:setText( "Panels: " + hb_ntos( len( ::aPanels ) ) + ":" + ::oCurPanel:cPanel ) diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index aab981c5ed..d878786010 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -200,7 +200,7 @@ CLASS IdeEdit INHERIT IdeObject METHOD hidePrototype() METHOD completeCode( p ) METHOD completeFieldName( p ) - METHOD updateFieldsList( cAlias ) +// METHOD updateFieldsList( cAlias ) METHOD setLineNumbersBkColor( nR, nG, nB ) METHOD setCurrentLineColor( nR, nG, nB ) @@ -284,7 +284,6 @@ METHOD IdeEdit:create( oIde, oEditor, nMode ) ::qEdit:hbSetSpaces( ::nTabSpaces ) ::qEdit:hbSetCompleter( ::qCompleter ) - ::qEdit:hbSetFldsCompleter( ::oEM:qFldsCompleter ) ::toggleCurrentLineHighlightMode() ::toggleLineNumbers() @@ -667,7 +666,10 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) ::aViewportInfo := p1 ELSEIF p == 21041 - ::updateFieldsList( p1 ) + ::qEdit:hbSetFieldsListActive( ::oEM:updateFieldsList( p1 ) ) + + ELSEIF p == 21042 + ::qEdit:hbSetFieldsListActive( ::oEM:updateFieldsList() ) ENDIF EXIT @@ -2271,31 +2273,6 @@ METHOD IdeEdit:completeFieldName( p ) /*----------------------------------------------------------------------*/ -METHOD IdeEdit:updateFieldsList( cAlias ) - LOCAL aFlds -HB_TRACE( HB_TR_ALWAYS, cAlias ) - //::disconnect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) - - aFlds := ::oBM:fetchFldsList( cAlias ) - asort( aFlds, , , {|e,f| lower( e ) < lower( f ) } ) - - ::oEM:qFldsStrList:clear() - aeval( aFlds, {|e| ::oEM:qFldsStrList:append( e ) } ) - - ::oEM:qFldsModel:setStringList( ::oEM:qFldsStrList ) - ::oEM:qFldsCompleter:setModel( ::oEM:qFldsModel ) - - ::oEM:qFldsCompleter:setWrapAround( .t. ) - ::oEM:qFldsCompleter:setCaseSensitivity( Qt_CaseInsensitive ) - ::oEM:qFldsCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel ) - ::oEM:qFldsCompleter:setCompletionMode( QCompleter_PopupCompletion ) - QListView():from( ::oEM:qFldsCompleter:popup() ):setAlternatingRowColors( .t. ) - - //::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) - RETURN Self - -/*----------------------------------------------------------------------*/ - FUNCTION hbide_getPreviousWord( cText, nPos ) LOCAL cWord, n diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 1261003eb9..f67bd70375 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -84,7 +84,6 @@ CLASS IdeEditsManager INHERIT IdeObject DATA aActions INIT {} DATA aProtos INIT {} - DATA qFldsCompleter DATA qFldsStrList DATA qFldsModel @@ -174,6 +173,7 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD qscintilla() METHOD setStyleSheet( nMode ) METHOD updateCompleter() + METHOD updateFieldsList( cAlias ) METHOD getProto( cWord ) ENDCLASS @@ -240,20 +240,33 @@ METHOD IdeEditsManager:create( oIde ) /* Define fields completer */ ::qFldsStrList := QStringList():new() ::qFldsModel := QStringListModel():new() - ::qFldsCompleter := QCompleter():new() - // - ::qFldsCompleter:setWrapAround( .t. ) - ::qFldsCompleter:setCaseSensitivity( Qt_CaseInsensitive ) - ::qFldsCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel ) - ::qFldsCompleter:setCompletionMode( QCompleter_PopupCompletion ) - QListView():from( ::qFldsCompleter:popup() ):setAlternatingRowColors( .t. ) - // - ::connect( ::qFldsCompleter, "activated(QString)", {|p| ::execEvent( "qFldsCompleter_activated", p ) } ) RETURN Self /*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:updateFieldsList( cAlias ) + LOCAL aFlds + + IF ! empty( cAlias ) .AND. ! empty( aFlds := ::oBM:fetchFldsList( cAlias ) ) + asort( aFlds, , , {|e,f| lower( e ) < lower( f ) } ) + + ::qFldsStrList:clear() + aeval( aFlds, {|e| ::qFldsStrList:append( e ) } ) + ::qFldsModel:setStringList( ::qFldsStrList ) + + ::qCompleter:setModel( ::qFldsModel ) + RETURN .t. + + ELSE + ::qCompleter:setModel( ::qCompModel ) + + ENDIF + + RETURN .f. + +/*----------------------------------------------------------------------*/ + METHOD IdeEditsManager:updateCompleter() LOCAL aFun, aHrb, aUsr, n, s, k_ @@ -301,8 +314,8 @@ METHOD IdeEditsManager:updateCompleter() ::qCompModel:setStringList( ::qProtoList ) ::qCompleter:setModel( ::qCompModel ) ::qCompleter:setCompletionMode( QCompleter_PopupCompletion ) - - QListView():from( ::qCompleter:popup() ):setAlternatingRowColors( .t. ) + ( QListView():from( ::qCompleter:popup() ) ):setAlternatingRowColors( .t. ) + ( QListView():from( ::qCompleter:popup() ) ):setFont( QFont():new( "Courier New", 8 ) ) ::connect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index f89db1df85..d1161b9525 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -81,6 +81,7 @@ :hbHorzRulerVisible( lVisible ) -> NIL :hbSetProtoStyle( cCss ) -> NIL :hbSelectAll() -> NIL + :hbSetFieldsListActive( lActive ) -> NIL $DESCRIPTION$ @@ -91,15 +92,15 @@ $STATUS$ R $COMPLIANCE$ - Not Clipper Compatible + Not Clipper compatible $PLATFORMS$ - Windows, Linux, MacOS, OS2 + Windows, Linux, Mac OS X, OS/2 $VERSION$ 4.5 or upper $FILES$ - Prg source : contrib/hbqt/qtgui/THBQPlainTextEdit.prg - C++ wrappers : contrib/hbqt/qtgui/HBQPlainTextEdit.cpp - Library : hbqtgui + Harbour source: contrib/hbqt/qtgui/THBQPlainTextEdit.prg + C++ wrappers : contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + Library : hbqtgui $SEEALSO$ QPlainTextEdit $END$ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 17bc7bed31..1bc71c8137 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -121,6 +121,7 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent highlight = QRect( -1, -1, -1, -1 ); isSelectionPersistent = false; isShiftPressed = false; + isAliasCompleter = false; #if 0 QTextFrameFormat format( this->document()->rootFrame()->frameFormat() ); @@ -1363,82 +1364,72 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) } } - if( hbKeyPressSelection( event ) ) { + if( hbKeyPressSelection( event ) ){ return; } QPlainTextEdit::keyPressEvent( event ); -#if 0 - QString alias = hbTextAlias(); - if( ! alias.isEmpty() ) - { - if( block ){ - PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 ); - PHB_ITEM p2 = hb_itemPutCPtr( NULL, alias.toLatin1().data() ); - hb_vmEvalBlockV( block, 2, p1, p2 ); - hb_itemRelease( p1 ); - hb_itemRelease( p2 ); - } - cFlds->setCompletionPrefix( ( QString ) 'L' ); - cFlds->popup()->setCurrentIndex( cFlds->completionModel()->index( 0, 0 ) ); - QRect cr = cursorRect(); - cFlds->popup()->setMaximumWidth( viewport()->width() ); - - cr.setWidth( cFlds->popup()->sizeHintForColumn( 0 ) + cFlds->popup()->verticalScrollBar()->sizeHint().width() ); - cr.setTop( cr.top() + horzRulerHeight + 5 ); - cr.setBottom( cr.bottom() + horzRulerHeight + 5 ); -HB_TRACE( HB_TR_ALWAYS, ( "1004" ) ); - cFlds->complete( cr ); // popup it up! -HB_TRACE( HB_TR_ALWAYS, ( "1005" ) ); + if( ! c ){ + return; } - else -#endif + if( isTipActive ){ + c->popup()->hide(); + return; + } + + if( ! isAliasCompleter ){ + QString alias = hbTextAlias(); + if( ! alias.isEmpty() ){ + if( block ){ + PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 ); + PHB_ITEM p2 = hb_itemPutC( NULL, alias.toLatin1().data() ); + hb_vmEvalBlockV( block, 2, p1, p2 ); + hb_itemRelease( p1 ); + hb_itemRelease( p2 ); + } + } + } + + if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ){ + c->popup()->hide(); + return; + } + const bool ctrlOrShift = event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ); + if( ctrlOrShift && event->text().isEmpty() ){ + return; + } + static QString eow( " ~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */ + bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift; + QString completionPrefix = hbTextUnderCursor( true ); + + if( hasModifier || + event->text().isEmpty() || + completionPrefix.length() < ( isAliasCompleter ? 0 : 1 ) || + eow.contains( event->text().right( 1 ) ) ) { - if( ! c ) { - return; + c->popup()->hide(); + return; + } + + if( completionPrefix != c->completionPrefix() ) { + c->setCompletionPrefix( completionPrefix ); + c->popup()->setCurrentIndex( c->completionModel()->index( 0, 0 ) ); + } + QRect cr = cursorRect(); + + c->popup()->setMaximumWidth( viewport()->width() ); + cr.setWidth( c->popup()->sizeHintForColumn( 0 ) + c->popup()->verticalScrollBar()->sizeHint().width() ); + cr.setTop( cr.top() + horzRulerHeight + 5 ); + cr.setBottom( cr.bottom() + horzRulerHeight + 5 ); + + c->complete( cr ); // pop it up! + if( c->popup()->isHidden() && isAliasCompleter ){ + if( block ){ + PHB_ITEM p1 = hb_itemPutNI( NULL, 21042 ); + hb_vmEvalBlockV( block, 1, p1 ); + hb_itemRelease( p1 ); + isAliasCompleter = false; } - - if( isTipActive ) { - c->popup()->hide(); - return; - } - - if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ) { - c->popup()->hide(); - return; - } - - const bool ctrlOrShift = event->modifiers() & ( Qt::ControlModifier | Qt::ShiftModifier ); - if( ( ctrlOrShift && event->text().isEmpty() ) ) { - return; - } - - static QString eow( " ~!@#$%^&*()+{}|:\"<>?,./;'[]\\-=" ); /* end of word */ - bool hasModifier = ( event->modifiers() != Qt::NoModifier ) && !ctrlOrShift; - QString completionPrefix = hbTextUnderCursor( true ); - - if( ( hasModifier || - event->text().isEmpty() || - completionPrefix.length() < 1 || - eow.contains( event->text().right( 1 ) ) ) ) - { - c->popup()->hide(); - return; - } - - if( completionPrefix != c->completionPrefix() ) { - c->setCompletionPrefix( completionPrefix ); - c->popup()->setCurrentIndex( c->completionModel()->index( 0, 0 ) ); - } - QRect cr = cursorRect(); - - c->popup()->setMaximumWidth( viewport()->width() ); - - cr.setWidth( c->popup()->sizeHintForColumn( 0 ) + c->popup()->verticalScrollBar()->sizeHint().width() ); - cr.setTop( cr.top() + horzRulerHeight + 5 ); - cr.setBottom( cr.bottom() + horzRulerHeight + 5 ); - - c->complete( cr ); // popup it up! } } diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 5806543cab..88c71a7c00 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -160,6 +160,7 @@ private: QRect highlight; bool isSelectionPersistent; bool isShiftPressed; + bool isAliasCompleter; protected: bool event( QEvent * event ); @@ -217,6 +218,7 @@ public slots: void hbHorzRulerVisible( bool visible ) { hbUpdateHorzRulerHeight( visible ? 20 : 0 ); }; void hbSetProtoStyle( const QString & css = "" ); void hbSelectAll(); + void hbSetFieldsListActive( bool active ) { isAliasCompleter = active; }; private slots: void hbSlotCursorPositionChanged(); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 55bf07b728..27454d68fb 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -904,6 +904,20 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSELECTALL ) } } +/* + * void hbSetFieldsListActive( bool active ) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETFIELDSLISTACTIVE ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbSetFieldsListActive( hb_parl( 2 ) ); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSETFIELDSLISTACTIVE FP=( p )->hbSetFieldsListActive( hb_parl( 2 ) ); 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 3b63824d08..24c1feb8e9 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -120,6 +120,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbHorzRulerVisible( lVisible ) METHOD hbSetProtoStyle( cCss ) METHOD hbSelectAll() + METHOD hbSetFieldsListActive( lActive ) ENDCLASS @@ -344,3 +345,7 @@ METHOD HBQPlainTextEdit:hbSetProtoStyle( cCss ) METHOD HBQPlainTextEdit:hbSelectAll() RETURN Qt_HBQPlainTextEdit_hbSelectAll( ::pPtr ) + +METHOD HBQPlainTextEdit:hbSetFieldsListActive( lActive ) + RETURN Qt_HBQPlainTextEdit_hbSetFieldsListActive( ::pPtr, lActive ) + diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index 55400b7dee..e60347060c 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -151,7 +151,8 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbHorzRulerVisible( bool visible ) void hbSetProtoStyle( const QString & css ) void hbSelectAll() - + void hbSetFieldsListActive( bool active ) +