本文整理汇总了C++中DistributionList::emails方法的典型用法代码示例。如果您正苦于以下问题:C++ DistributionList::emails方法的具体用法?C++ DistributionList::emails怎么用?C++ DistributionList::emails使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistributionList
的用法示例。
在下文中一共展示了DistributionList::emails方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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 );
}
示例3: main
int main(int argc, char **argv)
{
KAboutData aboutData("testdistlist", I18N_NOOP("Test Distribution Lists"), "0.1");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(args->isSet("list"))
{
QString name = args->getOption("list");
DistributionListManager *manager = new DistributionListManager(StdAddressBook::self());
manager->load();
DistributionList *list = manager->list(name);
if(!list)
{
kdDebug() << "No list with name '" << name << "'" << endl;
return 1;
}
else
{
kdDebug() << "RESULT: " << list->emails().join(", ") << endl;
return 0;
}
}
DistributionListEditor *editor = new DistributionListEditor(StdAddressBook::self(), 0);
editor->show();
app.setMainWidget(editor);
QObject::connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
app.exec();
delete editor;
}