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

List:       kde-commits
Subject:    kdepim/libkdepim
From:       Till Adam <adam () kde ! org>
Date:       2005-03-10 14:49:12
Message-ID: 20050310144912.05F9017AA0 () office ! kde ! org
[Download RAW message or body]

CVS commit by tilladam: 

Don't create bogus additional completion entries if the name is already of
the form "Lastname, Firstname", as in the branch. Additionally clean up
the code some.

One could maybe construct virtual entries of the form "Foo Bar" from the
original "Bar, Foo" to make completion on the first name possible in these
cases, but I have a feeling that this is not the right place to do that 
kind of email parsing. Ideally the completion fields should be available
individually from kabc and ldap, probably.


  M +18 -19    addresseelineedit.cpp   1.38


--- kdepim/libkdepim/addresseelineedit.cpp  #1.37:1.38
@@ -504,13 +504,13 @@ void AddresseeLineEdit::addContact( cons
       addCompletionItem( addr.preferredEmail() + " (" + name + ")", weight );
 
+    if ( name.find( ',' ) ) return; // probably already of the form "Lastname, Firstname"
+
     bool bDone = false;
-    int i = 1;
-    do{
-      i = name.findRev(' ');
-      if( 1 < i ){
-        QString sLastName( name.mid(i+1) );
+    int i = -1;
+    while( ( i = name.findRev(' ') > 1 ) && !bDone ) {
+      QString sLastName( name.mid( i+1 ) );
         if( ! sLastName.isEmpty() &&
             2 <= sLastName.length() &&   // last names must be at least 2 chars long
-            ! sLastName.endsWith(".") ){ // last names must not end with a dot (like "Jr." or "Sr.")
+          ! sLastName.endsWith(".") ) { // last names must not end with a dot (like "Jr." or "Sr.")
           name.truncate( i );
           if( !name.isEmpty() ){
@@ -525,5 +525,4 @@ void AddresseeLineEdit::addContact( cons
           bDone = true;
         }
-      }
       if( !bDone ){
         name.truncate( i );
@@ -531,5 +530,5 @@ void AddresseeLineEdit::addContact( cons
           name.truncate( name.length()-1 );
       }
-    }while( 1 < i && !bDone );
+    }
   }
 }


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

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