-rw-r--r-- | korganizer/koagendaitem.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 7a685d8..81681df 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -537,187 +537,189 @@ void KOAgendaItem::paintEvent ( QPaintEvent *e ) | |||
537 | paintMe( mSelected ); | 537 | paintMe( mSelected ); |
538 | return; | 538 | return; |
539 | } else { | 539 | } else { |
540 | if ( mAllDay ) | 540 | if ( mAllDay ) |
541 | paintFrom = paintPixAllday(); | 541 | paintFrom = paintPixAllday(); |
542 | else | 542 | else |
543 | paintFrom = paintPix(); | 543 | paintFrom = paintPix(); |
544 | } | 544 | } |
545 | xx += rx; | 545 | xx += rx; |
546 | 546 | ||
547 | if ( xx < 0 ) { | 547 | if ( xx < 0 ) { |
548 | rw = rw + xx; | 548 | rw = rw + xx; |
549 | rx -= xx; | 549 | rx -= xx; |
550 | xx = 0; | 550 | xx = 0; |
551 | if ( rw <= 1 ) { | 551 | if ( rw <= 1 ) { |
552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 552 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | if ( paintFrom->width() < xx+rw ) { | 556 | if ( paintFrom->width() < xx+rw ) { |
557 | rw = paintFrom->width() - xx; | 557 | rw = paintFrom->width() - xx; |
558 | if ( rw <= 1 ) { | 558 | if ( rw <= 1 ) { |
559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 559 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
560 | return; | 560 | return; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 563 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 564 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
565 | } | 565 | } |
566 | void KOAgendaItem::computeText() | 566 | void KOAgendaItem::computeText() |
567 | { | 567 | { |
568 | mDisplayedText = mIncidence->summary(); | 568 | mDisplayedText = mIncidence->summary(); |
569 | if ( (mIncidence->typeID() == todoID ) ) { | 569 | if ( (mIncidence->typeID() == todoID ) ) { |
570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 570 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 571 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 572 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
573 | else if ( !(mIncidence->doesFloat())) | 573 | else if ( !(mIncidence->doesFloat())) |
574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 574 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
575 | } | 575 | } |
576 | } else { | 576 | } else { |
577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 577 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 578 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
579 | 579 | ||
580 | if ( mAllDay ) { | 580 | if ( mAllDay ) { |
581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 581 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
582 | if ( mIncidence->doesRecur() ) { | 582 | if ( mIncidence->doesRecur() ) { |
583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; | 583 | mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; |
584 | } else { | 584 | } else { |
585 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 585 | int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() ); |
586 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) + " ("+QString::number( dur )+i18n(" days") +")" ; | ||
586 | } | 587 | } |
587 | } | 588 | } |
588 | } | 589 | } |
589 | } | 590 | } |
590 | 591 | ||
591 | if ( !mIncidence->location().isEmpty() ) { | 592 | if ( !mIncidence->location().isEmpty() ) { |
592 | if ( mAllDay ) | 593 | if ( mAllDay ) |
593 | mDisplayedText += " ("; | 594 | mDisplayedText += " ("; |
594 | else | 595 | else |
595 | mDisplayedText += "\n("; | 596 | mDisplayedText += "\n("; |
596 | mDisplayedText += mIncidence->location() +")"; | 597 | mDisplayedText += mIncidence->location() +")"; |
597 | } | 598 | } |
598 | #ifdef DESKTOP_VERSION | 599 | #ifdef DESKTOP_VERSION |
599 | QString tipText = mIncidence->summary(); | 600 | QString tipText = mIncidence->summary(); |
600 | if ( !mIncidence->doesFloat() ) { | 601 | if ( !mIncidence->doesFloat() ) { |
601 | if ( mIncidence->typeID() == eventID ) { | 602 | if ( mIncidence->typeID() == eventID ) { |
602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 603 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 604 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 605 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
605 | } | 606 | } |
606 | else { | 607 | else { |
607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 608 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 609 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
609 | } | 610 | } |
610 | } | 611 | } |
611 | else if ( mIncidence->typeID() == todoID ) { | 612 | else if ( mIncidence->typeID() == todoID ) { |
612 | if (mIncidence->hasStartDate()) | 613 | if (mIncidence->hasStartDate()) |
613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 614 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
614 | if (((Todo*)mIncidence)->hasDueDate()) | 615 | if (((Todo*)mIncidence)->hasDueDate()) |
615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 616 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
616 | } | 617 | } |
617 | } else if ( mIncidence->typeID() == todoID ) { | 618 | } else if ( mIncidence->typeID() == todoID ) { |
618 | if (mIncidence->hasStartDate()) | 619 | if (mIncidence->hasStartDate()) |
619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 620 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
620 | if (((Todo*)mIncidence)->hasDueDate()) | 621 | if (((Todo*)mIncidence)->hasDueDate()) |
621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 622 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
622 | } | 623 | } |
623 | 624 | ||
624 | if (!mIncidence->location().isEmpty()) { | 625 | if (!mIncidence->location().isEmpty()) { |
625 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 626 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
626 | } | 627 | } |
627 | QToolTip::add(this,tipText,toolTipGroup(),""); | 628 | QToolTip::add(this,tipText,toolTipGroup(),""); |
628 | #endif | 629 | #endif |
629 | } | 630 | } |
630 | void KOAgendaItem::updateItem() | 631 | void KOAgendaItem::updateItem() |
631 | { | 632 | { |
632 | computeText(); | 633 | computeText(); |
633 | 634 | ||
634 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 635 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
635 | paintMe( mSelected ); | 636 | paintMe( mSelected ); |
636 | repaint( false); | 637 | repaint( false); |
637 | } | 638 | } |
638 | 639 | ||
639 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 640 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
640 | { | 641 | { |
641 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 642 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
642 | paintMe( mSelected ); | 643 | paintMe( mSelected ); |
643 | repaint( false ); | 644 | repaint( false ); |
644 | } | 645 | } |
645 | 646 | ||
646 | /* | 647 | /* |
647 | Return height of item in units of agenda cells | 648 | Return height of item in units of agenda cells |
648 | */ | 649 | */ |
649 | int KOAgendaItem::cellHeight() | 650 | int KOAgendaItem::cellHeight() |
650 | { | 651 | { |
651 | int ret = mCellYBottom - mCellYTop + 1; | 652 | int ret = mCellYBottom - mCellYTop + 1; |
652 | if ( ret <= 0 ) { | 653 | if ( ret <= 0 ) { |
653 | ret = 1; | 654 | ret = 1; |
654 | mCellYBottom = 0; | 655 | mCellYBottom = 0; |
655 | mCellYTop = 0; | 656 | mCellYTop = 0; |
656 | } | 657 | } |
657 | return ret; | 658 | return ret; |
658 | } | 659 | } |
659 | // it may be that allday agenda items have a needed width > 32000 | 660 | // it may be that allday agenda items have a needed width > 32000 |
660 | // this code is to fix this problem | 661 | // this code is to fix this problem |
661 | int KOAgendaItem::resizeMe( int grid, int wid, int hei ) | 662 | int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) |
662 | { | 663 | { |
663 | int diff = 0; | 664 | int diff = 0; |
664 | if ( mCellX < -3 && mAllDay ) { | 665 | if ( mCellX < -3 && mAllDay ) { |
665 | diff = (mCellX + 3) * -grid; | 666 | diff = (mCellX + 3) * -grid; |
666 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); | 667 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); |
667 | if ( diff >= wid ) { | 668 | if ( diff >= wid ) { |
668 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); | 669 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); |
669 | //diff = 0; | 670 | //diff = 0; |
670 | } | 671 | } |
671 | } | 672 | } |
672 | if ( wid == width() || diff >= wid ) | 673 | if ( (!invalidWidth && wid == width() ) || diff >= wid ) |
673 | resize( wid, hei ); | 674 | resize( wid, hei ); |
674 | else | 675 | else |
675 | resize( wid - diff, hei ); | 676 | resize( wid - diff, hei ); |
677 | //qDebug("wid %d x %d ", width(), x()); | ||
676 | return diff; | 678 | return diff; |
677 | } | 679 | } |
678 | /* | 680 | /* |
679 | Return height of item in units of agenda cells | 681 | Return height of item in units of agenda cells |
680 | */ | 682 | */ |
681 | int KOAgendaItem::cellWidth() | 683 | int KOAgendaItem::cellWidth() |
682 | { | 684 | { |
683 | return mCellXWidth - mCellX + 1; | 685 | return mCellXWidth - mCellX + 1; |
684 | } | 686 | } |
685 | 687 | ||
686 | void KOAgendaItem::setItemDate(QDate qd) | 688 | void KOAgendaItem::setItemDate(QDate qd) |
687 | { | 689 | { |
688 | mDate = qd; | 690 | mDate = qd; |
689 | } | 691 | } |
690 | 692 | ||
691 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 693 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
692 | { | 694 | { |
693 | mCellX = X; | 695 | mCellX = X; |
694 | mCellYTop = YTop; | 696 | mCellYTop = YTop; |
695 | mCellYBottom = YBottom; | 697 | mCellYBottom = YBottom; |
696 | } | 698 | } |
697 | 699 | ||
698 | void KOAgendaItem::setCellXWidth(int xwidth) | 700 | void KOAgendaItem::setCellXWidth(int xwidth) |
699 | { | 701 | { |
700 | mCellXWidth = xwidth; | 702 | mCellXWidth = xwidth; |
701 | } | 703 | } |
702 | 704 | ||
703 | void KOAgendaItem::setCellX(int XLeft, int XRight) | 705 | void KOAgendaItem::setCellX(int XLeft, int XRight) |
704 | { | 706 | { |
705 | mCellX = XLeft; | 707 | mCellX = XLeft; |
706 | mCellXWidth = XRight; | 708 | mCellXWidth = XRight; |
707 | } | 709 | } |
708 | 710 | ||
709 | void KOAgendaItem::setCellY(int YTop, int YBottom) | 711 | void KOAgendaItem::setCellY(int YTop, int YBottom) |
710 | { | 712 | { |
711 | mCellYTop = YTop; | 713 | mCellYTop = YTop; |
712 | mCellYBottom = YBottom; | 714 | mCellYBottom = YBottom; |
713 | } | 715 | } |
714 | 716 | ||
715 | void KOAgendaItem::setSubCell(int subCell) | 717 | void KOAgendaItem::setSubCell(int subCell) |
716 | { | 718 | { |
717 | mSubCell = subCell; | 719 | mSubCell = subCell; |
718 | } | 720 | } |
719 | 721 | ||
720 | void KOAgendaItem::setSubCells(int subCells) | 722 | void KOAgendaItem::setSubCells(int subCells) |
721 | { | 723 | { |
722 | mSubCells = subCells; | 724 | mSubCells = subCells; |
723 | } | 725 | } |