diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3b521bc94e..4fc0248591 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,28 @@ The license applies to all entries newer than 2009-04-28. */ +2010-07-29 18:47 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: methods to control code completions and completion tips. + + + contrib/hbide/resources/help1.png + + contrib/hbide/resources/infotips.png + + * contrib/hbide/hbide.qrc + + Added: two more images foe code completions and completion tips. + + * contrib/hbide/idedocks.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + + Added: controls to toggle code completions and completion tips. + The settings are not saved for the next run and are applicable + per editing instance. + 2010-07-29 15:49 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/hbide.prg ! Minor. diff --git a/harbour/contrib/hbide/hbide.qrc b/harbour/contrib/hbide/hbide.qrc index 9115d74c80..dc739c37da 100644 --- a/harbour/contrib/hbide/hbide.qrc +++ b/harbour/contrib/hbide/hbide.qrc @@ -102,12 +102,14 @@ resources/hbidesplash.png resources/hbidesplashwatermark.png resources/help.png +resources/help1.png resources/helpdoc.png resources/hilight-all.png resources/horzruler.png resources/idepreferences.png resources/increaseindent.png resources/info.png +resources/infotips.png resources/insert-datetime.png resources/insert-external-file.png resources/insert-procname.png diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 8366012e89..5e9cb53d4b 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -743,13 +743,12 @@ METHOD IdeDocks:buildToolBarPanels() aadd( aBtns, { "deleteline" , "Delete Current Line" , {|| ::oEM:deleteLine() } } ) aadd( aBtns, { "duplicateline" , "Duplicate Current Line" , {|| ::oEM:duplicateLine() } } ) aadd( aBtns, {} ) - #if 0 - aadd( aBtns, { "togglelinenumber", "Toggle Line Numbers" , {|| ::oEM:toggleLineNumbers() } } ) - aadd( aBtns, { "curlinehilight" , "Toggle Current Line Hilight", {|| ::oEM:toggleCurrentLineHighlightMode() } } ) - #endif aadd( aBtns, { "togglelinenumber", "Toggle Line Numbers" , {|| ::oEM:toggleLineNumbers() } } ) aadd( aBtns, { "horzruler" , "Toggle Horizontal Ruler" , {|| ::oEM:toggleHorzRuler() } } ) aadd( aBtns, { "curlinehilight" , "Toggle Current Line Hilight", {|| ::oEM:toggleCurrentLineHighlightMode() } } ) + aadd( aBtns, {} ) + aadd( aBtns, { "help1" , "Toggle Code Completion" , {|| ::oEM:toggleCodeCompetion() } } ) + aadd( aBtns, { "infotips" , "Toggle Completion Tips" , {|| ::oEM:toggleCompetionTips() } } ) FOR EACH a_ IN aBtns IF empty( a_ ) ::qTBarLines:addSeparator() diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index a95ea74030..c9d9bafd05 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -184,6 +184,8 @@ CLASS IdeEdit INHERIT IdeObject METHOD toggleLineSelectionMode() METHOD clearSelection() METHOD togglePersistentSelection() + METHOD toggleCodeCompetion() + METHOD toggleCompetionTips() METHOD getWord( lSelect ) METHOD getLine( nLine, lSelect ) @@ -1387,6 +1389,18 @@ METHOD IdeEdit:togglePersistentSelection() /*----------------------------------------------------------------------*/ +METHOD IdeEdit:toggleCodeCompetion() + ::qEdit:hbToggleCodeCompetion() + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEdit:toggleCompetionTips() + ::qEdit:hbToggleCompetionTips() + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEdit:redo() ::qEdit:redo() RETURN Self @@ -1529,7 +1543,7 @@ METHOD IdeEdit:find( cText, nPosFrom ) /* nFlags will decide the position, case sensitivity and direction */ METHOD IdeEdit:findEx( cText, nFlags, nStart ) - LOCAL qCursor, lFound, cT, nPos + LOCAL qCursor, lFound, nPos DEFAULT nStart TO 0 @@ -1546,12 +1560,11 @@ METHOD IdeEdit:findEx( cText, nFlags, nStart ) IF ( lFound := ::qEdit:find( cText, nFlags ) ) ::qEdit:centerCursor() - qCursor := ::getCursor() - cT := qCursor:selectedText() - //qCursor:clearSelection() - ::qEdit:hbSetSelectionInfo( { qCursor:blockNumber(), qCursor:columnNumber() - len( cT ), ; - qCursor:blockNumber(), qCursor:columnNumber(), 1 } ) - //::qEdit:setTextCursor( qCursor ) + qCursor := QTextCursor():from( ::qEdit:textCursor() ) //::getCursor() + + ::qEdit:hbSetSelectionInfo( { qCursor:blockNumber(), qCursor:columnNumber() - len( cText ), ; + qCursor:blockNumber(), qCursor:columnNumber(), 1, .t., .f. } ) + qCursor:clearSelection() ELSE qCursor:setPosition( nPos ) ::qEdit:setTextCursor( qCursor ) diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index f67bd70375..1fdc0a5d2e 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -145,6 +145,8 @@ CLASS IdeEditsManager INHERIT IdeObject METHOD toggleLineNumbers() METHOD toggleHorzRuler() METHOD toggleCurrentLineHighlightMode() + METHOD toggleCodeCompetion() + METHOD toggleCompetionTips() METHOD getText() METHOD getWord( lSelect ) @@ -747,6 +749,26 @@ METHOD IdeEditsManager:toggleHorzRuler() /*----------------------------------------------------------------------*/ +METHOD IdeEditsManager:toggleCodeCompetion() + LOCAL oEdit + ::oIde:lHorzRulerVisible := ! ::lHorzRulerVisible + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:toggleCodeCompetion() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD IdeEditsManager:toggleCompetionTips() + LOCAL oEdit + ::oIde:lHorzRulerVisible := ! ::lHorzRulerVisible + IF !empty( oEdit := ::getEditObjectCurrent() ) + oEdit:toggleCompetionTips() + ENDIF + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD IdeEditsManager:duplicateLine() LOCAL oEdit IF !empty( oEdit := ::getEditObjectCurrent() ) diff --git a/harbour/contrib/hbide/resources/help1.png b/harbour/contrib/hbide/resources/help1.png new file mode 100644 index 0000000000..0b334e64b4 Binary files /dev/null and b/harbour/contrib/hbide/resources/help1.png differ diff --git a/harbour/contrib/hbide/resources/infotips.png b/harbour/contrib/hbide/resources/infotips.png new file mode 100644 index 0000000000..d80abf6138 Binary files /dev/null and b/harbour/contrib/hbide/resources/infotips.png differ diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index d1161b9525..be6d4a69dc 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -82,6 +82,8 @@ :hbSetProtoStyle( cCss ) -> NIL :hbSelectAll() -> NIL :hbSetFieldsListActive( lActive ) -> NIL + :hbToggleCodeCompetion() -> NIL + :hbToggleCompetionTips() -> NIL $DESCRIPTION$ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 3668e60ee3..dce4a8a26e 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -122,6 +122,8 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent isSelectionPersistent = false; isShiftPressed = false; isAliasCompleter = false; + isCodeCompletionActive = true; + isCompletionTipsActive = true; #if 0 QTextFrameFormat format( this->document()->rootFrame()->frameFormat() ); @@ -178,6 +180,12 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent void HBQPlainTextEdit::hbShowPrototype( const QString & tip, int rows, int cols ) { + if( ! isCompletionTipsActive ){ + ttTextEdit->hide(); + ttLabel->hide(); + return; + } + if( rows <= 1 ) { ttLabel->setText( tip ); @@ -464,9 +472,23 @@ void HBQPlainTextEdit::hbSetSelectionInfo( PHB_ITEM selectionInfo ) columnEnds = hb_arrayGetNI( selectionInfo, 4 ); selectionMode = hb_arrayGetNI( selectionInfo, 5 ); - emit selectionChanged(); - - update(); + PHB_ITEM pSome = hb_arrayGetItemPtr( selectionInfo, 6 ); + if( hb_itemType( pSome ) & HB_IT_LOGICAL ){ + if( hb_itemGetL( pSome ) ){ + QTextCursor c( textCursor() ); + c.clearSelection(); + } + } + pSome = hb_arrayGetItemPtr( selectionInfo, 7 ); + if( hb_itemType( pSome ) & HB_IT_LOGICAL ){ + if( hb_itemGetL( pSome ) ){ + emit selectionChanged(); + } + } + else { + emit selectionChanged(); + } + repaint(); } /*----------------------------------------------------------------------*/ @@ -771,6 +793,8 @@ void HBQPlainTextEdit::mouseDoubleClickEvent( QMouseEvent *event ) columnEnds = c.columnNumber(); columnBegins = columnEnds - ( c.selectionEnd() - c.selectionStart() ); selectionMode = selectionMode_stream; + c.clearSelection(); + setTextCursor( c ); emit selectionChanged(); repaint(); } @@ -1371,6 +1395,13 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) } QPlainTextEdit::keyPressEvent( event ); + if( ! isCodeCompletionActive ){ + if( c ){ + c->popup()->hide(); + } + return; + } + if( ! c ){ return; } @@ -1402,10 +1433,6 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) eow.contains( event->text().right( 1 ) ) ) { c->popup()->hide(); - #if 0 - if( isAliasCompleter ) - hbRefreshCompleter( "" ); - #endif return; } @@ -1421,15 +1448,6 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) cr.setBottom( cr.bottom() + horzRulerHeight + 5 ); c->complete( cr ); // pop it up! - if( c->popup()->isHidden() && isAliasCompleter ){ - #if 0 - if( block ){ - PHB_ITEM p1 = hb_itemPutNI( NULL, 21041 ); - hb_vmEvalBlockV( block, 1, p1 ); - hb_itemRelease( p1 ); - } - #endif - } } /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index a10403849b..62f516ae00 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -161,6 +161,8 @@ private: bool isSelectionPersistent; bool isShiftPressed; bool isAliasCompleter; + bool isCodeCompletionActive; + bool isCompletionTipsActive; protected: bool event( QEvent * event ); @@ -220,6 +222,8 @@ public slots: void hbSelectAll(); void hbSetFieldsListActive( bool active ) { isAliasCompleter = active; }; void hbRefreshCompleter( const QString & alias = "" ); + void hbToggleCodeCompetion() { isCodeCompletionActive = ! isCodeCompletionActive; }; + void hbToggleCompetionTips() { isCompletionTipsActive = ! isCompletionTipsActive; }; private slots: void hbSlotCursorPositionChanged(); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 27454d68fb..6965d422f4 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -918,6 +918,34 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBSETFIELDSLISTACTIVE ) } } +/* + * void hbToggleCodeCompetion() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBTOGGLECODECOMPETION ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbToggleCodeCompetion(); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBTOGGLECODECOMPETION FP=( p )->hbToggleCodeCompetion(); p is NULL" ) ); + } +} + +/* + * void hbToggleCompetionTips() + */ +HB_FUNC( QT_HBQPLAINTEXTEDIT_HBTOGGLECOMPETIONTIPS ) +{ + HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); + if( p ) + ( p )->hbToggleCompetionTips(); + else + { + HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBTOGGLECOMPETIONTIPS FP=( p )->hbToggleCompetionTips(); 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 24c1feb8e9..2bd684ddc4 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -121,6 +121,8 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbSetProtoStyle( cCss ) METHOD hbSelectAll() METHOD hbSetFieldsListActive( lActive ) + METHOD hbToggleCodeCompetion() + METHOD hbToggleCompetionTips() ENDCLASS @@ -349,3 +351,11 @@ METHOD HBQPlainTextEdit:hbSelectAll() METHOD HBQPlainTextEdit:hbSetFieldsListActive( lActive ) RETURN Qt_HBQPlainTextEdit_hbSetFieldsListActive( ::pPtr, lActive ) + +METHOD HBQPlainTextEdit:hbToggleCodeCompetion() + RETURN Qt_HBQPlainTextEdit_hbToggleCodeCompetion( ::pPtr ) + + +METHOD HBQPlainTextEdit:hbToggleCompetionTips() + RETURN Qt_HBQPlainTextEdit_hbToggleCompetionTips( ::pPtr ) + diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index e60347060c..056196a0dc 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -152,6 +152,8 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbSetProtoStyle( const QString & css ) void hbSelectAll() void hbSetFieldsListActive( bool active ) + void hbToggleCodeCompetion() + void hbToggleCompetionTips()