本文整理汇总了C++中kabc::AddressBook::createDistributionList方法的典型用法代码示例。如果您正苦于以下问题:C++ AddressBook::createDistributionList方法的具体用法?C++ AddressBook::createDistributionList怎么用?C++ AddressBook::createDistributionList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::AddressBook
的用法示例。
在下文中一共展示了AddressBook::createDistributionList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
void DistributionListDialog::slotUser1()
{
bool isEmpty = true;
KABC::AddressBook *ab = KABC::StdAddressBook::self( true );
for (int i = 0; i < mRecipientsList->topLevelItemCount(); ++i) {
DistributionListItem *item = static_cast<DistributionListItem *>(
mRecipientsList->topLevelItem( i ));
if ( item && item->checkState( 0 ) == Qt::Checked ) {
isEmpty = false;
break;
}
}
if ( isEmpty ) {
KMessageBox::information( this,
i18nc("@info", "There are no recipients in your list. "
"First select some recipients, "
"then try again.") );
return;
}
QString name = mTitleEdit->text();
if ( name.isEmpty() ) {
bool ok = false;
name = KInputDialog::getText( i18nc("@title:window","New Distribution List"),
i18nc("@label:textbox","Please enter name:"), QString(), &ok, this );
if ( !ok || name.isEmpty() )
return;
}
if ( ab->findDistributionListByName( name ) ) {
KMessageBox::information( this,
i18nc( "@info", "<para>Distribution list with the given name <resource>%1</resource> "
"already exists. Please select a different name.</para>", name ) );
return;
}
KABC::DistributionList *dlist = ab->createDistributionList( name );
for (int i = 0; i < mRecipientsList->topLevelItemCount(); ++i) {
DistributionListItem *item = static_cast<DistributionListItem *>(
mRecipientsList->topLevelItem( i ));
if ( item && item->checkState( 0 ) == Qt::Checked ) {
kDebug() << item->addressee().fullEmail() << item->addressee().uid();
if ( item->isTransient() ) {
ab->insertAddressee( item->addressee() );
}
if ( item->email() == item->addressee().preferredEmail() ) {
dlist->insertEntry( item->addressee() );
} else {
dlist->insertEntry( item->addressee(), item->email() );
}
}
}
// let the resource know that the data has changed
KABC::Resource *resource = dlist->resource();
resource->insertDistributionList( dlist );
// save the resource
bool saveError = true;
KABC::Ticket *ticket = ab->requestSaveTicket( resource );
if ( ticket ) {
if ( ab->save( ticket ) ) {
saveError = false;
}
else
ab->releaseSaveTicket( ticket );
}
if ( saveError ) {
kWarning() << "Couldn't save new addresses in the distribution list just created to the address book";
}
close();
}