本文整理汇总了C++中kabc::Address类的典型用法代码示例。如果您正苦于以下问题:C++ Address类的具体用法?C++ Address怎么用?C++ Address使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createUrl
QString LocationMap::createUrl( const KABC::Address &addr )
{
/**
This method makes substitutions for the following place holders:
%s street
%r region
%l locality
%z zip code
%c country (in ISO format)
*/
QString urlTemplate = KABPrefs::instance()->locationMapURL().arg( KGlobal::locale()->country() );
if ( urlTemplate.isEmpty() ) {
KMessageBox::error( 0, i18n( "No service provider available for map lookup!\nPlease add one in the configuration dialog." ) );
return QString::null;
}
#if KDE_VERSION >= 319
return urlTemplate.replace( "%s", addr.street() ).
replace( "%r", addr.region() ).
replace( "%l", addr.locality() ).
replace( "%z", addr.postalCode() ).
replace( "%c", addr.countryToISO( addr.country() ) );
#else
return urlTemplate.replace( "%s", addr.street() ).
replace( "%r", addr.region() ).
replace( "%l", addr.locality() ).
replace( "%z", addr.postalCode() ).
replace( "%c", "" );
#endif
}
示例2: updateAddressEdits
void AddressEditDialog::updateAddressEdits()
{
if ( mPreviousAddress )
saveAddress( *mPreviousAddress );
KABC::Address::List::Iterator it = mTypeCombo->selectedElement();
KABC::Address a = *it;
mPreviousAddress = &(*it);
bool tmp = mChanged;
mStreetTextEdit->setText( a.street() );
mRegionEdit->setText( a.region() );
mLocalityEdit->setText( a.locality() );
mPostalCodeEdit->setText( a.postalCode() );
mPOBoxEdit->setText( a.postOfficeBox() );
mCountryCombo->setCurrentText( a.country() );
mLabel = a.label();
mPreferredCheckBox->setChecked( a.type() & KABC::Address::Pref );
if ( a.isEmpty() )
mCountryCombo->setCurrentText( KGlobal::locale()->twoAlphaToCountryName( KGlobal::locale()->country() ) );
mStreetTextEdit->setFocus();
mChanged = tmp;
}
示例3: fieldName
void KABC::ResourceSlox::createAddressFields( QDomDocument &doc, QDomElement &parent,
const QString &prefix, const KABC::Address &addr )
{
WebdavHandler::addSloxElement( this, doc, parent, prefix + fieldName( Street ), addr.street() );
WebdavHandler::addSloxElement( this, doc, parent, prefix + fieldName( PostalCode ), addr.postalCode() );
WebdavHandler::addSloxElement( this, doc, parent, prefix + fieldName( City ), addr.locality() );
WebdavHandler::addSloxElement( this, doc, parent, prefix + fieldName( State ), addr.region() );
WebdavHandler::addSloxElement( this, doc, parent, prefix + fieldName( Country ), addr.country() );
}
示例4: updateAddressView
void AddressEditWidget::updateAddressView()
{
const KABC::Address address = mAddressSelectionWidget->currentAddress();
if ( address.isEmpty() ) {
mAddressView->setText( QString() );
} else {
mAddressView->setText( address.formattedAddress( mName ) );
}
}
示例5: storeContact
void AddressEditWidget::storeContact( KABC::Addressee &contact ) const
{
// delete all previous addresses
const KABC::Address::List oldAddresses = contact.addresses();
for ( int i = 0; i < oldAddresses.count(); ++i ) {
contact.removeAddress( oldAddresses.at( i ) );
}
// insert the new ones
for ( int i = 0; i < mAddressList.count(); ++i ) {
const KABC::Address address( mAddressList.at( i ) );
if ( !address.isEmpty() ) {
contact.insertAddress( address );
}
}
}
示例6: fixPreferredAddress
void AddressEditWidget::fixPreferredAddress( const KABC::Address &preferredAddress )
{
// as the preferred address is mutual exclusive, we have to
// remove the flag from all other addresses
if ( preferredAddress.type() & KABC::Address::Pref ) {
for ( int i = 0; i < mAddressList.count(); ++i ) {
KABC::Address &address = mAddressList[ i ];
address.setType( address.type() & ~KABC::Address::Pref );
}
}
}
示例7:
KABC::Address VCard21Parser::readAddressFromQStringList(const QStringList &data, const int type)
{
KABC::Address mAddress;
mAddress.setType(type);
if(data.count() > 0)
mAddress.setPostOfficeBox(data[0]);
if(data.count() > 1)
mAddress.setExtended(data[1]);
if(data.count() > 2)
mAddress.setStreet(data[2]);
if(data.count() > 3)
mAddress.setLocality(data[3]);
if(data.count() > 4)
mAddress.setRegion(data[4]);
if(data.count() > 5)
mAddress.setPostalCode(data[5]);
if(data.count() > 6)
mAddress.setCountry(data[6]);
return mAddress;
}
示例8: 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 );
}
示例9: setOtherStreet
static void setOtherStreet(const QString &value, KABC::Address &address)
{
address.setStreet(value);
}
示例10: 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).
//.........这里部分代码省略.........
示例11: doExport
void GMXXXPort::doExport( QFile *fp, const KABC::AddresseeList &list )
{
if (!fp || !list.count())
return;
QTextStream t( fp );
t.setEncoding( QTextStream::Latin1 );
KABC::AddresseeList::ConstIterator it;
typedef QMap<int, const KABC::Addressee *> AddressMap;
AddressMap addrMap;
const KABC::Addressee *addr;
t << "AB_ADDRESSES:\n";
t << "Address_id,Nickname,Firstname,Lastname,Title,Birthday,Comments,"
"Change_date,Status,Address_link_id,Categories\n";
int no = 0;
const QChar DELIM('#');
for ( it = list.begin(); it != list.end(); ++it ) {
addr = &(*it);
if (addr->isEmpty())
continue;
addrMap[++no] = addr;
t << no << DELIM // Address_id
<< addr->nickName() << DELIM // Nickname
<< addr->givenName() << DELIM // Firstname
<< addr->familyName() << DELIM // Lastname
<< addr->title() << DELIM // Title
<< dateString(addr->birthday()) << DELIM // Birthday
<< addr->note() /*.replace('\n',"\r\n")*/ << DELIM // Comments
<< dateString(addr->revision()) << DELIM // Change_date
<< "1##0\n"; // Status, Address_link_id, Categories
}
t << "####\n";
t << "AB_ADDRESS_RECORDS:\n";
t << "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\n";
no = 1;
while ( (addr = addrMap[no]) != NULL ) {
for (unsigned int record_id=0; record_id<3; record_id++) {
KABC::Address address;
KABC::PhoneNumber phone, fax, cell;
if (record_id == 0) {
address = addr->address(KABC::Address::Work);
phone = addr->phoneNumber(KABC::PhoneNumber::Work);
fax = addr->phoneNumber(KABC::PhoneNumber::Fax);
cell = addr->phoneNumber(KABC::PhoneNumber::Work | KABC::PhoneNumber::Cell);
} else {
address = addr->address(KABC::Address::Home);
phone = addr->phoneNumber(KABC::PhoneNumber::Home);
cell = addr->phoneNumber(KABC::PhoneNumber::Cell);
}
const QStringList emails = addr->emails();
QString email;
if (emails.count()>record_id) email = emails[record_id];
t << no << DELIM // Address_id
<< record_id << DELIM // Record_id
<< address.street() << DELIM // Street
<< address.country() << DELIM // Country
<< address.postalCode() << DELIM // Zipcode
<< address.locality() << DELIM // City
<< phone.number() << DELIM // Phone
<< fax.number() << DELIM // Fax
<< cell.number() << DELIM // Mobile
<< ((cell.type()&KABC::PhoneNumber::Pref)?-1:0) << DELIM // Mobile_type
<< email << DELIM // Email
<< ((record_id==0)?addr->url().url():QString::null) << DELIM // Homepage
<< ((record_id==0)?addr->role():QString::null) << DELIM // Position
<< DELIM // Comments
<< record_id << DELIM // Record_type_id (0,1,2) - see above
<< DELIM // Record_type (name of this additional record entry)
<< ((record_id==0)?addr->organization():QString::null) << DELIM // Company
<< ((record_id==0)?addr->custom("KADDRESSBOOK", "X-Department"):QString::null) << DELIM // Department
<< dateString(addr->revision()) << DELIM // Change_date
<< 5 << DELIM // Preferred
<< 1 << endl; // Status (should always be "1")
}
++no;
};
t << "####";
}
示例12: 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);
//.........这里部分代码省略.........
示例13: setOtherCity
static void setOtherCity(const QString &value, KABC::Address &address)
{
address.setLocality(value);
}
示例14: msTNEFToVPart
QString KTnef::msTNEFToVPart( const QByteArray &tnef )
{
bool bOk = false;
KTNEFParser parser;
QByteArray b( tnef );
QBuffer buf( &b );
MemoryCalendar::Ptr cal( new MemoryCalendar( KDateTime::UTC ) );
KABC::Addressee addressee;
ICalFormat calFormat;
Event::Ptr event( new Event() );
if ( parser.openDevice( &buf ) ) {
KTNEFMessage *tnefMsg = parser.message();
//QMap<int,KTNEFProperty*> props = parser.message()->properties();
// Everything depends from property PR_MESSAGE_CLASS
// (this is added by KTNEFParser):
QString msgClass = tnefMsg->findProp( 0x001A, QString(), true ).toUpper();
if ( !msgClass.isEmpty() ) {
// Match the old class names that might be used by Outlook for
// compatibility with Microsoft Mail for Windows for Workgroups 3.1.
bool bCompatClassAppointment = false;
bool bCompatMethodRequest = false;
bool bCompatMethodCancled = false;
bool bCompatMethodAccepted = false;
bool bCompatMethodAcceptedCond = false;
bool bCompatMethodDeclined = false;
if ( msgClass.startsWith( QLatin1String( "IPM.MICROSOFT SCHEDULE." ) ) ) {
bCompatClassAppointment = true;
if ( msgClass.endsWith( QLatin1String( ".MTGREQ" ) ) ) {
bCompatMethodRequest = true;
}
if ( msgClass.endsWith( QLatin1String( ".MTGCNCL" ) ) ) {
bCompatMethodCancled = true;
}
if ( msgClass.endsWith( QLatin1String( ".MTGRESPP" ) ) ) {
bCompatMethodAccepted = true;
}
if ( msgClass.endsWith( QLatin1String( ".MTGRESPA" ) ) ) {
bCompatMethodAcceptedCond = true;
}
if ( msgClass.endsWith( QLatin1String( ".MTGRESPN" ) ) ) {
bCompatMethodDeclined = true;
}
}
bool bCompatClassNote = ( msgClass == "IPM.MICROSOFT MAIL.NOTE" );
if ( bCompatClassAppointment || "IPM.APPOINTMENT" == msgClass ) {
// Compose a vCal
bool bIsReply = false;
QString prodID = "-//Microsoft Corporation//Outlook ";
prodID += tnefMsg->findNamedProp( "0x8554", "9.0" );
prodID += "MIMEDIR/EN\n";
prodID += "VERSION:2.0\n";
calFormat.setApplication( "Outlook", prodID );
iTIPMethod method;
if ( bCompatMethodRequest ) {
method = iTIPRequest;
} else if ( bCompatMethodCancled ) {
method = iTIPCancel;
} else if ( bCompatMethodAccepted || bCompatMethodAcceptedCond ||
bCompatMethodDeclined ) {
method = iTIPReply;
bIsReply = true;
} else {
// pending(khz): verify whether "0x0c17" is the right tag ???
//
// at the moment we think there are REQUESTS and UPDATES
//
// but WHAT ABOUT REPLIES ???
//
//
if ( tnefMsg->findProp(0x0c17) == "1" ) {
bIsReply = true;
}
method = iTIPRequest;
}
/// ### FIXME Need to get this attribute written
ScheduleMessage schedMsg( event, method, ScheduleMessage::Unknown );
QString sSenderSearchKeyEmail( tnefMsg->findProp( 0x0C1D ) );
if ( !sSenderSearchKeyEmail.isEmpty() ) {
int colon = sSenderSearchKeyEmail.indexOf( ':' );
// May be e.g. "SMTP:[email protected]"
if ( sSenderSearchKeyEmail.indexOf( ':' ) == -1 ) {
sSenderSearchKeyEmail.remove( 0, colon+1 );
}
}
QString s( tnefMsg->findProp( 0x8189 ) );
const QStringList attendees = s.split( ';' );
if ( attendees.count() ) {
for ( QStringList::const_iterator it = attendees.begin();
it != attendees.end(); ++it ) {
// Skip all entries that have no '@' since these are
//.........这里部分代码省略.........
示例15: setOtherState
static void setOtherState(const QString &value, KABC::Address &address)
{
address.setRegion(value);
}