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,75 +1,104 @@ +/* + This file is part of the Opie Project + Copyright (C) The Main Author <main-author@whereever.org> + =. Copyright (C) The Opie Team <opie-devel@handhelds.org> + .=l. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ -#include "ocontactfields.h" +#include <opie2/ocontactfields.h> #include <qstringlist.h> #include <qobject.h> // We should use our own enum in the future .. #include <qpe/recordfields.h> #include <qpe/config.h> -#include <opie/ocontact.h> +#include <opie2/ocontact.h> +namespace Opie { /*! \internal Returns a list of personal field names for a contact. */ QStringList OContactFields::personalfields( bool sorted, bool translated ) { QStringList list; QMap<int, QString> mapIdToStr; if ( translated ) mapIdToStr = idToTrFields(); else mapIdToStr = idToUntrFields(); list.append( mapIdToStr[ Qtopia::AddressUid ] ); list.append( mapIdToStr[ Qtopia::AddressCategory ] ); list.append( mapIdToStr[ Qtopia::Title ] ); list.append( mapIdToStr[ Qtopia::FirstName ] ); list.append( mapIdToStr[ Qtopia::MiddleName ] ); list.append( mapIdToStr[ Qtopia::LastName ] ); list.append( mapIdToStr[ Qtopia::Suffix ] ); list.append( mapIdToStr[ Qtopia::FileAs ] ); list.append( mapIdToStr[ Qtopia::JobTitle ] ); list.append( mapIdToStr[ Qtopia::Department ] ); list.append( mapIdToStr[ Qtopia::Company ] ); list.append( mapIdToStr[ Qtopia::Notes ] ); list.append( mapIdToStr[ Qtopia::Groups ] ); if (sorted) list.sort(); return list; } /*! \internal Returns a list of details field names for a contact. */ QStringList OContactFields::detailsfields( bool sorted, bool translated ) { QStringList list; QMap<int, QString> mapIdToStr; if ( translated ) mapIdToStr = idToTrFields(); else mapIdToStr = idToUntrFields(); list.append( mapIdToStr[ Qtopia::Office ] ); list.append( mapIdToStr[ Qtopia::Profession ] ); list.append( mapIdToStr[ Qtopia::Assistant ] ); list.append( mapIdToStr[ Qtopia::Manager ] ); list.append( mapIdToStr[ Qtopia::Spouse ] ); list.append( mapIdToStr[ Qtopia::Gender ] ); list.append( mapIdToStr[ Qtopia::Birthday ] ); list.append( mapIdToStr[ Qtopia::Anniversary ] ); list.append( mapIdToStr[ Qtopia::Nickname ] ); list.append( mapIdToStr[ Qtopia::Children ] ); if (sorted) list.sort(); return list; } /*! @@ -414,64 +443,66 @@ void OContactFields::saveToRecord( OContact &cnt ){ // Store fieldorder into this contact. cnt.setCustomField( CONTACT_FIELD_ORDER_NAME, fieldOrder ); globalFieldOrder = fieldOrder; changedFieldOrder = true; } void OContactFields::loadFromRecord( const OContact &cnt ){ qDebug("ocontactfields loadFromRecord"); qDebug("loading >%s<",cnt.fullName().latin1()); // Get fieldorder for this contact. If none is defined, // we will use the global one from the config file.. fieldOrder = cnt.customField( CONTACT_FIELD_ORDER_NAME ); qDebug("fieldOrder from contact>%s<",fieldOrder.latin1()); if (fieldOrder.isEmpty()){ fieldOrder = globalFieldOrder; } qDebug("effective fieldOrder in loadFromRecord >%s<",fieldOrder.latin1()); } void OContactFields::setFieldOrder( int num, int index ){ qDebug("qcontactfields setfieldorder pos %i -> %i",num,index); fieldOrder[num] = QString::number( index, 16 )[0]; // We will store this new fieldorder globally to // remember it for contacts which have none globalFieldOrder = fieldOrder; changedFieldOrder = true; qDebug("fieldOrder >%s<",fieldOrder.latin1()); } int OContactFields::getFieldOrder( int num, int defIndex ){ qDebug("ocontactfields getFieldOrder"); qDebug("fieldOrder >%s<",fieldOrder.latin1()); // Get index of combo as char.. QChar poschar = fieldOrder[num]; bool ok; int ret = 0; // Convert char to number.. if ( !( poschar == QChar::null ) ) ret = QString( poschar ).toInt(&ok, 16); else ok = false; // Return default value if index for // num was not set or if anything else happened.. if ( !ok ) ret = defIndex; qDebug("returning >%i<",ret); return ret; } + +} |