-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 ) tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); if ( !tempX.isEmpty() ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Assistant" ) ) .arg( tempX ); } if ( !mAddressee.url().url().isEmpty() ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Homepage" ) ) .arg( mAddressee.url().url() ); } tempX = mAddressee.nickName(); if ( !tempX.isEmpty() ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Nickname" ) ) .arg( tempX ); } tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); if ( !tempX.isEmpty() ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Messanger" ) ) .arg( tempX ); } tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); if ( !tempX.isEmpty() ) { QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); if ( dt.isValid () ) { tempX = KGlobal::locale()->formatDate(dt, true); notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Anniversary" ) ) .arg( tempX ); } } tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); if ( !tempX.isEmpty() ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Spouse" ) ) .arg( tempX ); } tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); if ( !tempX.isEmpty() ) { notes += QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\">%2</td></tr>" ) .arg( i18n( "Children" ) ) .arg( tempX ); } if ( !mAddressee.note().isEmpty() ) { notes += QString( "<tr>" "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label "<td align=\"left\">%2</td>" // note "</tr>" ).arg( i18n( "Notes" ) ) //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); //qDebug("AddresseeView::setAddressee has to be verified."); } } else { notes = QString( "<tr><td align=\"right\"><b>%1</b></td>" "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) .arg( i18n("Details") ) .arg( i18n("Show!") ); } QString aRole = ""; QString aOrga = ""; if ( true /*!mAddressee.role().isEmpty()*/ ) { aRole = "<tr>" "<td align=\"left\">" + mAddressee.role() + "</td>" "</tr>"; } if ( true /*!mAddressee.organization().isEmpty()*/ ) { aOrga = "<tr>" "<td align=\"left\">" + mAddressee.organization() + "</td>" "</tr>"; } mText = ""; QString picString = ""; KABC::Picture picture = mAddressee.photo(); + if (picture.undefined() ) picture = mAddressee.logo(); bool picAvailintern = false; bool picAvailUrl = false; if (! picture.undefined() ) { picAvailintern = (picture.isIntern() && !picture.data().isNull()); picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); } if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; if ( picAvailintern ) { QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); + int wid = picture.data().width(); + int hei = picture.data().height(); + if ( wid > 128 || hei > 128 ) { + if ( wid > hei ) { + hei = (hei*128)/wid; + wid = 128; + } else { + wid = (wid*128)/hei; + hei = 128; + } + } + picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); } else { if ( picAvailUrl ) { - QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); + QPixmap picPix( picture.url() ); + QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); + int wid = picPix.width(); + int hei = picPix.height(); + if ( wid > 128 || hei > 128 ) { + if ( wid > hei ) { + hei = (hei*128)/wid; + wid = 128; + } else { + wid = (wid*128)/hei; + hei = 128; + } + } + picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); } else { if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { static bool setDefaultImageChildren = false; if ( !setDefaultImageChildren ) { QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); setDefaultImageChildren = true; } picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { static bool setDefaultImagepouses = false; if ( !setDefaultImagepouses ) { QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); setDefaultImagepouses = true; } picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; } else { QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); if ( gen == "male" ) { static bool setDefaultImageMale = false; if ( !setDefaultImageMale ) { QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); setDefaultImageMale = true; } picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; } else if ( gen == "female" ) { static bool setDefaultImageFemale = false; if ( !setDefaultImageFemale ) { QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); setDefaultImageFemale = true; } picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; } else { static bool setDefaultImage = false; if ( !setDefaultImage ) { //qDebug("Setting default pixmap "); QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); setDefaultImage = true; } picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; } } } } mText = QString::fromLatin1( "<html>" "<body text=\"%1\" bgcolor=\"%2\">" // text and background color "<table>" "<tr>" "<td rowspan=\"3\" align=\"right\" valign=\"top\">" "%3" "</td>" "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name "</tr>" "%5" // role "%6" // organization "<td colspan=\"2\"> </td>" "%7" // dynamic part "%8" // notes "</table>" "</body>" "</html>") //US .arg( /*KGlobalSettings::textColor().name()*/ "black" ) //US .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) .arg( picString ) .arg( name ) .arg( aRole ) .arg( aOrga ) .arg( dynamicPart ) .arg( notes ); } else { // no picture! mText = "<table width=\"100%\">\n"; //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; #ifdef DESKTOP_VERSION mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; #else mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; #endif mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; mText += "<table><td colspan=\"2\"> </td>"; /* mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" "<td align=\"left\"><b>%2</b></td></tr>" ) .arg( i18n(" ") ) .arg( name ); */ |