void KOEditorDetails::fillIncidence( Incidence *incidence )
{
    incidence->clearAttendees();
    QVector<Q3ListViewItem*> toBeDeleted;
    Q3ListViewItem *item;
    AttendeeListItem *a;
    for ( item = mListView->firstChild(); item; item = item->nextSibling() ) {
        a = (AttendeeListItem *)item;
        Attendee *attendee = a->data();
        Q_ASSERT( attendee );
        /* Check if the attendee is a distribution list and expand it */
        if ( attendee->email().isEmpty() ) {
            KPIM::DistributionList list =
                KPIM::DistributionList::findByName( KABC::StdAddressBook::self(), attendee->name() );
            if ( !list.isEmpty() ) {
                toBeDeleted.push_back( item ); // remove it once we are done expanding
                KPIM::DistributionList::Entry::List entries = list.entries( KABC::StdAddressBook::self() );
                KPIM::DistributionList::Entry::List::Iterator it( entries.begin() );
                while ( it != entries.end() ) {
                    KPIM::DistributionList::Entry &e = ( *it );
                    ++it;
                    // this calls insertAttendee, which appends
                    insertAttendeeFromAddressee( e.addressee, attendee );
                    // TODO: duplicate check, in case it was already added manually
                }
            }
        } else {
            bool skip = false;
            if ( attendee->email().endsWith( QLatin1String( "example.net" ) ) ) {
                if ( KMessageBox::warningYesNo(
                            this,
                            i18nc( "@info",
                                   "%1 does not look like a valid email address. "
                                   "Are you sure you want to invite this participant?",
                                   attendee->email() ),
                            i18nc( "@title", "Invalid Email Address" ) ) != KMessageBox::Yes ) {
                    skip = true;
                }
            }
            if ( !skip ) {
                incidence->addAttendee( new Attendee( *attendee ) );
            }
        }
    }

    KOAttendeeEditor::fillIncidence( incidence );

    // cleanup
    qDeleteAll( toBeDeleted );
    toBeDeleted.clear();
}
Beispiel #2
0
void KOEditorFreeBusy::writeEvent(KCal::Event * event)
{
  event->clearAttendees();
  QValueVector<FreeBusyItem*> toBeDeleted;
  for ( FreeBusyItem *item = static_cast<FreeBusyItem *>( mGanttView->firstChild() ); item;
        item = static_cast<FreeBusyItem*>( item->nextSibling() ) )
  {
    Attendee *attendee = item->attendee();
    Q_ASSERT( attendee );
    /* Check if the attendee is a distribution list and expand it */
    if ( attendee->email().isEmpty() ) {
      KPIM::DistributionList list =
        KPIM::DistributionList::findByName( KABC::StdAddressBook::self(), attendee->name() );
      if ( !list.isEmpty() ) {
        toBeDeleted.push_back( item ); // remove it once we are done expanding
        KPIM::DistributionList::Entry::List entries = list.entries( KABC::StdAddressBook::self() );
        KPIM::DistributionList::Entry::List::Iterator it( entries.begin() );
        while ( it != entries.end() ) {
          KPIM::DistributionList::Entry &e = ( *it );
          ++it;
          // this calls insertAttendee, which appends
          insertAttendeeFromAddressee( e.addressee, attendee );
          // TODO: duplicate check, in case it was already added manually
        }
      }
    } else {
      bool skip = false;
      if ( attendee->email().endsWith( "example.net" ) ) {
        if ( KMessageBox::warningYesNo( this, i18n("%1 does not look like a valid email address. "
                "Are you sure you want to invite this participant?").arg( attendee->email() ),
              i18n("Invalid email address") ) != KMessageBox::Yes ) {
          skip = true;
        }
      }
      if ( !skip ) {
        event->addAttendee( new Attendee( *attendee ) );
      }
    }
  }

  KOAttendeeEditor::writeEvent( event );

  // cleanup
  QValueVector<FreeBusyItem*>::iterator it;
  for( it = toBeDeleted.begin(); it != toBeDeleted.end(); ++it ) {
    delete *it;
  }
}