void AddresseeTest::emptyTest() { KContacts::Addressee addressee; QVERIFY(addressee.isEmpty()); KContacts::Addressee addresseeWithMail; addresseeWithMail.insertEmail(QStringLiteral("*****@*****.**")); QVERIFY(!addresseeWithMail.isEmpty()); }
void ReportGenerator::contactToTemplate( TextTemplate *tmpl, const QString& prefix, const KContacts::Addressee& contact ) { if( contact.isEmpty() ) return; tmpl->setValue( ADDRESS_TAG( prefix, "NAME" ), escapeTrml2pdfXML( contact.realName() ) ); QString co = contact.organization(); if( co.isEmpty() ) { co = contact.realName(); } tmpl->setValue( ADDRESS_TAG( prefix, "ORGANISATION" ), escapeTrml2pdfXML( co ) ); tmpl->setValue( ADDRESS_TAG( prefix, "URL" ), escapeTrml2pdfXML( contact.url().toString() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "EMAIL" ), escapeTrml2pdfXML( contact.preferredEmail() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "PHONE" ), escapeTrml2pdfXML( contact.phoneNumber( KContacts::PhoneNumber::Work ).number() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "FAX" ), escapeTrml2pdfXML( contact.phoneNumber( KContacts::PhoneNumber::Fax ).number() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "CELL" ), escapeTrml2pdfXML( contact.phoneNumber( KContacts::PhoneNumber::Cell ).number() ) ); KContacts::Address address; address = contact.address( KContacts::Address::Pref ); if( address.isEmpty() ) address = contact.address(KContacts::Address::Work ); if( address.isEmpty() ) address = contact.address(KContacts::Address::Home ); if( address.isEmpty() ) address = contact.address(KContacts::Address::Postal ); tmpl->setValue( ADDRESS_TAG( prefix, "POSTBOX" ), escapeTrml2pdfXML( address.postOfficeBox() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "EXTENDED" ), escapeTrml2pdfXML( address.extended() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "STREET" ), escapeTrml2pdfXML( address.street() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "LOCALITY" ), escapeTrml2pdfXML( address.locality() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "REGION" ), escapeTrml2pdfXML( address.region() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "POSTCODE" ), escapeTrml2pdfXML( address.postalCode() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "COUNTRY" ), escapeTrml2pdfXML( address.country() ) ); tmpl->setValue( ADDRESS_TAG( prefix, "REGION" ), escapeTrml2pdfXML( address.region() ) ); tmpl->setValue( ADDRESS_TAG( prefix,"LABEL" ), escapeTrml2pdfXML( address.label() ) ); }