本文整理汇总了C++中DistributionList::entries方法的典型用法代码示例。如果您正苦于以下问题:C++ DistributionList::entries方法的具体用法?C++ DistributionList::entries怎么用?C++ DistributionList::entries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DistributionList
的用法示例。
在下文中一共展示了DistributionList::entries方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateEntryView
void DistributionListEditor::updateEntryView()
{
DistributionList *list = mManager->list( mNameCombo->currentText() );
if ( !list ) return;
mEntryView->clear();
DistributionList::Entry::List entries = list->entries();
DistributionList::Entry::List::ConstIterator it;
for( it = entries.begin(); it != entries.end(); ++it ) {
new EditEntryItem( mEntryView, (*it).addressee, (*it).email );
}
EditEntryItem *entryItem = dynamic_cast<EditEntryItem *>( mEntryView->selectedItem() );
bool state = (entryItem != 0L);
changeEmailButton->setEnabled(state);
removeEntryButton->setEnabled(state);
}
示例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: 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 );
}
示例4: updateEntryView
void DistributionListEditorWidget::updateEntryView()
{
if(mNameCombo->currentText().isEmpty())
{
mListLabel->setText(i18n("Selected addressees:"));
}
else
{
mListLabel->setText(i18n("Selected addresses in '%1':").arg(mNameCombo->currentText()));
}
mEntryView->clear();
DistributionList *list = mManager->list(mNameCombo->currentText());
if(!list)
{
mEditButton->setEnabled(false);
mRemoveButton->setEnabled(false);
mChangeEmailButton->setEnabled(false);
mRemoveEntryButton->setEnabled(false);
mAddresseeView->setEnabled(false);
mEntryView->setEnabled(false);
return;
}
else
{
mEditButton->setEnabled(true);
mRemoveButton->setEnabled(true);
mAddresseeView->setEnabled(true);
mEntryView->setEnabled(true);
}
DistributionList::Entry::List entries = list->entries();
DistributionList::Entry::List::ConstIterator it;
for(it = entries.begin(); it != entries.end(); ++it)
{
new EntryItem(mEntryView, (*it).addressee, (*it).email);
}
EntryItem *entryItem = static_cast< EntryItem * >(mEntryView->selectedItem());
bool state = entryItem;
mChangeEmailButton->setEnabled(state);
mRemoveEntryButton->setEnabled(state);
}
示例5: save
bool DistributionListManager::save()
{
kdDebug(5700) << "DistListManager::save()" << endl;
KSimpleConfig cfg( locateLocal( "data", "kabc/distlists" ) );
cfg.deleteGroup( "DistributionLists" );
cfg.setGroup( "DistributionLists" );
DistributionList *list;
for( list = mLists.first(); list; list = mLists.next() ) {
kdDebug(5700) << " Saving '" << list->name() << "'" << endl;
QStringList value;
const DistributionList::Entry::List entries = list->entries();
DistributionList::Entry::List::ConstIterator it;
for( it = entries.begin(); it != entries.end(); ++it ) {
value.append( (*it).addressee.uid() );
value.append( (*it).email );
}
if ( d->mMissingEntries.find( list->name() ) != d->mMissingEntries.end() ) {
const MissingEntryList missList = d->mMissingEntries[ list->name() ];
MissingEntryList::ConstIterator missIt;
for ( missIt = missList.begin(); missIt != missList.end(); ++missIt ) {
value.append( (*missIt).first );
value.append( (*missIt).second );
}
}
cfg.writeEntry( list->name(), value );
}
cfg.sync();
return true;
}