From df85a620e5351aa21604641d2306d49de410819d Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sun, 16 May 2010 22:44:11 +0000 Subject: [PATCH] 2010-15-16 15:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbqt/hbqt_hbqplaintextedit.cpp * contrib/hbqt/hbqt_hbqplaintextedit.h * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp * contrib/hbide/ideedit.prg ! More fluency and refinements in selection process spanning across all three modes. --- harbour/ChangeLog | 8 +++++ harbour/contrib/hbide/ideedit.prg | 6 ++-- .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 34 +++++++------------ harbour/contrib/hbqt/hbqt_hbqplaintextedit.h | 2 +- .../contrib/hbqt/qtgui/HBQPlainTextEdit.cpp | 2 +- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 4dde5e2b7e..f97f61d563 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,14 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-15-16 15:40 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbqt/hbqt_hbqplaintextedit.cpp + * contrib/hbqt/hbqt_hbqplaintextedit.h + * contrib/hbqt/qtgui/HBQPlainTextEdit.cpp + * contrib/hbide/ideedit.prg + ! More fluency and refinements in selection process spanning + across all three modes. + 2010-05-16 23:36 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * debian/rules - doc/man/hbmk.1 diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 88e9d7361c..33eb9f11ef 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -744,7 +744,7 @@ STATIC FUNCTION hbide_qCursorDownInsert( qCursor ) METHOD IdeEdit:clearSelection() - ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,0 } ) + ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,1 } ) RETURN Self @@ -950,14 +950,14 @@ METHOD IdeEdit:deleteBlockContents( aCord ) qCursor:movePosition( QTextCursor_StartOfLine, QTextCursor_KeepAnchor ) qCursor:movePosition( QTextCursor_Right , QTextCursor_KeepAnchor, nR ) qCursor:removeSelectedText() - ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,0 } ) + ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,1 } ) ELSEIF nSelMode == selectionMode_line hbide_qPositionCursor( qCursor, nT, nL ) qCursor:movePosition( QTextCursor_Down , QTextCursor_KeepAnchor, nB - nT + 1 ) qCursor:movePosition( QTextCursor_StartOfLine, QTextCursor_KeepAnchor ) qCursor:removeSelectedText() - ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,0 } ) + ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,1 } ) ::isLineSelectionON := .f. ENDIF diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index 804a285ad8..383f184813 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -74,6 +74,7 @@ #if QT_VERSION >= 0x040500 #include "hbqt_hbqplaintextedit.h" +#include #define selectionState_off 0 #define selectionState_on 1 @@ -282,7 +283,7 @@ bool HBQPlainTextEdit::isCursorInSelection() /*----------------------------------------------------------------------*/ -void HBQPlainTextEdit::hbClearColumnSelection() +void HBQPlainTextEdit::hbClearSelection() { setCursorWidth( 1 ); @@ -361,7 +362,7 @@ void HBQPlainTextEdit::hbSetSelectionMode( int mode, bool on ) if( on ) { isLineSelectionON = true; - hbClearColumnSelection(); + hbClearSelection(); QTextCursor c( textCursor() ); rowBegins = c.blockNumber(); rowEnds = rowBegins; @@ -584,7 +585,7 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) if( selectionState == 1 ) { selectionState = 2; - hbClearColumnSelection(); + hbClearSelection(); } if( columnBegins == -1 ) @@ -600,6 +601,7 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) columnEnds = columnBegins; emit selectionChanged(); + QPlainTextEdit::mouseMoveEvent( event ); } else { @@ -619,7 +621,6 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) } c.clearSelection(); setTextCursor( c ); - event->accept(); repaint(); } } @@ -664,7 +665,7 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) { selectionMode = selectionMode_stream; selectionState = 0; - hbClearColumnSelection(); + hbClearSelection(); repaint(); } @@ -684,7 +685,7 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) if( selectionState == 0 ) { - hbClearColumnSelection(); + hbClearSelection(); } if( selectionMode == selectionMode_column ) setCursorWidth( 0 ); @@ -744,7 +745,7 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) break; } } -//HB_TRACE( HB_TR_ALWAYS, ( "0 NAV %i %i %i %i", rowBegins, columnBegins, rowEnds, columnEnds ) ); + event->accept(); c.clearSelection(); setTextCursor( c ); @@ -782,9 +783,8 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) rowEnds = row; columnEnds = col; } -//HB_TRACE( HB_TR_ALWAYS, ( "1 NAV %i %i %i %i", rowBegins, columnBegins, rowEnds, columnEnds ) ); update(); - event->accept(); + //event->accept(); return true; } // if( shift && isNavableKey( k ) ) else if( selectionMode == selectionMode_column ) @@ -871,7 +871,7 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) selectionState = 0; if( columnEnds == columnBegins ) { - hbClearColumnSelection(); + hbClearSelection(); } } } @@ -883,8 +883,8 @@ bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) QPlainTextEdit::keyPressEvent( event ); QTextCursor c( textCursor() ); rowEnds = c.blockNumber(); - event->accept(); - update(); + //event->accept(); + repaint(); return true; } } @@ -897,6 +897,7 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) { if( hbKeyPressSelection( event ) ) { + QApplication::processEvents(); return; } @@ -967,15 +968,6 @@ void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) c->complete( cr ); // popup it up! } -/*----------------------------------------------------------------------*/ -#if 0 -QString HBQPlainTextEdit::hbTextForPrefix() -{ - QTextCursor tc = textCursor(); - tc.select( QTextCursor::WordUnderCursor ); - return tc.selectedText(); -} -#endif /*----------------------------------------------------------------------*/ QString HBQPlainTextEdit::hbTextUnderCursor() diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 13f84e5540..8086e83fd5 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -204,7 +204,7 @@ private slots: void hbUpdateHorzRuler( const QRect &, int ); void hbPaintSelection( QPaintEvent * ); bool hbKeyPressSelection( QKeyEvent * ); - void hbClearColumnSelection(); + void hbClearSelection(); void hbUpdateCaret(); }; diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 1e5f61baab..1f5ef89fb4 100644 --- a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp +++ b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp @@ -72,7 +72,7 @@ #include "../hbqt_hbqplaintextedit.h" /* - * HBQPlainTextEdit ( QWidget * parent = 0 ) + * HBQPlainTextEdit ( QWidget * parent = 0 ) . * HBQPlainTextEdit ( const QString & text, QWidget * parent = 0 ) * virtual ~HBQPlainTextEdit () */