Bug 117118 - composer kaddressbook no adresses at first launch
Summary: composer kaddressbook no adresses at first launch
Status: RESOLVED FIXED
Alias: None
Product: kmail
Classification: Unmaintained
Component: composer (show other bugs)
Version: 1.8.2
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-26 23:57 UTC by Wolfgang Binder
Modified: 2007-09-14 12:17 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Load adresses sync (458 bytes, patch)
2006-01-07 22:49 UTC, Bram Schoenmakers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Binder 2005-11-26 23:57:45 UTC
Version:           1.8.2 (using KDE KDE 3.4.2)
Installed from:    SuSE RPMs
OS:                Linux

when kontact is launched, composer cannot find addressbook-entries except recent entries. The full addressbook is only shown after a 2nd launch of composer.
Comment 1 Bram Schoenmakers 2006-01-07 21:40:44 UTC
I see the same bug happening with KMail in the 3.5 branch (7 January 2006).
Comment 2 Bram Schoenmakers 2006-01-07 22:49:27 UTC
Created attachment 14176 [details]
Load adresses sync

Just sent this patch to kde-pim@kde.org for approval. It loads addresses in
sync instead of async. It solves the problem anyhow.
Comment 3 Bram Schoenmakers 2006-01-13 20:38:27 UTC
SVN commit 497767 by bram:

Fix bug 117118: composer kaddressbook no adresses at first launch

Update the list again once the resource is loaded.

BUG:117118



 M  +23 -15    recipientspicker.cpp  
 M  +7 -1      recipientspicker.h  


--- branches/KDE/3.5/kdepim/kmail/recipientspicker.cpp #497766:497767
@@ -27,7 +27,6 @@
 
 #include <klistview.h>
 #include <klocale.h>
-#include <kabc/stdaddressbook.h>
 #include <kabc/resource.h>
 #include <kiconloader.h>
 #include <kdialog.h>
@@ -324,6 +323,13 @@
   buttonLayout->addWidget( closeButton );
   connect( closeButton, SIGNAL( clicked() ), SLOT( close() ) );
 
+  {
+    using namespace KABC;
+    mAddressBook = KABC::StdAddressBook::self( true );
+    connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook * ) ),
+             this, SLOT( insertAddressBook( AddressBook * ) ) );
+  }
+
   initCollections();
 
   mCollectionCombo->setCurrentItem( 0 );
@@ -355,8 +361,21 @@
 
 void RecipientsPicker::initCollections()
 {
-  KABC::StdAddressBook *addressbook = KABC::StdAddressBook::self( true );
+  mAllRecipients = new RecipientsCollection;
+  mAllRecipients->setTitle( i18n("All") );
+  insertCollection( mAllRecipients );
 
+  insertDistributionLists();
+
+  insertRecentAddresses();
+
+  mSelectedRecipients = new RecipientsCollection;
+  mSelectedRecipients->setTitle( i18n("Selected Recipients") );
+  insertCollection( mSelectedRecipients );
+}
+
+void RecipientsPicker::insertAddressBook( KABC::AddressBook *addressbook )
+{
   QMap<KABC::Resource *,RecipientsCollection *> collectionMap;
 
   QPtrList<KABC::Resource> resources = addressbook->resources();
@@ -369,9 +388,6 @@
 
   QMap<QString,RecipientsCollection *> categoryMap;
 
-  mAllRecipients = new RecipientsCollection;
-  mAllRecipients->setTitle( i18n("All") );
-
   KABC::AddressBook::Iterator it;
   for( it = addressbook->begin(); it != addressbook->end(); ++it ) {
     QStringList emails = (*it).emails();
@@ -405,8 +421,6 @@
     }
   }
 
-  insertCollection( mAllRecipients );
-
   QMap<KABC::Resource *,RecipientsCollection *>::ConstIterator it2;
   for( it2 = collectionMap.begin(); it2 != collectionMap.end(); ++it2 ) {
     insertCollection( *it2 );
@@ -416,14 +430,8 @@
   for( it3 = categoryMap.begin(); it3 != categoryMap.end(); ++it3 ) {
     insertCollection( *it3 );
   }
-
-  insertDistributionLists();
-
-  insertRecentAddresses();
-
-  mSelectedRecipients = new RecipientsCollection;
-  mSelectedRecipients->setTitle( i18n("Selected Recipients") );
-  insertCollection( mSelectedRecipients );
+  
+  updateList();
 }
 
 void RecipientsPicker::insertDistributionLists()
--- branches/KDE/3.5/kdepim/kmail/recipientspicker.h #497766:497767
@@ -26,6 +26,7 @@
 #include <klistview.h>
 #include <klistviewsearchline.h>
 #include <kabc/addressee.h>
+#include <kabc/stdaddressbook.h>
 
 #include <qwidget.h>
 #include <qdialog.h>
@@ -133,6 +134,8 @@
     void keyPressEvent( QKeyEvent * );
 };
 
+using namespace KABC;
+
 class RecipientsPicker : public QDialog
 {
     Q_OBJECT
@@ -172,8 +175,11 @@
     void slotPicked();
     void setFocusList();
     void resetSearch();
-
+    void insertAddressBook( AddressBook * );
+    
   private:
+    KABC::StdAddressBook *mAddressBook;
+      
     QComboBox *mCollectionCombo;
     KListView *mRecipientList;
     KListViewSearchLine *mSearchLine;