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

List:       kde-pim
Subject:    Re: [Kde-pim] [PATCH] kmail recipient picker fixes
From:       Sander van Grieken <sander () 3v8 ! net>
Date:       2007-11-11 16:55:10
Message-ID: 200711111755.11874.sander () 3v8 ! net
[Download RAW message or body]

On Sunday 11 November 2007 01:17:25 Thomas McGuire wrote:
> Hi Sander,
>
> On Saturday 10 November 2007, Sander van Grieken wrote:
> > This is the first time I'm posting to this list. I understand that this
> > is the place to be if one wants to submit patches?
>
> Yes, this is the right place.
>
> > I've created a patch to kmail/recipientspicker that fixes crashes when
> > receiving addressbook-changed events from kaddressbook, fixes duplicate
> > resource and recipient entries and fixes some memory management problems.
>
> Thanks for the patch! I tried it, but as soon as I open the recipient
> picker, KMail crashes with the backtrace below (without the patch, it
> doesn't crash). But just before that, I could see that the duplicated
> entries are indeed gone :)

Hi Thomas,

Thanks for testing it, and for your swift response!

> Some things I noticed:
> - What happens if a recipient has multiple e-mail addresses? According to
> the logic of genKey(), he will be added to the collection only once, since
> the key is made with the preferred e-mail address. However, there should be
> one entry for each e-mail address. (I am not sure about the actual behavior
> since I couldn't test it) - genKey() should be generateKey()

Thanks, I didn't notice that. 

> - You sometimes don't adhere to the (admittedly strange) coding style of
> KMail with
>
>   regard to parenthesis. For example:
>   > if (!mDistributionList.isEmpty())
>
>   should be
>
>   >if ( !mDistributionList.isEmpty() )
>
>   or
>
>   > mAllRecipients->addItem(*rcptIt);
>
>   should be
>
>   > mAllRecipients->addItem( *rcptIt );
>
>   But this is minor, and you did it correctly in most places.

Should be all ok now :)

> As for the crash, I think the reason is that a recipient can be in multiple
> collections. For example, if you put a person in your address book into a
> category, he will be in two collections, the one for the catogory and the
> one for the resource. This might be problematic, because it looks like the
> code then double-deletes the items in ~RecipientsPicker(). But again, I am
> not sure and might be wrong, I didn't have time to look at this more
> toroughly.

Aah, yes I know where this crash comes from. The old implementation put 
everything in the (derived) mAllRecipients list and used that as 
the 'datastore' and treated the other lists as only reference containers. The 
new implementation inverts this and makes all lists datastores except for 
mAllRecipients, which is now only a reference container. 

The crash comes from the fact that the category lists are also reference 
containers, resulting in the double-free because they are still treated like 
a datastore in the destructor..

> Again, thanks for the work, I hope you'll come up with an improved version
> of the patch.

Here it is. Fixing the above problem also exposed another problem with 
distribution list entries that crash after an addressbook-changed event, so 
I've also fixed that.

grtz,
Sander


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

Index: kmail/recipientspicker.h
===================================================================
--- kmail/recipientspicker.h	(revision 734800)
+++ kmail/recipientspicker.h	(working copy)
@@ -52,12 +52,15 @@
     typedef QList<RecipientItem *> List;
 
 #ifdef KDEPIM_NEW_DISTRLISTS
-  RecipientItem( KABC::AddressBook *ab );
-  void setDistributionList( const KPIM::DistributionList& );
+    RecipientItem( KABC::AddressBook *ab );
+    void setDistributionList( const KPIM::DistributionList& );
+    KPIM::DistributionList& distributionList();
 #else
     RecipientItem();
     void setDistributionList( KABC::DistributionList * );
+    KABC::DistributionList * distributionList();
 #endif
+
     void setAddressee( const KABC::Addressee &, const QString &email );
 
     void setRecipientType( const QString &type );
@@ -71,18 +74,27 @@
 
     QString key() const { return mKey; }
 
-    QString toolTip() const;
+    QString tooltip() const;
 
   private:
+#ifdef KDEPIM_NEW_DISTRLISTS
+    QString createTooltip( KPIM::DistributionList & ) const;
+#else
+    QString createTooltip( KABC::DistributionList * ) const;
+#endif
+
     KABC::Addressee mAddressee;
+    QString mName;
     QString mEmail;
+    QString mRecipient;
 #ifdef KDEPIM_NEW_DISTRLISTS
