-rw-r--r-- | kabc/addresseeview.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/kabc/addresseeview.cpp b/kabc/addresseeview.cpp index 487e8a5..2dda968 100644 --- a/kabc/addresseeview.cpp +++ b/kabc/addresseeview.cpp | |||
@@ -223,245 +223,242 @@ void AddresseeView::setAddressee( const KABC::Addressee& addr ) | |||
223 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); | 223 | //US .arg( KStringHandler::tagURLs( mAddressee.url().url() ) ); |
224 | .arg( mAddressee.url().url() ); | 224 | .arg( mAddressee.url().url() ); |
225 | //qDebug("AddresseeView::setAddressee has to be verified."); | 225 | //qDebug("AddresseeView::setAddressee has to be verified."); |
226 | } | 226 | } |
227 | 227 | ||
228 | KABC::Address::List addresses = mAddressee.addresses(); | 228 | KABC::Address::List addresses = mAddressee.addresses(); |
229 | KABC::Address::List::ConstIterator addrIt; | 229 | KABC::Address::List::ConstIterator addrIt; |
230 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { | 230 | for ( addrIt = addresses.begin(); addrIt != addresses.end(); ++addrIt ) { |
231 | if ( true /*(*addrIt).label().isEmpty()*/ ) { | 231 | if ( true /*(*addrIt).label().isEmpty()*/ ) { |
232 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); | 232 | QString formattedAddress = (*addrIt).formattedAddress().stripWhiteSpace(); |
233 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); | 233 | //US formattedAddress = formattedAddress.replace( '\n', "<br>" ); |
234 | //qDebug("adresss %s ",formattedAddress.latin1() ); | 234 | //qDebug("adresss %s ",formattedAddress.latin1() ); |
235 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); | 235 | formattedAddress = formattedAddress.replace( QRegExp("\n"), "<br>" ); |
236 | //qDebug("AddresseeView::setAddressee has to be verified."); | 236 | //qDebug("AddresseeView::setAddressee has to be verified."); |
237 | 237 | ||
238 | dynamicPart += QString( | 238 | dynamicPart += QString( |
239 | "<tr><td align=\"right\"><b>%1</b></td>" | 239 | "<tr><td align=\"right\"><b>%1</b></td>" |
240 | "<td align=\"left\">%2</td></tr>" ) | 240 | "<td align=\"left\">%2</td></tr>" ) |
241 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 241 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
242 | .arg( formattedAddress ); | 242 | .arg( formattedAddress ); |
243 | } else { | 243 | } else { |
244 | 244 | ||
245 | dynamicPart += QString( | 245 | dynamicPart += QString( |
246 | "<tr><td align=\"right\"><b>%1</b></td>" | 246 | "<tr><td align=\"right\"><b>%1</b></td>" |
247 | "<td align=\"left\">%2</td></tr>" ) | 247 | "<td align=\"left\">%2</td></tr>" ) |
248 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) | 248 | .arg( KABC::Address::typeLabel( (*addrIt).type() ) ) |
249 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); | 249 | //US .arg( (*addrIt).label().replace( '\n', "<br>" ) ); |
250 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); | 250 | .arg( (*addrIt).label() /*replace( QRegExp("\n"), "<br>" )*/ ); |
251 | 251 | ||
252 | } | 252 | } |
253 | } | 253 | } |
254 | 254 | ||
255 | QString notes; | 255 | QString notes; |
256 | if ( !mAddressee.note().isEmpty() ) { | 256 | if ( !mAddressee.note().isEmpty() ) { |
257 | notes = QString( | 257 | notes = QString( |
258 | "<tr>" | 258 | "<tr>" |
259 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label | 259 | "<td align=\"right\" valign=\"top\"><b>%1</b></td>" // note label |
260 | "<td align=\"left\">%2</td>" // note | 260 | "<td align=\"left\">%2</td>" // note |
261 | "</tr>" ).arg( i18n( "Notes" ) ) | 261 | "</tr>" ).arg( i18n( "Notes" ) ) |
262 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); | 262 | //US .arg( mAddressee.note().replace( '\n', "<br>" ) ); |
263 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); | 263 | .arg( mAddressee.note().replace( QRegExp("\n"), "<br>" ) ); |
264 | //qDebug("AddresseeView::setAddressee has to be verified."); | 264 | //qDebug("AddresseeView::setAddressee has to be verified."); |
265 | } | 265 | } |
266 | 266 | ||
267 | QString aRole = ""; | 267 | QString aRole = ""; |
268 | QString aOrga = ""; | 268 | QString aOrga = ""; |
269 | if ( true /*!mAddressee.role().isEmpty()*/ ) { | 269 | if ( true /*!mAddressee.role().isEmpty()*/ ) { |
270 | aRole = "<tr>" | 270 | aRole = "<tr>" |
271 | "<td align=\"left\">" + mAddressee.role() + "</td>" | 271 | "<td align=\"left\">" + mAddressee.role() + "</td>" |
272 | "</tr>"; | 272 | "</tr>"; |
273 | } | 273 | } |
274 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { | 274 | if ( true /*!mAddressee.organization().isEmpty()*/ ) { |
275 | aOrga = "<tr>" | 275 | aOrga = "<tr>" |
276 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; | 276 | "<td align=\"left\">" + mAddressee.organization() + "</td>" ; |
277 | "</tr>"; | 277 | "</tr>"; |
278 | } | 278 | } |
279 | mText = ""; | 279 | mText = ""; |
280 | QString picString = ""; | 280 | QString picString = ""; |
281 | KABC::Picture picture = mAddressee.photo(); | 281 | KABC::Picture picture = mAddressee.photo(); |
282 | bool picAvailintern = false; | 282 | bool picAvailintern = false; |
283 | bool picAvailUrl = false; | 283 | bool picAvailUrl = false; |
284 | if (! picture.undefined() ) { | 284 | if (! picture.undefined() ) { |
285 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); | 285 | picAvailintern = (picture.isIntern() && !picture.data().isNull()); |
286 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); | 286 | picAvailUrl = !picture.isIntern() && QFile::exists(picture.url() ); |
287 | } | 287 | } |
288 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { | 288 | if ( picAvailUrl || picAvailintern || QApplication::desktop()->width() > 320 ) { |
289 | if ( picAvailintern ) { | 289 | if ( picAvailintern ) { |
290 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); | 290 | QMimeSourceFactory::defaultFactory()->setImage( "myimage", picture.data() ); |
291 | } else { | 291 | } else { |
292 | if ( picAvailUrl ) { | 292 | if ( picAvailUrl ) { |
293 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); | 293 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", QPixmap( picture.url() )); |
294 | } else { | 294 | } else { |
295 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); | 295 | QMimeSourceFactory::defaultFactory()->setPixmap( "myimage", KGlobal::iconLoader()->loadIcon( "package_toys", KIcon::Desktop, 128 ) ); |
296 | } | 296 | } |
297 | } | 297 | } |
298 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; | 298 | picString = "<img src=\"myimage\" width=\"50\" height=\"70\">"; |
299 | mText = QString::fromLatin1( | 299 | mText = QString::fromLatin1( |
300 | "<html>" | 300 | "<html>" |
301 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color | 301 | "<body text=\"%1\" bgcolor=\"%2\">" // text and background color |
302 | "<table>" | 302 | "<table>" |
303 | "<tr>" | 303 | "<tr>" |
304 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" | 304 | "<td rowspan=\"3\" align=\"right\" valign=\"top\">" |
305 | "%3" | 305 | "%3" |
306 | "</td>" | 306 | "</td>" |
307 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name | 307 | "<td align=\"left\"><font size=\"+2\"><b>%4</b></font></td>" // name |
308 | "</tr>" | 308 | "</tr>" |
309 | "%5" // role | 309 | "%5" // role |
310 | "%6" // organization | 310 | "%6" // organization |
311 | "<td colspan=\"2\"> </td>" | 311 | "<td colspan=\"2\"> </td>" |
312 | "%7" // dynamic part | 312 | "%7" // dynamic part |
313 | "%8" // notes | 313 | "%8" // notes |
314 | "</table>" | 314 | "</table>" |
315 | "</body>" | 315 | "</body>" |
316 | "</html>") | 316 | "</html>") |
317 | //US | 317 | //US |
318 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) | 318 | .arg( /*KGlobalSettings::textColor().name()*/ "black" ) |
319 | //US | 319 | //US |
320 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) | 320 | .arg( /*KGlobalSettings::baseColor().name()*/ "white" ) |
321 | .arg( picString ) | 321 | .arg( picString ) |
322 | .arg( name ) | 322 | .arg( name ) |
323 | .arg( aRole ) | 323 | .arg( aRole ) |
324 | .arg( aOrga ) | 324 | .arg( aOrga ) |
325 | .arg( dynamicPart ) | 325 | .arg( dynamicPart ) |
326 | .arg( notes ); | 326 | .arg( notes ); |
327 | 327 | ||
328 | } else { // no picture! | 328 | } else { // no picture! |
329 | 329 | ||
330 | mText = "<table width=\"100%\">\n"; | 330 | mText = "<table width=\"100%\">\n"; |
331 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; | 331 | //mText += "<tr bgcolor=\"#3679AD\"><td><h2>"; |
332 | #ifdef DESKTOP_VERSION | 332 | #ifdef DESKTOP_VERSION |
333 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; | 333 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h1>"; |
334 | #else | 334 | #else |
335 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; | 335 | mText += "<tr bgcolor=\"#5699CD\"><td align=\"left\"><h2>"; |
336 | #endif | 336 | #endif |
337 | 337 | ||
338 | #ifdef DESKTOP_VERSION | 338 | #ifdef DESKTOP_VERSION |
339 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; | 339 | mText += "<font color=\"#FFFFFF\"> <em>" + name+"</em></font></h1>"; |
340 | #else | 340 | #else |
341 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; | 341 | mText += "<font color=\"#FFFFFF\"> <em>" + name +"</em></font></h2>"; |
342 | #endif | 342 | #endif |
343 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; | 343 | mText += "</td></tr>\n<tr bgcolor=\"#EAF8FA\"><td>"; |
344 | 344 | ||
345 | mText += "<table><td colspan=\"2\"> </td>"; | 345 | mText += "<table><td colspan=\"2\"> </td>"; |
346 | /* | 346 | /* |
347 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" | 347 | mText += QString("<tr><td align=\"right\"><b2>%1</b2></td>" |
348 | "<td align=\"left\"><b>%2</b></td></tr>" ) | 348 | "<td align=\"left\"><b>%2</b></td></tr>" ) |
349 | .arg( i18n(" ") ) | 349 | .arg( i18n(" ") ) |
350 | .arg( name ); | 350 | .arg( name ); |
351 | */ | 351 | */ |
352 | if ( ! mAddressee.role().isEmpty() ) | 352 | if ( ! mAddressee.role().isEmpty() ) |
353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 353 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
354 | "<td align=\"left\">%2</td></tr>" ) | 354 | "<td align=\"left\">%2</td></tr>" ) |
355 | .arg( i18n(" ") ) | 355 | .arg( i18n(" ") ) |
356 | .arg( mAddressee.role()); | 356 | .arg( mAddressee.role()); |
357 | if ( ! mAddressee.organization().isEmpty() ) | 357 | if ( ! mAddressee.organization().isEmpty() ) |
358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" | 358 | mText += QString("<tr><td align=\"right\"><b>%1</b></td>" |
359 | "<td align=\"left\">%2</td></tr>" ) | 359 | "<td align=\"left\">%2</td></tr>" ) |
360 | .arg( i18n(" ") ) | 360 | .arg( i18n(" ") ) |
361 | .arg( mAddressee.organization()); | 361 | .arg( mAddressee.organization()); |
362 | mText += dynamicPart; | 362 | mText += dynamicPart; |
363 | mText += notes; | 363 | mText += notes; |
364 | mText += "</table>"; | 364 | mText += "</table>"; |
365 | 365 | ||
366 | } | 366 | } |
367 | 367 | ||
368 | // at last display it... | 368 | // at last display it... |
369 | setText( mText ); | 369 | setText( mText ); |
370 | 370 | ||
371 | } | 371 | } |
372 | 372 | ||
373 | KABC::Addressee AddresseeView::addressee() const | 373 | KABC::Addressee AddresseeView::addressee() const |
374 | { | 374 | { |
375 | return mAddressee; | 375 | return mAddressee; |
376 | } | 376 | } |
377 | void AddresseeView::addTag(const QString & tag,const QString & text) | 377 | void AddresseeView::addTag(const QString & tag,const QString & text) |
378 | { | 378 | { |
379 | if ( text.isEmpty() ) | 379 | if ( text.isEmpty() ) |
380 | return; | 380 | return; |
381 | int number=text.contains("\n"); | 381 | int number=text.contains("\n"); |
382 | QString str = "<" + tag + ">"; | 382 | QString str = "<" + tag + ">"; |
383 | QString tmpText=text; | 383 | QString tmpText=text; |
384 | QString tmpStr=str; | 384 | QString tmpStr=str; |
385 | if(number !=-1) | 385 | if(number !=-1) |
386 | { | 386 | { |
387 | if (number > 0) { | 387 | if (number > 0) { |
388 | int pos=0; | 388 | int pos=0; |
389 | QString tmp; | 389 | QString tmp; |
390 | for(int i=0;i<=number;i++) { | 390 | for(int i=0;i<=number;i++) { |
391 | pos=tmpText.find("\n"); | 391 | pos=tmpText.find("\n"); |
392 | tmp=tmpText.left(pos); | 392 | tmp=tmpText.left(pos); |
393 | tmpText=tmpText.right(tmpText.length()-pos-1); | 393 | tmpText=tmpText.right(tmpText.length()-pos-1); |
394 | tmpStr+=tmp+"<br>"; | 394 | tmpStr+=tmp+"<br>"; |
395 | } | 395 | } |
396 | } | 396 | } |
397 | else tmpStr += tmpText; | 397 | else tmpStr += tmpText; |
398 | tmpStr+="</" + tag + ">"; | 398 | tmpStr+="</" + tag + ">"; |
399 | mText.append(tmpStr); | 399 | mText.append(tmpStr); |
400 | } | 400 | } |
401 | else | 401 | else |
402 | { | 402 | { |
403 | str += text + "</" + tag + ">"; | 403 | str += text + "</" + tag + ">"; |
404 | mText.append(str); | 404 | mText.append(str); |
405 | } | 405 | } |
406 | } | 406 | } |
407 | 407 | ||
408 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, | 408 | AddresseeChooser::AddresseeChooser( KABC::Addressee loc, KABC::Addressee rem, bool takeloc, QWidget *parent, const char *name ) : KDialogBase(parent,name, |
409 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) | 409 | true ,i18n("Conflict! Please choose Adressee!"),Ok|User1|Close,Close, false) |
410 | { | 410 | { |
411 | findButton( Close )->setText( i18n("Cancel Sync")); | 411 | findButton( Close )->setText( i18n("Cancel Sync")); |
412 | findButton( Ok )->setText( i18n("Remote")); | 412 | findButton( Ok )->setText( i18n("Remote")); |
413 | findButton( User1 )->setText( i18n("Local")); | 413 | findButton( User1 )->setText( i18n("Local")); |
414 | QWidget* topframe = new QWidget( this ); | 414 | QWidget* topframe = new QWidget( this ); |
415 | //QVBox* topframe = new QVBox( this ); | ||
416 | setMainWidget( topframe ); | 415 | setMainWidget( topframe ); |
417 | QBoxLayout* bl; | 416 | QBoxLayout* bl; |
418 | if ( QApplication::desktop()->width() < 640 ) { | 417 | if ( QApplication::desktop()->width() < 640 ) { |
419 | bl = new QVBoxLayout( topframe ); | 418 | bl = new QVBoxLayout( topframe ); |
420 | |||
421 | } else { | 419 | } else { |
422 | bl = new QHBoxLayout( topframe ); | 420 | bl = new QHBoxLayout( topframe ); |
423 | |||
424 | } | 421 | } |
425 | QVBox* subframe = new QVBox( topframe ); | 422 | QVBox* subframe = new QVBox( topframe ); |
426 | bl->addWidget(subframe ); | 423 | bl->addWidget(subframe ); |
427 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); | 424 | QLabel* lab = new QLabel( i18n("Local Addressee"), subframe ); |
425 | if ( takeloc ) | ||
426 | lab->setBackgroundColor(Qt::green.light() ); | ||
428 | AddresseeView * av = new AddresseeView( subframe ); | 427 | AddresseeView * av = new AddresseeView( subframe ); |
429 | av->setAddressee( loc ); | 428 | av->setAddressee( loc ); |
430 | subframe = new QVBox( topframe ); | 429 | subframe = new QVBox( topframe ); |
431 | bl->addWidget(subframe ); | 430 | bl->addWidget(subframe ); |
432 | lab = new QLabel( i18n("Remote Addressee"), subframe ); | 431 | lab = new QLabel( i18n("Remote Addressee"), subframe ); |
432 | if ( !takeloc ) | ||
433 | lab->setBackgroundColor(Qt::green.light() ); | ||
433 | av = new AddresseeView( subframe ); | 434 | av = new AddresseeView( subframe ); |
434 | av->setAddressee( rem ); | 435 | av->setAddressee( rem ); |
435 | 436 | QObject::connect(findButton( Ok ),SIGNAL(clicked()),this, SLOT(slot_remote())); | |
436 | QObject::connect(findButton( Ok ),SIGNAL(clicked()), | 437 | QObject::connect(this,SIGNAL(user1Clicked()),this, SLOT(slot_local())); |
437 | SLOT(slot_remote())); | ||
438 | QObject::connect(this,SIGNAL(user1Clicked()), | ||
439 | SLOT(slot_local())); | ||
440 | #ifndef DESKTOP_VERSION | 438 | #ifndef DESKTOP_VERSION |
441 | showMaximized(); | 439 | showMaximized(); |
442 | #else | 440 | #else |
443 | resize ( 640, 400 ); | 441 | resize ( 640, 400 ); |
444 | #endif | 442 | #endif |
445 | } | 443 | } |
446 | 444 | ||
447 | int AddresseeChooser::executeD( bool local ) | 445 | int AddresseeChooser::executeD( bool local ) |
448 | { | 446 | { |
449 | mSyncResult = 3; | 447 | mSyncResult = 3; |
450 | if ( local ) | 448 | if ( local ) |
451 | findButton( User1 )->setFocus(); | 449 | findButton( User1 )->setFocus(); |
452 | else | 450 | else |
453 | findButton( Ok )->setFocus(); | 451 | findButton( Ok )->setFocus(); |
454 | exec(); | 452 | exec(); |
455 | qDebug("returning %d ",mSyncResult ); | ||
456 | return mSyncResult; | 453 | return mSyncResult; |
457 | } | 454 | } |
458 | void AddresseeChooser::slot_remote() | 455 | void AddresseeChooser::slot_remote() |
459 | { | 456 | { |
460 | mSyncResult = 2; | 457 | mSyncResult = 2; |
461 | accept(); | 458 | accept(); |
462 | } | 459 | } |
463 | void AddresseeChooser::slot_local() | 460 | void AddresseeChooser::slot_local() |
464 | { | 461 | { |
465 | mSyncResult = 1; | 462 | mSyncResult = 1; |
466 | accept(); | 463 | accept(); |
467 | } | 464 | } |