[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    branches/kdepim/enterprise/kdepim/libkdepim
From:       Allen Winter <winter () kde ! org>
Date:       2010-02-04 18:32:17
Message-ID: 1265308337.214309.18976.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1085247 by winterz:

Fix overwriting selected text by pasted text
kolab/issue4084

MERGE: none (already in trunk)


 M  +12 -11    addresseelineedit.cpp  


--- branches/kdepim/enterprise/kdepim/libkdepim/addresseelineedit.cpp #1085246:1085247
@@ -296,24 +296,25 @@
 
   QString contents = text();
   int start_sel = 0;
-  int end_sel = 0;
   int pos = cursorPosition( );
-  if ( getSelection( &start_sel, &end_sel ) ) {
+
+  if ( hasSelectedText() ) {
     // Cut away the selection.
-    if ( pos > end_sel )
-      pos -= (end_sel - start_sel);
-    else if ( pos > start_sel )
-      pos = start_sel;
-    contents = contents.left( start_sel ) + contents.right( end_sel + 1 );
+    start_sel = selectionStart();
+    pos = start_sel;
+    contents = contents.left( start_sel ) + contents.mid( start_sel + selectedText().length() );
   }
 
   int eot = contents.length();
-  while ((eot > 0) && contents[ eot - 1 ].isSpace() ) eot--;
-  if ( eot == 0 )
+  while ( ( eot > 0 ) && contents[ eot - 1 ].isSpace() ) {
+    eot--;
+  }
+  if ( eot == 0 ) {
     contents = QString::null;
-  else if ( pos >= eot ) {
-    if ( contents[ eot - 1 ] == ',' )
+  } else if ( pos >= eot ) {
+    if ( contents[ eot - 1 ] == ',' ) {
       eot--;
+    }
     contents.truncate( eot );
     contents += ", ";
     pos = eot + 2;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic