summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-07-07 06:29:27 (UTC)
committer zautrix <zautrix>2004-07-07 06:29:27 (UTC)
commitf2bf08414f8006f0ddedc293804566b3b154428c (patch) (side-by-side diff)
treea611e80fb264c5f2c8551982b1bc6a6da6d8e6d6
parentc9c0fefaead651c073318e8242d86675519dbcf6 (diff)
downloadkdepimpi-f2bf08414f8006f0ddedc293804566b3b154428c.zip
kdepimpi-f2bf08414f8006f0ddedc293804566b3b154428c.tar.gz
kdepimpi-f2bf08414f8006f0ddedc293804566b3b154428c.tar.bz2
Fix of the address type == other problem
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--kabc/address.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/kabc/address.cpp b/kabc/address.cpp
index 26e0b6a..c820a6c 100644
--- a/kabc/address.cpp
+++ b/kabc/address.cpp
@@ -165,282 +165,303 @@ QString Address::extended() const
{
return mExtended;
}
QString Address::extendedLabel()
{
return i18n("Extended Address Information");
}
void Address::setStreet( const QString &s )
{
mEmpty = false;
mStreet = s;
}
QString Address::street() const
{
return mStreet;
}
QString Address::streetLabel()
{
return i18n("Street");
}
void Address::setLocality( const QString &s )
{
mEmpty = false;
mLocality = s;
}
QString Address::locality() const
{
return mLocality;
}
QString Address::localityLabel()
{
return i18n("Locality");
}
void Address::setRegion( const QString &s )
{
mEmpty = false;
mRegion = s;
}
QString Address::region() const
{
return mRegion;
}
QString Address::regionLabel()
{
return i18n("Region");
}
void Address::setPostalCode( const QString &s )
{
mEmpty = false;
mPostalCode = s;
}
QString Address::postalCode() const
{
return mPostalCode;
}
QString Address::postalCodeLabel()
{
return i18n("Postal Code");
}
void Address::setCountry( const QString &s )
{
mEmpty = false;
mCountry = s;
}
QString Address::country() const
{
return mCountry;
}
QString Address::countryLabel()
{
return i18n("Country");
}
void Address::setLabel( const QString &s )
{
mEmpty = false;
mLabel = s;
}
QString Address::label() const
{
return mLabel;
}
QString Address::labelLabel()
{
return i18n("Delivery Label");
}
Address::TypeList Address::typeList()
{
TypeList list;
list << Dom << Intl << Postal << Parcel << Home << Work << Pref;
return list;
}
QString Address::typeLabel( int type )
{
+ QString label;
+ if ( type & Dom )
+ label += i18n("Domestic")+" ";
+ if ( type & Intl )
+ label += i18n("International")+" ";
+ if ( type & Postal )
+ label += i18n("Postal")+" ";
+ if ( type & Parcel )
+ label += i18n("Parcel")+" ";
+ if ( type & Work )
+ label += i18n("Work Address", "Work")+" ";
+ if ( type & Home )
+ label += i18n("Home Address", "Home") +" ";
+ if ( type & Pref )
+ label += i18n("Preferred Address", "(p)");
+ if ( label.isEmpty() )
+ label = i18n("Other");
+ return label;
+
+#if 0
switch ( type ) {
case Dom:
return i18n("Domestic");
break;
case Intl:
return i18n("International");
break;
case Postal:
return i18n("Postal");
break;
case Parcel:
return i18n("Parcel");
break;
case Home:
return i18n("Home Address", "Home");
break;
case Work:
return i18n("Work Address", "Work");
break;
case Pref:
return i18n("Preferred Address");
break;
default:
return i18n("Other");
break;
}
+#endif
}
void Address::dump() const
{
qDebug("Address::dump() +++++++++++++++++ ");
#if 0
kdDebug(5700) << " Address {" << endl;
kdDebug(5700) << " Id: " << id() << endl;
kdDebug(5700) << " Extended: " << extended() << endl;
kdDebug(5700) << " Street: " << street() << endl;
kdDebug(5700) << " Postal Code: " << postalCode() << endl;
kdDebug(5700) << " Locality: " << locality() << endl;
kdDebug(5700) << " }" << endl;
#endif
}
QString Address::formattedAddress( const QString &realName
, const QString &orgaName ) const
{
QString ciso;
QString addrTemplate;
QString ret;
// **************************************************************
// LR: currently we have no iso handling - we will format the address manually here
QString text;
if ( !street().isEmpty() )
text += street() + "\n";
if ( !postOfficeBox().isEmpty() )
text += postOfficeBox() + "\n";
text += locality() + QString(" ") + region();
if ( !postalCode().isEmpty() )
text += QString(", ") + postalCode();
text += "\n";
if ( !country().isEmpty() )
text += country() + "\n";
text += extended();
return text;
// **************************************************************
// FIXME: first check for iso-country-field and prefer that one
if ( !country().isEmpty() ) {
ciso = countryToISO( country() );
} else {
// fall back to our own country
ciso = KGlobal::locale()->country();
}
//qDebug("ciso %s ",ciso.latin1() );
KSimpleConfig entry( locate( "locale",
QString( "l10n/" ) + ciso + QString( "/entry.desktop" ) ) );
entry.setGroup( "KCM Locale" );
// decide whether this needs special business address formatting
if ( orgaName.isNull() ) {
addrTemplate = entry.readEntry( "AddressFormat" );
} else {
addrTemplate = entry.readEntry( "BusinessAddressFormat" );
if ( addrTemplate.isEmpty() )
addrTemplate = entry.readEntry( "AddressFormat" );
}
// in the case there's no format found at all, default to what we've always
// used:
if ( addrTemplate.isEmpty() ) {
qDebug("address format database incomplete****************** ");
kdWarning(5700) << "address format database incomplete "
<< "(no format for locale " << ciso
<< " found). Using default address formatting." << endl;
addrTemplate = "%0(%n\\n)%0(%cm\\n)%0(%s\\n)%0(PO BOX %p\\n)%0(%l%w%r)%,%z";
}
// scan
parseAddressTemplateSection( addrTemplate, ret, realName, orgaName );
// now add the country line if needed (formatting this time according to
// the rules of our own system country )
if ( !country().isEmpty() ) {
KSimpleConfig entry( locate( "locale", QString( "l10n/" )
+ KGlobal::locale()->country() + QString( "/entry.desktop" ) ) );
entry.setGroup( "KCM Locale" );
QString cpos = entry.readEntry( "AddressCountryPosition" );
if ( "BELOW" == cpos || cpos.isEmpty() ) {
ret = ret + "\n\n" + country().upper();
} else if ( "below" == cpos ) {
ret = ret + "\n\n" + country();
} else if ( "ABOVE" == cpos ) {
ret = country().upper() + "\n\n" + ret;
} else if ( "above" == cpos ) {
ret = country() + "\n\n" + ret;
}
}
return ret;
}
bool Address::parseAddressTemplateSection( const QString &tsection,
QString &result, const QString &realName, const QString &orgaName ) const
{
// This method first parses and substitutes any bracketed sections and
// after that replaces any tags with their values. If a bracketed section
// or a tag evaluate to zero, they are not just removed but replaced
// with a placeholder. This is because in the last step conditionals are
// resolved which depend on information about zero-evaluations.
result = tsection;
int stpos = 0;
bool ret = false;
// first check for brackets that have to be evaluated first
int fpos = result.find( KABC_FMTTAG_purgeempty, stpos );
while ( -1 != fpos ) {
int bpos1 = fpos + KABC_FMTTAG_purgeempty.length();
int bpos2;
// expect opening bracket and find next balanced closing bracket. If
// next char is no opening bracket, continue parsing (no valid tag)
if ( '(' == result[bpos1] ) {
bpos2 = findBalancedBracket( result, bpos1 );
if ( -1 != bpos2 ) {
// we have balanced brackets, recursively parse: