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


C++ AddressBook::requestSaveTicket方法代码示例

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


在下文中一共展示了AddressBook::requestSaveTicket方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:50,代码来源:kaddrbook.cpp

示例2: 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;
}
开发者ID:Jtalk,项目名称:kopete-fork-xep0136,代码行数:24,代码来源:kabcpersistence.cpp

示例3: 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();
}
开发者ID:akhuettel,项目名称:kdepim-noakonadi,代码行数:79,代码来源:distributionlistdialog.cpp


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