diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 0eb98d953d..bc9fee5526 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,24 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-15-15 12:03 UTC-0800 Pritpal Bedi (pritpal@vouchcac.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/idedocks.prg + * contrib/hbide/ideedit.prg + * contrib/hbide/ideeditor.prg + ! Fixed: the artifacts reported by Mindaugas and Itamar. + ! Optimized: C++ code. + ! Fixed: many other artifacts, i.e., status-bar panel was wrongly + reporting selection mode. + + Mindaugas, can you please test again ? + 2010-05-15 20:02 UTC+0200 José Luis Capel (jlcapel at hotmail . com) + contrib/hbwin/win_srv.c + contrib/hbwin/tests/testsrv.prg diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 5b1c1c2778..7d7db96d9d 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -451,7 +451,7 @@ METHOD IdeDocks:buildViewWidget( cObjectName ) oFrame:oTabWidget:oWidget:setCornerWidget( qTBtnClose, Qt_TopRightCorner ) ENDIF - oFrame:oTabWidget:oWidget:setUsesScrollButtons( .f. ) + oFrame:oTabWidget:oWidget:setUsesScrollButtons( .t. ) oFrame:oTabWidget:oWidget:setMovable( .t. ) aadd( ::oIde:aViews, oFrame ) diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 32495edb8a..5d768e3f2d 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -765,7 +765,7 @@ METHOD IdeEdit:copyBlockContents( aCord ) IF nMode == selectionMode_stream IF i == nT .AND. i == nB - cLine := substr( cLine, aCord[ 4 ] + 1, nW ) + cLine := substr( cLine, aCord[ 2 ] + 1, nW ) ELSEIF i == nT cLine := substr( cLine, aCord[ 2 ] + 1 ) ELSEIF i == nB @@ -784,6 +784,8 @@ METHOD IdeEdit:copyBlockContents( aCord ) cClip += cLine + iif( i < nB, hb_osNewLine(), "" ) NEXT + * HB_TRACE( HB_TR_ALWAYS, "copyBlockContents", cClip ) + hbide_blockContents( { nMode, ::aBlockCopyContents } ) qClip := QClipboard():new() @@ -1233,7 +1235,8 @@ METHOD IdeEdit:toggleLineNumbers() METHOD IdeEdit:toggleSelectionMode() ::isColumnSelectionON := ! ::isColumnSelectionON - ::qEdit:hbHighlightSelectedColumns( ::isColumnSelectionON ) + //::qEdit:hbHighlightSelectedColumns( ::isColumnSelectionON ) + ::qEdit:hbSetSelectionMode( iif( ::isColumnSelectionON, 2, 1 ), .t. ) ::dispStatusInfo() RETURN Self diff --git a/harbour/contrib/hbide/ideeditor.prg b/harbour/contrib/hbide/ideeditor.prg index 43b2615933..803c13259f 100644 --- a/harbour/contrib/hbide/ideeditor.prg +++ b/harbour/contrib/hbide/ideeditor.prg @@ -1374,8 +1374,6 @@ METHOD IdeEditor:dispEditInfo( qEdit ) ::oIde:oSBar:getItem( SB_PNL_COLUMN ):caption := "Col " + hb_ntos( qCursor:columnNumber() + 1 ) ::oIde:oSBar:getItem( SB_PNL_INS ):caption := iif( qEdit:overwriteMode() , " ", "Ins" ) ::oIde:oSBar:getItem( SB_PNL_MODIFIED ):caption := iif( qDocument:isModified(), "Modified", iif( qEdit:isReadOnly(), "ReadOnly", " " ) ) - - ::oIde:oSBar:getItem( SB_PNL_STREAM ):caption := "Stream" ::oIde:oSBar:getItem( SB_PNL_EDIT ):caption := "Edit" RETURN Self diff --git a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt index 277bb4ccf6..3091dac9f7 100644 --- a/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt +++ b/harbour/contrib/hbqt/doc/en/class_hbqplaintextedit.txt @@ -58,7 +58,6 @@ :hbBlockIndent( nSteps ) -> NIL :hbDeleteLine() -> NIL :hbMoveLine( nIDirection ) -> NIL - :hbHighlightSelectedColumns( lYes ) -> NIL :hbGetSelectedText() -> cQString :hbTextUnderCursor() -> cQString :hbShowPrototype( cTip ) -> NIL diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 694758652f..beb6ad7323 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -107,7 +107,7 @@ HBQPlainTextEdit::HBQPlainTextEdit( QWidget * parent ) : QPlainTextEdit( parent rowBegins = -1; rowEnds = -1; selectionState = selectionState_off; - selectionMode = selectionMode_none; + selectionMode = selectionMode_stream; selectionDisplay = selectionDisplay_none; isColumnSelectionEnabled = false; isLineSelectionON = false; @@ -331,13 +331,6 @@ void HBQPlainTextEdit::hbGetSelectionInfo() /*----------------------------------------------------------------------*/ -void HBQPlainTextEdit::hbHighlightSelectedColumns( bool yes ) -{ - hbSetSelectionMode( ( yes ? selectionMode_column : selectionMode_stream ), true ); -} - -/*----------------------------------------------------------------------*/ - void HBQPlainTextEdit::hbSetSelectionMode( int mode, bool on ) { switch( mode ) @@ -362,33 +355,32 @@ void HBQPlainTextEdit::hbSetSelectionMode( int mode, bool on ) } case selectionMode_line: { + selectionMode = selectionMode_line; isColumnSelectionEnabled = false; if( on ) { isLineSelectionON = true; hbClearColumnSelection(); QTextCursor c( textCursor() ); - rowBegins = c.blockNumber(); - rowEnds = c.blockNumber(); - columnBegins = 0; - columnEnds = 0; - selectionMode = selectionMode_line; + rowBegins = c.blockNumber(); + rowEnds = rowBegins; + columnBegins = 0; + columnEnds = 0; } else { isLineSelectionON = false; - selectionMode = selectionMode_stream; } - break; } + #if 0 default: { selectionMode = selectionMode_none; hbClearColumnSelection(); } + #endif } - update(); } @@ -518,13 +510,26 @@ void HBQPlainTextEdit::hbPaste() void HBQPlainTextEdit::mouseDoubleClickEvent( QMouseEvent *event ) { + QPlainTextEdit::mouseDoubleClickEvent( event ); + + QTextCursor c( textCursor() ); + if( c.hasSelection() ) + { + rowBegins = c.blockNumber(); + rowEnds = rowBegins; + columnEnds = c.columnNumber(); + columnBegins = columnEnds - ( c.selectionEnd() - c.selectionStart() ); + selectionMode = selectionMode_stream; + emit selectionChanged(); + repaint(); + } + if( block ) { PHB_ITEM p1 = hb_itemPutNI( NULL, QEvent::MouseButtonDblClick ); hb_vmEvalBlockV( block, 1, p1 ); hb_itemRelease( p1 ); } - QPlainTextEdit::mouseDoubleClickEvent( event ); } /*----------------------------------------------------------------------*/ @@ -543,15 +548,19 @@ void HBQPlainTextEdit::mouseReleaseEvent( QMouseEvent *event ) selectionState = 1; setCursorWidth( 1 ); QPlainTextEdit::mouseReleaseEvent( event ); + if( isLineSelectionON ) + { + QTextCursor c( textCursor() ); + rowEnds = c.blockNumber(); + repaint(); + } } /*----------------------------------------------------------------------*/ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) { - if( isColumnSelectionEnabled ) - selectionMode = selectionMode_column; - else + if( selectionMode == selectionMode_line ) selectionMode = selectionMode_stream; if( event->buttons() & Qt::LeftButton ) @@ -564,7 +573,7 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) if( columnBegins == -1 ) { - if( isColumnSelectionEnabled ) + if( selectionMode == selectionMode_column ) setCursorWidth( 0 ); QTextCursor c( textCursor() ); @@ -578,7 +587,7 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) } else { - if( isColumnSelectionEnabled ) + if( selectionMode == selectionMode_column ) { QTextCursor c( cursorForPosition( QPoint( 1,1 ) ) ); rowEnds = c.blockNumber() + ( event->y() / fontMetrics().height() ); @@ -587,7 +596,7 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) QPlainTextEdit::mouseMoveEvent( event ); QTextCursor c = textCursor(); - if( ! isColumnSelectionEnabled ) + if( selectionMode != selectionMode_column ) { rowEnds = c.blockNumber(); columnEnds = c.columnNumber(); @@ -618,15 +627,6 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) return true; } - if( isColumnSelectionEnabled ) - { - selectionMode = selectionMode_column; - } - else if( selectionMode != selectionMode_line ) - { - selectionMode = selectionMode_stream; - } - bool bClear = false; if( selectionMode == selectionMode_column || selectionMode == selectionMode_stream ) @@ -654,6 +654,7 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) columnBegins = col; rowEnds = row; columnEnds = col; + emit selectionChanged(); } if( selectionMode == selectionMode_column ) @@ -831,15 +832,11 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) } else if( selectionMode == selectionMode_line ) { - if( isLineSelectionON && ( k == Qt::Key_Up || k == Qt::Key_Down ) ) + if( isLineSelectionON && isNavableKey( k ) ) { QPlainTextEdit::keyPressEvent( event ); QTextCursor c( textCursor() ); - if( ( k == Qt::Key_Down && c.blockNumber() == rowEnds + 1 ) || - ( k == Qt::Key_Up && c.blockNumber() == rowBegins - 1 ) ) - { - rowEnds = c.blockNumber(); - } + rowEnds = c.blockNumber(); event->ignore(); update(); return true; @@ -1234,7 +1231,7 @@ void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event ) for( i = ( rb >= t ? rb : t ); i <= re; i++ ) { - if( i == rb ) + if( i == rowBegins ) { if( rb == re ) { @@ -1248,7 +1245,7 @@ void HBQPlainTextEdit::hbPaintSelection( QPaintEvent * event ) r = QRect( x, top, width + abs( x ), fontHeight ); } } - else if( i == re ) + else if( i == rowEnds ) { int x = ( ( columnEnds - c ) * fontWidth ) + marginX; r = QRect( 0, top, x, fontHeight ); diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 05d5f9cf99..6664e41ba2 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -177,7 +177,6 @@ public slots: void hbDuplicateLine(); void hbReplaceSelection( const QString & txt ); void hbInsertTab( int mode ); - void hbHighlightSelectedColumns( bool yes ); QString hbGetSelectedText(); QString hbTextUnderCursor(); void hbNumberBlockVisible( bool b ); diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index e6f391f83f..1e5f61baab 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -580,20 +580,6 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT_HBMOVELINE ) } } -/* - * void hbHighlightSelectedColumns( bool yes ) - */ -HB_FUNC( QT_HBQPLAINTEXTEDIT_HBHIGHLIGHTSELECTEDCOLUMNS ) -{ - HBQPlainTextEdit * p = hbqt_par_HBQPlainTextEdit( 1 ); - if( p ) - ( p )->hbHighlightSelectedColumns( hb_parl( 2 ) ); - else - { - HB_TRACE( HB_TR_DEBUG, ( "............................... F=QT_HBQPLAINTEXTEDIT_HBHIGHLIGHTSELECTEDCOLUMNS FP=( p )->hbHighlightSelectedColumns( hb_parl( 2 ) ); p is NULL" ) ); - } -} - /* * QString hbGetSelectedText() */ diff --git a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg index 1a5d16fb68..23653e41bf 100644 --- a/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg +++ b/harbour/contrib/hbqt/qtgui/THBQPlainTextEdit.prg @@ -97,7 +97,6 @@ CREATE CLASS HBQPlainTextEdit INHERIT HbQtObjectHandler, QPlainTextEdit METHOD hbBlockIndent( nSteps ) METHOD hbDeleteLine() METHOD hbMoveLine( nIDirection ) - METHOD hbHighlightSelectedColumns( lYes ) METHOD hbGetSelectedText() METHOD hbTextUnderCursor() METHOD hbShowPrototype( cTip ) @@ -246,10 +245,6 @@ METHOD HBQPlainTextEdit:hbMoveLine( nIDirection ) RETURN Qt_HBQPlainTextEdit_hbMoveLine( ::pPtr, nIDirection ) -METHOD HBQPlainTextEdit:hbHighlightSelectedColumns( lYes ) - RETURN Qt_HBQPlainTextEdit_hbHighlightSelectedColumns( ::pPtr, lYes ) - - METHOD HBQPlainTextEdit:hbGetSelectedText() RETURN Qt_HBQPlainTextEdit_hbGetSelectedText( ::pPtr ) diff --git a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth index 0009632445..a1a92b954c 100644 --- a/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth +++ b/harbour/contrib/hbqt/qth/HBQPlainTextEdit.qth @@ -128,7 +128,6 @@ HB_FUNC( QT_HBQPLAINTEXTEDIT ) void hbBlockIndent( int steps ) void hbDeleteLine() void hbMoveLine( int iDirection ) - void hbHighlightSelectedColumns( bool yes ) QString hbGetSelectedText() QString hbTextUnderCursor() void hbShowPrototype( const QString & tip )