本文整理汇总了C++中kabc::AddressBook::save方法的典型用法代码示例。如果您正苦于以下问题:C++ AddressBook::save方法的具体用法?C++ AddressBook::save怎么用?C++ AddressBook::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::AddressBook
的用法示例。
在下文中一共展示了AddressBook::save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addAddressee
bool KAddrBookExternal::addAddressee(const KABC::Addressee &addr)
{
KABC::AddressBook *addressBook = KABC::StdAddressBook::self(true);
#if KDE_IS_VERSION(3,4,89)
// This ugly hack will be removed in 4.0
while(!addressBook->loadingHasFinished())
{
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
// use sleep here to reduce cpu usage
usleep(100);
}
#endif
// Select a resource
QPtrList<KABC::Resource> kabcResources = addressBook->resources();
QPtrList<KRES::Resource> kresResources;
QPtrListIterator<KABC::Resource> resIt(kabcResources);
KABC::Resource *kabcResource;
while((kabcResource = resIt.current()) != 0)
{
++resIt;
if(!kabcResource->readOnly())
{
KRES::Resource *res = static_cast<KRES::Resource *>(kabcResource);
if(res)
kresResources.append(res);
}
}
kabcResource = static_cast<KABC::Resource *>(KRES::SelectDialog::getResource(kresResources, 0));
KABC::Ticket *ticket = addressBook->requestSaveTicket(kabcResource);
bool saved = false;
if(ticket)
{
KABC::Addressee addressee(addr);
addressee.setResource(kabcResource);
addressBook->insertAddressee(addressee);
saved = addressBook->save(ticket);
if(!saved)
addressBook->releaseSaveTicket(ticket);
}
addressBook->emitAddressBookChanged();
return saved;
}
示例2: 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
}
示例3: slotWriteAddressBook
void KABCPersistence::slotWriteAddressBook()
{
//kDebug( 14010 ) ;
KABC::AddressBook* ab = addressBook();
QListIterator<KABC::Resource *> it( d->pendingResources );
while ( it.hasNext() )
{
//kDebug( 14010 ) << "Writing resource " << it.current()->resourceName();
KABC::Ticket *ticket = ab->requestSaveTicket( it.next() );
if ( !ticket )
kWarning( 14010 ) << "WARNING: Resource is locked by other application!";
else
{
if ( !ab->save( ticket ) )
{
kWarning( 14010 ) << "ERROR: Saving failed!";
ab->releaseSaveTicket( ticket );
}
}
//kDebug( 14010 ) << "Finished writing KABC";
}
d->pendingResources.clear();
d->addrBookWritePending = false;
}
示例4: 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();
}