Ejemplo n.º 1
0
bool ResourceGroupwise::asyncSave( Ticket* )
{
  if ( !mServer->login() ) return false;

  KABC::Addressee::List::Iterator it;

  KABC::Addressee::List addedList = addedAddressees();
  for ( it = addedList.begin(); it != addedList.end(); ++it ) {
    if ( mServer->insertAddressee( mPrefs->writeAddressBook(), *it ) ) {
      clearChange( *it );
      idMapper().setRemoteId( (*it).uid(), (*it).custom( "GWRESOURCE", "UID" ) );
    }
  }

  KABC::Addressee::List changedList = changedAddressees();
  for ( it = changedList.begin(); it != changedList.end(); ++it ) {
    if ( mServer->changeAddressee( *it ) )
      clearChange( *it );
  }

  KABC::Addressee::List deletedList = deletedAddressees();
  for ( it = deletedList.begin(); it != deletedList.end(); ++it ) {
    if ( mServer->removeAddressee( *it ) )
      clearChange( *it );
  }

  if ( appIsWhiteListedForSAB() )
  saveCache();

  mServer->logout();

  return true;
}
Ejemplo n.º 2
0
void DistributionListDialog::setRecipients( const Recipient::List &recipients )
{
  Recipient::List::ConstIterator it;
  for( it = recipients.begin(); it != recipients.end(); ++it ) {
    QStringList emails = KPIM::splitEmailAddrList( (*it).email() );
    QStringList::ConstIterator it2;
    for( it2 = emails.begin(); it2 != emails.end(); ++it2 ) {
      QString name;
      QString email;
      KABC::Addressee::parseEmailAddress( *it2, name, email );
      if ( !email.isEmpty() ) {
        DistributionListItem *item = new DistributionListItem( mRecipientsList );
        KABC::Addressee::List addressees =
          KABC::StdAddressBook::self( true )->findByEmail( email );
        if ( addressees.isEmpty() ) {
          KABC::Addressee a;
          a.setNameFromString( name );
          a.insertEmail( email );
          item->setTransientAddressee( a, email );
          item->setOn( true );
        } else {
          KABC::Addressee::List::ConstIterator it3;
          for( it3 = addressees.begin(); it3 != addressees.end(); ++it3 ) {
            item->setAddressee( *it3, email );
            if ( it3 == addressees.begin() ) item->setOn( true );
          }
        }
      }
    }
  }
}
Ejemplo n.º 3
0
void KOAttendeeListView::dropEvent( QDropEvent *e )
{
#ifndef KORG_NODND
  QString text;
  QString vcards;

#ifndef KORG_NOKABC
  if ( KVCardDrag::decode( e, vcards ) ) {
    KABC::VCardConverter converter;

    KABC::Addressee::List list = converter.parseVCards( vcards );
    KABC::Addressee::List::Iterator it;
    for ( it = list.begin(); it != list.end(); ++it ) {
      QString em( (*it).fullEmail() );
      if (em.isEmpty()) {
        em=(*it).realName();
      }
      addAttendee( em );
    }
  } else
#endif // KORG_NOKABC
  if (QTextDrag::decode(e,text)) {
    kdDebug(5850) << "Dropped : " << text << endl;
    QStringList emails = QStringList::split(",",text);
    for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
      addAttendee(*it);
    }
  }
