-rw-r--r-- | korganizer/komonthview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index eea9a4d..4aeb20c 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -344,1537 +344,1541 @@ void MonthViewItem::paint(QPainter *p) | |||
344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; | 344 | //int y = 3;//(height() - mRecurPixmap.height()) /2; |
345 | int size = PIXMAP_SIZE; | 345 | int size = PIXMAP_SIZE; |
346 | if ( QApplication::desktop()->width() < 300 ) | 346 | if ( QApplication::desktop()->width() < 300 ) |
347 | size = 3; | 347 | size = 3; |
348 | int y = (heihei - size -1 ) /2; | 348 | int y = (heihei - size -1 ) /2; |
349 | 349 | ||
350 | if ( mIncidence->calID() > 1 ) { | 350 | if ( mIncidence->calID() > 1 ) { |
351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); | 351 | p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); |
352 | p->drawRect ( x, y-2,size,size+4); | 352 | p->drawRect ( x, y-2,size,size+4); |
353 | x += size + 1; | 353 | x += size + 1; |
354 | } | 354 | } |
355 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 355 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
356 | if ( mInfo ) { | 356 | if ( mInfo ) { |
357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 357 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
358 | x += size + 1; | 358 | x += size + 1; |
359 | } | 359 | } |
360 | if ( mRecur ) { | 360 | if ( mRecur ) { |
361 | p->fillRect ( x, y,size,size, Qt::blue ); | 361 | p->fillRect ( x, y,size,size, Qt::blue ); |
362 | x += size + 1; | 362 | x += size + 1; |
363 | } | 363 | } |
364 | if ( mAlarm ) { | 364 | if ( mAlarm ) { |
365 | p->fillRect ( x, y,size,size, Qt::red ); | 365 | p->fillRect ( x, y,size,size, Qt::red ); |
366 | x += size + 1; | 366 | x += size + 1; |
367 | } | 367 | } |
368 | if ( mReply ) { | 368 | if ( mReply ) { |
369 | p->fillRect ( x, y,size,size, Qt::yellow ); | 369 | p->fillRect ( x, y,size,size, Qt::yellow ); |
370 | x += size + 1; | 370 | x += size + 1; |
371 | } | 371 | } |
372 | } | 372 | } |
373 | 373 | ||
374 | 374 | ||
375 | 375 | ||
376 | 376 | ||
377 | if ( sel ) p->setPen( Qt::white ); | 377 | if ( sel ) p->setPen( Qt::white ); |
378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); | 378 | else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); |
379 | 379 | ||
380 | #if 0 | 380 | #if 0 |
381 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 381 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 382 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
383 | #endif | 383 | #endif |
384 | QColor textColor = p->pen().color(); | 384 | QColor textColor = p->pen().color(); |
385 | 385 | ||
386 | 386 | ||
387 | if ( mMultiday ) { | 387 | if ( mMultiday ) { |
388 | int yyy = y+(size/2); | 388 | int yyy = y+(size/2); |
389 | int sizeM = size+2; | 389 | int sizeM = size+2; |
390 | p->setBrush( QBrush( textColor ) ); | 390 | p->setBrush( QBrush( textColor ) ); |
391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; | 391 | p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; |
392 | if ( mMultiday == 2 || mMultiday == 3 ) { | 392 | if ( mMultiday == 2 || mMultiday == 3 ) { |
393 | QPointArray pa ( 3 ); | 393 | QPointArray pa ( 3 ); |
394 | pa.setPoint (0, x, yyy ); | 394 | pa.setPoint (0, x, yyy ); |
395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); | 395 | pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); |
396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); | 396 | pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); |
397 | p->drawPolygon( pa ); | 397 | p->drawPolygon( pa ); |
398 | } | 398 | } |
399 | if ( mMultiday == 2 || mMultiday == 1 ) { | 399 | if ( mMultiday == 2 || mMultiday == 1 ) { |
400 | QPointArray pa ( 3 ); | 400 | QPointArray pa ( 3 ); |
401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); | 401 | pa.setPoint (0, x+sizeM +sizeM/2, yyy ); |
402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); | 402 | pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); |
403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); | 403 | pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); |
404 | p->drawPolygon( pa ); | 404 | p->drawPolygon( pa ); |
405 | } | 405 | } |
406 | if ( mMultiday == 1 ) { | 406 | if ( mMultiday == 1 ) { |
407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 407 | // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); | 408 | p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); |
409 | } | 409 | } |
410 | if ( mMultiday == 3 ) { | 410 | if ( mMultiday == 3 ) { |
411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); | 411 | // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); |
412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); | 412 | p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); |
413 | 413 | ||
414 | } | 414 | } |
415 | x += sizeM/2 + 1; | 415 | x += sizeM/2 + 1; |
416 | x += sizeM + 1; | 416 | x += sizeM + 1; |
417 | } | 417 | } |
418 | 418 | ||
419 | if ( mIncidence->typeID() == todoID ){ | 419 | if ( mIncidence->typeID() == todoID ){ |
420 | Todo* td = ( Todo* ) mIncidence; | 420 | Todo* td = ( Todo* ) mIncidence; |
421 | if ( td->isCompleted() ) { | 421 | if ( td->isCompleted() ) { |
422 | int half = size/2; | 422 | int half = size/2; |
423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; | 423 | p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; |
424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; | 424 | p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; |
425 | x += half+half + 4; | 425 | x += half+half + 4; |
426 | 426 | ||
427 | } else { | 427 | } else { |
428 | int val = td->percentComplete()/20; | 428 | int val = td->percentComplete()/20; |
429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); | 429 | p->fillRect ( x+1, y-2, val ,size+4,textColor ); |
430 | p->drawRect ( x, y-2,7,size+4); | 430 | p->drawRect ( x, y-2,7,size+4); |
431 | x += size + 3; | 431 | x += size + 3; |
432 | } | 432 | } |
433 | } | 433 | } |
434 | QFontMetrics fm = p->fontMetrics(); | 434 | QFontMetrics fm = p->fontMetrics(); |
435 | int yPos; | 435 | int yPos; |
436 | int pmheight = size; | 436 | int pmheight = size; |
437 | if( pmheight < fm.height() ) | 437 | if( pmheight < fm.height() ) |
438 | yPos = fm.ascent() + fm.leading()/2; | 438 | yPos = fm.ascent() + fm.leading()/2; |
439 | else | 439 | else |
440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 440 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
441 | 441 | ||
442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { | 442 | if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { |
443 | p->drawText( x, yPos, text() ); | 443 | p->drawText( x, yPos, text() ); |
444 | if ( mIncidence->cancelled() ) { | 444 | if ( mIncidence->cancelled() ) { |
445 | int wid = fm.width( text() ); | 445 | int wid = fm.width( text() ); |
446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 446 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
447 | } | 447 | } |
448 | } else { | 448 | } else { |
449 | QString pText = text(); | 449 | QString pText = text(); |
450 | if( pText.mid(2,1) == ":" ) | 450 | if( pText.mid(2,1) == ":" ) |
451 | pText = pText.mid( 6 ); | 451 | pText = pText.mid( 6 ); |
452 | p->drawText( x, yPos, pText ); | 452 | p->drawText( x, yPos, pText ); |
453 | if ( mIncidence->cancelled() ) { | 453 | if ( mIncidence->cancelled() ) { |
454 | int wid = fm.width( pText ); | 454 | int wid = fm.width( pText ); |
455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); | 455 | p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); |
456 | } | 456 | } |
457 | } | 457 | } |
458 | } | 458 | } |
459 | 459 | ||
460 | int MonthViewItem::height(const QListBox *lb) const | 460 | int MonthViewItem::height(const QListBox *lb) const |
461 | { | 461 | { |
462 | int ret = 10; | 462 | int ret = 10; |
463 | if ( lb ) | 463 | if ( lb ) |
464 | ret = lb->fontMetrics().lineSpacing()+1; | 464 | ret = lb->fontMetrics().lineSpacing()+1; |
465 | return ret; | 465 | return ret; |
466 | } | 466 | } |
467 | 467 | ||
468 | int MonthViewItem::width(const QListBox *lb) const | 468 | int MonthViewItem::width(const QListBox *lb) const |
469 | { | 469 | { |
470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { | 470 | if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { |
471 | int size = PIXMAP_SIZE; | 471 | int size = PIXMAP_SIZE; |
472 | if ( QApplication::desktop()->width() < 300 ) | 472 | if ( QApplication::desktop()->width() < 300 ) |
473 | size = 3; | 473 | size = 3; |
474 | int x = 1; | 474 | int x = 1; |
475 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 475 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
476 | if ( mInfo ) { | 476 | if ( mInfo ) { |
477 | x += size + 1; | 477 | x += size + 1; |
478 | } | 478 | } |
479 | if( mRecur ) { | 479 | if( mRecur ) { |
480 | x += size+1; | 480 | x += size+1; |
481 | } | 481 | } |
482 | if( mAlarm ) { | 482 | if( mAlarm ) { |
483 | x += size+1; | 483 | x += size+1; |
484 | } | 484 | } |
485 | if( mReply ) { | 485 | if( mReply ) { |
486 | x += size+1; | 486 | x += size+1; |
487 | } | 487 | } |
488 | } | 488 | } |
489 | if( mMultiday ) { | 489 | if( mMultiday ) { |
490 | x += size+1+2+size/2; | 490 | x += size+1+2+size/2; |
491 | } | 491 | } |
492 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 492 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
493 | } | 493 | } |
494 | if ( ! lb ) | 494 | if ( ! lb ) |
495 | return 10; | 495 | return 10; |
496 | return lb->width(); | 496 | return lb->width(); |
497 | } | 497 | } |
498 | 498 | ||
499 | 499 | ||
500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 500 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
501 | : KNoScrollListBox( par ), | 501 | : KNoScrollListBox( par ), |
502 | mMonthView( parent ) | 502 | mMonthView( parent ) |
503 | { | 503 | { |
504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); | 504 | //QVBoxLayout *topLayout = new QVBoxLayout( this ); |
505 | currentPalette = 0; | 505 | currentPalette = 0; |
506 | // mLabel = new QLabel( this );QPushButton | 506 | // mLabel = new QLabel( this );QPushButton |
507 | mLabel = new QPushButton( this ); | 507 | mLabel = new QPushButton( this ); |
508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 508 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
509 | //mLabel->setLineWidth( 1 ); | 509 | //mLabel->setLineWidth( 1 ); |
510 | //mLabel->setAlignment( AlignCenter ); | 510 | //mLabel->setAlignment( AlignCenter ); |
511 | mLabel->setFlat( true ); | 511 | mLabel->setFlat( true ); |
512 | mLabel->setFocusPolicy(NoFocus); | 512 | mLabel->setFocusPolicy(NoFocus); |
513 | //mItemList = new KNoScrollListBox( this ); | 513 | //mItemList = new KNoScrollListBox( this ); |
514 | setMinimumSize( 10, 10 ); | 514 | setMinimumSize( 10, 10 ); |
515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); | 515 | setFrameStyle( QFrame::Panel | QFrame::Plain ); |
516 | setLineWidth( 1 ); | 516 | setLineWidth( 1 ); |
517 | //topLayout->addWidget( mItemList ); | 517 | //topLayout->addWidget( mItemList ); |
518 | mLabel->raise(); | 518 | mLabel->raise(); |
519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 519 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
520 | mStandardPalette = palette(); | 520 | mStandardPalette = palette(); |
521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 521 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
522 | 522 | ||
523 | enableScrollBars( false ); | 523 | enableScrollBars( false ); |
524 | updateConfig(); | 524 | updateConfig(); |
525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 525 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 526 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), | 527 | connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), |
528 | SLOT( defaultAction( QListBoxItem * ) ) ); | 528 | SLOT( defaultAction( QListBoxItem * ) ) ); |
529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, | 529 | connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, |
530 | const QPoint &) ), | 530 | const QPoint &) ), |
531 | SLOT( contextMenu( QListBoxItem * ) ) ); | 531 | SLOT( contextMenu( QListBoxItem * ) ) ); |
532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), | 532 | connect( this, SIGNAL( highlighted( QListBoxItem *) ), |
533 | SLOT( selection( QListBoxItem * ) ) ); | 533 | SLOT( selection( QListBoxItem * ) ) ); |
534 | 534 | ||
535 | /* | 535 | /* |
536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), | 536 | connect( this, SIGNAL( clicked( QListBoxItem * ) ), |
537 | SLOT( selection( QListBoxItem * ) ) ); | 537 | SLOT( selection( QListBoxItem * ) ) ); |
538 | */ | 538 | */ |
539 | } | 539 | } |
540 | #ifdef DESKTOP_VERSION | 540 | #ifdef DESKTOP_VERSION |
541 | QToolTipGroup *MonthViewCell::toolTipGroup() | 541 | QToolTipGroup *MonthViewCell::toolTipGroup() |
542 | { | 542 | { |
543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 543 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
544 | return mToolTipGroup; | 544 | return mToolTipGroup; |
545 | } | 545 | } |
546 | #endif | 546 | #endif |
547 | 547 | ||
548 | void MonthViewCell::setDate( const QDate &date ) | 548 | void MonthViewCell::setDate( const QDate &date ) |
549 | { | 549 | { |
550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 550 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
551 | mDate = date; | 551 | mDate = date; |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | //resizeEvent( 0 ); | 555 | //resizeEvent( 0 ); |
556 | } | 556 | } |
557 | 557 | ||
558 | QDate MonthViewCell::date() const | 558 | QDate MonthViewCell::date() const |
559 | { | 559 | { |
560 | return mDate; | 560 | return mDate; |
561 | } | 561 | } |
562 | 562 | ||
563 | void MonthViewCell::setPrimary( bool primary ) | 563 | void MonthViewCell::setPrimary( bool primary ) |
564 | { | 564 | { |
565 | mPrimary = primary; | 565 | mPrimary = primary; |
566 | //setMyPalette(); | 566 | //setMyPalette(); |
567 | } | 567 | } |
568 | void MonthViewCell::setMyPalette() | 568 | void MonthViewCell::setMyPalette() |
569 | { | 569 | { |
570 | 570 | ||
571 | if ( mHoliday) { | 571 | if ( mHoliday) { |
572 | if ( currentPalette == 1 ) return; | 572 | if ( currentPalette == 1 ) return; |
573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 573 | mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
574 | setPalette( mHolidayPalette ); | 574 | setPalette( mHolidayPalette ); |
575 | //mLabel->setPalette( mHolidayPalette ); | 575 | //mLabel->setPalette( mHolidayPalette ); |
576 | currentPalette = 1; | 576 | currentPalette = 1; |
577 | 577 | ||
578 | } else { | 578 | } else { |
579 | if ( mPrimary ) { | 579 | if ( mPrimary ) { |
580 | if ( currentPalette == 2 ) return; | 580 | if ( currentPalette == 2 ) return; |
581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 581 | mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
582 | //mLabel->setPalette( mPrimaryPalette ); | 582 | //mLabel->setPalette( mPrimaryPalette ); |
583 | setPalette( mPrimaryPalette ); | 583 | setPalette( mPrimaryPalette ); |
584 | currentPalette = 2; | 584 | currentPalette = 2; |
585 | 585 | ||
586 | } else { | 586 | } else { |
587 | if ( currentPalette == 3 ) return; | 587 | if ( currentPalette == 3 ) return; |
588 | setPalette( mNonPrimaryPalette ); | 588 | setPalette( mNonPrimaryPalette ); |
589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); | 589 | mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); |
590 | //mLabel->setPalette( mNonPrimaryPalette );; | 590 | //mLabel->setPalette( mNonPrimaryPalette );; |
591 | currentPalette = 3; | 591 | currentPalette = 3; |
592 | } | 592 | } |
593 | } | 593 | } |
594 | //QPalette pal = palette(); | 594 | //QPalette pal = palette(); |
595 | 595 | ||
596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 596 | //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
597 | } | 597 | } |
598 | QPalette MonthViewCell::getPalette () | 598 | QPalette MonthViewCell::getPalette () |
599 | { | 599 | { |
600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 600 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
601 | return mStandardPalette; | 601 | return mStandardPalette; |
602 | if ( mHoliday) { | 602 | if ( mHoliday) { |
603 | return mHolidayPalette ; | 603 | return mHolidayPalette ; |
604 | } else { | 604 | } else { |
605 | if ( mPrimary ) { | 605 | if ( mPrimary ) { |
606 | return mPrimaryPalette ; | 606 | return mPrimaryPalette ; |
607 | } | 607 | } |
608 | } | 608 | } |
609 | return mNonPrimaryPalette; | 609 | return mNonPrimaryPalette; |
610 | } | 610 | } |
611 | bool MonthViewCell::isPrimary() const | 611 | bool MonthViewCell::isPrimary() const |
612 | { | 612 | { |
613 | return mPrimary; | 613 | return mPrimary; |
614 | } | 614 | } |
615 | 615 | ||
616 | void MonthViewCell::setHoliday( bool holiday ) | 616 | void MonthViewCell::setHoliday( bool holiday ) |
617 | { | 617 | { |
618 | mHoliday = holiday; | 618 | mHoliday = holiday; |
619 | //setMyPalette(); | 619 | //setMyPalette(); |
620 | } | 620 | } |
621 | 621 | ||
622 | void MonthViewCell::setHoliday( const QString &holiday ) | 622 | void MonthViewCell::setHoliday( const QString &holiday ) |
623 | { | 623 | { |
624 | mHolidayString = holiday; | 624 | mHolidayString = holiday; |
625 | 625 | ||
626 | if ( !holiday.isEmpty() ) { | 626 | if ( !holiday.isEmpty() ) { |
627 | setHoliday( true ); | 627 | setHoliday( true ); |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | void MonthViewCell::startUpdateCell() | 631 | void MonthViewCell::startUpdateCell() |
632 | { | 632 | { |
633 | blockSignals( true ); | 633 | blockSignals( true ); |
634 | mdayCount = 0; | 634 | mdayCount = 0; |
635 | setFocusPolicy(NoFocus); | 635 | setFocusPolicy(NoFocus); |
636 | if ( !mMonthView->isUpdatePossible() ) | 636 | if ( !mMonthView->isUpdatePossible() ) |
637 | return; | 637 | return; |
638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 638 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
639 | while ( mitem ) { | 639 | while ( mitem ) { |
640 | mitem->setBlockRepaint( true ); | 640 | mitem->setBlockRepaint( true ); |
641 | mitem = (MonthViewItem *)mitem->next(); | 641 | mitem = (MonthViewItem *)mitem->next(); |
642 | } | 642 | } |
643 | if ( mAvailItemList.count() > 20 ) { | 643 | if ( mAvailItemList.count() > 20 ) { |
644 | mAvailItemList.setAutoDelete( true ); | 644 | mAvailItemList.setAutoDelete( true ); |
645 | mAvailItemList.clear(); | 645 | mAvailItemList.clear(); |
646 | mAvailItemList.setAutoDelete( false ); | 646 | mAvailItemList.setAutoDelete( false ); |
647 | clear(); | 647 | clear(); |
648 | } | 648 | } |
649 | 649 | ||
650 | setPrimary( mDate.month()%2 ); | 650 | setPrimary( mDate.month()%2 ); |
651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 651 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
652 | if ( mDate == QDate::currentDate() ) { | 652 | if ( mDate == QDate::currentDate() ) { |
653 | setLineWidth( 3 ); | 653 | setLineWidth( 3 ); |
654 | } else { | 654 | } else { |
655 | setLineWidth( 1 ); | 655 | setLineWidth( 1 ); |
656 | } | 656 | } |
657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); | 657 | MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); |
658 | //clear(); | 658 | //clear(); |
659 | while ( CurrentAvailItem ) { | 659 | while ( CurrentAvailItem ) { |
660 | MonthViewItem *item = CurrentAvailItem; | 660 | MonthViewItem *item = CurrentAvailItem; |
661 | //item->setHighlightedFalse(); | 661 | //item->setHighlightedFalse(); |
662 | item->recycle( 0, ""); | 662 | item->recycle( 0, ""); |
663 | CurrentAvailItem = (MonthViewItem *)item->next(); | 663 | CurrentAvailItem = (MonthViewItem *)item->next(); |
664 | mAvailItemList.append( item ); | 664 | mAvailItemList.append( item ); |
665 | takeItem ( item ); | 665 | takeItem ( item ); |
666 | } | 666 | } |
667 | 667 | ||
668 | #ifdef DESKTOP_VERSION | 668 | #ifdef DESKTOP_VERSION |
669 | QToolTip::remove(this); | 669 | QToolTip::remove(this); |
670 | #endif | 670 | #endif |
671 | mToolTip.clear(); | 671 | mToolTip.clear(); |
672 | //qApp->processEvents(); | 672 | //qApp->processEvents(); |
673 | #if 0 | 673 | #if 0 |
674 | if ( !mHolidayString.isEmpty() ) { | 674 | if ( !mHolidayString.isEmpty() ) { |
675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 675 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
676 | item->setPalette( mHolidayPalette ); | 676 | item->setPalette( mHolidayPalette ); |
677 | insertItem( item ); | 677 | insertItem( item ); |
678 | mToolTip.append ( mHolidayString ); | 678 | mToolTip.append ( mHolidayString ); |
679 | } | 679 | } |
680 | #endif | 680 | #endif |
681 | } | 681 | } |
682 | 682 | ||
683 | int MonthViewCell::insertEvent(Event *event) | 683 | int MonthViewCell::insertEvent(Event *event) |
684 | { | 684 | { |
685 | bool useToolTips = true; | 685 | bool useToolTips = true; |
686 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
687 | useToolTips = false; | 687 | useToolTips = false; |
688 | #endif | 688 | #endif |
689 | QString mToolTipText; | 689 | QString mToolTipText; |
690 | setFocusPolicy(WheelFocus); | 690 | setFocusPolicy(WheelFocus); |
691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 691 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 692 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
693 | return mdayCount; | 693 | return mdayCount; |
694 | else | 694 | else |
695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 695 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
696 | return mdayCount; | 696 | return mdayCount; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( event->isHoliday()) { | 699 | if ( event->isHoliday()) { |
700 | setHoliday( true ); | 700 | setHoliday( true ); |
701 | if ( mDate.dayOfWeek() == 7 ) | 701 | if ( mDate.dayOfWeek() == 7 ) |
702 | setLineWidth( 3 ); | 702 | setLineWidth( 3 ); |
703 | } | 703 | } |
704 | QString text; | 704 | QString text; |
705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day | 705 | int multiday = 0;// 1 = start, 2 = midddle, 3 = end day |
706 | if (event->isMultiDay()) { | 706 | if (event->isMultiDay()) { |
707 | QString prefix = "<->";multiday = 2; | 707 | QString prefix = "<->";multiday = 2; |
708 | QString time; | 708 | QString time; |
709 | if ( event->doesRecur() ) { | 709 | if ( event->doesRecur() ) { |
710 | if ( event->recursOn( mDate) ) { | 710 | if ( event->recursOn( mDate) ) { |
711 | prefix ="->" ;multiday = 1; | 711 | prefix ="->" ;multiday = 1; |
712 | } | 712 | } |
713 | else { | 713 | else { |
714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 714 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
715 | if ( event->recursOn( mDate.addDays( -days)) ) { | 715 | if ( event->recursOn( mDate.addDays( -days)) ) { |
716 | prefix ="<-" ;multiday = 3; | 716 | prefix ="<-" ;multiday = 3; |
717 | } | 717 | } |
718 | } | 718 | } |
719 | 719 | ||
720 | } else { | 720 | } else { |
721 | if (mDate == event->dtStart().date()) { | 721 | if (mDate == event->dtStart().date()) { |
722 | prefix ="->" ;multiday = 1; | 722 | prefix ="->" ;multiday = 1; |
723 | } else if (mDate == event->dtEnd().date()) { | 723 | } else if (mDate == event->dtEnd().date()) { |
724 | prefix ="<-" ;multiday = 3; | 724 | prefix ="<-" ;multiday = 3; |
725 | } | 725 | } |
726 | } | 726 | } |
727 | if ( !event->doesFloat() ) { | 727 | if ( !event->doesFloat() ) { |
728 | if ( mDate == event->dtStart().date () ) | 728 | if ( mDate == event->dtStart().date () ) |
729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 729 | time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
730 | else if ( mDate == event->dtEnd().date () ) | 730 | else if ( mDate == event->dtEnd().date () ) |
731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 731 | time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
732 | 732 | ||
733 | } | 733 | } |
734 | text = time + event->summary(); | 734 | text = time + event->summary(); |
735 | if ( useToolTips ) | 735 | if ( useToolTips ) |
736 | mToolTipText += prefix + text; | 736 | mToolTipText += prefix + text; |
737 | } else { | 737 | } else { |
738 | if (event->doesFloat()) { | 738 | if (event->doesFloat()) { |
739 | text = event->summary(); | 739 | text = event->summary(); |
740 | if ( useToolTips ) | 740 | if ( useToolTips ) |
741 | mToolTipText += text; | 741 | mToolTipText += text; |
742 | } | 742 | } |
743 | else { | 743 | else { |
744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 744 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
745 | text += " " + event->summary(); | 745 | text += " " + event->summary(); |
746 | if ( useToolTips ) | 746 | if ( useToolTips ) |
747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 747 | mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
748 | } | 748 | } |
749 | } | 749 | } |
750 | if ( useToolTips && ! event->location().isEmpty() ) { | 750 | if ( useToolTips && ! event->location().isEmpty() ) { |
751 | mToolTipText += " (" + event->location() +")"; | 751 | mToolTipText += " (" + event->location() +")"; |
752 | } | 752 | } |
753 | MonthViewItem *item ; | 753 | MonthViewItem *item ; |
754 | 754 | ||
755 | if ( mAvailItemList.count() ) { | 755 | if ( mAvailItemList.count() ) { |
756 | item = mAvailItemList.first(); | 756 | item = mAvailItemList.first(); |
757 | mAvailItemList.remove( item ); | 757 | mAvailItemList.remove( item ); |
758 | item->recycle( event, text ); | 758 | item->recycle( event, text ); |
759 | } else { | 759 | } else { |
760 | item = new MonthViewItem( event, text ); | 760 | item = new MonthViewItem( event, text ); |
761 | } | 761 | } |
762 | 762 | ||
763 | QPalette pal; | 763 | QPalette pal; |
764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 764 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
765 | QStringList categories = event->categories(); | 765 | QStringList categories = event->categories(); |
766 | QString cat = categories.first(); | 766 | QString cat = categories.first(); |
767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 767 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
768 | pal = getPalette(); | 768 | pal = getPalette(); |
769 | if (cat.isEmpty()) { | 769 | if (cat.isEmpty()) { |
770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 770 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); | 771 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); |
772 | } else { | 772 | } else { |
773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 773 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
774 | } | 774 | } |
775 | 775 | ||
776 | } else { | 776 | } else { |
777 | if (cat.isEmpty()) { | 777 | if (cat.isEmpty()) { |
778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 778 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); | 779 | pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); |
780 | } else { | 780 | } else { |
781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 781 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
782 | } | 782 | } |
783 | } | 783 | } |
784 | 784 | ||
785 | } else { | 785 | } else { |
786 | pal = mStandardPalette ; | 786 | pal = mStandardPalette ; |
787 | } | 787 | } |
788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 788 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
789 | item->setPalette( pal ); | 789 | item->setPalette( pal ); |
790 | item->setRecur( event->doesRecur() ); | 790 | item->setRecur( event->doesRecur() ); |
791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); | 791 | item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); |
792 | item->setMoreInfo( event->description().length() > 0 ); | 792 | item->setMoreInfo( event->description().length() > 0 ); |
793 | #ifdef DESKTOP_VERSION | 793 | #ifdef DESKTOP_VERSION |
794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 794 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
795 | KOPrefs::instance()->email()); | 795 | KOPrefs::instance()->email()); |
796 | if ( me != 0 ) { | 796 | if ( me != 0 ) { |
797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 797 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
798 | item->setReply(true && multiday < 2); | 798 | item->setReply(true && multiday < 2); |
799 | else | 799 | else |
800 | item->setReply(false); | 800 | item->setReply(false); |
801 | } else | 801 | } else |
802 | item->setReply(false); | 802 | item->setReply(false); |
803 | #endif | 803 | #endif |
804 | 804 | ||
805 | item->setMultiDay( multiday ); | 805 | item->setMultiDay( multiday ); |
806 | if ( multiday ) { | 806 | if ( multiday ) { |
807 | insertItem( item ,mdayCount); | 807 | insertItem( item ,mdayCount); |
808 | ++mdayCount; | 808 | ++mdayCount; |
809 | } else { | 809 | } else { |
810 | uint i = mdayCount; | 810 | uint i = mdayCount; |
811 | uint pos = mdayCount; | 811 | uint pos = mdayCount; |
812 | uint itcount = count(); | 812 | uint itcount = count(); |
813 | if ( itcount > 1000 ) { | 813 | if ( itcount > 1000 ) { |
814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); | 814 | qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); |
815 | itcount = 0; | 815 | itcount = 0; |
816 | } | 816 | } |
817 | for ( i = pos; i < itcount;++i ) { | 817 | for ( i = pos; i < itcount;++i ) { |
818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); | 818 | // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); |
819 | QListBoxItem* it = this->item ( i ); | 819 | QListBoxItem* it = this->item ( i ); |
820 | if ( it && text < it->text() ) { | 820 | if ( it && text < it->text() ) { |
821 | pos = i; | 821 | pos = i; |
822 | break; | 822 | break; |
823 | } | 823 | } |
824 | ++pos; | 824 | ++pos; |
825 | } | 825 | } |
826 | insertItem( item ,pos); | 826 | insertItem( item ,pos); |
827 | } | 827 | } |
828 | if ( useToolTips ) { | 828 | if ( useToolTips ) { |
829 | mToolTip.append( mToolTipText ); | 829 | mToolTip.append( mToolTipText ); |
830 | } | 830 | } |
831 | return mdayCount; | 831 | return mdayCount; |
832 | } | 832 | } |
833 | void MonthViewCell::insertTodo(Todo *todo) | 833 | void MonthViewCell::insertTodo(Todo *todo) |
834 | { | 834 | { |
835 | setFocusPolicy(WheelFocus); | 835 | setFocusPolicy(WheelFocus); |
836 | QString text; | 836 | QString text; |
837 | if (todo->hasDueDate()) { | 837 | if (todo->hasDueDate()) { |
838 | if (!todo->doesFloat()) { | 838 | if (!todo->doesFloat()) { |
839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 839 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
840 | text += " "; | 840 | text += " "; |
841 | } | 841 | } |
842 | } | 842 | } |
843 | text += todo->summary(); | 843 | text += todo->summary(); |
844 | MonthViewItem *item ; | 844 | MonthViewItem *item ; |
845 | if ( mAvailItemList.count() ) { | 845 | if ( mAvailItemList.count() ) { |
846 | item = mAvailItemList.first(); | 846 | item = mAvailItemList.first(); |
847 | mAvailItemList.remove( item ); | 847 | mAvailItemList.remove( item ); |
848 | item->recycle( todo, text ); | 848 | item->recycle( todo, text ); |
849 | } else { | 849 | } else { |
850 | item = new MonthViewItem( todo, text ); | 850 | item = new MonthViewItem( todo, text ); |
851 | } | 851 | } |
852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 852 | //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
853 | //item->setPalette( mStandardPalette ); | 853 | //item->setPalette( mStandardPalette ); |
854 | QPalette pal; | 854 | QPalette pal; |
855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 855 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
856 | QStringList categories = todo->categories(); | 856 | QStringList categories = todo->categories(); |
857 | QString cat = categories.first(); | 857 | QString cat = categories.first(); |
858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 858 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
859 | pal = getPalette(); | 859 | pal = getPalette(); |
860 | if (cat.isEmpty()) { | 860 | if (cat.isEmpty()) { |
861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 861 | //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); | 862 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); |
863 | } else { | 863 | } else { |
864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 864 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
865 | } | 865 | } |
866 | 866 | ||
867 | } else { | 867 | } else { |
868 | if (cat.isEmpty()) { | 868 | if (cat.isEmpty()) { |
869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 869 | //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); | 870 | pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); |
871 | } else { | 871 | } else { |
872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 872 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
873 | } | 873 | } |
874 | } | 874 | } |
875 | 875 | ||
876 | } else { | 876 | } else { |
877 | pal = mStandardPalette ; | 877 | pal = mStandardPalette ; |
878 | } | 878 | } |
879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); | 879 | pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); |
880 | item->setPalette( pal ); | 880 | item->setPalette( pal ); |
881 | item->setRecur( todo->doesRecur() ); | 881 | item->setRecur( todo->doesRecur() ); |
882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); | 882 | item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); |
883 | item->setMoreInfo( todo->description().length() > 0 ); | 883 | item->setMoreInfo( todo->description().length() > 0 ); |
884 | insertItem( item , count()); | 884 | insertItem( item , count()); |
885 | #ifdef DESKTOP_VERSION | 885 | #ifdef DESKTOP_VERSION |
886 | mToolTip.append( text ); | 886 | mToolTip.append( text ); |
887 | #endif | 887 | #endif |
888 | } | 888 | } |
889 | void MonthViewCell::repaintfinishUpdateCell() | 889 | void MonthViewCell::repaintfinishUpdateCell() |
890 | { | 890 | { |
891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 891 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
892 | while ( mitem ) { | 892 | while ( mitem ) { |
893 | mitem->setBlockRepaint( false ); | 893 | mitem->setBlockRepaint( false ); |
894 | updateItem ( mitem ); | 894 | updateItem ( mitem ); |
895 | mitem = (MonthViewItem *)mitem->next(); | 895 | mitem = (MonthViewItem *)mitem->next(); |
896 | } | 896 | } |
897 | blockSignals( false ); | 897 | blockSignals( false ); |
898 | } | 898 | } |
899 | void MonthViewCell::finishUpdateCell() | 899 | void MonthViewCell::finishUpdateCell() |
900 | { | 900 | { |
901 | 901 | ||
902 | 902 | ||
903 | 903 | ||
904 | #ifdef DESKTOP_VERSION | 904 | #ifdef DESKTOP_VERSION |
905 | if (mToolTip.count() > 0 ) { | 905 | if (mToolTip.count() > 0 ) { |
906 | mToolTip.sort(); | 906 | mToolTip.sort(); |
907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); | 907 | QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); |
908 | } | 908 | } |
909 | #endif | 909 | #endif |
910 | //sort(); | 910 | //sort(); |
911 | //setMyPalette(); | 911 | //setMyPalette(); |
912 | setMyPalette(); | 912 | setMyPalette(); |
913 | 913 | ||
914 | resizeEvent( 0 ); | 914 | resizeEvent( 0 ); |
915 | 915 | ||
916 | } | 916 | } |
917 | void MonthViewCell::updateCell() | 917 | void MonthViewCell::updateCell() |
918 | { | 918 | { |
919 | if ( !mMonthView->isUpdatePossible() ) | 919 | if ( !mMonthView->isUpdatePossible() ) |
920 | return; | 920 | return; |
921 | startUpdateCell(); | 921 | startUpdateCell(); |
922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 922 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 923 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
924 | Event *event; | 924 | Event *event; |
925 | for( event = events.first(); event; event = events.next() ) { // for event | 925 | for( event = events.first(); event; event = events.next() ) { // for event |
926 | insertEvent(event); | 926 | insertEvent(event); |
927 | } | 927 | } |
928 | // insert due todos | 928 | // insert due todos |
929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 929 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
930 | Todo *todo; | 930 | Todo *todo; |
931 | for(todo = todos.first(); todo; todo = todos.next()) { | 931 | for(todo = todos.first(); todo; todo = todos.next()) { |
932 | insertTodo( todo ); | 932 | insertTodo( todo ); |
933 | } | 933 | } |
934 | finishUpdateCell(); | 934 | finishUpdateCell(); |
935 | // if ( isVisible()) | 935 | // if ( isVisible()) |
936 | //qApp->processEvents(); | 936 | //qApp->processEvents(); |
937 | } | 937 | } |
938 | 938 | ||
939 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 939 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
940 | { | 940 | { |
941 | 941 | ||
942 | if ( bigFont ) { | 942 | if ( bigFont ) { |
943 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 943 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
944 | int ps = fo.pointSize() + 2; | 944 | int ps = fo.pointSize() + 2; |
945 | if ( ps < 18 ) | 945 | if ( ps < 18 ) |
946 | ps += 2; | 946 | ps += 2; |
947 | fo.setPointSize( ps ); | 947 | fo.setPointSize( ps ); |
948 | setFont( fo ); | 948 | setFont( fo ); |
949 | } else | 949 | } else |
950 | setFont( KOPrefs::instance()->mMonthViewFont ); | 950 | setFont( KOPrefs::instance()->mMonthViewFont ); |
951 | 951 | ||
952 | QFontMetrics fm( font() ); | 952 | QFontMetrics fm( font() ); |
953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 953 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 954 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
955 | mHolidayPalette = mStandardPalette; | 955 | mHolidayPalette = mStandardPalette; |
956 | mPrimaryPalette = mStandardPalette; | 956 | mPrimaryPalette = mStandardPalette; |
957 | mNonPrimaryPalette = mStandardPalette; | 957 | mNonPrimaryPalette = mStandardPalette; |
958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 958 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 959 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 960 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 961 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 962 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 963 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 964 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 965 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 966 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 967 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
968 | } | 968 | } |
969 | //updateCell(); | 969 | //updateCell(); |
970 | } | 970 | } |
971 | 971 | ||
972 | void MonthViewCell::enableScrollBars( bool enabled ) | 972 | void MonthViewCell::enableScrollBars( bool enabled ) |
973 | { | 973 | { |
974 | 974 | ||
975 | return; | 975 | return; |
976 | if ( enabled ) { | 976 | if ( enabled ) { |
977 | QListBoxItem *fi = firstItem (); | 977 | QListBoxItem *fi = firstItem (); |
978 | if (fi ) { | 978 | if (fi ) { |
979 | int ihei = fi->height( this ); | 979 | int ihei = fi->height( this ); |
980 | int hei = numRows () * ihei; | 980 | int hei = numRows () * ihei; |
981 | if ( hei < height() - horizontalScrollBar()->height () ) { | 981 | if ( hei < height() - horizontalScrollBar()->height () ) { |
982 | setVScrollBarMode(QScrollView::AlwaysOff); | 982 | setVScrollBarMode(QScrollView::AlwaysOff); |
983 | } | 983 | } |
984 | else | 984 | else |
985 | setVScrollBarMode(QScrollView::Auto); | 985 | setVScrollBarMode(QScrollView::Auto); |
986 | if ( ihei *3 > height() ) { | 986 | if ( ihei *3 > height() ) { |
987 | setHScrollBarMode(QScrollView::AlwaysOff); | 987 | setHScrollBarMode(QScrollView::AlwaysOff); |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | setHScrollBarMode(QScrollView::Auto); | 990 | setHScrollBarMode(QScrollView::Auto); |
991 | } | 991 | } |
992 | } else { | 992 | } else { |
993 | setVScrollBarMode(QScrollView::Auto); | 993 | setVScrollBarMode(QScrollView::Auto); |
994 | setHScrollBarMode(QScrollView::Auto); | 994 | setHScrollBarMode(QScrollView::Auto); |
995 | } | 995 | } |
996 | } else { | 996 | } else { |
997 | setVScrollBarMode(QScrollView::AlwaysOff); | 997 | setVScrollBarMode(QScrollView::AlwaysOff); |
998 | setHScrollBarMode(QScrollView::AlwaysOff); | 998 | setHScrollBarMode(QScrollView::AlwaysOff); |
999 | } | 999 | } |
1000 | } | 1000 | } |
1001 | 1001 | ||
1002 | Incidence *MonthViewCell::selectedIncidence() | 1002 | Incidence *MonthViewCell::selectedIncidence() |
1003 | { | 1003 | { |
1004 | int index = currentItem(); | 1004 | int index = currentItem(); |
1005 | if ( index < 0 ) return 0; | 1005 | if ( index < 0 ) return 0; |
1006 | 1006 | ||
1007 | MonthViewItem *mitem = | 1007 | MonthViewItem *mitem = |
1008 | static_cast<MonthViewItem *>( item( index ) ); | 1008 | static_cast<MonthViewItem *>( item( index ) ); |
1009 | 1009 | ||
1010 | if ( !mitem ) return 0; | 1010 | if ( !mitem ) return 0; |
1011 | 1011 | ||
1012 | return mitem->incidence(); | 1012 | return mitem->incidence(); |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | QDate MonthViewCell::selectedIncidenceDate() | 1015 | QDate MonthViewCell::selectedIncidenceDate() |
1016 | { | 1016 | { |
1017 | QDate qd; | 1017 | QDate qd; |
1018 | int index = currentItem(); | 1018 | int index = currentItem(); |
1019 | if ( index < 0 ) return qd; | 1019 | if ( index < 0 ) return qd; |
1020 | return mDate; | 1020 | return mDate; |
1021 | } | 1021 | } |
1022 | 1022 | ||
1023 | void MonthViewCell::deselect() | 1023 | void MonthViewCell::deselect() |
1024 | { | 1024 | { |
1025 | clearSelection(); | 1025 | clearSelection(); |
1026 | enableScrollBars( false ); | 1026 | enableScrollBars( false ); |
1027 | // updateCell(); | 1027 | // updateCell(); |
1028 | } | 1028 | } |
1029 | void MonthViewCell::select() | 1029 | void MonthViewCell::select() |
1030 | { | 1030 | { |
1031 | ;// updateCell(); | 1031 | ;// updateCell(); |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) | 1034 | void MonthViewCell::resizeEvent ( QResizeEvent * e ) |
1035 | { | 1035 | { |
1036 | if ( !mMonthView->isUpdatePossible() ) | 1036 | if ( !mMonthView->isUpdatePossible() ) |
1037 | return; | 1037 | return; |
1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); | 1038 | //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); |
1039 | deselect(); | 1039 | deselect(); |
1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); | 1040 | mLabel->setMaximumHeight( height() - lineWidth()*2 ); |
1041 | 1041 | ||
1042 | QString text; | 1042 | QString text; |
1043 | //mLabel->setText( text ); | 1043 | //mLabel->setText( text ); |
1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 1044 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 1045 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); | 1046 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); |
1047 | mLabel->resize( mLabelBigSize ); | 1047 | mLabel->resize( mLabelBigSize ); |
1048 | } else { | 1048 | } else { |
1049 | mLabel->resize( mLabelSize ); | 1049 | mLabel->resize( mLabelSize ); |
1050 | text = QString::number( mDate.day() ); | 1050 | text = QString::number( mDate.day() ); |
1051 | } | 1051 | } |
1052 | mLabel->setText( text ); | 1052 | mLabel->setText( text ); |
1053 | 1053 | ||
1054 | int size = height() - mLabel->height() - lineWidth()-1; | 1054 | int size = height() - mLabel->height() - lineWidth()-1; |
1055 | //qDebug("LW %d ", lineWidth()); | 1055 | //qDebug("LW %d ", lineWidth()); |
1056 | if ( size > 0 ) | 1056 | if ( size > 0 ) |
1057 | verticalScrollBar()->setMaximumHeight( size ); | 1057 | verticalScrollBar()->setMaximumHeight( size ); |
1058 | size = width() - mLabel->width() -lineWidth()-1; | 1058 | size = width() - mLabel->width() -lineWidth()-1; |
1059 | if ( size > 0 ) | 1059 | if ( size > 0 ) |
1060 | horizontalScrollBar()->setMaximumWidth( size ); | 1060 | horizontalScrollBar()->setMaximumWidth( size ); |
1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); | 1061 | mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); |
1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 1062 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
1063 | // mItemList->resize ( width(), height () ); | 1063 | // mItemList->resize ( width(), height () ); |
1064 | if ( e ) | 1064 | if ( e ) |
1065 | KNoScrollListBox::resizeEvent ( e ); | 1065 | KNoScrollListBox::resizeEvent ( e ); |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 1068 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
1069 | { | 1069 | { |
1070 | 1070 | ||
1071 | if ( !item ) { | 1071 | if ( !item ) { |
1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1072 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1073 | emit newEventSignal( dt ); | 1073 | emit newEventSignal( dt ); |
1074 | return; | 1074 | return; |
1075 | } | 1075 | } |
1076 | 1076 | ||
1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1077 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1078 | Incidence *incidence = eventItem->incidence(); | 1078 | Incidence *incidence = eventItem->incidence(); |
1079 | if ( incidence ) mMonthView->defaultAction( incidence ); | 1079 | if ( incidence ) mMonthView->defaultAction( incidence ); |
1080 | } | 1080 | } |
1081 | void MonthViewCell::showDay() | 1081 | void MonthViewCell::showDay() |
1082 | { | 1082 | { |
1083 | emit showDaySignal( date() ); | 1083 | emit showDaySignal( date() ); |
1084 | } | 1084 | } |
1085 | void MonthViewCell::newEvent() | 1085 | void MonthViewCell::newEvent() |
1086 | { | 1086 | { |
1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1087 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1088 | emit newEventSignal( dt ); | 1088 | emit newEventSignal( dt ); |
1089 | } | 1089 | } |
1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 1090 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
1091 | { | 1091 | { |
1092 | mMonthView->setSelectedCell( this ); | 1092 | mMonthView->setSelectedCell( this ); |
1093 | if ( item == 0 ) { | 1093 | if ( item == 0 ) { |
1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 1094 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
1095 | emit newEventSignal( dt ); | 1095 | emit newEventSignal( dt ); |
1096 | return; | 1096 | return; |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 1101 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
1102 | { | 1102 | { |
1103 | mMonthView->setPopupCell( this ); | 1103 | mMonthView->setPopupCell( this ); |
1104 | if ( !item ) { | 1104 | if ( !item ) { |
1105 | mMonthView->showContextMenu( 0 ); | 1105 | mMonthView->showContextMenu( 0 ); |
1106 | return; | 1106 | return; |
1107 | } | 1107 | } |
1108 | //selection( item ); | 1108 | //selection( item ); |
1109 | //qApp->processEvents(); | 1109 | //qApp->processEvents(); |
1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 1110 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
1111 | Incidence *incidence = eventItem->incidence(); | 1111 | Incidence *incidence = eventItem->incidence(); |
1112 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 1112 | if ( incidence ) { |
1113 | mMonthView->showContextMenu( incidence ); | ||
1114 | selection( item ); | ||
1115 | doHighLight( incidence ); | ||
1116 | } | ||
1113 | } | 1117 | } |
1114 | 1118 | ||
1115 | void MonthViewCell::selection( QListBoxItem *item ) | 1119 | void MonthViewCell::selection( QListBoxItem *item ) |
1116 | { | 1120 | { |
1117 | if ( !item ) { | 1121 | if ( !item ) { |
1118 | emit highlightIncidence( 0 , this, 0 ); | 1122 | emit highlightIncidence( 0 , this, 0 ); |
1119 | return; | 1123 | return; |
1120 | } | 1124 | } |
1121 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); | 1125 | MonthViewItem * it = (static_cast<MonthViewItem *>( item )); |
1122 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); | 1126 | emit highlightIncidence( it->incidence(), this, it->multiDay() ); |
1123 | mMonthView->setSelectedCell( this ); | 1127 | mMonthView->setSelectedCell( this ); |
1124 | } | 1128 | } |
1125 | 1129 | ||
1126 | void MonthViewCell::deHighLight() | 1130 | void MonthViewCell::deHighLight() |
1127 | { | 1131 | { |
1128 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1132 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1129 | while ( mitem ) { | 1133 | while ( mitem ) { |
1130 | if ( mitem->setHighlightedFalse() ) | 1134 | if ( mitem->setHighlightedFalse() ) |
1131 | updateItem ( mitem ); | 1135 | updateItem ( mitem ); |
1132 | mitem = (MonthViewItem *)mitem->next(); | 1136 | mitem = (MonthViewItem *)mitem->next(); |
1133 | } | 1137 | } |
1134 | } | 1138 | } |
1135 | // returns true if no inc found | 1139 | // returns true if no inc found |
1136 | bool MonthViewCell::doHighLight( Incidence * inc ) | 1140 | bool MonthViewCell::doHighLight( Incidence * inc ) |
1137 | { | 1141 | { |
1138 | 1142 | ||
1139 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); | 1143 | MonthViewItem *mitem = (MonthViewItem*) firstItem (); |
1140 | while ( mitem ) { | 1144 | while ( mitem ) { |
1141 | if ( mitem->incidence() == inc ) { | 1145 | if ( mitem->incidence() == inc ) { |
1142 | if ( mitem->setHighlighted( inc ) ) | 1146 | if ( mitem->setHighlighted( inc ) ) |
1143 | updateItem ( mitem ); | 1147 | updateItem ( mitem ); |
1144 | return false; | 1148 | return false; |
1145 | } | 1149 | } |
1146 | mitem = (MonthViewItem *)mitem->next(); | 1150 | mitem = (MonthViewItem *)mitem->next(); |
1147 | } | 1151 | } |
1148 | return true; | 1152 | return true; |
1149 | } | 1153 | } |
1150 | // ******************************************************************************* | 1154 | // ******************************************************************************* |
1151 | // ******************************************************************************* | 1155 | // ******************************************************************************* |
1152 | // ******************************************************************************* | 1156 | // ******************************************************************************* |
1153 | 1157 | ||
1154 | 1158 | ||
1155 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 1159 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
1156 | : KOEventView( calendar, parent, name ), | 1160 | : KOEventView( calendar, parent, name ), |
1157 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 1161 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
1158 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 1162 | mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
1159 | { | 1163 | { |
1160 | mFlagKeyPressed = false; | 1164 | mFlagKeyPressed = false; |
1161 | mShortDayLabelsM = false; | 1165 | mShortDayLabelsM = false; |
1162 | mShortDayLabelsW = false; | 1166 | mShortDayLabelsW = false; |
1163 | skipResize = false; | 1167 | skipResize = false; |
1164 | clPending = true; | 1168 | clPending = true; |
1165 | mPopupCell = 0; | 1169 | mPopupCell = 0; |
1166 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); | 1170 | mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); |
1167 | mWidStack = new QWidgetStack( this ); | 1171 | mWidStack = new QWidgetStack( this ); |
1168 | QVBoxLayout* hb = new QVBoxLayout( this ); | 1172 | QVBoxLayout* hb = new QVBoxLayout( this ); |
1169 | mMonthView = new QWidget( mWidStack ); | 1173 | mMonthView = new QWidget( mWidStack ); |
1170 | mWeekView = new QWidget( mWidStack ); | 1174 | mWeekView = new QWidget( mWidStack ); |
1171 | #if QT_VERSION >= 0x030000 | 1175 | #if QT_VERSION >= 0x030000 |
1172 | mWidStack->addWidget(mMonthView ); | 1176 | mWidStack->addWidget(mMonthView ); |
1173 | mWidStack->addWidget(mWeekView ); | 1177 | mWidStack->addWidget(mWeekView ); |
1174 | #else | 1178 | #else |
1175 | mWidStack->addWidget( mMonthView, 1 ); | 1179 | mWidStack->addWidget( mMonthView, 1 ); |
1176 | mWidStack->addWidget( mWeekView , 1 ); | 1180 | mWidStack->addWidget( mWeekView , 1 ); |
1177 | #endif | 1181 | #endif |
1178 | hb->addWidget( mNavigatorBar ); | 1182 | hb->addWidget( mNavigatorBar ); |
1179 | hb->addWidget( mWidStack ); | 1183 | hb->addWidget( mWidStack ); |
1180 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 1184 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
1181 | updatePossible = false; | 1185 | updatePossible = false; |
1182 | //updatePossible = true; | 1186 | //updatePossible = true; |
1183 | mCells.setAutoDelete( true ); | 1187 | mCells.setAutoDelete( true ); |
1184 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1188 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1185 | mDayLabels.resize( mDaysPerWeek ); | 1189 | mDayLabels.resize( mDaysPerWeek ); |
1186 | mDayLabelsW.resize( mDaysPerWeek ); | 1190 | mDayLabelsW.resize( mDaysPerWeek ); |
1187 | QFont bfont = font(); | 1191 | QFont bfont = font(); |
1188 | if ( QApplication::desktop()->width() < 650 ) { | 1192 | if ( QApplication::desktop()->width() < 650 ) { |
1189 | bfont.setPointSize( bfont.pointSize() - 2 ); | 1193 | bfont.setPointSize( bfont.pointSize() - 2 ); |
1190 | } | 1194 | } |
1191 | bfont.setBold( true ); | 1195 | bfont.setBold( true ); |
1192 | int i; | 1196 | int i; |
1193 | 1197 | ||
1194 | for( i = 0; i < mDaysPerWeek; i++ ) { | 1198 | for( i = 0; i < mDaysPerWeek; i++ ) { |
1195 | QLabel *label = new QLabel( mMonthView ); | 1199 | QLabel *label = new QLabel( mMonthView ); |
1196 | label->setFont(bfont); | 1200 | label->setFont(bfont); |
1197 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1201 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1198 | label->setLineWidth(1); | 1202 | label->setLineWidth(1); |
1199 | label->setAlignment(AlignCenter); | 1203 | label->setAlignment(AlignCenter); |
1200 | mDayLabels.insert( i, label ); | 1204 | mDayLabels.insert( i, label ); |
1201 | label = new QLabel( mWeekView ); | 1205 | label = new QLabel( mWeekView ); |
1202 | label->setFont(bfont); | 1206 | label->setFont(bfont); |
1203 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1207 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1204 | label->setLineWidth(1); | 1208 | label->setLineWidth(1); |
1205 | label->setAlignment(AlignCenter); | 1209 | label->setAlignment(AlignCenter); |
1206 | mDayLabelsW.insert( i, label ); | 1210 | mDayLabelsW.insert( i, label ); |
1207 | } | 1211 | } |
1208 | 1212 | ||
1209 | bfont.setBold( false ); | 1213 | bfont.setBold( false ); |
1210 | mWeekLabels.resize( mNumWeeks+1 ); | 1214 | mWeekLabels.resize( mNumWeeks+1 ); |
1211 | mWeekLabelsW.resize( 2 ); | 1215 | mWeekLabelsW.resize( 2 ); |
1212 | for( i = 0; i < mNumWeeks+1; i++ ) { | 1216 | for( i = 0; i < mNumWeeks+1; i++ ) { |
1213 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 1217 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
1214 | label->setFocusPolicy(NoFocus); | 1218 | label->setFocusPolicy(NoFocus); |
1215 | label->setFont(bfont); | 1219 | label->setFont(bfont); |
1216 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1220 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1217 | label->setFlat(true); | 1221 | label->setFlat(true); |
1218 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1222 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1219 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1223 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1220 | //label->setLineWidth(1); | 1224 | //label->setLineWidth(1); |
1221 | //label->setAlignment(AlignCenter); | 1225 | //label->setAlignment(AlignCenter); |
1222 | mWeekLabels.insert( i, label ); | 1226 | mWeekLabels.insert( i, label ); |
1223 | } | 1227 | } |
1224 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1228 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1225 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); | 1229 | mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); |
1226 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 1230 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
1227 | 1231 | ||
1228 | for( i = 0; i < 1+1; i++ ) { | 1232 | for( i = 0; i < 1+1; i++ ) { |
1229 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 1233 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
1230 | label->setFocusPolicy(NoFocus); | 1234 | label->setFocusPolicy(NoFocus); |
1231 | label->setFont(bfont); | 1235 | label->setFont(bfont); |
1232 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 1236 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
1233 | label->setFlat(true); | 1237 | label->setFlat(true); |
1234 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 1238 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
1235 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 1239 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
1236 | //label->setLineWidth(1); | 1240 | //label->setLineWidth(1); |
1237 | //label->setAlignment(AlignCenter); | 1241 | //label->setAlignment(AlignCenter); |
1238 | mWeekLabelsW.insert( i, label ); | 1242 | mWeekLabelsW.insert( i, label ); |
1239 | } | 1243 | } |
1240 | mWeekLabelsW[1]->setText( i18n("W")); | 1244 | mWeekLabelsW[1]->setText( i18n("W")); |
1241 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); | 1245 | mWeekLabelsW[1]->setFocusPolicy(WheelFocus); |
1242 | 1246 | ||
1243 | 1247 | ||
1244 | int row, col; | 1248 | int row, col; |
1245 | mCells.resize( mNumCells ); | 1249 | mCells.resize( mNumCells ); |
1246 | for( row = 0; row < mNumWeeks; ++row ) { | 1250 | for( row = 0; row < mNumWeeks; ++row ) { |
1247 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1251 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1248 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 1252 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
1249 | mCells.insert( row * mDaysPerWeek + col, cell ); | 1253 | mCells.insert( row * mDaysPerWeek + col, cell ); |
1250 | 1254 | ||
1251 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1255 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1252 | SLOT( defaultAction( Incidence * ) ) ); | 1256 | SLOT( defaultAction( Incidence * ) ) ); |
1253 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1257 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1254 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1258 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1255 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1259 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1256 | SIGNAL( showDaySignal( QDate ) ) ); | 1260 | SIGNAL( showDaySignal( QDate ) ) ); |
1257 | connect( cell, SIGNAL( nextCell() ), | 1261 | connect( cell, SIGNAL( nextCell() ), |
1258 | SLOT( nextCell() ) ); | 1262 | SLOT( nextCell() ) ); |
1259 | connect( cell, SIGNAL( prevCell() ), | 1263 | connect( cell, SIGNAL( prevCell() ), |
1260 | SLOT( prevCell() ) ); | 1264 | SLOT( prevCell() ) ); |
1261 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1265 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1262 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1266 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1263 | } | 1267 | } |
1264 | } | 1268 | } |
1265 | mCellsW.resize( mDaysPerWeek ); | 1269 | mCellsW.resize( mDaysPerWeek ); |
1266 | for( col = 0; col < mDaysPerWeek; ++col ) { | 1270 | for( col = 0; col < mDaysPerWeek; ++col ) { |
1267 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 1271 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
1268 | mCellsW.insert( col, cell ); | 1272 | mCellsW.insert( col, cell ); |
1269 | 1273 | ||
1270 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 1274 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
1271 | SLOT( defaultAction( Incidence * ) ) ); | 1275 | SLOT( defaultAction( Incidence * ) ) ); |
1272 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 1276 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
1273 | SIGNAL( newEventSignal( QDateTime ) ) ); | 1277 | SIGNAL( newEventSignal( QDateTime ) ) ); |
1274 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 1278 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
1275 | SIGNAL( showDaySignal( QDate ) ) ); | 1279 | SIGNAL( showDaySignal( QDate ) ) ); |
1276 | connect( cell, SIGNAL( nextCell() ), | 1280 | connect( cell, SIGNAL( nextCell() ), |
1277 | SLOT( nextCell() ) ); | 1281 | SLOT( nextCell() ) ); |
1278 | connect( cell, SIGNAL( prevCell() ), | 1282 | connect( cell, SIGNAL( prevCell() ), |
1279 | SLOT( prevCell() ) ); | 1283 | SLOT( prevCell() ) ); |
1280 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), | 1284 | connect( cell, SIGNAL( highlightIncidence( Incidence * , MonthViewCell *, int ) ), |
1281 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); | 1285 | SLOT( incidenceHighlighted( Incidence *, MonthViewCell *, int ) )); |
1282 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 1286 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
1283 | } | 1287 | } |
1284 | 1288 | ||
1285 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 1289 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
1286 | mContextMenu = eventPopup(); | 1290 | mContextMenu = eventPopup(); |
1287 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1291 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1288 | i18n("New Event..."),this, | 1292 | i18n("New Event..."),this, |
1289 | SLOT(slotNewEvent()),false); | 1293 | SLOT(slotNewEvent()),false); |
1290 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1294 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1291 | i18n("New Todo..."),this, | 1295 | i18n("New Todo..."),this, |
1292 | SLOT(slotNewTodo()),false); | 1296 | SLOT(slotNewTodo()),false); |
1293 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), | 1297 | mContextMenu->addAdditionalItem(QIconSet(QPixmap()), |
1294 | i18n("Journal"),this, | 1298 | i18n("Journal"),this, |
1295 | SLOT(slotEditJournal()),false); | 1299 | SLOT(slotEditJournal()),false); |
1296 | 1300 | ||
1297 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, | 1301 | connect (mContextMenu ,SIGNAL(categoryChanged( Incidence * )),this, |
1298 | SLOT( catChanged( Incidence * ) )); | 1302 | SLOT( catChanged( Incidence * ) )); |
1299 | 1303 | ||
1300 | 1304 | ||
1301 | QString pathString = ""; | 1305 | QString pathString = ""; |
1302 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 1306 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
1303 | if ( QApplication::desktop()->width() < 480 ) | 1307 | if ( QApplication::desktop()->width() < 480 ) |
1304 | pathString += "icons16/"; | 1308 | pathString += "icons16/"; |
1305 | } else | 1309 | } else |
1306 | pathString += "iconsmini/"; | 1310 | pathString += "iconsmini/"; |
1307 | mNewItemMenu = new QPopupMenu( this ); | 1311 | mNewItemMenu = new QPopupMenu( this ); |
1308 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); | 1312 | mNewItemMenu->insertItem( SmallIcon( pathString +"newevent" ), i18n("New Event..."),this, SLOT(slotNewEvent())); |
1309 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); | 1313 | mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); |
1310 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); | 1314 | mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); |
1311 | 1315 | ||
1312 | // updateConfig(); //useless here... | 1316 | // updateConfig(); //useless here... |
1313 | // ... but we need mWidthLongDayLabel computed | 1317 | // ... but we need mWidthLongDayLabel computed |
1314 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1318 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1315 | mWidthLongDayLabel = 0; | 1319 | mWidthLongDayLabel = 0; |
1316 | for (int i = 0; i < 7; i++) { | 1320 | for (int i = 0; i < 7; i++) { |
1317 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1321 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1318 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1322 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1319 | } | 1323 | } |
1320 | 1324 | ||
1321 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1325 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1322 | 1326 | ||
1323 | #if 0 | 1327 | #if 0 |
1324 | if ( mShowWeekView ) | 1328 | if ( mShowWeekView ) |
1325 | mWidStack->raiseWidget( mWeekView ); | 1329 | mWidStack->raiseWidget( mWeekView ); |
1326 | else | 1330 | else |
1327 | mWidStack->raiseWidget( mMonthView ); | 1331 | mWidStack->raiseWidget( mMonthView ); |
1328 | #endif | 1332 | #endif |
1329 | 1333 | ||
1330 | emit incidenceSelected( 0 ); | 1334 | emit incidenceSelected( 0 ); |
1331 | 1335 | ||
1332 | mComputeLayoutTimer = new QTimer( this ); | 1336 | mComputeLayoutTimer = new QTimer( this ); |
1333 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); | 1337 | connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); |
1334 | 1338 | ||
1335 | 1339 | ||
1336 | #ifndef DESKTOP_VERSION | 1340 | #ifndef DESKTOP_VERSION |
1337 | resize( QApplication::desktop()->size() ); | 1341 | resize( QApplication::desktop()->size() ); |
1338 | #else | 1342 | #else |
1339 | resize(640, 480 ); | 1343 | resize(640, 480 ); |
1340 | updatePossible = true; | 1344 | updatePossible = true; |
1341 | #endif | 1345 | #endif |
1342 | computeLayout(); | 1346 | computeLayout(); |
1343 | 1347 | ||
1344 | if ( mShowWeekView ) | 1348 | if ( mShowWeekView ) |
1345 | mWidStack->raiseWidget( mWeekView ); | 1349 | mWidStack->raiseWidget( mWeekView ); |
1346 | else | 1350 | else |
1347 | mWidStack->raiseWidget( mMonthView ); | 1351 | mWidStack->raiseWidget( mMonthView ); |
1348 | } | 1352 | } |
1349 | 1353 | ||
1350 | KOMonthView::~KOMonthView() | 1354 | KOMonthView::~KOMonthView() |
1351 | { | 1355 | { |
1352 | delete mContextMenu; | 1356 | delete mContextMenu; |
1353 | } | 1357 | } |
1354 | 1358 | ||
1355 | void KOMonthView::catChanged( Incidence * ) | 1359 | void KOMonthView::catChanged( Incidence * ) |
1356 | { | 1360 | { |
1357 | updateView(); | 1361 | updateView(); |
1358 | } | 1362 | } |
1359 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) | 1363 | void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) |
1360 | { | 1364 | { |
1361 | static Incidence * lastInc = 0; | 1365 | static Incidence * lastInc = 0; |
1362 | static MonthViewCell * lastCell = 0; | 1366 | static MonthViewCell * lastCell = 0; |
1363 | 1367 | ||
1364 | if ( lastInc == inc && lastCell == mc ) | 1368 | if ( lastInc == inc && lastCell == mc ) |
1365 | return; | 1369 | return; |
1366 | lastInc = inc; | 1370 | lastInc = inc; |
1367 | lastCell = mc; | 1371 | lastCell = mc; |
1368 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); | 1372 | //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); |
1369 | 1373 | ||
1370 | bool weekview = false; | 1374 | bool weekview = false; |
1371 | uint index = 0; | 1375 | uint index = 0; |
1372 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1376 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1373 | if ( mCellsW[i] == mc ) { | 1377 | if ( mCellsW[i] == mc ) { |
1374 | weekview = true; | 1378 | weekview = true; |
1375 | index = i; | 1379 | index = i; |
1376 | break; | 1380 | break; |
1377 | } | 1381 | } |
1378 | } | 1382 | } |
1379 | QPtrVector<MonthViewCell> *cells; | 1383 | QPtrVector<MonthViewCell> *cells; |
1380 | if ( weekview ) | 1384 | if ( weekview ) |
1381 | cells = &mCellsW; | 1385 | cells = &mCellsW; |
1382 | else { | 1386 | else { |
1383 | for (uint i = 0; i < mCells.count(); ++i) { | 1387 | for (uint i = 0; i < mCells.count(); ++i) { |
1384 | if ( mCells[i] == mc ) { | 1388 | if ( mCells[i] == mc ) { |
1385 | index = i; | 1389 | index = i; |
1386 | break; | 1390 | break; |
1387 | } | 1391 | } |
1388 | } | 1392 | } |
1389 | cells = &mCells; | 1393 | cells = &mCells; |
1390 | } | 1394 | } |
1391 | for (uint i = 0; i < (*cells).count(); ++i) { | 1395 | for (uint i = 0; i < (*cells).count(); ++i) { |
1392 | (*cells)[i]->deHighLight(); | 1396 | (*cells)[i]->deHighLight(); |
1393 | } | 1397 | } |
1394 | if ( ! inc ) | 1398 | if ( ! inc ) |
1395 | return; | 1399 | return; |
1396 | 1400 | ||
1397 | uint count = (*cells).count(); | 1401 | uint count = (*cells).count(); |
1398 | bool goLeft = (mday > 1 && index > 0); | 1402 | bool goLeft = (mday > 1 && index > 0); |
1399 | bool goRight = (mday < 3 && mday > 0 && index < count -1); | 1403 | bool goRight = (mday < 3 && mday > 0 && index < count -1); |
1400 | for (uint iii = 1; iii < count; ++iii) { | 1404 | for (uint iii = 1; iii < count; ++iii) { |
1401 | if ( goLeft ) { | 1405 | if ( goLeft ) { |
1402 | int left = index - iii; | 1406 | int left = index - iii; |
1403 | if ( left >= 0 ) { | 1407 | if ( left >= 0 ) { |
1404 | if ( (*cells)[(uint)left]->doHighLight(inc) ) | 1408 | if ( (*cells)[(uint)left]->doHighLight(inc) ) |
1405 | goLeft = false; | 1409 | goLeft = false; |
1406 | } else | 1410 | } else |
1407 | goLeft = false; | 1411 | goLeft = false; |
1408 | } | 1412 | } |
1409 | if ( goRight ) { | 1413 | if ( goRight ) { |
1410 | uint right = index + iii; | 1414 | uint right = index + iii; |
1411 | if ( right < count ) { | 1415 | if ( right < count ) { |
1412 | if ( (*cells)[right]->doHighLight(inc) ) | 1416 | if ( (*cells)[right]->doHighLight(inc) ) |
1413 | goRight = false; | 1417 | goRight = false; |
1414 | 1418 | ||
1415 | } else | 1419 | } else |
1416 | goRight = false; | 1420 | goRight = false; |
1417 | } | 1421 | } |
1418 | 1422 | ||
1419 | } | 1423 | } |
1420 | #if 0 | 1424 | #if 0 |
1421 | if ( mday > 1 && index > 0 ) | 1425 | if ( mday > 1 && index > 0 ) |
1422 | for (int i = index-1; i >= 0; --i) { | 1426 | for (int i = index-1; i >= 0; --i) { |
1423 | //qDebug("index %d iii %d ", index, i); | 1427 | //qDebug("index %d iii %d ", index, i); |
1424 | if ( (*cells)[(uint)i]->doHighLight(inc) ) | 1428 | if ( (*cells)[(uint)i]->doHighLight(inc) ) |
1425 | break; | 1429 | break; |
1426 | } | 1430 | } |
1427 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) | 1431 | if ( mday < 3 && mday > 0 && index < (*cells).count()-1) |
1428 | for (uint i = index+1; i < (*cells).count(); ++i) { | 1432 | for (uint i = index+1; i < (*cells).count(); ++i) { |
1429 | if ( (*cells)[i]->doHighLight(inc) ) | 1433 | if ( (*cells)[i]->doHighLight(inc) ) |
1430 | break; | 1434 | break; |
1431 | } | 1435 | } |
1432 | #endif | 1436 | #endif |
1433 | 1437 | ||
1434 | } | 1438 | } |
1435 | void KOMonthView::selectInternalWeekNum ( int n ) | 1439 | void KOMonthView::selectInternalWeekNum ( int n ) |
1436 | { | 1440 | { |
1437 | switchView(); | 1441 | switchView(); |
1438 | if ( !KOPrefs::instance()->mMonthViewWeek ) | 1442 | if ( !KOPrefs::instance()->mMonthViewWeek ) |
1439 | emit selectMonth (); | 1443 | emit selectMonth (); |
1440 | else | 1444 | else |
1441 | emit selectWeekNum ( n ); | 1445 | emit selectWeekNum ( n ); |
1442 | } | 1446 | } |
1443 | 1447 | ||
1444 | int KOMonthView::currentWeek() | 1448 | int KOMonthView::currentWeek() |
1445 | { | 1449 | { |
1446 | if ( mShowWeekView ) | 1450 | if ( mShowWeekView ) |
1447 | return mWeekLabelsW[0]->getWeekNum(); | 1451 | return mWeekLabelsW[0]->getWeekNum(); |
1448 | return mWeekLabels[0]->getWeekNum(); | 1452 | return mWeekLabels[0]->getWeekNum(); |
1449 | } | 1453 | } |
1450 | void KOMonthView::switchView() | 1454 | void KOMonthView::switchView() |
1451 | { | 1455 | { |
1452 | if ( selectedCell( ) ) | 1456 | if ( selectedCell( ) ) |
1453 | selectedCell()->deselect(); | 1457 | selectedCell()->deselect(); |
1454 | mShowWeekView = !mShowWeekView; | 1458 | mShowWeekView = !mShowWeekView; |
1455 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 1459 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
1456 | if ( clPending ) { | 1460 | if ( clPending ) { |
1457 | computeLayout(); | 1461 | computeLayout(); |
1458 | updateConfig(); | 1462 | updateConfig(); |
1459 | } | 1463 | } |
1460 | if ( mShowWeekView ) | 1464 | if ( mShowWeekView ) |
1461 | mWidStack->raiseWidget( mWeekView ); | 1465 | mWidStack->raiseWidget( mWeekView ); |
1462 | else | 1466 | else |
1463 | mWidStack->raiseWidget( mMonthView ); | 1467 | mWidStack->raiseWidget( mMonthView ); |
1464 | clPending = false; | 1468 | clPending = false; |
1465 | } | 1469 | } |
1466 | 1470 | ||
1467 | int KOMonthView::maxDatesHint() | 1471 | int KOMonthView::maxDatesHint() |
1468 | { | 1472 | { |
1469 | return mNumCells; | 1473 | return mNumCells; |
1470 | } | 1474 | } |
1471 | 1475 | ||
1472 | int KOMonthView::currentDateCount() | 1476 | int KOMonthView::currentDateCount() |
1473 | { | 1477 | { |
1474 | return mNumCells; | 1478 | return mNumCells; |
1475 | } | 1479 | } |
1476 | 1480 | ||
1477 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 1481 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
1478 | { | 1482 | { |
1479 | QPtrList<Incidence> selected; | 1483 | QPtrList<Incidence> selected; |
1480 | 1484 | ||
1481 | if ( mSelectedCell ) { | 1485 | if ( mSelectedCell ) { |
1482 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 1486 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
1483 | if ( incidence ) selected.append( incidence ); | 1487 | if ( incidence ) selected.append( incidence ); |
1484 | } | 1488 | } |
1485 | 1489 | ||
1486 | return selected; | 1490 | return selected; |
1487 | } | 1491 | } |
1488 | 1492 | ||
1489 | DateList KOMonthView::selectedDates() | 1493 | DateList KOMonthView::selectedDates() |
1490 | { | 1494 | { |
1491 | DateList selected; | 1495 | DateList selected; |
1492 | 1496 | ||
1493 | if ( mSelectedCell ) { | 1497 | if ( mSelectedCell ) { |
1494 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 1498 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
1495 | if ( qd.isValid() ) selected.append( qd ); | 1499 | if ( qd.isValid() ) selected.append( qd ); |
1496 | } | 1500 | } |
1497 | 1501 | ||
1498 | return selected; | 1502 | return selected; |
1499 | } | 1503 | } |
1500 | #if 0 | 1504 | #if 0 |
1501 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1505 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1502 | const QDate &td) | 1506 | const QDate &td) |
1503 | { | 1507 | { |
1504 | #ifndef KORG_NOPRINTER | 1508 | #ifndef KORG_NOPRINTER |
1505 | calPrinter->preview(CalPrinter::Month, fd, td); | 1509 | calPrinter->preview(CalPrinter::Month, fd, td); |
1506 | #endif | 1510 | #endif |
1507 | } | 1511 | } |
1508 | #endif | 1512 | #endif |
1509 | void KOMonthView::updateConfig() | 1513 | void KOMonthView::updateConfig() |
1510 | { | 1514 | { |
1511 | 1515 | ||
1512 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1516 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1513 | 1517 | ||
1514 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1518 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1515 | mWeekStartsMonday = true; | 1519 | mWeekStartsMonday = true; |
1516 | } | 1520 | } |
1517 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1521 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1518 | mWidthLongDayLabel = 0; | 1522 | mWidthLongDayLabel = 0; |
1519 | 1523 | ||
1520 | for (int i = 0; i < 7; i++) { | 1524 | for (int i = 0; i < 7; i++) { |
1521 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1525 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1522 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1526 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1523 | } | 1527 | } |
1524 | bool temp = mShowSatSunComp ; | 1528 | bool temp = mShowSatSunComp ; |
1525 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1529 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1526 | if ( ! mShowWeekView ) { | 1530 | if ( ! mShowWeekView ) { |
1527 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1531 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1528 | computeLayout(); | 1532 | computeLayout(); |
1529 | } else | 1533 | } else |
1530 | doComputeLayoutWeek(); | 1534 | doComputeLayoutWeek(); |
1531 | updateDayLabels(); | 1535 | updateDayLabels(); |
1532 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1536 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1533 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1537 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1534 | //resizeEvent( 0 ); | 1538 | //resizeEvent( 0 ); |
1535 | for (uint i = 0; i < mCells.count(); ++i) { | 1539 | for (uint i = 0; i < mCells.count(); ++i) { |
1536 | mCells[i]->updateConfig(); | 1540 | mCells[i]->updateConfig(); |
1537 | } | 1541 | } |
1538 | 1542 | ||
1539 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1543 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1540 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1544 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1541 | } | 1545 | } |
1542 | #ifdef DESKTOP_VERSION | 1546 | #ifdef DESKTOP_VERSION |
1543 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1547 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1544 | #endif | 1548 | #endif |
1545 | updateView(); | 1549 | updateView(); |
1546 | } | 1550 | } |
1547 | 1551 | ||
1548 | void KOMonthView::updateDayLabels() | 1552 | void KOMonthView::updateDayLabels() |
1549 | { | 1553 | { |
1550 | 1554 | ||
1551 | QPtrVector<QLabel> *mDayLabelsT; | 1555 | QPtrVector<QLabel> *mDayLabelsT; |
1552 | 1556 | ||
1553 | mDayLabelsT = &mDayLabelsW; | 1557 | mDayLabelsT = &mDayLabelsW; |
1554 | for (int i = 0; i < 7; i++) { | 1558 | for (int i = 0; i < 7; i++) { |
1555 | { | 1559 | { |
1556 | bool show = mShortDayLabelsW; | 1560 | bool show = mShortDayLabelsW; |
1557 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1561 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1558 | show = true; | 1562 | show = true; |
1559 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1563 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1560 | } | 1564 | } |
1561 | } | 1565 | } |
1562 | mDayLabelsT = &mDayLabels; | 1566 | mDayLabelsT = &mDayLabels; |
1563 | for (int i = 0; i < 7; i++) { | 1567 | for (int i = 0; i < 7; i++) { |
1564 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1568 | if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1565 | bool show = mShortDayLabelsM; | 1569 | bool show = mShortDayLabelsM; |
1566 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1570 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1567 | show = true; | 1571 | show = true; |
1568 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1572 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1569 | } else { | 1573 | } else { |
1570 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); | 1574 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); |
1571 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); | 1575 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); |
1572 | 1576 | ||
1573 | } | 1577 | } |
1574 | } | 1578 | } |
1575 | 1579 | ||
1576 | } | 1580 | } |
1577 | 1581 | ||
1578 | void KOMonthView::clearList() | 1582 | void KOMonthView::clearList() |
1579 | { | 1583 | { |
1580 | unsigned int i; | 1584 | unsigned int i; |
1581 | for( i = 0; i < mCells.size(); ++i ) { | 1585 | for( i = 0; i < mCells.size(); ++i ) { |
1582 | mCells[i]->clear(); | 1586 | mCells[i]->clear(); |
1583 | } | 1587 | } |
1584 | for( i = 0; i < mCellsW.size(); ++i ) { | 1588 | for( i = 0; i < mCellsW.size(); ++i ) { |
1585 | mCellsW[i]->clear(); | 1589 | mCellsW[i]->clear(); |
1586 | } | 1590 | } |
1587 | } | 1591 | } |
1588 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1592 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1589 | { | 1593 | { |
1590 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1594 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1591 | 1595 | ||
1592 | QPtrVector<MonthViewCell> *cells; | 1596 | QPtrVector<MonthViewCell> *cells; |
1593 | QPtrVector<QLabel> *dayLabels; | 1597 | QPtrVector<QLabel> *dayLabels; |
1594 | QPtrVector<KOWeekButton> *weekLabels; | 1598 | QPtrVector<KOWeekButton> *weekLabels; |
1595 | uint weekNum = 6; | 1599 | uint weekNum = 6; |
1596 | mStartDate = start; | 1600 | mStartDate = start; |
1597 | if ( mShowWeekView ) { | 1601 | if ( mShowWeekView ) { |
1598 | weekNum = 1; | 1602 | weekNum = 1; |
1599 | cells = &mCellsW; | 1603 | cells = &mCellsW; |
1600 | dayLabels = &mDayLabelsW; | 1604 | dayLabels = &mDayLabelsW; |
1601 | weekLabels = &mWeekLabelsW; | 1605 | weekLabels = &mWeekLabelsW; |
1602 | if ( !KGlobal::locale()->weekStartsMonday() ) { | 1606 | if ( !KGlobal::locale()->weekStartsMonday() ) { |
1603 | mStartDate = mStartDate.addDays( 1 ); | 1607 | mStartDate = mStartDate.addDays( 1 ); |
1604 | } | 1608 | } |
1605 | } else { | 1609 | } else { |
1606 | cells = &mCells; | 1610 | cells = &mCells; |
1607 | dayLabels = &mDayLabels; | 1611 | dayLabels = &mDayLabels; |
1608 | weekLabels = &mWeekLabels; | 1612 | weekLabels = &mWeekLabels; |
1609 | } | 1613 | } |
1610 | 1614 | ||
1611 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1615 | int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1612 | 1616 | ||
1613 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { | 1617 | if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { |
1614 | mWeekStartsMonday = true; | 1618 | mWeekStartsMonday = true; |
1615 | } | 1619 | } |
1616 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1620 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1617 | 1621 | ||
1618 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1622 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1619 | mStartDate = mStartDate.addDays( -1 ); | 1623 | mStartDate = mStartDate.addDays( -1 ); |
1620 | } | 1624 | } |
1621 | uint i; | 1625 | uint i; |
1622 | for( i = 0; i < (*cells).size(); ++i ) { | 1626 | for( i = 0; i < (*cells).size(); ++i ) { |
1623 | QDate date = mStartDate.addDays( i ); | 1627 | QDate date = mStartDate.addDays( i ); |
1624 | (*cells)[i]->setDate( date ); | 1628 | (*cells)[i]->setDate( date ); |
1625 | 1629 | ||
1626 | #ifndef KORG_NOPLUGINS | 1630 | #ifndef KORG_NOPLUGINS |
1627 | // add holiday, if present | 1631 | // add holiday, if present |
1628 | QString hstring(KOCore::self()->holiday(date)); | 1632 | QString hstring(KOCore::self()->holiday(date)); |
1629 | (*cells)[i]->setHoliday( hstring ); | 1633 | (*cells)[i]->setHoliday( hstring ); |
1630 | #endif | 1634 | #endif |
1631 | 1635 | ||
1632 | } | 1636 | } |
1633 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1637 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1634 | for( i = 0; i < weekNum; ++i ) { | 1638 | for( i = 0; i < weekNum; ++i ) { |
1635 | int wno; | 1639 | int wno; |
1636 | // remember, according to ISO 8601, the first week of the year is the | 1640 | // remember, according to ISO 8601, the first week of the year is the |
1637 | // first week that contains a thursday. Thus we must subtract off 4, | 1641 | // first week that contains a thursday. Thus we must subtract off 4, |
1638 | // not just 1. | 1642 | // not just 1. |
1639 | int dayOfYear = date.dayOfYear(); | 1643 | int dayOfYear = date.dayOfYear(); |
1640 | if (dayOfYear % 7 != 0) | 1644 | if (dayOfYear % 7 != 0) |
1641 | wno = dayOfYear / 7 + 1; | 1645 | wno = dayOfYear / 7 + 1; |
1642 | else | 1646 | else |
1643 | wno =dayOfYear / 7; | 1647 | wno =dayOfYear / 7; |
1644 | (*weekLabels)[i]->setWeekNum( wno ); | 1648 | (*weekLabels)[i]->setWeekNum( wno ); |
1645 | date = date.addDays( 7 ); | 1649 | date = date.addDays( 7 ); |
1646 | } | 1650 | } |
1647 | updateView(); | 1651 | updateView(); |
1648 | } | 1652 | } |
1649 | 1653 | ||
1650 | void KOMonthView::showEvents(QPtrList<Event>) | 1654 | void KOMonthView::showEvents(QPtrList<Event>) |
1651 | { | 1655 | { |
1652 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1656 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1653 | } | 1657 | } |
1654 | 1658 | ||
1655 | void KOMonthView::changeEventDisplay(Event *, int) | 1659 | void KOMonthView::changeEventDisplay(Event *, int) |
1656 | { | 1660 | { |
1657 | // this should be re-written to be much more efficient, but this | 1661 | // this should be re-written to be much more efficient, but this |
1658 | // quick-and-dirty-hack gets the job done for right now. | 1662 | // quick-and-dirty-hack gets the job done for right now. |
1659 | //qDebug("KOMonthView::changeEventDisplay "); | 1663 | //qDebug("KOMonthView::changeEventDisplay "); |
1660 | updateView(); | 1664 | updateView(); |
1661 | } | 1665 | } |
1662 | 1666 | ||
1663 | void KOMonthView::updateView() | 1667 | void KOMonthView::updateView() |
1664 | { | 1668 | { |
1665 | 1669 | ||
1666 | if ( !updatePossible ) | 1670 | if ( !updatePossible ) |
1667 | return; | 1671 | return; |
1668 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); | 1672 | //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); |
1669 | //QTime ti; | 1673 | //QTime ti; |
1670 | //ti.start(); | 1674 | //ti.start(); |
1671 | clearSelection(); | 1675 | clearSelection(); |
1672 | QPtrVector<MonthViewCell> *cells; | 1676 | QPtrVector<MonthViewCell> *cells; |
1673 | if ( mShowWeekView ) { | 1677 | if ( mShowWeekView ) { |
1674 | cells = &mCellsW; | 1678 | cells = &mCellsW; |
1675 | } else { | 1679 | } else { |
1676 | cells = &mCells; | 1680 | cells = &mCells; |
1677 | } | 1681 | } |
1678 | #if 1 | 1682 | #if 1 |
1679 | int i; | 1683 | int i; |
1680 | int timeSpan = (*cells).size()-1; | 1684 | int timeSpan = (*cells).size()-1; |
1681 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1685 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1682 | timeSpan = 6; | 1686 | timeSpan = 6; |
1683 | for( i = 0; i < timeSpan + 1; ++i ) { | 1687 | for( i = 0; i < timeSpan + 1; ++i ) { |
1684 | (*cells)[i]->startUpdateCell(); | 1688 | (*cells)[i]->startUpdateCell(); |
1685 | } | 1689 | } |
1686 | 1690 | ||
1687 | QPtrList<Event> events = calendar()->events(); | 1691 | QPtrList<Event> events = calendar()->events(); |
1688 | Event *event; | 1692 | Event *event; |
1689 | QDateTime dt; | 1693 | QDateTime dt; |
1690 | QDate endDate = mStartDate.addDays( timeSpan ); | 1694 | QDate endDate = mStartDate.addDays( timeSpan ); |
1691 | for( event = events.first(); event; event = events.next() ) { // for event | 1695 | for( event = events.first(); event; event = events.next() ) { // for event |
1692 | if ( event->doesRecur() ) { | 1696 | if ( event->doesRecur() ) { |
1693 | bool last; | 1697 | bool last; |
1694 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1698 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1695 | QDateTime incidenceEnd; | 1699 | QDateTime incidenceEnd; |
1696 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1700 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1697 | bool invalid = false; | 1701 | bool invalid = false; |
1698 | while( true ) { | 1702 | while( true ) { |
1699 | if ( incidenceStart.isValid() ) { | 1703 | if ( incidenceStart.isValid() ) { |
1700 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1704 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1701 | int st = incidenceStart.date().daysTo( endDate ); | 1705 | int st = incidenceStart.date().daysTo( endDate ); |
1702 | if ( st >= 0 ) { // start before timeend | 1706 | if ( st >= 0 ) { // start before timeend |
1703 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1707 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1704 | if ( end >= 0 ) { // end after timestart --- got one! | 1708 | if ( end >= 0 ) { // end after timestart --- got one! |
1705 | //normalize | 1709 | //normalize |
1706 | st = timeSpan - st; | 1710 | st = timeSpan - st; |
1707 | if ( st < 0 ) st = 0; | 1711 | if ( st < 0 ) st = 0; |
1708 | if ( end > timeSpan ) end = timeSpan; | 1712 | if ( end > timeSpan ) end = timeSpan; |
1709 | int iii; | 1713 | int iii; |
1710 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1714 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1711 | for ( iii = st;iii<= end;++iii) | 1715 | for ( iii = st;iii<= end;++iii) |
1712 | (*cells)[iii]->insertEvent( event ); | 1716 | (*cells)[iii]->insertEvent( event ); |
1713 | } | 1717 | } |
1714 | } | 1718 | } |
1715 | } else { | 1719 | } else { |
1716 | if ( invalid ) | 1720 | if ( invalid ) |
1717 | break; | 1721 | break; |
1718 | invalid = true; | 1722 | invalid = true; |
1719 | //qDebug("invalid %s", event->summary().latin1()); | 1723 | //qDebug("invalid %s", event->summary().latin1()); |
1720 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1724 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1721 | } | 1725 | } |
1722 | if ( last ) | 1726 | if ( last ) |
1723 | break; | 1727 | break; |
1724 | bool ok; | 1728 | bool ok; |
1725 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1729 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1726 | if ( ! ok ) | 1730 | if ( ! ok ) |
1727 | break; | 1731 | break; |
1728 | if ( incidenceStart.date() > endDate ) | 1732 | if ( incidenceStart.date() > endDate ) |
1729 | break; | 1733 | break; |
1730 | } | 1734 | } |
1731 | } else { // no recur | 1735 | } else { // no recur |
1732 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) | 1736 | if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) |
1733 | if ( event->uid().left(15) == QString("last-syncEvent-") ) | 1737 | if ( event->uid().left(15) == QString("last-syncEvent-") ) |
1734 | continue; | 1738 | continue; |
1735 | int st = event->dtStart().date().daysTo( endDate ); | 1739 | int st = event->dtStart().date().daysTo( endDate ); |
1736 | if ( st >= 0 ) { // start before timeend | 1740 | if ( st >= 0 ) { // start before timeend |
1737 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1741 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1738 | if ( end >= 0 ) { // end after timestart --- got one! | 1742 | if ( end >= 0 ) { // end after timestart --- got one! |
1739 | //normalize | 1743 | //normalize |
1740 | st = timeSpan - st; | 1744 | st = timeSpan - st; |
1741 | if ( st < 0 ) st = 0; | 1745 | if ( st < 0 ) st = 0; |
1742 | if ( end > timeSpan ) end = timeSpan; | 1746 | if ( end > timeSpan ) end = timeSpan; |
1743 | int iii; | 1747 | int iii; |
1744 | for ( iii = st;iii<= end;++iii) | 1748 | for ( iii = st;iii<= end;++iii) |
1745 | (*cells)[iii]->insertEvent( event ); | 1749 | (*cells)[iii]->insertEvent( event ); |
1746 | } | 1750 | } |
1747 | } | 1751 | } |
1748 | } | 1752 | } |
1749 | } | 1753 | } |
1750 | // insert due todos | 1754 | // insert due todos |
1751 | QPtrList<Todo> todos = calendar()->todos( ); | 1755 | QPtrList<Todo> todos = calendar()->todos( ); |
1752 | Todo *todo; | 1756 | Todo *todo; |
1753 | for(todo = todos.first(); todo; todo = todos.next()) { | 1757 | for(todo = todos.first(); todo; todo = todos.next()) { |
1754 | //insertTodo( todo ); | 1758 | //insertTodo( todo ); |
1755 | if ( todo->hasDueDate() ) { | 1759 | if ( todo->hasDueDate() ) { |
1756 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1760 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1757 | if ( day >= 0 && day < timeSpan + 1) { | 1761 | if ( day >= 0 && day < timeSpan + 1) { |
1758 | (*cells)[day]->insertTodo( todo ); | 1762 | (*cells)[day]->insertTodo( todo ); |
1759 | } | 1763 | } |
1760 | } | 1764 | } |
1761 | } | 1765 | } |
1762 | 1766 | ||
1763 | for( i = 0; i < timeSpan+1; ++i ) { | 1767 | for( i = 0; i < timeSpan+1; ++i ) { |
1764 | (*cells)[i]->finishUpdateCell(); | 1768 | (*cells)[i]->finishUpdateCell(); |
1765 | } | 1769 | } |
1766 | processSelectionChange(); | 1770 | processSelectionChange(); |
1767 | //qApp->processEvents(); | 1771 | //qApp->processEvents(); |
1768 | for( i = 0; i < timeSpan+1; ++i ) { | 1772 | for( i = 0; i < timeSpan+1; ++i ) { |
1769 | //(*cells)[i]->repaintfinishUpdateCell(); | 1773 | //(*cells)[i]->repaintfinishUpdateCell(); |
1770 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); | 1774 | QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) ); |
1771 | } | 1775 | } |
1772 | setKeyBFocus(); | 1776 | setKeyBFocus(); |
1773 | #else | 1777 | #else |
1774 | // old code | 1778 | // old code |
1775 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1779 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1776 | int i; | 1780 | int i; |
1777 | for( i = 0; i < (*cells).count(); ++i ) { | 1781 | for( i = 0; i < (*cells).count(); ++i ) { |
1778 | (*cells)[i]->updateCell(); | 1782 | (*cells)[i]->updateCell(); |
1779 | } | 1783 | } |
1780 | 1784 | ||
1781 | //qDebug("KOMonthView::updateView() "); | 1785 | //qDebug("KOMonthView::updateView() "); |
1782 | processSelectionChange(); | 1786 | processSelectionChange(); |
1783 | // qDebug("---------------------------------------------------------------------+ "); | 1787 | // qDebug("---------------------------------------------------------------------+ "); |
1784 | (*cells)[0]->setFocus(); | 1788 | (*cells)[0]->setFocus(); |
1785 | #endif | 1789 | #endif |
1786 | 1790 | ||
1787 | //qDebug("update time %d ", ti.elapsed()); | 1791 | //qDebug("update time %d ", ti.elapsed()); |
1788 | } | 1792 | } |
1789 | 1793 | ||
1790 | void KOMonthView::setKeyBoardFocus() | 1794 | void KOMonthView::setKeyBoardFocus() |
1791 | { | 1795 | { |
1792 | //qDebug("KOMonthView::setKeyBoardFocus() "); | 1796 | //qDebug("KOMonthView::setKeyBoardFocus() "); |
1793 | bool shootAgain = false; | 1797 | bool shootAgain = false; |
1794 | if ( mShowWeekView ) { | 1798 | if ( mShowWeekView ) { |
1795 | shootAgain = !mWeekLabelsW[1]->hasFocus(); | 1799 | shootAgain = !mWeekLabelsW[1]->hasFocus(); |
1796 | mWeekLabelsW[1]->setFocus(); | 1800 | mWeekLabelsW[1]->setFocus(); |
1797 | } | 1801 | } |
1798 | else { | 1802 | else { |
1799 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); | 1803 | shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); |
1800 | mWeekLabels[mNumWeeks]->setFocus(); | 1804 | mWeekLabels[mNumWeeks]->setFocus(); |
1801 | } | 1805 | } |
1802 | --mKBFcounter; | 1806 | --mKBFcounter; |
1803 | if ( shootAgain && mKBFcounter > 0 ) { | 1807 | if ( shootAgain && mKBFcounter > 0 ) { |
1804 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); | 1808 | QTimer::singleShot( 50, this, SLOT ( setKeyBoardFocus() ) ); |
1805 | } | 1809 | } |
1806 | } | 1810 | } |
1807 | void KOMonthView::setKeyBFocus() | 1811 | void KOMonthView::setKeyBFocus() |
1808 | { | 1812 | { |
1809 | //qDebug("KOMonthView::setKeyBFocus() "); | 1813 | //qDebug("KOMonthView::setKeyBFocus() "); |
1810 | mKBFcounter = 10; | 1814 | mKBFcounter = 10; |
1811 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); | 1815 | QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); |
1812 | } | 1816 | } |
1813 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1817 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1814 | { | 1818 | { |
1815 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); | 1819 | //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); |
1816 | if ( isVisible() ) { | 1820 | if ( isVisible() ) { |
1817 | //qDebug("KOMonthView::isVisible "); | 1821 | //qDebug("KOMonthView::isVisible "); |
1818 | slotComputeLayout(); | 1822 | slotComputeLayout(); |
1819 | } else | 1823 | } else |
1820 | mComputeLayoutTimer->start( 100 ); | 1824 | mComputeLayoutTimer->start( 100 ); |
1821 | if ( e ) | 1825 | if ( e ) |
1822 | KOEventView::resizeEvent( e ); | 1826 | KOEventView::resizeEvent( e ); |
1823 | } | 1827 | } |
1824 | 1828 | ||
1825 | void KOMonthView::slotComputeLayout() | 1829 | void KOMonthView::slotComputeLayout() |
1826 | { | 1830 | { |
1827 | mComputeLayoutTimer->stop(); | 1831 | mComputeLayoutTimer->stop(); |
1828 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); | 1832 | //qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() ); |
1829 | computeLayout(); | 1833 | computeLayout(); |
1830 | clPending = true; | 1834 | clPending = true; |
1831 | setKeyBFocus(); | 1835 | setKeyBFocus(); |
1832 | } | 1836 | } |
1833 | 1837 | ||
1834 | void KOMonthView::doComputeLayoutWeek() | 1838 | void KOMonthView::doComputeLayoutWeek() |
1835 | { | 1839 | { |
1836 | 1840 | ||
1837 | int daysToShow; | 1841 | int daysToShow; |
1838 | bool combinedSatSun = false; | 1842 | bool combinedSatSun = false; |
1839 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1843 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1840 | daysToShow = 6; | 1844 | daysToShow = 6; |
1841 | combinedSatSun = true; | 1845 | combinedSatSun = true; |
1842 | } | 1846 | } |
1843 | int wid = width();//e | 1847 | int wid = width();//e |
1844 | int hei = height()-1-mNavigatorBar->height(); | 1848 | int hei = height()-1-mNavigatorBar->height(); |
1845 | #ifdef DESKTOP_VERSION | 1849 | #ifdef DESKTOP_VERSION |
1846 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { | 1850 | if ( !KOPrefs::instance()->mMonthViewWeekRowlayout ) { |
1847 | daysToShow = 2; | 1851 | daysToShow = 2; |
1848 | } else | 1852 | } else |
1849 | #endif | 1853 | #endif |
1850 | { | 1854 | { |
1851 | if ( wid < hei + 40 ) | 1855 | if ( wid < hei + 40 ) |
1852 | daysToShow = 2; | 1856 | daysToShow = 2; |
1853 | else | 1857 | else |
1854 | daysToShow = 3; | 1858 | daysToShow = 3; |
1855 | } | 1859 | } |
1856 | bool landscape = (daysToShow == 3); | 1860 | bool landscape = (daysToShow == 3); |
1857 | mShowSatSunComp = true; | 1861 | mShowSatSunComp = true; |
1858 | combinedSatSun = true; | 1862 | combinedSatSun = true; |
1859 | 1863 | ||
1860 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); | 1864 | //qDebug("KOMonthView::computeLayout() WWW ------------------------------------ "); |
1861 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1865 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1862 | int weeklabelwid = fm.width( "888" ); | 1866 | int weeklabelwid = fm.width( "888" ); |
1863 | wid -= weeklabelwid; | 1867 | wid -= weeklabelwid; |
1864 | 1868 | ||
1865 | int colWid = wid / daysToShow; | 1869 | int colWid = wid / daysToShow; |
1866 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1870 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1867 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1871 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1868 | int colModulo = wid % daysToShow; | 1872 | int colModulo = wid % daysToShow; |
1869 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1873 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1870 | //qDebug("rowmod %d ", rowModulo); | 1874 | //qDebug("rowmod %d ", rowModulo); |
1871 | int i; | 1875 | int i; |
1872 | int x,y,w,h; | 1876 | int x,y,w,h; |
1873 | x= 0; | 1877 | x= 0; |
1874 | y= 0; | 1878 | y= 0; |
1875 | w = colWid; | 1879 | w = colWid; |
1876 | h = dayLabelHei ; | 1880 | h = dayLabelHei ; |
1877 | for ( i = 0; i < 7; i++) { | 1881 | for ( i = 0; i < 7; i++) { |
1878 | if ( i && !( i % daysToShow) && i < 6) { | 1882 | if ( i && !( i % daysToShow) && i < 6) { |
1879 | y += hei/(5-daysToShow); | 1883 | y += hei/(5-daysToShow); |
1880 | x = 0; | 1884 | x = 0; |