本文整理汇总了C++中kabc::Address::formattedAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ Address::formattedAddress方法的具体用法?C++ Address::formattedAddress怎么用?C++ Address::formattedAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::Address
的用法示例。
在下文中一共展示了Address::formattedAddress方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateAddressEdit
void AddressEditWidget::updateAddressEdit()
{
KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
bool block = signalsBlocked();
blockSignals( true );
mAddressField->setText( "" );
if ( it != mAddressList.end() ) {
KABC::Address a = *it;
if ( !a.isEmpty() ) {
#if KDE_VERSION >= 319
if ( a.type() & KABC::Address::Work && mAddressee.realName() != mAddressee.organization() ) {
mAddressField->setText( a.formattedAddress( mAddressee.realName(),
mAddressee.organization() ) );
} else {
mAddressField->setText( a.formattedAddress( mAddressee.realName() ) );
}
#else
QString text;
if ( !a.street().isEmpty() )
text += a.street() + "\n";
if ( !a.postOfficeBox().isEmpty() )
text += a.postOfficeBox() + "\n";
text += a.locality() + QString(" ") + a.region();
if ( !a.postalCode().isEmpty() )
text += QString(", ") + a.postalCode();
text += "\n";
if ( !a.country().isEmpty() )
text += a.country() + "\n";
text += a.extended();
mAddressField->setText( text );
#endif
}
}
blockSignals( block );
}
示例2: updateAddressView
void AddressEditWidget::updateAddressView()
{
const KABC::Address address = mAddressSelectionWidget->currentAddress();
if ( address.isEmpty() ) {
mAddressView->setText( QString() );
} else {
mAddressView->setText( address.formattedAddress( mName ) );
}
}
示例3: entityData
QVariant ContactsTreeModel::entityData( const Item &item, int column, int role ) const
{
if ( item.mimeType() == KABC::Addressee::mimeType() ) {
if ( !item.hasPayload<KABC::Addressee>() ) {
// Pass modeltest
if ( role == Qt::DisplayRole )
return item.remoteId();
return QVariant();
}
const KABC::Addressee contact = item.payload<KABC::Addressee>();
if ( role == Qt::DecorationRole ) {
if ( column == 0 ) {
const KABC::Picture picture = contact.photo();
if ( picture.isIntern() ) {
return picture.data().scaled( QSize( 16, 16 ), Qt::KeepAspectRatio );
} else {
return KIcon( QLatin1String( "x-office-contact" ) );
}
}
return QVariant();
} else if ( (role == Qt::DisplayRole) || (role == Qt::EditRole) ) {
switch ( mColumns.at( column ) ) {
case FullName:
return contact.realName();
break;
case Birthday:
if ( contact.birthday().isValid() )
return KGlobal::locale()->formatDate( contact.birthday().date() );
break;
case HomeAddress:
{
const KABC::Address address = contact.address( KABC::Address::Home );
if ( !address.isEmpty() )
return address.formattedAddress();
}
break;
case BusinessAddress:
{
const KABC::Address address = contact.address( KABC::Address::Work );
if ( !address.isEmpty() )
return address.formattedAddress();
}
break;
case PhoneNumbers:
{
QStringList values;
const KABC::PhoneNumber::List numbers = contact.phoneNumbers();
foreach ( const KABC::PhoneNumber &number, numbers )
values += number.number();
return values.join( "\n" );
}
break;
case PreferredEmail:
return contact.preferredEmail();
break;
case AllEmails:
return contact.emails().join( "\n" );
break;
case Organization:
return contact.organization();
break;
case Homepage:
return contact.url().url();
break;
case Note:
return contact.note();
break;
}
}
} else if ( item.mimeType() == KABC::ContactGroup::mimeType() ) {
示例4: toString
QString AddresseeDiffAlgo::toString(const KABC::Address &addr)
{
return addr.formattedAddress();
}
示例5: 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;
}
示例6: compare
void ContactsHandler::compare(Akonadi::AbstractDifferencesReporter *reporter,
const Akonadi::Item &leftItem, const Akonadi::Item &rightItem)
{
Q_ASSERT(leftItem.hasPayload<KABC::Addressee>());
Q_ASSERT(rightItem.hasPayload<KABC::Addressee>());
const KABC::Addressee leftContact = leftItem.payload<KABC::Addressee>();
const KABC::Addressee rightContact = rightItem.payload<KABC::Addressee>();
const QString modifiedBy = mSession->userName();
const QString modifiedOn = formatDate(getDateModified(rightContact));
reporter->setLeftPropertyValueTitle(i18nc("@title:column", "Local Contact"));
reporter->setRightPropertyValueTitle(
i18nc("@title:column", "Serverside Contact: modified by %1 on %2",
modifiedBy, modifiedOn));
bool seenPrimaryAddress = false;
bool seenOtherAddress = false;
ContactAccessorHash::const_iterator it = mAccessors->constBegin();
ContactAccessorHash::const_iterator endIt = mAccessors->constEnd();
for (; it != endIt; ++it) {
// check if this is a read-only field
if ((*it)->getter == 0) {
continue;
}
QString leftValue = (*it)->getter(leftContact);
QString rightValue = (*it)->getter(rightContact);
QString diffName = (*it)->diffName;
if (diffName.isEmpty()) {
// check for special fields
if (isAddressValue(it.key())) {
if (isPrimaryAddressValue(it.key())) {
if (!seenPrimaryAddress) {
diffName = i18nc("item:intable", "Primary Address");
seenPrimaryAddress = true;
const KABC::Address leftAddress =
leftContact.address(KABC::Address::Work | KABC::Address::Pref);
const KABC::Address rightAddress =
rightContact.address(KABC::Address::Work | KABC::Address::Pref);
leftValue = leftAddress.formattedAddress();
rightValue = rightAddress.formattedAddress();
} else {
// already printed, skip
continue;
}
} else {
if (!seenOtherAddress) {
seenOtherAddress = true;
diffName = i18nc("item:intable", "Other Address");
const KABC::Address leftAddress =
leftContact.address(KABC::Address::Home);
const KABC::Address rightAddress =
rightContact.address(KABC::Address::Home);
leftValue = leftAddress.formattedAddress();
rightValue = rightAddress.formattedAddress();
} else {
// already printed, skip
continue;
}
}
} else if (it.key() == "do_not_call") {
diffName = i18nc("@item:intable", "Do Not Call");
leftValue = getDoNotCall(leftContact) == QLatin1String("1")
? QLatin1String("Yes") : QLatin1String("No");
rightValue = getDoNotCall(rightContact) == QLatin1String("1")
? QLatin1String("Yes") : QLatin1String("No");
} else {
// internal field, skip
continue;
}
}
if (leftValue.isEmpty() && rightValue.isEmpty()) {
continue;
}
if (leftValue.isEmpty()) {
reporter->addProperty(Akonadi::AbstractDifferencesReporter::AdditionalRightMode,
diffName, leftValue, rightValue);
} else if (rightValue.isEmpty()) {
reporter->addProperty(Akonadi::AbstractDifferencesReporter::AdditionalLeftMode,
diffName, leftValue, rightValue);
} else if (leftValue != rightValue) {
reporter->addProperty(Akonadi::AbstractDifferencesReporter::ConflictMode,
diffName, leftValue, rightValue);
}
}
}