Diffstat (limited to 'libopie2/opiepim/ocontactfields.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiepim/ocontactfields.cpp | 233 |
1 files changed, 122 insertions, 111 deletions
diff --git a/libopie2/opiepim/ocontactfields.cpp b/libopie2/opiepim/ocontactfields.cpp index 7206f0d..0f08a5a 100644 --- a/libopie2/opiepim/ocontactfields.cpp +++ b/libopie2/opiepim/ocontactfields.cpp @@ -6,73 +6,89 @@ // We should use our own enum in the future .. #include <qpe/recordfields.h> #include <qpe/config.h> #include <opie/ocontact.h> /*! \internal - Returns a list of details field names for a contact. + Returns a list of personal field names for a contact. */ -QStringList OContactFields::untrdetailsfields( bool sorted ) +QStringList OContactFields::personalfields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); + 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::AddressUid ] ); + list.append( mapIdToStr[ Qtopia::AddressCategory ] ); - 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 ] ); + 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 translated list of details field names for a contact. + Returns a list of details field names for a contact. */ -QStringList OContactFields::trdetailsfields( bool sorted ) +QStringList OContactFields::detailsfields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); + 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::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] ); + 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; } - /*! \internal - Returns a translated list of phone field names for a contact. + Returns a list of phone field names for a contact. */ -QStringList OContactFields::trphonefields( bool sorted ) +QStringList OContactFields::phonefields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); list.append( mapIdToStr[Qtopia::BusinessPhone] ); list.append( mapIdToStr[Qtopia::BusinessFax] ); list.append( mapIdToStr[Qtopia::BusinessMobile] ); list.append( mapIdToStr[Qtopia::BusinessPager] ); list.append( mapIdToStr[Qtopia::BusinessWebPage] ); list.append( mapIdToStr[Qtopia::DefaultEmail] ); @@ -84,137 +100,130 @@ QStringList OContactFields::trphonefields( bool sorted ) // list.append( mapIdToStr[Qtopia::HomePager] ); list.append( mapIdToStr[Qtopia::HomeWebPage] ); if (sorted) list.sort(); return list; } - /*! \internal - Returns a list of phone field names for a contact. + Returns a list of field names for a contact. */ -QStringList OContactFields::untrphonefields( bool sorted ) +QStringList OContactFields::fields( bool sorted, bool translated ) { QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); - - list.append( mapIdToStr[ Qtopia::BusinessPhone ] ); - list.append( mapIdToStr[ Qtopia::BusinessFax ] ); - list.append( mapIdToStr[ Qtopia::BusinessMobile ] ); - list.append( mapIdToStr[ Qtopia::BusinessPager ] ); - list.append( mapIdToStr[ Qtopia::BusinessWebPage ] ); - - list.append( mapIdToStr[ Qtopia::DefaultEmail ] ); - list.append( mapIdToStr[ Qtopia::Emails ] ); + QMap<int, QString> mapIdToStr; + if ( translated ) + mapIdToStr = idToTrFields(); + else + mapIdToStr = idToUntrFields(); - list.append( mapIdToStr[ Qtopia::HomePhone ] ); - list.append( mapIdToStr[ Qtopia::HomeFax ] ); - list.append( mapIdToStr[ Qtopia::HomeMobile ] ); - //list.append( mapIdToStr[Qtopia::HomePager] ); - list.append( mapIdToStr[Qtopia::HomeWebPage] ); + list += personalfields( sorted, translated ); - if (sorted) list.sort(); - - return list; -} - - -/*! - \internal - Returns a translated list of field names for a contact. -*/ -QStringList OContactFields::trfields( bool sorted ) -{ - QStringList list; - QMap<int, QString> mapIdToStr = idToTrFields(); - - 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 += trphonefields( sorted ); + list += phonefields( sorted, translated ); list.append( mapIdToStr[Qtopia::BusinessStreet] ); list.append( mapIdToStr[Qtopia::BusinessCity] ); list.append( mapIdToStr[Qtopia::BusinessState] ); list.append( mapIdToStr[Qtopia::BusinessZip] ); list.append( mapIdToStr[Qtopia::BusinessCountry] ); list.append( mapIdToStr[Qtopia::HomeStreet] ); list.append( mapIdToStr[Qtopia::HomeCity] ); list.append( mapIdToStr[Qtopia::HomeState] ); list.append( mapIdToStr[Qtopia::HomeZip] ); list.append( mapIdToStr[Qtopia::HomeCountry] ); - list += trdetailsfields( sorted ); - - list.append( mapIdToStr[Qtopia::Notes] ); - list.append( mapIdToStr[Qtopia::Groups] ); + list += detailsfields( sorted, translated ); if (sorted) list.sort(); return list; } + /*! \internal - Returns an untranslated list of field names for a contact. + Returns an untranslated list of personal field names for a contact. */ -QStringList OContactFields::untrfields( bool sorted ) +QStringList OContactFields::untrpersonalfields( bool sorted ) { - QStringList list; - QMap<int, QString> mapIdToStr = idToUntrFields(); + return personalfields( sorted, false ); +} - 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 ] ); +/*! + \internal + Returns a translated list of personal field names for a contact. +*/ +QStringList OContactFields::trpersonalfields( bool sorted ) +{ + return personalfields( sorted, true ); +} - list.append( mapIdToStr[ Qtopia::JobTitle ] ); - list.append( mapIdToStr[ Qtopia::Department ] ); - list.append( mapIdToStr[ Qtopia::Company ] ); - list += untrphonefields( sorted ); +/*! + \internal + Returns an untranslated list of details field names for a contact. +*/ +QStringList OContactFields::untrdetailsfields( bool sorted ) +{ + return detailsfields( sorted, false ); +} - list.append( mapIdToStr[ Qtopia::BusinessStreet ] ); - list.append( mapIdToStr[ Qtopia::BusinessCity ] ); - list.append( mapIdToStr[ Qtopia::BusinessState ] ); - list.append( mapIdToStr[ Qtopia::BusinessZip ] ); - list.append( mapIdToStr[ Qtopia::BusinessCountry ] ); - list.append( mapIdToStr[ Qtopia::HomeStreet ] ); - list.append( mapIdToStr[ Qtopia::HomeCity ] ); - list.append( mapIdToStr[ Qtopia::HomeState ] ); - list.append( mapIdToStr[ Qtopia::HomeZip ] ); - list.append( mapIdToStr[ Qtopia::HomeCountry ] ); +/*! + \internal + Returns a translated list of details field names for a contact. +*/ +QStringList OContactFields::trdetailsfields( bool sorted ) +{ + return detailsfields( sorted, true ); +} - list += untrdetailsfields( sorted ); - list.append( mapIdToStr[ Qtopia::Notes ] ); - list.append( mapIdToStr[ Qtopia::Groups ] ); +/*! + \internal + Returns a translated list of phone field names for a contact. +*/ +QStringList OContactFields::trphonefields( bool sorted ) +{ + return phonefields( sorted, true ); +} - if (sorted) list.sort(); +/*! + \internal + Returns an untranslated list of phone field names for a contact. +*/ +QStringList OContactFields::untrphonefields( bool sorted ) +{ + return phonefields( sorted, false ); +} - return list; + +/*! + \internal + Returns a translated list of field names for a contact. +*/ +QStringList OContactFields::trfields( bool sorted ) +{ + return fields( sorted, true ); +} + +/*! + \internal + Returns an untranslated list of field names for a contact. +*/ +QStringList OContactFields::untrfields( bool sorted ) +{ + return fields( sorted, false ); } + QMap<int, QString> OContactFields::idToTrFields() { QMap<int, QString> ret_map; ret_map.insert( Qtopia::AddressUid, QObject::tr( "User Id" ) ); ret_map.insert( Qtopia::AddressCategory, QObject::tr( "Categories" ) ); ret_map.insert( Qtopia::Title, QObject::tr( "Name Title") ); @@ -324,17 +333,17 @@ QMap<int, QString> OContactFields::idToUntrFields() ret_map.insert( Qtopia::HomeCity, "Home City" ); ret_map.insert( Qtopia::HomeState, "Home State" ); ret_map.insert( Qtopia::HomeZip, "Home Zip" ); ret_map.insert( Qtopia::HomeCountry, "Home Country" ); ret_map.insert( Qtopia::HomeWebPage, "Home Web Page" ); //personal ret_map.insert( Qtopia::Spouse, "Spouse" ); - ret_map.insert( Qtopia::Gender, "Gender" ); + ret_map.insert( Qtopia::Gender, "Gender" ); ret_map.insert( Qtopia::Birthday, "Birthday" ); ret_map.insert( Qtopia::Anniversary, "Anniversary" ); ret_map.insert( Qtopia::Nickname, "Nickname" ); ret_map.insert( Qtopia::Children, "Children" ); // other ret_map.insert( Qtopia::Notes, "Notes" ); ret_map.insert( Qtopia::Groups, "Groups" ); @@ -352,16 +361,18 @@ QMap<QString, int> OContactFields::trFieldsToId() QMap<int, QString>::Iterator it; for( it = idtostr.begin(); it != idtostr.end(); ++it ) ret_map.insert( *it, it.key() ); return ret_map; } +/* ======================================================================= */ + QMap<QString, int> OContactFields::untrFieldsToId() { QMap<int, QString> idtostr = idToUntrFields(); QMap<QString, int> ret_map; QMap<int, QString>::Iterator it; for( it = idtostr.begin(); it != idtostr.end(); ++it ) |