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

List:       kde-commits
Subject:    KDE/kdepim/kaddressbook
From:       Tobias Koenig <tokoe () kde ! org>
Date:       2009-11-13 12:11:45
Message-ID: 1258114305.201881.15266.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1048476 by tokoe:

Allow the user to decide whether he wants to use
all contacts from a folder with or without the subfolders.

BUG: 214141


 M  +36 -9     contactselectionwidget.cpp  
 M  +2 -0      contactselectionwidget.h  


--- trunk/KDE/kdepim/kaddressbook/contactselectionwidget.cpp #1048475:1048476
@@ -23,11 +23,13 @@
 
 #include <akonadi/collectioncombobox.h>
 #include <akonadi/entitytreemodel.h>
+#include <akonadi/itemfetchjob.h>
 #include <akonadi/itemfetchscope.h>
 #include <klocale.h>
 
 #include <QtCore/QAbstractItemModel>
 #include <QtGui/QButtonGroup>
+#include <QtGui/QCheckBox>
 #include <QtGui/QGridLayout>
 #include <QtGui/QGroupBox>
 #include <QtGui/QItemSelectionModel>
@@ -42,9 +44,12 @@
 
   mSelectedContactsButton->setEnabled( mSelectionModel->hasSelection() );
   mAddressBookSelection->setEnabled( false );
+  mAddressBookSelectionRecursive->setEnabled( false );
 
   connect( mAddressBookContactsButton, SIGNAL( toggled( bool ) ),
            mAddressBookSelection, SLOT( setEnabled( bool ) ) );
+  connect( mAddressBookContactsButton, SIGNAL( toggled( bool ) ),
+           mAddressBookSelectionRecursive, SLOT( setEnabled( bool ) ) );
 
   // apply default configuration
   if ( mSelectionModel->hasSelection() )
@@ -95,6 +100,7 @@
   mAddressBookSelection = new Akonadi::CollectionComboBox;
   mAddressBookSelection->setMimeTypeFilter( QStringList() << KABC::Addressee::mimeType() );
   mAddressBookSelection->setAccessRightsFilter( Akonadi::Collection::ReadOnly );
+  mAddressBookSelectionRecursive = new QCheckBox( i18n( "Include Subfolders" ) );
 
   group->addButton( mAllContactsButton );
   group->addButton( mSelectedContactsButton );
@@ -102,9 +108,15 @@
 
   boxLayout->addWidget( mAllContactsButton, 0, 0, 1, 2 );
   boxLayout->addWidget( mSelectedContactsButton, 1, 0, 1, 2 );
-  boxLayout->addWidget( mAddressBookContactsButton, 2, 0 );
-  boxLayout->addWidget( mAddressBookSelection, 2, 1 );
+  boxLayout->addWidget( mAddressBookContactsButton, 2, 0, Qt::AlignTop );
 
+  QVBoxLayout *addressBookLayout = new QVBoxLayout;
+  addressBookLayout->setMargin( 0 );
+  addressBookLayout->addWidget( mAddressBookSelection );
+  addressBookLayout->addWidget( mAddressBookSelectionRecursive );
+
+  boxLayout->addLayout( addressBookLayout, 2, 1 );
+
   layout->addWidget( groupBox );
   layout->addStretch( 1 );
 }
@@ -151,17 +163,32 @@
     return contacts;
   }
 
-  Akonadi::RecursiveItemFetchJob *job = new Akonadi::RecursiveItemFetchJob( collection );
-  job->fetchScope().fetchFullPayload();
+  if ( mAddressBookSelectionRecursive->isChecked() ) {
+    Akonadi::RecursiveItemFetchJob *job = new Akonadi::RecursiveItemFetchJob( collection );
+    job->fetchScope().fetchFullPayload();
 
-  if ( job->exec() ) {
-    const Akonadi::Item::List items = job->items();
+    if ( job->exec() ) {
+      const Akonadi::Item::List items = job->items();
 
-    foreach ( const Akonadi::Item &item, items ) {
-      if ( item.hasPayload<KABC::Addressee>() ) {
-        contacts.append( item.payload<KABC::Addressee>() );
+      foreach ( const Akonadi::Item &item, items ) {
+        if ( item.hasPayload<KABC::Addressee>() ) {
+          contacts.append( item.payload<KABC::Addressee>() );
+        }
       }
     }
+  } else {
+    Akonadi::ItemFetchJob *job = new Akonadi::ItemFetchJob( collection );
+    job->fetchScope().fetchFullPayload();
+
+    if ( job->exec() ) {
+      const Akonadi::Item::List items = job->items();
+
+      foreach ( const Akonadi::Item &item, items ) {
+        if ( item.hasPayload<KABC::Addressee>() ) {
+          contacts.append( item.payload<KABC::Addressee>() );
+        }
+      }
+    }
   }
 
   return contacts;
--- trunk/KDE/kdepim/kaddressbook/contactselectionwidget.h #1048475:1048476
@@ -25,6 +25,7 @@
 #include <kabc/addressee.h>
 
 class QAbstractItemModel;
+class QCheckBox;
 class QItemSelectionModel;
 class QLabel;
 class QRadioButton;
@@ -86,6 +87,7 @@
     QRadioButton *mSelectedContactsButton;
     QRadioButton *mAddressBookContactsButton;
     Akonadi::CollectionComboBox *mAddressBookSelection;
+    QCheckBox *mAddressBookSelectionRecursive;
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

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