summaryrefslogtreecommitdiffabout
path: root/kabc
Unidiff
Diffstat (limited to 'kabc') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp48
1 files changed, 42 insertions, 6 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 8f104e0..aa96210 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -230,71 +230,107 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
230 //qDebug("AddresseeView::setAddressee has to be verified."); 230 //qDebug("AddresseeView::setAddressee has to be verified.");
231 } 231 }
232 232
233 QString aRole = ""; 233 QString aRole = "";
234 QString aOrga = ""; 234 QString aOrga = "";
235 if ( true /*!mAddressee.role().isEmpty()*/ ) { 235 if ( true /*!mAddressee.role().isEmpty()*/ ) {
236 aRole = "<tr>" 236 aRole = "<tr>"
237 "<td align=\"left\">" + mAddressee.role() + "</td>" 237 "<td align=\"left\">" + mAddressee.role() + "</td>"
238 "</tr>"; 238 "</tr>";
239 } 239 }
240 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 240 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
241 aOrga = "<tr>" 241 aOrga = "<tr>"
242 "<td align=\"left\">" + mAddressee.organization() + "</td>" 242 "<td align=\"left\">" + mAddressee.organization() + "</td>"
243 "</tr>"; 243 "</tr>";
244 } 244 }
245 mText = ""; 245 mText = "";
246 QString picString = ""; 246 QString picString = "";
247 KABC::Picture picture = mAddressee.photo(); 247 KABC::Picture picture = mAddressee.photo();
248 bool picAvailintern = false; 248 bool picAvailintern = false;
249 bool picAvailUrl = false; 249 bool picAvailUrl = false;
250 if (! picture.undefined() ) { 250 if (! picture.undefined() ) {
251 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 251 picAvailintern = (picture.isIntern() && !picture.data().isNull());
252 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 252 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
253 } 253 }
254 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 254 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
255 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 255 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
256 if ( picAvailintern ) { 256 if ( picAvailintern ) {
257 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 257 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
258 } else { 258 } else {
259 if ( picAvailUrl ) { 259 if ( picAvailUrl ) {
260 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); 260 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() ));
261 } else { 261 } else {
262 static bool setDefaultImage = false; 262 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
263 if ( !setDefaultImage ) { 263 static bool setDefaultImageChildren = false;
264 qDebug("Setting default pixmap "); 264 if ( !setDefaultImageChildren ) {
265 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultPenguin", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); 265 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
266 setDefaultImage = true; 266 setDefaultImageChildren = true;
267 }
268 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";
269
270 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) {
271 static bool setDefaultImagepouses = false;
272 if ( !setDefaultImagepouses ) {
273 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) );
274 setDefaultImagepouses = true;
275 }
276 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">";
277 } else {
278 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
279 if ( gen == "male" ) {
280 static bool setDefaultImageMale = false;
281 if ( !setDefaultImageMale ) {
282 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) );
283 setDefaultImageMale = true;
284 }
285 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">";
286
287 } else if ( gen == "female" ) {
288 static bool setDefaultImageFemale = false;
289 if ( !setDefaultImageFemale ) {
290 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) );
291 setDefaultImageFemale = true;
292 }
293 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
294
295 } else {
296 static bool setDefaultImage = false;
297 if ( !setDefaultImage ) {
298 qDebug("Setting default pixmap ");
299 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
300 setDefaultImage = true;
301 }
302 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
303 }
267 } 304 }
268 picString = "<img src=\"defaultPenguin\" width=\"64\" height=\"64\">";
269 } 305 }
270 } 306 }
271 mText = QString::fromLatin1( 307 mText = QString::fromLatin1(
272 "<html>" 308 "<html>"
273 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 309 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
274 "<table>" 310 "<table>"
275 "<tr>" 311 "<tr>"
276 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 312 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
277 "%3" 313 "%3"
278 "</td>" 314 "</td>"
279 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 315 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
280 "</tr>" 316 "</tr>"
281 "%5" // role 317 "%5" // role
282 "%6" // organization 318 "%6" // organization
283 "<td colspan=\"2\">&nbsp;</td>" 319 "<td colspan=\"2\">&nbsp;</td>"
284 "%7" // dynamic part 320 "%7" // dynamic part
285 "%8" // notes 321 "%8" // notes
286 "</table>" 322 "</table>"
287 "</body>" 323 "</body>"
288 "</html>") 324 "</html>")
289//US 325//US
290 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 326 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
291//US 327//US
292 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 328 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
293 .arg( picString ) 329 .arg( picString )
294 .arg( name ) 330 .arg( name )
295 .arg( aRole ) 331 .arg( aRole )
296 .arg( aOrga ) 332 .arg( aOrga )
297 .arg( dynamicPart ) 333 .arg( dynamicPart )
298 .arg( notes ); 334 .arg( notes );
299 335
300 } else { // no picture! 336 } else { // no picture!