summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimcontactfields.cpp
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimcontactfields.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimcontactfields.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/libopie2/opiepim/core/opimcontactfields.cpp b/libopie2/opiepim/core/opimcontactfields.cpp
index 120beb6..5d45d1f 100644
--- a/libopie2/opiepim/core/opimcontactfields.cpp
+++ b/libopie2/opiepim/core/opimcontactfields.cpp
@@ -10,48 +10,50 @@
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
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 "opimcontactfields.h" 30#include "opimcontactfields.h"
31 31
32/* OPIE */ 32/* OPIE */
33#include <opie2/opimcontact.h> 33#include <opie2/opimcontact.h>
34#include <opie2/odebug.h>
35
34#include <qpe/config.h> 36#include <qpe/config.h>
35 37
36/* QT */ 38/* QT */
37#include <qobject.h> 39#include <qobject.h>
38 40
39 41
40namespace Opie 42namespace Opie
41{ 43{
42/*! 44/*!
43 \internal 45 \internal
44 Returns a list of personal field names for a contact. 46 Returns a list of personal field names for a contact.
45*/ 47*/
46QStringList OPimContactFields::personalfields( bool sorted, bool translated ) 48QStringList OPimContactFields::personalfields( bool sorted, bool translated )
47{ 49{
48 QStringList list; 50 QStringList list;
49 QMap<int, QString> mapIdToStr; 51 QMap<int, QString> mapIdToStr;
50 if ( translated ) 52 if ( translated )
51 mapIdToStr = idToTrFields(); 53 mapIdToStr = idToTrFields();
52 else 54 else
53 mapIdToStr = idToUntrFields(); 55 mapIdToStr = idToUntrFields();
54 56
55 list.append( mapIdToStr[ Qtopia::AddressUid ] ); 57 list.append( mapIdToStr[ Qtopia::AddressUid ] );
56 list.append( mapIdToStr[ Qtopia::AddressCategory ] ); 58 list.append( mapIdToStr[ Qtopia::AddressCategory ] );
57 59
@@ -421,96 +423,96 @@ OPimContactFields::OPimContactFields() :
421 // use it as a start pattern 423 // use it as a start pattern
422 Config cfg ( "AddressBook" ); 424 Config cfg ( "AddressBook" );
423 cfg.setGroup( "ContactFieldOrder" ); 425 cfg.setGroup( "ContactFieldOrder" );
424 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER ); 426 globalFieldOrder = cfg.readEntry( "General", DEFAULT_FIELD_ORDER );
425} 427}
426 428
427OPimContactFields::~OPimContactFields() 429OPimContactFields::~OPimContactFields()
428{ 430{
429 431
430 // We will store the fieldorder into the config file 432 // We will store the fieldorder into the config file
431 // to reuse it for the future.. 433 // to reuse it for the future..
432 if ( changedFieldOrder ) 434 if ( changedFieldOrder )
433 { 435 {
434 Config cfg ( "AddressBook" ); 436 Config cfg ( "AddressBook" );
435 cfg.setGroup( "ContactFieldOrder" ); 437 cfg.setGroup( "ContactFieldOrder" );
436 cfg.writeEntry( "General", globalFieldOrder ); 438 cfg.writeEntry( "General", globalFieldOrder );
437 } 439 }
438} 440}
439 441
440 442
441 443
442void OPimContactFields::saveToRecord( OPimContact &cnt ) 444void OPimContactFields::saveToRecord( OPimContact &cnt )
443{ 445{
444 446
445 qDebug( "ocontactfields saveToRecord: >%s<", fieldOrder.latin1() ); 447 odebug << "ocontactfields saveToRecord: >" << fieldOrder << "<" << oendl;
446 448
447 // Store fieldorder into this contact. 449 // Store fieldorder into this contact.
448 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); 450 cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder );
449 451
450 globalFieldOrder = fieldOrder; 452 globalFieldOrder = fieldOrder;
451 changedFieldOrder = true; 453 changedFieldOrder = true;
452 454
453} 455}
454 456
455void OPimContactFields::loadFromRecord( const OPimContact &cnt ) 457void OPimContactFields::loadFromRecord( const OPimContact &cnt )
456{ 458{
457 qDebug( "ocontactfields loadFromRecord" ); 459 odebug << "ocontactfields loadFromRecord" << oendl;
458 qDebug( "loading >%s<", cnt.fullName().latin1() ); 460 odebug << "loading >" << cnt.fullName() << "<" << oendl;
459 461
460 // Get fieldorder for this contact. If none is defined, 462 // Get fieldorder for this contact. If none is defined,
461 // we will use the global one from the config file.. 463 // we will use the global one from the config file..
462 464
463 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); 465 fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME );
464 466
465 qDebug( "fieldOrder from contact>%s<", fieldOrder.latin1() ); 467 odebug << "fieldOrder from contact>" << fieldOrder << "<" << oendl;
466 468
467 if ( fieldOrder.isEmpty() ) 469 if ( fieldOrder.isEmpty() )
468 { 470 {
469 fieldOrder = globalFieldOrder; 471 fieldOrder = globalFieldOrder;
470 } 472 }
471 473
472 474
473 qDebug( "effective fieldOrder in loadFromRecord >%s<", fieldOrder.latin1() ); 475 odebug << "effective fieldOrder in loadFromRecord >" << fieldOrder << "<" << oendl;
474} 476}
475 477
476void OPimContactFields::setFieldOrder( int num, int index ) 478void OPimContactFields::setFieldOrder( int num, int index )
477{ 479{
478 qDebug( "qcontactfields setfieldorder pos %i -> %i", num, index ); 480 odebug << "qcontactfields setfieldorder pos " << num << " -> " << index << "" << oendl;
479 481
480 fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ]; 482 fieldOrder[ num ] = QString::number( index, 16 ) [ 0 ];
481 483
482 // We will store this new fieldorder globally to 484 // We will store this new fieldorder globally to
483 // remember it for contacts which have none 485 // remember it for contacts which have none
484 globalFieldOrder = fieldOrder; 486 globalFieldOrder = fieldOrder;
485 changedFieldOrder = true; 487 changedFieldOrder = true;
486 488
487 qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); 489 odebug << "fieldOrder >" << fieldOrder << "<" << oendl;
488} 490}
489 491
490int OPimContactFields::getFieldOrder( int num, int defIndex ) 492int OPimContactFields::getFieldOrder( int num, int defIndex )
491{ 493{
492 qDebug( "ocontactfields getFieldOrder" ); 494 odebug << "ocontactfields getFieldOrder" << oendl;
493 qDebug( "fieldOrder >%s<", fieldOrder.latin1() ); 495 odebug << "fieldOrder >" << fieldOrder << "<" << oendl;
494 496
495 // Get index of combo as char.. 497 // Get index of combo as char..
496 QChar poschar = fieldOrder[ num ]; 498 QChar poschar = fieldOrder[ num ];
497 499
498 bool ok; 500 bool ok;
499 int ret = 0; 501 int ret = 0;
500 // Convert char to number.. 502 // Convert char to number..
501 if ( !( poschar == QChar::null ) ) 503 if ( !( poschar == QChar::null ) )
502 ret = QString( poschar ).toInt( &ok, 16 ); 504 ret = QString( poschar ).toInt( &ok, 16 );
503 else 505 else
504 ok = false; 506 ok = false;
505 507
506 // Return default value if index for 508 // Return default value if index for
507 // num was not set or if anything else happened.. 509 // num was not set or if anything else happened..
508 if ( !ok ) ret = defIndex; 510 if ( !ok ) ret = defIndex;
509 511
510 qDebug( "returning >%i<", ret ); 512 odebug << "returning >" << ret << "<" << oendl;
511 513
512 return ret; 514 return ret;
513 515
514} 516}
515 517
516} 518}