void KOEditorDetails::updateCurrentItem()
{
    AttendeeListItem *item = static_cast<AttendeeListItem*>( mListView->selectedItem() );
    if ( item ) {
        item->updateItem();
    }
}
Example #2
0
KCal::Attendee * KOEditorDetails::currentAttendee() const
{
  QListViewItem *item = mListView->selectedItem();
  AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
  if ( !aItem )
    return 0;
  return aItem->data();
}
Q3ListViewItem *KOEditorDetails::hasExampleAttendee() const
{
    for ( Q3ListViewItemIterator it( mListView ); it.current(); ++it ) {
        AttendeeListItem *item = static_cast<AttendeeListItem*>( it.current() );
        Attendee *attendee = item->data();
        Q_ASSERT( attendee );
        if ( isExampleAttendee( attendee ) ) {
            return item;
        }
    }
    return 0;
}
Example #4
0
void KOEditorDetails::changeStatusForMe(Attendee::PartStat status)
{
  const QStringList myEmails = KOPrefs::instance()->allEmails();
  for ( QListViewItemIterator it( mListView ); it.current(); ++it ) {
    AttendeeListItem *item = static_cast<AttendeeListItem*>( it.current() );
    for ( QStringList::ConstIterator it2( myEmails.begin() ), end( myEmails.end() ); it2 != end; ++it2 ) {
      if ( item->data()->email() == *it2 ) {
        item->data()->setStatus( status );
        item->updateItem();
      }
    }
  }
}
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();
}
void KOEditorDetails::removeAttendee()
{
    AttendeeListItem *aItem = static_cast<AttendeeListItem *>( mListView->selectedItem() );
    if ( !aItem ) {
        return;
    }

    AttendeeListItem *nextSelectedItem = static_cast<AttendeeListItem*>( aItem->nextSibling() );
    if ( mListView->childCount() == 1 ) {
        nextSelectedItem = 0;
    }
    if ( mListView->childCount() > 1 && aItem == mListView->lastItem() ) {
        nextSelectedItem = static_cast<AttendeeListItem*>( mListView->firstChild() );
    }

    Attendee *delA = new Attendee( aItem->data()->name(), aItem->data()->email(),
                                   aItem->data()->RSVP(), aItem->data()->status(),
                                   aItem->data()->role(), aItem->data()->uid() );
    mDelAttendees.append( delA );

    delete aItem;

    if ( nextSelectedItem ) {
        mListView->setSelected( nextSelectedItem, true );
    }
    updateAttendeeInput();
    emit updateAttendeeSummary( mListView->childCount() );
}
Example #7
0
void KOEditorDetails::removeAttendee()
{
  AttendeeListItem *aItem =
      static_cast<AttendeeListItem *>( mListView->selectedItem() );
  if ( !aItem ) return;

  Attendee *delA = new Attendee( aItem->data()->name(), aItem->data()->email(),
                                 aItem->data()->RSVP(), aItem->data()->status(),
                                 aItem->data()->role(), aItem->data()->uid() );
  mdelAttendees.append( delA );

  delete aItem;

  updateAttendeeInput();
  emit updateAttendeeSummary( mListView->childCount() );
}