summaryrefslogtreecommitdiffabout
path: root/kabc/addresseeview.cpp
Unidiff
Diffstat (limited to 'kabc/addresseeview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kabc/addresseeview.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp
index 5c24acf..cde19a1 100644
--- a/kabc/addresseeview.cpp
+++ b/kabc/addresseeview.cpp
@@ -167,548 +167,573 @@ void AddresseeView::setAddressee( const KABC::Addressee& mAddressee )
167 .arg( type ) 167 .arg( type )
168 .arg( *emailIt ); 168 .arg( *emailIt );
169 ++emailIt; 169 ++emailIt;
170 } 170 }
171 } 171 }
172 if ( mAddressee.birthday().date().isValid() ) { 172 if ( mAddressee.birthday().date().isValid() ) {
173 dynamicPart += QString( 173 dynamicPart += QString(
174 "<tr><td align=\"right\"><b>%1</b></td>" 174 "<tr><td align=\"right\"><b>%1</b></td>"
175 "<td align=\"left\">%2</td></tr>" ) 175 "<td align=\"left\">%2</td></tr>" )
176 .arg( i18n ("Birthday") ) 176 .arg( i18n ("Birthday") )
177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) ); 177 .arg( KGlobal::locale()->formatDate( mAddressee.birthday().date() ,true) );
178 } 178 }
179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false ); 179 dynamicPart += getPhoneNumbers( mAddressee.phoneNumbers(), false );
180 180
181 for ( ; emailIt != emails.end(); ++emailIt ) { 181 for ( ; emailIt != emails.end(); ++emailIt ) {
182 if ( kemailAvail ) { 182 if ( kemailAvail ) {
183 dynamicPart += QString( 183 dynamicPart += QString(
184 "<tr><td align=\"right\"><b>%1</b></td>" 184 "<tr><td align=\"right\"><b>%1</b></td>"
185 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" ) 185 "<td align=\"left\"><a href=\"mailto:%2 <%3> \">%4</a></td></tr>" )
186 .arg( type ) 186 .arg( type )
187 .arg( name ) 187 .arg( name )
188 .arg( *emailIt ) 188 .arg( *emailIt )
189 .arg( *emailIt ); 189 .arg( *emailIt );
190 } else { 190 } else {
191 dynamicPart += QString( 191 dynamicPart += QString(
192 "<tr><td align=\"right\"><b>%1</b></td>" 192 "<tr><td align=\"right\"><b>%1</b></td>"
193 "<td align=\"left\">%2</td></tr>" ) 193 "<td align=\"left\">%2</td></tr>" )
194 .arg( type ) 194 .arg( type )
195 .arg( *emailIt ); 195 .arg( *emailIt );
196 } 196 }
197 } 197 }
198 198
199 199
200 200
201 KABC::Address::List addresses = mAddressee.addresses(); 201 KABC::Address::List addresses = mAddressee.addresses();
202 KABC::Address::List::ConstIterator addrIt; 202 KABC::Address::List::ConstIterator addrIt;
203 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { 203 for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) {
204 if ( true /*(*addrIt).label().isEmpty()*/ ) { 204 if ( true /*(*addrIt).label().isEmpty()*/ ) {
205 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); 205 QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace();
206//US formattedAddress = formattedAddress.replace( '\n', "<br>" ); 206//US formattedAddress = formattedAddress.replace( '\n', "<br>" );
207 //qDebug("adresss %s ",formattedAddress.latin1() ); 207 //qDebug("adresss %s ",formattedAddress.latin1() );
208 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); 208 formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" );
209 //qDebug("AddresseeView::setAddressee has to be verified."); 209 //qDebug("AddresseeView::setAddressee has to be verified.");
210 210
211 dynamicPart += QString( 211 dynamicPart += QString(
212 "<tr><td align=\"right\"><b>%1</b></td>" 212 "<tr><td align=\"right\"><b>%1</b></td>"
213 "<td align=\"left\">%2</td></tr>" ) 213 "<td align=\"left\">%2</td></tr>" )
214 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 214 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
215 .arg( formattedAddress ); 215 .arg( formattedAddress );
216 } else { 216 } else {
217 217
218 dynamicPart += QString( 218 dynamicPart += QString(
219 "<tr><td align=\"right\"><b>%1</b></td>" 219 "<tr><td align=\"right\"><b>%1</b></td>"
220 "<td align=\"left\">%2</td></tr>" ) 220 "<td align=\"left\">%2</td></tr>" )
221 .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) 221 .arg( KABC::Address::typeLabel( (*addrIt).type() ) )
222//US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); 222//US .arg( (*addrIt).label().replace( '\n', "<br>" ) );
223 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); 223 .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ );
224 224
225 } 225 }
226 } 226 }
227 227
228 228
229 QString notes; 229 QString notes;
230 if ( sFullDetailsMode ) { 230 if ( sFullDetailsMode ) {
231 notes = QString( 231 notes = QString(
232 "<tr><td align=\"right\"><b>%1</b></td>" 232 "<tr><td align=\"right\"><b>%1</b></td>"
233 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" ) 233 "<td align=\"left\"><a href=\"notAllDetails\">%4</a></td></tr>" )
234 .arg( i18n("Details") ) 234 .arg( i18n("Details") )
235 .arg( i18n("Hide!") ); 235 .arg( i18n("Hide!") );
236 236
237 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 237 QString tempX = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
238 if ( !tempX.isEmpty() ) { 238 if ( !tempX.isEmpty() ) {
239 if ( tempX == "male" || tempX == "female" ) { 239 if ( tempX == "male" || tempX == "female" ) {
240 notes += QString( 240 notes += QString(
241 "<tr><td align=\"right\"><b>%1</b></td>" 241 "<tr><td align=\"right\"><b>%1</b></td>"
242 "<td align=\"left\">%2</td></tr>" ) 242 "<td align=\"left\">%2</td></tr>" )
243 .arg( i18n( "" ) ) 243 .arg( i18n( "" ) )
244 .arg( i18n(tempX) ); 244 .arg( i18n(tempX) );
245 } 245 }
246 } 246 }
247 247
248 248
249 tempX = mAddressee.secrecy().asString(); 249 tempX = mAddressee.secrecy().asString();
250 250
251 notes += QString( 251 notes += QString(
252 "<tr><td align=\"right\"><b>%1</b></td>" 252 "<tr><td align=\"right\"><b>%1</b></td>"
253 "<td align=\"left\">%2</td></tr>" ) 253 "<td align=\"left\">%2</td></tr>" )
254 .arg( "" ) 254 .arg( "" )
255 .arg( tempX ); 255 .arg( tempX );
256 256
257 257
258 tempX = mAddressee.categories().join(" - "); 258 tempX = mAddressee.categories().join(" - ");
259 if ( !tempX.isEmpty() ) { 259 if ( !tempX.isEmpty() ) {
260 notes += QString( 260 notes += QString(
261 "<tr><td align=\"right\"><b>%1</b></td>" 261 "<tr><td align=\"right\"><b>%1</b></td>"
262 "<td align=\"left\">%2</td></tr>" ) 262 "<td align=\"left\">%2</td></tr>" )
263 .arg( i18n( "Category" ) ) 263 .arg( i18n( "Category" ) )
264 .arg( tempX ); 264 .arg( tempX );
265 } 265 }
266 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" ); 266 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Profession" );
267 if ( !tempX.isEmpty() ) { 267 if ( !tempX.isEmpty() ) {
268 notes += QString( 268 notes += QString(
269 "<tr><td align=\"right\"><b>%1</b></td>" 269 "<tr><td align=\"right\"><b>%1</b></td>"
270 "<td align=\"left\">%2</td></tr>" ) 270 "<td align=\"left\">%2</td></tr>" )
271 .arg( i18n( "Profession" ) ) 271 .arg( i18n( "Profession" ) )
272 .arg( tempX ); 272 .arg( tempX );
273 } 273 }
274 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" ); 274 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Office" );
275 if ( !tempX.isEmpty() ) { 275 if ( !tempX.isEmpty() ) {
276 notes += QString( 276 notes += QString(
277 "<tr><td align=\"right\"><b>%1</b></td>" 277 "<tr><td align=\"right\"><b>%1</b></td>"
278 "<td align=\"left\">%2</td></tr>" ) 278 "<td align=\"left\">%2</td></tr>" )
279 .arg( i18n( "Office" ) ) 279 .arg( i18n( "Office" ) )
280 .arg( tempX ); 280 .arg( tempX );
281 } 281 }
282 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" ); 282 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Department" );
283 if ( !tempX.isEmpty() ) { 283 if ( !tempX.isEmpty() ) {
284 notes += QString( 284 notes += QString(
285 "<tr><td align=\"right\"><b>%1</b></td>" 285 "<tr><td align=\"right\"><b>%1</b></td>"
286 "<td align=\"left\">%2</td></tr>" ) 286 "<td align=\"left\">%2</td></tr>" )
287 .arg( i18n( "Department" ) ) 287 .arg( i18n( "Department" ) )
288 .arg( tempX ); 288 .arg( tempX );
289 } 289 }
290 290
291 tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" ); 291 tempX = mAddressee.custom( "KADDRESSBOOK", "X-ManagersName" );
292 if ( !tempX.isEmpty() ) { 292 if ( !tempX.isEmpty() ) {
293 notes += QString( 293 notes += QString(
294 "<tr><td align=\"right\"><b>%1</b></td>" 294 "<tr><td align=\"right\"><b>%1</b></td>"
295 "<td align=\"left\">%2</td></tr>" ) 295 "<td align=\"left\">%2</td></tr>" )
296 .arg( i18n( "Manager" ) ) 296 .arg( i18n( "Manager" ) )
297 .arg( tempX ); 297 .arg( tempX );
298 } 298 }
299 tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" ); 299 tempX = mAddressee.custom( "KADDRESSBOOK", "X-AssistantsName" );
300 if ( !tempX.isEmpty() ) { 300 if ( !tempX.isEmpty() ) {
301 notes += QString( 301 notes += QString(
302 "<tr><td align=\"right\"><b>%1</b></td>" 302 "<tr><td align=\"right\"><b>%1</b></td>"
303 "<td align=\"left\">%2</td></tr>" ) 303 "<td align=\"left\">%2</td></tr>" )
304 .arg( i18n( "Assistant" ) ) 304 .arg( i18n( "Assistant" ) )
305 .arg( tempX ); 305 .arg( tempX );
306 } 306 }
307 if ( !mAddressee.url().url().isEmpty() ) { 307 if ( !mAddressee.url().url().isEmpty() ) {
308 notes += QString( 308 notes += QString(
309 "<tr><td align=\"right\"><b>%1</b></td>" 309 "<tr><td align=\"right\"><b>%1</b></td>"
310 "<td align=\"left\">%2</td></tr>" ) 310 "<td align=\"left\">%2</td></tr>" )
311 .arg( i18n( "Homepage" ) ) 311 .arg( i18n( "Homepage" ) )
312 .arg( mAddressee.url().url() ); 312 .arg( mAddressee.url().url() );
313 } 313 }
314 tempX = mAddressee.nickName(); 314 tempX = mAddressee.nickName();
315 if ( !tempX.isEmpty() ) { 315 if ( !tempX.isEmpty() ) {
316 notes += QString( 316 notes += QString(
317 "<tr><td align=\"right\"><b>%1</b></td>" 317 "<tr><td align=\"right\"><b>%1</b></td>"
318 "<td align=\"left\">%2</td></tr>" ) 318 "<td align=\"left\">%2</td></tr>" )
319 .arg( i18n( "Nickname" ) ) 319 .arg( i18n( "Nickname" ) )
320 .arg( tempX ); 320 .arg( tempX );
321 } 321 }
322 tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" ); 322 tempX = mAddressee.custom( "KADDRESSBOOK", "X-IMAddress" );
323 if ( !tempX.isEmpty() ) { 323 if ( !tempX.isEmpty() ) {
324 notes += QString( 324 notes += QString(
325 "<tr><td align=\"right\"><b>%1</b></td>" 325 "<tr><td align=\"right\"><b>%1</b></td>"
326 "<td align=\"left\">%2</td></tr>" ) 326 "<td align=\"left\">%2</td></tr>" )
327 .arg( i18n( "Messanger" ) ) 327 .arg( i18n( "Messanger" ) )
328 .arg( tempX ); 328 .arg( tempX );
329 } 329 }
330 330
331 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" ); 331 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Anniversary" );
332 if ( !tempX.isEmpty() ) { 332 if ( !tempX.isEmpty() ) {
333 QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d"); 333 QDate dt = KGlobal::locale()->readDate( tempX, "%Y-%m-%d");
334 if ( dt.isValid () ) { 334 if ( dt.isValid () ) {
335 tempX = KGlobal::locale()->formatDate(dt, true); 335 tempX = KGlobal::locale()->formatDate(dt, true);
336 notes += QString( 336 notes += QString(
337 "<tr><td align=\"right\"><b>%1</b></td>" 337 "<tr><td align=\"right\"><b>%1</b></td>"
338 "<td align=\"left\">%2</td></tr>" ) 338 "<td align=\"left\">%2</td></tr>" )
339 .arg( i18n( "Anniversary" ) ) 339 .arg( i18n( "Anniversary" ) )
340 .arg( tempX ); 340 .arg( tempX );
341 } 341 }
342 } 342 }
343 tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ); 343 tempX = mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" );
344 if ( !tempX.isEmpty() ) { 344 if ( !tempX.isEmpty() ) {
345 notes += QString( 345 notes += QString(
346 "<tr><td align=\"right\"><b>%1</b></td>" 346 "<tr><td align=\"right\"><b>%1</b></td>"
347 "<td align=\"left\">%2</td></tr>" ) 347 "<td align=\"left\">%2</td></tr>" )
348 .arg( i18n( "Spouse" ) ) 348 .arg( i18n( "Spouse" ) )
349 .arg( tempX ); 349 .arg( tempX );
350 } 350 }
351 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" ); 351 tempX = mAddressee.custom( "KADDRESSBOOK", "X-Children" );
352 if ( !tempX.isEmpty() ) { 352 if ( !tempX.isEmpty() ) {
353 notes += QString( 353 notes += QString(
354 "<tr><td align=\"right\"><b>%1</b></td>" 354 "<tr><td align=\"right\"><b>%1</b></td>"
355 "<td align=\"left\">%2</td></tr>" ) 355 "<td align=\"left\">%2</td></tr>" )
356 .arg( i18n( "Children" ) ) 356 .arg( i18n( "Children" ) )
357 .arg( tempX ); 357 .arg( tempX );
358 } 358 }
359 359
360 if ( !mAddressee.note().isEmpty() ) { 360 if ( !mAddressee.note().isEmpty() ) {
361 notes += QString( 361 notes += QString(
362 "<tr>" 362 "<tr>"
363 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label 363 "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label
364 "<td align=\"left\">%2</td>" // note 364 "<td align=\"left\">%2</td>" // note
365 "</tr>" ).arg( i18n( "Notes" ) ) 365 "</tr>" ).arg( i18n( "Notes" ) )
366 //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); 366 //US .arg( mAddressee.note().replace( '\n', "<br>" ) );
367 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); 367 .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) );
368 //qDebug("AddresseeView::setAddressee has to be verified."); 368 //qDebug("AddresseeView::setAddressee has to be verified.");
369 } 369 }
370 } else { 370 } else {
371 notes = QString( 371 notes = QString(
372 "<tr><td align=\"right\"><b>%1</b></td>" 372 "<tr><td align=\"right\"><b>%1</b></td>"
373 "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" ) 373 "<td align=\"left\"><a href=\"allDetails\">%4</a></td></tr>" )
374 .arg( i18n("Details") ) 374 .arg( i18n("Details") )
375 .arg( i18n("Show!") ); 375 .arg( i18n("Show!") );
376 376
377 377
378 } 378 }
379 379
380 QString aRole = ""; 380 QString aRole = "";
381 QString aOrga = ""; 381 QString aOrga = "";
382 if ( true /*!mAddressee.role().isEmpty()*/ ) { 382 if ( true /*!mAddressee.role().isEmpty()*/ ) {
383 aRole = "<tr>" 383 aRole = "<tr>"
384 "<td align=\"left\">" + mAddressee.role() + "</td>" 384 "<td align=\"left\">" + mAddressee.role() + "</td>"
385 "</tr>"; 385 "</tr>";
386 } 386 }
387 if ( true /*!mAddressee.organization().isEmpty()*/ ) { 387 if ( true /*!mAddressee.organization().isEmpty()*/ ) {
388 aOrga = "<tr>" 388 aOrga = "<tr>"
389 "<td align=\"left\">" + mAddressee.organization() + "</td>" 389 "<td align=\"left\">" + mAddressee.organization() + "</td>"
390 "</tr>"; 390 "</tr>";
391 } 391 }
392 mText = ""; 392 mText = "";
393 QString picString = ""; 393 QString picString = "";
394 KABC::Picture picture = mAddressee.photo(); 394 KABC::Picture picture = mAddressee.photo();
395 if (picture.undefined() ) picture = mAddressee.logo(); 395 if (picture.undefined() ) picture = mAddressee.logo();
396 bool picAvailintern = false; 396 bool picAvailintern = false;
397 bool picAvailUrl = false; 397 bool picAvailUrl = false;
398 if (! picture.undefined() ) { 398 if (! picture.undefined() ) {
399 picAvailintern = (picture.isIntern() && !picture.data().isNull()); 399 picAvailintern = (picture.isIntern() && !picture.data().isNull());
400 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); 400 picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() );
401 } 401 }
402 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { 402 if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) {
403 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; 403 picString = "<img src=\"myimage\" width=\"50\" height=\"70\">";
404 if ( picAvailintern ) { 404 if ( picAvailintern ) {
405 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); 405 QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() );
406 int wid = picture.data().width(); 406 int wid = picture.data().width();
407 int hei = picture.data().height(); 407 int hei = picture.data().height();
408 if ( wid > 128 || hei > 128 ) { 408 if ( wid > 128 || hei > 128 ) {
409 if ( wid > hei ) { 409 if ( wid > hei ) {
410 hei = (hei*128)/wid; 410 hei = (hei*128)/wid;
411 wid = 128; 411 wid = 128;
412 } else { 412 } else {
413 wid = (wid*128)/hei; 413 wid = (wid*128)/hei;
414 hei = 128; 414 hei = 128;
415 } 415 }
416 } 416 }
417 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); 417 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
418 } else { 418 } else {
419 if ( picAvailUrl ) { 419 if ( picAvailUrl ) {
420 QPixmap picPix( picture.url() ); 420 QPixmap picPix( picture.url() );
421 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix ); 421 QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", picPix );
422 int wid = picPix.width(); 422 int wid = picPix.width();
423 int hei = picPix.height(); 423 int hei = picPix.height();
424 if ( wid > 128 || hei > 128 ) { 424 if ( wid > 128 || hei > 128 ) {
425 if ( wid > hei ) { 425 if ( wid > hei ) {
426 hei = (hei*128)/wid; 426 hei = (hei*128)/wid;
427 wid = 128; 427 wid = 128;
428 } else { 428 } else {
429 wid = (wid*128)/hei; 429 wid = (wid*128)/hei;
430 hei = 128; 430 hei = 128;
431 } 431 }
432 } 432 }
433 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei); 433 picString = QString("<img src=\"myimage\" width=\"%1\" height=\"%2\">").arg(wid).arg(hei);
434 } else { 434 } else {
435 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) { 435 if ( !mAddressee.custom( "KADDRESSBOOK", "X-Children" ).isEmpty() ) {
436 static bool setDefaultImageChildren = false; 436 static bool setDefaultImageChildren = false;
437 if ( !setDefaultImageChildren ) { 437 if ( !setDefaultImageChildren ) {
438 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) ); 438 QMimeSourceFactory::defaultFactory()->setPixmap( "familyIcon", KGlobal::iconLoader()->loadIcon( "ic_kids", KIcon::Desktop, 128 ) );
439 setDefaultImageChildren = true; 439 setDefaultImageChildren = true;
440 } 440 }
441 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">"; 441 picString = "<img src=\"familyIcon\" width=\"64\" height=\"64\">";
442 442
443 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) { 443 } else if ( !mAddressee.custom( "KADDRESSBOOK", "X-SpousesName" ).isEmpty() ) {
444 static bool setDefaultImagepouses = false; 444 static bool setDefaultImagepouses = false;
445 if ( !setDefaultImagepouses ) { 445 if ( !setDefaultImagepouses ) {
446 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) ); 446 QMimeSourceFactory::defaultFactory()->setPixmap( "SpousesIcon", KGlobal::iconLoader()->loadIcon( "ic_family", KIcon::Desktop, 128 ) );
447 setDefaultImagepouses = true; 447 setDefaultImagepouses = true;
448 } 448 }
449 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">"; 449 picString = "<img src=\"SpousesIcon\" width=\"64\" height=\"64\">";
450 } else { 450 } else {
451 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" ); 451 QString gen = mAddressee.custom( "KADDRESSBOOK", "X-Gender" );
452 if ( gen == "male" ) { 452 if ( gen == "male" ) {
453 static bool setDefaultImageMale = false; 453 static bool setDefaultImageMale = false;
454 if ( !setDefaultImageMale ) { 454 if ( !setDefaultImageMale ) {
455 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) ); 455 QMimeSourceFactory::defaultFactory()->setPixmap( "MaleIcon", KGlobal::iconLoader()->loadIcon( "ic_male", KIcon::Desktop, 128 ) );
456 setDefaultImageMale = true; 456 setDefaultImageMale = true;
457 } 457 }
458 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">"; 458 picString = "<img src=\"MaleIcon\" width=\"64\" height=\"64\">";
459 459
460 } else if ( gen == "female" ) { 460 } else if ( gen == "female" ) {
461 static bool setDefaultImageFemale = false; 461 static bool setDefaultImageFemale = false;
462 if ( !setDefaultImageFemale ) { 462 if ( !setDefaultImageFemale ) {
463 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) ); 463 QMimeSourceFactory::defaultFactory()->setPixmap( "FemaleIcon", KGlobal::iconLoader()->loadIcon( "ic_female", KIcon::Desktop, 128 ) );
464 setDefaultImageFemale = true; 464 setDefaultImageFemale = true;
465 } 465 }
466 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">"; 466 picString = "<img src=\"FemaleIcon\" width=\"64\" height=\"64\">";
467 467
468 } else { 468 } else {
469 static bool setDefaultImage = false; 469 static bool setDefaultImage = false;
470 if ( !setDefaultImage ) { 470 if ( !setDefaultImage ) {
471 //qDebug("Setting default pixmap "); 471 //qDebug("Setting default pixmap ");
472 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) ); 472 QMimeSourceFactory::defaultFactory()->setPixmap( "defaultIcon", KGlobal::iconLoader()->loadIcon( "ic_penguin", KIcon::Desktop, 128 ) );
473 setDefaultImage = true; 473 setDefaultImage = true;
474 } 474 }
475 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">"; 475 picString = "<img src=\"defaultIcon\" width=\"64\" height=\"64\">";
476 } 476 }
477 } 477 }
478 } 478 }
479 } 479 }
480 mText = QString::fromLatin1( 480 mText = QString::fromLatin1(
481 "<html>" 481 "<html>"
482 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color 482 "<body text=\"%1\" bgcolor=\"%2\">" // text and background color
483 "<table>" 483 "<table>"
484 "<tr>" 484 "<tr>"
485 "<td rowspan=\"3\" align=\"right\" valign=\"top\">" 485 "<td rowspan=\"3\" align=\"right\" valign=\"top\">"
486 "%3" 486 "%3"
487 "</td>" 487 "</td>"
488 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name 488 "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name
489 "</tr>" 489 "</tr>"
490 "%5" // role 490 "%5" // role
491 "%6" // organization 491 "%6" // organization
492 "<td colspan=\"2\">&nbsp;</td>" 492 "<td colspan=\"2\">&nbsp;</td>"
493 "%7" // dynamic part 493 "%7" // dynamic part
494 "%8" // notes 494 "%8" // notes
495 "</table>" 495 "</table>"
496 "</body>" 496 "</body>"
497 "</html>") 497 "</html>")
498//US 498//US
499 .arg( /*KGlobalSettings::textColor().name()*/ "black" ) 499 .arg( /*KGlobalSettings::textColor().name()*/ "black" )
500//US 500//US
501 .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) 501 .arg( /*KGlobalSettings::baseColor().name()*/ "white" )
502 .arg( picString ) 502 .arg( picString )
503 .arg( name ) 503 .arg( name )
504 .arg( aRole ) 504 .arg( aRole )
505 .arg( aOrga ) 505 .arg( aOrga )
506 .arg( dynamicPart ) 506 .arg( dynamicPart )
507 .arg( notes ); 507 .arg( notes );
508 508
509 } else { // no picture! 509 } else { // no picture!
510 510
511mText = "<table width=\"100%\">\n"; 511mText = "<table width=\"100%\">\n";
512 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; 512 //mText += "<tr bgcolor=\"#3679AD\"><td><h2>";
513#ifdef DESKTOP_VERSION 513#ifdef DESKTOP_VERSION
514 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; 514 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>";
515 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>"; 515 mText += "<font color=\"#FFFFFF\">" + name +"</font></h1>";
516#else 516#else
517 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>"; 517 mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h3>";
518 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>"; 518 mText += "<font color=\"#FFFFFF\"> " + name +"</font></h3>";
519#endif 519#endif
520 520
521 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; 521 mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>";
522 522
523 mText += "<table><td colspan=\"2\">&nbsp;</td>"; 523 mText += "<table><td colspan=\"2\">&nbsp;</td>";
524 /* 524 /*
525 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" 525 mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>"
526 "<td align=\"left\"><b>%2</b></td></tr>" ) 526 "<td align=\"left\"><b>%2</b></td></tr>" )
527 .arg( i18n(" ") ) 527 .arg( i18n(" ") )
528 .arg( name ); 528 .arg( name );
529 */ 529 */
530 if ( ! mAddressee.role().isEmpty() ) 530 if ( ! mAddressee.role().isEmpty() )
531 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 531 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
532 "<td align=\"left\">%2</td></tr>" ) 532 "<td align=\"left\">%2</td></tr>" )
533 .arg( i18n(" ") ) 533 .arg( i18n(" ") )
534 .arg( mAddressee.role()); 534 .arg( mAddressee.role());
535 if ( ! mAddressee.organization().isEmpty() ) 535 if ( ! mAddressee.organization().isEmpty() )
536 mText += QString("<tr><td align=\"right\"><b>%1</b></td>" 536 mText += QString("<tr><td align=\"right\"><b>%1</b></td>"
537 "<td align=\"left\">%2</td></tr>" ) 537 "<td align=\"left\">%2</td></tr>" )
538 .arg( i18n(" ") ) 538 .arg( i18n(" ") )
539 .arg( mAddressee.organization()); 539 .arg( mAddressee.organization());
540 mText += dynamicPart; 540 mText += dynamicPart;
541 mText += notes; 541 mText += notes;
542 mText += "</table>"; 542 mText += "</table>";
543 543
544 } 544 }
545 545
546 // at last display it... 546 // at last display it...
547 setText( mText ); 547 setText( mText );
548 548
549} 549}
550 550
551QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones ,bool preferred ) 551QString AddresseeView::getPhoneNumbers( KABC::PhoneNumber::List phones_unsorted ,bool preferred )
552{ 552{
553 ExternalAppHandler* eah = ExternalAppHandler::instance(); 553 ExternalAppHandler* eah = ExternalAppHandler::instance();
554 bool kphoneAvail = eah->isPhoneAppAvailable(); 554 bool kphoneAvail = eah->isPhoneAppAvailable();
555 bool kfaxAvail = eah->isFaxAppAvailable(); 555 bool kfaxAvail = eah->isFaxAppAvailable();
556 bool ksmsAvail = eah->isSMSAppAvailable(); 556 bool ksmsAvail = eah->isSMSAppAvailable();
557 bool kpagerAvail = eah->isPagerAppAvailable(); 557 bool kpagerAvail = eah->isPagerAppAvailable();
558 bool ksipAvail = eah->isSIPAppAvailable(); 558 bool ksipAvail = eah->isSIPAppAvailable();
559 QString dynamicPart; 559 QString dynamicPart;
560 KABC::PhoneNumber::List::ConstIterator phoneIt; 560 KABC::PhoneNumber::List::ConstIterator phoneIt;
561 QString extension; 561 QString extension;
562 int phonetype; 562 int phonetype;
563 QString sms; 563 QString sms;
564
565 KABC::PhoneNumber::List::Iterator it;
566 KABC::PhoneNumber::List phones ;
567
568 PhoneNumber::TypeList tList = PhoneNumber::supportedTypeList();
569 int i = 0;
570 int max = tList.count();
571 while ( i < max-1 ) {
572 for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) {
573 if ( (*it).type() == tList[i] ) {
574 phones.append( (*it ) );
575 break;
576 }
577 }
578 ++i;
579 }
580 for ( it = phones_unsorted.begin(); it != phones_unsorted.end(); ++it ) {
581 if ( (*it).type() == tList[ max-1 ] )
582 phones.append( (*it ) );
583 }
584
564 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) { 585 for ( phoneIt = phones.begin(); phoneIt != phones.end(); ++phoneIt ) {
565 phonetype = (*phoneIt).type(); 586 phonetype = (*phoneIt).type();
566 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) 587 bool con = false;
588 if ( ((phonetype & KABC::PhoneNumber::Pref) == 0 ) == preferred ) con = true;
589 if ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell ) con = !preferred;;
590 if ( con )
567 continue; 591 continue;
592
568 if (ksmsAvail && 593 if (ksmsAvail &&
569 ( 594 (
570 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) || 595 ((phonetype & KABC::PhoneNumber::Car) == KABC::PhoneNumber::Car) ||
571 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell) 596 ((phonetype & KABC::PhoneNumber::Cell) == KABC::PhoneNumber::Cell)
572 ) 597 )
573 ) 598 )
574 { 599 {
575 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" ) 600 sms = QString("<a href=\"smsto:%1 \">(sms)</a>" )
576 .arg( (*phoneIt).number() ); 601 .arg( (*phoneIt).number() );
577 602
578 } 603 }
579 else 604 else
580 sms = ""; 605 sms = "";
581 606
582 extension = QString::null; 607 extension = QString::null;
583 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) { 608 if ((phonetype & KABC::PhoneNumber::Fax) == KABC::PhoneNumber::Fax) {
584 if (kfaxAvail) extension = "faxto:"; 609 if (kfaxAvail) extension = "faxto:";
585 } 610 }
586 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) { 611 else if ((phonetype & KABC::PhoneNumber::Pager) == KABC::PhoneNumber::Pager) {
587 if (kpagerAvail) extension = "pagerto:"; 612 if (kpagerAvail) extension = "pagerto:";
588 } 613 }
589#if 0 614#if 0
590 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) { 615 else if ((phonetype & KABC::PhoneNumber::Sip) == KABC::PhoneNumber::Sip) {
591 if (ksipAvail) extension = "sipto:"; 616 if (ksipAvail) extension = "sipto:";
592 } 617 }
593#endif 618#endif
594 else if (kphoneAvail) { 619 else if (kphoneAvail) {
595 extension = "phoneto:"; 620 extension = "phoneto:";
596 } 621 }
597 else 622 else
598 extension = QString::null; 623 extension = QString::null;
599 624
600 if ( !extension.isEmpty() ) { 625 if ( !extension.isEmpty() ) {
601 dynamicPart += QString( 626 dynamicPart += QString(
602 "<tr><td align=\"right\"><b>%1</b></td>" 627 "<tr><td align=\"right\"><b>%1</b></td>"
603 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" ) 628 "<td align=\"left\"><a href=\"%2%3 \">%4</a> %5</td></tr>" )
604 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 629 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
605 .arg( extension ) 630 .arg( extension )
606 .arg( (*phoneIt).number() ) 631 .arg( (*phoneIt).number() )
607 .arg( (*phoneIt).number() ) 632 .arg( (*phoneIt).number() )
608 .arg( sms ); 633 .arg( sms );
609 634
610 } else { 635 } else {
611 dynamicPart += QString( 636 dynamicPart += QString(
612 "<tr><td align=\"right\"><b>%1</b></td>" 637 "<tr><td align=\"right\"><b>%1</b></td>"
613 "<td align=\"left\">%2 %3</td></tr>" ) 638 "<td align=\"left\">%2 %3</td></tr>" )
614 .arg( KABC::PhoneNumber::typeLabel( phonetype ) ) 639 .arg( KABC::PhoneNumber::typeLabel( phonetype ) )
615 .arg( (*phoneIt).number() ) 640 .arg( (*phoneIt).number() )
616 .arg( sms ); 641 .arg( sms );
617 } 642 }
618 } 643 }
619 return dynamicPart; 644 return dynamicPart;
620} 645}
621/* 646/*
622KABC::Addressee AddresseeView::addressee() const 647KABC::Addressee AddresseeView::addressee() const
623{ 648{
624 return mAddressee; 649 return mAddressee;
625} 650}
626*/ 651*/
627void AddresseeView::addTag(const QString & tag,const QString & text) 652void AddresseeView::addTag(const QString & tag,const QString & text)
628{ 653{
629 if ( text.isEmpty() ) 654 if ( text.isEmpty() )
630 return; 655 return;
631 int number=text.contains("\n"); 656 int number=text.contains("\n");
632 QString str = "<" + tag + ">"; 657 QString str = "<" + tag + ">";
633 QString tmpText=text; 658 QString tmpText=text;
634 QString tmpStr=str; 659 QString tmpStr=str;
635 if(number !=-1) 660 if(number !=-1)
636 { 661 {
637 if (number > 0) { 662 if (number > 0) {
638 int pos=0; 663 int pos=0;
639 QString tmp; 664 QString tmp;
640 for(int i=0;i<=number;i++) { 665 for(int i=0;i<=number;i++) {
641 pos=tmpText.find("\n"); 666 pos=tmpText.find("\n");
642 tmp=tmpText.left(pos); 667 tmp=tmpText.left(pos);
643 tmpText=tmpText.right(tmpText.length()-pos-1); 668 tmpText=tmpText.right(tmpText.length()-pos-1);
644 tmpStr+=tmp+"<br>"; 669 tmpStr+=tmp+"<br>";
645 } 670 }
646 } 671 }
647 else tmpStr += tmpText; 672 else tmpStr += tmpText;
648 tmpStr+="</" + tag + ">"; 673 tmpStr+="</" + tag + ">";
649 mText.append(tmpStr); 674 mText.append(tmpStr);
650 } 675 }
651 else 676 else
652 { 677 {
653 str += text + "</" + tag + ">"; 678 str += text + "</" + tag + ">";
654 mText.append(str); 679 mText.append(str);
655 } 680 }
656} 681}
657 682
658AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, 683AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name,
659 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) 684 true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false)
660{ 685{
661 findButton( Close )->setText( i18n("Cancel Sync")); 686 findButton( Close )->setText( i18n("Cancel Sync"));
662 findButton( Ok )->setText( i18n("Remote")); 687 findButton( Ok )->setText( i18n("Remote"));
663 findButton( User1 )->setText( i18n("Local")); 688 findButton( User1 )->setText( i18n("Local"));
664 QWidget* topframe = new QWidget( this ); 689 QWidget* topframe = new QWidget( this );
665 setMainWidget( topframe ); 690 setMainWidget( topframe );
666 QBoxLayout* bl; 691 QBoxLayout* bl;
667 if ( QApplication::desktop()->width() < 640 ) { 692 if ( QApplication::desktop()->width() < 640 ) {
668 bl = new QVBoxLayout( topframe ); 693 bl = new QVBoxLayout( topframe );
669 } else { 694 } else {
670 bl = new QHBoxLayout( topframe ); 695 bl = new QHBoxLayout( topframe );
671 } 696 }
672 QVBox* subframe = new QVBox( topframe ); 697 QVBox* subframe = new QVBox( topframe );
673 bl->addWidget(subframe ); 698 bl->addWidget(subframe );
674 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); 699 QLabel* lab = new QLabel( i18n("Local Addressee"), subframe );
675 if ( takeloc ) 700 if ( takeloc )
676 lab->setBackgroundColor(Qt::green.light() ); 701 lab->setBackgroundColor(Qt::green.light() );
677 AddresseeView * av = new AddresseeView( subframe ); 702 AddresseeView * av = new AddresseeView( subframe );
678 av->setAddressee( loc ); 703 av->setAddressee( loc );
679 subframe = new QVBox( topframe ); 704 subframe = new QVBox( topframe );
680 bl->addWidget(subframe ); 705 bl->addWidget(subframe );
681 lab = new QLabel( i18n("Remote Addressee"), subframe ); 706 lab = new QLabel( i18n("Remote Addressee"), subframe );
682 if ( !takeloc ) 707 if ( !takeloc )
683 lab->setBackgroundColor(Qt::green.light() ); 708 lab->setBackgroundColor(Qt::green.light() );
684 av = new AddresseeView( subframe ); 709 av = new AddresseeView( subframe );
685 av->setAddressee( rem ); 710 av->setAddressee( rem );
686 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); 711 QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote()));
687 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); 712 QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local()));
688#ifndef DESKTOP_VERSION 713#ifndef DESKTOP_VERSION
689 showMaximized(); 714 showMaximized();
690#else 715#else
691 resize ( 640, 400 ); 716 resize ( 640, 400 );
692#endif 717#endif
693} 718}
694 719
695int AddresseeChooser::executeD( bool local ) 720int AddresseeChooser::executeD( bool local )
696{ 721{
697 mSyncResult = 3; 722 mSyncResult = 3;
698 if ( local ) 723 if ( local )
699 findButton( User1 )->setFocus(); 724 findButton( User1 )->setFocus();
700 else 725 else
701 findButton( Ok )->setFocus(); 726 findButton( Ok )->setFocus();
702 exec(); 727 exec();
703 return mSyncResult; 728 return mSyncResult;
704} 729}
705void AddresseeChooser::slot_remote() 730void AddresseeChooser::slot_remote()
706{ 731{
707 mSyncResult = 2; 732 mSyncResult = 2;
708 accept(); 733 accept();
709} 734}
710void AddresseeChooser::slot_local() 735void AddresseeChooser::slot_local()
711{ 736{
712 mSyncResult = 1; 737 mSyncResult = 1;
713 accept(); 738 accept();
714} 739}