#endif //KORG_NODND
}
Ejemplo n.º 4
0
void VCardViewerDialog::updateView()
{
  mView->setAddressee( *mIt );

  KABC::Addressee::List::Iterator it = mIt;
  actionButton( Apply )->setEnabled( (++it) != mContacts.end() );
}
Ejemplo n.º 5
0
bool DetailledPrintStyle::printEntries( const KABC::Addressee::List &contacts,
                                        KPrinter *printer,
                                        QPainter *painter,
                                        const QRect &window)
{
  QRect brect;
  int ypos = 0, count = 0;

  KABC::Addressee::List::ConstIterator it;
  for ( it = contacts.begin(); it != contacts.end(); ++it ) {
    if ( !(*it).isEmpty() ) {
      // do a faked print to get the bounding rect:
      if ( !mPainter->printAddressee( *it, window, painter, ypos, true, &brect) ) {
        // it does not fit on the page beginning at ypos:
        printer->newPage();

        // WORK_TO_DO: this assumes the entry fits on the whole page
        // (dunno how to fix this without being illogical)
        ypos = 0;
      }

      mPainter->printAddressee( *it, window, painter, ypos, false, &brect );
      ypos += brect.height();
    }

    mPrintProgress->setProgress( (count++ * 100) / contacts.count() );
  }

  mPrintProgress->setProgress( 100 );

  return true;
}
Ejemplo n.º 6
0
void KOAttendeeEditor::openAddressBook()
{
#ifndef KORG_NOKABC
  KPIM::AddressesDialog *dia = new KPIM::AddressesDialog( this, "adddialog" );
  dia->setShowCC( false );
  dia->setShowBCC( false );
  if ( dia->exec() ) {
    KABC::Addressee::List aList = dia->allToAddressesNoDuplicates();
    for ( KABC::Addressee::List::iterator itr = aList.begin();
          itr != aList.end(); ++itr ) {
      insertAttendeeFromAddressee( (*itr) );
    }
  }
  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
}
Ejemplo n.º 7
0
    bool AddressbookHandler::addAddressees( KABC::Addressee::List& p_addresseeList )
    {
        bool ret = true;
        KABC::VCardConverter vCardConv;
        QString vCard;

        RRA_Uint32Vector* added_ids = rra_uint32vector_new();

        if ( p_addresseeList.begin() == p_addresseeList.end() ) {
            goto finish;
        }

        for (KABC::Addressee::List::Iterator it = p_addresseeList.begin();
                it != p_addresseeList.end(); ++it ) {
            incrementSteps();

            kdDebug(2120) << "Adding Contact on Device: " << (*it).uid() << endl;

            vCard = vCardConv.createVCard ( ( *it ) );

            uint32_t newObjectId = m_rra->putVCard( vCard, mTypeId, 0 );
            if (newObjectId == 0) {
                addErrorEntry((*it).realName());
                ret = false;
            }

            m_rra->markIdUnchanged( mTypeId, newObjectId );

            mUidHelper->addId("SynCEAddressbook",
                "RRA-ID-" + QString::number ( newObjectId, 16 ).rightJustify( 8, '0' ),
                (*it).uid());

            kdDebug(2120) << "    ID-Pair: KDEID: " << (*it).uid() << " DeviceID: " <<
                "RRA-ID-" + QString::number ( newObjectId, 16 ).rightJustify( 8, '0' ) << endl;

            rra_uint32vector_add(added_ids, newObjectId);

            KApplication::kApplication()->processEvents();
        }


    finish:
        m_rra->registerAddedObjects(mTypeId, added_ids);
        rra_uint32vector_destroy(added_ids, true);

        return ret;
    }
Ejemplo n.º 8
0
 void AddressbookHandler::insertIntoAddressBookSyncee(KSync::AddressBookSyncee *mAddressBookSyncee, KABC::Addressee::List &list, int state)
 {
     for(KABC::Addressee::List::Iterator it = list.begin(); it != list.end(); ++it) {
         KSync::AddressBookSyncEntry entry(*it, mAddressBookSyncee);
         entry.setState(state);
         mAddressBookSyncee->addEntry(entry.clone());
     }
 }
