summaryrefslogtreecommitdiffabout
path: root/korganizer/koagendaitem.cpp
Unidiff
Diffstat (limited to 'korganizer/koagendaitem.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp24
1 files changed, 10 insertions, 14 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index 9fe1be4..abb29f7 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -335,38 +335,41 @@ bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e )
335} 335}
336void KOAgendaItem::repaintMe( ) 336void KOAgendaItem::repaintMe( )
337{ 337{
338 paintMe ( mSelected ); 338 paintMe ( mSelected );
339} 339}
340void KOAgendaItem::paintMe( bool selected, QPainter* paint ) 340void KOAgendaItem::paintMe( bool selected, QPainter* paint )
341{ 341{
342 if ( globalFlagBlockAgendaItemUpdate && ! selected) 342 if ( globalFlagBlockAgendaItemUpdate && ! selected)
343 return; 343 return;
344 QPainter pa; 344 QPainter pa;
345 345
346 if ( mSelected ) { 346 if ( mSelected ) {
347 pa.begin( paintPixSel() ); 347 pa.begin( this );
348 } else { 348 } else {
349 if ( mAllDay ) 349 if ( mAllDay )
350 pa.begin( paintPixAllday() ); 350 pa.begin( paintPixAllday() );
351 else 351 else
352 pa.begin( paintPix() ); 352 pa.begin( paintPix() );
353 } 353 }
354 int x, yy, w, h; 354 int x, yy, w, h;
355 float nfh = 7.0; 355 float nfh = 7.0;
356 x = pos().x(); w = width(); h = height (); 356 x = pos().x(); w = width(); h = height ();
357 if ( mAllDay ) 357 if ( mAllDay )
358 yy = y(); 358 yy = y();
359 else 359 else
360 yy = mCellYTop * ( height() / cellHeight() ); 360 yy = mCellYTop * ( height() / cellHeight() );
361 if ( mSelected ) {
362 pa.translate( -x, -yy );
363 }
361 xPaintCoord= x; 364 xPaintCoord= x;
362 yPaintCoord = yy; 365 yPaintCoord = yy;
363 wPaintCoord = width(); 366 wPaintCoord = width();
364 hPaintCoord = height(); 367 hPaintCoord = height();
365 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 368 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
366 if ( paint == 0 ) 369 if ( paint == 0 )
367 paint = &pa; 370 paint = &pa;
368 bool horLayout = ( w < h ); 371 bool horLayout = ( w < h );
369 int maxhei = mFontPixelSize+4; 372 int maxhei = mFontPixelSize+4;
370 if ( horLayout ) 373 if ( horLayout )
371 maxhei += AGENDA_ICON_SIZE -4; 374 maxhei += AGENDA_ICON_SIZE -4;
372 bool small = ( h < maxhei ); 375 bool small = ( h < maxhei );
@@ -461,92 +464,85 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
461 if ( ! small ) { 464 if ( ! small ) {
462 QFontMetrics fm ( paint->font() ); 465 QFontMetrics fm ( paint->font() );
463 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);
464 } 467 }
465 468
466 } 469 }
467 pa.end(); 470 pa.end();
468 471
469} 472}
470void KOAgendaItem::resizePixmap( int w , int h ) 473void KOAgendaItem::resizePixmap( int w , int h )
471{ 474{
472 paintPix()->resize( w, h ); 475 paintPix()->resize( w, h );
473 paintPixSel()->resize( w, h );
474 476
475} 477}
476QPixmap * KOAgendaItem::paintPix() 478QPixmap * KOAgendaItem::paintPix()
477{ 479{
478 static QPixmap* mPaintPix = 0; 480 static QPixmap* mPaintPix = 0;
479 if ( ! mPaintPix ) { 481 if ( ! mPaintPix ) {
480 int w = QApplication::desktop()->width(); 482 int w = QApplication::desktop()->width();
481 int h = QApplication::desktop()->height(); 483 int h = QApplication::desktop()->height();
482 mPaintPix = new QPixmap(w,h); 484 mPaintPix = new QPixmap(w,h);
483 } 485 }
484 return mPaintPix ; 486 return mPaintPix ;
485} 487}
486QPixmap * KOAgendaItem::paintPixAllday() 488QPixmap * KOAgendaItem::paintPixAllday()
487{ 489{
488 static QPixmap* mPaintPixA = 0; 490 static QPixmap* mPaintPixA = 0;
489 if ( ! mPaintPixA ) { 491 if ( ! mPaintPixA ) {
490 int w = QApplication::desktop()->width(); 492 int w = QApplication::desktop()->width();
491 int h = QApplication::desktop()->height()/3; 493 int h = QApplication::desktop()->height()/3;
492 mPaintPixA = new QPixmap(w,h); 494 mPaintPixA = new QPixmap(w,h);
493 } 495 }
494 return mPaintPixA ; 496 return mPaintPixA ;
495} 497}
496QPixmap * KOAgendaItem::paintPixSel() 498
497{
498 static QPixmap* mPaintPixSel = 0;
499 if ( ! mPaintPixSel ) {
500 int w = QApplication::desktop()->width();
501 int h = QApplication::desktop()->height();
502 mPaintPixSel = new QPixmap(w,h);
503 }
504 return mPaintPixSel ;
505}
506void KOAgendaItem::paintEvent ( QPaintEvent *e ) 499void KOAgendaItem::paintEvent ( QPaintEvent *e )
507{ 500{
508 501
509 if ( globalFlagBlockAgendaItemPaint ) 502 if ( globalFlagBlockAgendaItemPaint )
510 return; 503 return;
511 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 504 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
512 return; 505 return;
513 int yy; 506 int yy;
514 if ( mAllDay ) 507 if ( mAllDay )
515 yy = y(); 508 yy = y();
516 else 509 else
517 yy = mCellYTop * ( height() / cellHeight() ); 510 yy = mCellYTop * ( height() / cellHeight() );
518 int xx = x(); 511 int xx = x();
519 512
520 if ( xPaintCoord != xx || yPaintCoord != yy || 513 if ( xPaintCoord != xx || yPaintCoord != yy ||
521 wPaintCoord != width() || hPaintCoord != height()) { 514 wPaintCoord != width() || hPaintCoord != height()) {
522 xPaintCoord= xx; 515 xPaintCoord= xx;
523 yPaintCoord = yy; 516 yPaintCoord = yy;
524 wPaintCoord = width(); 517 wPaintCoord = width();
525 hPaintCoord = height(); 518 hPaintCoord = height();
526 globalFlagBlockAgendaItemUpdate = 0; 519 globalFlagBlockAgendaItemUpdate = 0;
527 paintMe( mSelected ); 520 paintMe( mSelected );
528 //qDebug("calling paintMe "); 521 //qDebug("calling paintMe ");
529 globalFlagBlockAgendaItemUpdate = 1; 522 globalFlagBlockAgendaItemUpdate = 1;
523 if ( mSelected )
524 return;
530 } 525 }
531 int rx, ry, rw, rh; 526 int rx, ry, rw, rh;
532 rx = e->rect().x(); 527 rx = e->rect().x();
533 ry = e->rect().y(); 528 ry = e->rect().y();
534 rw = e->rect().width(); 529 rw = e->rect().width();
535 rh = e->rect().height(); 530 rh = e->rect().height();
536 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 531 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
537 532
538 QPixmap* paintFrom ; 533 QPixmap* paintFrom ;
539 if ( mSelected ) { 534 if ( mSelected ) {
540 paintFrom = paintPixSel(); 535 paintMe( mSelected );
536 return;
541 } else { 537 } else {
542 if ( mAllDay ) 538 if ( mAllDay )
543 paintFrom = paintPixAllday(); 539 paintFrom = paintPixAllday();
544 else 540 else
545 paintFrom = paintPix(); 541 paintFrom = paintPix();
546 } 542 }
547 xx += rx; 543 xx += rx;
548 544
549 if ( xx < 0 ) { 545 if ( xx < 0 ) {
550 rw = rw + xx; 546 rw = rw + xx;
551 rx -= xx; 547 rx -= xx;
552 xx = 0; 548 xx = 0;