author | zautrix <zautrix> | 2004-09-21 07:05:01 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-21 07:05:01 (UTC) |
commit | 434ddaa08e0a650422ef271332a1d11879028095 (patch) (unidiff) | |
tree | e4f229120d8bfa9febb7ab123b1311329f0e6aa4 /kabc | |
parent | ed49c55dac215ac2ed9286ebfc36e5a19417f0bb (diff) | |
download | kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.zip kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.tar.gz kdepimpi-434ddaa08e0a650422ef271332a1d11879028095.tar.bz2 |
DTM sync fixes
-rw-r--r-- | kabc/addressbook.cpp | 8 | ||||
-rw-r--r-- | kabc/addressee.cpp | 28 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/resourcesharpdtm.cpp | 57 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.cpp | 119 | ||||
-rw-r--r-- | kabc/plugins/sharpdtm/sharpdtmconverter.h | 1 |
5 files changed, 117 insertions, 96 deletions
diff --git a/kabc/addressbook.cpp b/kabc/addressbook.cpp index adb451f..5fb49eb 100644 --- a/kabc/addressbook.cpp +++ b/kabc/addressbook.cpp | |||
@@ -239,5 +239,3 @@ void AddressBook::init(const QString &config, const QString &family ) | |||
239 | QString fami = family; | 239 | QString fami = family; |
240 | qDebug("new ab "); | ||
241 | if (config != 0) { | 240 | if (config != 0) { |
242 | qDebug("config != 0 "); | ||
243 | if ( family == "syncContact" ) { | 241 | if ( family == "syncContact" ) { |
@@ -608,3 +606,3 @@ void AddressBook::preExternSync( AddressBook* aBook, const QString& csd ) | |||
608 | { | 606 | { |
609 | qDebug("AddressBook::preExternSync "); | 607 | //qDebug("AddressBook::preExternSync "); |
610 | AddressBook::Iterator it; | 608 | AddressBook::Iterator it; |
@@ -618,6 +616,6 @@ void AddressBook::postExternSync( AddressBook* aBook , const QString& csd) | |||
618 | { | 616 | { |
619 | qDebug("AddressBook::postExternSync "); | 617 | //qDebug("AddressBook::postExternSync "); |
620 | AddressBook::Iterator it; | 618 | AddressBook::Iterator it; |
621 | for ( it = begin(); it != end(); ++it ) { | 619 | for ( it = begin(); it != end(); ++it ) { |
622 | qDebug("check uid %s ", (*it).uid().latin1() ); | 620 | // qDebug("check uid %s ", (*it).uid().latin1() ); |
623 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || | 621 | if ( (*it).tempSyncStat() == SYNC_TEMPSTATE_NEW_ID || |
diff --git a/kabc/addressee.cpp b/kabc/addressee.cpp index e241281..31ce1d6 100644 --- a/kabc/addressee.cpp +++ b/kabc/addressee.cpp | |||
@@ -45,2 +45,4 @@ using namespace KABC; | |||
45 | static bool matchBinaryPattern( int value, int pattern ); | 45 | static bool matchBinaryPattern( int value, int pattern ); |
46 | static bool matchBinaryPatternA( int value, int pattern ); | ||
47 | static bool matchBinaryPatternP( int value, int pattern ); | ||
46 | 48 | ||
@@ -383,3 +385,3 @@ void Addressee::setOriginalExternalUID( const QString &id ) | |||
383 | mData->empty = false; | 385 | mData->empty = false; |
384 | qDebug("*******Set orig uid %s ", id.latin1()); | 386 | //qDebug("*******Set orig uid %s ", id.latin1()); |
385 | mData->originalExternalUID = id; | 387 | mData->originalExternalUID = id; |
@@ -396,3 +398,3 @@ void Addressee::setUid( const QString &id ) | |||
396 | detach(); | 398 | detach(); |
397 | qDebug("****setuid %s ", id.latin1()); | 399 | //qDebug("****setuid %s ", id.latin1()); |
398 | mData->empty = false; | 400 | mData->empty = false; |
@@ -1292,3 +1294,3 @@ PhoneNumber Addressee::phoneNumber( int type ) const | |||
1292 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { | 1294 | for( it = mData->phoneNumbers.begin(); it != mData->phoneNumbers.end(); ++it ) { |
1293 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1295 | if ( matchBinaryPatternP( (*it).type(), type ) ) { |
1294 | if ( (*it).type() & PhoneNumber::Pref ) | 1296 | if ( (*it).type() & PhoneNumber::Pref ) |
@@ -1529,3 +1531,3 @@ Address Addressee::address( int type ) const | |||
1529 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { | 1531 | for( it = mData->addresses.begin(); it != mData->addresses.end(); ++it ) { |
1530 | if ( matchBinaryPattern( (*it).type(), type ) ) { | 1532 | if ( matchBinaryPatternA( (*it).type(), type ) ) { |
1531 | if ( (*it).type() & Address::Pref ) | 1533 | if ( (*it).type() & Address::Pref ) |
@@ -1837,3 +1839,2 @@ QDataStream &KABC::operator>>( QDataStream &s, Addressee &a ) | |||
1837 | } | 1839 | } |
1838 | |||
1839 | bool matchBinaryPattern( int value, int pattern ) | 1840 | bool matchBinaryPattern( int value, int pattern ) |
@@ -1851 +1852,18 @@ bool matchBinaryPattern( int value, int pattern ) | |||
1851 | } | 1852 | } |
1853 | |||
1854 | bool matchBinaryPatternP( int value, int pattern ) | ||
1855 | { | ||
1856 | |||
1857 | if ( pattern == 0 ) | ||
1858 | return ( value == 0 ); | ||
1859 | else | ||
1860 | return ( (pattern |PhoneNumber::Pref ) == ( value |PhoneNumber::Pref ) ); | ||
1861 | } | ||
1862 | bool matchBinaryPatternA( int value, int pattern ) | ||
1863 | { | ||
1864 | |||
1865 | if ( pattern == 0 ) | ||
1866 | return ( value == 0 ); | ||
1867 | else | ||
1868 | return ( (pattern | Address::Pref) == ( value | Address::Pref ) ); | ||
1869 | } | ||
diff --git a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp index bba5f9a..48d3985 100644 --- a/kabc/plugins/sharpdtm/resourcesharpdtm.cpp +++ b/kabc/plugins/sharpdtm/resourcesharpdtm.cpp | |||
@@ -131,3 +131,3 @@ bool ResourceSharpDTM::doOpen() | |||
131 | SlZDataBase::addressbookItems(), | 131 | SlZDataBase::addressbookItems(), |
132 | NULL, true); | 132 | NULL, false); |
133 | 133 | ||
@@ -141,3 +141,3 @@ bool ResourceSharpDTM::doOpen() | |||
141 | mConverter = new SharpDTMConverter(); | 141 | mConverter = new SharpDTMConverter(); |
142 | bool res = mConverter->init(); | 142 | bool res = mConverter->init(); |
143 | if ( !res ) | 143 | if ( !res ) |
@@ -226,9 +226,10 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
226 | KABC::Addressee addressee; | 226 | KABC::Addressee addressee; |
227 | qDebug("1NEW id is %d", id); | ||
228 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); | 227 | res = mConverter->sharpToAddressee( id, mAccess, addressee ); |
229 | addressee.setUid((*it).uid() ); | 228 | addressee.setUid((*it).uid() ); |
230 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_CSUM ); | 229 | addressee.setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
231 | changedAddressees.append( addressee ); | ||
232 | res = mAccess->finishEditCard(&id); | 230 | res = mAccess->finishEditCard(&id); |
233 | qDebug("2NEW id is %d", id); | 231 | //qDebug("2NEW id is %d", id); |
232 | addressee.setExternalUID( QString::number( id ) ); | ||
233 | addressee.setOriginalExternalUID( QString::number( id ) ); | ||
234 | changedAddressees.append( addressee ); | ||
234 | 235 | ||
@@ -236,5 +237,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
236 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 237 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
237 | else { | 238 | |
238 | qDebug("added card success "); | ||
239 | } | ||
240 | } | 239 | } |
@@ -257,2 +256,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
257 | //changed | 256 | //changed |
257 | qDebug("changed ****"); | ||
258 | res = mAccess->startEditCard(id); | 258 | res = mAccess->startEditCard(id); |
@@ -271,5 +271,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
271 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | 271 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); |
272 | else { | 272 | |
273 | qDebug("change card succes "); | ||
274 | } | ||
275 | } | 273 | } |
@@ -282,38 +280,3 @@ bool ResourceSharpDTM::save( Ticket *ticket ) | |||
282 | } | 280 | } |
283 | |||
284 | |||
285 | |||
286 | |||
287 | |||
288 | |||
289 | |||
290 | |||
291 | } | ||
292 | |||
293 | #if 0 | ||
294 | // old code | ||
295 | CardId id = 0;// 0 means new card | ||
296 | KABC::Addressee addressee = (*it); | ||
297 | |||
298 | res = mAccess->startEditCard(id); | ||
299 | if (res == true) | ||
300 | { | ||
301 | res = mConverter->addresseeToSharp( *it, mAccess, id ); | ||
302 | if (res == true) | ||
303 | { | ||
304 | res = mAccess->finishEditCard(&id); | ||
305 | if (res == false) | ||
306 | qDebug("Unable to append Contact: %s", addressee.formattedName().latin1()); | ||
307 | } | 281 | } |
308 | else | ||
309 | { | ||
310 | qDebug("Unable to convert Addressee: %s", addressee.formattedName().latin1()); | ||
311 | mAccess->cancelEditCard(); | ||
312 | } | ||
313 | } | ||
314 | else | ||
315 | { | ||
316 | qDebug("Unable to add new card. Addressee: %s", addressee.formattedName().latin1()); | ||
317 | } | ||
318 | #endif | ||
319 | 282 | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp index b065bf3..f3bf2c5 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.cpp +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.cpp | |||
@@ -28,2 +28,3 @@ $Id$ | |||
28 | #include "kglobal.h" | 28 | #include "kglobal.h" |
29 | #include <qregexp.h> | ||
29 | 30 | ||
@@ -33,2 +34,3 @@ $Id$ | |||
33 | #include <sl/slcategories.h> | 34 | #include <sl/slcategories.h> |
35 | #include <libkdepim/ksyncprofile.h> | ||
34 | //US #include <qpe/categoryselect.h> | 36 | //US #include <qpe/categoryselect.h> |
@@ -75,2 +77,3 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
75 | addr.setOriginalExternalUID( QString::number( contact ) ); | 77 | addr.setOriginalExternalUID( QString::number( contact ) ); |
78 | addr.setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | ||
76 | 79 | ||
@@ -78,4 +81,4 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
78 | // name | 81 | // name |
79 | qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); | 82 | //qDebug("SharpDTMConverter::sharpToAddressee check if the fileAs transformation works!!"); |
80 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); | 83 | addr.setFormattedName(db->readField(ZdbAdrs::FileAs)); // needs fix |
81 | 84 | ||
@@ -88,13 +91,20 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
88 | 91 | ||
89 | |||
90 | QString emailstr = db->readField(ZdbAdrs::Emails); | 92 | QString emailstr = db->readField(ZdbAdrs::Emails); |
91 | qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); | 93 | emailstr.replace( QRegExp(","), " " ); |
92 | QStringList emails = QStringList::split(",", emailstr); | 94 | emailstr.replace( QRegExp(";"), " " ); |
93 | 95 | emailstr.replace( QRegExp(":"), " " ); | |
96 | //qDebug("SharpDTMConverter::sharpToAddressee whats the character to seperate the emailadresses? %s ", emailstr.latin1()); | ||
97 | QStringList emails = QStringList::split(" ", emailstr.simplifyWhiteSpace()); | ||
98 | bool defE = false; | ||
99 | bool found = false; | ||
94 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { | 100 | for ( QStringList::Iterator it = emails.begin(); it != emails.end(); ++it ) { |
95 | addr.insertEmail( *it, ((*it) == db->readField(ZdbAdrs::DefaultEmail)) ); | 101 | if (found ) |
102 | defE = false; | ||
103 | else | ||
104 | found = defE = ((*it).lower() == db->readField(ZdbAdrs::DefaultEmail).lower()); | ||
105 | addr.insertEmail( *it, defE ); | ||
96 | } | 106 | } |
97 | 107 | if ( ! found ) | |
98 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) | 108 | if (!db->readField(ZdbAdrs::DefaultEmail).isEmpty()) |
99 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); | 109 | addr.insertEmail(db->readField(ZdbAdrs::DefaultEmail), true); |
100 | 110 | ||
@@ -200,3 +210,3 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
200 | 210 | ||
201 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); //? | 211 | addr.setRole( db->readField(ZdbAdrs::JobTitle) ); |
202 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); | 212 | addr.setOrganization( db->readField(ZdbAdrs::Company) ); |
@@ -212,4 +222,4 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
212 | QString gen = db->readField(ZdbAdrs::Gender); | 222 | QString gen = db->readField(ZdbAdrs::Gender); |
213 | qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); | 223 | //qDebug("SharpDTMConverter::sharpToAddressee pleas check that gender works!! : Gender: %s", gen.latin1()); |
214 | qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); | 224 | //qDebug("SharpDTMConverter::sharpToAddressee: may be int db->readUshortField(\"ZdbAdrs::Gender\") is here better suited"); |
215 | 225 | ||
@@ -221,10 +231,9 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
221 | 231 | ||
222 | QDate ann = db->readDateField(ZdbAdrs::Anniversary); | 232 | QDate ann = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Anniversary) ); |
223 | |||
224 | if (ann.isValid()) { | 233 | if (ann.isValid()) { |
225 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); | 234 | QString dt = KGlobal::locale()->formatDate(ann, true, KLocale::ISODate); |
226 | //US | 235 | //qDebug("qtopiaToAddressee annyversary found:%s", dt.latin1()); |
227 | // qDebug("QtopiaConverter::qtopiaToAddressee found:%s", dt.latin1()); | ||
228 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); | 236 | addr.insertCustom( "KADDRESSBOOK", "X-Anniversary", dt); |
229 | } | 237 | } |
238 | |||
230 | 239 | ||
@@ -233,3 +242,4 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
233 | 242 | ||
234 | QDate birthd = db->readDateField(ZdbAdrs::Birthday); | 243 | QDate birthd = KGlobal::locale()->readDate( db->readField(ZdbAdrs::Birthday) ); |
244 | //qDebug("birtd %s ", birthd.toString().latin1()); | ||
235 | if (birthd.isValid()) | 245 | if (birthd.isValid()) |
@@ -242,4 +252,5 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
242 | QString notes = db->readField(ZdbAdrs::Notes); | 252 | QString notes = db->readField(ZdbAdrs::Notes); |
243 | notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; | 253 | //notes += "\nBusinessWebPage: " + db->readField(ZdbAdrs::BusinessWebPage) + "\n"; |
244 | 254 | if ( addr.url().isEmpty() ) | |
255 | addr.setUrl( db->readField(ZdbAdrs::BusinessWebPage) ); | ||
245 | addr.setNote( db->readField(ZdbAdrs::Notes) ); | 256 | addr.setNote( db->readField(ZdbAdrs::Notes) ); |
@@ -251,3 +262,3 @@ bool SharpDTMConverter::sharpToAddressee( const CardId &contact, const SlZDataBa | |||
251 | 262 | ||
252 | qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); | 263 | //qDebug("SharpDTMConverter::sharpToAddressee please check that the categories will be converted" ); |
253 | QArray<int> catArray = db->readCategories(); | 264 | QArray<int> catArray = db->readCategories(); |
@@ -268,2 +279,3 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
268 | { | 279 | { |
280 | bool cellHome = false, cellWork = false; | ||
269 | // name | 281 | // name |
@@ -275,10 +287,10 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
275 | 287 | ||
276 | qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!"); | 288 | //qDebug("SharpDTMConverter::addresseeToSharp check if the fileAs transformation works!!\n%s",addr.formattedName().latin1() ); |
277 | database->writeField(ZdbAdrs::FileAs, addr.formattedName()); | 289 | database->writeField(ZdbAdrs::FileAs, addr.formattedName()); |
278 | 290 | database->writeField(ZdbAdrs::FullName, addr.formattedName()); | |
279 | 291 | ||
280 | 292 | ||
281 | qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); | 293 | //qDebug("SharpDTMConverter::addresseeToSharp check which seperator we need here for the emails!!"); |
282 | qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); | 294 | //qDebug("SharpDTMConverter::addresseeToSharp its probably the same from sharpToAddressee"); |
283 | QString emails = addr.emails().join(","); | 295 | QString emails = addr.emails().join(" "); |
284 | database->writeField(ZdbAdrs::Emails, emails ); | 296 | database->writeField(ZdbAdrs::Emails, emails ); |
@@ -307,4 +319,6 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
307 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); | 319 | PhoneNumber homemobile = addr.phoneNumber( PhoneNumber::Home | PhoneNumber::Cell ); |
308 | if (!homemobile.number().isEmpty()) | 320 | if (!homemobile.number().isEmpty()) { |
309 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); | 321 | database->writeField(ZdbAdrs::HomeMobile, homemobile.number()); |
322 | cellHome = true; | ||
323 | } | ||
310 | 324 | ||
@@ -332,4 +346,13 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
332 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); | 346 | PhoneNumber businessmobile = addr.phoneNumber( PhoneNumber::Work | PhoneNumber::Cell ); |
333 | if (!businessmobile.number().isEmpty()) | 347 | if (!businessmobile.number().isEmpty()) { |
334 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | 348 | cellWork = true; |
349 | database->writeField(ZdbAdrs::BusinessMobile, businessmobile.number()); | ||
350 | } | ||
351 | PhoneNumber mobile = addr.phoneNumber( PhoneNumber::Cell ); | ||
352 | if (!businessmobile.number().isEmpty()) { | ||
353 | if ( ! cellHome ) | ||
354 | database->writeField(ZdbAdrs::HomeMobile, mobile.number()); | ||
355 | else if (! cellWork ) | ||
356 | database->writeField(ZdbAdrs::BusinessMobile, mobile.number()); | ||
357 | } | ||
335 | 358 | ||
@@ -352,8 +375,8 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
352 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); | 375 | QString gt = addr.custom( "KADDRESSBOOK", "X-Gender" ); |
353 | qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); | 376 | //qDebug("SharpDTMConverter::addresseeToSharp please check that gender works!! : Gender: %s", gt.latin1()); |
354 | qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); | 377 | //qDebug("SharpDTMConverter::addresseeToSharp: may be writeField(\"ZdbAdrs::Gender\", ushort) is here better suited?"); |
355 | qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); | 378 | //qDebug("SharpDTMConverter::addresseeToSharp: check also the reverse functionality in sharpToAddressee"); |
356 | if (gt = "male") | 379 | if (gt == "male") |
357 | database->writeField(ZdbAdrs::Gender, "male"); | 380 | database->writeField(ZdbAdrs::Gender, "male"); |
358 | else if (gt = "female") | 381 | else if (gt == "female") |
359 | database->writeField(ZdbAdrs::Gender, "female"); | 382 | database->writeField(ZdbAdrs::Gender, "female"); |
@@ -365,7 +388,12 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
365 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate | 388 | addr.custom("KADDRESSBOOK", "X-Anniversary" ), "%Y-%m-%d"); // = Qt::ISODate |
366 | database->writeField(ZdbAdrs::Anniversary, dt ); | 389 | if ( dt.isValid() ) { |
367 | 390 | QString dateS = KGlobal::locale()->formatDate(dt, true ); | |
391 | database->writeField(ZdbAdrs::Anniversary, dateS ); | ||
392 | } | ||
368 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); | 393 | database->writeField(ZdbAdrs::Children, addr.custom( "KADDRESSBOOK", "X-Children" )); |
369 | 394 | dt = addr.birthday().date(); | |
370 | database->writeField(ZdbAdrs::Birthday, addr.birthday().date()); | 395 | if ( dt.isValid() ) { |
396 | QString dateS = KGlobal::locale()->formatDate(dt, true ); | ||
397 | database->writeField(ZdbAdrs::Birthday, dateS); | ||
398 | } | ||
371 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); | 399 | database->writeField(ZdbAdrs::Nickname, addr.nickName()); |
@@ -379,5 +407,10 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
379 | 407 | ||
380 | qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); | 408 | //qDebug("SharpDTMConverter::addresseeToSharp please check if category transformation works"); |
381 | 409 | ||
382 | QStringList cats = addr.categories(); | 410 | QStringList cats = addr.categories(); |
411 | int ii; | ||
412 | for ( ii = 0; ii < cats.count() ;++ii ) { | ||
413 | if ( !catDB->exists( cats[ii] )) | ||
414 | catDB->addCategory(cats[ii]); | ||
415 | } | ||
383 | QArray<int> iar; | 416 | QArray<int> iar; |
@@ -385,2 +418,3 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
385 | QArray<int> iar = catDB->ids(cats); | 418 | QArray<int> iar = catDB->ids(cats); |
419 | qDebug("***cat count is %d ", iar.count()); | ||
386 | database->updateCategories(contact, iar); | 420 | database->updateCategories(contact, iar); |
@@ -390 +424,8 @@ bool SharpDTMConverter::addresseeToSharp( const Addressee &addr, SlZDataBase* da | |||
390 | } | 424 | } |
425 | |||
426 | QDate SharpDTMConverter::convertDate( QString s) | ||
427 | { | ||
428 | QDate dt = KGlobal::locale()->readDate( s ); | ||
429 | return dt; | ||
430 | return QDate (); | ||
431 | } | ||
diff --git a/kabc/plugins/sharpdtm/sharpdtmconverter.h b/kabc/plugins/sharpdtm/sharpdtmconverter.h index 99e0413..a04083e 100644 --- a/kabc/plugins/sharpdtm/sharpdtmconverter.h +++ b/kabc/plugins/sharpdtm/sharpdtmconverter.h | |||
@@ -80,2 +80,3 @@ public: | |||
80 | SlCategory::SlCategories* catDB; | 80 | SlCategory::SlCategories* catDB; |
81 | QDate convertDate( QString ); | ||
81 | 82 | ||