本文整理汇总了C++中kabc::VCardConverter::parseVCards方法的典型用法代码示例。如果您正苦于以下问题:C++ VCardConverter::parseVCards方法的具体用法?C++ VCardConverter::parseVCards怎么用?C++ VCardConverter::parseVCards使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::VCardConverter
的用法示例。
在下文中一共展示了VCardConverter::parseVCards方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: interpretAddressBookDownloadItemsJob
bool GroupDavGlobals::interpretAddressBookDownloadItemsJob(
KABC::AddressBookAdaptor *adaptor, KIO::Job *job, const QString &jobData)
{
kdDebug(5800) << "GroupDavGlobals::interpretAddressBookDownloadItemsJob, vCard=" << endl;
kdDebug(5800) << jobData << endl;
if(!adaptor || !job) return false;
KABC::VCardConverter conv;
KABC::Addressee::List addrs(conv.parseVCards(jobData));
if(addrs.count() != 1)
{
kdError() << "Parsed vCard does not contain exactly one addressee." << endl;
return false;
}
KABC::Addressee a = addrs.first();
KIO::SimpleJob *sjob = dynamic_cast<KIO::SimpleJob *>(job);
KURL remoteId;
if(sjob) remoteId = sjob->url();
QString fingerprint = extractFingerprint(job, jobData);
adaptor->addressbookItemDownloaded(a, a.uid(), remoteId, fingerprint,
remoteId.prettyURL());
return true;
}
示例2: dropped
void ViewManager::dropped(QDropEvent *e)
{
kdDebug(5720) << "ViewManager::dropped: got a drop event" << endl;
// don't allow drops from our own drags
if(e->source() == this)
return;
QString clipText, vcards;
KURL::List urls;
if(KURLDrag::decode(e, urls))
{
KURL::List::ConstIterator it = urls.begin();
int c = urls.count();
if(c > 1)
{
QString questionString = i18n("Import one contact into your addressbook?", "Import %n contacts into your addressbook?", c);
if(KMessageBox::questionYesNo(this, questionString, i18n("Import Contacts?"), i18n("Import"), i18n("Do Not Import")) == KMessageBox::Yes)
{
for(; it != urls.end(); ++it)
emit urlDropped(*it);
}
}
else if(c == 1)
emit urlDropped(*it);
}
else if(KVCardDrag::decode(e, vcards))
{
KABC::VCardConverter converter;
const KABC::Addressee::List list = converter.parseVCards(vcards);
KABC::Addressee::List::ConstIterator it;
for(it = list.begin(); it != list.end(); ++it)
{
KABC::Addressee a = mCore->addressBook()->findByUid((*it).uid());
if(a.isEmpty()) // not yet in address book
{
mCore->addressBook()->insertAddressee(*it);
emit modified();
}
}
mActiveView->refresh();
}
}
示例3: readContents
bool VCard_LDIFCreator::readContents( const QString &path )
{
// read file contents
QFile file( path );
if ( !file.open( QIODevice::ReadOnly ) )
return false;
QString info;
text.truncate(0);
// read the file
QByteArray contents = file.readAll();
file.close();
// convert the file contents to a KABC::Addressee address
KABC::Addressee::List addrList;
KABC::Addressee addr;
KABC::VCardConverter converter;
addrList = converter.parseVCards( contents);
if ( addrList.count() == 0 ) {
KABC::AddresseeList l; // FIXME porting
if ( !KABC::LDIFConverter::LDIFToAddressee( contents, l ) )
return false;
// FIXME porting
KABC::AddresseeList::ConstIterator it( l.constBegin() );
for ( ; it != l.constEnd(); ++ it ) {
addrList.append( *it );
}
}
if ( addrList.count()>1 ) {
// create an overview (list of all names)
name = i18np("One contact found:", "%1 contacts found:", addrList.count());
int no, linenr;
for (linenr=no=0; linenr<30 && no<addrList.count(); ++no) {
addr = addrList[no];
info = addr.formattedName().simplified();
if (info.isEmpty())
info = addr.givenName() + ' ' + addr.familyName();
info = info.simplified();
if (info.isEmpty())
continue;
text.append(info);
text.append("\n");
++linenr;
}
return true;
}
// create card for _one_ contact
addr = addrList[ 0 ];
// prepare the text
name = addr.formattedName().simplified();
if ( name.isEmpty() )
name = addr.givenName() + ' ' + addr.familyName();
name = name.simplified();
KABC::PhoneNumber::List pnList = addr.phoneNumbers();
QStringList phoneNumbers;
for (int no=0; no<pnList.count(); ++no) {
QString pn = pnList[no].number().simplified();
if (!pn.isEmpty() && !phoneNumbers.contains(pn))
phoneNumbers.append(pn);
}
if ( !phoneNumbers.isEmpty() )
text += phoneNumbers.join("\n") + '\n';
info = addr.organization().simplified();
if ( !info.isEmpty() )
text += info + '\n';
// get an address
KABC::Address address = addr.address(KABC::Address::Work);
if (address.isEmpty())
address = addr.address(KABC::Address::Home);
if (address.isEmpty())
address = addr.address(KABC::Address::Pref);
info = address.formattedAddress();
if ( !info.isEmpty() )
text += info + '\n';
return true;
}
示例4:
KABC::Addressee::List AddresseeUtil::clipboardToAddressees(const QString &data)
{
KABC::VCardConverter converter;
return converter.parseVCards(data);
}