本文整理汇总了C++中kabc::Addressee::formattedName方法的典型用法代码示例。如果您正苦于以下问题:C++ Addressee::formattedName方法的具体用法?C++ Addressee::formattedName怎么用?C++ Addressee::formattedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kabc::Addressee
的用法示例。
在下文中一共展示了Addressee::formattedName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: guessedDisplayType
// Tries to guess the display type that is used for the passed contact
static DisplayNameEditWidget::DisplayType guessedDisplayType( const KABC::Addressee &contact )
{
if ( contact.formattedName() == ( contact.givenName() + QLatin1Char( ' ' ) + contact.familyName() ) ) {
return DisplayNameEditWidget::SimpleName;
} else if ( contact.formattedName() == contact.assembledName() ) {
return DisplayNameEditWidget::FullName;
} else if ( contact.formattedName() == ( contact.familyName() + QLatin1String( ", " ) + contact.givenName() ) ) {
return DisplayNameEditWidget::ReverseNameWithComma;
} else if ( contact.formattedName() == ( contact.familyName() + QLatin1Char( ' ' ) + contact.givenName() ) ) {
return DisplayNameEditWidget::ReverseName;
} else if ( contact.formattedName() == contact.organization() ) {
return DisplayNameEditWidget::Organization;
} else {
return DisplayNameEditWidget::CustomName;
}
}
示例2: dataForAddressee
QVariant PersonsModel::dataForAddressee(const QString &personId, const KABC::Addressee &person, int role) const
{
Q_D(const PersonsModel);
switch(role) {
case FormattedNameRole:
return person.formattedName();
case PhotoRole:
if (!person.photo().data().isNull()) {
return person.photo().data();
} else if (!person.photo().url().isEmpty()) {
return QPixmap(person.photo().url());
} else {
return QPixmap(d->genericAvatarImagePath);
}
case PersonIdRole:
return personId;
case PersonVCardRole:
return QVariant::fromValue<KABC::Addressee>(person);
case ContactsVCardRole:
return QVariant::fromValue<KABC::AddresseeList>(d->metacontacts[d->personIndex[personId].row()].contacts());
case GroupsRole:
return person.categories();
}
return QVariant();
}
示例3: formatAttendees
void HtmlExport::formatAttendees( QTextStream *ts, Incidence *event )
{
Attendee::List attendees = event->attendees();
if (attendees.count()) {
*ts << "<em>";
#ifndef KORG_NOKABC
KABC::AddressBook *add_book = KABC::StdAddressBook::self( true );
KABC::Addressee::List addressList;
addressList = add_book->findByEmail(event->organizer().email());
KABC::Addressee o = addressList.first();
if (!o.isEmpty() && addressList.size()<2) {
*ts << "<a href=\"mailto:" << event->organizer().email() << "\">";
*ts << cleanChars(o.formattedName()) << "</a>\n";
}
else *ts << event->organizer().fullName();
#else
*ts << event->organizer().fullName();
#endif
*ts << "</em><br />";
Attendee::List::ConstIterator it;
for( it = attendees.begin(); it != attendees.end(); ++it ) {
Attendee *a = *it;
if (!a->email().isEmpty()) {
*ts << "<a href=\"mailto:" << a->email();
*ts << "\">" << cleanChars(a->name()) << "</a>";
}
else {
*ts << " " << cleanChars(a->name());
}
*ts << "<br />" << "\n";
}
} else {
*ts << " \n";
}
}
示例4: hasNameMatch
bool KABCHandler::hasNameMatch(const KABC::Addressee& contact, const QString& name)
{
if (contact.assembledName().lower().find(name) != -1) return true;
if (contact.formattedName().lower().find(name) != -1) return true;
return false;
}
示例5: getName
QString ContactsModel::getName(KABC::Addressee contact) const
{
QString name = contact.formattedName();
if (name.isEmpty()) {
name = QString("%1 %2").arg(contact.givenName()).arg(contact.familyName());
}
return name;
}
示例6: onItemsFetched
void akonadimailsearch::onItemsFetched(KJob *job)
{
if (job->error()) {
kWarning() << job->errorString();
} else {
ItemFetchJob *itemFetchJob = qobject_cast<ItemFetchJob*>(job);
foreach (const Item &item, itemFetchJob->items()) {
if(item.hasPayload<KABC::Addressee>()) {
const QString id = item.url().prettyUrl();
const KABC::Addressee contact = item.payload<KABC::Addressee>();
QTextStream out(stdout);
if(contact.preferredEmail().size() > 0 && \
( contact.preferredEmail().contains(mysearch) || contact.formattedName().contains(mysearch) )){
out << contact.formattedName() << " <" << contact.preferredEmail()<< ">" <<endl;
}
}
}
}
if (--activeFetchJobsCount == 0) {
emit finished();
}
}
示例7: parseIncidenceAttribute
void KCalResourceSlox::parseIncidenceAttribute( const QDomElement &e,
Incidence *incidence )
{
QString tag = e.tagName();
QString text = decodeText( e.text() );
if ( text.isEmpty() ) return;
if ( tag == fieldName( IncidenceTitle ) ) {
incidence->setSummary( text );
} else if ( e.tagName() == fieldName( Description ) ) {
incidence->setDescription( text );
} else if ( tag == fieldName( Reminder ) ) {
int minutes = text.toInt();
if ( minutes != 0 ) {
Alarm::List alarms = incidence->alarms();
Alarm *alarm;
if ( alarms.isEmpty() ) alarm = incidence->newAlarm();
else alarm = alarms.first();
if ( alarm->type() == Alarm::Invalid ) {
alarm->setType( Alarm::Display );
}
Duration d( minutes * -60 );
alarm->setStartOffset( d );
alarm->setEnabled( true );
} else {
// 0 reminder -> disable alarm
incidence->clearAlarms();
}
} else if ( tag == fieldName( CreatedBy ) ) {
KABC::Addressee a;
if ( mAccounts ) a = mAccounts->lookupUser( text );
else kDebug() << "KCalResourceSlox: no accounts set";
incidence->setOrganizer( Person( a.formattedName(), a.preferredEmail() ) );
} else if ( tag == fieldName( Participants ) ) {
parseMembersAttribute( e, incidence );
} else if ( tag == "readrights" ) {
parseReadRightsAttribute( e, incidence );
} else if ( tag == fieldName( Categories ) ) {
incidence->setCategories( text.split( QRegExp(",\\s*") ) );
} else if ( tag == fieldName( LastModified ) && type() == "ox" ) {
incidence->setCustomProperty( "SLOX", "LastModified", text );
}
}
示例8: retrieveAddresseeListFromDevice
bool AddressbookHandler::retrieveAddresseeListFromDevice( KABC::Addressee::List &mAddresseeList, QValueList<uint32_t> &idList )
{
KABC::VCardConverter vCardConv;
bool ret = true;
for ( QValueList<uint32_t>::const_iterator it = idList.begin(); it != idList.end(); ++it ) {
incrementSteps();
kdDebug(2120) << "Retrieving Contact from device: " << "RRA-ID-" +
QString::number ( *it, 16 ).rightJustify( 8, '0' ) << endl;
QString vCard = m_rra->getVCard( mTypeId, *it );
if (vCard.isEmpty()) {
addErrorEntry("RRA-ID-" + QString::number ( *it, 16 ).rightJustify( 8, '0' ));
ret = false;
}
KABC::Addressee addr = vCardConv.parseVCard ( vCard );
addr.setFormattedName(addr.formattedName().replace("\\,", ","));
QString kdeId;
if ((kdeId = mUidHelper->kdeId("SynCEAddressbook", addr.uid(), "---")) != "---") {
addr.setUid(kdeId);
} else {
mUidHelper->addId("SynCEAddressbook", addr.uid(), addr.uid());
}
kdDebug(2120) << " ID-Pair: KDEID: " << addr.uid() << " DeviceID: " <<
"RRA-ID-" + QString::number ( *it, 16 ).rightJustify( 8, '0' ) << endl;
mAddresseeList.push_back( addr );
KApplication::kApplication()->processEvents();
}
return ret;
}
示例9: itemEquals
bool AddresseeEmailSelection::itemEquals( const KABC::Addressee &addressee, uint index, const QString &pattern ) const
{
return (pattern == addressee.formattedName() + " " + email( addressee, index )) ||
(addressee.emails().contains( pattern ));
}
示例10: config
NameEditDialog::NameEditDialog( const KABC::Addressee &addr, int type,
bool readOnly, QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Edit Contact Name" ), Help | Ok | Cancel,
Ok, parent, name, true ), mAddressee( addr )
{
QWidget *page = plainPage();
QGridLayout *layout = new QGridLayout( page );
layout->setSpacing( spacingHint() );
layout->addColSpacing( 2, 100 );
QLabel *label;
label = new QLabel( i18n( "Honorific prefixes:" ), page );
layout->addWidget( label, 0, 0 );
mPrefixCombo = new KComboBox( page );
mPrefixCombo->setDuplicatesEnabled( false );
mPrefixCombo->setEditable( true );
mPrefixCombo->setEnabled( !readOnly );
label->setBuddy( mPrefixCombo );
layout->addMultiCellWidget( mPrefixCombo, 0, 0, 1, 2 );
QWhatsThis::add( mPrefixCombo, i18n( "The predefined honorific prefixes can be extended in the settings dialog." ) );
label = new QLabel( i18n( "Given name:" ), page );
layout->addWidget( label, 1, 0 );
mGivenNameEdit = new KLineEdit( page );
mGivenNameEdit->setReadOnly( readOnly );
label->setBuddy( mGivenNameEdit );
layout->addMultiCellWidget( mGivenNameEdit, 1, 1, 1, 2 );
label = new QLabel( i18n( "Additional names:" ), page );
layout->addWidget( label, 2, 0 );
mAdditionalNameEdit = new KLineEdit( page );
mAdditionalNameEdit->setReadOnly( readOnly );
label->setBuddy( mAdditionalNameEdit );
layout->addMultiCellWidget( mAdditionalNameEdit, 2, 2, 1, 2 );
label = new QLabel( i18n( "Family names:" ), page );
layout->addWidget( label, 3, 0 );
mFamilyNameEdit = new KLineEdit( page );
mFamilyNameEdit->setReadOnly( readOnly );
label->setBuddy( mFamilyNameEdit );
layout->addMultiCellWidget( mFamilyNameEdit, 3, 3, 1, 2 );
label = new QLabel( i18n( "Honorific suffixes:" ), page );
layout->addWidget( label, 4, 0 );
mSuffixCombo = new KComboBox( page );
mSuffixCombo->setDuplicatesEnabled( false );
mSuffixCombo->setEditable( true );
mSuffixCombo->setEnabled( !readOnly );
label->setBuddy( mSuffixCombo );
layout->addMultiCellWidget( mSuffixCombo, 4, 4, 1, 2 );
QWhatsThis::add( mSuffixCombo, i18n( "The predefined honorific suffixes can be extended in the settings dialog." ) );
label = new QLabel( i18n( "Formatted name:" ), page );
layout->addWidget( label, 5, 0 );
mFormattedNameCombo = new KComboBox( page );
mFormattedNameCombo->setEnabled( !readOnly );
layout->addWidget( mFormattedNameCombo, 5, 1 );
connect( mFormattedNameCombo, SIGNAL( activated( int ) ), SLOT( typeChanged( int ) ) );
mFormattedNameEdit = new KLineEdit( page );
mFormattedNameEdit->setEnabled( type == CustomName && !readOnly );
layout->addWidget( mFormattedNameEdit, 5, 2 );
mParseBox = new QCheckBox( i18n( "Parse name automatically" ), page );
mParseBox->setEnabled( !readOnly );
connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( parseBoxChanged(bool) ) );
connect( mParseBox, SIGNAL( toggled(bool) ), SLOT( modified() ) );
layout->addMultiCellWidget( mParseBox, 6, 6, 0, 1 );
// Fill in the values
mFamilyNameEdit->setText( addr.familyName() );
mGivenNameEdit->setText( addr.givenName() );
mAdditionalNameEdit->setText( addr.additionalName() );
mFormattedNameEdit->setText( addr.formattedName() );
// Prefix and suffix combos
KConfig config( "kabcrc" );
config.setGroup( "General" );
QStringList sTitle;
sTitle += "";
sTitle += i18n( "Dr." );
sTitle += i18n( "Miss" );
sTitle += i18n( "Mr." );
sTitle += i18n( "Mrs." );
sTitle += i18n( "Ms." );
sTitle += i18n( "Prof." );
sTitle += config.readListEntry( "Prefixes" );
sTitle.sort();
QStringList sSuffix;
sSuffix += "";
sSuffix += i18n( "I" );
sSuffix += i18n( "II" );
sSuffix += i18n( "III" );
sSuffix += i18n( "Jr." );
sSuffix += i18n( "Sr." );
//.........这里部分代码省略.........
示例11: getValue
QString KWMailMergeKABC::getValue( const QString &name, int record ) const
{
kdDebug() << "KWMailMergeKABC::getValue(" << name << ", " << record << ")" << endl;
if ( record < 0 )
return name;
// This doesn't ever happen, right? So why is it there? Dirk Schmidt
if ( record == -1 && _iterator == _addressBook->end() )
return "";
//
// Set the iterator to the asked Addressee.
//
bool uidAvailable = false;
if ( record != -1 )
{
int counter = 0;
for ( _UIDIterator = _exclusiveUIDs.begin(); _UIDIterator != _exclusiveUIDs.end()
&& counter < record; _UIDIterator++ )
{
counter++;
}
for ( _iterator = _addressBook->begin(); _iterator != _addressBook->end(); ++_iterator )
{
if( _iterator->uid() == *_UIDIterator )
{
uidAvailable = true;
break;
}
}
}
if( !uidAvailable )
{
return ( i18n ( "KAddressbook entry '%1' not available." ).arg( *_UIDIterator ) );
}
KABC::Addressee addr = *_iterator;
_iterator++; // Don't know why. Could be removed? Dirk Schmidt
//
// Return the asked variable.
//
if ( name == "KAddressbook identifier" )
return addr.uid();
if ( name == "Name" )
return addr.name();
if ( name == "Formatted name" )
return addr.formattedName();
if ( name == "Family names" )
return addr.familyName();
if ( name == "Given name" )
return addr.givenName();
if ( name == "Additional names" )
return addr.additionalName();
if ( name == "Honorific prefixes" )
return addr.prefix();
if ( name == "Honorific suffixes" )
return addr.suffix();
if ( name == "Nick name" )
return addr.nickName();
if ( name == "Birthday" )
return KGlobal::locale()->formatDate( addr.birthday().date() );
if ( name == "Home address: Street" )
{
KABC::Address a = addr.address( KABC::Address::Home );
return a.street();
}
if ( name == "Home address: Locality" )
{
KABC::Address a = addr.address( KABC::Address::Home );
return a.locality();
}
if ( name == "Home address: Region" )
{
KABC::Address a = addr.address( KABC::Address::Home );
return a.region();
}
if ( name == "Home address: Postal code" )
{
KABC::Address a = addr.address( KABC::Address::Home );
return a.postalCode();
}
if ( name == "Home address: Country" )
{
KABC::Address a = addr.address( KABC::Address::Home );
return a.country();
}
if ( name == "Home address: Label" )
{
KABC::Address a = addr.address( KABC::Address::Home );
return a.label();
}
//.........这里部分代码省略.........
示例12: 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;
}
示例13: importContacts
KABC::AddresseeList GMXXXPort::importContacts( const QString& ) const
{
KABC::AddresseeList addrList;
QString fileName = KFileDialog::getOpenFileName( ":xxport_gmx",
GMX_FILESELECTION_STRING, 0 );
if ( fileName.isEmpty() )
return addrList;
QFile file( fileName );
if ( !file.open( IO_ReadOnly ) ) {
QString msg = i18n( "<qt>Unable to open <b>%1</b> for reading.</qt>" );
KMessageBox::error( parentWidget(), msg.arg( fileName ) );
return addrList;
}
QDateTime dt;
QTextStream gmxStream( &file );
gmxStream.setEncoding( QTextStream::Latin1 );
QString line, line2;
line = gmxStream.readLine();
line2 = gmxStream.readLine();
if (!line.startsWith("AB_ADDRESSES:") || !line2.startsWith("Address_id")) {
KMessageBox::error( parentWidget(), i18n("%1 is not a GMX address book file.").arg(fileName) );
return addrList;
}
QStringList strList;
typedef QMap<QString, KABC::Addressee *> AddressMap;
AddressMap addrMap;
// "Address_id,Nickname,Firstname,Lastname,Title,Birthday,Comments,Change_date,Status,Address_link_id,Categories"
line = gmxStream.readLine();
while (!line.startsWith("####") && !gmxStream.atEnd()) {
while (1) {
strList = QStringList::split('#', line, true);
if (strList.count() >= 11)
break;
line.append('\n');
line.append(gmxStream.readLine());
};
KABC::Addressee *addr = new KABC::Addressee;
addr->setNickName(strList[1]);
addr->setGivenName(strList[2]);
addr->setFamilyName(strList[3]);
addr->setTitle(strList[4]);
if (addr->formattedName().isEmpty())
addr->setFormattedName(addr->realName());
if (checkDateTime(strList[5],dt)) addr->setBirthday(dt);
addr->setNote(strList[6]);
if (checkDateTime(strList[7],dt)) addr->setRevision(dt);
// addr->setStatus(strList[8]); Status
// addr->xxx(strList[9]); Address_link_id
// addr->setCategory(strList[10]); Categories
addrMap[strList[0]] = addr;
line = gmxStream.readLine();
}
// now read the address records
line = gmxStream.readLine();
if (!line.startsWith("AB_ADDRESS_RECORDS:")) {
kdWarning() << "Could not find address records!\n";
return addrList;
}
// Address_id,Record_id,Street,Country,Zipcode,City,Phone,Fax,Mobile,Mobile_type,Email,
// Homepage,Position,Comments,Record_type_id,Record_type,Company,Department,Change_date,Preferred,Status
line = gmxStream.readLine();
line = gmxStream.readLine();
while (!line.startsWith("####") && !gmxStream.atEnd()) {
while (1) {
strList = QStringList::split('#', line, true);
if (strList.count() >= 21)
break;
line.append('\n');
line.append(gmxStream.readLine());
};
KABC::Addressee *addr = addrMap[strList[0]];
if (addr) {
for ( QStringList::Iterator it = strList.begin(); it != strList.end(); ++it )
*it = (*it).simplifyWhiteSpace();
// strList[1] = Record_id (numbered item, ignore here)
int id = strList[14].toInt(); // Record_type_id (0=work,1=home,2=other)
int type = (id==0) ? KABC::Address::Work : KABC::Address::Home;
if (!strList[19].isEmpty() && strList[19].toInt()!=0)
type |= KABC::Address::Pref; // Preferred address (seems to be bitfield for telephone Prefs)
KABC::Address adr = addr->address(type);
adr.setStreet(strList[2]);
adr.setCountry(strList[3]);
adr.setPostalCode(strList[4]);
adr.setLocality(strList[5]);
addr->insertPhoneNumber( KABC::PhoneNumber(strList[6], KABC::PhoneNumber::Home) );
addr->insertPhoneNumber( KABC::PhoneNumber(strList[7], KABC::PhoneNumber::Fax) );
int celltype = KABC::PhoneNumber::Cell;
// strList[9]=Mobile_type // always 0 or -1(default phone).
//.........这里部分代码省略.........
示例14: toXml
QString Contact::toXml(const KABC::Addressee &addr)
{
/**
* Handle distribution lists.
*/
if(KPIM::DistributionList::isDistributionList(addr))
{
if(s_distListMap)
return (*s_distListMap)[ addr.uid() ];
else
return QString();
}
/**
* Handle normal contacts.
*/
QString xml;
xml += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
xml += "<contact>\n";
xml += "<direct_ref>" + addr.uid() + "</direct_ref>\n";
xml += "<sensitivity>" + custom("sensitivity", addr, "0") + "</sensitivity>\n";
xml += "<message_class>IPM.Contact</message_class>\n";
xml += "<is_recurring>" + custom("is_recurring", addr, "false") + "</is_recurring>\n";
xml += "<reminder_set>" + custom("reminder_set", addr, "false") + "</reminder_set>\n";
xml += "<send_rich_info>" + custom("send_rich_info", addr, "false") + "</send_rich_info>\n";
xml += "<subject>" + addr.formattedName() + "</subject>\n";
xml += "<last_modification_time>" + addr.revision().toString(Qt::ISODate) + "</last_modification_time>\n";
xml += "<display_name_prefix>" + addr.prefix() + "</display_name_prefix>\n";
xml += "<first_name>" + addr.givenName() + "</first_name>\n";
xml += "<middle_name>" + addr.additionalName() + "</middle_name>\n";
xml += "<last_name>" + addr.familyName() + "</last_name>\n";
xml += "<suffix>" + addr.suffix() + "</suffix>\n";
xml += "<display_name>" + addr.assembledName() + "</display_name>\n";
xml += "<file_as>" + addr.formattedName() + "</file_as>\n";
xml += "<nickname>" + addr.nickName() + "</nickname>\n";
xml += "<web_page_address>" + addr.url().url() + "</web_page_address>\n";
xml += "<company_name>" + addr.organization() + "</company_name>\n";
xml += "<job_title>" + addr.title() + "</job_title>\n";
QStringList emails = addr.emails();
for(uint i = 0; i < 3; ++i)
{
QString type, address, comment, display;
if(i < emails.count())
{
type = "SMTP";
address = emails[ i ];
/**
* If the contact was created by kontact use the email address as
* display name and the formatted name as comment, otherwise we use
* the values from the server.
*/
if(custom("comes_from_scalix", addr) != "true")
{
comment = addr.formattedName();
display = emails[ i ];
}
else
{
comment = custom(QString("email%1_address_with_comment").arg(i + 1), addr);
display = custom(QString("email%1_display_name").arg(i + 1), addr);
}
}
xml += QString("<email%1_address_type>").arg(i + 1) + type +
QString("</email%1_address_type>").arg(i + 1) + "\n";
xml += QString("<email%1_address>").arg(i + 1) + address +
QString("</email%1_address>").arg(i + 1) + "\n";
xml += QString("<email%1_address_with_comment>").arg(i + 1) + comment +
QString("</email%1_address_with_comment>").arg(i + 1) + "\n";
xml += QString("<email%1_display_name>").arg(i + 1) + display +
QString("</email%1_display_name>").arg(i + 1) + "\n";
}
KABC::PhoneNumber phone = addr.phoneNumber(KABC::PhoneNumber::Home);
xml += "<home_phone_number>" + phone.number() + "</home_phone_number>\n";
phone = addr.phoneNumber(KABC::PhoneNumber::Work);
xml += "<work_phone_number>" + phone.number() + "</work_phone_number>\n";
phone = addr.phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Fax);
xml += "<work_fax_number>" + phone.number() + "</work_fax_number>\n";
phone = addr.phoneNumber(KABC::PhoneNumber::Cell);
xml += "<mobile_phone_number>" + phone.number() + "</mobile_phone_number>\n";
const KABC::Address workAddress = addr.address(KABC::Address::Work);
xml += "<work_address_street>" + workAddress.street() + "</work_address_street>\n";
xml += "<work_address_zip>" + workAddress.postalCode() + "</work_address_zip>\n";
xml += "<work_address_city>" + workAddress.locality() + "</work_address_city>\n";
xml += "<work_address_state>" + workAddress.region() + "</work_address_state>\n";
xml += "<work_address_country>" + workAddress.country() + "</work_address_country>\n";
const KABC::Address homeAddress = addr.address(KABC::Address::Home);
//.........这里部分代码省略.........
示例15: event
bool ContactListView::event( QEvent *e )
{
if( e->type() != QEvent::ToolTip )
return K3ListView::event( e );
if ( !tooltips() )
return true;
QHelpEvent * he = static_cast< QHelpEvent * >( e );
QPoint pnt = viewport()->mapFromGlobal( mapToGlobal( he->pos() ) );
Q3ListViewItem * item = itemAt ( pnt );
if ( item )
{
ContactListViewItem *plvi = static_cast<ContactListViewItem *>( item );
QString s;
//kDebug(5720) <<"Tip rec:" << r.x() <<"," << r.y() <<"," << r.width()
// << "," << r.height();
KABC::Addressee a = plvi->addressee();
if (a.isEmpty())
return true;
s += i18nc("label: value", "%1: %2", a.formattedNameLabel(),
a.formattedName());
s += '\n';
s += i18nc("label: value", "%1: %2", a.organizationLabel(),
a.organization());
QString notes = a.note().trimmed();
if ( !notes.isEmpty() ) {
notes += '\n';
s += '\n' + i18nc("label: value", "%1: \n", a.noteLabel());
QFontMetrics fm( font() );
// Begin word wrap code based on QMultiLineEdit code
int i = 0;
bool doBreak = false;
int linew = 0;
int lastSpace = -1;
int a = 0;
int lastw = 0;
while ( i < int(notes.length()) ) {
doBreak = false;
if ( notes[i] != '\n' )
linew += fm.width( notes[i] );
if ( lastSpace >= a && notes[i] != '\n' )
if (linew >= parentWidget()->width()) {
doBreak = true;
if ( lastSpace > a ) {
i = lastSpace;
linew = lastw;
}
else
i = qMax( a, i-1 );
}
if ( notes[i] == '\n' || doBreak ) {
s += notes.mid( a, i - a + (doBreak?1:0) ) +'\n';
a = i + 1;
lastSpace = a;
linew = 0;
}
if ( notes[i].isSpace() ) {
lastSpace = i;
lastw = linew;
}
if ( lastSpace <= a ) {
lastw = linew;
}
++i;
}
}
if ( s.isEmpty() )
QToolTip::hideText();
else
QToolTip::showText( he->globalPos(), s );
}
return true;
}