author | drw <drw> | 2003-05-18 23:20:25 (UTC) |
---|---|---|
committer | drw <drw> | 2003-05-18 23:20:25 (UTC) |
commit | 586dea6e61c766da49ba6cb55dd71851c0fafad3 (patch) (unidiff) | |
tree | 6122bd75b327c4a29157a66e273bae9632ac22a0 | |
parent | 34c5b88459bcf5e02deae6b04e8bc17ee0de74c0 (diff) | |
download | opie-586dea6e61c766da49ba6cb55dd71851c0fafad3.zip opie-586dea6e61c766da49ba6cb55dd71851c0fafad3.tar.gz opie-586dea6e61c766da49ba6cb55dd71851c0fafad3.tar.bz2 |
Updates to ocontact, oevent & otodo's toRichText() implementations
-rw-r--r-- | libopie/pim/ocontact.cpp | 31 | ||||
-rw-r--r-- | libopie/pim/oevent.cpp | 56 | ||||
-rw-r--r-- | libopie/pim/otodo.cpp | 54 | ||||
-rw-r--r-- | libopie2/opiepim/ocontact.cpp | 31 | ||||
-rw-r--r-- | libopie2/opiepim/oevent.cpp | 56 | ||||
-rw-r--r-- | libopie2/opiepim/otodo.cpp | 54 |
6 files changed, 212 insertions, 70 deletions
diff --git a/libopie/pim/ocontact.cpp b/libopie/pim/ocontact.cpp index a7ca975..a2fb68c 100644 --- a/libopie/pim/ocontact.cpp +++ b/libopie/pim/ocontact.cpp | |||
@@ -395,281 +395,286 @@ OContact::~OContact() | |||
395 | Returns the groups for the contact. | 395 | Returns the groups for the contact. |
396 | */ | 396 | */ |
397 | 397 | ||
398 | /*! \fn QStringList OContact::groupList() const | 398 | /*! \fn QStringList OContact::groupList() const |
399 | \internal | 399 | \internal |
400 | */ | 400 | */ |
401 | 401 | ||
402 | /*! \fn QString OContact::field(int) const | 402 | /*! \fn QString OContact::field(int) const |
403 | \internal | 403 | \internal |
404 | */ | 404 | */ |
405 | 405 | ||
406 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 406 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
407 | \internal | 407 | \internal |
408 | */ | 408 | */ |
409 | 409 | ||
410 | /*! \fn void OContact::setUid( int id ) | 410 | /*! \fn void OContact::setUid( int id ) |
411 | \internal | 411 | \internal |
412 | Sets the uid for this record to \a id. | 412 | Sets the uid for this record to \a id. |
413 | */ | 413 | */ |
414 | 414 | ||
415 | /*! \enum OContact::journal_action | 415 | /*! \enum OContact::journal_action |
416 | \internal | 416 | \internal |
417 | */ | 417 | */ |
418 | 418 | ||
419 | /*! | 419 | /*! |
420 | \internal | 420 | \internal |
421 | */ | 421 | */ |
422 | QMap<int, QString> OContact::toMap() const | 422 | QMap<int, QString> OContact::toMap() const |
423 | { | 423 | { |
424 | QMap<int, QString> map = mMap; | 424 | QMap<int, QString> map = mMap; |
425 | QString cats = idsToString( categories() ); | 425 | QString cats = idsToString( categories() ); |
426 | if ( !cats.isEmpty() ) | 426 | if ( !cats.isEmpty() ) |
427 | map.insert( Qtopia::AddressCategory, cats ); | 427 | map.insert( Qtopia::AddressCategory, cats ); |
428 | return map; | 428 | return map; |
429 | } | 429 | } |
430 | 430 | ||
431 | /*! | 431 | /*! |
432 | Returns a rich text formatted QString representing the contents the contact. | 432 | Returns a rich text formatted QString representing the contents the contact. |
433 | */ | 433 | */ |
434 | QString OContact::toRichText() const | 434 | QString OContact::toRichText() const |
435 | { | 435 | { |
436 | QString text; | 436 | QString text; |
437 | QString value, comp, state; | 437 | QString value, comp, state; |
438 | QString str; | 438 | QString str; |
439 | bool marker = false; | 439 | bool marker = false; |
440 | 440 | ||
441 | // name, jobtitle and company | 441 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 442 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>"; | 443 | text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; |
444 | |||
444 | if ( !(value = jobTitle()).isEmpty() ) | 445 | if ( !(value = jobTitle()).isEmpty() ) |
445 | text += Qtopia::escapeString(value) + "<br>"; | 446 | text += Qtopia::escapeString(value) + "<br>"; |
446 | 447 | ||
447 | comp = company(); | 448 | comp = company(); |
448 | if ( !(value = department()).isEmpty() ) { | 449 | if ( !(value = department()).isEmpty() ) { |
449 | text += Qtopia::escapeString(value); | 450 | text += Qtopia::escapeString(value); |
450 | if ( comp ) | 451 | if ( comp ) |
451 | text += ", "; | 452 | text += ", "; |
452 | else | 453 | else |
453 | text += "<br>"; | 454 | text += "<br>"; |
454 | } | 455 | } |
455 | if ( !comp.isEmpty() ) | 456 | if ( !comp.isEmpty() ) |
456 | text += Qtopia::escapeString(comp) + "<br>"; | 457 | text += Qtopia::escapeString(comp) + "<br>"; |
457 | 458 | ||
459 | text += "<hr><br>"; | ||
460 | |||
461 | // defailt email | ||
458 | QString defEmail = defaultEmail(); | 462 | QString defEmail = defaultEmail(); |
459 | if ( !defEmail.isEmpty() ) | 463 | if ( !defEmail.isEmpty() ) |
460 | text += "<b>" + QObject::tr("Default Email: ") + "</b>" | 464 | text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" |
461 | + Qtopia::escapeString(defEmail) + "<br>"; | 465 | + Qtopia::escapeString(defEmail) + "<br>"; |
462 | 466 | ||
463 | text += "<hr>"; | 467 | text += "<br>"; |
464 | 468 | ||
465 | // business address | 469 | // business address |
466 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 470 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
467 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 471 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
468 | text += "<br>"; | ||
469 | text += QObject::tr( "<b>Work Address:</b>" ); | 472 | text += QObject::tr( "<b>Work Address:</b>" ); |
470 | text += "<br>"; | 473 | text += "<br>"; |
471 | marker = true; | 474 | marker = true; |
472 | } | 475 | } |
473 | 476 | ||
474 | if ( !(value = businessStreet()).isEmpty() ) | 477 | if ( !(value = businessStreet()).isEmpty() ) |
475 | text += Qtopia::escapeString(value) + "<br>"; | 478 | text += Qtopia::escapeString(value) + "<br>"; |
476 | state = businessState(); | 479 | state = businessState(); |
477 | if ( !(value = businessZip()).isEmpty() ) | 480 | if ( !(value = businessZip()).isEmpty() ) |
478 | text += Qtopia::escapeString(value) + " "; | 481 | text += Qtopia::escapeString(value) + " "; |
479 | if ( !(value = businessCity()).isEmpty() ) { | 482 | if ( !(value = businessCity()).isEmpty() ) { |
480 | text += Qtopia::escapeString(value); | 483 | text += Qtopia::escapeString(value); |
481 | if ( state ) | 484 | if ( state ) |
482 | text += ", " + Qtopia::escapeString(state); | 485 | text += ", " + Qtopia::escapeString(state); |
483 | text += "<br>"; | 486 | text += "<br>"; |
484 | } else if ( !state.isEmpty() ) | 487 | } else if ( !state.isEmpty() ) |
485 | text += Qtopia::escapeString(state) + "<br>"; | 488 | text += Qtopia::escapeString(state) + "<br>"; |
486 | 489 | ||
487 | if ( !(value = businessCountry()).isEmpty() ) | 490 | if ( !(value = businessCountry()).isEmpty() ) |
488 | text += Qtopia::escapeString(value) + "<br>"; | 491 | text += Qtopia::escapeString(value) + "<br>"; |
489 | 492 | ||
490 | // rest of Business data | 493 | // rest of Business data |
491 | str = office(); | 494 | str = office(); |
492 | if ( !str.isEmpty() ){ | 495 | if ( !str.isEmpty() ){ |
493 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 496 | text += "<b>" + QObject::tr("Office: ") + "</b>" |
494 | + Qtopia::escapeString(str) + "<br>"; | 497 | + Qtopia::escapeString(str) + "<br>"; |
495 | marker = true; | 498 | marker = true; |
496 | } | 499 | } |
497 | str = businessWebpage(); | 500 | str = businessWebpage(); |
498 | if ( !str.isEmpty() ){ | 501 | if ( !str.isEmpty() ){ |
499 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" | 502 | text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" |
500 | + Qtopia::escapeString(str) + "<br>"; | 503 | + Qtopia::escapeString(str) + "<br>"; |
501 | marker = true; | 504 | marker = true; |
502 | } | 505 | } |
503 | str = businessPhone(); | 506 | str = businessPhone(); |
504 | if ( !str.isEmpty() ){ | 507 | if ( !str.isEmpty() ){ |
505 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" | 508 | text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" |
506 | + Qtopia::escapeString(str) + "<br>"; | 509 | + Qtopia::escapeString(str) + "<br>"; |
507 | marker = true; | 510 | marker = true; |
508 | } | 511 | } |
509 | str = businessFax(); | 512 | str = businessFax(); |
510 | if ( !str.isEmpty() ){ | 513 | if ( !str.isEmpty() ){ |
511 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" | 514 | text += "<b><img src=\"addressbook/faxwork\">" + QObject::tr("Business Fax: ") + "</b>" |
512 | + Qtopia::escapeString(str) + "<br>"; | 515 | + Qtopia::escapeString(str) + "<br>"; |
513 | marker = true; | 516 | marker = true; |
514 | } | 517 | } |
515 | str = businessMobile(); | 518 | str = businessMobile(); |
516 | if ( !str.isEmpty() ){ | 519 | if ( !str.isEmpty() ){ |
517 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" | 520 | text += "<b><img src=\"addressbook/mobilework\">" + QObject::tr("Business Mobile: ") + "</b>" |
518 | + Qtopia::escapeString(str) + "<br>"; | 521 | + Qtopia::escapeString(str) + "<br>"; |
519 | marker = true; | 522 | marker = true; |
520 | } | 523 | } |
521 | str = businessPager(); | 524 | str = businessPager(); |
522 | if ( !str.isEmpty() ){ | 525 | if ( !str.isEmpty() ){ |
523 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 526 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" |
524 | + Qtopia::escapeString(str) + "<br>"; | 527 | + Qtopia::escapeString(str) + "<br>"; |
525 | marker = true; | 528 | marker = true; |
526 | } | 529 | } |
527 | 530 | ||
531 | text += "<br>"; | ||
532 | |||
528 | // home address | 533 | // home address |
529 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 534 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
530 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 535 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
531 | text += "<br>"; | ||
532 | text += QObject::tr( "<b>Home Address:</b>" ); | 536 | text += QObject::tr( "<b>Home Address:</b>" ); |
533 | text += "<br>"; | 537 | text += "<br>"; |
534 | } | 538 | } |
535 | 539 | ||
536 | if ( !(value = homeStreet()).isEmpty() ) | 540 | if ( !(value = homeStreet()).isEmpty() ) |
537 | text += Qtopia::escapeString(value) + "<br>"; | 541 | text += Qtopia::escapeString(value) + "<br>"; |
538 | state = homeState(); | 542 | state = homeState(); |
539 | if ( !(value = homeZip()).isEmpty() ) | 543 | if ( !(value = homeZip()).isEmpty() ) |
540 | text += Qtopia::escapeString(value) + " "; | 544 | text += Qtopia::escapeString(value) + " "; |
541 | if ( !(value = homeCity()).isEmpty() ) { | 545 | if ( !(value = homeCity()).isEmpty() ) { |
542 | text += Qtopia::escapeString(value); | 546 | text += Qtopia::escapeString(value); |
543 | if ( !state.isEmpty() ) | 547 | if ( !state.isEmpty() ) |
544 | text += ", " + Qtopia::escapeString(state); | 548 | text += ", " + Qtopia::escapeString(state); |
545 | text += "<br>"; | 549 | text += "<br>"; |
546 | } else if (!state.isEmpty()) | 550 | } else if (!state.isEmpty()) |
547 | text += Qtopia::escapeString(state) + "<br>"; | 551 | text += Qtopia::escapeString(state) + "<br>"; |
548 | if ( !(value = homeCountry()).isEmpty() ) | 552 | if ( !(value = homeCountry()).isEmpty() ) |
549 | text += Qtopia::escapeString(value) + "<br>"; | 553 | text += Qtopia::escapeString(value) + "<br>"; |
550 | 554 | ||
551 | // rest of Home data | 555 | // rest of Home data |
552 | str = homeWebpage(); | 556 | str = homeWebpage(); |
553 | if ( !str.isEmpty() ){ | 557 | if ( !str.isEmpty() ){ |
554 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" | 558 | text += "<b><img src=\"addressbook/webpagehome\">" + QObject::tr("Home Web Page: ") + "</b>" |
555 | + Qtopia::escapeString(str) + "<br>"; | 559 | + Qtopia::escapeString(str) + "<br>"; |
556 | marker = true; | 560 | marker = true; |
557 | } | 561 | } |
558 | str = homePhone(); | 562 | str = homePhone(); |
559 | if ( !str.isEmpty() ){ | 563 | if ( !str.isEmpty() ){ |
560 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" | 564 | text += "<b><img src=\"addressbook/phonehome\">" + QObject::tr("Home Phone: ") + "</b>" |
561 | + Qtopia::escapeString(str) + "<br>"; | 565 | + Qtopia::escapeString(str) + "<br>"; |
562 | marker = true; | 566 | marker = true; |
563 | } | 567 | } |
564 | str = homeFax(); | 568 | str = homeFax(); |
565 | if ( !str.isEmpty() ){ | 569 | if ( !str.isEmpty() ){ |
566 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" | 570 | text += "<b><img src=\"addressbook/faxhome\">" + QObject::tr("Home Fax: ") + "</b>" |
567 | + Qtopia::escapeString(str) + "<br>"; | 571 | + Qtopia::escapeString(str) + "<br>"; |
568 | marker = true; | 572 | marker = true; |
569 | } | 573 | } |
570 | str = homeMobile(); | 574 | str = homeMobile(); |
571 | if ( !str.isEmpty() ){ | 575 | if ( !str.isEmpty() ){ |
572 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" | 576 | text += "<b><img src=\"addressbook/mobilehome\">" + QObject::tr("Home Mobile: ") + "</b>" |
573 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
574 | marker = true; | 578 | marker = true; |
575 | } | 579 | } |
576 | 580 | ||
577 | if ( marker ) | 581 | if ( marker ) |
578 | text += "<br><hr><br>"; | 582 | text += "<br><hr><br>"; |
579 | // the others... | 583 | // the others... |
580 | str = emails(); | 584 | str = emails(); |
581 | if ( !str.isEmpty() && ( str != defEmail ) ) | 585 | if ( !str.isEmpty() && ( str != defEmail ) ) |
582 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" | 586 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" |
583 | + Qtopia::escapeString(str) + "<br>"; | 587 | + Qtopia::escapeString(str) + "<br>"; |
584 | str = profession(); | 588 | str = profession(); |
585 | if ( !str.isEmpty() ) | 589 | if ( !str.isEmpty() ) |
586 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 590 | text += "<b>" + QObject::tr("Profession: ") + "</b>" |
587 | + Qtopia::escapeString(str) + "<br>"; | 591 | + Qtopia::escapeString(str) + "<br>"; |
588 | str = assistant(); | 592 | str = assistant(); |
589 | if ( !str.isEmpty() ) | 593 | if ( !str.isEmpty() ) |
590 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 594 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" |
591 | + Qtopia::escapeString(str) + "<br>"; | 595 | + Qtopia::escapeString(str) + "<br>"; |
592 | str = manager(); | 596 | str = manager(); |
593 | if ( !str.isEmpty() ) | 597 | if ( !str.isEmpty() ) |
594 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 598 | text += "<b>" + QObject::tr("Manager: ") + "</b>" |
595 | + Qtopia::escapeString(str) + "<br>"; | 599 | + Qtopia::escapeString(str) + "<br>"; |
596 | str = gender(); | 600 | str = gender(); |
597 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 601 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
598 | if ( str.toInt() == 1 ) | 602 | if ( str.toInt() == 1 ) |
599 | str = QObject::tr( "Male" ); | 603 | str = QObject::tr( "Male" ); |
600 | else if ( str.toInt() == 2 ) | 604 | else if ( str.toInt() == 2 ) |
601 | str = QObject::tr( "Female" ); | 605 | str = QObject::tr( "Female" ); |
602 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 606 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
603 | } | 607 | } |
604 | str = spouse(); | 608 | str = spouse(); |
605 | if ( !str.isEmpty() ) | 609 | if ( !str.isEmpty() ) |
606 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 610 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
607 | + Qtopia::escapeString(str) + "<br>"; | 611 | + Qtopia::escapeString(str) + "<br>"; |
608 | if ( birthday().isValid() ){ | 612 | if ( birthday().isValid() ){ |
609 | str = TimeString::numberDateString( birthday() ); | 613 | str = TimeString::numberDateString( birthday() ); |
610 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 614 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
611 | + Qtopia::escapeString(str) + "<br>"; | 615 | + Qtopia::escapeString(str) + "<br>"; |
612 | } | 616 | } |
613 | if ( anniversary().isValid() ){ | 617 | if ( anniversary().isValid() ){ |
614 | str = TimeString::numberDateString( anniversary() ); | 618 | str = TimeString::numberDateString( anniversary() ); |
615 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 619 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
616 | + Qtopia::escapeString(str) + "<br>"; | 620 | + Qtopia::escapeString(str) + "<br>"; |
617 | } | 621 | } |
618 | str = children(); | 622 | str = children(); |
619 | if ( !str.isEmpty() ) | 623 | if ( !str.isEmpty() ) |
620 | text += "<b>" + QObject::tr("Children: ") + "</b>" | 624 | text += "<b>" + QObject::tr("Children: ") + "</b>" |
621 | + Qtopia::escapeString(str) + "<br>"; | 625 | + Qtopia::escapeString(str) + "<br>"; |
622 | 626 | ||
623 | str = nickname(); | 627 | str = nickname(); |
624 | if ( !str.isEmpty() ) | 628 | if ( !str.isEmpty() ) |
625 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 629 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" |
626 | + Qtopia::escapeString(str) + "<br>"; | 630 | + Qtopia::escapeString(str) + "<br>"; |
627 | 631 | ||
632 | // categories | ||
628 | if ( categoryNames("Contacts").count() ){ | 633 | if ( categoryNames("Contacts").count() ){ |
629 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 634 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
630 | text += categoryNames("Contacts").join(", "); | 635 | text += categoryNames("Contacts").join(", "); |
631 | text += "<br>"; | 636 | text += "<br>"; |
632 | } | 637 | } |
633 | 638 | ||
634 | // notes last | 639 | // notes last |
635 | if ( !(value = notes()).isEmpty() ) { | 640 | if ( !(value = notes()).isEmpty() ) { |
636 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; | 641 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; |
637 | QRegExp reg("\n"); | 642 | QRegExp reg("\n"); |
638 | 643 | ||
639 | //QString tmp = Qtopia::escapeString(value); | 644 | //QString tmp = Qtopia::escapeString(value); |
640 | QString tmp = QStyleSheet::convertFromPlainText(value); | 645 | QString tmp = QStyleSheet::convertFromPlainText(value); |
641 | //tmp.replace( reg, "<br>" ); | 646 | //tmp.replace( reg, "<br>" ); |
642 | text += "<br>" + tmp + "<br>"; | 647 | text += "<br>" + tmp + "<br>"; |
643 | } | 648 | } |
644 | return text; | 649 | return text; |
645 | } | 650 | } |
646 | 651 | ||
647 | /*! | 652 | /*! |
648 | \internal | 653 | \internal |
649 | */ | 654 | */ |
650 | void OContact::insert( int key, const QString &v ) | 655 | void OContact::insert( int key, const QString &v ) |
651 | { | 656 | { |
652 | QString value = v.stripWhiteSpace(); | 657 | QString value = v.stripWhiteSpace(); |
653 | if ( value.isEmpty() ) | 658 | if ( value.isEmpty() ) |
654 | mMap.remove( key ); | 659 | mMap.remove( key ); |
655 | else | 660 | else |
656 | mMap.insert( key, value ); | 661 | mMap.insert( key, value ); |
657 | } | 662 | } |
658 | 663 | ||
659 | /*! | 664 | /*! |
660 | \internal | 665 | \internal |
661 | */ | 666 | */ |
662 | void OContact::replace( int key, const QString & v ) | 667 | void OContact::replace( int key, const QString & v ) |
663 | { | 668 | { |
664 | QString value = v.stripWhiteSpace(); | 669 | QString value = v.stripWhiteSpace(); |
665 | if ( value.isEmpty() ) | 670 | if ( value.isEmpty() ) |
666 | mMap.remove( key ); | 671 | mMap.remove( key ); |
667 | else | 672 | else |
668 | mMap.replace( key, value ); | 673 | mMap.replace( key, value ); |
669 | } | 674 | } |
670 | 675 | ||
671 | /*! | 676 | /*! |
672 | \internal | 677 | \internal |
673 | */ | 678 | */ |
674 | QString OContact::find( int key ) const | 679 | QString OContact::find( int key ) const |
675 | { | 680 | { |
diff --git a/libopie/pim/oevent.cpp b/libopie/pim/oevent.cpp index 83b191f..e4f5d92 100644 --- a/libopie/pim/oevent.cpp +++ b/libopie/pim/oevent.cpp | |||
@@ -190,112 +190,144 @@ QDateTime OEvent::endDateTimeInZone()const { | |||
190 | } | 190 | } |
191 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 191 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
192 | changeOrModify(); | 192 | changeOrModify(); |
193 | data->end = dt; | 193 | data->end = dt; |
194 | } | 194 | } |
195 | bool OEvent::isMultipleDay()const { | 195 | bool OEvent::isMultipleDay()const { |
196 | return data->end.date().day() - data->start.date().day(); | 196 | return data->end.date().day() - data->start.date().day(); |
197 | } | 197 | } |
198 | bool OEvent::isAllDay()const { | 198 | bool OEvent::isAllDay()const { |
199 | return data->isAllDay; | 199 | return data->isAllDay; |
200 | } | 200 | } |
201 | void OEvent::setAllDay( bool allDay ) { | 201 | void OEvent::setAllDay( bool allDay ) { |
202 | changeOrModify(); | 202 | changeOrModify(); |
203 | data->isAllDay = allDay; | 203 | data->isAllDay = allDay; |
204 | if (allDay ) data->timezone = "UTC"; | 204 | if (allDay ) data->timezone = "UTC"; |
205 | } | 205 | } |
206 | void OEvent::setTimeZone( const QString& tz ) { | 206 | void OEvent::setTimeZone( const QString& tz ) { |
207 | changeOrModify(); | 207 | changeOrModify(); |
208 | data->timezone = tz; | 208 | data->timezone = tz; |
209 | } | 209 | } |
210 | QString OEvent::timeZone()const { | 210 | QString OEvent::timeZone()const { |
211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
212 | return data->timezone; | 212 | return data->timezone; |
213 | } | 213 | } |
214 | bool OEvent::match( const QRegExp& re )const { | 214 | bool OEvent::match( const QRegExp& re )const { |
215 | if ( re.match( data->description ) != -1 ){ | 215 | if ( re.match( data->description ) != -1 ){ |
216 | setLastHitField( Qtopia::DatebookDescription ); | 216 | setLastHitField( Qtopia::DatebookDescription ); |
217 | return true; | 217 | return true; |
218 | } | 218 | } |
219 | if ( re.match( data->note ) != -1 ){ | 219 | if ( re.match( data->note ) != -1 ){ |
220 | setLastHitField( Qtopia::Note ); | 220 | setLastHitField( Qtopia::Note ); |
221 | return true; | 221 | return true; |
222 | } | 222 | } |
223 | if ( re.match( data->location ) != -1 ){ | 223 | if ( re.match( data->location ) != -1 ){ |
224 | setLastHitField( Qtopia::Location ); | 224 | setLastHitField( Qtopia::Location ); |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | if ( re.match( data->start.toString() ) != -1 ){ | 227 | if ( re.match( data->start.toString() ) != -1 ){ |
228 | setLastHitField( Qtopia::StartDateTime ); | 228 | setLastHitField( Qtopia::StartDateTime ); |
229 | return true; | 229 | return true; |
230 | } | 230 | } |
231 | if ( re.match( data->end.toString() ) != -1 ){ | 231 | if ( re.match( data->end.toString() ) != -1 ){ |
232 | setLastHitField( Qtopia::EndDateTime ); | 232 | setLastHitField( Qtopia::EndDateTime ); |
233 | return true; | 233 | return true; |
234 | } | 234 | } |
235 | return false; | 235 | return false; |
236 | } | 236 | } |
237 | QString OEvent::toRichText()const { | 237 | QString OEvent::toRichText()const { |
238 | QString text; | 238 | QString text, value; |
239 | |||
240 | // description | ||
241 | text += "<b><h3><img src=\"datebook/DateBook\">"; | ||
239 | if ( !description().isEmpty() ) { | 242 | if ( !description().isEmpty() ) { |
240 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; | 243 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); |
241 | text += Qtopia::escapeString(description() ). | 244 | } |
242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 245 | text += "</h3></b><br><hr><br>"; |
246 | |||
247 | // location | ||
248 | if ( !(value = location()).isEmpty() ) { | ||
249 | text += "<b>" + QObject::tr( "Location:" ) + "</b> "; | ||
250 | text += Qtopia::escapeString(value) + "<br>"; | ||
251 | } | ||
252 | |||
253 | // all day event | ||
254 | if ( isAllDay() ) { | ||
255 | text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; | ||
243 | } | 256 | } |
244 | if ( startDateTime().isValid() ) { | 257 | // multiple day event |
245 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | 258 | else if ( isMultipleDay () ) { |
246 | text += Qtopia::escapeString(startDateTime().toString() ). | 259 | text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; |
247 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 260 | } |
261 | // start & end times | ||
262 | else { | ||
263 | // start time | ||
264 | if ( startDateTime().isValid() ) { | ||
265 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | ||
266 | text += Qtopia::escapeString(startDateTime().toString() ). | ||
267 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
268 | } | ||
269 | |||
270 | // end time | ||
271 | if ( endDateTime().isValid() ) { | ||
272 | text += "<b>" + QObject::tr( "End:") + "</b> "; | ||
273 | text += Qtopia::escapeString(endDateTime().toString() ). | ||
274 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
275 | } | ||
248 | } | 276 | } |
249 | if ( endDateTime().isValid() ) { | 277 | |
250 | text += "<b>" + QObject::tr( "End:") + "</b> "; | 278 | // categories |
251 | text += Qtopia::escapeString(endDateTime().toString() ). | 279 | if ( categoryNames("Calendar").count() ){ |
252 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 280 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
281 | text += categoryNames("Calendar").join(", "); | ||
282 | text += "<br>"; | ||
253 | } | 283 | } |
284 | |||
285 | //notes | ||
254 | if ( !note().isEmpty() ) { | 286 | if ( !note().isEmpty() ) { |
255 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 287 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; |
256 | text += note(); | 288 | text += note(); |
257 | // text += Qtopia::escapeString(note() ). | 289 | // text += Qtopia::escapeString(note() ). |
258 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 290 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
259 | } | 291 | } |
260 | return text; | 292 | return text; |
261 | } | 293 | } |
262 | QString OEvent::toShortText()const { | 294 | QString OEvent::toShortText()const { |
263 | QString text; | 295 | QString text; |
264 | text += QString::number( startDateTime().date().day() ); | 296 | text += QString::number( startDateTime().date().day() ); |
265 | text += "."; | 297 | text += "."; |
266 | text += QString::number( startDateTime().date().month() ); | 298 | text += QString::number( startDateTime().date().month() ); |
267 | text += "."; | 299 | text += "."; |
268 | text += QString::number( startDateTime().date().year() ); | 300 | text += QString::number( startDateTime().date().year() ); |
269 | text += " "; | 301 | text += " "; |
270 | text += QString::number( startDateTime().time().hour() ); | 302 | text += QString::number( startDateTime().time().hour() ); |
271 | text += ":"; | 303 | text += ":"; |
272 | text += QString::number( startDateTime().time().minute() ); | 304 | text += QString::number( startDateTime().time().minute() ); |
273 | text += " - "; | 305 | text += " - "; |
274 | text += description(); | 306 | text += description(); |
275 | return text; | 307 | return text; |
276 | } | 308 | } |
277 | QString OEvent::type()const { | 309 | QString OEvent::type()const { |
278 | return QString::fromLatin1("OEvent"); | 310 | return QString::fromLatin1("OEvent"); |
279 | } | 311 | } |
280 | QString OEvent::recordField( int /*id */ )const { | 312 | QString OEvent::recordField( int /*id */ )const { |
281 | return QString::null; | 313 | return QString::null; |
282 | } | 314 | } |
283 | int OEvent::rtti() { | 315 | int OEvent::rtti() { |
284 | return OPimResolver::DateBook; | 316 | return OPimResolver::DateBook; |
285 | } | 317 | } |
286 | bool OEvent::loadFromStream( QDataStream& ) { | 318 | bool OEvent::loadFromStream( QDataStream& ) { |
287 | return true; | 319 | return true; |
288 | } | 320 | } |
289 | bool OEvent::saveToStream( QDataStream& )const { | 321 | bool OEvent::saveToStream( QDataStream& )const { |
290 | return true; | 322 | return true; |
291 | } | 323 | } |
292 | void OEvent::changeOrModify() { | 324 | void OEvent::changeOrModify() { |
293 | if ( data->count != 1 ) { | 325 | if ( data->count != 1 ) { |
294 | data->deref(); | 326 | data->deref(); |
295 | Data* d2 = new Data; | 327 | Data* d2 = new Data; |
296 | d2->description = data->description; | 328 | d2->description = data->description; |
297 | d2->location = data->location; | 329 | d2->location = data->location; |
298 | 330 | ||
299 | if (data->manager ) | 331 | if (data->manager ) |
300 | d2->manager = new OPimNotifyManager( *data->manager ); | 332 | d2->manager = new OPimNotifyManager( *data->manager ); |
301 | 333 | ||
diff --git a/libopie/pim/otodo.cpp b/libopie/pim/otodo.cpp index e087a00..c84eeeb 100644 --- a/libopie/pim/otodo.cpp +++ b/libopie/pim/otodo.cpp | |||
@@ -228,117 +228,151 @@ void OTodo::setStartDate( const QDate& date ) { | |||
228 | void OTodo::setCompletedDate( const QDate& date ) { | 228 | void OTodo::setCompletedDate( const QDate& date ) { |
229 | changeOrModify(); | 229 | changeOrModify(); |
230 | data->completed = date; | 230 | data->completed = date; |
231 | } | 231 | } |
232 | void OTodo::setState( const OPimState& state ) { | 232 | void OTodo::setState( const OPimState& state ) { |
233 | changeOrModify(); | 233 | changeOrModify(); |
234 | if (data->state ) | 234 | if (data->state ) |
235 | (*data->state) = state; | 235 | (*data->state) = state; |
236 | else | 236 | else |
237 | data->state = new OPimState( state ); | 237 | data->state = new OPimState( state ); |
238 | } | 238 | } |
239 | void OTodo::setRecurrence( const ORecur& rec) { | 239 | void OTodo::setRecurrence( const ORecur& rec) { |
240 | changeOrModify(); | 240 | changeOrModify(); |
241 | if (data->recur ) | 241 | if (data->recur ) |
242 | (*data->recur) = rec; | 242 | (*data->recur) = rec; |
243 | else | 243 | else |
244 | data->recur = new ORecur( rec ); | 244 | data->recur = new ORecur( rec ); |
245 | } | 245 | } |
246 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 246 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { |
247 | changeOrModify(); | 247 | changeOrModify(); |
248 | 248 | ||
249 | if (data->maintainer ) | 249 | if (data->maintainer ) |
250 | (*data->maintainer) = pim; | 250 | (*data->maintainer) = pim; |
251 | else | 251 | else |
252 | data->maintainer = new OPimMaintainer( pim ); | 252 | data->maintainer = new OPimMaintainer( pim ); |
253 | } | 253 | } |
254 | bool OTodo::isOverdue( ) | 254 | bool OTodo::isOverdue( ) |
255 | { | 255 | { |
256 | if( data->hasDate && !data->isCompleted) | 256 | if( data->hasDate && !data->isCompleted) |
257 | return QDate::currentDate() > data->date; | 257 | return QDate::currentDate() > data->date; |
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | void OTodo::setProgress(ushort progress ) | 260 | void OTodo::setProgress(ushort progress ) |
261 | { | 261 | { |
262 | changeOrModify(); | 262 | changeOrModify(); |
263 | data->prog = progress; | 263 | data->prog = progress; |
264 | } | 264 | } |
265 | QString OTodo::toShortText() const { | 265 | QString OTodo::toShortText() const { |
266 | return summary(); | 266 | return summary(); |
267 | } | 267 | } |
268 | /*! | 268 | /*! |
269 | Returns a richt text string | 269 | Returns a richt text string |
270 | */ | 270 | */ |
271 | QString OTodo::toRichText() const | 271 | QString OTodo::toRichText() const |
272 | { | 272 | { |
273 | QString text; | 273 | QString text; |
274 | QStringList catlist; | 274 | QStringList catlist; |
275 | 275 | ||
276 | // Description of the todo | 276 | // summary |
277 | text += "<b><h3><img src=\"todo/TodoList\">"; | ||
277 | if ( !summary().isEmpty() ) { | 278 | if ( !summary().isEmpty() ) { |
278 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 279 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); |
279 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
280 | } | 280 | } |
281 | text += "</h3></b><br><hr><br>"; | ||
282 | |||
283 | // description | ||
281 | if( !description().isEmpty() ){ | 284 | if( !description().isEmpty() ){ |
282 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 285 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
283 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 286 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
284 | } | 287 | } |
285 | text += "<br><br><br>"; | ||
286 | 288 | ||
287 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 289 | // priority |
288 | + QString::number( priority() ) + " <br>"; | 290 | int priorityval = priority(); |
291 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + | ||
292 | QString::number( priorityval ) + "\">"; | ||
293 | // text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + | ||
294 | // QString::number( priority() ) + "\"><br>"; | ||
295 | switch ( priorityval ) | ||
296 | { | ||
297 | case 1 : text += QObject::tr( "Very high" ); | ||
298 | break; | ||
299 | case 2 : text += QObject::tr( "High" ); | ||
300 | break; | ||
301 | case 3 : text += QObject::tr( "Normal" ); | ||
302 | break; | ||
303 | case 4 : text += QObject::tr( "Low" ); | ||
304 | break; | ||
305 | case 5 : text += QObject::tr( "Very low" ); | ||
306 | break; | ||
307 | }; | ||
308 | text += "<br>"; | ||
309 | |||
310 | // progress | ||
289 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 311 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
290 | + QString::number( progress() ) + " %<br>"; | 312 | + QString::number( progress() ) + " %<br>"; |
313 | |||
314 | // due date | ||
291 | if (hasDueDate() ){ | 315 | if (hasDueDate() ){ |
292 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 316 | QDate dd = dueDate(); |
293 | text += dueDate().toString(); | 317 | int off = QDate::currentDate().daysTo( dd ); |
294 | text += "<br>"; | 318 | |
319 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | ||
320 | if ( off < 0 ) | ||
321 | text += "#FF0000"; | ||
322 | else if ( off == 0 ) | ||
323 | text += "#FFFF00"; | ||
324 | else if ( off > 0 ) | ||
325 | text += "#00FF00"; | ||
326 | |||
327 | text += "\">" + dd.toString() + "</font><br>"; | ||
295 | } | 328 | } |
296 | 329 | ||
330 | // categories | ||
297 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 331 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
298 | text += categoryNames( "Todo List" ).join(", "); | 332 | text += categoryNames( "Todo List" ).join(", "); |
299 | text += "<br>"; | 333 | text += "<br>"; |
300 | 334 | ||
301 | return text; | 335 | return text; |
302 | } | 336 | } |
303 | bool OTodo::hasNotifiers()const { | 337 | bool OTodo::hasNotifiers()const { |
304 | if (!data->notifiers) return false; | 338 | if (!data->notifiers) return false; |
305 | return !data->notifiers->isEmpty(); | 339 | return !data->notifiers->isEmpty(); |
306 | } | 340 | } |
307 | OPimNotifyManager& OTodo::notifiers() { | 341 | OPimNotifyManager& OTodo::notifiers() { |
308 | if (!data->notifiers ) | 342 | if (!data->notifiers ) |
309 | data->notifiers = new OPimNotifyManager; | 343 | data->notifiers = new OPimNotifyManager; |
310 | return (*data->notifiers); | 344 | return (*data->notifiers); |
311 | } | 345 | } |
312 | const OPimNotifyManager& OTodo::notifiers()const{ | 346 | const OPimNotifyManager& OTodo::notifiers()const{ |
313 | if (!data->notifiers ) | 347 | if (!data->notifiers ) |
314 | data->notifiers = new OPimNotifyManager; | 348 | data->notifiers = new OPimNotifyManager; |
315 | 349 | ||
316 | return (*data->notifiers); | 350 | return (*data->notifiers); |
317 | } | 351 | } |
318 | 352 | ||
319 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 353 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
320 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
321 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
322 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
323 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
324 | return priority() < toDoEvent.priority(); | 358 | return priority() < toDoEvent.priority(); |
325 | }else{ | 359 | }else{ |
326 | return dueDate() < toDoEvent.dueDate(); | 360 | return dueDate() < toDoEvent.dueDate(); |
327 | } | 361 | } |
328 | } | 362 | } |
329 | return false; | 363 | return false; |
330 | } | 364 | } |
331 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 365 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
332 | { | 366 | { |
333 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
334 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
335 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
336 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
337 | return priority() <= toDoEvent.priority(); | 371 | return priority() <= toDoEvent.priority(); |
338 | }else{ | 372 | }else{ |
339 | return dueDate() <= toDoEvent.dueDate(); | 373 | return dueDate() <= toDoEvent.dueDate(); |
340 | } | 374 | } |
341 | } | 375 | } |
342 | return true; | 376 | return true; |
343 | } | 377 | } |
344 | bool OTodo::operator>(const OTodo &toDoEvent )const | 378 | bool OTodo::operator>(const OTodo &toDoEvent )const |
diff --git a/libopie2/opiepim/ocontact.cpp b/libopie2/opiepim/ocontact.cpp index a7ca975..a2fb68c 100644 --- a/libopie2/opiepim/ocontact.cpp +++ b/libopie2/opiepim/ocontact.cpp | |||
@@ -395,281 +395,286 @@ OContact::~OContact() | |||
395 | Returns the groups for the contact. | 395 | Returns the groups for the contact. |
396 | */ | 396 | */ |
397 | 397 | ||
398 | /*! \fn QStringList OContact::groupList() const | 398 | /*! \fn QStringList OContact::groupList() const |
399 | \internal | 399 | \internal |
400 | */ | 400 | */ |
401 | 401 | ||
402 | /*! \fn QString OContact::field(int) const | 402 | /*! \fn QString OContact::field(int) const |
403 | \internal | 403 | \internal |
404 | */ | 404 | */ |
405 | 405 | ||
406 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) | 406 | /*! \fn void OContact::saveJournal( journal_action, const QString & = QString::null ) |
407 | \internal | 407 | \internal |
408 | */ | 408 | */ |
409 | 409 | ||
410 | /*! \fn void OContact::setUid( int id ) | 410 | /*! \fn void OContact::setUid( int id ) |
411 | \internal | 411 | \internal |
412 | Sets the uid for this record to \a id. | 412 | Sets the uid for this record to \a id. |
413 | */ | 413 | */ |
414 | 414 | ||
415 | /*! \enum OContact::journal_action | 415 | /*! \enum OContact::journal_action |
416 | \internal | 416 | \internal |
417 | */ | 417 | */ |
418 | 418 | ||
419 | /*! | 419 | /*! |
420 | \internal | 420 | \internal |
421 | */ | 421 | */ |
422 | QMap<int, QString> OContact::toMap() const | 422 | QMap<int, QString> OContact::toMap() const |
423 | { | 423 | { |
424 | QMap<int, QString> map = mMap; | 424 | QMap<int, QString> map = mMap; |
425 | QString cats = idsToString( categories() ); | 425 | QString cats = idsToString( categories() ); |
426 | if ( !cats.isEmpty() ) | 426 | if ( !cats.isEmpty() ) |
427 | map.insert( Qtopia::AddressCategory, cats ); | 427 | map.insert( Qtopia::AddressCategory, cats ); |
428 | return map; | 428 | return map; |
429 | } | 429 | } |
430 | 430 | ||
431 | /*! | 431 | /*! |
432 | Returns a rich text formatted QString representing the contents the contact. | 432 | Returns a rich text formatted QString representing the contents the contact. |
433 | */ | 433 | */ |
434 | QString OContact::toRichText() const | 434 | QString OContact::toRichText() const |
435 | { | 435 | { |
436 | QString text; | 436 | QString text; |
437 | QString value, comp, state; | 437 | QString value, comp, state; |
438 | QString str; | 438 | QString str; |
439 | bool marker = false; | 439 | bool marker = false; |
440 | 440 | ||
441 | // name, jobtitle and company | 441 | // name, jobtitle and company |
442 | if ( !(value = fullName()).isEmpty() ) | 442 | if ( !(value = fullName()).isEmpty() ) |
443 | text += "<b><h3>" + Qtopia::escapeString(value) + "</h3></b><br>"; | 443 | text += "<b><h3><img src=\"addressbook/AddressBook\">" + Qtopia::escapeString(value) + "</h3></b>"; |
444 | |||
444 | if ( !(value = jobTitle()).isEmpty() ) | 445 | if ( !(value = jobTitle()).isEmpty() ) |
445 | text += Qtopia::escapeString(value) + "<br>"; | 446 | text += Qtopia::escapeString(value) + "<br>"; |
446 | 447 | ||
447 | comp = company(); | 448 | comp = company(); |
448 | if ( !(value = department()).isEmpty() ) { | 449 | if ( !(value = department()).isEmpty() ) { |
449 | text += Qtopia::escapeString(value); | 450 | text += Qtopia::escapeString(value); |
450 | if ( comp ) | 451 | if ( comp ) |
451 | text += ", "; | 452 | text += ", "; |
452 | else | 453 | else |
453 | text += "<br>"; | 454 | text += "<br>"; |
454 | } | 455 | } |
455 | if ( !comp.isEmpty() ) | 456 | if ( !comp.isEmpty() ) |
456 | text += Qtopia::escapeString(comp) + "<br>"; | 457 | text += Qtopia::escapeString(comp) + "<br>"; |
457 | 458 | ||
459 | text += "<hr><br>"; | ||
460 | |||
461 | // defailt email | ||
458 | QString defEmail = defaultEmail(); | 462 | QString defEmail = defaultEmail(); |
459 | if ( !defEmail.isEmpty() ) | 463 | if ( !defEmail.isEmpty() ) |
460 | text += "<b>" + QObject::tr("Default Email: ") + "</b>" | 464 | text += "<b><img src=\"addressbook/email\">" + QObject::tr("Default Email: ") + "</b>" |
461 | + Qtopia::escapeString(defEmail) + "<br>"; | 465 | + Qtopia::escapeString(defEmail) + "<br>"; |
462 | 466 | ||
463 | text += "<hr>"; | 467 | text += "<br>"; |
464 | 468 | ||
465 | // business address | 469 | // business address |
466 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || | 470 | if ( !businessStreet().isEmpty() || !businessCity().isEmpty() || |
467 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { | 471 | !businessZip().isEmpty() || !businessCountry().isEmpty() ) { |
468 | text += "<br>"; | ||
469 | text += QObject::tr( "<b>Work Address:</b>" ); | 472 | text += QObject::tr( "<b>Work Address:</b>" ); |
470 | text += "<br>"; | 473 | text += "<br>"; |
471 | marker = true; | 474 | marker = true; |
472 | } | 475 | } |
473 | 476 | ||
474 | if ( !(value = businessStreet()).isEmpty() ) | 477 | if ( !(value = businessStreet()).isEmpty() ) |
475 | text += Qtopia::escapeString(value) + "<br>"; | 478 | text += Qtopia::escapeString(value) + "<br>"; |
476 | state = businessState(); | 479 | state = businessState(); |
477 | if ( !(value = businessZip()).isEmpty() ) | 480 | if ( !(value = businessZip()).isEmpty() ) |
478 | text += Qtopia::escapeString(value) + " "; | 481 | text += Qtopia::escapeString(value) + " "; |
479 | if ( !(value = businessCity()).isEmpty() ) { | 482 | if ( !(value = businessCity()).isEmpty() ) { |
480 | text += Qtopia::escapeString(value); | 483 | text += Qtopia::escapeString(value); |
481 | if ( state ) | 484 | if ( state ) |
482 | text += ", " + Qtopia::escapeString(state); | 485 | text += ", " + Qtopia::escapeString(state); |
483 | text += "<br>"; | 486 | text += "<br>"; |
484 | } else if ( !state.isEmpty() ) | 487 | } else if ( !state.isEmpty() ) |
485 | text += Qtopia::escapeString(state) + "<br>"; | 488 | text += Qtopia::escapeString(state) + "<br>"; |
486 | 489 | ||
487 | if ( !(value = businessCountry()).isEmpty() ) | 490 | if ( !(value = businessCountry()).isEmpty() ) |
488 | text += Qtopia::escapeString(value) + "<br>"; | 491 | text += Qtopia::escapeString(value) + "<br>"; |
489 | 492 | ||
490 | // rest of Business data | 493 | // rest of Business data |
491 | str = office(); | 494 | str = office(); |
492 | if ( !str.isEmpty() ){ | 495 | if ( !str.isEmpty() ){ |
493 | text += "<b>" + QObject::tr("Office: ") + "</b>" | 496 | text += "<b>" + QObject::tr("Office: ") + "</b>" |
494 | + Qtopia::escapeString(str) + "<br>"; | 497 | + Qtopia::escapeString(str) + "<br>"; |
495 | marker = true; | 498 | marker = true; |
496 | } | 499 | } |
497 | str = businessWebpage(); | 500 | str = businessWebpage(); |
498 | if ( !str.isEmpty() ){ | 501 | if ( !str.isEmpty() ){ |
499 | text += "<b>" + QObject::tr("Business Web Page: ") + "</b>" | 502 | text += "<b><img src=\"addressbook/webpagework\">" + QObject::tr("Business Web Page: ") + "</b>" |
500 | + Qtopia::escapeString(str) + "<br>"; | 503 | + Qtopia::escapeString(str) + "<br>"; |
501 | marker = true; | 504 | marker = true; |
502 | } | 505 | } |
503 | str = businessPhone(); | 506 | str = businessPhone(); |
504 | if ( !str.isEmpty() ){ | 507 | if ( !str.isEmpty() ){ |
505 | text += "<b>" + QObject::tr("Business Phone: ") + "</b>" | 508 | text += "<b><img src=\"addressbook/phonework\">" + QObject::tr("Business Phone: ") + "</b>" |
506 | + Qtopia::escapeString(str) + "<br>"; | 509 | + Qtopia::escapeString(str) + "<br>"; |
507 | marker = true; | 510 | marker = true; |
508 | } | 511 | } |
509 | str = businessFax(); | 512 | str = businessFax(); |
510 | if ( !str.isEmpty() ){ | 513 | if ( !str.isEmpty() ){ |
511 | text += "<b>" + QObject::tr("Business Fax: ") + "</b>" | 514 | text += "<b><img src=\"addressbook/faxwork\">" + QObject::tr("Business Fax: ") + "</b>" |
512 | + Qtopia::escapeString(str) + "<br>"; | 515 | + Qtopia::escapeString(str) + "<br>"; |
513 | marker = true; | 516 | marker = true; |
514 | } | 517 | } |
515 | str = businessMobile(); | 518 | str = businessMobile(); |
516 | if ( !str.isEmpty() ){ | 519 | if ( !str.isEmpty() ){ |
517 | text += "<b>" + QObject::tr("Business Mobile: ") + "</b>" | 520 | text += "<b><img src=\"addressbook/mobilework\">" + QObject::tr("Business Mobile: ") + "</b>" |
518 | + Qtopia::escapeString(str) + "<br>"; | 521 | + Qtopia::escapeString(str) + "<br>"; |
519 | marker = true; | 522 | marker = true; |
520 | } | 523 | } |
521 | str = businessPager(); | 524 | str = businessPager(); |
522 | if ( !str.isEmpty() ){ | 525 | if ( !str.isEmpty() ){ |
523 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" | 526 | text += "<b>" + QObject::tr("Business Pager: ") + "</b>" |
524 | + Qtopia::escapeString(str) + "<br>"; | 527 | + Qtopia::escapeString(str) + "<br>"; |
525 | marker = true; | 528 | marker = true; |
526 | } | 529 | } |
527 | 530 | ||
531 | text += "<br>"; | ||
532 | |||
528 | // home address | 533 | // home address |
529 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || | 534 | if ( !homeStreet().isEmpty() || !homeCity().isEmpty() || |
530 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { | 535 | !homeZip().isEmpty() || !homeCountry().isEmpty() ) { |
531 | text += "<br>"; | ||
532 | text += QObject::tr( "<b>Home Address:</b>" ); | 536 | text += QObject::tr( "<b>Home Address:</b>" ); |
533 | text += "<br>"; | 537 | text += "<br>"; |
534 | } | 538 | } |
535 | 539 | ||
536 | if ( !(value = homeStreet()).isEmpty() ) | 540 | if ( !(value = homeStreet()).isEmpty() ) |
537 | text += Qtopia::escapeString(value) + "<br>"; | 541 | text += Qtopia::escapeString(value) + "<br>"; |
538 | state = homeState(); | 542 | state = homeState(); |
539 | if ( !(value = homeZip()).isEmpty() ) | 543 | if ( !(value = homeZip()).isEmpty() ) |
540 | text += Qtopia::escapeString(value) + " "; | 544 | text += Qtopia::escapeString(value) + " "; |
541 | if ( !(value = homeCity()).isEmpty() ) { | 545 | if ( !(value = homeCity()).isEmpty() ) { |
542 | text += Qtopia::escapeString(value); | 546 | text += Qtopia::escapeString(value); |
543 | if ( !state.isEmpty() ) | 547 | if ( !state.isEmpty() ) |
544 | text += ", " + Qtopia::escapeString(state); | 548 | text += ", " + Qtopia::escapeString(state); |
545 | text += "<br>"; | 549 | text += "<br>"; |
546 | } else if (!state.isEmpty()) | 550 | } else if (!state.isEmpty()) |
547 | text += Qtopia::escapeString(state) + "<br>"; | 551 | text += Qtopia::escapeString(state) + "<br>"; |
548 | if ( !(value = homeCountry()).isEmpty() ) | 552 | if ( !(value = homeCountry()).isEmpty() ) |
549 | text += Qtopia::escapeString(value) + "<br>"; | 553 | text += Qtopia::escapeString(value) + "<br>"; |
550 | 554 | ||
551 | // rest of Home data | 555 | // rest of Home data |
552 | str = homeWebpage(); | 556 | str = homeWebpage(); |
553 | if ( !str.isEmpty() ){ | 557 | if ( !str.isEmpty() ){ |
554 | text += "<b>" + QObject::tr("Home Web Page: ") + "</b>" | 558 | text += "<b><img src=\"addressbook/webpagehome\">" + QObject::tr("Home Web Page: ") + "</b>" |
555 | + Qtopia::escapeString(str) + "<br>"; | 559 | + Qtopia::escapeString(str) + "<br>"; |
556 | marker = true; | 560 | marker = true; |
557 | } | 561 | } |
558 | str = homePhone(); | 562 | str = homePhone(); |
559 | if ( !str.isEmpty() ){ | 563 | if ( !str.isEmpty() ){ |
560 | text += "<b>" + QObject::tr("Home Phone: ") + "</b>" | 564 | text += "<b><img src=\"addressbook/phonehome\">" + QObject::tr("Home Phone: ") + "</b>" |
561 | + Qtopia::escapeString(str) + "<br>"; | 565 | + Qtopia::escapeString(str) + "<br>"; |
562 | marker = true; | 566 | marker = true; |
563 | } | 567 | } |
564 | str = homeFax(); | 568 | str = homeFax(); |
565 | if ( !str.isEmpty() ){ | 569 | if ( !str.isEmpty() ){ |
566 | text += "<b>" + QObject::tr("Home Fax: ") + "</b>" | 570 | text += "<b><img src=\"addressbook/faxhome\">" + QObject::tr("Home Fax: ") + "</b>" |
567 | + Qtopia::escapeString(str) + "<br>"; | 571 | + Qtopia::escapeString(str) + "<br>"; |
568 | marker = true; | 572 | marker = true; |
569 | } | 573 | } |
570 | str = homeMobile(); | 574 | str = homeMobile(); |
571 | if ( !str.isEmpty() ){ | 575 | if ( !str.isEmpty() ){ |
572 | text += "<b>" + QObject::tr("Home Mobile: ") + "</b>" | 576 | text += "<b><img src=\"addressbook/mobilehome\">" + QObject::tr("Home Mobile: ") + "</b>" |
573 | + Qtopia::escapeString(str) + "<br>"; | 577 | + Qtopia::escapeString(str) + "<br>"; |
574 | marker = true; | 578 | marker = true; |
575 | } | 579 | } |
576 | 580 | ||
577 | if ( marker ) | 581 | if ( marker ) |
578 | text += "<br><hr><br>"; | 582 | text += "<br><hr><br>"; |
579 | // the others... | 583 | // the others... |
580 | str = emails(); | 584 | str = emails(); |
581 | if ( !str.isEmpty() && ( str != defEmail ) ) | 585 | if ( !str.isEmpty() && ( str != defEmail ) ) |
582 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" | 586 | text += "<b>" + QObject::tr("All Emails: ") + "</b>" |
583 | + Qtopia::escapeString(str) + "<br>"; | 587 | + Qtopia::escapeString(str) + "<br>"; |
584 | str = profession(); | 588 | str = profession(); |
585 | if ( !str.isEmpty() ) | 589 | if ( !str.isEmpty() ) |
586 | text += "<b>" + QObject::tr("Profession: ") + "</b>" | 590 | text += "<b>" + QObject::tr("Profession: ") + "</b>" |
587 | + Qtopia::escapeString(str) + "<br>"; | 591 | + Qtopia::escapeString(str) + "<br>"; |
588 | str = assistant(); | 592 | str = assistant(); |
589 | if ( !str.isEmpty() ) | 593 | if ( !str.isEmpty() ) |
590 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" | 594 | text += "<b>" + QObject::tr("Assistant: ") + "</b>" |
591 | + Qtopia::escapeString(str) + "<br>"; | 595 | + Qtopia::escapeString(str) + "<br>"; |
592 | str = manager(); | 596 | str = manager(); |
593 | if ( !str.isEmpty() ) | 597 | if ( !str.isEmpty() ) |
594 | text += "<b>" + QObject::tr("Manager: ") + "</b>" | 598 | text += "<b>" + QObject::tr("Manager: ") + "</b>" |
595 | + Qtopia::escapeString(str) + "<br>"; | 599 | + Qtopia::escapeString(str) + "<br>"; |
596 | str = gender(); | 600 | str = gender(); |
597 | if ( !str.isEmpty() && str.toInt() != 0 ) { | 601 | if ( !str.isEmpty() && str.toInt() != 0 ) { |
598 | if ( str.toInt() == 1 ) | 602 | if ( str.toInt() == 1 ) |
599 | str = QObject::tr( "Male" ); | 603 | str = QObject::tr( "Male" ); |
600 | else if ( str.toInt() == 2 ) | 604 | else if ( str.toInt() == 2 ) |
601 | str = QObject::tr( "Female" ); | 605 | str = QObject::tr( "Female" ); |
602 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; | 606 | text += "<b>" + QObject::tr("Gender: ") + "</b>" + str + "<br>"; |
603 | } | 607 | } |
604 | str = spouse(); | 608 | str = spouse(); |
605 | if ( !str.isEmpty() ) | 609 | if ( !str.isEmpty() ) |
606 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" | 610 | text += "<b>" + QObject::tr("Spouse: ") + "</b>" |
607 | + Qtopia::escapeString(str) + "<br>"; | 611 | + Qtopia::escapeString(str) + "<br>"; |
608 | if ( birthday().isValid() ){ | 612 | if ( birthday().isValid() ){ |
609 | str = TimeString::numberDateString( birthday() ); | 613 | str = TimeString::numberDateString( birthday() ); |
610 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" | 614 | text += "<b>" + QObject::tr("Birthday: ") + "</b>" |
611 | + Qtopia::escapeString(str) + "<br>"; | 615 | + Qtopia::escapeString(str) + "<br>"; |
612 | } | 616 | } |
613 | if ( anniversary().isValid() ){ | 617 | if ( anniversary().isValid() ){ |
614 | str = TimeString::numberDateString( anniversary() ); | 618 | str = TimeString::numberDateString( anniversary() ); |
615 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" | 619 | text += "<b>" + QObject::tr("Anniversary: ") + "</b>" |
616 | + Qtopia::escapeString(str) + "<br>"; | 620 | + Qtopia::escapeString(str) + "<br>"; |
617 | } | 621 | } |
618 | str = children(); | 622 | str = children(); |
619 | if ( !str.isEmpty() ) | 623 | if ( !str.isEmpty() ) |
620 | text += "<b>" + QObject::tr("Children: ") + "</b>" | 624 | text += "<b>" + QObject::tr("Children: ") + "</b>" |
621 | + Qtopia::escapeString(str) + "<br>"; | 625 | + Qtopia::escapeString(str) + "<br>"; |
622 | 626 | ||
623 | str = nickname(); | 627 | str = nickname(); |
624 | if ( !str.isEmpty() ) | 628 | if ( !str.isEmpty() ) |
625 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" | 629 | text += "<b>" + QObject::tr("Nickname: ") + "</b>" |
626 | + Qtopia::escapeString(str) + "<br>"; | 630 | + Qtopia::escapeString(str) + "<br>"; |
627 | 631 | ||
632 | // categories | ||
628 | if ( categoryNames("Contacts").count() ){ | 633 | if ( categoryNames("Contacts").count() ){ |
629 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 634 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
630 | text += categoryNames("Contacts").join(", "); | 635 | text += categoryNames("Contacts").join(", "); |
631 | text += "<br>"; | 636 | text += "<br>"; |
632 | } | 637 | } |
633 | 638 | ||
634 | // notes last | 639 | // notes last |
635 | if ( !(value = notes()).isEmpty() ) { | 640 | if ( !(value = notes()).isEmpty() ) { |
636 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; | 641 | text += "<br><hr><b>" + QObject::tr( "Notes:") + "</b> "; |
637 | QRegExp reg("\n"); | 642 | QRegExp reg("\n"); |
638 | 643 | ||
639 | //QString tmp = Qtopia::escapeString(value); | 644 | //QString tmp = Qtopia::escapeString(value); |
640 | QString tmp = QStyleSheet::convertFromPlainText(value); | 645 | QString tmp = QStyleSheet::convertFromPlainText(value); |
641 | //tmp.replace( reg, "<br>" ); | 646 | //tmp.replace( reg, "<br>" ); |
642 | text += "<br>" + tmp + "<br>"; | 647 | text += "<br>" + tmp + "<br>"; |
643 | } | 648 | } |
644 | return text; | 649 | return text; |
645 | } | 650 | } |
646 | 651 | ||
647 | /*! | 652 | /*! |
648 | \internal | 653 | \internal |
649 | */ | 654 | */ |
650 | void OContact::insert( int key, const QString &v ) | 655 | void OContact::insert( int key, const QString &v ) |
651 | { | 656 | { |
652 | QString value = v.stripWhiteSpace(); | 657 | QString value = v.stripWhiteSpace(); |
653 | if ( value.isEmpty() ) | 658 | if ( value.isEmpty() ) |
654 | mMap.remove( key ); | 659 | mMap.remove( key ); |
655 | else | 660 | else |
656 | mMap.insert( key, value ); | 661 | mMap.insert( key, value ); |
657 | } | 662 | } |
658 | 663 | ||
659 | /*! | 664 | /*! |
660 | \internal | 665 | \internal |
661 | */ | 666 | */ |
662 | void OContact::replace( int key, const QString & v ) | 667 | void OContact::replace( int key, const QString & v ) |
663 | { | 668 | { |
664 | QString value = v.stripWhiteSpace(); | 669 | QString value = v.stripWhiteSpace(); |
665 | if ( value.isEmpty() ) | 670 | if ( value.isEmpty() ) |
666 | mMap.remove( key ); | 671 | mMap.remove( key ); |
667 | else | 672 | else |
668 | mMap.replace( key, value ); | 673 | mMap.replace( key, value ); |
669 | } | 674 | } |
670 | 675 | ||
671 | /*! | 676 | /*! |
672 | \internal | 677 | \internal |
673 | */ | 678 | */ |
674 | QString OContact::find( int key ) const | 679 | QString OContact::find( int key ) const |
675 | { | 680 | { |
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index 83b191f..e4f5d92 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -190,112 +190,144 @@ QDateTime OEvent::endDateTimeInZone()const { | |||
190 | } | 190 | } |
191 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 191 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
192 | changeOrModify(); | 192 | changeOrModify(); |
193 | data->end = dt; | 193 | data->end = dt; |
194 | } | 194 | } |
195 | bool OEvent::isMultipleDay()const { | 195 | bool OEvent::isMultipleDay()const { |
196 | return data->end.date().day() - data->start.date().day(); | 196 | return data->end.date().day() - data->start.date().day(); |
197 | } | 197 | } |
198 | bool OEvent::isAllDay()const { | 198 | bool OEvent::isAllDay()const { |
199 | return data->isAllDay; | 199 | return data->isAllDay; |
200 | } | 200 | } |
201 | void OEvent::setAllDay( bool allDay ) { | 201 | void OEvent::setAllDay( bool allDay ) { |
202 | changeOrModify(); | 202 | changeOrModify(); |
203 | data->isAllDay = allDay; | 203 | data->isAllDay = allDay; |
204 | if (allDay ) data->timezone = "UTC"; | 204 | if (allDay ) data->timezone = "UTC"; |
205 | } | 205 | } |
206 | void OEvent::setTimeZone( const QString& tz ) { | 206 | void OEvent::setTimeZone( const QString& tz ) { |
207 | changeOrModify(); | 207 | changeOrModify(); |
208 | data->timezone = tz; | 208 | data->timezone = tz; |
209 | } | 209 | } |
210 | QString OEvent::timeZone()const { | 210 | QString OEvent::timeZone()const { |
211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
212 | return data->timezone; | 212 | return data->timezone; |
213 | } | 213 | } |
214 | bool OEvent::match( const QRegExp& re )const { | 214 | bool OEvent::match( const QRegExp& re )const { |
215 | if ( re.match( data->description ) != -1 ){ | 215 | if ( re.match( data->description ) != -1 ){ |
216 | setLastHitField( Qtopia::DatebookDescription ); | 216 | setLastHitField( Qtopia::DatebookDescription ); |
217 | return true; | 217 | return true; |
218 | } | 218 | } |
219 | if ( re.match( data->note ) != -1 ){ | 219 | if ( re.match( data->note ) != -1 ){ |
220 | setLastHitField( Qtopia::Note ); | 220 | setLastHitField( Qtopia::Note ); |
221 | return true; | 221 | return true; |
222 | } | 222 | } |
223 | if ( re.match( data->location ) != -1 ){ | 223 | if ( re.match( data->location ) != -1 ){ |
224 | setLastHitField( Qtopia::Location ); | 224 | setLastHitField( Qtopia::Location ); |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | if ( re.match( data->start.toString() ) != -1 ){ | 227 | if ( re.match( data->start.toString() ) != -1 ){ |
228 | setLastHitField( Qtopia::StartDateTime ); | 228 | setLastHitField( Qtopia::StartDateTime ); |
229 | return true; | 229 | return true; |
230 | } | 230 | } |
231 | if ( re.match( data->end.toString() ) != -1 ){ | 231 | if ( re.match( data->end.toString() ) != -1 ){ |
232 | setLastHitField( Qtopia::EndDateTime ); | 232 | setLastHitField( Qtopia::EndDateTime ); |
233 | return true; | 233 | return true; |
234 | } | 234 | } |
235 | return false; | 235 | return false; |
236 | } | 236 | } |
237 | QString OEvent::toRichText()const { | 237 | QString OEvent::toRichText()const { |
238 | QString text; | 238 | QString text, value; |
239 | |||
240 | // description | ||
241 | text += "<b><h3><img src=\"datebook/DateBook\">"; | ||
239 | if ( !description().isEmpty() ) { | 242 | if ( !description().isEmpty() ) { |
240 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; | 243 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "" ); |
241 | text += Qtopia::escapeString(description() ). | 244 | } |
242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 245 | text += "</h3></b><br><hr><br>"; |
246 | |||
247 | // location | ||
248 | if ( !(value = location()).isEmpty() ) { | ||
249 | text += "<b>" + QObject::tr( "Location:" ) + "</b> "; | ||
250 | text += Qtopia::escapeString(value) + "<br>"; | ||
251 | } | ||
252 | |||
253 | // all day event | ||
254 | if ( isAllDay() ) { | ||
255 | text += "<b><i>" + QObject::tr( "This is an all day event" ) + "</i></b><br>"; | ||
243 | } | 256 | } |
244 | if ( startDateTime().isValid() ) { | 257 | // multiple day event |
245 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | 258 | else if ( isMultipleDay () ) { |
246 | text += Qtopia::escapeString(startDateTime().toString() ). | 259 | text += "<b><i>" + QObject::tr( "This is a multiple day event" ) + "</i></b><br>"; |
247 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 260 | } |
261 | // start & end times | ||
262 | else { | ||
263 | // start time | ||
264 | if ( startDateTime().isValid() ) { | ||
265 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | ||
266 | text += Qtopia::escapeString(startDateTime().toString() ). | ||
267 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
268 | } | ||
269 | |||
270 | // end time | ||
271 | if ( endDateTime().isValid() ) { | ||
272 | text += "<b>" + QObject::tr( "End:") + "</b> "; | ||
273 | text += Qtopia::escapeString(endDateTime().toString() ). | ||
274 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
275 | } | ||
248 | } | 276 | } |
249 | if ( endDateTime().isValid() ) { | 277 | |
250 | text += "<b>" + QObject::tr( "End:") + "</b> "; | 278 | // categories |
251 | text += Qtopia::escapeString(endDateTime().toString() ). | 279 | if ( categoryNames("Calendar").count() ){ |
252 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 280 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
281 | text += categoryNames("Calendar").join(", "); | ||
282 | text += "<br>"; | ||
253 | } | 283 | } |
284 | |||
285 | //notes | ||
254 | if ( !note().isEmpty() ) { | 286 | if ( !note().isEmpty() ) { |
255 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 287 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; |
256 | text += note(); | 288 | text += note(); |
257 | // text += Qtopia::escapeString(note() ). | 289 | // text += Qtopia::escapeString(note() ). |
258 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 290 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
259 | } | 291 | } |
260 | return text; | 292 | return text; |
261 | } | 293 | } |
262 | QString OEvent::toShortText()const { | 294 | QString OEvent::toShortText()const { |
263 | QString text; | 295 | QString text; |
264 | text += QString::number( startDateTime().date().day() ); | 296 | text += QString::number( startDateTime().date().day() ); |
265 | text += "."; | 297 | text += "."; |
266 | text += QString::number( startDateTime().date().month() ); | 298 | text += QString::number( startDateTime().date().month() ); |
267 | text += "."; | 299 | text += "."; |
268 | text += QString::number( startDateTime().date().year() ); | 300 | text += QString::number( startDateTime().date().year() ); |
269 | text += " "; | 301 | text += " "; |
270 | text += QString::number( startDateTime().time().hour() ); | 302 | text += QString::number( startDateTime().time().hour() ); |
271 | text += ":"; | 303 | text += ":"; |
272 | text += QString::number( startDateTime().time().minute() ); | 304 | text += QString::number( startDateTime().time().minute() ); |
273 | text += " - "; | 305 | text += " - "; |
274 | text += description(); | 306 | text += description(); |
275 | return text; | 307 | return text; |
276 | } | 308 | } |
277 | QString OEvent::type()const { | 309 | QString OEvent::type()const { |
278 | return QString::fromLatin1("OEvent"); | 310 | return QString::fromLatin1("OEvent"); |
279 | } | 311 | } |
280 | QString OEvent::recordField( int /*id */ )const { | 312 | QString OEvent::recordField( int /*id */ )const { |
281 | return QString::null; | 313 | return QString::null; |
282 | } | 314 | } |
283 | int OEvent::rtti() { | 315 | int OEvent::rtti() { |
284 | return OPimResolver::DateBook; | 316 | return OPimResolver::DateBook; |
285 | } | 317 | } |
286 | bool OEvent::loadFromStream( QDataStream& ) { | 318 | bool OEvent::loadFromStream( QDataStream& ) { |
287 | return true; | 319 | return true; |
288 | } | 320 | } |
289 | bool OEvent::saveToStream( QDataStream& )const { | 321 | bool OEvent::saveToStream( QDataStream& )const { |
290 | return true; | 322 | return true; |
291 | } | 323 | } |
292 | void OEvent::changeOrModify() { | 324 | void OEvent::changeOrModify() { |
293 | if ( data->count != 1 ) { | 325 | if ( data->count != 1 ) { |
294 | data->deref(); | 326 | data->deref(); |
295 | Data* d2 = new Data; | 327 | Data* d2 = new Data; |
296 | d2->description = data->description; | 328 | d2->description = data->description; |
297 | d2->location = data->location; | 329 | d2->location = data->location; |
298 | 330 | ||
299 | if (data->manager ) | 331 | if (data->manager ) |
300 | d2->manager = new OPimNotifyManager( *data->manager ); | 332 | d2->manager = new OPimNotifyManager( *data->manager ); |
301 | 333 | ||
diff --git a/libopie2/opiepim/otodo.cpp b/libopie2/opiepim/otodo.cpp index e087a00..c84eeeb 100644 --- a/libopie2/opiepim/otodo.cpp +++ b/libopie2/opiepim/otodo.cpp | |||
@@ -228,117 +228,151 @@ void OTodo::setStartDate( const QDate& date ) { | |||
228 | void OTodo::setCompletedDate( const QDate& date ) { | 228 | void OTodo::setCompletedDate( const QDate& date ) { |
229 | changeOrModify(); | 229 | changeOrModify(); |
230 | data->completed = date; | 230 | data->completed = date; |
231 | } | 231 | } |
232 | void OTodo::setState( const OPimState& state ) { | 232 | void OTodo::setState( const OPimState& state ) { |
233 | changeOrModify(); | 233 | changeOrModify(); |
234 | if (data->state ) | 234 | if (data->state ) |
235 | (*data->state) = state; | 235 | (*data->state) = state; |
236 | else | 236 | else |
237 | data->state = new OPimState( state ); | 237 | data->state = new OPimState( state ); |
238 | } | 238 | } |
239 | void OTodo::setRecurrence( const ORecur& rec) { | 239 | void OTodo::setRecurrence( const ORecur& rec) { |
240 | changeOrModify(); | 240 | changeOrModify(); |
241 | if (data->recur ) | 241 | if (data->recur ) |
242 | (*data->recur) = rec; | 242 | (*data->recur) = rec; |
243 | else | 243 | else |
244 | data->recur = new ORecur( rec ); | 244 | data->recur = new ORecur( rec ); |
245 | } | 245 | } |
246 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { | 246 | void OTodo::setMaintainer( const OPimMaintainer& pim ) { |
247 | changeOrModify(); | 247 | changeOrModify(); |
248 | 248 | ||
249 | if (data->maintainer ) | 249 | if (data->maintainer ) |
250 | (*data->maintainer) = pim; | 250 | (*data->maintainer) = pim; |
251 | else | 251 | else |
252 | data->maintainer = new OPimMaintainer( pim ); | 252 | data->maintainer = new OPimMaintainer( pim ); |
253 | } | 253 | } |
254 | bool OTodo::isOverdue( ) | 254 | bool OTodo::isOverdue( ) |
255 | { | 255 | { |
256 | if( data->hasDate && !data->isCompleted) | 256 | if( data->hasDate && !data->isCompleted) |
257 | return QDate::currentDate() > data->date; | 257 | return QDate::currentDate() > data->date; |
258 | return false; | 258 | return false; |
259 | } | 259 | } |
260 | void OTodo::setProgress(ushort progress ) | 260 | void OTodo::setProgress(ushort progress ) |
261 | { | 261 | { |
262 | changeOrModify(); | 262 | changeOrModify(); |
263 | data->prog = progress; | 263 | data->prog = progress; |
264 | } | 264 | } |
265 | QString OTodo::toShortText() const { | 265 | QString OTodo::toShortText() const { |
266 | return summary(); | 266 | return summary(); |
267 | } | 267 | } |
268 | /*! | 268 | /*! |
269 | Returns a richt text string | 269 | Returns a richt text string |
270 | */ | 270 | */ |
271 | QString OTodo::toRichText() const | 271 | QString OTodo::toRichText() const |
272 | { | 272 | { |
273 | QString text; | 273 | QString text; |
274 | QStringList catlist; | 274 | QStringList catlist; |
275 | 275 | ||
276 | // Description of the todo | 276 | // summary |
277 | text += "<b><h3><img src=\"todo/TodoList\">"; | ||
277 | if ( !summary().isEmpty() ) { | 278 | if ( !summary().isEmpty() ) { |
278 | text += "<b>" + QObject::tr( "Summary:") + "</b><br>"; | 279 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "" ); |
279 | text += Qtopia::escapeString(summary() ).replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | ||
280 | } | 280 | } |
281 | text += "</h3></b><br><hr><br>"; | ||
282 | |||
283 | // description | ||
281 | if( !description().isEmpty() ){ | 284 | if( !description().isEmpty() ){ |
282 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; | 285 | text += "<b>" + QObject::tr( "Description:" ) + "</b><br>"; |
283 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; | 286 | text += Qtopia::escapeString(description() ).replace(QRegExp( "[\n]"), "<br>" ) ; |
284 | } | 287 | } |
285 | text += "<br><br><br>"; | ||
286 | 288 | ||
287 | text += "<b>" + QObject::tr( "Priority:") +" </b>" | 289 | // priority |
288 | + QString::number( priority() ) + " <br>"; | 290 | int priorityval = priority(); |
291 | text += "<b>" + QObject::tr( "Priority:") +" </b><img src=\"todo/priority" + | ||
292 | QString::number( priorityval ) + "\">"; | ||
293 | // text += "<b>" + QObject::tr( "Priority:") +"</b><img src=\"todo/priority" + | ||
294 | // QString::number( priority() ) + "\"><br>"; | ||
295 | switch ( priorityval ) | ||
296 | { | ||
297 | case 1 : text += QObject::tr( "Very high" ); | ||
298 | break; | ||
299 | case 2 : text += QObject::tr( "High" ); | ||
300 | break; | ||
301 | case 3 : text += QObject::tr( "Normal" ); | ||
302 | break; | ||
303 | case 4 : text += QObject::tr( "Low" ); | ||
304 | break; | ||
305 | case 5 : text += QObject::tr( "Very low" ); | ||
306 | break; | ||
307 | }; | ||
308 | text += "<br>"; | ||
309 | |||
310 | // progress | ||
289 | text += "<b>" + QObject::tr( "Progress:") + " </b>" | 311 | text += "<b>" + QObject::tr( "Progress:") + " </b>" |
290 | + QString::number( progress() ) + " %<br>"; | 312 | + QString::number( progress() ) + " %<br>"; |
313 | |||
314 | // due date | ||
291 | if (hasDueDate() ){ | 315 | if (hasDueDate() ){ |
292 | text += "<b>" + QObject::tr( "Deadline:") + " </b>"; | 316 | QDate dd = dueDate(); |
293 | text += dueDate().toString(); | 317 | int off = QDate::currentDate().daysTo( dd ); |
294 | text += "<br>"; | 318 | |
319 | text += "<b>" + QObject::tr( "Deadline:" ) + " </b><font color=\""; | ||
320 | if ( off < 0 ) | ||
321 | text += "#FF0000"; | ||
322 | else if ( off == 0 ) | ||
323 | text += "#FFFF00"; | ||
324 | else if ( off > 0 ) | ||
325 | text += "#00FF00"; | ||
326 | |||
327 | text += "\">" + dd.toString() + "</font><br>"; | ||
295 | } | 328 | } |
296 | 329 | ||
330 | // categories | ||
297 | text += "<b>" + QObject::tr( "Category:") + "</b> "; | 331 | text += "<b>" + QObject::tr( "Category:") + "</b> "; |
298 | text += categoryNames( "Todo List" ).join(", "); | 332 | text += categoryNames( "Todo List" ).join(", "); |
299 | text += "<br>"; | 333 | text += "<br>"; |
300 | 334 | ||
301 | return text; | 335 | return text; |
302 | } | 336 | } |
303 | bool OTodo::hasNotifiers()const { | 337 | bool OTodo::hasNotifiers()const { |
304 | if (!data->notifiers) return false; | 338 | if (!data->notifiers) return false; |
305 | return !data->notifiers->isEmpty(); | 339 | return !data->notifiers->isEmpty(); |
306 | } | 340 | } |
307 | OPimNotifyManager& OTodo::notifiers() { | 341 | OPimNotifyManager& OTodo::notifiers() { |
308 | if (!data->notifiers ) | 342 | if (!data->notifiers ) |
309 | data->notifiers = new OPimNotifyManager; | 343 | data->notifiers = new OPimNotifyManager; |
310 | return (*data->notifiers); | 344 | return (*data->notifiers); |
311 | } | 345 | } |
312 | const OPimNotifyManager& OTodo::notifiers()const{ | 346 | const OPimNotifyManager& OTodo::notifiers()const{ |
313 | if (!data->notifiers ) | 347 | if (!data->notifiers ) |
314 | data->notifiers = new OPimNotifyManager; | 348 | data->notifiers = new OPimNotifyManager; |
315 | 349 | ||
316 | return (*data->notifiers); | 350 | return (*data->notifiers); |
317 | } | 351 | } |
318 | 352 | ||
319 | bool OTodo::operator<( const OTodo &toDoEvent )const{ | 353 | bool OTodo::operator<( const OTodo &toDoEvent )const{ |
320 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 354 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
321 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; | 355 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return false; |
322 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 356 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
323 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 357 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
324 | return priority() < toDoEvent.priority(); | 358 | return priority() < toDoEvent.priority(); |
325 | }else{ | 359 | }else{ |
326 | return dueDate() < toDoEvent.dueDate(); | 360 | return dueDate() < toDoEvent.dueDate(); |
327 | } | 361 | } |
328 | } | 362 | } |
329 | return false; | 363 | return false; |
330 | } | 364 | } |
331 | bool OTodo::operator<=(const OTodo &toDoEvent )const | 365 | bool OTodo::operator<=(const OTodo &toDoEvent )const |
332 | { | 366 | { |
333 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; | 367 | if( !hasDueDate() && !toDoEvent.hasDueDate() ) return true; |
334 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; | 368 | if( !hasDueDate() && toDoEvent.hasDueDate() ) return true; |
335 | if( hasDueDate() && toDoEvent.hasDueDate() ){ | 369 | if( hasDueDate() && toDoEvent.hasDueDate() ){ |
336 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide | 370 | if( dueDate() == toDoEvent.dueDate() ){ // let's the priority decide |
337 | return priority() <= toDoEvent.priority(); | 371 | return priority() <= toDoEvent.priority(); |
338 | }else{ | 372 | }else{ |
339 | return dueDate() <= toDoEvent.dueDate(); | 373 | return dueDate() <= toDoEvent.dueDate(); |
340 | } | 374 | } |
341 | } | 375 | } |
342 | return true; | 376 | return true; |
343 | } | 377 | } |
344 | bool OTodo::operator>(const OTodo &toDoEvent )const | 378 | bool OTodo::operator>(const OTodo &toDoEvent )const |