summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-10-24 20:42:26 (UTC)
committer zautrix <zautrix>2005-10-24 20:42:26 (UTC)
commitf696b904526567d45cd01a5b607644f8aa3bfe6b (patch) (unidiff)
tree938cad6f52461b54969da1933cae232c5c4da6f5
parent9b626f37040b4da2a23cdce2d9241218b84d3d88 (diff)
downloadkdepimpi-f696b904526567d45cd01a5b607644f8aa3bfe6b.zip
kdepimpi-f696b904526567d45cd01a5b607644f8aa3bfe6b.tar.gz
kdepimpi-f696b904526567d45cd01a5b607644f8aa3bfe6b.tar.bz2
fixx
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index b416115..407424d 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -453,264 +453,268 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
453 } 453 }
454 QRect dr; 454 QRect dr;
455 if ( w + x > parentWidget()->width() ) 455 if ( w + x > parentWidget()->width() )
456 w = parentWidget()->width()-x; 456 w = parentWidget()->width()-x;
457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); 457 paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr );
458 //qDebug("%d %d %d %d ", x, yy, w, h ); 458 //qDebug("%d %d %d %d ", x, yy, w, h );
459 if ( mIncidence->cancelled() ){ 459 if ( mIncidence->cancelled() ){
460 460
461 461
462 small = ( height() < 20 ); 462 small = ( height() < 20 );
463 463
464 if ( ! small ) { 464 if ( ! small ) {
465 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 466 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
467 } 467 }
468 468
469 } 469 }
470 pa.end(); 470 pa.end();
471 471
472} 472}
473 473
474QPixmap * KOAgendaItem::paintPix() 474QPixmap * KOAgendaItem::paintPix()
475{ 475{
476 static QPixmap* mPaintPix = 0; 476 static QPixmap* mPaintPix = 0;
477 if ( ! mPaintPix ) { 477 if ( ! mPaintPix ) {
478 int w = QApplication::desktop()->width(); 478 int w = QApplication::desktop()->width();
479 int h = QApplication::desktop()->height(); 479 int h = QApplication::desktop()->height();
480 mPaintPix = new QPixmap(w,h); 480 mPaintPix = new QPixmap(w,h);
481 } 481 }
482 return mPaintPix ; 482 return mPaintPix ;
483} 483}
484QPixmap * KOAgendaItem::paintPixAllday() 484QPixmap * KOAgendaItem::paintPixAllday()
485{ 485{
486 static QPixmap* mPaintPixA = 0; 486 static QPixmap* mPaintPixA = 0;
487 if ( ! mPaintPixA ) { 487 if ( ! mPaintPixA ) {
488 int w = QApplication::desktop()->width(); 488 int w = QApplication::desktop()->width();
489 int h = QApplication::desktop()->height()/5; 489 int h = QApplication::desktop()->height()/5;
490 mPaintPixA = new QPixmap(w,h); 490 mPaintPixA = new QPixmap(w,h);
491 } 491 }
492 return mPaintPixA ; 492 return mPaintPixA ;
493} 493}
494 494
495void KOAgendaItem::repaintItem() 495void KOAgendaItem::repaintItem()
496{ 496{
497 globalFlagBlockAgendaItemPaint = 0; 497 globalFlagBlockAgendaItemPaint = 0;
498 globalFlagBlockAgenda = 0; 498 globalFlagBlockAgenda = 0;
499 repaint( false ); 499 repaint( false );
500} 500}
501void KOAgendaItem::paintEvent ( QPaintEvent *e ) 501void 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}
566void KOAgendaItem::computeText() 566void 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 ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
582 if ( mIncidence->doesRecur() ) { 582 int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() );
583 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")"; 583 mDisplayedText += " ("+QString::number( dur )+i18n(" days") +")" ;
584 } else { 584
585 int dur = 1+ (static_cast<Event*>(mIncidence))->dtStart().date().daysTo( (static_cast<Event*>(mIncidence))->dtEnd().date() ); 585 if ( mIncidence->dtStart().date().addDays(3) < 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 if ( mIncidence->doesRecur() ) {
587 } 587 mDisplayedText += " (" + mIncidence->recurrence()->recurrenceText() + ")";
588 } 588 } else {
589 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true);
590 }
591 }
592 }
589 } 593 }
590 } 594 }
591 if ( !mIncidence->location().isEmpty() ) { 595 if ( !mIncidence->location().isEmpty() ) {
592 if ( mAllDay ) 596 if ( mAllDay )
593 mDisplayedText += " ("; 597 mDisplayedText += " (";
594 else 598 else
595 mDisplayedText += "\n("; 599 mDisplayedText += "\n(";
596 mDisplayedText += mIncidence->location() +")"; 600 mDisplayedText += mIncidence->location() +")";
597 } 601 }
598#ifdef DESKTOP_VERSION 602#ifdef DESKTOP_VERSION
599 QString tipText = mIncidence->summary(); 603 QString tipText = mIncidence->summary();
600 if ( !mIncidence->doesFloat() ) { 604 if ( !mIncidence->doesFloat() ) {
601 if ( mIncidence->typeID() == eventID ) { 605 if ( mIncidence->typeID() == eventID ) {
602 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 606 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
603 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 607 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
604 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 608 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
605 } 609 }
606 else { 610 else {
607 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 611 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
608 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 612 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
609 } 613 }
610 } 614 }
611 else if ( mIncidence->typeID() == todoID ) { 615 else if ( mIncidence->typeID() == todoID ) {
612 if (mIncidence->hasStartDate()) 616 if (mIncidence->hasStartDate())
613 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 617 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
614 if (((Todo*)mIncidence)->hasDueDate()) 618 if (((Todo*)mIncidence)->hasDueDate())
615 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr(); 619 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueStr();
616 } 620 }
617 } else if ( mIncidence->typeID() == todoID ) { 621 } else if ( mIncidence->typeID() == todoID ) {
618 if (mIncidence->hasStartDate()) 622 if (mIncidence->hasStartDate())
619 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr(); 623 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartDateStr();
620 if (((Todo*)mIncidence)->hasDueDate()) 624 if (((Todo*)mIncidence)->hasDueDate())
621 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr(); 625 tipText += "\n"+i18n("Due: ")+ (static_cast<Todo*>(mIncidence))->dtDueDateStr();
622 } 626 }
623 627
624 if (!mIncidence->location().isEmpty()) { 628 if (!mIncidence->location().isEmpty()) {
625 tipText += "\n"+i18n("Location: ")+mIncidence->location(); 629 tipText += "\n"+i18n("Location: ")+mIncidence->location();
626 } 630 }
627 QToolTip::add(this,tipText,toolTipGroup(),""); 631 QToolTip::add(this,tipText,toolTipGroup(),"");
628#endif 632#endif
629} 633}
630void KOAgendaItem::updateItem() 634void KOAgendaItem::updateItem()
631{ 635{
632 computeText(); 636 computeText();
633 637
634 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y()); 638 //qDebug("KOAgendaItem:: updateItem() %s %d %d ",incidence()->summary().latin1(), x(), y());
635 paintMe( mSelected ); 639 paintMe( mSelected );
636 repaint( false); 640 repaint( false);
637} 641}
638 642
639void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 643void KOAgendaItem::resizeEvent ( QResizeEvent *ev )
640{ 644{
641 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1()); 645 //qDebug("KOAgendaItem::resizeEvent %s ", mIncidence->summary().latin1());
642 paintMe( mSelected ); 646 paintMe( mSelected );
643 repaint( false ); 647 repaint( false );
644} 648}
645 649
646/* 650/*
647 Return height of item in units of agenda cells 651 Return height of item in units of agenda cells
648*/ 652*/
649int KOAgendaItem::cellHeight() 653int KOAgendaItem::cellHeight()
650{ 654{
651 int ret = mCellYBottom - mCellYTop + 1; 655 int ret = mCellYBottom - mCellYTop + 1;
652 if ( ret <= 0 ) { 656 if ( ret <= 0 ) {
653 ret = 1; 657 ret = 1;
654 mCellYBottom = 0; 658 mCellYBottom = 0;
655 mCellYTop = 0; 659 mCellYTop = 0;
656 } 660 }
657 return ret; 661 return ret;
658} 662}
659// it may be that allday agenda items have a needed width > 32000 663// it may be that allday agenda items have a needed width > 32000
660// this code is to fix this problem 664// this code is to fix this problem
661int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) 665int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth )
662{ 666{
663 int diff = 0; 667 int diff = 0;
664 if ( mCellX < -3 && mAllDay ) { 668 if ( mCellX < -3 && mAllDay ) {
665 diff = (mCellX + 3) * -grid; 669 diff = (mCellX + 3) * -grid;
666 //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid); 670 //qDebug("%s: cellX %d diff %d wid %d grid %d ", mDisplayedText.latin1(), mCellX, diff, wid, grid);
667 if ( diff >= wid ) { 671 if ( diff >= wid ) {
668 // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid); 672 // qDebug("KOAgendaItem::resizeMe: diff >= wid: diff %d wid %d ", diff, wid);
669 //diff = 0; 673 //diff = 0;
670 } 674 }
671 } 675 }
672 if ( (!invalidWidth && wid == width() ) || diff >= wid ) 676 if ( (!invalidWidth && wid == width() ) || diff >= wid )
673 resize( wid, hei ); 677 resize( wid, hei );
674 else 678 else
675 resize( wid - diff, hei ); 679 resize( wid - diff, hei );
676 //qDebug("wid %d x %d ", width(), x()); 680 //qDebug("wid %d x %d ", width(), x());
677 return diff; 681 return diff;
678} 682}
679/* 683/*
680 Return height of item in units of agenda cells 684 Return height of item in units of agenda cells
681*/ 685*/
682int KOAgendaItem::cellWidth() 686int KOAgendaItem::cellWidth()
683{ 687{
684 return mCellXWidth - mCellX + 1; 688 return mCellXWidth - mCellX + 1;
685} 689}
686 690
687void KOAgendaItem::setItemDate(QDate qd) 691void KOAgendaItem::setItemDate(QDate qd)
688{ 692{
689 mDate = qd; 693 mDate = qd;
690} 694}
691 695
692void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 696void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
693{ 697{
694 mCellX = X; 698 mCellX = X;
695 mCellYTop = YTop; 699 mCellYTop = YTop;
696 mCellYBottom = YBottom; 700 mCellYBottom = YBottom;
697} 701}
698 702
699void KOAgendaItem::setCellXWidth(int xwidth) 703void KOAgendaItem::setCellXWidth(int xwidth)
700{ 704{
701 mCellXWidth = xwidth; 705 mCellXWidth = xwidth;
702} 706}
703 707
704void KOAgendaItem::setCellX(int XLeft, int XRight) 708void KOAgendaItem::setCellX(int XLeft, int XRight)
705{ 709{
706 mCellX = XLeft; 710 mCellX = XLeft;
707 mCellXWidth = XRight; 711 mCellXWidth = XRight;
708} 712}
709 713
710void KOAgendaItem::setCellY(int YTop, int YBottom) 714void KOAgendaItem::setCellY(int YTop, int YBottom)
711{ 715{
712 mCellYTop = YTop; 716 mCellYTop = YTop;
713 mCellYBottom = YBottom; 717 mCellYBottom = YBottom;
714} 718}
715 719
716void KOAgendaItem::setSubCell(int subCell) 720void KOAgendaItem::setSubCell(int subCell)