From 6c715b67a8f0e32a4edca5be91332622834c8d91 Mon Sep 17 00:00:00 2001 From: eilers Date: Fri, 01 Aug 2003 12:30:16 +0000 Subject: Merging changes from BRANCH_1_0 to HEAD --- (limited to 'libopie2/opiepim/ocontact.cpp') diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index be4ce0a..3473baa 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp @@ -21,10 +21,11 @@ #include "ocontact.h" #include "opimresolver.h" +#include "oconversion.h" #include -#include "oconversion.h" #include +#include #include #include @@ -438,12 +439,16 @@ QString OContact::toRichText() const QString str; bool marker = false; + Config cfg("qpe"); + cfg.setGroup("Appearance"); + int addressformat = cfg.readNumEntry( "AddressFormat", Zip_City_State ); + // name, jobtitle and company if ( !(value = fullName()).isEmpty() ) - text += "

" + Qtopia::escapeString(value) + "

"; - + text += "

" + Qtopia::escapeString(value) + "

"; + if ( !(value = jobTitle()).isEmpty() ) - text += Qtopia::escapeString(value) + "
"; + text += Qtopia::escapeString(value); comp = company(); if ( !(value = department()).isEmpty() ) { @@ -454,77 +459,110 @@ QString OContact::toRichText() const text += "
"; } if ( !comp.isEmpty() ) - text += Qtopia::escapeString(comp) + "
"; + text += Qtopia::escapeString(comp); - text += "

"; + text += "

"; // defailt email QString defEmail = defaultEmail(); - if ( !defEmail.isEmpty() ) - text += "" + QObject::tr("Default Email: ") + "" - + Qtopia::escapeString(defEmail) + "
"; - - text += "
"; + if ( !defEmail.isEmpty() ){ + text += " " + QObject::tr("Default Email: ") + "" + + Qtopia::escapeString(defEmail); + marker = true; + } // business address if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || !businessZip().isEmpty() || !businessCountry().isEmpty() ) { - text += QObject::tr( "Work Address:" ); - text += "
"; + text += QObject::tr( "

Work Address:" ); marker = true; } - if ( !(value = businessStreet()).isEmpty() ) - text += Qtopia::escapeString(value) + "
"; - state = businessState(); - if ( !(value = businessZip()).isEmpty() ) - text += Qtopia::escapeString(value) + " "; - if ( !(value = businessCity()).isEmpty() ) { - text += Qtopia::escapeString(value); - if ( state ) - text += ", " + Qtopia::escapeString(state); - text += "
"; - } else if ( !state.isEmpty() ) - text += Qtopia::escapeString(state) + "
"; + if ( !(value = businessStreet()).isEmpty() ){ + text += "
" + Qtopia::escapeString(value); + marker = true; + } + + switch( addressformat ){ + case Zip_City_State:{ // Zip_Code City, State + state = businessState(); + if ( !(value = businessZip()).isEmpty() ){ + text += "
" + Qtopia::escapeString(value) + " "; + marker = true; + + } else + text += "
"; + + if ( !(value = businessCity()).isEmpty() ) { + marker = true; + text += Qtopia::escapeString(value); + if ( state ) + text += ", " + Qtopia::escapeString(state); + } else if ( !state.isEmpty() ){ + text += "
" + Qtopia::escapeString(state); + marker = true; + } + break; + } + case City_State_Zip:{ // City, State Zip_Code + state = businessState(); + if ( !(value = businessCity()).isEmpty() ) { + marker = true; + text += "
" + Qtopia::escapeString(value); + if ( state ) + text += ", " + Qtopia::escapeString(state); + } else if ( !state.isEmpty() ){ + text += "
" + Qtopia::escapeString(state); + marker = true; + } + if ( !(value = businessZip()).isEmpty() ){ + text += " " + Qtopia::escapeString(value); + marker = true; + } + break; + } + } - if ( !(value = businessCountry()).isEmpty() ) - text += Qtopia::escapeString(value) + "
"; + if ( !(value = businessCountry()).isEmpty() ){ + text += "
" + Qtopia::escapeString(value); + marker = true; + } // rest of Business data str = office(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Office: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Office: ") + "" + + Qtopia::escapeString(str); marker = true; } str = businessWebpage(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Business Web Page: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Business Web Page: ") + "" + + Qtopia::escapeString(str); marker = true; } str = businessPhone(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Business Phone: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Business Phone: ") + "" + + Qtopia::escapeString(str); marker = true; } str = businessFax(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Business Fax: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Business Fax: ") + "" + + Qtopia::escapeString(str); marker = true; } str = businessMobile(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Business Mobile: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Business Mobile: ") + "" + + Qtopia::escapeString(str); marker = true; } str = businessPager(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Business Pager: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Business Pager: ") + "" + + Qtopia::escapeString(str); marker = true; } @@ -533,107 +571,142 @@ QString OContact::toRichText() const // home address if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || !homeZip().isEmpty() || !homeCountry().isEmpty() ) { - text += QObject::tr( "Home Address:" ); - text += "
"; + text += QObject::tr( "

Home Address:" ); + marker = true; } - if ( !(value = homeStreet()).isEmpty() ) - text += Qtopia::escapeString(value) + "
"; - state = homeState(); - if ( !(value = homeZip()).isEmpty() ) - text += Qtopia::escapeString(value) + " "; - if ( !(value = homeCity()).isEmpty() ) { - text += Qtopia::escapeString(value); - if ( !state.isEmpty() ) - text += ", " + Qtopia::escapeString(state); - text += "
"; - } else if (!state.isEmpty()) - text += Qtopia::escapeString(state) + "
"; - if ( !(value = homeCountry()).isEmpty() ) - text += Qtopia::escapeString(value) + "
"; + if ( !(value = homeStreet()).isEmpty() ){ + text += "
" + Qtopia::escapeString(value); + marker = true; + } + + switch( addressformat ){ + case Zip_City_State:{ // Zip_Code City, State + state = homeState(); + if ( !(value = homeZip()).isEmpty() ){ + text += "
" + Qtopia::escapeString(value) + " "; + marker = true; + } else + text += "
"; + + if ( !(value = homeCity()).isEmpty() ) { + marker = true; + text += Qtopia::escapeString(value); + if ( !state.isEmpty() ) + text += ", " + Qtopia::escapeString(state); + } else if (!state.isEmpty()) { + text += "
" + Qtopia::escapeString(state); + marker = true; + } + break; + } + case City_State_Zip:{ // City, State Zip_Code + state = homeState(); + if ( !(value = homeCity()).isEmpty() ) { + marker = true; + text += "
" + Qtopia::escapeString(value); + if ( state ) + text += ", " + Qtopia::escapeString(state); + } else if ( !state.isEmpty() ){ + text += "
" + Qtopia::escapeString(state); + marker = true; + } + if ( !(value = homeZip()).isEmpty() ){ + text += " " + Qtopia::escapeString(value); + marker = true; + } + break; + } + } + + if ( !(value = homeCountry()).isEmpty() ){ + text += "
" + Qtopia::escapeString(value); + marker = true; + } // rest of Home data str = homeWebpage(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Home Web Page: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Home Web Page: ") + "" + + Qtopia::escapeString(str); marker = true; } str = homePhone(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Home Phone: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Home Phone: ") + "" + + Qtopia::escapeString(str); marker = true; } str = homeFax(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Home Fax: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Home Fax: ") + "" + + Qtopia::escapeString(str); marker = true; } str = homeMobile(); if ( !str.isEmpty() ){ - text += "" + QObject::tr("Home Mobile: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Home Mobile: ") + "" + + Qtopia::escapeString(str); marker = true; } if ( marker ) - text += "


