-rw-r--r-- | kabc/addresseeview.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index f3cfb23..05d604f 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -297,205 +297,231 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee ) | |||
297 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); | 297 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); |
298 | if ( !tempX.isEmpty() ) { | 298 | if ( !tempX.isEmpty() ) { |
299 | notes += QString( | 299 | notes += QString( |
300 | "<tr><td align=\"right\"><b>%1</b></td>" | 300 | "<tr><td align=\"right\"><b>%1</b></td>" |
301 | "<td align=\"left\">%2</td></tr>" ) | 301 | "<td align=\"left\">%2</td></tr>" ) |
302 | .arg( i18n( "Assistant" ) ) | 302 | .arg( i18n( "Assistant" ) ) |
303 | .arg( tempX ); | 303 | .arg( tempX ); |
304 | } | 304 | } |
305 | if ( !mAddressee.url().url().isEmpty() ) { | 305 | if ( !mAddressee.url().url().isEmpty() ) { |
306 | notes += QString( | 306 | notes += QString( |
307 | "<tr><td align=\"right\"><b>%1</b></td>" | 307 | "<tr><td align=\"right\"><b>%1</b></td>" |
308 | "<td align=\"left\">%2</td></tr>" ) | 308 | "<td align=\"left\">%2</td></tr>" ) |
309 | .arg( i18n( "Homepage" ) ) | 309 | .arg( i18n( "Homepage" ) ) |
310 | .arg( mAddressee.url().url() ); | 310 | .arg( mAddressee.url().url() ); |
311 | } | 311 | } |
312 | tempX = mAddressee.nickName(); | 312 | tempX = mAddressee.nickName(); |
313 | if ( !tempX.isEmpty() ) { | 313 | if ( !tempX.isEmpty() ) { |
314 | notes += QString( | 314 | notes += QString( |
315 | "<tr><td align=\"right\"><b>%1</b></td>" | 315 | "<tr><td align=\"right\"><b>%1</b></td>" |
316 | "<td align=\"left\">%2</td></tr>" ) | 316 | "<td align=\"left\">%2</td></tr>" ) |
317 | .arg( i18n( "Nickname" ) ) | 317 | .arg( i18n( "Nickname" ) ) |
318 | .arg( tempX ); | 318 | .arg( tempX ); |
319 | } | 319 | } |
320 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); | 320 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); |
321 | if ( !tempX.isEmpty() ) { | 321 | if ( !tempX.isEmpty() ) { |
322 | notes += QString( | 322 | notes += QString( |
323 | "<tr><td align=\"right\"><b>%1</b></td>" | 323 | "<tr><td align=\"right\"><b>%1</b></td>" |
324 | "<td align=\"left\">%2</td></tr>" ) | 324 | "<td align=\"left\">%2</td></tr>" ) |
325 | .arg( i18n( "Messanger" ) ) | 325 | .arg( i18n( "Messanger" ) ) |
326 | .arg( tempX ); | 326 | .arg( tempX ); |
327 | } | 327 | } |
328 | 328 | ||
329 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); | 329 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); |
330 | if ( !tempX.isEmpty() ) { | 330 | if ( !tempX.isEmpty() ) { |
331 | QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); | 331 | QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); |
332 | if ( dt.isValid () ) { | 332 | if ( dt.isValid () ) { |
333 | tempX = KGlobal::locale()->formatDate(dt, true); | 333 | tempX = KGlobal::locale()->formatDate(dt, true); |
334 | notes += QString( | 334 | notes += QString( |
335 | "<tr><td align=\"right\"><b>%1</b></td>" | 335 | "<tr><td align=\"right\"><b>%1</b></td>" |
336 | "<td align=\"left\">%2</td></tr>" ) | 336 | "<td align=\"left\">%2</td></tr>" ) |
337 | .arg( i18n( "Anniversary" ) ) | 337 | .arg( i18n( "Anniversary" ) ) |
338 | .arg( tempX ); | 338 | .arg( tempX ); |
339 | } | 339 | } |
340 | } | 340 | } |
341 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); | 341 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); |
342 | if ( !tempX.isEmpty() ) { | 342 | if ( !tempX.isEmpty() ) { |
343 | notes += QString( | 343 | notes += QString( |
344 | "<tr><td align=\"right\"><b>%1</b></td>" | 344 | "<tr><td align=\"right\"><b>%1</b></td>" |
345 | "<td align=\"left\">%2</td></tr>" ) | 345 | "<td align=\"left\">%2</td></tr>" ) |
346 | .arg( i18n( "Spouse" ) ) | 346 | .arg( i18n( "Spouse" ) ) |
347 | .arg( tempX ); | 347 | .arg( tempX ); |
348 | } | 348 | } |
349 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); | 349 | tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); |
350 | if ( !tempX.isEmpty() ) { | 350 | if ( !tempX.isEmpty() ) { |
351 | notes += QString( | 351 | notes += QString( |
352 | "<tr><td align=\"right\"><b>%1</b></td>" | 352 | "<tr><td align=\"right\"><b>%1</b></td>" |
353 | "<td align=\"left\">%2</td></tr>" ) | 353 | "<td align=\"left\">%2</td></tr>" ) |
354 | .arg( i18n( "Children" ) ) | 354 | .arg( i18n( "Children" ) ) |
355 | .arg( tempX ); | 355 | .arg( tempX ); |
356 | } | 356 | } |
357 | 357 | ||
358 | if ( !mAddressee.note().isEmpty() ) { | 358 | if ( !mAddressee.note().isEmpty() ) { |
359 | notes += QString( | 359 | notes += QString( |
360 | "<tr>" | 360 | "<tr>" |
361 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 361 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
362 | "<td align=\"left\">%2</td>" // note | 362 | "<td align=\"left\">%2</td>" // note |
363 | "</tr>" ).arg( i18n( "Notes" ) ) | 363 | "</tr>" ).arg( i18n( "Notes" ) ) |
364 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 364 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
365 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 365 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |
366 | //qDebug("AddresseeView::setAddressee has to be verified."); | 366 | //qDebug("AddresseeView::setAddressee has to be verified."); |
367 | } | 367 | } |
368 | } else { | 368 | } else { |
369 | notes = QString( | 369 | notes = QString( |
370 | "<tr><td align=\"right\"><b>%1</b></td>" | 370 | "<tr><td align=\"right\"><b>%1</b></td>" |
371 | "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) | 371 | "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) |
372 | .arg( i18n("Details") ) | 372 | .arg( i18n("Details") ) |
373 | .arg( i18n("Show!") ); | 373 | .arg( i18n("Show!") ); |
374 | 374 | ||
375 | 375 | ||
376 | } | 376 | } |
377 | 377 | ||
378 | QString aRole = ""; | 378 | QString aRole = ""; |
379 | QString aOrga = ""; | 379 | QString aOrga = ""; |
380 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 380 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
381 | aRole = "<tr>" | 381 | aRole = "<tr>" |
382 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 382 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
383 | "</tr>"; | 383 | "</tr>"; |
384 | } | 384 | } |
385 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 385 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
386 | aOrga = "<tr>" | 386 | aOrga = "<tr>" |
387 | "<td align=\"left\">" + mAddressee.organization() + "</td>" | 387 | "<td align=\"left\">" + mAddressee.organization() + "</td>" |
388 | "</tr>"; | 388 | "</tr>"; |
389 | } | 389 | } |
390 | mText = ""; | 390 | mText = ""; |
391 | QString picString = ""; | 391 | QString picString = ""; |
392 | KABC::Picture picture = mAddressee.photo(); | 392 | KABC::Picture picture = mAddressee.photo(); |
393 | if (picture.undefined() ) picture = mAddressee.logo(); | ||
393 | bool picAvailintern = false; | 394 | bool picAvailintern = false; |
394 | bool picAvailUrl = false; | 395 | bool picAvailUrl = false; |
395 | if (! picture.undefined() ) { | 396 | if (! picture.undefined() ) { |
396 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 397 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
397 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 398 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
398 | } | 399 | } |
399 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 400 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
400 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 401 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
401 | if ( picAvailintern ) { | 402 | if ( picAvailintern ) { |
402 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 403 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
404 | int wid = picture.data().width(); | ||
405 | int hei = picture.data().height(); | ||
406 | if ( wid > 128 || hei > 128 ) { | ||
407 | if ( wid > hei ) { | ||
408 | hei = (hei*128)/wid; | ||
409 | wid = 128; | ||
410 | } else { | ||
411 | wid = (wid*128)/hei; | ||
412 | hei = 128; | ||
413 | } | ||
414 | } | ||
415 | picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); | ||
403 | } else { | 416 | } else { |
404 | if ( picAvailUrl ) { | 417 | if ( picAvailUrl ) { |
405 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 418 | QPixmap picPix( picture.url() ); |
419 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); | ||
420 | int wid = picPix.width(); | ||
421 | int hei = picPix.height(); | ||
422 | if ( wid > 128 || hei > 128 ) { | ||
423 | if ( wid > hei ) { | ||
424 | hei = (hei*128)/wid; | ||
425 | wid = 128; | ||
426 | } else { | ||
427 | wid = (wid*128)/hei; | ||
428 | hei = 128; | ||
429 | } | ||
430 | } | ||
431 | picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); | ||
406 | } else { | 432 | } else { |
407 | if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { | 433 | if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { |
408 | static bool setDefaultImageChildren = false; | 434 | static bool setDefaultImageChildren = false; |
409 | if ( !setDefaultImageChildren ) { | 435 | if ( !setDefaultImageChildren ) { |
410 | QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); | 436 | QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); |
411 | setDefaultImageChildren = true; | 437 | setDefaultImageChildren = true; |
412 | } | 438 | } |
413 | picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; | 439 | picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; |
414 | 440 | ||
415 | } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { | 441 | } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { |
416 | static bool setDefaultImagepouses = false; | 442 | static bool setDefaultImagepouses = false; |
417 | if ( !setDefaultImagepouses ) { | 443 | if ( !setDefaultImagepouses ) { |
418 | QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); | 444 | QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); |
419 | setDefaultImagepouses = true; | 445 | setDefaultImagepouses = true; |
420 | } | 446 | } |
421 | picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; | 447 | picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; |
422 | } else { | 448 | } else { |
423 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); | 449 | QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); |
424 | if ( gen == "male" ) { | 450 | if ( gen == "male" ) { |
425 | static bool setDefaultImageMale = false; | 451 | static bool setDefaultImageMale = false; |
426 | if ( !setDefaultImageMale ) { | 452 | if ( !setDefaultImageMale ) { |
427 | QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); | 453 | QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); |
428 | setDefaultImageMale = true; | 454 | setDefaultImageMale = true; |
429 | } | 455 | } |
430 | picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; | 456 | picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; |
431 | 457 | ||
432 | } else if ( gen == "female" ) { | 458 | } else if ( gen == "female" ) { |
433 | static bool setDefaultImageFemale = false; | 459 | static bool setDefaultImageFemale = false; |
434 | if ( !setDefaultImageFemale ) { | 460 | if ( !setDefaultImageFemale ) { |
435 | QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); | 461 | QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); |
436 | setDefaultImageFemale = true; | 462 | setDefaultImageFemale = true; |
437 | } | 463 | } |
438 | picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; | 464 | picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; |
439 | 465 | ||
440 | } else { | 466 | } else { |
441 | static bool setDefaultImage = false; | 467 | static bool setDefaultImage = false; |
442 | if ( !setDefaultImage ) { | 468 | if ( !setDefaultImage ) { |
443 | //qDebug("Setting default pixmap "); | 469 | //qDebug("Setting default pixmap "); |
444 | QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); | 470 | QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); |
445 | setDefaultImage = true; | 471 | setDefaultImage = true; |
446 | } | 472 | } |
447 | picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; | 473 | picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; |
448 | } | 474 | } |
449 | } | 475 | } |
450 | } | 476 | } |
451 | } | 477 | } |
452 | mText = QString::fromLatin1( | 478 | mText = QString::fromLatin1( |
453 | "<html>" | 479 | "<html>" |
454 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color | 480 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color |
455 | "<table>" | 481 | "<table>" |
456 | "<tr>" | 482 | "<tr>" |
457 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" | 483 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" |
458 | "%3" | 484 | "%3" |
459 | "</td>" | 485 | "</td>" |
460 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name | 486 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name |
461 | "</tr>" | 487 | "</tr>" |
462 | "%5" // role | 488 | "%5" // role |
463 | "%6" // organization | 489 | "%6" // organization |
464 | "<td colspan=\"2\"> </td>" | 490 | "<td colspan=\"2\"> </td>" |
465 | "%7" // dynamic part | 491 | "%7" // dynamic part |
466 | "%8" // notes | 492 | "%8" // notes |
467 | "</table>" | 493 | "</table>" |
468 | "</body>" | 494 | "</body>" |
469 | "</html>") | 495 | "</html>") |
470 | //US | 496 | //US |
471 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) | 497 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) |
472 | //US | 498 | //US |
473 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 499 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
474 | .arg( picString ) | 500 | .arg( picString ) |
475 | .arg( name ) | 501 | .arg( name ) |
476 | .arg( aRole ) | 502 | .arg( aRole ) |
477 | .arg( aOrga ) | 503 | .arg( aOrga ) |
478 | .arg( dynamicPart ) | 504 | .arg( dynamicPart ) |
479 | .arg( notes ); | 505 | .arg( notes ); |
480 | 506 | ||
481 | } else { // no picture! | 507 | } else { // no picture! |
482 | 508 | ||
483 | mText = "<table width=\"100%\">\n"; | 509 | mText = "<table width=\"100%\">\n"; |
484 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 510 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
485 | #ifdef DESKTOP_VERSION | 511 | #ifdef DESKTOP_VERSION |
486 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 512 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
487 | mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; | 513 | mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; |
488 | #else | 514 | #else |
489 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; | 515 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; |
490 | mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; | 516 | mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; |
491 | #endif | 517 | #endif |
492 | 518 | ||
493 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 519 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
494 | 520 | ||
495 | mText += "<table><td colspan=\"2\"> </td>"; | 521 | mText += "<table><td colspan=\"2\"> </td>"; |
496 | /* | 522 | /* |
497 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 523 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
498 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 524 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
499 | .arg( i18n(" ") ) | 525 | .arg( i18n(" ") ) |
500 | .arg( name ); | 526 | .arg( name ); |
501 | */ | 527 | */ |