Diffstat (limited to 'libopie2/opiepim/ocontactfields.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index deaa1e5..bec00f7 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp | |||
@@ -1,9 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Main Author <main-author@whereever.org> | 3 | Copyright (C) Stefan Eilers <eilers.stefan@epost.de> |
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | 4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
@@ -24,23 +24,26 @@ | |||
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <opie2/ocontactfields.h> | 30 | #include "ocontactfields.h" |
31 | 31 | ||
32 | #include <qstringlist.h> | 32 | /* OPIE */ |
33 | #include <opie2/ocontact.h> | ||
34 | #include <qpe/recordfields.h> // We should use our own enum in the future .. | ||
35 | #include <qpe/config.h> | ||
36 | |||
37 | /* QT */ | ||
33 | #include <qobject.h> | 38 | #include <qobject.h> |
39 | #include <qstringlist.h> | ||
34 | 40 | ||
35 | // We should use our own enum in the future .. | ||
36 | #include <qpe/recordfields.h> | ||
37 | #include <qpe/config.h> | ||
38 | #include <opie2/ocontact.h> | ||
39 | 41 | ||
40 | namespace Opie { | 42 | namespace Opie |
43 | { | ||
41 | /*! | 44 | /*! |
42 | \internal | 45 | \internal |
43 | Returns a list of personal field names for a contact. | 46 | Returns a list of personal field names for a contact. |
44 | */ | 47 | */ |
45 | QStringList OContactFields::personalfields( bool sorted, bool translated ) | 48 | QStringList OContactFields::personalfields( bool sorted, bool translated ) |
46 | { | 49 | { |
@@ -420,70 +423,77 @@ OContactFields::OContactFields(): | |||
420 | // use it as a start pattern | 423 | // use it as a start pattern |
421 | Config cfg ( "AddressBook" ); | 424 | Config cfg ( "AddressBook" ); |
422 | cfg.setGroup( "ContactFieldOrder" ); | 425 | cfg.setGroup( "ContactFieldOrder" ); |
423 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); | 426 | globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); |
424 | } | 427 | } |
425 | 428 | ||
426 | OContactFields::~OContactFields(){ | 429 | OContactFields::~OContactFields() |
430 | { | ||
427 | 431 | ||
428 | // We will store the fieldorder into the config file | 432 | // We will store the fieldorder into the config file |
429 | // to reuse it for the future.. | 433 | // to reuse it for the future.. |
430 | if ( changedFieldOrder ){ | 434 | if ( changedFieldOrder ) |
435 | { | ||
431 | Config cfg ( "AddressBook" ); | 436 | Config cfg ( "AddressBook" ); |
432 | cfg.setGroup( "ContactFieldOrder" ); | 437 | cfg.setGroup( "ContactFieldOrder" ); |
433 | cfg.writeEntry( "General", globalFieldOrder ); | 438 | cfg.writeEntry( "General", globalFieldOrder ); |
434 | } | 439 | } |
435 | } | 440 | } |
436 | 441 | ||
437 | 442 | ||
438 | 443 | ||
439 | void OContactFields::saveToRecord( OContact &cnt ){ | 444 | void OContactFields::saveToRecord( OContact &cnt ) |
445 | { | ||
440 | 446 | ||
441 | qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1()); | 447 | qDebug("ocontactfields saveToRecord: >%s<",fieldOrder.latin1()); |
442 | 448 | ||
443 | // Store fieldorder into this contact. | 449 | // Store fieldorder into this contact. |
444 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); | 450 | cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); |
445 | 451 | ||
446 | globalFieldOrder = fieldOrder; | 452 | globalFieldOrder = fieldOrder; |
447 | changedFieldOrder = true; | 453 | changedFieldOrder = true; |
448 | 454 | ||
449 | } | 455 | } |
450 | 456 | ||
451 | void OContactFields::loadFromRecord( const OContact &cnt ){ | 457 | void OContactFields::loadFromRecord( const OContact &cnt ) |
458 | { | ||
452 | qDebug("ocontactfields loadFromRecord"); | 459 | qDebug("ocontactfields loadFromRecord"); |
453 | qDebug("loading >%s<",cnt.fullName().latin1()); | 460 | qDebug("loading >%s<",cnt.fullName().latin1()); |
454 | 461 | ||
455 | // Get fieldorder for this contact. If none is defined, | 462 | // Get fieldorder for this contact. If none is defined, |
456 | // we will use the global one from the config file.. | 463 | // we will use the global one from the config file.. |
457 | 464 | ||
458 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); | 465 | fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); |
459 | 466 | ||
460 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); | 467 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); |
461 | 468 | ||
462 | if (fieldOrder.isEmpty()){ | 469 | if ( fieldOrder.isEmpty() ) |
470 | { | ||
463 | fieldOrder = globalFieldOrder; | 471 | fieldOrder = globalFieldOrder; |
464 | } | 472 | } |
465 | 473 | ||
466 | 474 | ||
467 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); | 475 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); |
468 | } | 476 | } |
469 | 477 | ||
470 | void OContactFields::setFieldOrder( int num, int index ){ | 478 | void OContactFields::setFieldOrder( int num, int index ) |
479 | { | ||
471 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); | 480 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); |
472 | 481 | ||
473 | fieldOrder[num] = QString::number( index, 16 )[0]; | 482 | fieldOrder[num] = QString::number( index, 16 )[0]; |
474 | 483 | ||
475 | // We will store this new fieldorder globally to | 484 | // We will store this new fieldorder globally to |
476 | // remember it for contacts which have none | 485 | // remember it for contacts which have none |
477 | globalFieldOrder = fieldOrder; | 486 | globalFieldOrder = fieldOrder; |
478 | changedFieldOrder = true; | 487 | changedFieldOrder = true; |
479 | 488 | ||
480 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 489 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); |
481 | } | 490 | } |
482 | 491 | ||
483 | int OContactFields::getFieldOrder( int num, int defIndex ){ | 492 | int OContactFields::getFieldOrder( int num, int defIndex ) |
493 | { | ||
484 | qDebug("ocontactfields getFieldOrder"); | 494 | qDebug("ocontactfields getFieldOrder"); |
485 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 495 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); |
486 | 496 | ||
487 | // Get index of combo as char.. | 497 | // Get index of combo as char.. |
488 | QChar poschar = fieldOrder[num]; | 498 | QChar poschar = fieldOrder[num]; |
489 | 499 | ||