From 9fd84b2d617212878d4901f45d2f873550f5cc7a Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sat, 10 Jul 2010 01:38:23 +0000 Subject: [PATCH] 2010-07-09 18:35 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 * contrib/hbide/hbide.prg * contrib/hbide/ideedit.prg * contrib/hbide/ideeditor.prg * contrib/hbide/idefunctions.prg * contrib/hbide/ideharbourhelp.prg + Implemented: completely reworked code completion basics and brand new function prototype display as tooltip ( now entirely native widget with many extras ). --- harbour/ChangeLog | 16 ++++ harbour/contrib/hbide/hbide.prg | 5 +- harbour/contrib/hbide/ideedit.prg | 86 ++++++++++++------- harbour/contrib/hbide/ideeditor.prg | 66 +++++++++----- harbour/contrib/hbide/idefunctions.prg | 46 ++++------ harbour/contrib/hbide/ideharbourhelp.prg | 4 +- .../hbqt/doc/en/class_hbqplaintextedit.txt | 1 + .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 68 ++++++++++++--- harbour/contrib/hbqt/hbqt_hbqplaintextedit.h | 6 ++ .../contrib/hbqt/qtgui/HBQPlainTextEdit.cpp | 14 +++ .../contrib/hbqt/qtgui/THBQPlainTextEdit.prg | 5 ++ harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth | 1 + 12 files changed, 223 insertions(+), 95 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e3b79f1d9a..637dd89a71 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,22 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-09 18:35 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 + * contrib/hbide/hbide.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + * contrib/hbide/idefunctions.prg + * contrib/hbide/ideharbourhelp.prg + + Implemented: completely reworked code completion basics + and brand new function prototype display as tooltip + ( now entirely native widget with many extras ). + 2010-07-09 22:57 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/make.hbs * contrib/hbpre.hbm diff --git a/harbour/contrib/hbide/hbide.prg b/harbour/contrib/hbide/hbide.prg index e6251ad750..1d0c1e8ed0 100644 --- a/harbour/contrib/hbide/hbide.prg +++ b/harbour/contrib/hbide/hbide.prg @@ -538,8 +538,6 @@ METHOD HbIde:create( aParams ) ::qTabWidget:setCurrentIndex( ::qTabWidget:count() - 1 ) ::qTabWidget:setCurrentIndex( val( ::oINI:cRecentTabIndex ) ) - ::oEM:updateCompleter() - ::showApplicationCursor() qSplash:close() @@ -552,6 +550,9 @@ METHOD HbIde:create( aParams ) /* Initialize plugins */ hbide_loadPlugins( Self, "1.0" ) + /* Fill auto completion lists - it must be the last action and be present here always */ + ::oEM:updateCompleter() + DO WHILE .t. ::nEvent := AppEvent( @::mp1, @::mp2, @::oXbp ) diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 2f9e0a72ed..2f95dfc7d6 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -115,6 +115,7 @@ CLASS IdeEdit INHERIT IdeObject DATA cCurLineText INIT "" DATA cProto INIT "" + DATA cProtoOrg INIT "" DATA qTimer DATA nProtoLine INIT -1 DATA nProtoCol INIT -1 @@ -419,7 +420,7 @@ METHOD IdeEdit:connectEditSignals( oEdit ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) - LOCAL pAct, qAct, n, qEdit, oo, nLine, qCursor + LOCAL pAct, qAct, n, qEdit, oo, qCursor HB_SYMBOL_UNUSED( p1 ) @@ -505,10 +506,20 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) ::markCurrentFunction() + #if 0 + IF ::nProtoLine != -1 + IF ::getLineNo() == ::nProtoLine .AND. ::getColumnNo() >= ::nProtoCol + 1 + ::cProto := hbide_formatProto_1( ::cProtoOrg ) + ::showProtoType() + ENDIF + ENDIF + #endif + + #if 0 IF ::nProtoLine != -1 nLine := ::getLineNo() IF ! ::isSuspended - IF nLine != ::nProtoLine .OR. ::getColumnNo() <= ::nProtoCol + IF nLine != ::nProtoLine .OR. ::getColumnNo() < ::nProtoCol ::suspendPrototype() ENDIF ELSE @@ -517,7 +528,7 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) ENDIF ENDIF ENDIF - + #endif EXIT CASE copyAvailable @@ -554,21 +565,6 @@ METHOD IdeEdit:execEvent( nMode, oEdit, p, p1 ) /*----------------------------------------------------------------------*/ -METHOD IdeEdit:dispStatusInfo() - LOCAL nMode - - ::qEdit:hbGetSelectionInfo() - nMode := ::aSelectionInfo[ 5 ] - - ::oAC:getAction( "TB_SelectionMode" ):setIcon( hbide_image( iif( nMode == 3, "selectionline", "stream" ) ) ) - ::oAC:getAction( "TB_SelectionMode" ):setChecked( nMode > 1 ) - - ::oDK:setStatusText( SB_PNL_STREAM, iif( nMode == 2, "Column", iif( nMode == 3, "Line", "Stream" ) ) ) - - RETURN Self - -/*----------------------------------------------------------------------*/ - METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) LOCAL key, kbm, qEvent, lAlt, lCtrl, lShift @@ -592,6 +588,13 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) ENDIF SWITCH ( key ) + CASE Qt_Key_Backspace + IF ! lCtrl .AND. ! lAlt + IF ::getLineNo() == ::nProtoLine .AND. ::getColumnNo() <= ::nProtoCol + 1 + ::hidePrototype() + ENDIF + ENDIF + EXIT CASE Qt_Key_Space IF !lAlt .AND. !lShift .AND. !lCtrl ::lUpdatePrevWord := .t. @@ -618,7 +621,6 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) CASE QEvent_Enter CASE QEvent_FocusIn - ::resumePrototype() IF key == QEvent_FocusIn ::oUpDn:show() ENDIF @@ -630,7 +632,6 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) CASE QEvent_Leave CASE QEvent_FocusOut - ::suspendPrototype() EXIT CASE QEvent_Wheel @@ -654,6 +655,9 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) ELSEIF p == 21001 ::handlePreviousWord( .t. ) + ELSEIF p == 21002 + ::loadFuncHelp() + ELSEIF p == 21011 ::copyBlockContents( p1 ) @@ -678,6 +682,21 @@ METHOD IdeEdit:execKeyEvent( nMode, nEvent, p, p1 ) /*----------------------------------------------------------------------*/ +METHOD IdeEdit:dispStatusInfo() + LOCAL nMode + + ::qEdit:hbGetSelectionInfo() + nMode := ::aSelectionInfo[ 5 ] + + ::oAC:getAction( "TB_SelectionMode" ):setIcon( hbide_image( iif( nMode == 3, "selectionline", "stream" ) ) ) + ::oAC:getAction( "TB_SelectionMode" ):setChecked( nMode > 1 ) + + ::oDK:setStatusText( SB_PNL_STREAM, iif( nMode == 2, "Column", iif( nMode == 3, "Line", "Stream" ) ) ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + STATIC FUNCTION hbide_blockContents( aContents ) LOCAL oldContents STATIC contents := {} @@ -2132,13 +2151,17 @@ METHOD IdeEdit:loadFuncHelp() cWord := hbide_getPreviousWord( cText, nCol ) IF !empty( cWord ) - IF ! empty( ::oHL ) - ::oHL:jumpToFunction( cWord ) - ENDIF - IF !empty( cPro := ::oFN:positionToFunction( cWord, .t. ) ) - IF empty( ::cProto ) - ::showPrototype( ::cProto := hbide_formatProto( cPro ) ) + IF empty( cPro := ::oEM:getProto( cWord ) ) + IF ! empty( ::oHL ) + ::oHL:jumpToFunction( cWord ) ENDIF + IF !empty( cPro := ::oFN:positionToFunction( cWord, .t. ) ) + IF empty( ::cProto ) + ::showPrototype( ::cProto := cPro ) + ENDIF + ENDIF + ELSE + ::showPrototype( ::cProto := cPro ) ENDIF ENDIF RETURN Self @@ -2173,10 +2196,10 @@ METHOD IdeEdit:showPrototype( cProto ) IF ! ::isSuspended .AND. !empty( ::qEdit ) IF !empty( cProto ) - ::cProto := cProto + ::cProtoOrg := cProto + ::cProto := hbide_formatProto( cProto ) ::nProtoLine := ::getLineNo() ::nProtoCol := ::getColumnNo() - ::qTimer:start() ENDIF ::qEdit:hbShowPrototype( ::cProto ) ENDIF @@ -2190,7 +2213,6 @@ METHOD IdeEdit:hidePrototype() ::nProtoLine := -1 ::nProtoCol := -1 ::cProto := "" - ::qTimer:stop() ::qEdit:hbShowPrototype( "" ) ENDIF RETURN Self @@ -2208,7 +2230,7 @@ METHOD IdeEdit:parseCodeCompletion( cSyntax ) ENDIF ELSE IF ( n := at( "(", cSyntax ) ) > 0 - cText := trim( substr( cSyntax, 1, n ) ) + cText := trim( substr( cSyntax, 1, n - 1 ) ) ELSE cText := trim( cSyntax ) ENDIF @@ -2417,10 +2439,14 @@ FUNCTION hbide_isHarbourKeyword( cWord, oIde ) FUNCTION hbide_formatProto( cProto ) LOCAL n, n1, cArgs + cProto := StrTran( cProto, "<", "<" ) + cProto := StrTran( cProto, ">", ">" ) + n := at( "(", cProto ) n1 := at( ")", cProto ) IF n > 0 .AND. n1 > 0 + cArgs := substr( cProto, n + 1, n1 - n - 1 ) cArgs := strtran( cArgs, ",", "" + "," + "" ) cProto := "

