summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp1
-rw-r--r--korganizer/koagendaitem.h2
2 files changed, 1 insertions, 2 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 81681df..b416115 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -399,385 +399,384 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
399 399
400 } 400 }
401 } 401 }
402 bool addIcon = false; 402 bool addIcon = false;
403 if ( ! small || w > 3 * h || h > 3* w ) 403 if ( ! small || w > 3 * h || h > 3* w )
404 addIcon = updateIcons( paint, horLayout ); 404 addIcon = updateIcons( paint, horLayout );
405 405
406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 406 //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); 407 qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0);
408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 408 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
409 if ( ! small ) { 409 if ( ! small ) {
410 x += 3; yy += 3;w -= 6; h-= 5; 410 x += 3; yy += 3;w -= 6; h-= 5;
411 } else { 411 } else {
412 x += 2; yy += 1;w -= 4; h-= 4; 412 x += 2; yy += 1;w -= 4; h-= 4;
413 if ( nfh < 6.01 ) { 413 if ( nfh < 6.01 ) {
414 yy -= 2; 414 yy -= 2;
415 h += 4; 415 h += 4;
416 } 416 }
417 else 417 else
418 if ( nfh < h -2 ) 418 if ( nfh < h -2 )
419 ++yy; 419 ++yy;
420 } 420 }
421 int align; 421 int align;
422#ifndef DESKTOP_VERSION 422#ifndef DESKTOP_VERSION
423 align = ( AlignLeft|WordBreak|AlignTop); 423 align = ( AlignLeft|WordBreak|AlignTop);
424#else 424#else
425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 425 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
426#endif 426#endif
427 if ( addIcon ) { 427 if ( addIcon ) {
428 if ( ! horLayout ) { 428 if ( ! horLayout ) {
429 x += AGENDA_ICON_SIZE+3; 429 x += AGENDA_ICON_SIZE+3;
430 w -= (AGENDA_ICON_SIZE+3); 430 w -= (AGENDA_ICON_SIZE+3);
431 } 431 }
432 else { 432 else {
433 yy+= AGENDA_ICON_SIZE+2; 433 yy+= AGENDA_ICON_SIZE+2;
434 h -=(AGENDA_ICON_SIZE+3); 434 h -=(AGENDA_ICON_SIZE+3);
435 } 435 }
436 } 436 }
437 if ( mWhiteText ) 437 if ( mWhiteText )
438 paint->setPen ( white); 438 paint->setPen ( white);
439 if ( x < 0 ) { 439 if ( x < 0 ) {
440 w = w+x-3; 440 w = w+x-3;
441 x = 3; 441 x = 3;
442 if ( !horLayout && addIcon ) 442 if ( !horLayout && addIcon )
443 x += AGENDA_ICON_SIZE+3; 443 x += AGENDA_ICON_SIZE+3;
444 if ( w > parentWidget()->width() ){ 444 if ( w > parentWidget()->width() ){
445 w = parentWidget()->width() - 6; 445 w = parentWidget()->width() - 6;
446#ifndef DESKTOP_VERSION 446#ifndef DESKTOP_VERSION
447 align = ( AlignHCenter|WordBreak|AlignTop); 447 align = ( AlignHCenter|WordBreak|AlignTop);
448#else 448#else
449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); 449 align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop);
450#endif 450#endif
451 451
452 } 452 }
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 ( 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}
631void KOAgendaItem::updateItem() 630void 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
640void KOAgendaItem::resizeEvent ( QResizeEvent *ev ) 639void 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*/
650int KOAgendaItem::cellHeight() 649int 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
662int KOAgendaItem::resizeMe( int grid, int wid, int hei, bool invalidWidth ) 661int 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*/
683int KOAgendaItem::cellWidth() 682int KOAgendaItem::cellWidth()
684{ 683{
685 return mCellXWidth - mCellX + 1; 684 return mCellXWidth - mCellX + 1;
686} 685}
687 686
688void KOAgendaItem::setItemDate(QDate qd) 687void KOAgendaItem::setItemDate(QDate qd)
689{ 688{
690 mDate = qd; 689 mDate = qd;
691} 690}
692 691
693void KOAgendaItem::setCellXY(int X, int YTop, int YBottom) 692void KOAgendaItem::setCellXY(int X, int YTop, int YBottom)
694{ 693{
695 mCellX = X; 694 mCellX = X;
696 mCellYTop = YTop; 695 mCellYTop = YTop;
697 mCellYBottom = YBottom; 696 mCellYBottom = YBottom;
698} 697}
699 698
700void KOAgendaItem::setCellXWidth(int xwidth) 699void KOAgendaItem::setCellXWidth(int xwidth)
701{ 700{
702 mCellXWidth = xwidth; 701 mCellXWidth = xwidth;
703} 702}
704 703
705void KOAgendaItem::setCellX(int XLeft, int XRight) 704void KOAgendaItem::setCellX(int XLeft, int XRight)
706{ 705{
707 mCellX = XLeft; 706 mCellX = XLeft;
708 mCellXWidth = XRight; 707 mCellXWidth = XRight;
709} 708}
710 709
711void KOAgendaItem::setCellY(int YTop, int YBottom) 710void KOAgendaItem::setCellY(int YTop, int YBottom)
712{ 711{
713 mCellYTop = YTop; 712 mCellYTop = YTop;
714 mCellYBottom = YBottom; 713 mCellYBottom = YBottom;
715} 714}
716 715
717void KOAgendaItem::setSubCell(int subCell) 716void KOAgendaItem::setSubCell(int subCell)
718{ 717{
719 mSubCell = subCell; 718 mSubCell = subCell;
720} 719}
721 720
722void KOAgendaItem::setSubCells(int subCells) 721void KOAgendaItem::setSubCells(int subCells)
723{ 722{
724 mSubCells = subCells; 723 mSubCells = subCells;
725} 724}
726 725
727void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 726void KOAgendaItem::setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
728 KOAgendaItem *last) 727 KOAgendaItem *last)
729{ 728{
730 mFirstMultiItem = first; 729 mFirstMultiItem = first;
731 mNextMultiItem = next; 730 mNextMultiItem = next;
732 mLastMultiItem = last; 731 mLastMultiItem = last;
733} 732}
734 733
735void KOAgendaItem::startMove() 734void KOAgendaItem::startMove()
736{ 735{
737 mStartCellX = mCellX; 736 mStartCellX = mCellX;
738 mStartCellXWidth = mCellXWidth; 737 mStartCellXWidth = mCellXWidth;
739 mStartCellYTop = mCellYTop; 738 mStartCellYTop = mCellYTop;
740 mStartCellYBottom = mCellYBottom; 739 mStartCellYBottom = mCellYBottom;
741} 740}
742 741
743void KOAgendaItem::resetMove() 742void KOAgendaItem::resetMove()
744{ 743{
745 mCellX = mStartCellX; 744 mCellX = mStartCellX;
746 mCellXWidth = mStartCellXWidth; 745 mCellXWidth = mStartCellXWidth;
747 mCellYTop = mStartCellYTop; 746 mCellYTop = mStartCellYTop;
748 mCellYBottom = mStartCellYBottom; 747 mCellYBottom = mStartCellYBottom;
749} 748}
750 749
751void KOAgendaItem::moveRelative(int dx, int dy) 750void KOAgendaItem::moveRelative(int dx, int dy)
752{ 751{
753 int newX = cellX() + dx; 752 int newX = cellX() + dx;
754 int newXWidth = cellXWidth() + dx; 753 int newXWidth = cellXWidth() + dx;
755 int newYTop = cellYTop() + dy; 754 int newYTop = cellYTop() + dy;
756 int newYBottom = cellYBottom() + dy; 755 int newYBottom = cellYBottom() + dy;
757 setCellXY(newX,newYTop,newYBottom); 756 setCellXY(newX,newYTop,newYBottom);
758 setCellXWidth(newXWidth); 757 setCellXWidth(newXWidth);
759} 758}
760 759
761void KOAgendaItem::expandTop(int dy) 760void KOAgendaItem::expandTop(int dy)
762{ 761{
763 int newYTop = cellYTop() + dy; 762 int newYTop = cellYTop() + dy;
764 int newYBottom = cellYBottom(); 763 int newYBottom = cellYBottom();
765 if (newYTop > newYBottom) newYTop = newYBottom; 764 if (newYTop > newYBottom) newYTop = newYBottom;
766 setCellY(newYTop, newYBottom); 765 setCellY(newYTop, newYBottom);
767} 766}
768 767
769void KOAgendaItem::expandBottom(int dy) 768void KOAgendaItem::expandBottom(int dy)
770{ 769{
771 int newYTop = cellYTop(); 770 int newYTop = cellYTop();
772 int newYBottom = cellYBottom() + dy; 771 int newYBottom = cellYBottom() + dy;
773 if (newYBottom < newYTop) newYBottom = newYTop; 772 if (newYBottom < newYTop) newYBottom = newYTop;
774 setCellY(newYTop, newYBottom); 773 setCellY(newYTop, newYBottom);
775} 774}
776 775
777void KOAgendaItem::expandLeft(int dx) 776void KOAgendaItem::expandLeft(int dx)
778{ 777{
779 int newX = cellX() + dx; 778 int newX = cellX() + dx;
780 int newXWidth = cellXWidth(); 779 int newXWidth = cellXWidth();
781 if (newX > newXWidth) newX = newXWidth; 780 if (newX > newXWidth) newX = newXWidth;
782 setCellX(newX,newXWidth); 781 setCellX(newX,newXWidth);
783} 782}
diff --git a/korganizer/koagendaitem.h b/korganizer/koagendaitem.h
index 37d89a6..27ee720 100644
--- a/korganizer/koagendaitem.h
+++ b/korganizer/koagendaitem.h
@@ -1,167 +1,167 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef KOAGENDAITEM_H 19#ifndef KOAGENDAITEM_H
20#define KOAGENDAITEM_H 20#define KOAGENDAITEM_H
21 21
22#include <qframe.h> 22#include <qframe.h>
23#include <qlabel.h> 23#include <qlabel.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25#include <qdatetime.h> 25#include <qdatetime.h>
26#include <qpalette.h> 26#include <qpalette.h>
27 27
28#include <libkcal/incidence.h> 28#include <libkcal/incidence.h>
29 29
30class KOAgendaItemWhatsThis; 30class KOAgendaItemWhatsThis;
31class QToolTipGroup; 31class QToolTipGroup;
32class QDragEnterEvent; 32class QDragEnterEvent;
33class QDropEvent; 33class QDropEvent;
34 34
35using namespace KCal; 35using namespace KCal;
36 36
37/* 37/*
38 The KOAgendaItem has to make sure that it receives all mouse events, which are 38 The KOAgendaItem has to make sure that it receives all mouse events, which are
39 to be used for dragging and resizing. That means it has to be installed as 39 to be used for dragging and resizing. That means it has to be installed as
40 eventfiler for its children, if it has children, and it has to pass mouse 40 eventfiler for its children, if it has children, and it has to pass mouse
41 events from the cildren to itself. See eventFilter(). 41 events from the cildren to itself. See eventFilter().
42*/ 42*/
43class KOAgendaItem : public QWidget 43class KOAgendaItem : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 public: 46 public:
47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0, 47 KOAgendaItem(Incidence *incidence, QDate qd, QWidget *parent, bool allday, const char *name=0,
48 WFlags f=0 ); 48 WFlags f=0 );
49 ~KOAgendaItem(); 49 ~KOAgendaItem();
50 QString getWhatsThisText(); 50 QString getWhatsThisText();
51 void init ( Incidence *incidence, QDate qd ); 51 void init ( Incidence *incidence, QDate qd );
52 int cellX() { return mCellX; } 52 int cellX() { return mCellX; }
53 int cellXWidth() { return mCellXWidth; } 53 int cellXWidth() { return mCellXWidth; }
54 int cellYTop() { return mCellYTop; } 54 int cellYTop() { return mCellYTop; }
55 int cellYBottom() { return mCellYBottom; } 55 int cellYBottom() { return mCellYBottom; }
56 int cellHeight(); 56 int cellHeight();
57 int cellWidth(); 57 int cellWidth();
58 int subCell() { return mSubCell; } 58 int subCell() { return mSubCell; }
59 int subCells() { return mSubCells; } 59 int subCells() { return mSubCells; }
60 60
61 void setCellXY(int X, int YTop, int YBottom); 61 void setCellXY(int X, int YTop, int YBottom);
62 void setCellY(int YTop, int YBottom); 62 void setCellY(int YTop, int YBottom);
63 void setCellX(int XLeft, int XRight); 63 void setCellX(int XLeft, int XRight);
64 void setCellXWidth(int xwidth); 64 void setCellXWidth(int xwidth);
65 void setSubCell(int subCell); 65 void setSubCell(int subCell);
66 void setSubCells(int subCells); 66 void setSubCells(int subCells);
67 67
68 /** Start movement */ 68 /** Start movement */
69 void startMove(); 69 void startMove();
70 /** Reset to original values */ 70 /** Reset to original values */
71 void resetMove(); 71 void resetMove();
72 72
73 void moveRelative(int dx,int dy); 73 void moveRelative(int dx,int dy);
74 void expandTop(int dy); 74 void expandTop(int dy);
75 void expandBottom(int dy); 75 void expandBottom(int dy);
76 void expandLeft(int dx); 76 void expandLeft(int dx);
77 void expandRight(int dx); 77 void expandRight(int dx);
78 int mLastMoveXPos; 78 int mLastMoveXPos;
79 79
80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next, 80 void setMultiItem(KOAgendaItem *first,KOAgendaItem *next,
81 KOAgendaItem *last); 81 KOAgendaItem *last);
82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; } 82 KOAgendaItem *firstMultiItem() { return mFirstMultiItem; }
83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; } 83 KOAgendaItem *nextMultiItem() { return mNextMultiItem; }
84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; } 84 KOAgendaItem *lastMultiItem() { return mLastMultiItem; }
85 85
86 Incidence *incidence() const { return mIncidence; } 86 Incidence *incidence() const { return mIncidence; }
87 QDate itemDate() { return mDate; } 87 QDate itemDate() { return mDate; }
88 88
89 /** Update the date of this item's occurence (not in the event) */ 89 /** Update the date of this item's occurence (not in the event) */
90 void setItemDate(QDate qd); 90 void setItemDate(QDate qd);
91 91
92 void setText ( const QString & text ) { mDisplayedText = text; } 92 void setText ( const QString & text ) { mDisplayedText = text; }
93 QString text () { return mDisplayedText; } 93 QString text () { return mDisplayedText; }
94 94
95 virtual bool eventFilter ( QObject *, QEvent * ); 95 virtual bool eventFilter ( QObject *, QEvent * );
96 96
97 static QToolTipGroup *toolTipGroup(); 97 static QToolTipGroup *toolTipGroup();
98 98
99 QPtrList<KOAgendaItem> conflictItems(); 99 QPtrList<KOAgendaItem> conflictItems();
100 void setConflictItems(QPtrList<KOAgendaItem>); 100 void setConflictItems(QPtrList<KOAgendaItem>);
101 void addConflictItem(KOAgendaItem *ci); 101 void addConflictItem(KOAgendaItem *ci);
102 void paintMe( bool, QPainter* painter = 0 ); 102 void paintMe( bool, QPainter* painter = 0 );
103 void repaintMe(); 103 void repaintMe();
104 static QPixmap * paintPix(); 104 static QPixmap * paintPix();
105 static QPixmap * paintPixAllday(); 105 static QPixmap * paintPixAllday();
106 void updateItem(); 106 void updateItem();
107 void computeText(); 107 void computeText();
108 void recreateIncidence(); 108 void recreateIncidence();
109 bool checkLayout(); 109 bool checkLayout();
110 void initColor (); 110 void initColor ();
111 bool isAllDay() { return mAllDay; } 111 bool isAllDay() { return mAllDay; }
112 int resizeMe( int grid, int wid, int hei, bool invalidHei = false ); 112 int resizeMe( int grid, int wid, int hei, bool invalidWidth = false );
113 public slots: 113 public slots:
114 bool updateIcons( QPainter *, bool ); 114 bool updateIcons( QPainter *, bool );
115 void select(bool=true); 115 void select(bool=true);
116 void repaintItem(); 116 void repaintItem();
117 117
118 protected: 118 protected:
119 void dragEnterEvent(QDragEnterEvent *e); 119 void dragEnterEvent(QDragEnterEvent *e);
120 void dropEvent(QDropEvent *e); 120 void dropEvent(QDropEvent *e);
121 void paintEvent ( QPaintEvent * ); 121 void paintEvent ( QPaintEvent * );
122 void resizeEvent ( QResizeEvent *ev ); 122 void resizeEvent ( QResizeEvent *ev );
123 123
124 private: 124 private:
125 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis; 125 KOAgendaItemWhatsThis* mKOAgendaItemWhatsThis;
126 bool mAllDay; 126 bool mAllDay;
127 bool mWhiteText; 127 bool mWhiteText;
128 int mCellX; 128 int mCellX;
129 int mCellXWidth; 129 int mCellXWidth;
130 int mCellYTop,mCellYBottom; 130 int mCellYTop,mCellYBottom;
131 int mSubCell; // subcell number of this item 131 int mSubCell; // subcell number of this item
132 int mSubCells; // Total number of subcells in cell of this item 132 int mSubCells; // Total number of subcells in cell of this item
133 int xPaintCoord; 133 int xPaintCoord;
134 int yPaintCoord; 134 int yPaintCoord;
135 int wPaintCoord; 135 int wPaintCoord;
136 int hPaintCoord; 136 int hPaintCoord;
137 // Variables to remember start position 137 // Variables to remember start position
138 int mStartCellX; 138 int mStartCellX;
139 int mStartCellXWidth; 139 int mStartCellXWidth;
140 int mStartCellYTop,mStartCellYBottom; 140 int mStartCellYTop,mStartCellYBottom;
141 int mLastMovePos; 141 int mLastMovePos;
142 142
143 // Multi item pointers 143 // Multi item pointers
144 KOAgendaItem *mFirstMultiItem; 144 KOAgendaItem *mFirstMultiItem;
145 KOAgendaItem *mNextMultiItem; 145 KOAgendaItem *mNextMultiItem;
146 KOAgendaItem *mLastMultiItem; 146 KOAgendaItem *mLastMultiItem;
147 147
148 int mFontPixelSize; 148 int mFontPixelSize;
149 Incidence *mIncidence; // corresponding event or todo 149 Incidence *mIncidence; // corresponding event or todo
150 QDate mDate; //date this events occurs (for recurrence) 150 QDate mDate; //date this events occurs (for recurrence)
151 //void showIcon( QLabel*, int ); 151 //void showIcon( QLabel*, int );
152 //QLabel *mTodoIconLabel; 152 //QLabel *mTodoIconLabel;
153 //QLabel *mItemLabel; 153 //QLabel *mItemLabel;
154 //QWidget *mIconBox; 154 //QWidget *mIconBox;
155 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly; 155 //QLabel *mIconAlarm,*mIconRecur,*mIconReadonly;
156 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer; 156 //QLabel *mIconReply,*mIconGroup,*mIconOrganizer;
157 //QLabel *mIconMoreInfo; 157 //QLabel *mIconMoreInfo;
158 static QToolTipGroup *mToolTipGroup; 158 static QToolTipGroup *mToolTipGroup;
159 159
160 QColor mBackgroundColor; 160 QColor mBackgroundColor;
161 QColorGroup mColorGroup; 161 QColorGroup mColorGroup;
162 QString mDisplayedText; 162 QString mDisplayedText;
163 bool mSelected; 163 bool mSelected;
164 QPtrList<KOAgendaItem> mConflictItems; 164 QPtrList<KOAgendaItem> mConflictItems;
165}; 165};
166 166
167#endif // KOAGENDAITEM_H 167#endif // KOAGENDAITEM_H