From bf43b397bece63f01acc2b783b627ea407b210bd Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sun, 16 May 2010 12:52:16 +0000 Subject: [PATCH] 2010-15-16 05:47 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 ! Fixed: Ctrl+X: cut() was faultering. --- harbour/ChangeLog | 7 +++ harbour/contrib/hbide/ideedit.prg | 14 ++--- .../contrib/hbqt/hbqt_hbqplaintextedit.cpp | 58 +++++++++---------- harbour/contrib/hbqt/hbqt_hbqplaintextedit.h | 2 +- .../contrib/hbqt/qtgui/HBQPlainTextEdit.cpp | 2 +- 5 files changed, 42 insertions(+), 41 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 30e615b75a..fc801d3b52 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,13 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-15-16 05:47 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 + ! Fixed: Ctrl+X: cut() was faultering. + 2010-05-16 11:12 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_svc.c ! Fixed callback definitions to be the ones required by Windows. diff --git a/harbour/contrib/hbide/ideedit.prg b/harbour/contrib/hbide/ideedit.prg index 1b90a047c4..88e9d7361c 100644 --- a/harbour/contrib/hbide/ideedit.prg +++ b/harbour/contrib/hbide/ideedit.prg @@ -911,16 +911,17 @@ METHOD IdeEdit:insertBlockContents( aCord ) /*----------------------------------------------------------------------*/ METHOD IdeEdit:deleteBlockContents( aCord ) - LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, k + LOCAL nT, nL, nB, nR, nW, i, cLine, qCursor, k, nSelMode hbide_normalizeRect( aCord, @nT, @nL, @nB, @nR ) k := aCord[ 7 ] k := iif( empty( k ), Qt_Key_X, k ) - IF k == Qt_Key_X ::copyBlockContents( aCord ) ENDIF + nSelMode := aCord[ 5 ] +//HB_TRACE( HB_TR_ALWAYS, nT, nL, nB, nR, nSelMode ) qCursor := QTextCursor():from( ::qEdit:textCursor() ) qCursor:beginEditBlock() @@ -935,7 +936,7 @@ METHOD IdeEdit:deleteBlockContents( aCord ) ELSE IF k == Qt_Key_Delete .OR. k == Qt_Key_X - IF aCord[ 5 ] == selectionMode_column + IF nSelMode == selectionMode_column FOR i := nT TO nB cLine := ::getLine( i + 1 ) cLine := pad( substr( cLine, 1, nL ), nL ) + substr( cLine, nR + 1 ) @@ -943,7 +944,7 @@ METHOD IdeEdit:deleteBlockContents( aCord ) NEXT hbide_qPositionCursor( qCursor, nT, nL ) - ELSEIF aCord[ 5 ] == selectionMode_stream + ELSEIF nSelMode == selectionMode_stream hbide_qPositionCursor( qCursor, nT, nL ) qCursor:movePosition( QTextCursor_Down , QTextCursor_KeepAnchor, nB - nT ) qCursor:movePosition( QTextCursor_StartOfLine, QTextCursor_KeepAnchor ) @@ -951,7 +952,7 @@ METHOD IdeEdit:deleteBlockContents( aCord ) qCursor:removeSelectedText() ::qEdit:hbSetSelectionInfo( { -1,-1,-1,-1,0 } ) - ELSEIF aCord[ 5 ] == selectionMode_line + ELSEIF nSelMode == selectionMode_line hbide_qPositionCursor( qCursor, nT, nL ) qCursor:movePosition( QTextCursor_Down , QTextCursor_KeepAnchor, nB - nT + 1 ) qCursor:movePosition( QTextCursor_StartOfLine, QTextCursor_KeepAnchor ) @@ -1242,7 +1243,6 @@ METHOD IdeEdit:toggleLineNumbers() METHOD IdeEdit:toggleSelectionMode() ::isColumnSelectionON := ! ::isColumnSelectionON - //::qEdit:hbHighlightSelectedColumns( ::isColumnSelectionON ) ::qEdit:hbSetSelectionMode( iif( ::isColumnSelectionON, 2, 1 ), .t. ) ::dispStatusInfo() RETURN Self @@ -1276,7 +1276,7 @@ METHOD IdeEdit:undo() /*----------------------------------------------------------------------*/ METHOD IdeEdit:cut() - ::qEdit:hbCut() + ::qEdit:hbCut( Qt_Key_X ) RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp index d676eed789..804a285ad8 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.cpp @@ -344,6 +344,7 @@ void HBQPlainTextEdit::hbSetSelectionMode( int mode, bool on ) selectionMode = selectionMode_stream; isColumnSelectionEnabled = false; isLineSelectionON = false; + setCursorWidth( 1 ); break; } case selectionMode_column: @@ -373,13 +374,6 @@ void HBQPlainTextEdit::hbSetSelectionMode( int mode, bool on ) } break; } - #if 0 - default: - { - selectionMode = selectionMode_none; - hbClearColumnSelection(); - } - #endif } update(); } @@ -451,7 +445,7 @@ void HBQPlainTextEdit::hbCut( int k ) hb_itemRelease( p1 ); hb_itemRelease( p2 ); - if( selectionMode == selectionMode_column && k == 0 ) + if( selectionMode == selectionMode_column ) //&& k == 0 ) columnEnds = columnBegins; } else @@ -633,7 +627,22 @@ void HBQPlainTextEdit::mouseMoveEvent( QMouseEvent *event ) /*----------------------------------------------------------------------*/ -bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) +void HBQPlainTextEdit::keyReleaseEvent( QKeyEvent * event ) +{ + QPlainTextEdit::keyReleaseEvent( event ); + + if( ( event->modifiers() & Qt::ControlModifier ) && event->text() == "" ) + { + if( selectionState == 2 ) + { + selectionState = 1; + } + } +} + +/*----------------------------------------------------------------------*/ + +bool HBQPlainTextEdit::hbKeyPressSelection( QKeyEvent * event ) { bool ctrl = event->modifiers() & Qt::ControlModifier; bool shift = event->modifiers() & Qt::ShiftModifier; @@ -735,7 +744,7 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) break; } } - +//HB_TRACE( HB_TR_ALWAYS, ( "0 NAV %i %i %i %i", rowBegins, columnBegins, rowEnds, columnEnds ) ); c.clearSelection(); setTextCursor( c ); @@ -773,8 +782,9 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) rowEnds = row; columnEnds = col; } +//HB_TRACE( HB_TR_ALWAYS, ( "1 NAV %i %i %i %i", rowBegins, columnBegins, rowEnds, columnEnds ) ); update(); - event->ignore(); + event->accept(); return true; } // if( shift && isNavableKey( k ) ) else if( selectionMode == selectionMode_column ) @@ -805,7 +815,7 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) columnEnds++; } repaint(); - event->ignore(); + event->accept(); return true; } } @@ -824,7 +834,7 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) columnEnds = columnBegins; } repaint(); - event->ignore(); + event->accept(); return true; } else @@ -839,7 +849,7 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) hbCut( k ); repaint(); selectionState = 0; - event->ignore(); + event->accept(); return true; } else @@ -873,7 +883,7 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) QPlainTextEdit::keyPressEvent( event ); QTextCursor c( textCursor() ); rowEnds = c.blockNumber(); - event->ignore(); + event->accept(); update(); return true; } @@ -883,25 +893,9 @@ bool HBQPlainTextEdit::hbKeyPressColumnSelection( QKeyEvent * event ) /*----------------------------------------------------------------------*/ -void HBQPlainTextEdit::keyReleaseEvent( QKeyEvent * event ) -{ - QPlainTextEdit::keyReleaseEvent( event ); - - bool ctrl = event->modifiers() & Qt::ControlModifier; - if( ctrl && event->text() == "" ) - { - if( selectionState > 0 ) - { - selectionState = 0; - } - } -} - -/*----------------------------------------------------------------------*/ - void HBQPlainTextEdit::keyPressEvent( QKeyEvent * event ) { - if( hbKeyPressColumnSelection( event ) ) + if( hbKeyPressSelection( event ) ) { return; } diff --git a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h index 0c154cd4dd..13f84e5540 100644 --- a/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h +++ b/harbour/contrib/hbqt/hbqt_hbqplaintextedit.h @@ -203,7 +203,7 @@ private slots: void hbUpdateLineNumberArea( const QRect &, int ); void hbUpdateHorzRuler( const QRect &, int ); void hbPaintSelection( QPaintEvent * ); - bool hbKeyPressColumnSelection( QKeyEvent * ); + bool hbKeyPressSelection( QKeyEvent * ); void hbClearColumnSelection(); void hbUpdateCaret(); }; diff --git a/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp b/harbour/contrib/hbqt/qtgui/HBQPlainTextEdit.cpp index 1f5ef89fb4..1e5f61baab 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 () */