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

List:       kmail-devel
Subject:    [Bug 131176] Autocompletion shows standard/preferred address after
From:       Christian Schaarschmidt <schaarsc () gmx ! de>
Date:       2007-03-28 19:50:56
Message-ID: 20070328195056.10473.qmail () ktown ! kde ! org
[Download RAW message or body]

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
         
http://bugs.kde.org/show_bug.cgi?id=131176         
schaarsc gmx de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED



------- Additional Comments From schaarsc gmx de  2007-03-28 21:50 -------
SVN commit 647586 by schaarsc:

list preferred email first 
BUG: 131176


 M  +22 -8     addresseelineedit.cpp  


--- branches/KDE/3.5/kdepim/libkdepim/addresseelineedit.cpp #647585:647586
 @ -575,36 +575,38  @
   //m_contactMap.insert( addr.realName(), addr );
   const QStringList emails = addr.emails();
   QStringList::ConstIterator it;
+  const int prefEmailWeight = 1;     //increment weight by prefEmailWeight
+  int isPrefEmail = prefEmailWeight; //first in list is preferredEmail
   for ( it = emails.begin(); it != emails.end(); ++it ) {
     //TODO: highlight preferredEmail
     const QString email( (*it) );
     const QString givenName = addr.givenName();
     const QString familyName= addr.familyName();
     const QString nickName  = addr.nickName();
-    const QString fullEmail = addr.fullEmail( email );
     const QString domain    = email.mid( email.find( ' ' ) + 1 );
+    QString fullEmail       = addr.fullEmail( email );
     //TODO: let user decide what fields to use in lookup, e.g. company, city, ...
 
     //for CompletionAuto
     if ( givenName.isEmpty() && familyName.isEmpty() ) {
-      addCompletionItem( fullEmail, weight, source ); // use whatever is there
+      addCompletionItem( fullEmail, weight + isPrefEmail, source ); // use whatever \
is there  } else {
       const QString byFirstName=  "\"" + givenName + " " + familyName + "\" <" + \
                email + ">";
       const QString byLastName =  "\"" + familyName + ", " + givenName + "\" <" + \
                email + ">";
-      addCompletionItem( byFirstName, weight, source );
-      addCompletionItem( byLastName, weight, source );
+      addCompletionItem( byFirstName, weight + isPrefEmail, source );
+      addCompletionItem( byLastName, weight + isPrefEmail, source );
     }
 
-    addCompletionItem( email, weight, source );
+    addCompletionItem( email, weight + isPrefEmail, source );
 
     if ( !nickName.isEmpty() ){
       const QString byNick     =  "\"" + nickName + "\" <" + email + ">";
-      addCompletionItem( byNick, weight, source );
+      addCompletionItem( byNick, weight + isPrefEmail, source );
     }
 
     if ( !domain.isEmpty() ){
       const QString byDomain   =  "\"" + domain + " " + familyName + " " + givenName \
                + "\" <" + email + ">";
-      addCompletionItem( byDomain, weight, source );
+      addCompletionItem( byDomain, weight + isPrefEmail, source );
     }
 
     //for CompletionShell, CompletionPopup
 @ -631,8 +633,18  @
 
     keyWords.append( email );
 
-    addCompletionItem( fullEmail, weight, source, &keyWords );
+    /* KMailCompletion does not have knowledge about identities, it stores emails \
and +     * keywords for each email. KMailCompletion::allMatches does a lookup on the
+     * keywords and returns an ordered list of emails. In order to get the preferred
+     * email before others for each identity we use this little trick.
+     * We remove the <blank> in getAdjustedCompletionItems.
+     */
+    if ( isPrefEmail == prefEmailWeight )
+      fullEmail.replace( " <", "  <" );
 
+    addCompletionItem( fullEmail, weight + isPrefEmail, source, &keyWords );
+    isPrefEmail = 0;
+
 #if 0
     int len = (*it).length();
     if ( len == 0 ) continue;
 @ -1009,6 +1021,8  @
         lastSourceIndex = idx;
       }
       (*it) = (*it).prepend( s_completionItemIndentString );
+      // remove preferred email sort <blank> added in  addContact()
+      (*it).replace( "  <", " <" );
     }
     sections[idx].append( *it );
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel


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

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