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

List:       kde-pim
Subject:    [Kde-pim] Kolab bugfix: Allow completion of names even if last name
From:       Karl-Heinz Zimmer <khz () kde ! org>
Date:       2004-08-11 21:31:56
Message-ID: 200408112332.00453 () postmaster ! bugcops ! org
[Download RAW message or body]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,

the following patch adds some functionallity we need to fix a
kolab bug (issue 31).

So far AddressLineEdit could not show the respective completion
proposal if the user typed the addressee's last name but in the
database(s) only the normal first name/last name combination was
stored.

So no completion is offered if you type "Brown" into the To line in
KMail's composer if complete name expected by KMail is "John Brown".

The patch tries to detect the last name and adds a respective entry
to the completion list.

Please review and comment if I may commit now or better wait ...

Thank you

Karl-Heinz
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQFBGpBMCcaVnbvggDcRAmuSAJsGv3yncsTrL7DRqvN6mNR3ekyX3ACcDfja
y84KADsD71sXIqfz+9xNBuI=
=IatK
-----END PGP SIGNATURE-----

["kolab_issue_31__khz.patch" (text/x-diff)]

Index: addresseelineedit.cpp
===================================================================
RCS file: /home/kde/kdepim/libkdepim/addresseelineedit.cpp,v
retrieving revision 1.25
diff -u -p -r1.25 addresseelineedit.cpp
--- addresseelineedit.cpp	9 Aug 2004 20:00:17 -0000	1.25
+++ addresseelineedit.cpp	11 Aug 2004 21:01:29 -0000
@@ -344,6 +344,7 @@ void AddresseeLineEdit::doCompletion( bo
       m_previousAddresses = prevAddr;
       QStringList items = s_completion->allMatches( s );
       items += s_completion->allMatches( "\"" + s );
+      //kdDebug(5300) << "     AddresseeLineEdit::doCompletion() found: " << \
items.join(" AND ") << endl;  uint beforeDollarCompletionCount = items.count();
 
       if ( s.find( ' ' ) == -1 ) // one word, possibly given name
@@ -478,7 +479,44 @@ void AddresseeLineEdit::addContact( cons
     //kdDebug(5300) << "     AddresseeLineEdit::addContact() \"" << tmp << "\"" << \
endl;  QString fullEmail = addr.fullEmail( tmp );
     //kdDebug(5300) << "                                     \"" << fullEmail << \
"\"" << endl; +    //kdDebug(5300) << "                                     " << \
weight << endl;  s_completion->addItem( fullEmail.simplifyWhiteSpace(), weight );
+    // Try to guess the last name: if found, we add an extra
+    // entry to the list to make sure completion works even
+    // if the user starts by typing in the last name.
+    QString name( addr.realName().simplifyWhiteSpace() );
+    if( name.endsWith("\"") )
+      name.truncate( name.length()-1 );
+    if( name.startsWith("\"") )
+      name = name.mid( 1 );
+    bool bDone = false;
+    int i = 1;
+    do{
+      i = name.findRev(' ');
+      if( 1 < i ){
+        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.") +          name.truncate( i );
+          if( !name.isEmpty() ){
+            sLastName.prepend( "\"" );
+            sLastName.append( ", " + name + "\" <" );
+          }
+          QString sExtraEntry( sLastName );
+          sExtraEntry.append( tmp.isEmpty() ? addr.preferredEmail() : tmp );
+          sExtraEntry.append( ">" );
+          //kdDebug(5300) << "     AddresseeLineEdit::addContact() added extra \"" \
<< sExtraEntry.simplifyWhiteSpace() << "\"" << endl; +          \
s_completion->addItem( sExtraEntry.simplifyWhiteSpace(), weight ); +          bDone = \
true; +        }
+      }
+      if( !bDone ){
+        name.truncate( i );
+        if( name.endsWith("\"") )
+          name.truncate( name.length()-1 );
+      }
+    }while( 1 < i && !bDone );
   }
 }
 



_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
https://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/

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

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