author | zautrix <zautrix> | 2005-06-14 18:15:28 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-14 18:15:28 (UTC) |
commit | d9df54411b01cabaf51fcae62b91f227f7eff5f5 (patch) (unidiff) | |
tree | 1b996ed8635d9cb7ecc03d735b46f03048fb4d95 | |
parent | 05f27a0fe3d9d5455439f0efd683321d8c247482 (diff) | |
download | kdepimpi-d9df54411b01cabaf51fcae62b91f227f7eff5f5.zip kdepimpi-d9df54411b01cabaf51fcae62b91f227f7eff5f5.tar.gz kdepimpi-d9df54411b01cabaf51fcae62b91f227f7eff5f5.tar.bz2 |
fix
-rw-r--r-- | korganizer/koagendaitem.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/korganizer/koagendaitem.cpp b/korganizer/koagendaitem.cpp index c7bc6eb..1be0aca 100644 --- a/korganizer/koagendaitem.cpp +++ b/korganizer/koagendaitem.cpp | |||
@@ -249,257 +249,258 @@ bool KOAgendaItem::updateIcons(QPainter * p, bool horLayout) | |||
249 | ++xOff; | 249 | ++xOff; |
250 | else | 250 | else |
251 | ++yOff; | 251 | ++yOff; |
252 | 252 | ||
253 | } | 253 | } |
254 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); | 254 | p->fillRect ( xOff*( 1 +AGENDA_ICON_SIZE )+x, yOff*( 1 +AGENDA_ICON_SIZE)+y, AGENDA_ICON_SIZE, AGENDA_ICON_SIZE, darkYellow ); |
255 | if ( horLayout ) | 255 | if ( horLayout ) |
256 | ++xOff; | 256 | ++xOff; |
257 | else | 257 | else |
258 | ++yOff; | 258 | ++yOff; |
259 | 259 | ||
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | return ( yOff || xOff ); | 263 | return ( yOff || xOff ); |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void KOAgendaItem::select(bool selected) | 267 | void KOAgendaItem::select(bool selected) |
268 | { | 268 | { |
269 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); | 269 | //qDebug("select %d %d",firstMultiItem(), nextMultiItem() ); |
270 | if (mSelected == selected) return; | 270 | if (mSelected == selected) return; |
271 | mSelected = selected; | 271 | mSelected = selected; |
272 | if ( ! isVisible() ) | 272 | if ( ! isVisible() ) |
273 | return; | 273 | return; |
274 | if ( firstMultiItem() ) | 274 | if ( firstMultiItem() ) |
275 | firstMultiItem()->select( selected ); | 275 | firstMultiItem()->select( selected ); |
276 | if ( !firstMultiItem() && nextMultiItem() ) { | 276 | if ( !firstMultiItem() && nextMultiItem() ) { |
277 | KOAgendaItem * placeItem = nextMultiItem(); | 277 | KOAgendaItem * placeItem = nextMultiItem(); |
278 | while ( placeItem ) { | 278 | while ( placeItem ) { |
279 | placeItem->select( selected ); | 279 | placeItem->select( selected ); |
280 | placeItem = placeItem->nextMultiItem(); | 280 | placeItem = placeItem->nextMultiItem(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | globalFlagBlockAgendaItemUpdate = 0; | 283 | globalFlagBlockAgendaItemUpdate = 0; |
284 | paintMe( selected ); | 284 | paintMe( selected ); |
285 | globalFlagBlockAgendaItemUpdate = 1; | 285 | globalFlagBlockAgendaItemUpdate = 1; |
286 | repaint( false ); | 286 | repaint( false ); |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | /* | 290 | /* |
291 | The eventFilter has to filter the mouse events of the agenda item childs. The | 291 | The eventFilter has to filter the mouse events of the agenda item childs. The |
292 | events are fed into the event handling method of KOAgendaItem. This allows the | 292 | events are fed into the event handling method of KOAgendaItem. This allows the |
293 | KOAgenda to handle the KOAgendaItems by using an eventFilter. | 293 | KOAgenda to handle the KOAgendaItems by using an eventFilter. |
294 | */ | 294 | */ |
295 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) | 295 | bool KOAgendaItem::eventFilter ( QObject *object, QEvent *e ) |
296 | { | 296 | { |
297 | if (e->type() == QEvent::MouseButtonPress || | 297 | if (e->type() == QEvent::MouseButtonPress || |
298 | e->type() == QEvent::MouseButtonDblClick || | 298 | e->type() == QEvent::MouseButtonDblClick || |
299 | e->type() == QEvent::MouseButtonRelease || | 299 | e->type() == QEvent::MouseButtonRelease || |
300 | e->type() == QEvent::MouseMove) { | 300 | e->type() == QEvent::MouseMove) { |
301 | QMouseEvent *me = (QMouseEvent *)e; | 301 | QMouseEvent *me = (QMouseEvent *)e; |
302 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> | 302 | QPoint itemPos = this->mapFromGlobal(((QWidget *)object)-> |
303 | mapToGlobal(me->pos())); | 303 | mapToGlobal(me->pos())); |
304 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); | 304 | QMouseEvent returnEvent (e->type(),itemPos,me->button(),me->state()); |
305 | return event(&returnEvent); | 305 | return event(&returnEvent); |
306 | } else { | 306 | } else { |
307 | return false; | 307 | return false; |
308 | } | 308 | } |
309 | } | 309 | } |
310 | void KOAgendaItem::repaintMe( ) | 310 | void KOAgendaItem::repaintMe( ) |
311 | { | 311 | { |
312 | paintMe ( mSelected ); | 312 | paintMe ( mSelected ); |
313 | } | 313 | } |
314 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) | 314 | void KOAgendaItem::paintMe( bool selected, QPainter* paint ) |
315 | { | 315 | { |
316 | if ( globalFlagBlockAgendaItemUpdate && ! selected) | 316 | if ( globalFlagBlockAgendaItemUpdate && ! selected) |
317 | return; | 317 | return; |
318 | QPainter pa; | 318 | QPainter pa; |
319 | 319 | ||
320 | if ( mSelected ) { | 320 | if ( mSelected ) { |
321 | pa.begin( paintPixSel() ); | 321 | pa.begin( paintPixSel() ); |
322 | } else { | 322 | } else { |
323 | if ( mAllDay ) | 323 | if ( mAllDay ) |
324 | pa.begin( paintPixAllday() ); | 324 | pa.begin( paintPixAllday() ); |
325 | else | 325 | else |
326 | pa.begin( paintPix() ); | 326 | pa.begin( paintPix() ); |
327 | } | 327 | } |
328 | int x, yy, w, h; | 328 | int x, yy, w, h; |
329 | float nfh = 7.0; | 329 | float nfh = 7.0; |
330 | x = pos().x(); w = width(); h = height (); | 330 | x = pos().x(); w = width(); h = height (); |
331 | if ( mAllDay ) | 331 | if ( mAllDay ) |
332 | yy = y(); | 332 | yy = y(); |
333 | else | 333 | else |
334 | yy = mCellYTop * ( height() / cellHeight() ); | 334 | yy = mCellYTop * ( height() / cellHeight() ); |
335 | xPaintCoord= x; | 335 | xPaintCoord= x; |
336 | yPaintCoord = yy; | 336 | yPaintCoord = yy; |
337 | wPaintCoord = width(); | 337 | wPaintCoord = width(); |
338 | hPaintCoord = height(); | 338 | hPaintCoord = height(); |
339 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); | 339 | //qDebug("paintMe %s %d %d %d %d",incidence()->summary().latin1(), x, yy, width(), height()); |
340 | if ( paint == 0 ) | 340 | if ( paint == 0 ) |
341 | paint = &pa; | 341 | paint = &pa; |
342 | bool horLayout = ( w < h ); | 342 | bool horLayout = ( w < h ); |
343 | int maxhei = mFontPixelSize+4; | 343 | int maxhei = mFontPixelSize+4; |
344 | if ( horLayout ) | 344 | if ( horLayout ) |
345 | maxhei += AGENDA_ICON_SIZE -4; | 345 | maxhei += AGENDA_ICON_SIZE -4; |
346 | bool small = ( h < maxhei ); | 346 | bool small = ( h < maxhei ); |
347 | if ( ! small ) | 347 | if ( ! small ) |
348 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); | 348 | paint->setFont(KOPrefs::instance()->mAgendaViewFont); |
349 | else { | 349 | else { |
350 | QFont f = KOPrefs::instance()->mAgendaViewFont; | 350 | QFont f = KOPrefs::instance()->mAgendaViewFont; |
351 | f.setBold( false ); | 351 | f.setBold( false ); |
352 | int fh = f.pointSize(); | 352 | int fh = f.pointSize(); |
353 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; | 353 | nfh = (((float)height())/(float)(mFontPixelSize+4))*fh; |
354 | if ( nfh < 6 ) | 354 | if ( nfh < 6 ) |
355 | nfh = 6; | 355 | nfh = 6; |
356 | f.setPointSize( nfh ); | 356 | f.setPointSize( nfh ); |
357 | paint->setFont(f); | 357 | paint->setFont(f); |
358 | } | 358 | } |
359 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); | 359 | paint->fillRect ( x, yy, w, h, mBackgroundColor ); |
360 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); | 360 | static const QPixmap completedPxmp = SmallIcon("greenhook16"); |
361 | static const QPixmap overduePxmp = SmallIcon("redcross16"); | 361 | static const QPixmap overduePxmp = SmallIcon("redcross16"); |
362 | if ( mIncidence->typeID() == todoID ) { | 362 | if ( mIncidence->typeID() == todoID ) { |
363 | Todo* tempTodo = static_cast<Todo*>(mIncidence); | 363 | Todo* tempTodo = static_cast<Todo*>(mIncidence); |
364 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); | 364 | int xx = pos().x()+(width()-completedPxmp.width()-3 ); |
365 | int yyy = yy+3; | 365 | int yyy = yy+3; |
366 | if ( tempTodo->isCompleted() ) | 366 | if ( tempTodo->isCompleted() ) |
367 | paint->drawPixmap ( xx, yyy, completedPxmp ); | 367 | paint->drawPixmap ( xx, yyy, completedPxmp ); |
368 | else { | 368 | else { |
369 | paint->drawPixmap ( xx, yyy, overduePxmp ); | 369 | paint->drawPixmap ( xx, yyy, overduePxmp ); |
370 | 370 | ||
371 | } | 371 | } |
372 | } | 372 | } |
373 | bool addIcon = false; | 373 | bool addIcon = false; |
374 | if ( ! small || w > 3 * h || h > 3* w ) | 374 | if ( ! small || w > 3 * h || h > 3* w ) |
375 | addIcon = updateIcons( paint, horLayout ); | 375 | addIcon = updateIcons( paint, horLayout ); |
376 | 376 | ||
377 | qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); | 377 | //qDrawShadePanel (paint, x, yy, w, h, mColorGroup, selected , 2, 0); |
378 | qDrawWinPanel (paint, x, yy, w, h, mColorGroup, selected ,0); | ||
378 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); | 379 | //qDebug("draw rect %d %d %d %d ",x, yy, w, h ); |
379 | if ( ! small ) { | 380 | if ( ! small ) { |
380 | x += 3; yy += 3;w -= 6; h-= 5; | 381 | x += 3; yy += 3;w -= 6; h-= 5; |
381 | } else { | 382 | } else { |
382 | x += 2; yy += 1;w -= 4; h-= 4; | 383 | x += 2; yy += 1;w -= 4; h-= 4; |
383 | if ( nfh < 6.01 ) { | 384 | if ( nfh < 6.01 ) { |
384 | yy -= 2; | 385 | yy -= 2; |
385 | h += 4; | 386 | h += 4; |
386 | } | 387 | } |
387 | else | 388 | else |
388 | if ( nfh < h -2 ) | 389 | if ( nfh < h -2 ) |
389 | ++yy; | 390 | ++yy; |
390 | } | 391 | } |
391 | int align; | 392 | int align; |
392 | #ifndef DESKTOP_VERSION | 393 | #ifndef DESKTOP_VERSION |
393 | align = ( AlignLeft|WordBreak|AlignTop); | 394 | align = ( AlignLeft|WordBreak|AlignTop); |
394 | #else | 395 | #else |
395 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); | 396 | align = ( AlignLeft|BreakAnywhere|WordBreak|AlignTop); |
396 | #endif | 397 | #endif |
397 | if ( addIcon ) { | 398 | if ( addIcon ) { |
398 | if ( ! horLayout ) { | 399 | if ( ! horLayout ) { |
399 | x += AGENDA_ICON_SIZE+3; | 400 | x += AGENDA_ICON_SIZE+3; |
400 | w -= (AGENDA_ICON_SIZE+3); | 401 | w -= (AGENDA_ICON_SIZE+3); |
401 | } | 402 | } |
402 | else { | 403 | else { |
403 | yy+= AGENDA_ICON_SIZE+2; | 404 | yy+= AGENDA_ICON_SIZE+2; |
404 | h -=(AGENDA_ICON_SIZE+3); | 405 | h -=(AGENDA_ICON_SIZE+3); |
405 | } | 406 | } |
406 | } | 407 | } |
407 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); | 408 | int colsum = mBackgroundColor.red() + mBackgroundColor.green() + mBackgroundColor.blue(); |
408 | if ( colsum < 250 ) | 409 | if ( colsum < 250 ) |
409 | paint->setPen ( white); | 410 | paint->setPen ( white); |
410 | if ( x < 0 ) { | 411 | if ( x < 0 ) { |
411 | w = w+x-3; | 412 | w = w+x-3; |
412 | x = 3; | 413 | x = 3; |
413 | if ( w > parentWidget()->width() ){ | 414 | if ( w > parentWidget()->width() ){ |
414 | w = parentWidget()->width() - 6; | 415 | w = parentWidget()->width() - 6; |
415 | #ifndef DESKTOP_VERSION | 416 | #ifndef DESKTOP_VERSION |
416 | align = ( AlignHCenter|WordBreak|AlignTop); | 417 | align = ( AlignHCenter|WordBreak|AlignTop); |
417 | #else | 418 | #else |
418 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); | 419 | align = ( AlignHCenter|BreakAnywhere|WordBreak|AlignTop); |
419 | #endif | 420 | #endif |
420 | 421 | ||
421 | } | 422 | } |
422 | } | 423 | } |
423 | QRect dr; | 424 | QRect dr; |
424 | if ( w + x > parentWidget()->width() ) | 425 | if ( w + x > parentWidget()->width() ) |
425 | w = parentWidget()->width()-x; | 426 | w = parentWidget()->width()-x; |
426 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); | 427 | paint->drawText ( x, yy, w, h, align, mDisplayedText, -1, &dr ); |
427 | //qDebug("%d %d %d %d ", x, yy, w, h ); | 428 | //qDebug("%d %d %d %d ", x, yy, w, h ); |
428 | if ( mIncidence->cancelled() ){ | 429 | if ( mIncidence->cancelled() ){ |
429 | 430 | ||
430 | 431 | ||
431 | small = ( height() < 20 ); | 432 | small = ( height() < 20 ); |
432 | 433 | ||
433 | if ( ! small ) { | 434 | if ( ! small ) { |
434 | QFontMetrics fm ( paint->font() ); | 435 | QFontMetrics fm ( paint->font() ); |
435 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); | 436 | paint->drawLine(dr.left(), yy+fm.height()/2, dr.right()-2, yy+fm.height()/2); |
436 | } | 437 | } |
437 | 438 | ||
438 | } | 439 | } |
439 | pa.end(); | 440 | pa.end(); |
440 | 441 | ||
441 | } | 442 | } |
442 | void KOAgendaItem::resizePixmap( int w , int h ) | 443 | void KOAgendaItem::resizePixmap( int w , int h ) |
443 | { | 444 | { |
444 | paintPix()->resize( w, h ); | 445 | paintPix()->resize( w, h ); |
445 | paintPixSel()->resize( w, h ); | 446 | paintPixSel()->resize( w, h ); |
446 | 447 | ||
447 | } | 448 | } |
448 | QPixmap * KOAgendaItem::paintPix() | 449 | QPixmap * KOAgendaItem::paintPix() |
449 | { | 450 | { |
450 | static QPixmap* mPaintPix = 0; | 451 | static QPixmap* mPaintPix = 0; |
451 | if ( ! mPaintPix ) { | 452 | if ( ! mPaintPix ) { |
452 | int w = QApplication::desktop()->width(); | 453 | int w = QApplication::desktop()->width(); |
453 | int h = QApplication::desktop()->height(); | 454 | int h = QApplication::desktop()->height(); |
454 | mPaintPix = new QPixmap(w,h); | 455 | mPaintPix = new QPixmap(w,h); |
455 | } | 456 | } |
456 | return mPaintPix ; | 457 | return mPaintPix ; |
457 | } | 458 | } |
458 | QPixmap * KOAgendaItem::paintPixAllday() | 459 | QPixmap * KOAgendaItem::paintPixAllday() |
459 | { | 460 | { |
460 | static QPixmap* mPaintPixA = 0; | 461 | static QPixmap* mPaintPixA = 0; |
461 | if ( ! mPaintPixA ) { | 462 | if ( ! mPaintPixA ) { |
462 | int w = QApplication::desktop()->width(); | 463 | int w = QApplication::desktop()->width(); |
463 | int h = QApplication::desktop()->height()/3; | 464 | int h = QApplication::desktop()->height()/3; |
464 | mPaintPixA = new QPixmap(w,h); | 465 | mPaintPixA = new QPixmap(w,h); |
465 | } | 466 | } |
466 | return mPaintPixA ; | 467 | return mPaintPixA ; |
467 | } | 468 | } |
468 | QPixmap * KOAgendaItem::paintPixSel() | 469 | QPixmap * KOAgendaItem::paintPixSel() |
469 | { | 470 | { |
470 | static QPixmap* mPaintPixSel = 0; | 471 | static QPixmap* mPaintPixSel = 0; |
471 | if ( ! mPaintPixSel ) { | 472 | if ( ! mPaintPixSel ) { |
472 | int w = QApplication::desktop()->width(); | 473 | int w = QApplication::desktop()->width(); |
473 | int h = QApplication::desktop()->height(); | 474 | int h = QApplication::desktop()->height(); |
474 | mPaintPixSel = new QPixmap(w,h); | 475 | mPaintPixSel = new QPixmap(w,h); |
475 | } | 476 | } |
476 | return mPaintPixSel ; | 477 | return mPaintPixSel ; |
477 | } | 478 | } |
478 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) | 479 | void KOAgendaItem::paintEvent ( QPaintEvent *e ) |
479 | { | 480 | { |
480 | 481 | ||
481 | if ( globalFlagBlockAgendaItemPaint ) | 482 | if ( globalFlagBlockAgendaItemPaint ) |
482 | return; | 483 | return; |
483 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) | 484 | if ( globalFlagBlockAgenda > 0 && globalFlagBlockAgenda < 5 ) |
484 | return; | 485 | return; |
485 | int yy; | 486 | int yy; |
486 | if ( mAllDay ) | 487 | if ( mAllDay ) |
487 | yy = y(); | 488 | yy = y(); |
488 | else | 489 | else |
489 | yy = mCellYTop * ( height() / cellHeight() ); | 490 | yy = mCellYTop * ( height() / cellHeight() ); |
490 | int xx = x(); | 491 | int xx = x(); |
491 | 492 | ||
492 | if ( xPaintCoord != xx || yPaintCoord != yy || | 493 | if ( xPaintCoord != xx || yPaintCoord != yy || |
493 | wPaintCoord != width() || hPaintCoord != height()) { | 494 | wPaintCoord != width() || hPaintCoord != height()) { |
494 | xPaintCoord= xx; | 495 | xPaintCoord= xx; |
495 | yPaintCoord = yy; | 496 | yPaintCoord = yy; |
496 | wPaintCoord = width(); | 497 | wPaintCoord = width(); |
497 | hPaintCoord = height(); | 498 | hPaintCoord = height(); |
498 | globalFlagBlockAgendaItemUpdate = 0; | 499 | globalFlagBlockAgendaItemUpdate = 0; |
499 | paintMe( mSelected ); | 500 | paintMe( mSelected ); |
500 | //qDebug("calling paintMe "); | 501 | //qDebug("calling paintMe "); |
501 | globalFlagBlockAgendaItemUpdate = 1; | 502 | globalFlagBlockAgendaItemUpdate = 1; |
502 | } | 503 | } |
503 | int rx, ry, rw, rh; | 504 | int rx, ry, rw, rh; |
504 | rx = e->rect().x(); | 505 | rx = e->rect().x(); |
505 | ry = e->rect().y(); | 506 | ry = e->rect().y(); |