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

List:       kde-commits
Subject:    branches/kdepim/enterprise/kdepim/korganizer
From:       Allen Winter <winter () kde ! org>
Date:       2010-04-29 22:20:18
Message-ID: 20100429222018.4D9A1AC8A7 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1120766 by winterz:

if selecting a distribution list, expand it and use it in the attendees list.
kolab/issue4119
MERGE: trunk



 M  +58 -14    koattendeeeditor.cpp  
 M  +4 -4      koattendeeeditor.h  
 M  +5 -0      koeditordetails.cpp  
 M  +2 -1      koeditordetails.h  


--- branches/kdepim/enterprise/kdepim/korganizer/koattendeeeditor.cpp #1120765:1120766
@@ -18,6 +18,8 @@
     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
 
+#include <config.h> // for KDEPIM_NEW_DISTRLISTS
+
 #include "koattendeeeditor.h"
 #include "koprefs.h"
 #include "koglobals.h"
@@ -32,6 +34,13 @@
 
 #include <libemailfunctions/email.h>
 
+#ifdef KDEPIM_NEW_DISTRLISTS
+#include "distributionlist.h"
+#else
+#include <kabc/distributionlist.h>
+#endif
+#include <kabc/stdaddressbook.h>
+
 #include <kiconloader.h>
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -102,6 +111,7 @@
   mNameEdit->installEventFilter( this );
   connect( mNameEdit, SIGNAL( textChanged( const QString & ) ),
            SLOT( updateAttendee() ) );
+  connect( mNameEdit, SIGNAL(returnPressed()), SLOT(expandAttendee()) );
   topLayout->addMultiCellWidget( mNameEdit, 0, 0, 1, 2 );
 
   whatsThis = i18n("Edits the role of the attendee selected "
@@ -207,21 +217,7 @@
   }
   delete dia;
   return;
-#if 0
-    // old code
-    KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this);
-    if (!a.isEmpty()) {
-        // If this is myself, I don't want to get a response but instead
-        // assume I will be available
-        bool myself = KOPrefs::instance()->thatIsMe( a.preferredEmail() );
-        KCal::Attendee::PartStat partStat =
-            myself ? KCal::Attendee::Accepted : KCal::Attendee::NeedsAction;
-        insertAttendee( new Attendee( a.realName(), a.preferredEmail(),
-                                      !myself, partStat,
-                                      KCal::Attendee::ReqParticipant, a.uid() ) );
-    }
 #endif
-#endif
 }
 
 void KOAttendeeEditor::insertAttendeeFromAddressee(const KABC::Addressee &a, const Attendee * at)
@@ -370,6 +366,17 @@
   mDelegateLabel->setText( QString() );
 }
 
+void KOAttendeeEditor::expandAttendee()
+{
+  KABC::Addressee::List aList = expandDistList( mNameEdit->text() );
+  if ( !aList.isEmpty() ) {
+    for ( KABC::Addressee::List::iterator itr = aList.begin(); itr != aList.end(); ++itr ) {
+      insertAttendeeFromAddressee( (*itr) );
+    }
+    removeAttendee( currentAttendee() );
+  }
+}
+
 void KOAttendeeEditor::updateAttendee()
 {
   Attendee *a = currentAttendee();
@@ -530,4 +537,41 @@
     return false;
 }
 
+KABC::Addressee::List KOAttendeeEditor::expandDistList( const QString &text )  const
+{
+  KABC::Addressee::List aList;
+  KABC::AddressBook *abook = KABC::StdAddressBook::self( true );
+
+#ifdef KDEPIM_NEW_DISTRLISTS
+  const QValueList<KPIM::DistributionList::Entry> eList =
+    KPIM::DistributionList::findByName( abook, text ).entries( abook );
+  QValueList<KPIM::DistributionList::Entry>::ConstIterator eit;
+  for ( eit = eList.begin(); eit != eList.end(); ++eit ) {
+    KABC::Addressee a = (*eit).addressee;
+    if ( !a.preferredEmail().isEmpty() && aList.find( a ) == aList.end() ) {
+      aList.append( a ) ;
+    }
+  }
+
+#else
+  KABC::DistributionListManager manager( abook );
+  manager.load();
+  const QStringList dList = manager.listNames();
+  for ( QStringList::ConstIterator it = dList.begin(); it != dList.end(); ++it ) {
+    if ( (*it) == text ) {
+      const QValueList<KABC::DistributionList::Entry> eList = manager.list( *it )->entries();
+      QValueList<KABC::DistributionList::Entry>::ConstIterator eit;
+      for ( eit = eList.begin(); eit != eList.end(); ++eit ) {
+        KABC::Addressee a = (*eit).addressee;
+        if ( !a.preferredEmail().isEmpty() && aList.find( a ) == aList.end() ) {
+          aList.append( a ) ;
+        }
+      }
+    }
+  }
+#endif
+  return aList;
+}
+
+
 #include "koattendeeeditor.moc"
--- branches/kdepim/enterprise/kdepim/korganizer/koattendeeeditor.h #1120765:1120766
@@ -23,6 +23,7 @@
 
 #include <qwidget.h>
 #include <libkcal/attendee.h>
+#include <kabc/addressee.h>
 
 class QBoxLayout;
 class QComboBox;
@@ -36,10 +37,6 @@
   class AddresseeLineEdit;
 }
 
-namespace KABC {
-  class Addressee;
-}
-
 namespace KCal {
   class Incidence;
 }
@@ -54,6 +51,7 @@
     KOAttendeeEditor( QWidget *parent, const char *name = 0 );
 
     virtual void insertAttendee( KCal::Attendee* attendee, bool fetchFB = true ) = 0;
+    virtual void removeAttendee( KCal::Attendee *attendee ) = 0;
 
     virtual void readEvent( KCal::Incidence *incidence );
     virtual void writeEvent( KCal::Incidence *incidence );
@@ -97,6 +95,7 @@
     void updateAttendeeInput();
     void clearAttendeeInput();
     void fillAttendeeInput( KCal::Attendee *a );
+    void expandAttendee();
     void updateAttendee();
 
   protected:
@@ -120,6 +119,7 @@
     QPtrList<KCal::Attendee> mnewAttendees;
 
   private:
+    KABC::Addressee::List expandDistList( const QString &text ) const;
     bool mDisableItemUpdate;
 };
 
--- branches/kdepim/enterprise/kdepim/korganizer/koeditordetails.cpp #1120765:1120766
@@ -271,6 +271,11 @@
   emit updateAttendeeSummary( mListView->childCount() );
 }
 
+void KOEditorDetails::removeAttendee( Attendee *a )
+{
+  Q_UNUSED( a );
+}
+
 void KOEditorDetails::setDefaults()
 {
   mRsvpButton->setChecked( true );
--- branches/kdepim/enterprise/kdepim/korganizer/koeditordetails.h #1120765:1120766
@@ -95,7 +95,8 @@
     /** Returns whether at least one attendee was added */
     bool hasAttendees();
 
-    void insertAttendee( Attendee*, bool goodEmailAddress = true );
+    void insertAttendee( Attendee *a, bool goodEmailAddress = true );
+    void removeAttendee( Attendee *a );
 
   protected slots:
     void removeAttendee();
[prev in list] [next in list] [prev in thread] [next in thread] 

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