From cd3fa7114583f44251bed8490cdd3c2f42768003 Mon Sep 17 00:00:00 2001 From: Thomas McGuire Date: Wed, 15 Aug 2007 14:40:10 +0000 Subject: [PATCH] Fix the cursor position for templates. Now %CURSOR works again, this was somehow lost in porting. Additionally, it is now possible again to set the cursor to the first line. BUG: 140917 CCBUG: 141459 svn path=/trunk/KDE/kdepim/; revision=700430 --- kmcomposewin.cpp | 5 ++--- kmedit.cpp | 8 ++++++++ kmedit.h | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index fdb2b2240..bc5b434c5 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -4635,9 +4635,8 @@ void KMComposeWin::slotEditKeys() void KMComposeWin::setReplyFocus( bool hasMessage ) { mEditor->setFocus(); - if ( hasMessage ) { - mEditor->setCursorPosition( 1, 0 ); - } + if ( hasMessage ) + mEditor->setCursorPositionFromStart( (unsigned int) mMsg->getCursorPos() ); } void KMComposeWin::setFocusToSubject() diff --git a/kmedit.cpp b/kmedit.cpp index 7599e9eec..8edf8edb5 100644 --- a/kmedit.cpp +++ b/kmedit.cpp @@ -759,4 +759,12 @@ void KMEdit::slotSpellDone() } } +void KMEdit::setCursorPositionFromStart( unsigned int pos ) { + unsigned int l = 0; + unsigned int c = 0; + posToRowCol( pos, l, c ); + setCursorPosition( l, c ); + ensureCursorVisible(); +} + #include "kmedit.moc" diff --git a/kmedit.h b/kmedit.h index 44f4c47d3..e58b0afc9 100644 --- a/kmedit.h +++ b/kmedit.h @@ -91,6 +91,10 @@ public: unsigned int lineBreakColumn() const; + /** set cursor to absolute position pos */ + void setCursorPositionFromStart(unsigned int pos); + + signals: void spellcheck_done( int result ); void attachPNGImageData( const QByteArray &image );