-  KPIM::DistributionList mDistributionList;
-  KABC::AddressBook *mAddressBook;
+    KPIM::DistributionList mDistributionList;
+    KABC::AddressBook *mAddressBook;
 #else
     KABC::DistributionList *mDistributionList;
 #endif
     QString mType;
+    QString mTooltip;
 
     QPixmap mIcon;
 
@@ -106,6 +118,9 @@
     RecipientsCollection();
     ~RecipientsCollection();
 
+    void setReferenceContainer( bool );
+    bool isReferenceContainer();
+
     void setTitle( const QString & );
     QString title() const;
 
@@ -114,14 +129,17 @@
     RecipientItem::List items() const;
 
     bool hasEquivalentItem( RecipientItem * ) const;
+    RecipientItem * getEquivalentItem( RecipientItem *) const;
 
     void clear();
 
     void deleteAll();
 
   private:
+    // flag to indicate if this collection contains just references
+    // or should manage memory (de)allocation as well.
+    bool mIsReferenceContainer;
     QString mTitle;
-    RecipientItem::List mItems;
     QMap<QString, RecipientItem *> mKeyMap;
 };
 
@@ -190,6 +208,8 @@
 
     void setDefaultButton( QPushButton *button );
 
+    void rebuildAllRecipientsList();
+
   protected slots:
     void updateList();
     void slotToClicked();
@@ -213,6 +233,7 @@
 
     QMap<int,RecipientsCollection *> mCollectionMap;
     RecipientsCollection *mAllRecipients;
+    RecipientsCollection *mDistributionLists;
     RecipientsCollection *mSelectedRecipients;
 
     Recipient::Type mDefaultType;
Index: kmail/recipientspicker.cpp
===================================================================
--- kmail/recipientspicker.cpp	(revision 734800)
+++ kmail/recipientspicker.cpp	(working copy)
@@ -69,7 +69,16 @@
 
   mIcon = KIconLoader::global()->loadIcon( "kontact_contacts", KIconLoader::Small );
 
-  mKey = 'D' + list.name();
+  mName = list.name();
+  mKey = list.name();
+
+  int count = list.entries( mAddressBook ).count();
+
+  mEmail = i18np( "1 email address", "%1 email addresses", count );
+
+  mRecipient = mName;
+
+  mTooltip = createTooltip( list );
 }
 #else
 void RecipientItem::setDistributionList( KABC::DistributionList *list )
@@ -78,7 +87,15 @@
 
   mIcon = KIconLoader::global()->loadIcon( "kontact_contacts", KIconLoader::Small );
 
-  mKey = 'D' + list->name();
+  mName = list->name();
+  mKey = list->name();
+
+  int count = list->entries().count();
+  mEmail = i18np( "1 email address", "%1 email addresses", count );
+
+  mRecipient = mName;
+
+  mTooltip = createTooltip( list );
 }
 #endif
 
@@ -87,14 +104,22 @@
 {
   mAddressee = a;
   mEmail = email;
-
+  mRecipient = mAddressee.fullEmail( mEmail );
+  
   QImage img = a.photo().data();
   if ( !img.isNull() )
     mIcon = QPixmap::fromImage( img.scaled( 20, 20, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
   else
     mIcon = KIconLoader::global()->loadIcon( "personal", KIconLoader::Small );
 
-  mKey = 'A' + a.preferredEmail();
+  mName = mAddressee.realName();
+  mKey = mAddressee.realName() + '|' + mEmail;
+  
+  mTooltip = "<qt>";
+  if ( !mAddressee.realName().isEmpty() ) {
+    mTooltip += mAddressee.realName() + "<br/>";
+  }
+  mTooltip += "<b>" + mEmail + "</b>";
 }
 
 QPixmap RecipientItem::icon() const
@@ -104,103 +129,81 @@
 
 QString RecipientItem::name() const
 {
-#ifdef KDEPIM_NEW_DISTRLISTS
-  if ( !mAddressee.isEmpty() ) return mAddressee.realName();
-  else if ( !mDistributionList.isEmpty() ) return mDistributionList.name();
-  else return QString();
-#else
-  if ( !mAddressee.isEmpty() ) return mAddressee.realName();
-  else if ( mDistributionList ) return mDistributionList->name();
-  else return QString();
-#endif
+  return mName;
 }
 
 QString RecipientItem::email() const
 {
-#ifdef KDEPIM_NEW_DISTRLISTS
-  if ( mAddressee.isEmpty() && !mDistributionList.isEmpty() ) {
-    int count = mDistributionList.entries( mAddressBook ).count();
-    return i18np( "1 email address", "%1 email addresses", count );
-  } else {
-    return mEmail;
-  }
-#else
-  if ( mAddressee.isEmpty() &&  mDistributionList ) {
-    int count = mDistributionList->entries().count();
-    return i18np( "1 email address", "%1 email addresses", count );
-  } else {
-    return mEmail;
-  }
-#endif
-  return QString();
+  return mEmail;
 }
 
-#ifdef KDEPIM_NEW_DISTRLISTS
 QString RecipientItem::recipient() const
 {
-  QString r;
-  if ( !mAddressee.isEmpty() ) r = mAddressee.fullEmail( mEmail );
-  else if ( !mDistributionList.isEmpty() ) r = mDistributionList.name();
-  return r;
+  return mRecipient;
 }
-#else
-QString RecipientItem::recipient() const
+
+QString RecipientItem::tooltip() const
 {
-  QString r;
-  if ( !mAddressee.isEmpty() ) r = mAddressee.fullEmail( mEmail );
-  else if ( mDistributionList ) r = mDistributionList->name();
-  return r;
+  return mTooltip;
 }
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+KPIM::DistributionList& RecipientItem::distributionList() {
+  return mDistributionList;
+}
+#else
+KABC::DistributionList * RecipientItem::distributionList() {
+  return mDistributionList;
+}
 #endif
 
-QString RecipientItem::toolTip() const
+#ifdef KDEPIM_NEW_DISTRLISTS
+QString RecipientItem::createTooltip( KPIM::DistributionList &distributionList ) const
 {
   QString txt = "<qt>";
 
-  if ( !mAddressee.isEmpty() ) {
-    if ( !mAddressee.realName().isEmpty() ) {
-      txt += mAddressee.realName() + "<br/>";
-    }
-    txt += "<b>" + mEmail + "</b>";
-#ifdef KDEPIM_NEW_DISTRLISTS
-  } else if ( !mDistributionList.isEmpty() ) {
-    txt += "<b>" + i18n( "Distribution List %1", mDistributionList.name() ) + "</b>";
-    txt += "<ul>";
-    KPIM::DistributionList::Entry::List entries = mDistributionList.entries( mAddressBook );
-    KPIM::DistributionList::Entry::List::ConstIterator it;
-    for( it = entries.begin(); it != entries.end(); ++it ) {
-      txt += "<li>";
-      txt += (*it).addressee.realName() + ' ';
-      txt += "<em>";
-      if ( (*it).email.isEmpty() ) txt += (*it).addressee.preferredEmail();
-      else txt += (*it).email;
-      txt += "</em>";
-      txt += "<li/>";
-    }
-    txt += "</ul>";
+  txt += "<b>" + i18n( "Distribution List %1", distributionList.name() ) + "</b>";
+  txt += "<ul>";
+  KPIM::DistributionList::Entry::List entries = distributionList.entries( mAddressBook );
+  KPIM::DistributionList::Entry::List::ConstIterator it;
+  for( it = entries.begin(); it != entries.end(); ++it ) {
+    txt += "<li>";
+    txt += (*it).addressee.realName() + ' ';
+    txt += "<em>";
+    if ( (*it).email.isEmpty() ) txt += (*it).addressee.preferredEmail();
+    else txt += (*it).email;
+    txt += "</em>";
+    txt += "<li/>";
   }
+  txt += "</ul>";
+  txt += "</qt>";
+  
+  return txt;
+}
 #else
-  } else if ( mDistributionList ) {
-    txt += "<b>" + i18n("Distribution List %1",
-        mDistributionList->name() ) + "</b>";
-    txt += "<ul>";
-    KABC::DistributionList::Entry::List entries = mDistributionList->entries();
-    KABC::DistributionList::Entry::List::ConstIterator it;
-    for( it = entries.begin(); it != entries.end(); ++it ) {
-      txt += "<li>";
-      txt += (*it).addressee().realName() + ' ';
-      txt += "<em>";
-      if ( (*it).email().isEmpty() ) txt += (*it).addressee().preferredEmail();
-      else txt += (*it).email();
-      txt += "</em>";
-      txt += "</li>";
-    }
-    txt += "</ul>";
+QString RecipientItem::createTooltip( KABC::DistributionList *distributionList ) const
+{
+  QString txt = "<qt>";
+
+  txt += "<b>" + i18n("Distribution List %1", distributionList->name() ) + "</b>";
+  txt += "<ul>";
+  KABC::DistributionList::Entry::List entries = distributionList->entries();
+  KABC::DistributionList::Entry::List::ConstIterator it;
+  for( it = entries.begin(); it != entries.end(); ++it ) {
+    txt += "<li>";
+    txt += (*it).addressee().realName() + ' ';
+    txt += "<em>";
+    if ( (*it).email().isEmpty() ) txt += (*it).addressee().preferredEmail();
+    else txt += (*it).email();
+    txt += "</em>";
+    txt += "</li>";
   }
-#endif
+  txt += "</ul>";
+  txt += "</qt>";
 
   return txt;
 }
+#endif
 
 void RecipientItem::setRecipientType( const QString &type )
 {
@@ -212,7 +215,6 @@
   return mType;
 }
 
-
 RecipientViewItem::RecipientViewItem( RecipientItem *item, QTreeWidget *listView )
   : QTreeWidgetItem( listView ), mRecipientItem( item )
 {
@@ -230,13 +232,24 @@
 
 RecipientsCollection::RecipientsCollection()
 {
+  mIsReferenceContainer = false;
 }
 
 RecipientsCollection::~RecipientsCollection()
 {
-  clear();
+  deleteAll();
 }
 
+void RecipientsCollection::setReferenceContainer( bool isReferenceContainer )
+{
+  mIsReferenceContainer = isReferenceContainer;
+}
+
+bool RecipientsCollection::isReferenceContainer()
+{
+  return mIsReferenceContainer;
+}
+
 void RecipientsCollection::setTitle( const QString &title )
 {
   mTitle = title;
@@ -249,14 +262,12 @@
 
 void RecipientsCollection::addItem( RecipientItem *item )
 {
-  mItems.append( item );
-
   mKeyMap.insert( item->key(), item );
 }
 
 RecipientItem::List RecipientsCollection::items() const
 {
-  return mItems;
+  return mKeyMap.values();
 }
 
 bool RecipientsCollection::hasEquivalentItem( RecipientItem *item ) const
@@ -264,6 +275,15 @@
   return mKeyMap.find( item->key() ) != mKeyMap.end();
 }
 
+RecipientItem * RecipientsCollection::getEquivalentItem( RecipientItem *item) const
+{
+  QMap<QString, RecipientItem *>::ConstIterator it;
+  it = mKeyMap.find( item->key() );
+  if ( it == mKeyMap.end() )
+    return 0;
+  return (*it);
+}
+
 void RecipientsCollection::clear()
 {
   mKeyMap.clear();
@@ -271,9 +291,11 @@
 
 void RecipientsCollection::deleteAll()
 {
-  QMap<QString, RecipientItem *>::ConstIterator it;
-  for( it = mKeyMap.begin(); it != mKeyMap.end(); ++it ) {
-    delete *it;
+  if ( !isReferenceContainer() ) {
+    QMap<QString, RecipientItem *>::ConstIterator it;
+    for( it = mKeyMap.begin(); it != mKeyMap.end(); ++it ) {
+      delete *it;
+    }
   }
   clear();
 }
@@ -319,10 +341,8 @@
 
   mCollectionCombo = new QComboBox( this );
   resLayout->addWidget( mCollectionCombo );
-  resLayout->addItem(new QSpacerItem(1, 1, QSizePolicy::Expanding));
+  resLayout->addItem( new QSpacerItem(1, 1, QSizePolicy::Expanding) );
 
-  connect( mCollectionCombo, SIGNAL( highlighted( int ) ),
-    SLOT( updateList() ) );
   connect( mCollectionCombo, SIGNAL( activated( int ) ),
     SLOT( updateList() ) );
 
@@ -404,8 +424,6 @@
 {
   writeConfig();
 
-  mAllRecipients->deleteAll();
-
   QMap<int,RecipientsCollection *>::ConstIterator it;
   for( it = mCollectionMap.begin(); it != mCollectionMap.end(); ++it ) {
     delete *it;
@@ -415,18 +433,22 @@
 void RecipientsPicker::initCollections()
 {
   mAllRecipients = new RecipientsCollection;
+  mAllRecipients->setReferenceContainer( true );
   mAllRecipients->setTitle( i18n("All") );
-  insertCollection( mAllRecipients );
 
-  insertAddressBook( mAddressBook );
+  mDistributionLists = new RecipientsCollection;
+  mDistributionLists->setTitle( i18n("Distribution Lists") );
 
-  insertDistributionLists();
+  mSelectedRecipients = new RecipientsCollection;
+  mSelectedRecipients->setTitle( i18n("Selected Recipients") );
 
+  insertCollection( mAllRecipients );
+  insertAddressBook( mAddressBook );
+  insertCollection( mDistributionLists );
   insertRecentAddresses();
+  insertCollection( mSelectedRecipients );
 
-  mSelectedRecipients = new RecipientsCollection;
-  mSelectedRecipients->setTitle( i18n("Selected Recipients") );
-  insertCollection( mSelectedRecipients );
+  rebuildAllRecipientsList();
 }
 
 void RecipientsPicker::insertAddressBook( KABC::AddressBook *addressbook )
@@ -454,12 +476,13 @@
       RecipientItem *item = new RecipientItem;
 #endif
       item->setAddressee( *it, *it3 );
-      mAllRecipients->addItem( item );
 
       QMap<KABC::Resource *,RecipientsCollection *>::ConstIterator collIt;
       collIt = collectionMap.find( it->resource() );
       if ( collIt != collectionMap.end() ) {
         (*collIt)->addItem( item );
+      } else {
+        kDebug(5006) << "Collection for resource not found. shouldn't happen";
       }
 
       QStringList categories = (*it).categories();
@@ -470,6 +493,7 @@
         RecipientsCollection *collection;
         if ( catMapIt == categoryMap.end() ) {
           collection = new RecipientsCollection;
+          collection->setReferenceContainer( true );
           collection->setTitle( *catIt );
           categoryMap.insert( *catIt, collection );
         } else {
@@ -490,33 +514,31 @@
     insertCollection( *it3 );
   }
 
+  insertDistributionLists();
+  rebuildAllRecipientsList();
   updateList();
 }
 
 void RecipientsPicker::insertDistributionLists()
 {
-  RecipientsCollection *collection = new RecipientsCollection;
-  collection->setTitle( i18n("Distribution Lists") );
-
+  mDistributionLists->deleteAll();
+  
 #ifdef KDEPIM_NEW_DISTRLISTS
   QList<KPIM::DistributionList> lists = KPIM::DistributionList::allDistributionLists( mAddressBook );
   for ( int i = 0; i < lists.count(); ++i ) {
     RecipientItem *item = new RecipientItem( mAddressBook );
     item->setDistributionList( lists[ i ] );
-    mAllRecipients->addItem( item );
-    collection->addItem( item );
+    mDistributionLists->addItem( item );
   }
 #else
   QList<KABC::DistributionList*> lists = mAddressBook->allDistributionLists();
   foreach ( KABC::DistributionList *list, lists ) {
     RecipientItem *item = new RecipientItem;
     item->setDistributionList( list );
-    mAllRecipients->addItem( item );
-    collection->addItem( item );
+    mDistributionLists->addItem( item );
   }
 #endif
-
-  insertCollection( collection );
+  
 }
 
 void RecipientsPicker::insertRecentAddresses()
@@ -536,9 +558,6 @@
     RecipientItem *item = new RecipientItem;
 #endif
     item->setAddressee( *it, (*it).preferredEmail() );
-    if ( !mAllRecipients->hasEquivalentItem( item ) ) {
-      mAllRecipients->addItem( item );
-    }
     collection->addItem( item );
   }
 
@@ -547,11 +566,17 @@
 
 void RecipientsPicker::insertCollection( RecipientsCollection *coll )
 {
-  int index = mCollectionMap.count();
-
-  kDebug(5006) <<"RecipientsPicker::insertCollection()" << coll->title()
-    << "index:" << index;
-
+  int index = 0;
+  QMap<int,RecipientsCollection *>::ConstIterator it;
+  for (it = mCollectionMap.begin(); it != mCollectionMap.end(); ++it) {
+    if ( (*it)->title() == coll->title() ) {
+      delete *it;
+      mCollectionMap.replace( index, coll );
+      return;
+    }
+    index++;
+  }
+  
   mCollectionCombo->insertItem( index, coll->title() );
   mCollectionMap.insert( index, coll );
 }
@@ -570,30 +595,42 @@
 
 void RecipientsPicker::setRecipients( const Recipient::List &recipients )
 {
-  RecipientItem::List allRecipients = mAllRecipients->items();
-  RecipientItem::List::ConstIterator itAll;
-  for( itAll = allRecipients.begin(); itAll != allRecipients.end(); ++itAll ) {
-    (*itAll)->setRecipientType( QString() );
-  }
+  mSelectedRecipients->deleteAll();
 
-  mSelectedRecipients->clear();
-
   Recipient::List::ConstIterator it;
   for( it = recipients.begin(); it != recipients.end(); ++it ) {
     RecipientItem *item = 0;
-    for( itAll = allRecipients.begin(); itAll != allRecipients.end(); ++itAll ) {
-      if ( (*itAll)->recipient() == (*it).email() ) {
-        (*itAll)->setRecipientType( (*it).typeLabel() );
-        item = *itAll;
+
+    // if recipient is a distribution list, create
+    // a detached copy.
+    RecipientItem::List items = mDistributionLists->items();
+    RecipientItem::List::ConstIterator distIt;
+#ifdef KDEPIM_NEW_DISTRLISTS
+    for ( distIt = items.begin(); distIt != items.end(); ++distIt ) {
+      if ( (*it).email() == (*distIt)->name() ) {
+        item = new RecipientItem( mAddressBook );
+        item->setDistributionList( (*distIt)->distributionList() );
       }
     }
+#else
+    for ( distIt = items.begin(); distIt != items.end(); ++distIt ) {
+      if ( (*it).email() == (*distIt)->name() ) {
+        item = new RecipientItem();
+        item->setDistributionList( (*distIt)->distributionList() );
+      }
+    }
+#endif
+    
     if ( !item ) {
       KABC::Addressee a;
       QString name;
       QString email;
+
       KABC::Addressee::parseEmailAddress( (*it).email(), name, email );
       a.setNameFromString( name );
       a.insertEmail( email );
+    
+      kDebug(5006) << "parsed recipient, name =" << name << "email = " << email;
 
 #ifdef KDEPIM_NEW_DISTRLISTS
       item = new RecipientItem( mAddressBook );
@@ -601,9 +638,9 @@
       item = new RecipientItem;
 #endif
       item->setAddressee( a, a.preferredEmail() );
-      item->setRecipientType( (*it).typeLabel() );
-      mAllRecipients->addItem( item );
     }
+    
+    item->setRecipientType( (*it).typeLabel() );
     mSelectedRecipients->addItem( item );
   }
 
@@ -612,7 +649,6 @@
 
 void RecipientsPicker::setDefaultButton( QPushButton *button )
 {
-//  button->setText( "<qt><b>" + button->text() + "</b></qt>" );
   button->setDefault( true );
 }
 
@@ -624,6 +660,27 @@
   mBccButton->setDefault( type == Recipient::Bcc );
 }
 
+void RecipientsPicker::rebuildAllRecipientsList()
+{
+  mAllRecipients->clear();
+
+  QMap<int,RecipientsCollection *>::ConstIterator it;
+  for( it = mCollectionMap.begin(); it != mCollectionMap.end(); ++it ) {
+    // skip self
+    if ( (*it) == mAllRecipients )
+      continue;
+
+    kDebug(5006) << "processing collection" << (*it)->title();
+
+    RecipientItem::List coll = (*it)->items();
+
+    RecipientItem::List::ConstIterator rcptIt;
+    for ( rcptIt = coll.begin(); rcptIt != coll.end(); ++rcptIt ) {
+      mAllRecipients->addItem( *rcptIt );
+    }
+  }
+}
+
 void RecipientsPicker::updateList()
 {
   mRecipientList->clear();
@@ -633,9 +690,15 @@
   RecipientItem::List items = coll->items();
   RecipientItem::List::ConstIterator it;
   for( it = items.begin(); it != items.end(); ++it ) {
+    if ( coll != mSelectedRecipients ) {
+      RecipientItem *selItem = mSelectedRecipients->getEquivalentItem(*it);
+      if (selItem) {
+        (*it)->setRecipientType( selItem->recipientType() );
+      }
+    }
     RecipientViewItem *newItem = new RecipientViewItem( *it, mRecipientList );
     for ( int i = 0; i < mRecipientList->columnCount(); i++ )
-      newItem->setToolTip( i, newItem->recipientItem()->toolTip() );
+      newItem->setToolTip( i, newItem->recipientItem()->tooltip() );
     mRecipientList->addTopLevelItem( newItem );
   }
 


_______________________________________________
KDE PIM mailing list kde-pim@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