author | alwin <alwin> | 2004-02-20 02:06:52 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-20 02:06:52 (UTC) |
commit | 55f4d502486e01927356908223622e435c975f7e (patch) (unidiff) | |
tree | 824b5c1e8992564677c4f39473bc108a32a2cf2a /libopie2/opiepim/ocontactfields.cpp | |
parent | 060b4fc7a3fd5c1b5f745167fe084f7486719b7e (diff) | |
download | opie-55f4d502486e01927356908223622e435c975f7e.zip opie-55f4d502486e01927356908223622e435c975f7e.tar.gz opie-55f4d502486e01927356908223622e435c975f7e.tar.bz2 |
moved the opie pim stuff to libopie2 - pim. Tried to resort them, may be someone should take a look for a better file order. but now all applications can start using libopiepim2 instead of libopie1-pim-stuff.
Diffstat (limited to 'libopie2/opiepim/ocontactfields.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index 0f08a5a..deaa1e5 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp | |||
@@ -1,59 +1,88 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | Copyright (C) The Main Author <main-author@whereever.org> | ||
4 | =. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | */ | ||
1 | 29 | ||
2 | #include "ocontactfields.h" | 30 | #include <opie2/ocontactfields.h> |
3 | 31 | ||
4 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
5 | #include <qobject.h> | 33 | #include <qobject.h> |
6 | 34 | ||
7 | // We should use our own enum in the future .. | 35 | // We should use our own enum in the future .. |
8 | #include <qpe/recordfields.h> | 36 | #include <qpe/recordfields.h> |
9 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
10 | #include <opie/ocontact.h> | 38 | #include <opie2/ocontact.h> |
11 | 39 | ||
40 | namespace Opie { | ||
12 | /*! | 41 | /*! |
13 | \internal | 42 | \internal |
14 | Returns a list of personal field names for a contact. | 43 | Returns a list of personal field names for a contact. |
15 | */ | 44 | */ |
16 | QStringList OContactFields::personalfields( bool sorted, bool translated ) | 45 | QStringList OContactFields::personalfields( bool sorted, bool translated ) |
17 | { | 46 | { |
18 | QStringList list; | 47 | QStringList list; |
19 | QMap<int, QString> mapIdToStr; | 48 | QMap<int, QString> mapIdToStr; |
20 | if ( translated ) | 49 | if ( translated ) |
21 | mapIdToStr = idToTrFields(); | 50 | mapIdToStr = idToTrFields(); |
22 | else | 51 | else |
23 | mapIdToStr = idToUntrFields(); | 52 | mapIdToStr = idToUntrFields(); |
24 | 53 | ||
25 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); | 54 | list.append( mapIdToStr[ Qtopia::AddressUid ] ); |
26 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); | 55 | list.append( mapIdToStr[ Qtopia::AddressCategory ] ); |
27 | 56 | ||
28 | list.append( mapIdToStr[ Qtopia::Title ] ); | 57 | list.append( mapIdToStr[ Qtopia::Title ] ); |
29 | list.append( mapIdToStr[ Qtopia::FirstName ] ); | 58 | list.append( mapIdToStr[ Qtopia::FirstName ] ); |
30 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); | 59 | list.append( mapIdToStr[ Qtopia::MiddleName ] ); |
31 | list.append( mapIdToStr[ Qtopia::LastName ] ); | 60 | list.append( mapIdToStr[ Qtopia::LastName ] ); |
32 | list.append( mapIdToStr[ Qtopia::Suffix ] ); | 61 | list.append( mapIdToStr[ Qtopia::Suffix ] ); |
33 | list.append( mapIdToStr[ Qtopia::FileAs ] ); | 62 | list.append( mapIdToStr[ Qtopia::FileAs ] ); |
34 | 63 | ||
35 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); | 64 | list.append( mapIdToStr[ Qtopia::JobTitle ] ); |
36 | list.append( mapIdToStr[ Qtopia::Department ] ); | 65 | list.append( mapIdToStr[ Qtopia::Department ] ); |
37 | list.append( mapIdToStr[ Qtopia::Company ] ); | 66 | list.append( mapIdToStr[ Qtopia::Company ] ); |
38 | 67 | ||
39 | list.append( mapIdToStr[ Qtopia::Notes ] ); | 68 | list.append( mapIdToStr[ Qtopia::Notes ] ); |
40 | list.append( mapIdToStr[ Qtopia::Groups ] ); | 69 | list.append( mapIdToStr[ Qtopia::Groups ] ); |
41 | 70 | ||
42 | if (sorted) list.sort(); | 71 | if (sorted) list.sort(); |
43 | return list; | 72 | return list; |
44 | } | 73 | } |
45 | 74 | ||
46 | /*! | 75 | /*! |
47 | \internal | 76 | \internal |
48 | Returns a list of details field names for a contact. | 77 | Returns a list of details field names for a contact. |
49 | */ | 78 | */ |
50 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) | 79 | QStringList OContactFields::detailsfields( bool sorted, bool translated ) |
51 | { | 80 | { |
52 | QStringList list; | 81 | QStringList list; |
53 | QMap<int, QString> mapIdToStr; | 82 | QMap<int, QString> mapIdToStr; |
54 | if ( translated ) | 83 | if ( translated ) |
55 | mapIdToStr = idToTrFields(); | 84 | mapIdToStr = idToTrFields(); |
56 | else | 85 | else |
57 | mapIdToStr = idToUntrFields(); | 86 | mapIdToStr = idToUntrFields(); |
58 | 87 | ||
59 | list.append( mapIdToStr[ Qtopia::Office ] ); | 88 | list.append( mapIdToStr[ Qtopia::Office ] ); |
@@ -430,48 +459,50 @@ void OContactFields::loadFromRecord( const OContact &cnt ){ | |||
430 | 459 | ||
431 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); | 460 | qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); |
432 | 461 | ||
433 | if (fieldOrder.isEmpty()){ | 462 | if (fieldOrder.isEmpty()){ |
434 | fieldOrder = globalFieldOrder; | 463 | fieldOrder = globalFieldOrder; |
435 | } | 464 | } |
436 | 465 | ||
437 | 466 | ||
438 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); | 467 | qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); |
439 | } | 468 | } |
440 | 469 | ||
441 | void OContactFields::setFieldOrder( int num, int index ){ | 470 | void OContactFields::setFieldOrder( int num, int index ){ |
442 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); | 471 | qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); |
443 | 472 | ||
444 | fieldOrder[num] = QString::number( index, 16 )[0]; | 473 | fieldOrder[num] = QString::number( index, 16 )[0]; |
445 | 474 | ||
446 | // We will store this new fieldorder globally to | 475 | // We will store this new fieldorder globally to |
447 | // remember it for contacts which have none | 476 | // remember it for contacts which have none |
448 | globalFieldOrder = fieldOrder; | 477 | globalFieldOrder = fieldOrder; |
449 | changedFieldOrder = true; | 478 | changedFieldOrder = true; |
450 | 479 | ||
451 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 480 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); |
452 | } | 481 | } |
453 | 482 | ||
454 | int OContactFields::getFieldOrder( int num, int defIndex ){ | 483 | int OContactFields::getFieldOrder( int num, int defIndex ){ |
455 | qDebug("ocontactfields getFieldOrder"); | 484 | qDebug("ocontactfields getFieldOrder"); |
456 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); | 485 | qDebug("fieldOrder >%s<",fieldOrder.latin1()); |
457 | 486 | ||
458 | // Get index of combo as char.. | 487 | // Get index of combo as char.. |
459 | QChar poschar = fieldOrder[num]; | 488 | QChar poschar = fieldOrder[num]; |
460 | 489 | ||
461 | bool ok; | 490 | bool ok; |
462 | int ret = 0; | 491 | int ret = 0; |
463 | // Convert char to number.. | 492 | // Convert char to number.. |
464 | if ( !( poschar == QChar::null ) ) | 493 | if ( !( poschar == QChar::null ) ) |
465 | ret = QString( poschar ).toInt(&ok, 16); | 494 | ret = QString( poschar ).toInt(&ok, 16); |
466 | else | 495 | else |
467 | ok = false; | 496 | ok = false; |
468 | 497 | ||
469 | // Return default value if index for | 498 | // Return default value if index for |
470 | // num was not set or if anything else happened.. | 499 | // num was not set or if anything else happened.. |
471 | if ( !ok ) ret = defIndex; | 500 | if ( !ok ) ret = defIndex; |
472 | 501 | ||
473 | qDebug("returning >%i<",ret); | 502 | qDebug("returning >%i<",ret); |
474 | 503 | ||
475 | return ret; | 504 | return ret; |
476 | 505 | ||
477 | } | 506 | } |
507 | |||
508 | } | ||