author | zautrix <zautrix> | 2004-07-07 06:29:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-07-07 06:29:27 (UTC) |
commit | f2bf08414f8006f0ddedc293804566b3b154428c (patch) (unidiff) | |
tree | a611e80fb264c5f2c8551982b1bc6a6da6d8e6d6 | |
parent | c9c0fefaead651c073318e8242d86675519dbcf6 (diff) | |
download | kdepimpi-f2bf08414f8006f0ddedc293804566b3b154428c.zip kdepimpi-f2bf08414f8006f0ddedc293804566b3b154428c.tar.gz kdepimpi-f2bf08414f8006f0ddedc293804566b3b154428c.tar.bz2 |
Fix of the address type == other problem
-rw-r--r-- | kabc/address.cpp | 21 |
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 | |||
@@ -197,218 +197,239 @@ void Address::setLocality( const QString &s ) | |||
197 | mLocality = s; | 197 | mLocality = s; |
198 | } | 198 | } |
199 | 199 | ||
200 | QString Address::locality() const | 200 | QString Address::locality() const |
201 | { | 201 | { |
202 | return mLocality; | 202 | return mLocality; |
203 | } | 203 | } |
204 | 204 | ||
205 | QString Address::localityLabel() | 205 | QString Address::localityLabel() |
206 | { | 206 | { |
207 | return i18n("Locality"); | 207 | return i18n("Locality"); |
208 | } | 208 | } |
209 | 209 | ||
210 | 210 | ||
211 | void Address::setRegion( const QString &s ) | 211 | void Address::setRegion( const QString &s ) |
212 | { | 212 | { |
213 | mEmpty = false; | 213 | mEmpty = false; |
214 | 214 | ||
215 | mRegion = s; | 215 | mRegion = s; |
216 | } | 216 | } |
217 | 217 | ||
218 | QString Address::region() const | 218 | QString Address::region() const |
219 | { | 219 | { |
220 | return mRegion; | 220 | return mRegion; |
221 | } | 221 | } |
222 | 222 | ||
223 | QString Address::regionLabel() | 223 | QString Address::regionLabel() |
224 | { | 224 | { |
225 | return i18n("Region"); | 225 | return i18n("Region"); |
226 | } | 226 | } |
227 | 227 | ||
228 | 228 | ||
229 | void Address::setPostalCode( const QString &s ) | 229 | void Address::setPostalCode( const QString &s ) |
230 | { | 230 | { |
231 | mEmpty = false; | 231 | mEmpty = false; |
232 | 232 | ||
233 | mPostalCode = s; | 233 | mPostalCode = s; |
234 | } | 234 | } |
235 | 235 | ||
236 | QString Address::postalCode() const | 236 | QString Address::postalCode() const |
237 | { | 237 | { |
238 | return mPostalCode; | 238 | return mPostalCode; |
239 | } | 239 | } |
240 | 240 | ||
241 | QString Address::postalCodeLabel() | 241 | QString Address::postalCodeLabel() |
242 | { | 242 | { |
243 | return i18n("Postal Code"); | 243 | return i18n("Postal Code"); |
244 | } | 244 | } |
245 | 245 | ||
246 | 246 | ||
247 | void Address::setCountry( const QString &s ) | 247 | void Address::setCountry( const QString &s ) |
248 | { | 248 | { |
249 | mEmpty = false; | 249 | mEmpty = false; |
250 | 250 | ||
251 | mCountry = s; | 251 | mCountry = s; |
252 | } | 252 | } |
253 | 253 | ||
254 | QString Address::country() const | 254 | QString Address::country() const |
255 | { | 255 | { |
256 | return mCountry; | 256 | return mCountry; |
257 | } | 257 | } |
258 | 258 | ||
259 | QString Address::countryLabel() | 259 | QString Address::countryLabel() |
260 | { | 260 | { |
261 | return i18n("Country"); | 261 | return i18n("Country"); |
262 | } | 262 | } |
263 | 263 | ||
264 | 264 | ||
265 | void Address::setLabel( const QString &s ) | 265 | void Address::setLabel( const QString &s ) |
266 | { | 266 | { |
267 | mEmpty = false; | 267 | mEmpty = false; |
268 | 268 | ||
269 | mLabel = s; | 269 | mLabel = s; |
270 | } | 270 | } |
271 | 271 | ||
272 | QString Address::label() const | 272 | QString Address::label() const |
273 | { | 273 | { |
274 | return mLabel; | 274 | return mLabel; |
275 | } | 275 | } |
276 | 276 | ||
277 | QString Address::labelLabel() | 277 | QString Address::labelLabel() |
278 | { | 278 | { |
279 | return i18n("Delivery Label"); | 279 | return i18n("Delivery Label"); |
280 | } | 280 | } |
281 | 281 | ||
282 | Address::TypeList Address::typeList() | 282 | Address::TypeList Address::typeList() |
283 | { | 283 | { |
284 | TypeList list; | 284 | TypeList list; |
285 | 285 | ||
286 | list << Dom << Intl << Postal << Parcel << Home << Work << Pref; | 286 | list << Dom << Intl << Postal << Parcel << Home << Work << Pref; |
287 | 287 | ||
288 | return list; | 288 | return list; |
289 | } | 289 | } |
290 | 290 | ||
291 | QString Address::typeLabel( int type ) | 291 | QString Address::typeLabel( int type ) |
292 | { | 292 | { |
293 | QString label; | ||
294 | if ( type & Dom ) | ||
295 | label += i18n("Domestic")+" "; | ||
296 | if ( type & Intl ) | ||
297 | label += i18n("International")+" "; | ||
298 | if ( type & Postal ) | ||
299 | label += i18n("Postal")+" "; | ||
300 | if ( type & Parcel ) | ||
301 | label += i18n("Parcel")+" "; | ||
302 | if ( type & Work ) | ||
303 | label += i18n("Work Address", "Work")+" "; | ||
304 | if ( type & Home ) | ||
305 | label += i18n("Home Address", "Home") +" "; | ||
306 | if ( type & Pref ) | ||
307 | label += i18n("Preferred Address", "(p)"); | ||
308 | if ( label.isEmpty() ) | ||
309 | label = i18n("Other"); | ||
310 | return label; | ||
311 | |||
312 | #if 0 | ||
293 | switch ( type ) { | 313 | switch ( type ) { |
294 | case Dom: | 314 | case Dom: |
295 | return i18n("Domestic"); | 315 | return i18n("Domestic"); |
296 | break; | 316 | break; |
297 | case Intl: | 317 | case Intl: |
298 | return i18n("International"); | 318 | return i18n("International"); |
299 | break; | 319 | break; |
300 | case Postal: | 320 | case Postal: |
301 | return i18n("Postal"); | 321 | return i18n("Postal"); |
302 | break; | 322 | break; |
303 | case Parcel: | 323 | case Parcel: |
304 | return i18n("Parcel"); | 324 | return i18n("Parcel"); |
305 | break; | 325 | break; |
306 | case Home: | 326 | case Home: |
307 | return i18n("Home Address", "Home"); | 327 | return i18n("Home Address", "Home"); |
308 | break; | 328 | break; |
309 | case Work: | 329 | case Work: |
310 | return i18n("Work Address", "Work"); | 330 | return i18n("Work Address", "Work"); |
311 | break; | 331 | break; |
312 | case Pref: | 332 | case Pref: |
313 | return i18n("Preferred Address"); | 333 | return i18n("Preferred Address"); |
314 | break; | 334 | break; |
315 | default: | 335 | default: |
316 | return i18n("Other"); | 336 | return i18n("Other"); |
317 | break; | 337 | break; |
318 | } | 338 | } |
339 | #endif | ||
319 | } | 340 | } |
320 | 341 | ||
321 | void Address::dump() const | 342 | void Address::dump() const |
322 | { | 343 | { |
323 | qDebug("Address::dump() +++++++++++++++++ "); | 344 | qDebug("Address::dump() +++++++++++++++++ "); |
324 | #if 0 | 345 | #if 0 |
325 | kdDebug(5700) << " Address {" << endl; | 346 | kdDebug(5700) << " Address {" << endl; |
326 | kdDebug(5700) << " Id: " << id() << endl; | 347 | kdDebug(5700) << " Id: " << id() << endl; |
327 | kdDebug(5700) << " Extended: " << extended() << endl; | 348 | kdDebug(5700) << " Extended: " << extended() << endl; |
328 | kdDebug(5700) << " Street: " << street() << endl; | 349 | kdDebug(5700) << " Street: " << street() << endl; |
329 | kdDebug(5700) << " Postal Code: " << postalCode() << endl; | 350 | kdDebug(5700) << " Postal Code: " << postalCode() << endl; |
330 | kdDebug(5700) << " Locality: " << locality() << endl; | 351 | kdDebug(5700) << " Locality: " << locality() << endl; |
331 | kdDebug(5700) << " }" << endl; | 352 | kdDebug(5700) << " }" << endl; |
332 | #endif | 353 | #endif |
333 | } | 354 | } |
334 | 355 | ||
335 | 356 | ||
336 | QString Address::formattedAddress( const QString &realName | 357 | QString Address::formattedAddress( const QString &realName |
337 | , const QString &orgaName ) const | 358 | , const QString &orgaName ) const |
338 | { | 359 | { |
339 | QString ciso; | 360 | QString ciso; |
340 | QString addrTemplate; | 361 | QString addrTemplate; |
341 | QString ret; | 362 | QString ret; |
342 | 363 | ||
343 | // ************************************************************** | 364 | // ************************************************************** |
344 | // LR: currently we have no iso handling - we will format the address manually here | 365 | // LR: currently we have no iso handling - we will format the address manually here |
345 | 366 | ||
346 | QString text; | 367 | QString text; |
347 | if ( !street().isEmpty() ) | 368 | if ( !street().isEmpty() ) |
348 | text += street() + "\n"; | 369 | text += street() + "\n"; |
349 | 370 | ||
350 | if ( !postOfficeBox().isEmpty() ) | 371 | if ( !postOfficeBox().isEmpty() ) |
351 | text += postOfficeBox() + "\n"; | 372 | text += postOfficeBox() + "\n"; |
352 | 373 | ||
353 | text += locality() + QString(" ") + region(); | 374 | text += locality() + QString(" ") + region(); |
354 | 375 | ||
355 | if ( !postalCode().isEmpty() ) | 376 | if ( !postalCode().isEmpty() ) |
356 | text += QString(", ") + postalCode(); | 377 | text += QString(", ") + postalCode(); |
357 | 378 | ||
358 | text += "\n"; | 379 | text += "\n"; |
359 | 380 | ||
360 | if ( !country().isEmpty() ) | 381 | if ( !country().isEmpty() ) |
361 | text += country() + "\n"; | 382 | text += country() + "\n"; |
362 | 383 | ||
363 | text += extended(); | 384 | text += extended(); |
364 | 385 | ||
365 | 386 | ||
366 | return text; | 387 | return text; |
367 | // ************************************************************** | 388 | // ************************************************************** |
368 | 389 | ||
369 | // FIXME: first check for iso-country-field and prefer that one | 390 | // FIXME: first check for iso-country-field and prefer that one |
370 | if ( !country().isEmpty() ) { | 391 | if ( !country().isEmpty() ) { |
371 | ciso = countryToISO( country() ); | 392 | ciso = countryToISO( country() ); |
372 | } else { | 393 | } else { |
373 | // fall back to our own country | 394 | // fall back to our own country |
374 | ciso = KGlobal::locale()->country(); | 395 | ciso = KGlobal::locale()->country(); |
375 | } | 396 | } |
376 | //qDebug("ciso %s ",ciso.latin1() ); | 397 | //qDebug("ciso %s ",ciso.latin1() ); |
377 | KSimpleConfig entry( locate( "locale", | 398 | KSimpleConfig entry( locate( "locale", |
378 | QString( "l10n/" ) + ciso + QString( "/entry.desktop" ) ) ); | 399 | QString( "l10n/" ) + ciso + QString( "/entry.desktop" ) ) ); |
379 | entry.setGroup( "KCM Locale" ); | 400 | entry.setGroup( "KCM Locale" ); |
380 | 401 | ||
381 | // decide whether this needs special business address formatting | 402 | // decide whether this needs special business address formatting |
382 | if ( orgaName.isNull() ) { | 403 | if ( orgaName.isNull() ) { |
383 | addrTemplate = entry.readEntry( "AddressFormat" ); | 404 | addrTemplate = entry.readEntry( "AddressFormat" ); |
384 | } else { | 405 | } else { |
385 | addrTemplate = entry.readEntry( "BusinessAddressFormat" ); | 406 | addrTemplate = entry.readEntry( "BusinessAddressFormat" ); |
386 | if ( addrTemplate.isEmpty() ) | 407 | if ( addrTemplate.isEmpty() ) |
387 | addrTemplate = entry.readEntry( "AddressFormat" ); | 408 | addrTemplate = entry.readEntry( "AddressFormat" ); |
388 | } | 409 | } |
389 | 410 | ||
390 | // in the case there's no format found at all, default to what we've always | 411 | // in the case there's no format found at all, default to what we've always |
391 | // used: | 412 | // used: |
392 | if ( addrTemplate.isEmpty() ) { | 413 | if ( addrTemplate.isEmpty() ) { |
393 | qDebug("address format database incomplete****************** "); | 414 | qDebug("address format database incomplete****************** "); |
394 | kdWarning(5700) << "address format database incomplete " | 415 | kdWarning(5700) << "address format database incomplete " |
395 | << "(no format for locale " << ciso | 416 | << "(no format for locale " << ciso |
396 | << " found). Using default address formatting." << endl; | 417 | << " found). Using default address formatting." << endl; |
397 | addrTemplate = "%0(%n\\n)%0(%cm\\n)%0(%s\\n)%0(PO BOX %p\\n)%0(%l%w%r)%,%z"; | 418 | addrTemplate = "%0(%n\\n)%0(%cm\\n)%0(%s\\n)%0(PO BOX %p\\n)%0(%l%w%r)%,%z"; |
398 | } | 419 | } |
399 | 420 | ||
400 | // scan | 421 | // scan |
401 | parseAddressTemplateSection( addrTemplate, ret, realName, orgaName ); | 422 | parseAddressTemplateSection( addrTemplate, ret, realName, orgaName ); |
402 | 423 | ||
403 | // now add the country line if needed (formatting this time according to | 424 | // now add the country line if needed (formatting this time according to |
404 | // the rules of our own system country ) | 425 | // the rules of our own system country ) |
405 | if ( !country().isEmpty() ) { | 426 | if ( !country().isEmpty() ) { |
406 | KSimpleConfig entry( locate( "locale", QString( "l10n/" ) | 427 | KSimpleConfig entry( locate( "locale", QString( "l10n/" ) |
407 | + KGlobal::locale()->country() + QString( "/entry.desktop" ) ) ); | 428 | + KGlobal::locale()->country() + QString( "/entry.desktop" ) ) ); |
408 | entry.setGroup( "KCM Locale" ); | 429 | entry.setGroup( "KCM Locale" ); |
409 | QString cpos = entry.readEntry( "AddressCountryPosition" ); | 430 | QString cpos = entry.readEntry( "AddressCountryPosition" ); |
410 | if ( "BELOW" == cpos || cpos.isEmpty() ) { | 431 | if ( "BELOW" == cpos || cpos.isEmpty() ) { |
411 | ret = ret + "\n\n" + country().upper(); | 432 | ret = ret + "\n\n" + country().upper(); |
412 | } else if ( "below" == cpos ) { | 433 | } else if ( "below" == cpos ) { |
413 | ret = ret + "\n\n" + country(); | 434 | ret = ret + "\n\n" + country(); |
414 | } else if ( "ABOVE" == cpos ) { | 435 | } else if ( "ABOVE" == cpos ) { |