Bug 122218

Summary: [PATCH] kmail add extra address
Product: [Unmaintained] kmail Reporter: Jerry Yau <jerry>
Component: generalAssignee: kdepim bugs <kdepim-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: l.lunak
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: RedHat Enterprise Linux   
OS: Linux   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: Uses visible | selected iterators

Description Jerry Yau 2006-02-18 15:20:14 UTC
Version:            (using KDE KDE 3.5.1)
Installed from:    RedHat RPMs
OS:                Linux

When I open a new email and then I use select button to select recipient. It appear a select recipient windows. I type a key word in search field in select recipient windows and then I get 4 recipients. I select these 4 recipients and then I press  Add as To button. A magical thing happen, ther are 36 recipients in kmail to field. It meas after I press send mail button, 36 people will receive this mail.
Comment 1 Philip Rodrigues 2006-02-18 18:57:32 UTC
Confirmed on r504793. The problem is that Shift-click to select a range includes those items that are hidden by the search. An example:

Address book contains:
aPhil
Bill
zPhil
Enter 'phil' in the search bar. Only "aPhil" and "zPhil" appear. Shift-click to select both, then "Add as to". All *three* names are added.

I suspect this is a problem with the widget rather than KMail.
Comment 2 Philip Rodrigues 2006-02-18 19:02:59 UTC
...and is almost certainly a manifestation of the same thing as bug 122158
Comment 3 Lubos Lunak 2006-02-20 15:23:07 UTC
The ksysguard bug #122158 was easily fixable by using QListViewItemIterator::Visible as flag when iterating over the items.
Comment 4 Ismail Onur Filiz 2006-03-05 13:52:14 UTC
Created attachment 14975 [details]
Uses visible | selected iterators

Wow, thanks for the pointer Lubos. Please review the attached patch which
solves the problem. It applies to recipientspicker.cpp tagged as 3.5.1.
Comment 5 Till Adam 2006-03-06 09:26:37 UTC
Patch looks correct, please commit.
Comment 6 Ismail Onur Filiz 2006-03-06 10:32:30 UTC
SVN commit 516198 by onurf:

Fix bug #122218 where a shift-select in a filtered recipients picker results in non-visible contacts to be added as recipients as well.

BUG: 122218



 M  +13 -16    recipientspicker.cpp  


--- branches/KDE/3.5/kdepim/kmail/recipientspicker.cpp #516197:516198
@@ -613,13 +613,11 @@
   kdDebug() << "RecipientsPicker::pick " << int( type ) << endl;
 
   int count = 0;
-  QListViewItem *viewItem;
-  for( viewItem = mRecipientList->firstChild(); viewItem;
-       viewItem = viewItem->nextSibling() ) {
-    if ( viewItem->isSelected() ) {
+  QListViewItemIterator it( mRecipientList , 
+            QListViewItemIterator::Visible | QListViewItemIterator::Selected );
+  for ( ; it.current(); ++it )
       ++count;
-    }
-  }
+
   if ( count > GlobalSettings::self()->maximumRecipients() ) {
     KMessageBox::sorry( this,
         i18n("You selected 1 recipient. The maximum supported number of "
@@ -630,16 +628,15 @@
     return;
   }
 
- for( viewItem = mRecipientList->firstChild(); viewItem;
-       viewItem = viewItem->nextSibling() ) {
-    if ( viewItem->isSelected() ) {
-      RecipientViewItem *item = static_cast<RecipientViewItem *>( viewItem );
-      if ( item ) {
-        RecipientItem *i = item->recipientItem();
-        Recipient r = i->recipient();
-        r.setType( type );
-        emit pickedRecipient( r );
-      }
+  it = QListViewItemIterator( mRecipientList , 
+            QListViewItemIterator::Visible | QListViewItemIterator::Selected );
+  for ( ; it.current(); ++it ) {
+    RecipientViewItem *item = static_cast<RecipientViewItem *>( it.current() );
+    if ( item ) {
+      RecipientItem *i = item->recipientItem();
+      Recipient r = i->recipient();
+      r.setType( type );
+      emit pickedRecipient( r );
     }
   }
   close();
Comment 7 Jerry Yau 2006-03-07 09:52:11 UTC
Thanks. After applying the patch, the recipient problem had bee fixed. But there is no way to select some address books in "address book field" in Select Recipient windows. For example : I can't select family address book when I just want to send email to my family and there are some records in my family address book. 
Comment 8 Ismail Onur Filiz 2006-03-07 18:41:05 UTC
Could you file a new wish for that, if that doesn't exist already? Thanks.