author | zautrix <zautrix> | 2005-02-19 16:54:24 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-19 16:54:24 (UTC) |
commit | 11b5b0eb24cfb943df106f7ee97646955bec0fd3 (patch) (unidiff) | |
tree | ca62b4515977e0538fff0b1ee15a25bd8aed808e | |
parent | e15d171a0630656b6e4a66d6cab6a7d64a37434b (diff) | |
download | kdepimpi-11b5b0eb24cfb943df106f7ee97646955bec0fd3.zip kdepimpi-11b5b0eb24cfb943df106f7ee97646955bec0fd3.tar.gz kdepimpi-11b5b0eb24cfb943df106f7ee97646955bec0fd3.tar.bz2 |
fixiiii
-rw-r--r-- | korganizer/koagendaitem.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index cead612..7b29ce7 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -322,193 +322,196 @@ void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | |||
322 | int x, yy, w, h; | 322 | int x, yy, w, h; |
323 | float nfh = 7.0; | 323 | float nfh = 7.0; |
324 | x = pos().x(); w = width(); h = height (); | 324 | x = pos().x(); w = width(); h = height (); |
325 | if ( mAllDay ) | 325 | if ( mAllDay ) |
326 | yy = y(); | 326 | yy = y(); |
327 | else | 327 | else |
328 | yy = mCellYTop * ( height() / cellHeight() ); | 328 | yy = mCellYTop * ( height() / cellHeight() ); |
329 | xPaintCoord= x; | 329 | xPaintCoord= x; |
330 | yPaintCoord = yy; | 330 | yPaintCoord = yy; |
331 | wPaintCoord = width(); | 331 | wPaintCoord = width(); |
332 | hPaintCoord = height(); | 332 | hPaintCoord = height(); |
333 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 333 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
334 | if ( paint == 0 ) | 334 | if ( paint == 0 ) |
335 | paint = &pa; | 335 | paint = &pa; |
336 | bool horLayout = ( w < h ); | 336 | bool horLayout = ( w < h ); |
337 | int maxhei = mFontPixelSize+4; | 337 | int maxhei = mFontPixelSize+4; |
338 | if ( horLayout ) | 338 | if ( horLayout ) |
339 | maxhei += AGENDA_ICON_SIZE -4; | 339 | maxhei += AGENDA_ICON_SIZE -4; |
340 | bool small = ( h < maxhei ); | 340 | bool small = ( h < maxhei ); |
341 | if ( ! small ) | 341 | if ( ! small ) |
342 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 342 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
343 | else { | 343 | else { |
344 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 344 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
345 | f.setBold( false ); | 345 | f.setBold( false ); |
346 | int fh = f.pointSize(); | 346 | int fh = f.pointSize(); |
347 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 347 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
348 | if ( nfh < 6 ) | 348 | if ( nfh < 6 ) |
349 | nfh = 6; | 349 | nfh = 6; |
350 | f.setPointSize( nfh ); | 350 | f.setPointSize( nfh ); |
351 | paint->setFont(f); | 351 | paint->setFont(f); |
352 | } | 352 | } |
353 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 353 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
354 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 354 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
355 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 355 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
356 | if ( mIncidence->type() == "Todo" ) { | 356 | if ( mIncidence->type() == "Todo" ) { |
357 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 357 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
358 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 358 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
359 | int yyy = yy+3; | 359 | int yyy = yy+3; |
360 | if ( tempTodo->isCompleted() ) | 360 | if ( tempTodo->isCompleted() ) |
361 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 361 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
362 | else { | 362 | else { |
363 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 363 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
364 | 364 | ||
365 | } | 365 | } |
366 | } | 366 | } |
367 | bool addIcon = false; | 367 | bool addIcon = false; |
368 | if ( ! small || w > 3 * h || h > 3* w ) | 368 | if ( ! small || w > 3 * h || h > 3* w ) |
369 | addIcon = updateIcons( paint, horLayout ); | 369 | addIcon = updateIcons( paint, horLayout ); |
370 | 370 | ||
371 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 371 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
372 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 372 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
373 | if ( ! small ) { | 373 | if ( ! small ) { |
374 | x += 3; yy += 3;w -= 6; h-= 5; | 374 | x += 3; yy += 3;w -= 6; h-= 5; |
375 | } else { | 375 | } else { |
376 | x += 2; yy += 1;w -= 4; h-= 4; | 376 | x += 2; yy += 1;w -= 4; h-= 4; |
377 | if ( nfh < 6.01 ) { | 377 | if ( nfh < 6.01 ) { |
378 | yy -= 2; | 378 | yy -= 2; |
379 | h += 4; | 379 | h += 4; |
380 | } | 380 | } |
381 | else | 381 | else |
382 | if ( nfh < h -2 ) | 382 | if ( nfh < h -2 ) |
383 | ++yy; | 383 | ++yy; |
384 | } | 384 | } |
385 | int align; | 385 | int align; |
386 | #ifndef DESKTOP_VERSION | 386 | #ifndef DESKTOP_VERSION |
387 | align = ( AlignLeft|WordBreak|AlignTop); | 387 | align = ( AlignLeft|WordBreak|AlignTop); |
388 | #else | 388 | #else |
389 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 389 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
390 | #endif | 390 | #endif |
391 | if ( addIcon ) { | 391 | if ( addIcon ) { |
392 | if ( ! horLayout ) { | 392 | if ( ! horLayout ) { |
393 | x += AGENDA_ICON_SIZE+3; | 393 | x += AGENDA_ICON_SIZE+3; |
394 | w -= (AGENDA_ICON_SIZE+3); | 394 | w -= (AGENDA_ICON_SIZE+3); |
395 | } | 395 | } |
396 | else { | 396 | else { |
397 | yy+= AGENDA_ICON_SIZE+2; | 397 | yy+= AGENDA_ICON_SIZE+2; |
398 | h -=(AGENDA_ICON_SIZE+3); | 398 | h -=(AGENDA_ICON_SIZE+3); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 401 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
402 | if ( colsum < 250 ) | 402 | if ( colsum < 250 ) |
403 | paint->setPen ( white); | 403 | paint->setPen ( white); |
404 | if ( x < 0 ) { | 404 | if ( x < 0 ) { |
405 | w = w+x-3; | 405 | w = w+x-3; |
406 | x = 3; | 406 | x = 3; |
407 | if ( w > parentWidget()->width() ){ | 407 | if ( w > parentWidget()->width() ){ |
408 | w = parentWidget()->width() - 6; | 408 | w = parentWidget()->width() - 6; |
409 | #ifndef DESKTOP_VERSION | 409 | #ifndef DESKTOP_VERSION |
410 | align = ( AlignCenter|WordBreak); | 410 | align = ( AlignCenter|WordBreak); |
411 | #else | 411 | #else |
412 | align = ( AlignCenter|BreakAnywhere|WordBreak); | 412 | align = ( AlignCenter|BreakAnywhere|WordBreak); |
413 | #endif | 413 | #endif |
414 | 414 | ||
415 | } | 415 | } |
416 | } | 416 | } |
417 | QRect dr; | 417 | QRect dr; |
418 | if ( w + x > parentWidget()->width() ) | ||
419 | w = parentWidget()->width()-x; | ||
418 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 420 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
421 | //qDebug("%d %d %d %d ", x, yy, w, h ); | ||
419 | if ( mIncidence->cancelled() ){ | 422 | if ( mIncidence->cancelled() ){ |
420 | if ( ! small ) { | 423 | if ( ! small ) { |
421 | QFontMetrics fm ( paint->font() ); | 424 | QFontMetrics fm ( paint->font() ); |
422 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 425 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
423 | } | 426 | } |
424 | 427 | ||
425 | } | 428 | } |
426 | pa.end(); | 429 | pa.end(); |
427 | 430 | ||
428 | } | 431 | } |
429 | void KOAgendaItem::resizePixmap( int w , int h ) | 432 | void KOAgendaItem::resizePixmap( int w , int h ) |
430 | { | 433 | { |
431 | paintPix()->resize( w, h ); | 434 | paintPix()->resize( w, h ); |
432 | paintPixSel()->resize( w, h ); | 435 | paintPixSel()->resize( w, h ); |
433 | 436 | ||
434 | } | 437 | } |
435 | QPixmap * KOAgendaItem::paintPix() | 438 | QPixmap * KOAgendaItem::paintPix() |
436 | { | 439 | { |
437 | static QPixmap* mPaintPix = 0; | 440 | static QPixmap* mPaintPix = 0; |
438 | if ( ! mPaintPix ) | 441 | if ( ! mPaintPix ) |
439 | mPaintPix = new QPixmap(1,1); | 442 | mPaintPix = new QPixmap(1,1); |
440 | return mPaintPix ; | 443 | return mPaintPix ; |
441 | } | 444 | } |
442 | QPixmap * KOAgendaItem::paintPixAllday() | 445 | QPixmap * KOAgendaItem::paintPixAllday() |
443 | { | 446 | { |
444 | static QPixmap* mPaintPixA = 0; | 447 | static QPixmap* mPaintPixA = 0; |
445 | if ( ! mPaintPixA ) | 448 | if ( ! mPaintPixA ) |
446 | mPaintPixA = new QPixmap(1,1); | 449 | mPaintPixA = new QPixmap(1,1); |
447 | return mPaintPixA ; | 450 | return mPaintPixA ; |
448 | } | 451 | } |
449 | QPixmap * KOAgendaItem::paintPixSel() | 452 | QPixmap * KOAgendaItem::paintPixSel() |
450 | { | 453 | { |
451 | static QPixmap* mPaintPixSel = 0; | 454 | static QPixmap* mPaintPixSel = 0; |
452 | if ( ! mPaintPixSel ) | 455 | if ( ! mPaintPixSel ) |
453 | mPaintPixSel = new QPixmap(1,1); | 456 | mPaintPixSel = new QPixmap(1,1); |
454 | return mPaintPixSel ; | 457 | return mPaintPixSel ; |
455 | } | 458 | } |
456 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 459 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
457 | { | 460 | { |
458 | 461 | ||
459 | if ( globalFlagBlockAgendaItemPaint ) | 462 | if ( globalFlagBlockAgendaItemPaint ) |
460 | return; | 463 | return; |
461 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 464 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
462 | return; | 465 | return; |
463 | int yy; | 466 | int yy; |
464 | if ( mAllDay ) | 467 | if ( mAllDay ) |
465 | yy = y(); | 468 | yy = y(); |
466 | else | 469 | else |
467 | yy = mCellYTop * ( height() / cellHeight() ); | 470 | yy = mCellYTop * ( height() / cellHeight() ); |
468 | int xx = x(); | 471 | int xx = x(); |
469 | if ( xPaintCoord != xx || yPaintCoord != yy || | 472 | if ( xPaintCoord != xx || yPaintCoord != yy || |
470 | wPaintCoord != width() || hPaintCoord != height()) { | 473 | wPaintCoord != width() || hPaintCoord != height()) { |
471 | xPaintCoord= xx; | 474 | xPaintCoord= xx; |
472 | yPaintCoord = yy; | 475 | yPaintCoord = yy; |
473 | wPaintCoord = width(); | 476 | wPaintCoord = width(); |
474 | hPaintCoord = height(); | 477 | hPaintCoord = height(); |
475 | globalFlagBlockAgendaItemUpdate = 0; | 478 | globalFlagBlockAgendaItemUpdate = 0; |
476 | paintMe( mSelected ); | 479 | paintMe( mSelected ); |
477 | //qDebug("calling paintMe "); | 480 | //qDebug("calling paintMe "); |
478 | globalFlagBlockAgendaItemUpdate = 1; | 481 | globalFlagBlockAgendaItemUpdate = 1; |
479 | } | 482 | } |
480 | int rx, ry, rw, rh; | 483 | int rx, ry, rw, rh; |
481 | rx = e->rect().x(); | 484 | rx = e->rect().x(); |
482 | ry = e->rect().y(); | 485 | ry = e->rect().y(); |
483 | rw = e->rect().width(); | 486 | rw = e->rect().width(); |
484 | rh = e->rect().height(); | 487 | rh = e->rect().height(); |
485 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); | 488 | //qDebug(" paintevent %s %d %d %d %d", mIncidence->summary().latin1(), x(), yy, width(), height()); |
486 | 489 | ||
487 | QPixmap* paintFrom ; | 490 | QPixmap* paintFrom ; |
488 | if ( mSelected ) { | 491 | if ( mSelected ) { |
489 | paintFrom = paintPixSel(); | 492 | paintFrom = paintPixSel(); |
490 | } else { | 493 | } else { |
491 | if ( mAllDay ) | 494 | if ( mAllDay ) |
492 | paintFrom = paintPixAllday(); | 495 | paintFrom = paintPixAllday(); |
493 | else | 496 | else |
494 | paintFrom = paintPix(); | 497 | paintFrom = paintPix(); |
495 | } | 498 | } |
496 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); | 499 | bitBlt (this, rx, ry, paintFrom, x()+rx ,yPaintCoord+ry, rw, rh ,CopyROP); |
497 | } | 500 | } |
498 | void KOAgendaItem::computeText() | 501 | void KOAgendaItem::computeText() |
499 | { | 502 | { |
500 | 503 | ||
501 | mDisplayedText = mIncidence->summary(); | 504 | mDisplayedText = mIncidence->summary(); |
502 | if ( (mIncidence->type() == "Todo") ) { | 505 | if ( (mIncidence->type() == "Todo") ) { |
503 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { | 506 | if ( static_cast<Todo*>(mIncidence)->hasDueDate() ) { |
504 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) | 507 | if ( static_cast<Todo*>(mIncidence)->dtDue().date() < QDate::currentDate() ) |
505 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; | 508 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatDate((static_cast<Todo*>(mIncidence))->dtDue().date(), true)+")"; |
506 | else if ( !(mIncidence->doesFloat())) | 509 | else if ( !(mIncidence->doesFloat())) |
507 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; | 510 | mDisplayedText += i18n(" (") +KGlobal::locale()->formatTime((static_cast<Todo*>(mIncidence))->dtDue().time())+")"; |
508 | } | 511 | } |
509 | } else { | 512 | } else { |
510 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) | 513 | if ( !(mIncidence->doesFloat()) && KOPrefs::instance()->mShowTimeInAgenda) |
511 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; | 514 | mDisplayedText += ": " +KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtStart().time()) + "-" + KGlobal::locale()->formatTime((static_cast<Event*>(mIncidence))->dtEnd().time()) ; |
512 | 515 | ||
513 | if ( mAllDay ) { | 516 | if ( mAllDay ) { |
514 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { | 517 | if ( mIncidence->dtStart().date().addDays(3) < mIncidence->dtEnd().date() ) { |