" + "" + substr( cProto, 1, n - 1 ) + "" + ; diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index d0fbfb4644..d996070ef6 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -82,6 +82,7 @@ CLASS IdeEditsManager INHERIT IdeObject DATA qContextMenu DATA qContextSub DATA aActions INIT {} + DATA aProtos INIT {} METHOD new( oIde ) METHOD create( oIde ) @@ -169,6 +170,7 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD qscintilla() METHOD setStyleSheet( nMode ) METHOD updateCompleter() + METHOD getProto( cWord ) ENDCLASS @@ -236,45 +238,50 @@ METHOD IdeEditsManager:create( oIde ) /*----------------------------------------------------------------------*/ METHOD IdeEditsManager:updateCompleter() - LOCAL aFun := ::oFN:getFunctionPrototypes() - LOCAL aHrb := ::oHL:getFunctionPrototypes() - LOCAL n, s, a_, k_:={} + LOCAL aFun, aHrb, n, s, k_ + + /* Collection of prototypes can be extended to honor plugins and defined in "setup" */ + + aFun := ::oFN:getFunctionPrototypes() + aHrb := ::oHL:getFunctionPrototypes() ::disconnect( ::qCompleter, "activated(QString)", {|p| ::execEvent( "qcompleter_activated", p ) } ) - FOR EACH a_ IN { aFun, aHrb } - FOR EACH s IN a_ - s := trim( s ) - IF ::oINI:lCompletionWithArgs - IF ascan( k_, s ) == 0 + ::aProtos := {} + aeval( aHrb, {|e| aadd( ::aProtos, e ) } ) + aeval( aFun, {|e| aadd( ::aProtos, e ) } ) + + k_:= {} + FOR EACH s IN ::aProtos + s := alltrim( s ) + IF ::oINI:lCompletionWithArgs + IF ascan( k_, s ) == 0 + aadd( k_, s ) + ENDIF + ELSE + IF ( n := at( "(", s ) ) == 0 + IF ( n := at( " ", s ) ) > 0 + aadd( k_, substr( s, 1, n - 1 ) ) + ELSE aadd( k_, s ) ENDIF ELSE - IF ( n := at( "(", s ) ) == 0 - IF ( n := at( " ", s ) ) > 0 - aadd( k_, substr( s, 1, n - 1 ) ) - ELSE - aadd( k_, trim( s ) ) - ENDIF - ELSE - aadd( k_, substr( s, 1, n - 1 ) ) - ENDIF + aadd( k_, trim( substr( s, 1, n - 1 ) ) ) ENDIF - NEXT + ENDIF NEXT - asort( k_, , , {|e,f| lower( e ) < lower( f ) } ) ::qProtoList:clear() aeval( k_, {|e| ::qProtoList:append( e ) } ) + ::qCompleter:setWrapAround( .t. ) + ::qCompleter:setCaseSensitivity( Qt_CaseInsensitive ) + ::qCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel ) ::qCompModel:setStringList( ::qProtoList ) ::qCompleter:setModel( ::qCompModel ) - ::qCompleter:setModelSorting( QCompleter_CaseInsensitivelySortedModel ) - ::qCompleter:setCaseSensitivity( Qt_CaseInsensitive ) ::qCompleter:setCompletionMode( QCompleter_PopupCompletion ) - ::qCompleter:setWrapAround( .t. ) QListView():from( ::qCompleter:popup() ):setAlternatingRowColors( .t. ) @@ -284,6 +291,21 @@ METHOD IdeEditsManager:updateCompleter() /*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:getProto( cWord ) + LOCAL n, nLen + + cWord := upper( cWord ) + nLen := len( cWord ) + + /* This can be rationalized */ + IF ( n := ascan( ::aProtos, {|e| upper( left( e, nLen ) ) == cWord } ) ) > 0 + RETURN ::aProtos[ n ] + ENDIF + + RETURN "" + +/*----------------------------------------------------------------------*/ + METHOD IdeEditsManager:destroy() LOCAL a_ diff --git a/harbour/contrib/hbide/idefunctions.prg b/harbour/contrib/hbide/idefunctions.prg index 08496df6d9..fa1d0b4ad9 100644 --- a/harbour/contrib/hbide/idefunctions.prg +++ b/harbour/contrib/hbide/idefunctions.prg @@ -82,17 +82,6 @@ /*----------------------------------------------------------------------*/ -#define editFunc_returnPressed 101 -#define editFunc_textChanged 102 -#define tableFuncList_itemSelectionChanged 103 -#define tableFuncList_itemDoubleClicked 104 -#define buttonMark_clicked 105 -#define buttonLoad_clicked 106 -#define buttonTag_clicked 107 -#define buttonClose_clicked 108 - -/*----------------------------------------------------------------------*/ - CLASS IdeFunctions INHERIT IdeObject DATA isNotSetYet INIT .t. @@ -146,16 +135,16 @@ METHOD IdeFunctions:create( oIde ) ::buildHeader() - ::oUI:signal( "editFunction" , "textChanged(QString)" , {|p| ::execEvent( editFunc_textChanged, p ) } ) - ::oUI:signal( "editFunction" , "returnPressed()" , {| | ::execEvent( editFunc_returnPressed ) } ) + ::oUI:signal( "editFunction" , "textChanged(QString)" , {|p| ::execEvent( "editFunc_textChanged", p ) } ) + ::oUI:signal( "editFunction" , "returnPressed()" , {| | ::execEvent( "editFunc_returnPressed" ) } ) // - ::oUI:signal( "buttonMark" , "clicked()" , {| | ::execEvent( buttonMark_clicked ) } ) - ::oUI:signal( "buttonLoad" , "clicked()" , {| | ::execEvent( buttonLoad_clicked ) } ) - ::oUI:signal( "buttonTag" , "clicked()" , {| | ::execEvent( buttonTag_clicked ) } ) - ::oUI:signal( "buttonClose" , "clicked()" , {| | ::execEvent( buttonClose_clicked ) } ) + ::oUI:signal( "buttonMark" , "clicked()" , {| | ::execEvent( "buttonMark_clicked" ) } ) + ::oUI:signal( "buttonLoad" , "clicked()" , {| | ::execEvent( "buttonLoad_clicked" ) } ) + ::oUI:signal( "buttonTag" , "clicked()" , {| | ::execEvent( "buttonTag_clicked" ) } ) + ::oUI:signal( "buttonClose" , "clicked()" , {| | ::execEvent( "buttonClose_clicked" ) } ) // - ::oUI:signal( "tableFuncList", "itemSelectionChanged()" , {| | ::execEvent( tableFuncList_itemSelectionChanged ) } ) - ::oUI:signal( "tableFuncList", "itemDoubleClicked(QTblWItem)", {|p| ::execEvent( tableFuncList_itemDoubleClicked, p ) } ) + ::oUI:signal( "tableFuncList", "itemSelectionChanged()" , {| | ::execEvent( "tableFuncList_itemSelectionChanged" ) } ) + ::oUI:signal( "tableFuncList", "itemDoubleClicked(QTblWItem)", {|p| ::execEvent( "tableFuncList_itemDoubleClicked", p ) } ) RETURN Self @@ -165,35 +154,36 @@ METHOD IdeFunctions:execEvent( nMode, p ) LOCAL n, nLen DO CASE - CASE nMode == editFunc_textChanged + CASE nMode == "editFunc_textChanged" p := upper( p ) nLen := len( p ) IF ( n := ascan( ::aList, {|e_| left( e_[ 1 ], nLen ) == p } ) ) > 0 ::oUI:q_tableFuncList:setCurrentItem( ::aItems[ n ] ) ENDIF - CASE nMode == editFunc_returnPressed + CASE nMode == "editFunc_returnPressed" ::openFunction( .f. ) - CASE nMode == tableFuncList_itemDoubleClicked + CASE nMode == "tableFuncList_itemDoubleClicked" ::openFunction( .f. ) - CASE nMode == buttonMark_clicked + CASE nMode == "buttonMark_clicked" ::oUI:q_listProjects:show() ::listProjects() - CASE nMode == buttonLoad_clicked + CASE nMode == "buttonLoad_clicked" ::oUI:q_listProjects:hide() ::loadTags() - CASE nMode == buttonTag_clicked + CASE nMode == "buttonTag_clicked" ::oUI:q_listProjects:hide() ::buildTags() + ::oEM:updateCompleter() - CASE nMode == buttonClose_clicked + CASE nMode == "buttonClose_clicked" ::oFunctionsDock:hide() - CASE nMode == tableFuncList_itemSelectionChanged + CASE nMode == "tableFuncList_itemSelectionChanged" n := ::oUI:q_tableFuncList:currentRow() IF n >= 0 ::oUI:q_editSyntax:setText( ::aList[ n + 1, 2 ] ) @@ -617,8 +607,6 @@ METHOD IdeFunctions:populateTable() ::oUI:q_labelEntries:setText( "Entries: " + hb_ntos( n ) ) NEXT - ::oEM:updateCompleter() - RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbide/ideharbourhelp.prg b/harbour/contrib/hbide/ideharbourhelp.prg index 8f206c2f79..fe8a111215 100644 --- a/harbour/contrib/hbide/ideharbourhelp.prg +++ b/harbour/contrib/hbide/ideharbourhelp.prg @@ -222,8 +222,6 @@ METHOD IdeHarbourHelp:show() ::populateRootInfo() ::refreshDocTree() - - ::oEM:updateCompleter() ENDIF RETURN Self @@ -499,6 +497,8 @@ METHOD IdeHarbourHelp:execEvent( nMode, p, p1 ) CASE "buttonRefresh_clicked" ::refreshDocTree() + ::aProtoTypes := {} + ::lLoadedProto := .f. ::oEM:updateCompleter() EXIT diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index 8145062a7e..5a00ad4b56 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -78,6 +78,7 @@ :hbHighlightArea( nTop, nLeft, nBottom, nRight, nMode ) -> NIL :hbTogglePersistentSelection() -> NIL :hbHorzRulerVisible( lVisible ) -> NIL + :hbSetProtoStyle( cCss ) -> NIL $DESCRIPTION$ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index bb0b1b523b..cadad25386 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -145,6 +145,17 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent setContentsMargins( 0,0,0,0 ); + ttFrame = new QFrame( this ); + ttFrame->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); + ttLayout = new QHBoxLayout( ttFrame ); + ttFrame->setLayout( ttLayout ); + ttLabel = new QLabel(); + ttLabel->setText( "" ); + hbSetProtoStyle(); + ttLayout->addWidget( ttLabel ); + ttFrame->setFocusPolicy( Qt::NoFocus ); + ttFrame->hide(); + #if 0 timer = new QTimer( this ); connect( timer, SIGNAL( timeout() ), this, SLOT( hbUpdateCaret() ) ); @@ -203,18 +214,35 @@ void HBQPlainTextEdit::hbRefresh() /*----------------------------------------------------------------------*/ +void HBQPlainTextEdit::hbSetProtoStyle( const QString & css ) +{ + if( css == ( QString ) "" ) + ttLabel->setStyleSheet( "background-color: rgb(255,255,174); border: 1px solid black; padding: 3px;" ); + else + ttLabel->setStyleSheet( css ); +} + +/*----------------------------------------------------------------------*/ + void HBQPlainTextEdit::hbShowPrototype( const QString & tip ) { + ttLabel->setText( tip ); + if( tip == ( QString ) "" ) { - QToolTip::hideText(); isTipActive = false; + ttFrame->hide(); } else { - QRect r = HBQPlainTextEdit::cursorRect(); - QToolTip::showText( mapToGlobal( QPoint( r.x(), r.y()+20 ) ), tip ); isTipActive = true; + QRect r = HBQPlainTextEdit::cursorRect(); + ttFrame->setMaximumWidth( viewport()->width() ); + int w = ttLabel->width(); + int x = r.x()-r.width(); + x = x + w > viewport()->width() ? viewport()->width() - w : x; + ttFrame->move( x, r.y() + 7 ); + ttFrame->show(); } } @@ -1255,13 +1283,6 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) { -//HB_TRACE( HB_TR_ALWAYS, ( "keyPressEvent %i 000", event->key() ) ); - if( hbKeyPressSelection( event ) ) - { -// QApplication::processEvents(); - return; - } -//HB_TRACE( HB_TR_ALWAYS, ( "keyPressEvent %i", event->key() ) ); if( c && c->popup()->isVisible() ) { // The following keys are forwarded by the completer to the widget @@ -1281,16 +1302,33 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) hb_itemRelease( p1 ); } break; + case Qt::Key_ParenLeft: + if( block ){ + PHB_ITEM p1 = hb_itemPutNI( NULL, 21002 ); + hb_vmEvalBlockV( block, 1, p1 ); + hb_itemRelease( p1 ); + } + break; default: break; } } + if( hbKeyPressSelection( event ) ) + { + return; + } QPlainTextEdit::keyPressEvent( event ); if( ! c ) return; + if( isTipActive ) + { + c->popup()->hide(); + return; + } + if( ( event->modifiers() & ( Qt::ControlModifier | Qt::AltModifier ) ) ) { c->popup()->hide(); @@ -1321,6 +1359,8 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) } 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 ); @@ -1917,6 +1957,14 @@ void HBQPlainTextEdit::hbUpdateHorzRuler( const QRect & rect, int dy ) if( dy == 0 ) horzRuler->update(); + + if( dy != 0 ) + { + if( isTipActive ) + { + ttFrame->move( ttFrame->x(), ttFrame->y() + dy ); + } + } } /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index ce11d3eda5..428777e88a 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -67,6 +67,8 @@ #include #include #include +#include +#include #include "hbqt_hbqsyntaxhighlighter.h" @@ -121,6 +123,9 @@ private: QList bookMarksGoto; QWidget * lineNumberArea; QFrame * horzRuler; + QFrame * ttFrame; + QHBoxLayout * ttLayout; + QLabel * ttLabel; int spaces; bool numberBlock; bool highlightCurLine; @@ -206,6 +211,7 @@ public slots: void hbHighlightArea( int, int, int, int, int ); void hbTogglePersistentSelection(); void hbHorzRulerVisible( bool visible ) { hbUpdateHorzRulerHeight( visible ? 20 : 0 ); }; + void hbSetProtoStyle( const QString & css = "" ); private slots: void hbSlotCursorPositionChanged(); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index c4a5a6e235..85c51e1c2b 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -860,6 +860,20 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBHORZRULERVISIBLE ) } } +/* + * void hbSetProtoStyle( const QString & css ) + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETPROTOSTYLE ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbSetProtoStyle( HBQPlainTextEdit::tr( hb_parc( 2 ) ) ); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBSETPROTOSTYLE FP=( p )->hbSetProtoStyle( HBQPlainTextEdit::tr( hb_parc( 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 be8974676f..ef07643b02 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -117,6 +117,7 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbHighlightArea( nTop, nLeft, nBottom, nRight, nMode ) METHOD hbTogglePersistentSelection() METHOD hbHorzRulerVisible( lVisible ) + METHOD hbSetProtoStyle( cCss ) ENDCLASS @@ -329,3 +330,7 @@ METHOD HBQPlainTextEdit:hbTogglePersistentSelection() METHOD HBQPlainTextEdit:hbHorzRulerVisible( lVisible ) RETURN Qt_HBQPlainTextEdit_hbHorzRulerVisible( ::pPtr, lVisible ) + +METHOD HBQPlainTextEdit:hbSetProtoStyle( cCss ) + RETURN Qt_HBQPlainTextEdit_hbSetProtoStyle( ::pPtr, cCss ) + diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index 163dee9cd8..45b69f355b 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -148,6 +148,7 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbHighlightArea( int top, int left, int bottom, int right, int mode ) void hbTogglePersistentSelection() void hbHorzRulerVisible( bool visible ) + void hbSetProtoStyle( const QString & css )