summaryrefslogtreecommitdiffabout
path: root/kabc/plugins/qtopia/qtopiaconverter.cpp
Side-by-side diff
Diffstat (limited to 'kabc/plugins/qtopia/qtopiaconverter.cpp') (more/less context) (show whitespace changes)
-rw-r--r--kabc/plugins/qtopia/qtopiaconverter.cpp24
1 files changed, 14 insertions, 10 deletions
diff --git a/kabc/plugins/qtopia/qtopiaconverter.cpp b/kabc/plugins/qtopia/qtopiaconverter.cpp
index 040226c..106596f 100644
--- a/kabc/plugins/qtopia/qtopiaconverter.cpp
+++ b/kabc/plugins/qtopia/qtopiaconverter.cpp
@@ -270,59 +270,62 @@ bool QtopiaConverter::qtopiaToAddressee( const QDomElement& el, Addressee &adr )
adr.setNote( el.attribute( "Notes" ) );
{
QStringList categories = QStringList::split(";", el.attribute("Categories" ) );
QString cat;
QStringList added;
for ( uint i = 0; i < categories.count(); i++ ) {
cat = m_edit->categoryById( categories[ i ], "Contacts" );
// if name is not empty and we did not add the
// cat try to repair broken files
if ( !cat.isEmpty() && !added.contains( cat ) ) {
adr.insertCategory( cat );
added << cat;
}
}
}
if ( !el.attribute( "Department" ).isEmpty() )
adr.insertCustom( "KADDRESSBOOK", "X-Department", el.attribute( "Department" ) );
if ( !el.attribute( "HomeWebPage" ).isEmpty() )
adr.insertCustom( "opie", "HomeWebPage", el.attribute( "HomeWebPage" ) );
if ( !el.attribute( "Spouse" ).isEmpty() )
adr.insertCustom( "KADDRESSBOOK", "X-SpousesName", el.attribute( "Spouse" ) );
- if ( !el.attribute( "Gender" ).isEmpty() )
- adr.insertCustom( "opie", "Gender", el.attribute( "Gender" ) );
-
+ if ( !el.attribute( "Gender" ).isEmpty() ) {
+ if ( el.attribute( "Gender" ) == "1" )
+ adr.insertCustom( "KADDRESSBOOK", "X-Gender", "male" );
+ else if ( el.attribute( "Gender" ) == "2" )
+ adr.insertCustom( "KADDRESSBOOK", "X-Gender", "female" );
+ }
QDate ann = dateFromString( el.attribute( "Anniversary" ) );
if ( ann.isValid() ) {
QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate);
adr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt );
}
if ( !el.attribute( "Children" ).isEmpty() )
- adr.insertCustom("opie", "Children", el.attribute("Children") );
+ adr.insertCustom("KADDRESSBOOK", "X-Children", el.attribute("Children") );
if ( !el.attribute( "Office" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-Office", el.attribute("Office") );
if ( !el.attribute( "Profession" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-Profession", el.attribute("Profession") );
if ( !el.attribute( "Assistant" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-AssistantsName", el.attribute("Assistant") );
if ( !el.attribute( "Manager" ).isEmpty() )
adr.insertCustom("KADDRESSBOOK", "X-ManagersName", el.attribute("Manager") );
}
return true;
}
bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *stream )
{
*stream << "<Contact ";
*stream << "FirstName=\"" << escape(ab.givenName()) << "\" ";
*stream << "MiddleName=\"" << escape(ab.additionalName()) << "\" ";
*stream << "LastName=\"" << escape(ab.familyName()) << "\" ";
*stream << "Suffix=\"" << escape(ab.suffix()) << "\" ";
QString sortStr;
sortStr = ab.formattedName();
@@ -363,66 +366,67 @@ bool QtopiaConverter::addresseeToQtopia( const Addressee &ab, QTextStream *strea
KABC::PhoneNumber homeMobile = ab.phoneNumber( KABC::PhoneNumber::Cell );
*stream << "HomeMobile=\"" << escape( homeMobile.number() ) << "\" ";
KABC::Address business = ab.address(KABC::Address::Work );
*stream << "BusinessStreet=\"" << escape( business.street() ) << "\" ";
*stream << "BusinessCity=\"" << escape( business.locality() ) << "\" ";
*stream << "BusinessZip=\"" << escape( business.postalCode() ) << "\" ";
*stream << "BusinessCountry=\"" << escape( business.country() ) << "\" ";
*stream << "BusinessState=\"" << escape( business.region() ) << "\" ";
//stream << "BusinessPager=\"" << << "\" ";
*stream << "Office=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Office" ) ) << "\" ";
*stream << "Profession=\"" << escape( ab.custom( "KADDRESSBOOK", "X-Profession" ) ) << "\" ";
*stream << "Assistant=\"" << escape( ab.custom( "KADDRESSBOOK", "X-AssistantsName") ) << "\" ";
*stream << "Manager=\"" << escape( ab.custom( "KADDRESSBOOK", "X-ManagersName" ) ) << "\" ";
KABC::Address home = ab.address( KABC::Address::Home );
*stream << "HomeStreet=\"" << escape( home.street() ) << "\" ";
*stream << "HomeCity=\"" << escape( home.locality() ) << "\" ";
*stream << "HomeState=\"" << escape( home.region() ) << "\" ";
*stream << "HomeZip=\"" << escape( home.postalCode() ) << "\" ";
*stream << "HomeCountry=\"" << escape( home.country() ) << "\" ";
*stream << "HomeWebPage=\"" << escape( ab.custom( "opie", "HomeWebPage" ) ) << "\" ";
*stream << "Spouse=\"" << escape( ab.custom( "KADDRESSBOOK", "X-SpousesName") ) << "\" ";
- *stream << "Gender=\"" << escape( ab.custom( "opie", "Gender") ) << "\" ";
+ QString gen = "0";
+ if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "male" )
+ gen = "1";
+ else if ( ab.custom( "KADDRESSBOOK", "X-Gender") == "female" )
+ gen = "2";
+ *stream << "Gender=\"" << escape( gen ) << "\" ";
if ( ab.birthday().date().isValid() )
*stream << "Birthday=\"" << escape( dateToString(ab.birthday().date() ) ) << "\" ";
- /*
- * Anniversary block again
- * Go from ISO -> QDate -> toString and then escape
- */
{
QDate ann = KGlobal::locale()->readDate( ab.custom("KADDRESSBOOK", "X-Anniversary" ),
"%Y-%m-%d");
if (ann.isValid() ) {
*stream << "Anniversary=\"" << escape( dateToString( ann ) ) << "\" ";
}
}
*stream << "Nickname=\"" << escape( ab.nickName() ) << "\" ";
- *stream << "Children=\"" << escape( ab.custom("opie", "Children" ) ) << "\" ";
+ *stream << "Children=\"" << escape( ab.custom("KADDRESSBOOK", "X-Children" ) ) << "\" ";
*stream << "Notes=\"" << escape( ab.note() ) << "\" ";
*stream << "Categories=\"" << categoriesToNumber( ab.categories(), "Contacts") << "\" ";
QString uid = ab.uid();
*stream << "Uid=\"" << uid << "\" ";
//*stream << map.toString( "addressbook", uid );
*stream << " />" << "\n";
return true;
}
#if 0
KTempFile* AddressBook::fromKDE( KSync::AddressBookSyncee *syncee, ExtraMap& map )
{
}
QStringList AddressBook::attributes()const {
QStringList lst;
lst << "FirstName";
lst << "MiddleName";
lst << "LastName";