Ejemplo n.º 9
0
void VCardViewerDialog::slotUser1()
{
  mIt = mContacts.remove( mIt );

  if ( mIt == mContacts.end() )
    slotApply();

  updateView();
}
Ejemplo n.º 10
0
void VCardViewerDialog::slotUser2()
{
  mIt++;

  if ( mIt == mContacts.end() )
    slotApply();

  updateView();
}
Ejemplo n.º 11
0
    bool AddressbookHandler::removeAddressees ( KABC::Addressee::List& p_addresseeList )
    {
//        int errorCount = 0;
        bool ret = false;
        RRA_Uint32Vector* deleted_ids = rra_uint32vector_new();
        KABC::Addressee::List::Iterator it = p_addresseeList.begin();

        if ( p_addresseeList.begin() == p_addresseeList.end() ) {
            goto success;
        }

        setStatus("Erasing deleted Contacts");

        for ( ; it != p_addresseeList.end(); ++it ) {
            incrementSteps();

            QString kUid = mUidHelper->konnectorId("SynCEAddressbook", (*it).uid(), "---");

            if (kUid != "---") {
                kdDebug(2120) << "Removing Contact on Device: " << "ID-Pair: KDEID: " <<
                    (*it).uid() << " DeviceId: " << kUid << endl;

                if (!m_rra->deleteObject (mTypeId, getOriginalId( kUid ))) {
//                    if (errorCount++ == -1) {
//                        goto error;
//                    }
                }

                mUidHelper->removeId("SynCEAddressbook", kUid);
                rra_uint32vector_add(deleted_ids, getOriginalId( kUid ));
            }

            KApplication::kApplication()->processEvents();
        }

    success:
        ret = true;

//    error:
        m_rra->removeDeletedObjects(mTypeId, deleted_ids);
        rra_uint32vector_destroy(deleted_ids, true);
        return ret;
    }
Ejemplo n.º 12
0
QString AddresseeUtil::addresseesToEmails(const KABC::Addressee::List &addrList)
{
    QStringList emails;

    KABC::Addressee::List::ConstIterator it;
    for(it = addrList.begin(); it != addrList.end(); ++it)
        emails.append((*it).fullEmail());

    return emails.join(",");
}
Ejemplo n.º 13
0
bool ResourceGroupwareBase::asyncSave( Ticket* )
{
  if ( mUploadJob ) {
    // FIXME: If the user cancels, need to reset the mUploadJob variable to 0.
    kdWarning() << "Upload still in progress." << endl;
    return false;
  }

  mUploadJob = createUploadJob( mAdaptor );
  connect( mUploadJob, SIGNAL( result( KPIM::GroupwareJob * ) ),
    SLOT( slotUploadJobResult( KPIM::GroupwareJob * ) ) );

  KABC::Addressee::List addr;
  KABC::Addressee::List::Iterator it;
  KPIM::GroupwareUploadItem::List addedItems, changedItems, deletedItems;

  addr = addedAddressees();
  for( it = addr.begin(); it != addr.end(); ++it ) {
    addedItems.append( adaptor()->newUploadItem( *it,
                                           KPIM::GroupwareUploadItem::Added ) );
  }
  // TODO: Check if the item has changed on the server...
  // In particular, check if the version we based our change on is still current
  // on the server
  addr = changedAddressees();
  for( it = addr.begin(); it != addr.end(); ++it ) {
    changedItems.append( adaptor()->newUploadItem( *it,
                                         KPIM::GroupwareUploadItem::Changed ) );
  }
  addr = deletedAddressees();
  for( it = addr.begin(); it != addr.end(); ++it ) {
    deletedItems.append( adaptor()->newUploadItem( *it,
                                         KPIM::GroupwareUploadItem::Deleted ) );
  }

  mUploadJob->setAddedItems( addedItems );
  mUploadJob->setChangedItems( changedItems );
  mUploadJob->setDeletedItems( deletedItems );

  return true;
}
Ejemplo n.º 14
0
void KOrganizerPlugin::processDropEvent( QDropEvent *event )
{
  QString text;

  KABC::VCardConverter converter;
  if ( KVCardDrag::canDecode( event ) && KVCardDrag::decode( event, text ) ) {
    KABC::Addressee::List contacts = converter.parseVCards( text );
    KABC::Addressee::List::Iterator it;

    QStringList attendees;
    for ( it = contacts.begin(); it != contacts.end(); ++it ) {
      QString email = (*it).fullEmail();
      if ( email.isEmpty() )
        attendees.append( (*it).realName() + "<>" );
      else
        attendees.append( email );
    }

    interface()->openEventEditor( i18n( "Meeting" ), QString::null, QString::null,
                                  attendees );
    return;
  }

  if ( QTextDrag::decode( event, text ) ) {
    kdDebug(5602) << "DROP:" << text << endl;
    interface()->openEventEditor( text );
    return;
  }

  KPIM::MailList mails;
  if ( KPIM::MailListDrag::decode( event, mails ) ) {
    if ( mails.count() != 1 ) {
      KMessageBox::sorry( core(),
                          i18n("Drops of multiple mails are not supported." ) );
    } else {
      KPIM::MailSummary mail = mails.first();
      QString txt = i18n("From: %1\nTo: %2\nSubject: %3").arg( mail.from() )
                    .arg( mail.to() ).arg( mail.subject() );

      KTempFile tf;
      tf.setAutoDelete( true );
      QString uri = QString::fromLatin1("kmail:") + QString::number( mail.serialNumber() );
      tf.file()->writeBlock( event->encodedData( "message/rfc822" ) );
      tf.close();
      interface()->openEventEditor( i18n("Mail: %1").arg( mail.subject() ), txt,
                                    uri, tf.name(), QStringList(), "message/rfc822" );
    }
    return;
  }

  KMessageBox::sorry( core(), i18n("Cannot handle drop events of type '%1'.")
                              .arg( event->format() ) );
}
Ejemplo n.º 15
0
    bool AddressbookHandler::updateAddressees( KABC::Addressee::List& p_addresseeList )
    {
        bool ret = true;
        KABC::Addressee::List::Iterator it = p_addresseeList.begin();
        KABC::VCardConverter vCardConv;
        QString vCard;

        if ( p_addresseeList.begin() == p_addresseeList.end() ) {
            goto finish;
        }

        setStatus("Writing changed Contacts");

        for ( ; it != p_addresseeList.end(); ++it ) {
            incrementSteps();

            QString kUid = mUidHelper->konnectorId("SynCEAddressbook", (*it).uid(), "---");

            if (kUid != "---") {
                kdDebug(2120) << "Updating Contact on Device: " << "ID-Pair: KDEID: " <<
                    (*it).uid() << " DeviceId: " << kUid << endl;
                vCard = vCardConv.createVCard ( ( *it ) );
                uint32_t retId = m_rra->putVCard ( vCard, mTypeId, getOriginalId( kUid ) );
                if (retId == 0) {
                    addErrorEntry((*it).realName());
                    ret = false;
                }

                m_rra->markIdUnchanged( mTypeId, getOriginalId( kUid ) );
            }

            KApplication::kApplication()->processEvents();
        }

finish:
        return ret;
    }
