summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-04-04 18:43:08 (UTC)
committer zautrix <zautrix>2005-04-04 18:43:08 (UTC)
commit8e7f4812c4ad239b6a17cce8aa84c00274ced4df (patch) (unidiff)
tree4245f8dbe39ce59c1199a9a97dc68ec74825271b /korganizer
parentff205358654ed8741f0008eabd64a0e8b0476b61 (diff)
downloadkdepimpi-8e7f4812c4ad239b6a17cce8aa84c00274ced4df.zip
kdepimpi-8e7f4812c4ad239b6a17cce8aa84c00274ced4df.tar.gz
kdepimpi-8e7f4812c4ad239b6a17cce8aa84c00274ced4df.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/koagendaitem.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp
index b30ad75..23afe7a 100644
--- a/korganizer/koagendaitem.cpp
+++ b/korganizer/koagendaitem.cpp
@@ -328,192 +328,196 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint )
328 else 328 else
329 yy = mCellYTop * ( height() / cellHeight() ); 329 yy = mCellYTop * ( height() / cellHeight() );
330 xPaintCoord= x; 330 xPaintCoord= x;
331 yPaintCoord = yy; 331 yPaintCoord = yy;
332 wPaintCoord = width(); 332 wPaintCoord = width();
333 hPaintCoord = height(); 333 hPaintCoord = height();
334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); 334 //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height());
335 if ( paint == 0 ) 335 if ( paint == 0 )
336 paint = &pa; 336 paint = &pa;
337 bool horLayout = ( w < h ); 337 bool horLayout = ( w < h );
338 int maxhei = mFontPixelSize+4; 338 int maxhei = mFontPixelSize+4;
339 if ( horLayout ) 339 if ( horLayout )
340 maxhei += AGENDA_ICON_SIZE -4; 340 maxhei += AGENDA_ICON_SIZE -4;
341 bool small = ( h < maxhei ); 341 bool small = ( h < maxhei );
342 if ( ! small ) 342 if ( ! small )
343 paint->setFont(KOPrefs::instance()->mAgendaViewFont); 343 paint->setFont(KOPrefs::instance()->mAgendaViewFont);
344 else { 344 else {
345 QFont f = KOPrefs::instance()->mAgendaViewFont; 345 QFont f = KOPrefs::instance()->mAgendaViewFont;
346 f.setBold( false ); 346 f.setBold( false );
347 int fh = f.pointSize(); 347 int fh = f.pointSize();
348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; 348 nfh = (((float)height())/(float)(mFontPixelSize+4))*fh;
349 if ( nfh < 6 ) 349 if ( nfh < 6 )
350 nfh = 6; 350 nfh = 6;
351 f.setPointSize( nfh ); 351 f.setPointSize( nfh );
352 paint->setFont(f); 352 paint->setFont(f);
353 } 353 }
354 paint->fillRect ( x, yy, w, h, mBackgroundColor ); 354 paint->fillRect ( x, yy, w, h, mBackgroundColor );
355 static const QPixmap completedPxmp = SmallIcon("greenhook16"); 355 static const QPixmap completedPxmp = SmallIcon("greenhook16");
356 static const QPixmap overduePxmp = SmallIcon("redcross16"); 356 static const QPixmap overduePxmp = SmallIcon("redcross16");
357 if ( mIncidence->type() == "Todo" ) { 357 if ( mIncidence->type() == "Todo" ) {
358 Todo* tempTodo = static_cast<Todo*>(mIncidence); 358 Todo* tempTodo = static_cast<Todo*>(mIncidence);
359 int xx = pos().x()+(width()-completedPxmp.width()-3 ); 359 int xx = pos().x()+(width()-completedPxmp.width()-3 );
360 int yyy = yy+3; 360 int yyy = yy+3;
361 if ( tempTodo->isCompleted() ) 361 if ( tempTodo->isCompleted() )
362 paint->drawPixmap ( xx, yyy, completedPxmp ); 362 paint->drawPixmap ( xx, yyy, completedPxmp );
363 else { 363 else {
364 paint->drawPixmap ( xx, yyy, overduePxmp ); 364 paint->drawPixmap ( xx, yyy, overduePxmp );
365 365
366 } 366 }
367 } 367 }
368 bool addIcon = false; 368 bool addIcon = false;
369 if ( ! small || w > 3 * h || h > 3* w ) 369 if ( ! small || w > 3 * h || h > 3* w )
370 addIcon = updateIcons( paint, horLayout ); 370 addIcon = updateIcons( paint, horLayout );
371 371
372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); 372 qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0);
373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); 373 //qDebug("draw rect %d %d %d %d ",x, yy, w, h );
374 if ( ! small ) { 374 if ( ! small ) {
375 x += 3; yy += 3;w -= 6; h-= 5; 375 x += 3; yy += 3;w -= 6; h-= 5;
376 } else { 376 } else {
377 x += 2; yy += 1;w -= 4; h-= 4; 377 x += 2; yy += 1;w -= 4; h-= 4;
378 if ( nfh < 6.01 ) { 378 if ( nfh < 6.01 ) {
379 yy -= 2; 379 yy -= 2;
380 h += 4; 380 h += 4;
381 } 381 }
382 else 382 else
383 if ( nfh < h -2 ) 383 if ( nfh < h -2 )
384 ++yy; 384 ++yy;
385 } 385 }
386 int align; 386 int align;
387#ifndef DESKTOP_VERSION 387#ifndef DESKTOP_VERSION
388 align = ( AlignLeft|WordBreak|AlignTop); 388 align = ( AlignLeft|WordBreak|AlignTop);
389#else 389#else
390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); 390 align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop);
391#endif 391#endif
392 if ( addIcon ) { 392 if ( addIcon ) {
393 if ( ! horLayout ) { 393 if ( ! horLayout ) {
394 x += AGENDA_ICON_SIZE+3; 394 x += AGENDA_ICON_SIZE+3;
395 w -= (AGENDA_ICON_SIZE+3); 395 w -= (AGENDA_ICON_SIZE+3);
396 } 396 }
397 else { 397 else {
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
425
426 small = ( height() < 20 );
427
424 if ( ! small ) { 428 if ( ! small ) {
425 QFontMetrics fm ( paint->font() ); 429 QFontMetrics fm ( paint->font() );
426 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);
427 } 431 }
428 432
429 } 433 }
430 pa.end(); 434 pa.end();
431 435
432} 436}
433void KOAgendaItem::resizePixmap( int w , int h ) 437void KOAgendaItem::resizePixmap( int w , int h )
434{ 438{
435 paintPix()->resize( w, h ); 439 paintPix()->resize( w, h );
436 paintPixSel()->resize( w, h ); 440 paintPixSel()->resize( w, h );
437 441
438} 442}
439QPixmap * KOAgendaItem::paintPix() 443QPixmap * KOAgendaItem::paintPix()
440{ 444{
441 static QPixmap* mPaintPix = 0; 445 static QPixmap* mPaintPix = 0;
442 if ( ! mPaintPix ) 446 if ( ! mPaintPix )
443 mPaintPix = new QPixmap(1,1); 447 mPaintPix = new QPixmap(1,1);
444 return mPaintPix ; 448 return mPaintPix ;
445} 449}
446QPixmap * KOAgendaItem::paintPixAllday() 450QPixmap * KOAgendaItem::paintPixAllday()
447{ 451{
448 static QPixmap* mPaintPixA = 0; 452 static QPixmap* mPaintPixA = 0;
449 if ( ! mPaintPixA ) 453 if ( ! mPaintPixA )
450 mPaintPixA = new QPixmap(1,1); 454 mPaintPixA = new QPixmap(1,1);
451 return mPaintPixA ; 455 return mPaintPixA ;
452} 456}
453QPixmap * KOAgendaItem::paintPixSel() 457QPixmap * KOAgendaItem::paintPixSel()
454{ 458{
455 static QPixmap* mPaintPixSel = 0; 459 static QPixmap* mPaintPixSel = 0;
456 if ( ! mPaintPixSel ) 460 if ( ! mPaintPixSel )
457 mPaintPixSel = new QPixmap(1,1); 461 mPaintPixSel = new QPixmap(1,1);
458 return mPaintPixSel ; 462 return mPaintPixSel ;
459} 463}
460void KOAgendaItem::paintEvent ( QPaintEvent *e ) 464void KOAgendaItem::paintEvent ( QPaintEvent *e )
461{ 465{
462 466
463 if ( globalFlagBlockAgendaItemPaint ) 467 if ( globalFlagBlockAgendaItemPaint )
464 return; 468 return;
465 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) 469 if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 )
466 return; 470 return;
467 int yy; 471 int yy;
468 if ( mAllDay ) 472 if ( mAllDay )
469 yy = y(); 473 yy = y();
470 else 474 else
471 yy = mCellYTop * ( height() / cellHeight() ); 475 yy = mCellYTop * ( height() / cellHeight() );
472 int xx = x(); 476 int xx = x();
473 477
474 if ( xPaintCoord != xx || yPaintCoord != yy || 478 if ( xPaintCoord != xx || yPaintCoord != yy ||
475 wPaintCoord != width() || hPaintCoord != height()) { 479 wPaintCoord != width() || hPaintCoord != height()) {
476 xPaintCoord= xx; 480 xPaintCoord= xx;
477 yPaintCoord = yy; 481 yPaintCoord = yy;
478 wPaintCoord = width(); 482 wPaintCoord = width();
479 hPaintCoord = height(); 483 hPaintCoord = height();
480 globalFlagBlockAgendaItemUpdate = 0; 484 globalFlagBlockAgendaItemUpdate = 0;
481 paintMe( mSelected ); 485 paintMe( mSelected );
482 //qDebug("calling paintMe "); 486 //qDebug("calling paintMe ");
483 globalFlagBlockAgendaItemUpdate = 1; 487 globalFlagBlockAgendaItemUpdate = 1;
484 } 488 }
485 int rx, ry, rw, rh; 489 int rx, ry, rw, rh;
486 rx = e->rect().x(); 490 rx = e->rect().x();
487 ry = e->rect().y(); 491 ry = e->rect().y();
488 rw = e->rect().width(); 492 rw = e->rect().width();
489 rh = e->rect().height(); 493 rh = e->rect().height();
490 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); 494 //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height());
491 495
492 QPixmap* paintFrom ; 496 QPixmap* paintFrom ;
493 if ( mSelected ) { 497 if ( mSelected ) {
494 paintFrom = paintPixSel(); 498 paintFrom = paintPixSel();
495 } else { 499 } else {
496 if ( mAllDay ) 500 if ( mAllDay )
497 paintFrom = paintPixAllday(); 501 paintFrom = paintPixAllday();
498 else 502 else
499 paintFrom = paintPix(); 503 paintFrom = paintPix();
500 } 504 }
501 xx += rx; 505 xx += rx;
502 506
503 if ( xx < 0 ) { 507 if ( xx < 0 ) {
504 rw = rw + xx; 508 rw = rw + xx;
505 rx -= xx; 509 rx -= xx;
506 xx = 0; 510 xx = 0;
507 if ( rw <= 1 ) { 511 if ( rw <= 1 ) {
508 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1()); 512 //qDebug("KOAgendaItem::Width1 <= 1 (%d). Returning. %s",rw,mDisplayedText.latin1());
509 return; 513 return;
510 } 514 }
511 } 515 }
512 if ( paintFrom->width() < xx+rw ) { 516 if ( paintFrom->width() < xx+rw ) {
513 rw = paintFrom->width() - xx; 517 rw = paintFrom->width() - xx;
514 if ( rw <= 1 ) { 518 if ( rw <= 1 ) {
515 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() ); 519 //qDebug("KOAgendaItem::Width2 <= 1 (%d). Returning.%s ",rw,mDisplayedText.latin1() );
516 return; 520 return;
517 } 521 }
518 } 522 }
519 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh); 523 //qDebug("%d %d %d %d %d %d %d",rx, ry, paintFrom, xx ,yPaintCoord+ry, rw, rh);