当前位置: 首页>>代码示例>>C++>>正文


C++ kabc::AddressBook类代码示例

本文整理汇总了C++中kabc::AddressBook的典型用法代码示例。如果您正苦于以下问题:C++ AddressBook类的具体用法?C++ AddressBook怎么用?C++ AddressBook使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了AddressBook类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddresseeViewItem

void
AddressesDialog::updateAvailableAddressees()
{
  d->ui->mAvailableView->clear();
  d->groupDict.clear();

  static const QString &personalGroup = KGlobal::staticQString( i18n( "Other Addresses" ) );
  d->personal = new AddresseeViewItem( d->ui->mAvailableView, personalGroup );
  d->personal->setHidden( true );
  d->groupDict.insert( personalGroup, d->personal );

  KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
  for( KABC::AddressBook::Iterator it = addressBook->begin();
       it != addressBook->end(); ++it ) {
    addAddresseeToAvailable( *it, d->personal );
  }

  d->recent = 0;
  updateRecentAddresses();

  addDistributionLists();
  if ( d->personal->childCount() > 0 ) {
    d->personal->setHidden( false );
  }

  checkForSingleAvailableGroup();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:27,代码来源:addressesdialog.cpp

示例2: addVCard

bool KAddrBookExternal::addVCard(const KABC::Addressee &addressee, QWidget *parent)
{
    KABC::AddressBook *ab = KABC::StdAddressBook::self(true);
    bool inserted = false;

    ab->setErrorHandler(new KABC::GuiErrorHandler(parent));

    KABC::Addressee::List addressees =
        ab->findByEmail(addressee.preferredEmail());

    if(addressees.isEmpty())
    {
        if(KAddrBookExternal::addAddressee(addressee))
        {
            QString text = i18n("The VCard was added to your addressbook; "
                                "you can add more information to this "
                                "entry by opening the addressbook.");
            KMessageBox::information(parent, text, QString::null, "addedtokabc");
            inserted = true;
        }
    }
    else
    {
        QString text = i18n("The VCard's primary email address is already in "
                            "your addressbook; however, you may save the VCard "
                            "into a file and import it into the addressbook "
                            "manually.");
        KMessageBox::information(parent, text);
        inserted = true;
    }

    ab->setErrorHandler(0);
    return inserted;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:34,代码来源:kaddrbook.cpp

示例3: setup

void TestDistrList::setup()
{
    // We need a std addressbook
    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    KABC::StdAddressBook::setAutomaticSave( false );

    // and two contacts
    KABC::Addressee addr1;
    addr1.setName( "addr1" );
    addr1.setFormattedName( "addr1" );
    addr1.insertEmail( "[email protected]", true );
    addr1.insertEmail( "[email protected]" );
    ab->insertAddressee( addr1 );
    assert( addr1.emails().count() == 2 );

    KABC::Addressee addr2;
    addr2.setName( "addr2" );
    addr2.insertEmail( "[email protected]", true );
    addr2.insertEmail( "[email protected]" );
    ab->insertAddressee( addr2 );
    assert( addr2.emails().count() == 2 );

    assert( !ab->findByName( "addr1" ).isEmpty() );
    assert( !ab->findByName( "addr2" ).isEmpty() );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:25,代码来源:testdistrlist.cpp

示例4: testNewList

void TestDistrList::testNewList()
{
    kDebug() ;
    DistributionList dl;
    dl.setName( "foo" );
    assert( !dl.isEmpty() );
    check( "name set", dl.formattedName(), "foo" );
    assert( DistributionList::isDistributionList( dl ) );

    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    ab->insertAddressee( dl );
#if 0 // can't do that until we have KABC::AddressBook::findByFormattedName, or we use setName()
    KABC::Addressee::List addrList = ab->findByName( "foo" );
    assert( addrList.count() == 1 );
    KABC::Addressee addr = addrList.first();
    assert( !addr.isEmpty() );
    check( "correct name", addr.name(), "foo" );
    assert( DistributionList::isDistributionList( addr ) );
#else
    KABC::Addressee addr = dl;
#endif

    DistributionList dl2 = DistributionList::findByName( ab, "foo" );
    assert( !dl2.isEmpty() );
    check( "correct name", dl2.formattedName(), "foo" );
    assert( DistributionList::isDistributionList( dl2 ) );

    // Test the ctor that takes an addressee
    DistributionList dl3( addr );
    assert( !dl3.isEmpty() );
    assert( DistributionList::isDistributionList( dl3 ) );
    check( "correct name", dl3.formattedName(), "foo" );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:33,代码来源:testdistrlist.cpp

示例5: testDuplicate

void TestDistrList::testDuplicate()
{
    kDebug() ;
    // This is a special test for the case where we have a contact and a distr list with the same name
    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    KABC::Addressee addr;
    addr.setName( "foo" );
    addr.insertEmail( "[email protected]", true );
    ab->insertAddressee( addr );

#if 0 // we need a findByFormattedName
    KABC::Addressee::List addrList = ab->findByName( "foo" );
    assert( addrList.count() == 2 );

    bool a = DistributionList::isDistributionList( addrList.first() );
    bool b = DistributionList::isDistributionList( addrList.last() );
    // one is a distr list, but not both
    assert( a || b );
    //
    assert( ! ( a && b ) );
#endif

    DistributionList dl = DistributionList::findByName( ab, "foo" );
    assert( !dl.isEmpty() );
    assert( DistributionList::isDistributionList( dl ) );
    assert( dl.formattedName() == "foo" );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:27,代码来源:testdistrlist.cpp

示例6: openEmail

//-----------------------------------------------------------------------------
void KAddrBookExternal::openEmail(const QString &addr, QWidget *parent)
{
    QString email;
    QString name;

    KABC::Addressee::parseEmailAddress(addr, name, email);

    KABC::AddressBook *ab = KABC::StdAddressBook::self(true);

    // force a reload of the address book file so that changes that were made
    // by other programs are loaded
    ab->asyncLoad();

    // if we have to reload the address book then we should also wait until
    // it's completely reloaded
#if KDE_IS_VERSION(3,4,89)
    // This ugly hack will be removed in 4.0
    while(!ab->loadingHasFinished())
    {
        QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);

        // use sleep here to reduce cpu usage
        usleep(100);
    }
#endif

    KABC::Addressee::List addressees = ab->findByEmail(email);

    if(addressees.count() > 0)
    {
        if(kapp->dcopClient()->isApplicationRegistered("kaddressbook"))
        {
            //make sure kaddressbook is loaded, otherwise showContactEditor
            //won't work as desired, see bug #87233
            DCOPRef call("kaddressbook", "kaddressbook");
            call.send("newInstance()");
        }
        else
        {
            kapp->startServiceByDesktopName("kaddressbook");
        }

        DCOPRef call("kaddressbook", "KAddressBookIface");
        call.send("showContactEditor(QString)", addressees.first().uid());
    }
    else
    {
        //TODO: Enable the better message at the next string unfreeze
#if 0
        QString text = i18n("<qt>The email address <b>%1</b> cannot be "
                            "found in your addressbook.</qt>").arg(email);
#else
        QString text = email + " " + i18n("is not in address book");
#endif
        KMessageBox::information(parent, text, QString::null, "notInAddressBook");
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:58,代码来源:kaddrbook.cpp

示例7: testDeleteList

void TestDistrList::testDeleteList()
{
    kDebug() ;

    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    DistributionList dl = DistributionList::findByName( ab, "foo" );
    assert( !dl.isEmpty() );
    ab->removeAddressee( dl );
    dl = DistributionList::findByName( ab, "foo" );
    assert( dl.isEmpty() );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:11,代码来源:testdistrlist.cpp

示例8: cleanup

void TestDistrList::cleanup()
{
    kDebug() ;
    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    ab->clear();
    KABC::StdAddressBook::close();

    QString kdehome = QFile::decodeName( getenv("KDEHOME") );
    KUrl urlkdehome;
    urlkdehome.setPath( kdehome );
    KIO::NetAccess::del( urlkdehome, 0 );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:12,代码来源:testdistrlist.cpp

示例9: slotSelectAddress

/** Select a mail address, using the KabApi */
void TagMailDlg::slotSelectAddress()
{
//Based on KMail
  QString addr, email, emailString;
  QStringList result;
  KABC::AddressBook *addressBook = KABC::StdAddressBook::self();
  KABC::AddressBook::Iterator it;
  for( it = addressBook->begin(); it != addressBook->end(); ++it ) {
    QStringList emails = (*it).emails();
    QString n = (*it).prefix() + " " +
    (*it).givenName() + " " +
    (*it).additionalName() + " " +
          (*it).familyName() + " " +
    (*it).suffix();
    n = n.simplifyWhiteSpace();
    for( unsigned int i = 0; i < emails.count(); ++i ) {
      if (!emails[i].isEmpty()) {
  if (n.isEmpty() || (emails[i].find( "<" ) != -1))
    addr = "";
  else { /* do we really need quotes around this name ? */
    if (n.find(QRegExp("[^ 0-9A-Za-z\\x0080-\\xFFFF]")) != -1)
      addr = qConfig.attrValueQuotation + n + qConfig.attrValueQuotation + " ";
    else
      addr = n + " ";
  }
  email = emails[i];
  if (!addr.isEmpty() && (email.find( "<" ) == -1)
      && (email.find( ">" ) == -1)
      && (email.find( "," ) == -1))
    addr += "<" + email + ">";
  else
    addr += email;
  addr.stripWhiteSpace();
  result.append( addr );
      }
    }
  }
 result.sort();

 if ( result.count() > 0 )
 {
   ListDlg listDlg(result);
   listDlg.setCaption(i18n("Select Address"));
   if (!listDlg.exec()) return;
   emailString = listDlg.getEntry();
   lineEmail->setText(emailString);
 } else
 {
//Actually this may mean also other erros, but the result is the same for us: cannot get the
//e-mail address
   KMessageBox::error(this,i18n("No addresses found."));
  }
}
开发者ID:serghei,项目名称:kde3-kdewebdev,代码行数:54,代码来源:tagmaildlg.cpp

示例10: core

KAB::Book::Book (Ekiga::ContactCore &_core): core(_core)
{
    KABC::AddressBook *kab = KABC::StdAddressBook::self ();

    kab->load (); // FIXME: turn async!

    for (KABC::AddressBook::Iterator iter = kab->begin ();
            iter != kab->end ();
            iter++) {

        add_contact (ContactPtr (new Contact (core, &(*iter))));
    }
}
开发者ID:brownsys,项目名称:pane-ekiga,代码行数:13,代码来源:kab-book.cpp

示例11: addresses

void KabcBridge::addresses(QStringList& result) // includes lists
{
  KCursorSaver busy(KBusyPtr::busy()); // loading might take a while

  KABC::AddressBook *addressBook = KABC::StdAddressBook::self( true );
  KABC::AddressBook::ConstIterator it;
  for( it = addressBook->constBegin(); it != addressBook->constEnd(); ++it ) {
    const QStringList emails = (*it).emails();
    QString n = (*it).prefix() + ' ' +
                (*it).givenName() + ' ' +
                (*it).additionalName() + ' ' +
                (*it).familyName() + ' ' +
                (*it).suffix();
    n = n.simplified();

    QRegExp needQuotes("[^ 0-9A-Za-z\\x0080-\\xFFFF]");
    QString endQuote = "\" ";
    QStringList::ConstIterator mit;
    QString addr, email;

    for ( mit = emails.begin(); mit != emails.end(); ++mit ) {
      email = *mit;
      if (!email.isEmpty()) {
        if (n.isEmpty() || (email.contains( '<' ) ))
          addr.clear();
        else { // do we really need quotes around this name ?
          if (n.contains(needQuotes) )
            addr = '"' + n + endQuote;
          else
            addr = n + ' ';
        }

        if (!addr.isEmpty() && !(email.contains( '<' ) )
            && !(email.contains( '>' ) )
            && !(email.contains( ',' ) ))
          addr += '<' + email + '>';
        else
          addr += email;
        addr = addr.trimmed();
        result.append( addr );
      }
    }
  }

  result += addressBook->allDistributionListNames();

  result.sort();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:48,代码来源:kmaddrbook.cpp

示例12: saveToKABC

void KoRdfFoaF::saveToKABC()
{
    Q_D (KoRdfFoaF);
    kDebug(30015) << "saving name:" << d->m_name;
#ifdef KDEPIMLIBS_FOUND
    KABC::StdAddressBook *ab = static_cast<KABC::StdAddressBook*>
                               (KABC::StdAddressBook::self());
    if (!ab) {
        return;
    }
    KABC::Ticket *ticket = ab->requestSaveTicket();
    KABC::Addressee addr = d->toKABC();
    ab->insertAddressee(addr);
    KABC::AddressBook* pab = ab;
    pab->save(ticket);
#endif
}
开发者ID:KDE,项目名称:calligra-history,代码行数:17,代码来源:KoRdfFoaF.cpp

示例13: testInsertEntry

void TestDistrList::testInsertEntry()
{
    kDebug() ;
    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    DistributionList dl = DistributionList::findByName( ab, "foo" );
    assert( !dl.isEmpty() );

#if 0 // the usual method
    KABC::Addressee addr1 = ab->findByName( "addr1" ).first();
    assert( !addr1.isEmpty() );
    dl.insertEntry( addr1 );
#else // the kolab-resource method
    dl.insertEntry( "addr1" );
#endif

    KABC::Addressee addr2 = ab->findByName( "addr2" ).first();
    assert( !addr2.isEmpty() );
    dl.insertEntry( addr2, "[email protected]" );

    // Try inserting it again, should do nothing
    dl.insertEntry( addr2, "[email protected]" );

    // And insert it with another email address
    dl.insertEntry( addr2, "[email protected]" );

    // Test entries()
    DistributionList::Entry::List entries = dl.entries( ab );
    check( "entries count", QString::number( entries.count() ), "3" );
    check( "first entry", entries[0].addressee.name(), "addr1" );
    check( "first entry", entries[0].email, QString() );
    check( "second entry", entries[1].addressee.name(), "addr2" );
    check( "second entry", entries[1].email, "[email protected]" );
    check( "third entry", entries[2].addressee.name(), "addr2" );
    check( "third entry", entries[2].email, "[email protected]" );

    // Test emails()
    QStringList emails = dl.emails( ab );
    kDebug() << emails;
    assert( emails.count() == 3 );
    check( "first email", emails[0], "addr1 <[email protected]>" );
    check( "second email", emails[1], "addr2 <[email protected]>" );
    check( "third email", emails[2], "addr2 <[email protected]>" );

    // Commit changes to the addressbook !!
    ab->insertAddressee( dl );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:46,代码来源:testdistrlist.cpp

示例14: categories

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;
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:18,代码来源:kmaddrbook.cpp

示例15: testRemoveEntry

void TestDistrList::testRemoveEntry()
{
    kDebug() ;
    KABC::AddressBook *ab = KABC::StdAddressBook::self();
    DistributionList dl = DistributionList::findByName( ab, "foo" );
    assert( !dl.isEmpty() );
    DistributionList::Entry::List entries = dl.entries( ab );
    check( "entries count before removeEntry", QString::number( entries.count() ), "3" );

    // Removing an empty entry shouldn't do anything
    dl.removeEntry( KABC::Addressee() );
    check( "entries count after removing empty entry", QString::number( dl.entries(ab).count() ), "3" );

    KABC::Addressee addr1 = ab->findByName( "addr1" ).first();
    assert( !addr1.isEmpty() );
    // Removing an entry with the wrong email passed, shouldn't do anything
    dl.removeEntry( addr1, "[email protected]" );
    check( "entries count after removing entry with invalid email", QString::number( dl.entries(ab).count() ), "3" );

    // Now remove entry correctly
    dl.removeEntry( addr1 );
    check( "removeEntry(addr1) worked", QString::number( dl.entries(ab).count() ), "2" );
    QStringList emails = dl.emails( ab );
    assert( emails.count() == 2 );
    check( "first email", emails[0], "addr2 <[email protected]>" );

    // Now move on to addr2. First remove with no or a wrong email (nothing should happen)
    KABC::Addressee addr2 = ab->findByName( "addr2" ).first();
    assert( !addr2.isEmpty() );
    dl.removeEntry( addr2 );
    check( "entries count after removing entry with no email", QString::number( dl.entries(ab).count() ), "2" );

    // Now remove addr2 correctly
    dl.removeEntry( addr2, "[email protected]" );
    check( "entries count after removing addr2", QString::number( dl.entries(ab).count() ), "1" );
    dl.removeEntry( addr2, "[email protected]" );
    check( "entries count after removing alternate addr2", QString::number( dl.entries(ab).count() ), "0" );
    assert( dl.entries(ab).isEmpty() );
    assert( dl.emails(ab).isEmpty() );
    assert( DistributionList::isDistributionList( dl ) );

    ab->insertAddressee( dl );
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:43,代码来源:testdistrlist.cpp


注:本文中的kabc::AddressBook类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。