"; - // the others... + text += "

"; + + // the rest... str = emails(); if ( !str.isEmpty() && ( str != defEmail ) ) - text += "" + QObject::tr("All Emails: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("All Emails: ") + "" + + Qtopia::escapeString(str); str = profession(); if ( !str.isEmpty() ) - text += "" + QObject::tr("Profession: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Profession: ") + "" + + Qtopia::escapeString(str); str = assistant(); if ( !str.isEmpty() ) - text += "" + QObject::tr("Assistant: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Assistant: ") + "" + + Qtopia::escapeString(str); str = manager(); if ( !str.isEmpty() ) - text += "" + QObject::tr("Manager: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Manager: ") + "" + + Qtopia::escapeString(str); str = gender(); if ( !str.isEmpty() && str.toInt() != 0 ) { - if ( str.toInt() == 1 ) - str = QObject::tr( "Male" ); - else if ( str.toInt() == 2 ) - str = QObject::tr( "Female" ); - text += "" + QObject::tr("Gender: ") + "" + str + "
"; + text += "
"; + if ( str.toInt() == 1 ) + str = QObject::tr( "Male" ); + else if ( str.toInt() == 2 ) + str = QObject::tr( "Female" ); + text += "" + QObject::tr("Gender: ") + "" + str; } str = spouse(); if ( !str.isEmpty() ) - text += "" + QObject::tr("Spouse: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Spouse: ") + "" + + Qtopia::escapeString(str); if ( birthday().isValid() ){ str = TimeString::numberDateString( birthday() ); - text += "" + QObject::tr("Birthday: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Birthday: ") + "" + + Qtopia::escapeString(str); } if ( anniversary().isValid() ){ str = TimeString::numberDateString( anniversary() ); - text += "" + QObject::tr("Anniversary: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Anniversary: ") + "" + + Qtopia::escapeString(str); } str = children(); if ( !str.isEmpty() ) - text += "" + QObject::tr("Children: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Children: ") + "" + + Qtopia::escapeString(str); str = nickname(); if ( !str.isEmpty() ) - text += "" + QObject::tr("Nickname: ") + "" - + Qtopia::escapeString(str) + "
"; + text += "
" + QObject::tr("Nickname: ") + "" + + Qtopia::escapeString(str); // categories if ( categoryNames("Contacts").count() ){ - text += "" + QObject::tr( "Category:") + " "; + text += "
" + QObject::tr( "Category:") + " "; text += categoryNames("Contacts").join(", "); - text += "
"; } // notes last -- cgit v0.9.0.2