author | zautrix <zautrix> | 2005-08-22 16:30:29 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-08-22 16:30:29 (UTC) |
commit | e011ace92e07174effca53b7dde20b9a5b695af0 (patch) (unidiff) | |
tree | 6e4e4da6b64aae85158ebbf9637f5980aef18448 /korganizer/koagendaitem.cpp | |
parent | 18780cc2342097b343ee2fa50c649f425ddaed34 (diff) | |
download | kdepimpi-e011ace92e07174effca53b7dde20b9a5b695af0.zip kdepimpi-e011ace92e07174effca53b7dde20b9a5b695af0.tar.gz kdepimpi-e011ace92e07174effca53b7dde20b9a5b695af0.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagendaitem.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 81681df..b416115 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -495,193 +495,192 @@ QPixmap * KOAgendaItem::paintPixAllday() | |||
495 | void KOAgendaItem::repaintItem() | 495 | void KOAgendaItem::repaintItem() |
496 | { | 496 | { |
497 | globalFlagBlockAgendaItemPaint = 0; | 497 | globalFlagBlockAgendaItemPaint = 0; |
498 | globalFlagBlockAgenda = 0; | 498 | globalFlagBlockAgenda = 0; |
499 | repaint( false ); | 499 | repaint( false ); |
500 | } | 500 | } |
501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 501 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
502 | { | 502 | { |
503 | 503 | ||
504 | if ( globalFlagBlockAgendaItemPaint ) | 504 | if ( globalFlagBlockAgendaItemPaint ) |
505 | return; | 505 | return; |
506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 506 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
507 | return; | 507 | return; |
508 | int yy; | 508 | int yy; |
509 | if ( mAllDay ) | 509 | if ( mAllDay ) |
510 | yy = y(); | 510 | yy = y(); |
511 | else | 511 | else |
512 | yy = mCellYTop * ( height() / cellHeight() ); | 512 | yy = mCellYTop * ( height() / cellHeight() ); |
513 | int xx = x(); | 513 | int xx = x(); |
514 | 514 | ||
515 | if ( xPaintCoord != xx || yPaintCoord != yy || | 515 | if ( xPaintCoord != xx || yPaintCoord != yy || |
516 | wPaintCoord != width() || hPaintCoord != height()) { | 516 | wPaintCoord != width() || hPaintCoord != height()) { |
517 | xPaintCoord= xx; | 517 | xPaintCoord= xx; |
518 | yPaintCoord = yy; | 518 | yPaintCoord = yy; |
519 | wPaintCoord = width(); | 519 | wPaintCoord = width(); |
520 | hPaintCoord = height(); | 520 | hPaintCoord = height(); |
521 | globalFlagBlockAgendaItemUpdate = 0; | 521 | globalFlagBlockAgendaItemUpdate = 0; |
522 | paintMe( mSelected ); | 522 | paintMe( mSelected ); |
523 | //qDebug("calling paintMe "); | 523 | //qDebug("calling paintMe "); |
524 | globalFlagBlockAgendaItemUpdate = 1; | 524 | globalFlagBlockAgendaItemUpdate = 1; |
525 | if ( mSelected ) | 525 | if ( mSelected ) |
526 | return; | 526 | return; |
527 | } | 527 | } |
528 | int rx, ry, rw, rh; | 528 | int rx, ry, rw, rh; |
529 | rx = e->rect().x(); | 529 | rx = e->rect().x(); |
530 | ry = e->rect().y(); | 530 | ry = e->rect().y(); |
531 | rw = e->rect().width(); | 531 | rw = e->rect().width(); |
532 | rh = e->rect().height(); | 532 | rh = e->rect().height(); |
533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 533 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
534 | 534 | ||
535 | QPixmap* paintFrom ; | 535 | QPixmap* paintFrom ; |
536 | if ( mSelected ) { | 536 | if ( mSelected ) { |
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 | int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() ); | 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 | 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") +")" ; |
587 | } | 587 | } |
588 | } | 588 | } |
589 | } | 589 | } |
590 | } | 590 | } |
591 | |||
592 | if ( !mIncidence->location().isEmpty() ) { | 591 | if ( !mIncidence->location().isEmpty() ) { |
593 | if ( mAllDay ) | 592 | if ( mAllDay ) |
594 | mDisplayedText += " ("; | 593 | mDisplayedText += " ("; |
595 | else | 594 | else |
596 | mDisplayedText += "\n("; | 595 | mDisplayedText += "\n("; |
597 | mDisplayedText += mIncidence->location() +")"; | 596 | mDisplayedText += mIncidence->location() +")"; |
598 | } | 597 | } |
599 | #ifdef DESKTOP_VERSION | 598 | #ifdef DESKTOP_VERSION |
600 | QString tipText = mIncidence->summary(); | 599 | QString tipText = mIncidence->summary(); |
601 | if ( !mIncidence->doesFloat() ) { | 600 | if ( !mIncidence->doesFloat() ) { |
602 | if ( mIncidence->typeID() == eventID ) { | 601 | if ( mIncidence->typeID() == eventID ) { |
603 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 602 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
604 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 603 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
605 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 604 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
606 | } | 605 | } |
607 | else { | 606 | else { |
608 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 607 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
609 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 608 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
610 | } | 609 | } |
611 | } | 610 | } |
612 | else if ( mIncidence->typeID() == todoID ) { | 611 | else if ( mIncidence->typeID() == todoID ) { |
613 | if (mIncidence->hasStartDate()) | 612 | if (mIncidence->hasStartDate()) |
614 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 613 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
615 | if (((Todo*)mIncidence)->hasDueDate()) | 614 | if (((Todo*)mIncidence)->hasDueDate()) |
616 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 615 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
617 | } | 616 | } |
618 | } else if ( mIncidence->typeID() == todoID ) { | 617 | } else if ( mIncidence->typeID() == todoID ) { |
619 | if (mIncidence->hasStartDate()) | 618 | if (mIncidence->hasStartDate()) |
620 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 619 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
621 | if (((Todo*)mIncidence)->hasDueDate()) | 620 | if (((Todo*)mIncidence)->hasDueDate()) |
622 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 621 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
623 | } | 622 | } |
624 | 623 | ||
625 | if (!mIncidence->location().isEmpty()) { | 624 | if (!mIncidence->location().isEmpty()) { |
626 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 625 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
627 | } | 626 | } |
628 | QToolTip::add(this,tipText,toolTipGroup(),""); | 627 | QToolTip::add(this,tipText,toolTipGroup(),""); |
629 | #endif | 628 | #endif |
630 | } | 629 | } |
631 | void KOAgendaItem::updateItem() | 630 | void KOAgendaItem::updateItem() |
632 | { | 631 | { |
633 | computeText(); | 632 | computeText(); |
634 | 633 | ||
635 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 634 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
636 | paintMe( mSelected ); | 635 | paintMe( mSelected ); |
637 | repaint( false); | 636 | repaint( false); |
638 | } | 637 | } |
639 | 638 | ||
640 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 639 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
641 | { | 640 | { |
642 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 641 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
643 | paintMe( mSelected ); | 642 | paintMe( mSelected ); |
644 | repaint( false ); | 643 | repaint( false ); |
645 | } | 644 | } |
646 | 645 | ||
647 | /* | 646 | /* |
648 | Return height of item in units of agenda cells | 647 | Return height of item in units of agenda cells |
649 | */ | 648 | */ |
650 | int KOAgendaItem::cellHeight() | 649 | int KOAgendaItem::cellHeight() |
651 | { | 650 | { |
652 | int ret = mCellYBottom - mCellYTop + 1; | 651 | int ret = mCellYBottom - mCellYTop + 1; |
653 | if ( ret <= 0 ) { | 652 | if ( ret <= 0 ) { |
654 | ret = 1; | 653 | ret = 1; |
655 | mCellYBottom = 0; | 654 | mCellYBottom = 0; |
656 | mCellYTop = 0; | 655 | mCellYTop = 0; |
657 | } | 656 | } |
658 | return ret; | 657 | return ret; |
659 | } | 658 | } |
660 | // it may be that allday agenda items have a needed width > 32000 | 659 | // it may be that allday agenda items have a needed width > 32000 |
661 | // this code is to fix this problem | 660 | // this code is to fix this problem |
662 | int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) | 661 | int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) |
663 | { | 662 | { |
664 | int diff = 0; | 663 | int diff = 0; |
665 | if ( mCellX < -3 && mAllDay ) { | 664 | if ( mCellX < -3 && mAllDay ) { |
666 | diff = (mCellX + 3) * -grid; | 665 | diff = (mCellX + 3) * -grid; |
667 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); | 666 | //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); |
668 | if ( diff >= wid ) { | 667 | if ( diff >= wid ) { |
669 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); | 668 | // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); |
670 | //diff = 0; | 669 | //diff = 0; |
671 | } | 670 | } |
672 | } | 671 | } |
673 | if ( (!invalidWidth && wid == width() ) || diff >= wid ) | 672 | if ( (!invalidWidth && wid == width() ) || diff >= wid ) |
674 | resize( wid, hei ); | 673 | resize( wid, hei ); |
675 | else | 674 | else |
676 | resize( wid - diff, hei ); | 675 | resize( wid - diff, hei ); |
677 | //qDebug("wid %d x %d ", width(), x()); | 676 | //qDebug("wid %d x %d ", width(), x()); |
678 | return diff; | 677 | return diff; |
679 | } | 678 | } |
680 | /* | 679 | /* |
681 | Return height of item in units of agenda cells | 680 | Return height of item in units of agenda cells |
682 | */ | 681 | */ |
683 | int KOAgendaItem::cellWidth() | 682 | int KOAgendaItem::cellWidth() |
684 | { | 683 | { |
685 | return mCellXWidth - mCellX + 1; | 684 | return mCellXWidth - mCellX + 1; |
686 | } | 685 | } |
687 | 686 | ||