Ejemplo n.º 16
0
void KOAttendeeEditor::openAddressBook()
{
  QPointer<KPIM::AddressesDialog> dia = new KPIM::AddressesDialog( this );
  dia->setShowCC( false );
  dia->setShowBCC( false );
  if ( dia->exec() == QDialog::Accepted ) {
    KABC::Addressee::List aList = dia->allToAddressesNoDuplicates();
    for ( KABC::Addressee::List::iterator itr = aList.begin();
          itr != aList.end(); ++itr ) {
      insertAttendeeFromAddressee( (*itr) );
    }
  }
  delete dia;
  return;
}
Ejemplo n.º 17
0
void ViewManager::dropped(QDropEvent *e)
{
    kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;

    // don't allow drops from our own drags
    if(e->source() == this)
        return;

    QString clipText, vcards;
    KURL::List urls;

    if(KURLDrag::decode(e, urls))
    {
        KURL::List::ConstIterator it = urls.begin();
        int c = urls.count();
        if(c > 1)
        {
            QString questionString = i18n("Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c);
            if(KMessageBox::questionYesNo(this, questionString, i18n("Import Contacts?"), i18n("Import"), i18n("Do Not Import")) == KMessageBox::Yes)
            {
                for(; it != urls.end(); ++it)
                    emit urlDropped(*it);
            }
        }
        else if(c == 1)
            emit urlDropped(*it);
    }
    else if(KVCardDrag::decode(e, vcards))
    {
        KABC::VCardConverter converter;

        const KABC::Addressee::List list = converter.parseVCards(vcards);
        KABC::Addressee::List::ConstIterator it;
        for(it = list.begin(); it != list.end(); ++it)
        {
            KABC::Addressee a = mCore->addressBook()->findByUid((*it).uid());
            if(a.isEmpty())      // not yet in address book
            {
                mCore->addressBook()->insertAddressee(*it);
                emit modified();
            }
        }

        mActiveView->refresh();
    }
}
Ejemplo n.º 18
0
QStringList KabcBridge::categories()
{
  KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
  KABC::Addressee::List addresses = addressBook->allAddressees();
  QStringList allcategories, aux;

  for ( KABC::Addressee::List::Iterator it = addresses.begin();
        it != addresses.end(); ++it ) {
    aux = ( *it ).categories();
    for ( QStringList::ConstIterator itAux = aux.constBegin();
          itAux != aux.constEnd(); ++itAux ) {
      // don't have duplicates in allcategories
      if ( !allcategories.contains( *itAux )  )
        allcategories += *itAux;
    }
  }
  return allcategories;
}
Ejemplo n.º 19
0
KABC::Addressee::List KAddressBookView::addressees()
{
    if(mFilter.isEmpty())
        return mCore->searchManager()->contacts();

    KABC::Addressee::List addresseeList;
    const KABC::Addressee::List contacts = mCore->searchManager()->contacts();

    KABC::Addressee::List::ConstIterator it;
    KABC::Addressee::List::ConstIterator contactsEnd(contacts.end());
    for(it = contacts.begin(); it != contactsEnd; ++it)
    {
        if(mFilter.filterAddressee(*it))
            addresseeList.append(*it);
    }

    return addresseeList;
}
Ejemplo n.º 20
0
void FritzBoxPhoneBook::attach(const KABC::Addressee::List contacts)
{
    KABC::Addressee::List::const_iterator contactI = contacts.begin();
    for ( ; contactI != contacts.end(); contactI++) {
//        kDebug() << "Now are "
//             << m_Contacts.size()
//             << " Contacts in List ";
        // If a Name has 3 work numbers or 5 Phones it is necessary to generate
        // 2 or more entrys of the same name eg "Björn Lässig (2)"
        int count = 1; // counts the necessary doubled Names

        FritzBoxPhoneBookContact fbContact(contactI->formattedName().simplified());

        KABC::PhoneNumber::List phoneNumbers = contactI->phoneNumbers();
        KABC::PhoneNumber::List::const_iterator phoneNumber = phoneNumbers.begin();
        for (; phoneNumber != phoneNumbers.end(); phoneNumber++) {
            FritzBoxPhoneNumber fbNumber(phoneNumber->number().simplified());
            if ( phoneNumber->type() & KABC::PhoneNumber::Fax ) continue;
            if ( phoneNumber->type() & KABC::PhoneNumber::Cell )
                fbNumber.setType(FritzBoxPhoneNumber::Mobile);
            if ( phoneNumber->type() & KABC::PhoneNumber::Home )
                fbNumber.setType(FritzBoxPhoneNumber::Home);
            if ( phoneNumber->type() & KABC::PhoneNumber::Work )
                fbNumber.setType(FritzBoxPhoneNumber::Work);
            // yes there is a bug, a number can have more than one Flag

            // @TODO find best numberType forthe label
            bool hasAdded = fbContact.addNumber(fbNumber);
            if (! hasAdded) {
                m_Contacts.addContact(fbContact);
                QString newName = contactI->formattedName().simplified() + " " + QString().number(count);
                count++;
                fbContact = FritzBoxPhoneBookContact(newName);
                hasAdded = fbContact.addNumber(fbNumber);
                if (! hasAdded)
                    kDebug() << "something really wicked happened";
            }
        }
        m_Contacts.addContact(fbContact);
    }

}
Ejemplo n.º 21
0
void KMFilterActionWithAddressWidget::slotAddrBook()
{
  KABC::Addressee::List lst = KABC::AddresseeDialog::getAddressees( this );

  if ( lst.empty() )
    return;

  QStringList addrList;

  for( KABC::Addressee::List::const_iterator it = lst.begin(); it != lst.end(); ++it )
    addrList << (*it).fullEmail();

  QString txt = mLineEdit->text().stripWhiteSpace();

  if ( !txt.isEmpty() ) {
    if ( !txt.endsWith( "," ) )
      txt += ", ";
    else
      txt += ' ';
  }

  mLineEdit->setText( txt + addrList.join(",") );
}
Ejemplo n.º 22
0
void SearchManager::search(const QString &pattern, const KABC::Field::List &fields, Type type)
{
    mPattern = pattern;
    mFields = fields;
    mType = type;

    KABC::Addressee::List allContacts;
    mContacts.clear();

#if KDE_VERSION >= 319
    KABC::AddresseeList list(mAddressBook->allAddressees());
    if(!fields.isEmpty())
        list.sortByField(fields.first());

    allContacts = list;
#else
    KABC::AddressBook::ConstIterator abIt(mAddressBook->begin());
    const KABC::AddressBook::ConstIterator abEndIt(mAddressBook->end());
    for(; abIt != abEndIt; ++abIt)
        allContacts.append(*abIt);
#endif

#ifdef KDEPIM_NEW_DISTRLISTS
    // Extract distribution lists from allContacts
    mDistributionLists.clear();
    KABC::Addressee::List::Iterator rmIt(allContacts.begin());
    const KABC::Addressee::List::Iterator rmEndIt(allContacts.end());
    while(rmIt != rmEndIt)
    {
        if(KPIM::DistributionList::isDistributionList(*rmIt))
        {
            mDistributionLists.append(static_cast<KPIM::DistributionList>(*rmIt));
            rmIt = allContacts.remove(rmIt);
        }
        else
            ++rmIt;
    }

    typedef KPIM::DistributionList::Entry Entry;
    if(!mSelectedDistributionList.isNull())
    {
        const KPIM::DistributionList dl = KPIM::DistributionList::findByName(mAddressBook, mSelectedDistributionList);
        if(!dl.isEmpty())
        {
            allContacts.clear();
            const Entry::List entries = dl.entries(mAddressBook);
            const Entry::List::ConstIterator end = entries.end();
            for(Entry::List::ConstIterator it = entries.begin(); it != end; ++it)
            {
                allContacts.append((*it).addressee);
            }
        }
    }

#endif

    if(mPattern.isEmpty())      // no pattern, return all
    {
        mContacts = allContacts;

        emit contactsUpdated();

        return;
    }

    const KABC::Field::List fieldList = !mFields.isEmpty() ? mFields : KABC::Field::allFields();

    KABC::Addressee::List::ConstIterator it(allContacts.begin());
    const KABC::Addressee::List::ConstIterator endIt(allContacts.end());
    for(; it != endIt; ++it)
    {
#ifdef KDEPIM_NEW_DISTRLISTS
        if(KPIM::DistributionList::isDistributionList(*it))
            continue;
#endif

        bool found = false;
        // search over all fields
        KABC::Field::List::ConstIterator fieldIt(fieldList.begin());
        const KABC::Field::List::ConstIterator fieldEndIt(fieldList.end());
        for(; fieldIt != fieldEndIt; ++fieldIt)
        {

            if(type == StartsWith && (*fieldIt)->value(*it).startsWith(pattern, false))
            {
                mContacts.append(*it);
                found = true;
                break;
            }
            else if(type == EndsWith && (*fieldIt)->value(*it).endsWith(pattern, false))
            {
                mContacts.append(*it);
                found = true;
                break;
            }
            else if(type == Contains && (*fieldIt)->value(*it).find(pattern, 0, false) != -1)
            {
                mContacts.append(*it);
                found = true;
                break;
            }
            else if(type == Equals && (*fieldIt)->value(*it).localeAwareCompare(pattern) == 0)
            {
                mContacts.append(*it);
                found = true;
                break;
            }
        }

        if(!found)
        {
            // search over custom fields
            const QStringList customs = (*it).customs();

            QStringList::ConstIterator customIt(customs.begin());
            const QStringList::ConstIterator customEndIt(customs.end());
            for(; customIt != customEndIt; ++customIt)
            {
                int pos = (*customIt).find(':');
                if(pos != -1)
                {
                    const QString value = (*customIt).mid(pos + 1);
                    if(type == StartsWith && value.startsWith(pattern, false))
                    {
                        mContacts.append(*it);
                        break;
                    }
                    else if(type == EndsWith && value.endsWith(pattern, false))
                    {
                        mContacts.append(*it);
                        break;
                    }
                    else if(type == Contains && value.find(pattern, 0, false) != -1)
                    {
                        mContacts.append(*it);
                        break;
                    }
                    else if(type == Equals && value.localeAwareCompare(pattern) == 0)
                    {
                        mContacts.append(*it);
                        break;
                    }
                }
            }
        }
    }

    emit contactsUpdated();
}
void TodoPlugin::processDropEvent( QDropEvent *event )
{
  const QMimeData *md = event->mimeData();

  if ( KABC::VCardDrag::canDecode( md ) ) {
    KABC::Addressee::List contacts;

    KABC::VCardDrag::fromMimeData( md, contacts );

    KABC::Addressee::List::Iterator it;

    QStringList attendees;
    for ( it = contacts.begin(); it != contacts.end(); ++it ) {
      QString email = (*it).fullEmail();
      if ( email.isEmpty() ) {
        attendees.append( (*it).realName() + "<>" );
      } else {
        attendees.append( email );
      }
    }

    interface()->openTodoEditor( i18nc( "@item", "Meeting" ),
                                 QString(), QStringList(), attendees );
    return;
  }

  if ( KCalUtils::ICalDrag::canDecode( event->mimeData() ) ) {
    KCalCore::MemoryCalendar::Ptr cal( new KCalCore::MemoryCalendar( KSystemTimeZones::local() ) );
    if ( KCalUtils::ICalDrag::fromMimeData( event->mimeData(), cal ) ) {
      KCalCore::Incidence::List incidences = cal->incidences();
      Q_ASSERT( incidences.count() );
      if ( !incidences.isEmpty() ) {
        event->accept();
        KCalCore::Incidence::Ptr i = incidences.first();
        QString summary;
        if ( i->type() == KCalCore::Incidence::TypeJournal ) {
          summary = i18nc( "@item", "Note: %1", i->summary() );
        } else {
          summary = i->summary();
        }
        interface()->openTodoEditor( summary, i->description(), QStringList() );
        return;
      }
      // else fall through to text decoding
    }
  }

  if ( md->hasText() ) {
    QString text = md->text();
    interface()->openTodoEditor( text );
    return;
  }

  if ( KPIM::MailList::canDecode( md ) ) {
    KPIM::MailList mails = KPIM::MailList::fromMimeData( md );
    event->accept();
    if ( mails.count() != 1 ) {
      KMessageBox::sorry(
        core(),
        i18nc( "@info", "Dropping multiple mails is not supported." ) );
    } else {
      KPIM::MailSummary mail = mails.first();
      QString txt = i18nc( "@item", "From: %1\nTo: %2\nSubject: %3",
                           mail.from(), mail.to(), mail.subject() );
      QString uri = QLatin1String( "kmail:" ) +
                    QString::number( mail.serialNumber() ) + '/' +
                    mail.messageId();
      KTemporaryFile tf;
      tf.setAutoRemove( true );
      tf.write( event->encodedData( "message/rfc822" ) );
      interface()->openTodoEditor(
        i18nc( "@item", "Mail: %1", mail.subject() ),
        txt, uri, tf.fileName(), QStringList(), "message/rfc822" );
      tf.close();
    }
    return;
  }

  kWarning() << QString( "Cannot handle drop events of type '%1'." ).arg( event->format() );
}