summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 5ee433a..7e6fa48 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -425,124 +425,144 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
425 QFontMetrics fm ( paint->font() ); 425 QFontMetrics fm ( paint->font() );
426 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); 426 paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2);
427 } 427 }
428 428
429 } 429 }
430 pa.end(); 430 pa.end();
431 431
432} 432}
433void KOAgendaItem::resizePixmap( int w , int h ) 433void KOAgendaItem::resizePixmap( int w , int h )
434{ 434{
435 paintPix()->resize( w, h ); 435 paintPix()->resize( w, h );
436 paintPixSel()->resize( w, h ); 436 paintPixSel()->resize( w, h );
437 437
438} 438}
439QPixmap * KOAgendaItem::paintPix() 439QPixmap * KOAgendaItem::paintPix()
440{ 440{
441 static QPixmap* mPaintPix = 0; 441 static QPixmap* mPaintPix = 0;
442 if ( ! mPaintPix ) 442 if ( ! mPaintPix )
443 mPaintPix = new QPixmap(1,1); 443 mPaintPix = new QPixmap(1,1);
444 return mPaintPix ; 444 return mPaintPix ;
445} 445}
446QPixmap * KOAgendaItem::paintPixAllday() 446QPixmap * KOAgendaItem::paintPixAllday()
447{ 447{
448 static QPixmap* mPaintPixA = 0; 448 static QPixmap* mPaintPixA = 0;
449 if ( ! mPaintPixA ) 449 if ( ! mPaintPixA )
450 mPaintPixA = new QPixmap(1,1); 450 mPaintPixA = new QPixmap(1,1);
451 return mPaintPixA ; 451 return mPaintPixA ;
452} 452}
453QPixmap * KOAgendaItem::paintPixSel() 453QPixmap * KOAgendaItem::paintPixSel()
454{ 454{
455 static QPixmap* mPaintPixSel = 0; 455 static QPixmap* mPaintPixSel = 0;
456 if ( ! mPaintPixSel ) 456 if ( ! mPaintPixSel )
457 mPaintPixSel = new QPixmap(1,1); 457 mPaintPixSel = new QPixmap(1,1);
458 return mPaintPixSel ; 458 return mPaintPixSel ;
459} 459}
460void KOAgendaItem::paintEvent ( QPaintEvent *e ) 460void KOAgendaItem::paintEvent ( QPaintEvent *e )
461{ 461{
462 462
463 if ( globalFlagBlockAgendaItemPaint ) 463 if ( globalFlagBlockAgendaItemPaint )
464 return; 464 return;
465 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 465 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
466 return; 466 return;
467 int yy; 467 int yy;
468 if ( mAllDay ) 468 if ( mAllDay )
469 yy = y(); 469 yy = y();
470 else 470 else
471 yy = mCellYTop * ( height() / cellHeight() ); 471 yy = mCellYTop * ( height() / cellHeight() );
472 int xx = x(); 472 int xx = x();
473
473 if ( xPaintCoord != xx || yPaintCoord != yy || 474 if ( xPaintCoord != xx || yPaintCoord != yy ||
474 wPaintCoord != width() || hPaintCoord != height()) { 475 wPaintCoord != width() || hPaintCoord != height()) {
475 xPaintCoord= xx; 476 xPaintCoord= xx;
476 yPaintCoord = yy; 477 yPaintCoord = yy;
477 wPaintCoord = width(); 478 wPaintCoord = width();
478 hPaintCoord = height(); 479 hPaintCoord = height();
479 globalFlagBlockAgendaItemUpdate = 0; 480 globalFlagBlockAgendaItemUpdate = 0;
480 paintMe( mSelected ); 481 paintMe( mSelected );
481 //qDebug("calling paintMe "); 482 //qDebug("calling paintMe ");
482 globalFlagBlockAgendaItemUpdate = 1; 483 globalFlagBlockAgendaItemUpdate = 1;
483 } 484 }
484 int rx, ry, rw, rh; 485 int rx, ry, rw, rh;
485 rx = e->rect().x(); 486 rx = e->rect().x();
486 ry = e->rect().y(); 487 ry = e->rect().y();
487 rw = e->rect().width(); 488 rw = e->rect().width();
488 rh = e->rect().height(); 489 rh = e->rect().height();
489 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 490 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
490 491
491 QPixmap* paintFrom ; 492 QPixmap* paintFrom ;
492 if ( mSelected ) { 493 if ( mSelected ) {
493 paintFrom = paintPixSel(); 494 paintFrom = paintPixSel();
494 } else { 495 } else {
495 if ( mAllDay ) 496 if ( mAllDay )
496 paintFrom = paintPixAllday(); 497 paintFrom = paintPixAllday();
497 else 498 else
498 paintFrom = paintPix(); 499 paintFrom = paintPix();
499 } 500 }
500 bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); 501 xx += rx;
502
503 if ( xx < 0 ) {
504 rw = rw + xx;
505 rx -= xx;
506 xx = 0;
507 if ( rw < 0 ) {
508 qDebug("KOAgendaItem::Width1 < 0. Returning ");
509 return;
510 }
511 }
512 if ( paintFrom->width() < xx+rw ) {
513 rw = paintFrom->width() - xx;
514 if ( rw < 0 ) {
515 qDebug("KOAgendaItem::Width2 < 0. Returning ");
516 return;
517 }
518 }
519 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);
520 bitBlt (this, rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh ,CopyROP);
501} 521}
502void KOAgendaItem::computeText() 522void KOAgendaItem::computeText()
503{ 523{
504 524
505 mDisplayedText = mIncidence->summary(); 525 mDisplayedText = mIncidence->summary();
506 if ( (mIncidence->type() == "Todo") ) { 526 if ( (mIncidence->type() == "Todo") ) {
507 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { 527 if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) {
508 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) 528 if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() )
509 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; 529 mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")";
510 else if ( !(mIncidence->doesFloat())) 530 else if ( !(mIncidence->doesFloat()))
511 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; 531 mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")";
512 } 532 }
513 } else { 533 } else {
514 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) 534 if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda)
515 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; 535 mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ;
516 536
517 if ( mAllDay ) { 537 if ( mAllDay ) {
518 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { 538 if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) {
519 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ; 539 mDisplayedText += ": " +KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtStart().date(), true) + " - " + KGlobal::locale()->formatDate((static_cast<Event*>(mIncidence))->dtEnd().date(), true) ;
520 } 540 }
521 } 541 }
522 542
523 } 543 }
524 544
525 if ( !mIncidence->location().isEmpty() ) { 545 if ( !mIncidence->location().isEmpty() ) {
526 if ( mAllDay ) 546 if ( mAllDay )
527 mDisplayedText += " ("; 547 mDisplayedText += " (";
528 else 548 else
529 mDisplayedText += "\n("; 549 mDisplayedText += "\n(";
530 mDisplayedText += mIncidence->location() +")"; 550 mDisplayedText += mIncidence->location() +")";
531 } 551 }
532 552
533 QString tipText = mIncidence->summary(); 553 QString tipText = mIncidence->summary();
534 if ( !mIncidence->doesFloat() ) { 554 if ( !mIncidence->doesFloat() ) {
535 if ( mIncidence->type() == "Event" ) { 555 if ( mIncidence->type() == "Event" ) {
536 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) { 556 if ( (static_cast<Event*>(mIncidence))->isMultiDay() ) {
537 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr(); 557 tipText += "\n"+i18n("From: ")+mIncidence->dtStartStr();
538 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr(); 558 tipText += "\n"+i18n("To: ")+(static_cast<Event*>(mIncidence))->dtEndStr();
539 } 559 }
540 else { 560 else {
541 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr(); 561 tipText += "\n"+i18n("Time: ")+mIncidence->dtStartTimeStr();
542 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr(); 562 tipText += " - "+(static_cast<Event*>(mIncidence))->dtEndTimeStr();
543 } 563 }
544 } 564 }
545 else if ( mIncidence->type() == "Todo" ) { 565 else if ( mIncidence->type() == "Todo" ) {
546 if (mIncidence->hasStartDate()) 566 if (mIncidence->hasStartDate())
547 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr(); 567 tipText += "\n"+i18n("Start: ")+ (static_cast<Todo*>(mIncidence))->dtStartStr();
548 if (((Todo*)mIncidence)->hasDueDate()) 568 if (((Todo*)mIncidence)->hasDueDate())