-rw-r--r-- | korganizer/koagendaitem.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index 23afe7a..e545ca8 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -398,237 +398,245 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
398 | yy+= AGENDA_ICON_SIZE+2; | 398 | yy+= AGENDA_ICON_SIZE+2; |
399 | h -=(AGENDA_ICON_SIZE+3); | 399 | h -=(AGENDA_ICON_SIZE+3); |
400 | } | 400 | } |
401 | } | 401 | } |
402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 402 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
403 | if ( colsum < 250 ) | 403 | if ( colsum < 250 ) |
404 | paint->setPen ( white); | 404 | paint->setPen ( white); |
405 | if ( x < 0 ) { | 405 | if ( x < 0 ) { |
406 | w = w+x-3; | 406 | w = w+x-3; |
407 | x = 3; | 407 | x = 3; |
408 | if ( w > parentWidget()->width() ){ | 408 | if ( w > parentWidget()->width() ){ |
409 | w = parentWidget()->width() - 6; | 409 | w = parentWidget()->width() - 6; |
410 | #ifndef DESKTOP_VERSION | 410 | #ifndef DESKTOP_VERSION |
411 | align = ( AlignHCenter|WordBreak|AlignTop); | 411 | align = ( AlignHCenter|WordBreak|AlignTop); |
412 | #else | 412 | #else |
413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 413 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
414 | #endif | 414 | #endif |
415 | 415 | ||
416 | } | 416 | } |
417 | } | 417 | } |
418 | QRect dr; | 418 | QRect dr; |
419 | if ( w + x > parentWidget()->width() ) | 419 | if ( w + x > parentWidget()->width() ) |
420 | w = parentWidget()->width()-x; | 420 | w = parentWidget()->width()-x; |
421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 421 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
422 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 422 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
423 | if ( mIncidence->cancelled() ){ | 423 | if ( mIncidence->cancelled() ){ |
424 | 424 | ||
425 | 425 | ||
426 | small = ( height() < 20 ); | 426 | small = ( height() < 20 ); |
427 | 427 | ||
428 | if ( ! small ) { | 428 | if ( ! small ) { |
429 | QFontMetrics fm ( paint->font() ); | 429 | QFontMetrics fm ( paint->font() ); |
430 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 430 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
431 | } | 431 | } |
432 | 432 | ||
433 | } | 433 | } |
434 | pa.end(); | 434 | pa.end(); |
435 | 435 | ||
436 | } | 436 | } |
437 | void KOAgendaItem::resizePixmap( int w , int h ) | 437 | void KOAgendaItem::resizePixmap( int w , int h ) |
438 | { | 438 | { |
439 | paintPix()->resize( w, h ); | 439 | paintPix()->resize( w, h ); |
440 | paintPixSel()->resize( w, h ); | 440 | paintPixSel()->resize( w, h ); |
441 | 441 | ||
442 | } | 442 | } |
443 | QPixmap * KOAgendaItem::paintPix() | 443 | QPixmap * KOAgendaItem::paintPix() |
444 | { | 444 | { |
445 | static QPixmap* mPaintPix = 0; | 445 | static QPixmap* mPaintPix = 0; |
446 | if ( ! mPaintPix ) | 446 | if ( ! mPaintPix ) { |
447 | mPaintPix = new QPixmap(1,1); | 447 | int w = QApplication::desktop()->width(); |
448 | int h = QApplication::desktop()->height(); | ||
449 | mPaintPix = new QPixmap(w,h); | ||
450 | } | ||
448 | return mPaintPix ; | 451 | return mPaintPix ; |
449 | } | 452 | } |
450 | QPixmap * KOAgendaItem::paintPixAllday() | 453 | QPixmap * KOAgendaItem::paintPixAllday() |
451 | { | 454 | { |
452 | static QPixmap* mPaintPixA = 0; | 455 | static QPixmap* mPaintPixA = 0; |
453 | if ( ! mPaintPixA ) | 456 | if ( ! mPaintPixA ) { |
454 | mPaintPixA = new QPixmap(1,1); | 457 | int w = QApplication::desktop()->width(); |
458 | int h = QApplication::desktop()->height()/3; | ||
459 | mPaintPixA = new QPixmap(w,h); | ||
460 | } | ||
455 | return mPaintPixA ; | 461 | return mPaintPixA ; |
456 | } | 462 | } |
457 | QPixmap * KOAgendaItem::paintPixSel() | 463 | QPixmap * KOAgendaItem::paintPixSel() |
458 | { | 464 | { |
459 | static QPixmap* mPaintPixSel = 0; | 465 | static QPixmap* mPaintPixSel = 0; |
460 | if ( ! mPaintPixSel ) | 466 | if ( ! mPaintPixSel ) { |
461 | mPaintPixSel = new QPixmap(1,1); | 467 | int w = QApplication::desktop()->width(); |
468 | int h = QApplication::desktop()->height(); | ||
469 | mPaintPixSel = new QPixmap(w,h); | ||
470 | } | ||
462 | return mPaintPixSel ; | 471 | return mPaintPixSel ; |
463 | } | 472 | } |
464 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 473 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
465 | { | 474 | { |
466 | 475 | ||
467 | if ( globalFlagBlockAgendaItemPaint ) | 476 | if ( globalFlagBlockAgendaItemPaint ) |
468 | return; | 477 | return; |
469 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 478 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
470 | return; | 479 | return; |
471 | int yy; | 480 | int yy; |
472 | if ( mAllDay ) | 481 | if ( mAllDay ) |
473 | yy = y(); | 482 | yy = y(); |
474 | else | 483 | else |
475 | yy = mCellYTop * ( height() / cellHeight() ); | 484 | yy = mCellYTop * ( height() / cellHeight() ); |
476 | int xx = x(); | 485 | int xx = x(); |
477 | 486 | ||
478 | if ( xPaintCoord != xx || yPaintCoord != yy || | 487 | if ( xPaintCoord != xx || yPaintCoord != yy || |
479 | wPaintCoord != width() || hPaintCoord != height()) { | 488 | wPaintCoord != width() || hPaintCoord != height()) { |
480 | xPaintCoord= xx; | 489 | xPaintCoord= xx; |
481 | yPaintCoord = yy; | 490 | yPaintCoord = yy; |
482 | wPaintCoord = width(); | 491 | wPaintCoord = width(); |
483 | hPaintCoord = height(); | 492 | hPaintCoord = height(); |
484 | globalFlagBlockAgendaItemUpdate = 0; | 493 | globalFlagBlockAgendaItemUpdate = 0; |
485 | paintMe( mSelected ); | 494 | paintMe( mSelected ); |
486 | //qDebug("calling paintMe "); | 495 | //qDebug("calling paintMe "); |
487 | globalFlagBlockAgendaItemUpdate = 1; | 496 | globalFlagBlockAgendaItemUpdate = 1; |
488 | } | 497 | } |
489 | int rx, ry, rw, rh; | 498 | int rx, ry, rw, rh; |
490 | rx = e->rect().x(); | 499 | rx = e->rect().x(); |
491 | ry = e->rect().y(); | 500 | ry = e->rect().y(); |
492 | rw = e->rect().width(); | 501 | rw = e->rect().width(); |
493 | rh = e->rect().height(); | 502 | rh = e->rect().height(); |
494 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 503 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
495 | 504 | ||
496 | QPixmap* paintFrom ; | 505 | QPixmap* paintFrom ; |
497 | if ( mSelected ) { | 506 | if ( mSelected ) { |
498 | paintFrom = paintPixSel(); | 507 | paintFrom = paintPixSel(); |
499 | } else { | 508 | } else { |
500 | if ( mAllDay ) | 509 | if ( mAllDay ) |
501 | paintFrom = paintPixAllday(); | 510 | paintFrom = paintPixAllday(); |
502 | else | 511 | else |
503 | paintFrom = paintPix(); | 512 | paintFrom = paintPix(); |
504 | } | 513 | } |
505 | xx += rx; | 514 | xx += rx; |
506 | 515 | ||
507 | if ( xx < 0 ) { | 516 | if ( xx < 0 ) { |
508 | rw = rw + xx; | 517 | rw = rw + xx; |
509 | rx -= xx; | 518 | rx -= xx; |
510 | xx = 0; | 519 | xx = 0; |
511 | if ( rw <= 1 ) { | 520 | if ( rw <= 1 ) { |
512 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); | 521 | //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); |
513 | return; | 522 | return; |
514 | } | 523 | } |
515 | } | 524 | } |
516 | if ( paintFrom->width() < xx+rw ) { | 525 | if ( paintFrom->width() < xx+rw ) { |
517 | rw = paintFrom->width() - xx; | 526 | rw = paintFrom->width() - xx; |
518 | if ( rw <= 1 ) { | 527 | if ( rw <= 1 ) { |
519 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); | 528 | //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); |
520 | return; | 529 | return; |
521 | } | 530 | } |
522 | } | 531 | } |
523 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); | 532 | //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); |
524 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); | 533 | bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP); |
525 | } | 534 | } |
526 | void KOAgendaItem::computeText() | 535 | void KOAgendaItem::computeText() |
527 | { | 536 | { |
528 | |||
529 | mDisplayedText = mIncidence->summary(); | 537 | mDisplayedText = mIncidence->summary(); |
530 | if ( (mIncidence->type() == "Todo") ) { | 538 | if ( (mIncidence->type() == "Todo") ) { |
531 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 539 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
532 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 540 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
533 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 541 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
534 | else if ( !(mIncidence->doesFloat())) | 542 | else if ( !(mIncidence->doesFloat())) |
535 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 543 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
536 | } | 544 | } |
537 | } else { | 545 | } else { |
538 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 546 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
539 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 547 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + " - " + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
540 | 548 | ||
541 | if ( mAllDay ) { | 549 | if ( mAllDay ) { |
542 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 550 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |
543 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; | 551 | mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; |
544 | } | 552 | } |
545 | } | 553 | } |
546 | 554 | ||
547 | } | 555 | } |
548 | 556 | ||
549 | if ( !mIncidence->location().isEmpty() ) { | 557 | if ( !mIncidence->location().isEmpty() ) { |
550 | if ( mAllDay ) | 558 | if ( mAllDay ) |
551 | mDisplayedText += " ("; | 559 | mDisplayedText += " ("; |
552 | else | 560 | else |
553 | mDisplayedText += "\n("; | 561 | mDisplayedText += "\n("; |
554 | mDisplayedText += mIncidence->location() +")"; | 562 | mDisplayedText += mIncidence->location() +")"; |
555 | } | 563 | } |
556 | 564 | #ifdef DESKTOP_VERSION | |
557 | QString tipText = mIncidence->summary(); | 565 | QString tipText = mIncidence->summary(); |
558 | if ( !mIncidence->doesFloat() ) { | 566 | if ( !mIncidence->doesFloat() ) { |
559 | if ( mIncidence->type() == "Event" ) { | 567 | if ( mIncidence->type() == "Event" ) { |
560 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { | 568 | if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { |
561 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); | 569 | tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); |
562 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); | 570 | tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); |
563 | } | 571 | } |
564 | else { | 572 | else { |
565 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); | 573 | tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); |
566 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); | 574 | tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); |
567 | } | 575 | } |
568 | } | 576 | } |
569 | else if ( mIncidence->type() == "Todo" ) { | 577 | else if ( mIncidence->type() == "Todo" ) { |
570 | if (mIncidence->hasStartDate()) | 578 | if (mIncidence->hasStartDate()) |
571 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); | 579 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); |
572 | if (((Todo*)mIncidence)->hasDueDate()) | 580 | if (((Todo*)mIncidence)->hasDueDate()) |
573 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); | 581 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); |
574 | } | 582 | } |
575 | } else if ( mIncidence->type() == "Todo" ) { | 583 | } else if ( mIncidence->type() == "Todo" ) { |
576 | if (mIncidence->hasStartDate()) | 584 | if (mIncidence->hasStartDate()) |
577 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); | 585 | tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); |
578 | if (((Todo*)mIncidence)->hasDueDate()) | 586 | if (((Todo*)mIncidence)->hasDueDate()) |
579 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); | 587 | tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); |
580 | } | 588 | } |
581 | 589 | ||
582 | if (!mIncidence->location().isEmpty()) { | 590 | if (!mIncidence->location().isEmpty()) { |
583 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); | 591 | tipText += "\n"+i18n("Location: ")+mIncidence->location(); |
584 | } | 592 | } |
585 | QToolTip::add(this,tipText,toolTipGroup(),""); | 593 | QToolTip::add(this,tipText,toolTipGroup(),""); |
586 | 594 | #endif | |
587 | } | 595 | } |
588 | void KOAgendaItem::updateItem() | 596 | void KOAgendaItem::updateItem() |
589 | { | 597 | { |
590 | computeText(); | 598 | computeText(); |
591 | 599 | ||
592 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); | 600 | //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); |
593 | paintMe( mSelected ); | 601 | paintMe( mSelected ); |
594 | repaint( false); | 602 | repaint( false); |
595 | } | 603 | } |
596 | 604 | ||
597 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) | 605 | void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) |
598 | { | 606 | { |
599 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); | 607 | //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); |
600 | paintMe( mSelected ); | 608 | paintMe( mSelected ); |
601 | repaint( false ); | 609 | repaint( false ); |
602 | } | 610 | } |
603 | 611 | ||
604 | /* | 612 | /* |
605 | Return height of item in units of agenda cells | 613 | Return height of item in units of agenda cells |
606 | */ | 614 | */ |
607 | int KOAgendaItem::cellHeight() | 615 | int KOAgendaItem::cellHeight() |
608 | { | 616 | { |
609 | int ret = mCellYBottom - mCellYTop + 1; | 617 | int ret = mCellYBottom - mCellYTop + 1; |
610 | if ( ret <= 0 ) { | 618 | if ( ret <= 0 ) { |
611 | ret = 1; | 619 | ret = 1; |
612 | mCellYBottom = 0; | 620 | mCellYBottom = 0; |
613 | mCellYTop = 0; | 621 | mCellYTop = 0; |
614 | } | 622 | } |
615 | return ret; | 623 | return ret; |
616 | } | 624 | } |
617 | 625 | ||
618 | /* | 626 | /* |
619 | Return height of item in units of agenda cells | 627 | Return height of item in units of agenda cells |
620 | */ | 628 | */ |
621 | int KOAgendaItem::cellWidth() | 629 | int KOAgendaItem::cellWidth() |
622 | { | 630 | { |
623 | return mCellXWidth - mCellX + 1; | 631 | return mCellXWidth - mCellX + 1; |
624 | } | 632 | } |
625 | 633 | ||
626 | void KOAgendaItem::setItemDate(QDate qd) | 634 | void KOAgendaItem::setItemDate(QDate qd) |
627 | { | 635 | { |
628 | mDate = qd; | 636 | mDate = qd; |
629 | } | 637 | } |
630 | 638 | ||
631 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) | 639 | void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) |
632 | { | 640 | { |
633 | mCellX = X; | 641 | mCellX = X; |
634 | mCellYTop = YTop; | 642 | mCellYTop = YTop; |