summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Unidiff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 8d06040..610aae6 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -356,770 +356,775 @@ void MonthViewItem::paint(QPainter *p)
356 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) ); 356 p->fillRect ( x, y-2,size,size+4, KOPrefs::instance()->defaultColor( mIncidence->calID() ) );
357 p->drawRect ( x, y-2,size,size+4); 357 p->drawRect ( x, y-2,size,size+4);
358 x += size + 1; 358 x += size + 1;
359 } 359 }
360 if ( KOPrefs::instance()->mMonthShowIcons ) { 360 if ( KOPrefs::instance()->mMonthShowIcons ) {
361 if ( mInfo ) { 361 if ( mInfo ) {
362 p->fillRect ( x, y,size,size, Qt::darkGreen ); 362 p->fillRect ( x, y,size,size, Qt::darkGreen );
363 x += size + 1; 363 x += size + 1;
364 } 364 }
365 if ( mRecur ) { 365 if ( mRecur ) {
366 p->fillRect ( x, y,size,size, Qt::blue ); 366 p->fillRect ( x, y,size,size, Qt::blue );
367 x += size + 1; 367 x += size + 1;
368 } 368 }
369 if ( mAlarm ) { 369 if ( mAlarm ) {
370 p->fillRect ( x, y,size,size, Qt::red ); 370 p->fillRect ( x, y,size,size, Qt::red );
371 x += size + 1; 371 x += size + 1;
372 } 372 }
373 if ( mReply ) { 373 if ( mReply ) {
374 p->fillRect ( x, y,size,size, Qt::yellow ); 374 p->fillRect ( x, y,size,size, Qt::yellow );
375 x += size + 1; 375 x += size + 1;
376 } 376 }
377 } 377 }
378 378
379 379
380 380
381 381
382 if ( sel ) p->setPen( Qt::white ); 382 if ( sel ) p->setPen( Qt::white );
383 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) ); 383 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) );
384 384
385#if 0 385#if 0
386 p->setPen( palette().color( QPalette::Normal, sel ? \ 386 p->setPen( palette().color( QPalette::Normal, sel ? \
387 QColorGroup::HighlightedText : QColorGroup::Foreground ) ); 387 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
388#endif 388#endif
389 QColor textColor = p->pen().color(); 389 QColor textColor = p->pen().color();
390 390
391 391
392 if ( mMultiday ) { 392 if ( mMultiday ) {
393 int yyy = y+(size/2); 393 int yyy = y+(size/2);
394 int sizeM = size+2; 394 int sizeM = size+2;
395 p->setBrush( QBrush( textColor ) ); 395 p->setBrush( QBrush( textColor ) );
396 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 396 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
397 if ( mMultiday == 2 || mMultiday == 3 ) { 397 if ( mMultiday == 2 || mMultiday == 3 ) {
398 QPointArray pa ( 3 ); 398 QPointArray pa ( 3 );
399 pa.setPoint (0, x, yyy ); 399 pa.setPoint (0, x, yyy );
400 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 400 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
401 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 401 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
402 p->drawPolygon( pa ); 402 p->drawPolygon( pa );
403 } 403 }
404 if ( mMultiday == 2 || mMultiday == 1 ) { 404 if ( mMultiday == 2 || mMultiday == 1 ) {
405 QPointArray pa ( 3 ); 405 QPointArray pa ( 3 );
406 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 406 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
407 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 407 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
408 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 408 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
409 p->drawPolygon( pa ); 409 p->drawPolygon( pa );
410 } 410 }
411 if ( mMultiday == 1 ) { 411 if ( mMultiday == 1 ) {
412 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 412 // p->fillRect ( x, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
413 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 ); 413 p->drawLine ( x+1, yyy-sizeM/2, x+1, yyy+sizeM/2 );
414 } 414 }
415 if ( mMultiday == 3 ) { 415 if ( mMultiday == 3 ) {
416 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) ); 416 // p->fillRect ( x+sizeM, yyy-sizeM/2+1, sizeM/2, size, QBrush ( QBrush::SolidPattern ) );
417 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 ); 417 p->drawLine ( x+sizeM +sizeM/2-1, yyy-sizeM/2, x+sizeM +sizeM/2-1, yyy+sizeM/2 );
418 418
419 } 419 }
420 x += sizeM/2 + 1; 420 x += sizeM/2 + 1;
421 x += sizeM + 1; 421 x += sizeM + 1;
422 } 422 }
423 423
424 if ( mIncidence->typeID() == todoID ){ 424 if ( mIncidence->typeID() == todoID ){
425 Todo* td = ( Todo* ) mIncidence; 425 Todo* td = ( Todo* ) mIncidence;
426 if ( td->isCompleted() ) { 426 if ( td->isCompleted() ) {
427 int half = size/2; 427 int half = size/2;
428 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 428 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
429 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ; 429 p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
430 x += half+half + 4; 430 x += half+half + 4;
431 431
432 } else { 432 } else {
433 int val = td->percentComplete()/20; 433 int val = td->percentComplete()/20;
434 p->fillRect ( x+1, y-2, val ,size+4,textColor ); 434 p->fillRect ( x+1, y-2, val ,size+4,textColor );
435 p->drawRect ( x, y-2,7,size+4); 435 p->drawRect ( x, y-2,7,size+4);
436 x += size + 3; 436 x += size + 3;
437 } 437 }
438 } 438 }
439 QFontMetrics fm = p->fontMetrics(); 439 QFontMetrics fm = p->fontMetrics();
440 int yPos; 440 int yPos;
441 int pmheight = size; 441 int pmheight = size;
442 if( pmheight < fm.height() ) 442 if( pmheight < fm.height() )
443 yPos = fm.ascent() + fm.leading()/2; 443 yPos = fm.ascent() + fm.leading()/2;
444 else 444 else
445 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 445 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
446 446
447 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 447 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
448 p->drawText( x, yPos, text() ); 448 p->drawText( x, yPos, text() );
449 if ( mIncidence->cancelled() ) { 449 if ( mIncidence->cancelled() ) {
450 int wid = fm.width( text() ); 450 int wid = fm.width( text() );
451 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 451 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
452 } 452 }
453 } else { 453 } else {
454 QString pText = text(); 454 QString pText = text();
455 if( pText.mid(2,1) == ":" ) 455 if( pText.mid(2,1) == ":" )
456 pText = pText.mid( 6 ); 456 pText = pText.mid( 6 );
457 p->drawText( x, yPos, pText ); 457 p->drawText( x, yPos, pText );
458 if ( mIncidence->cancelled() ) { 458 if ( mIncidence->cancelled() ) {
459 int wid = fm.width( pText ); 459 int wid = fm.width( pText );
460 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 460 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
461 } 461 }
462 } 462 }
463} 463}
464 464
465int MonthViewItem::height(const QListBox *lb) const 465int MonthViewItem::height(const QListBox *lb) const
466{ 466{
467 int ret = 10; 467 int ret = 10;
468 if ( lb ) 468 if ( lb )
469 ret = lb->fontMetrics().lineSpacing()+1; 469 ret = lb->fontMetrics().lineSpacing()+1;
470 return ret; 470 return ret;
471} 471}
472 472
473int MonthViewItem::width(const QListBox *lb) const 473int MonthViewItem::width(const QListBox *lb) const
474{ 474{
475 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 475 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
476 int size = PIXMAP_SIZE; 476 int size = PIXMAP_SIZE;
477 if ( QApplication::desktop()->width() < 300 ) 477 if ( QApplication::desktop()->width() < 300 )
478 size = 3; 478 size = 3;
479 int x = 1; 479 int x = 1;
480 if ( KOPrefs::instance()->mMonthShowIcons ) { 480 if ( KOPrefs::instance()->mMonthShowIcons ) {
481 if ( mInfo ) { 481 if ( mInfo ) {
482 x += size + 1; 482 x += size + 1;
483 } 483 }
484 if( mRecur ) { 484 if( mRecur ) {
485 x += size+1; 485 x += size+1;
486 } 486 }
487 if( mAlarm ) { 487 if( mAlarm ) {
488 x += size+1; 488 x += size+1;
489 } 489 }
490 if( mReply ) { 490 if( mReply ) {
491 x += size+1; 491 x += size+1;
492 } 492 }
493 } 493 }
494 if( mMultiday ) { 494 if( mMultiday ) {
495 x += size+1+2+size/2; 495 x += size+1+2+size/2;
496 } 496 }
497 return( x + lb->fontMetrics().width( text() ) + 1 ); 497 return( x + lb->fontMetrics().width( text() ) + 1 );
498 } 498 }
499 if ( ! lb ) 499 if ( ! lb )
500 return 10; 500 return 10;
501 return lb->width(); 501 return lb->width();
502} 502}
503 503
504 504
505MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) 505MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
506 : KNoScrollListBox( par ), 506 : KNoScrollListBox( par ),
507 mMonthView( parent ) 507 mMonthView( parent )
508{ 508{
509 //QVBoxLayout *topLayout = new QVBoxLayout( this ); 509 //QVBoxLayout *topLayout = new QVBoxLayout( this );
510 currentPalette = 0; 510 currentPalette = 0;
511 // mLabel = new QLabel( this );QPushButton 511 // mLabel = new QLabel( this );QPushButton
512 mLabel = new QPushButton( this ); 512 mLabel = new QPushButton( this );
513 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 513 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
514 //mLabel->setLineWidth( 1 ); 514 //mLabel->setLineWidth( 1 );
515 //mLabel->setAlignment( AlignCenter ); 515 //mLabel->setAlignment( AlignCenter );
516 mLabel->setFlat( true ); 516 mLabel->setFlat( true );
517 mLabel->setFocusPolicy(NoFocus); 517 mLabel->setFocusPolicy(NoFocus);
518 //mItemList = new KNoScrollListBox( this ); 518 //mItemList = new KNoScrollListBox( this );
519 setMinimumSize( 10, 10 ); 519 setMinimumSize( 10, 10 );
520 setFrameStyle( QFrame::Panel | QFrame::Plain ); 520 setFrameStyle( QFrame::Panel | QFrame::Plain );
521 setLineWidth( 1 ); 521 setLineWidth( 1 );
522 //topLayout->addWidget( mItemList ); 522 //topLayout->addWidget( mItemList );
523 mLabel->raise(); 523 mLabel->raise();
524 // QColor( 0,0,255 ) QColor( 160,1600,255 ) 524 // QColor( 0,0,255 ) QColor( 160,1600,255 )
525 mStandardPalette = palette(); 525 mStandardPalette = palette();
526 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); 526 mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
527 527
528 enableScrollBars( false ); 528 enableScrollBars( false );
529 updateConfig(); 529 updateConfig();
530 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); 530 //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() ));
531 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); 531 connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() ));
532 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), 532 connect( this , SIGNAL( doubleClicked( QListBoxItem *) ),
533 SLOT( defaultAction( QListBoxItem * ) ) ); 533 SLOT( defaultAction( QListBoxItem * ) ) );
534 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, 534 connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
535 const QPoint &) ), 535 const QPoint &) ),
536 SLOT( contextMenu( QListBoxItem * ) ) ); 536 SLOT( contextMenu( QListBoxItem * ) ) );
537 connect( this, SIGNAL( highlighted( QListBoxItem *) ), 537 connect( this, SIGNAL( highlighted( QListBoxItem *) ),
538 SLOT( selection( QListBoxItem * ) ) ); 538 SLOT( selection( QListBoxItem * ) ) );
539 539
540 /* 540 /*
541 connect( this, SIGNAL( clicked( QListBoxItem * ) ), 541 connect( this, SIGNAL( clicked( QListBoxItem * ) ),
542 SLOT( selection( QListBoxItem * ) ) ); 542 SLOT( selection( QListBoxItem * ) ) );
543 */ 543 */
544} 544}
545#ifdef DESKTOP_VERSION 545#ifdef DESKTOP_VERSION
546QToolTipGroup *MonthViewCell::toolTipGroup() 546QToolTipGroup *MonthViewCell::toolTipGroup()
547{ 547{
548 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); 548 if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
549 return mToolTipGroup; 549 return mToolTipGroup;
550} 550}
551#endif 551#endif
552 552
553void MonthViewCell::setDate( const QDate &date ) 553void MonthViewCell::setDate( const QDate &date )
554{ 554{
555 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; 555 // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
556 mDate = date; 556 mDate = date;
557 557
558 558
559 559
560 //resizeEvent( 0 ); 560 //resizeEvent( 0 );
561} 561}
562 562
563QDate MonthViewCell::date() const 563QDate MonthViewCell::date() const
564{ 564{
565 return mDate; 565 return mDate;
566} 566}
567 567
568void MonthViewCell::setPrimary( bool primary ) 568void MonthViewCell::setPrimary( bool primary )
569{ 569{
570 mPrimary = primary; 570 mPrimary = primary;
571 //setMyPalette(); 571 //setMyPalette();
572} 572}
573void MonthViewCell::setMyPalette() 573void MonthViewCell::setMyPalette()
574{ 574{
575 575
576 if ( mHoliday) { 576 if ( mHoliday) {
577 if ( currentPalette == 1 ) return; 577 if ( currentPalette == 1 ) return;
578 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); 578 mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) ));
579 setPalette( mHolidayPalette ); 579 setPalette( mHolidayPalette );
580 //mLabel->setPalette( mHolidayPalette ); 580 //mLabel->setPalette( mHolidayPalette );
581 currentPalette = 1; 581 currentPalette = 1;
582 582
583 } else { 583 } else {
584 if ( mPrimary ) { 584 if ( mPrimary ) {
585 if ( currentPalette == 2 ) return; 585 if ( currentPalette == 2 ) return;
586 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 586 mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
587 //mLabel->setPalette( mPrimaryPalette ); 587 //mLabel->setPalette( mPrimaryPalette );
588 setPalette( mPrimaryPalette ); 588 setPalette( mPrimaryPalette );
589 currentPalette = 2; 589 currentPalette = 2;
590 590
591 } else { 591 } else {
592 if ( currentPalette == 3 ) return; 592 if ( currentPalette == 3 ) return;
593 setPalette( mNonPrimaryPalette ); 593 setPalette( mNonPrimaryPalette );
594 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); 594 mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) ));
595 //mLabel->setPalette( mNonPrimaryPalette );; 595 //mLabel->setPalette( mNonPrimaryPalette );;
596 currentPalette = 3; 596 currentPalette = 3;
597 } 597 }
598 } 598 }
599 //QPalette pal = palette(); 599 //QPalette pal = palette();
600 600
601 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); 601 //mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
602} 602}
603QPalette MonthViewCell::getPalette () 603QPalette MonthViewCell::getPalette ()
604{ 604{
605 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 605 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
606 return mStandardPalette; 606 return mStandardPalette;
607 if ( mHoliday) { 607 if ( mHoliday) {
608 return mHolidayPalette ; 608 return mHolidayPalette ;
609 } else { 609 } else {
610 if ( mPrimary ) { 610 if ( mPrimary ) {
611 return mPrimaryPalette ; 611 return mPrimaryPalette ;
612 } 612 }
613 } 613 }
614 return mNonPrimaryPalette; 614 return mNonPrimaryPalette;
615} 615}
616bool MonthViewCell::isPrimary() const 616bool MonthViewCell::isPrimary() const
617{ 617{
618 return mPrimary; 618 return mPrimary;
619} 619}
620 620
621void MonthViewCell::setHoliday( bool holiday ) 621void MonthViewCell::setHoliday( bool holiday )
622{ 622{
623 mHoliday = holiday; 623 mHoliday = holiday;
624 //setMyPalette(); 624 //setMyPalette();
625} 625}
626 626
627void MonthViewCell::setHoliday( const QString &holiday ) 627void MonthViewCell::setHoliday( const QString &holiday )
628{ 628{
629 mHolidayString = holiday; 629 mHolidayString = holiday;
630 630
631 if ( !holiday.isEmpty() ) { 631 if ( !holiday.isEmpty() ) {
632 setHoliday( true ); 632 setHoliday( true );
633 } 633 }
634} 634}
635 635
636void MonthViewCell::startUpdateCell() 636void MonthViewCell::startUpdateCell()
637{ 637{
638 blockSignals( true ); 638 blockSignals( true );
639 mdayCount = 0; 639 mdayCount = 0;
640 setFocusPolicy(NoFocus); 640 setFocusPolicy(NoFocus);
641 if ( !mMonthView->isUpdatePossible() ) 641 if ( !mMonthView->isUpdatePossible() )
642 return; 642 return;
643 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 643 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
644 while ( mitem ) { 644 while ( mitem ) {
645 mitem->setBlockRepaint( true ); 645 mitem->setBlockRepaint( true );
646 mitem = (MonthViewItem *)mitem->next(); 646 mitem = (MonthViewItem *)mitem->next();
647 } 647 }
648 if ( mAvailItemList.count() > 20 ) { 648 if ( mAvailItemList.count() > 20 ) {
649 mAvailItemList.setAutoDelete( true ); 649 mAvailItemList.setAutoDelete( true );
650 mAvailItemList.clear(); 650 mAvailItemList.clear();
651 mAvailItemList.setAutoDelete( false ); 651 mAvailItemList.setAutoDelete( false );
652 clear(); 652 clear();
653 } 653 }
654 654
655 setPrimary( mDate.month()%2 ); 655 setPrimary( mDate.month()%2 );
656 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); 656 setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays);
657 if ( mDate == QDate::currentDate() ) { 657 if ( mDate == QDate::currentDate() ) {
658 setLineWidth( 3 ); 658 setLineWidth( 3 );
659 } else { 659 } else {
660 setLineWidth( 1 ); 660 setLineWidth( 1 );
661 } 661 }
662 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 662 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
663 //clear(); 663 //clear();
664 while ( CurrentAvailItem ) { 664 while ( CurrentAvailItem ) {
665 MonthViewItem *item = CurrentAvailItem; 665 MonthViewItem *item = CurrentAvailItem;
666 //item->setHighlightedFalse(); 666 //item->setHighlightedFalse();
667 item->recycle( 0, ""); 667 item->recycle( 0, "");
668 CurrentAvailItem = (MonthViewItem *)item->next(); 668 CurrentAvailItem = (MonthViewItem *)item->next();
669 mAvailItemList.append( item ); 669 mAvailItemList.append( item );
670 takeItem ( item ); 670 takeItem ( item );
671 } 671 }
672 672
673#ifdef DESKTOP_VERSION 673#ifdef DESKTOP_VERSION
674 QToolTip::remove(this); 674 QToolTip::remove(this);
675#endif 675#endif
676 mToolTip.clear(); 676 mToolTip.clear();
677 //qApp->processEvents(); 677 //qApp->processEvents();
678#if 0 678#if 0
679 if ( !mHolidayString.isEmpty() ) { 679 if ( !mHolidayString.isEmpty() ) {
680 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 680 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
681 item->setPalette( mHolidayPalette ); 681 item->setPalette( mHolidayPalette );
682 insertItem( item ); 682 insertItem( item );
683 mToolTip.append ( mHolidayString ); 683 mToolTip.append ( mHolidayString );
684 } 684 }
685#endif 685#endif
686} 686}
687 687
688int MonthViewCell::insertEvent(Event *event) 688int MonthViewCell::insertEvent(Event *event)
689{ 689{
690 bool useToolTips = true; 690 bool useToolTips = true;
691#ifndef DESKTOP_VERSION 691#ifndef DESKTOP_VERSION
692 useToolTips = false; 692 useToolTips = false;
693#endif 693#endif
694 QString mToolTipText; 694 QString mToolTipText;
695 setFocusPolicy(WheelFocus); 695 setFocusPolicy(WheelFocus);
696 if ( !(event->doesRecur() == Recurrence::rNone) ) { 696 if ( !(event->doesRecur() == Recurrence::rNone) ) {
697 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 697 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
698 return mdayCount; 698 return mdayCount;
699 else 699 else
700 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 700 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
701 return mdayCount; 701 return mdayCount;
702 } 702 }
703 703
704 if ( event->isHoliday()) { 704 if ( event->isHoliday()) {
705 setHoliday( true ); 705 setHoliday( true );
706 if ( mDate.dayOfWeek() == 7 ) 706 if ( mDate.dayOfWeek() == 7 )
707 setLineWidth( 3 ); 707 setLineWidth( 3 );
708 } 708 }
709 QString text; 709 QString text;
710 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day 710 int multiday = 0;// 1 = start, 2 = midddle, 3 = end day
711 if (event->isMultiDay()) { 711 if (event->isMultiDay()) {
712 QString prefix = "<->";multiday = 2; 712 QString prefix = "<->";multiday = 2;
713 QString time; 713 QString time;
714 if ( event->doesRecur() ) { 714 if ( event->doesRecur() ) {
715 if ( event->recursOn( mDate) ) { 715 if ( event->recursOn( mDate) ) {
716 prefix ="->" ;multiday = 1; 716 prefix ="->" ;multiday = 1;
717 } 717 }
718 else { 718 else {
719 int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); 719 int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
720 if ( event->recursOn( mDate.addDays( -days)) ) { 720 if ( event->recursOn( mDate.addDays( -days)) ) {
721 prefix ="<-" ;multiday = 3; 721 prefix ="<-" ;multiday = 3;
722 } 722 }
723 } 723 }
724 724
725 } else { 725 } else {
726 if (mDate == event->dtStart().date()) { 726 if (mDate == event->dtStart().date()) {
727 prefix ="->" ;multiday = 1; 727 prefix ="->" ;multiday = 1;
728 } else if (mDate == event->dtEnd().date()) { 728 } else if (mDate == event->dtEnd().date()) {
729 prefix ="<-" ;multiday = 3; 729 prefix ="<-" ;multiday = 3;
730 } 730 }
731 } 731 }
732 if ( !event->doesFloat() ) { 732 if ( !event->doesFloat() ) {
733 if ( mDate == event->dtStart().date () ) 733 if ( mDate == event->dtStart().date () )
734 time = KGlobal::locale()->formatTime(event->dtStart().time())+" "; 734 time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
735 else if ( mDate == event->dtEnd().date () ) 735 else if ( mDate == event->dtEnd().date () )
736 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" "; 736 time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
737 737
738 } 738 }
739 text = time + event->summary(); 739 text = time + event->summary();
740 if ( useToolTips ) 740 if ( useToolTips ) {
741 mToolTipText += prefix + text; 741 mToolTipText += prefix + text;
742 if ( event->doesFloat() ) {
743 mToolTipText += i18n(" (Duration: %1 days)" ).arg ( event->dtStart().daysTo(event->dtEnd())+1);
744
745 }
746 }
742 } else { 747 } else {
743 if (event->doesFloat()) { 748 if (event->doesFloat()) {
744 text = event->summary(); 749 text = event->summary();
745 if ( useToolTips ) 750 if ( useToolTips )
746 mToolTipText += text; 751 mToolTipText += text;
747 } 752 }
748 else { 753 else {
749 text = KGlobal::locale()->formatTime(event->dtStart().time()); 754 text = KGlobal::locale()->formatTime(event->dtStart().time());
750 text += " " + event->summary(); 755 text += " " + event->summary();
751 if ( useToolTips ) 756 if ( useToolTips )
752 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); 757 mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary();
753 } 758 }
754 } 759 }
755 if ( useToolTips && ! event->location().isEmpty() ) { 760 if ( useToolTips && ! event->location().isEmpty() ) {
756 mToolTipText += " (" + event->location() +")"; 761 mToolTipText += " (" + event->location() +")";
757 } 762 }
758 MonthViewItem *item ; 763 MonthViewItem *item ;
759 764
760 if ( mAvailItemList.count() ) { 765 if ( mAvailItemList.count() ) {
761 item = mAvailItemList.first(); 766 item = mAvailItemList.first();
762 mAvailItemList.remove( item ); 767 mAvailItemList.remove( item );
763 item->recycle( event, text ); 768 item->recycle( event, text );
764 } else { 769 } else {
765 item = new MonthViewItem( event, text ); 770 item = new MonthViewItem( event, text );
766 } 771 }
767 772
768 QPalette pal; 773 QPalette pal;
769 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 774 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
770 QStringList categories = event->categories(); 775 QStringList categories = event->categories();
771 QString cat = categories.first(); 776 QString cat = categories.first();
772 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 777 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
773 pal = getPalette(); 778 pal = getPalette();
774 if (cat.isEmpty()) { 779 if (cat.isEmpty()) {
775 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 780 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
776 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() )); 781 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( event->calID() ));
777 } else { 782 } else {
778 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 783 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
779 } 784 }
780 785
781 } else { 786 } else {
782 if (cat.isEmpty()) { 787 if (cat.isEmpty()) {
783 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 788 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
784 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() )); 789 pal = QPalette( KOPrefs::instance()->defaultColor( event->calID() ), KOPrefs::instance()->defaultColor( event->calID() ));
785 } else { 790 } else {
786 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 791 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
787 } 792 }
788 } 793 }
789 794
790 } else { 795 } else {
791 pal = mStandardPalette ; 796 pal = mStandardPalette ;
792 } 797 }
793 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); 798 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
794 item->setPalette( pal ); 799 item->setPalette( pal );
795 item->setRecur( event->doesRecur() ); 800 item->setRecur( event->doesRecur() );
796 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() ); 801 item->setAlarm( event->isAlarmEnabled() && multiday < 2 && event->alarmEnabled() );
797 item->setMoreInfo( event->description().length() > 0 ); 802 item->setMoreInfo( event->description().length() > 0 );
798#ifdef DESKTOP_VERSION 803#ifdef DESKTOP_VERSION
799 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, 804 Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails,
800 KOPrefs::instance()->email()); 805 KOPrefs::instance()->email());
801 if ( me != 0 ) { 806 if ( me != 0 ) {
802 if ( me->status() == Attendee::NeedsAction && me->RSVP()) 807 if ( me->status() == Attendee::NeedsAction && me->RSVP())
803 item->setReply(true && multiday < 2); 808 item->setReply(true && multiday < 2);
804 else 809 else
805 item->setReply(false); 810 item->setReply(false);
806 } else 811 } else
807 item->setReply(false); 812 item->setReply(false);
808#endif 813#endif
809 814
810 item->setMultiDay( multiday ); 815 item->setMultiDay( multiday );
811 if ( multiday ) { 816 if ( multiday ) {
812 insertItem( item ,mdayCount); 817 insertItem( item ,mdayCount);
813 ++mdayCount; 818 ++mdayCount;
814 } else { 819 } else {
815 uint i = mdayCount; 820 uint i = mdayCount;
816 uint pos = mdayCount; 821 uint pos = mdayCount;
817 uint itcount = count(); 822 uint itcount = count();
818 if ( itcount > 1000 ) { 823 if ( itcount > 1000 ) {
819 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount); 824 qDebug("KO: Bug in MonthViewCell::insertEvent %u ", itcount);
820 itcount = 0; 825 itcount = 0;
821 } 826 }
822 for ( i = pos; i < itcount;++i ) { 827 for ( i = pos; i < itcount;++i ) {
823 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount ); 828 // qDebug("i %d mday %u count %d ",i,itcount,mdayCount );
824 QListBoxItem* it = this->item ( i ); 829 QListBoxItem* it = this->item ( i );
825 if ( it && text < it->text() ) { 830 if ( it && text < it->text() ) {
826 pos = i; 831 pos = i;
827 break; 832 break;
828 } 833 }
829 ++pos; 834 ++pos;
830 } 835 }
831 insertItem( item ,pos); 836 insertItem( item ,pos);
832 } 837 }
833 if ( useToolTips ) { 838 if ( useToolTips ) {
834 mToolTip.append( mToolTipText ); 839 mToolTip.append( mToolTipText );
835 } 840 }
836 return mdayCount; 841 return mdayCount;
837} 842}
838void MonthViewCell::insertTodo(Todo *todo) 843void MonthViewCell::insertTodo(Todo *todo)
839{ 844{
840 setFocusPolicy(WheelFocus); 845 setFocusPolicy(WheelFocus);
841 QString text; 846 QString text;
842 if (todo->hasDueDate()) { 847 if (todo->hasDueDate()) {
843 if (!todo->doesFloat()) { 848 if (!todo->doesFloat()) {
844 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 849 text += KGlobal::locale()->formatTime(todo->dtDue().time());
845 text += " "; 850 text += " ";
846 } 851 }
847 } 852 }
848 text += todo->summary(); 853 text += todo->summary();
849 MonthViewItem *item ; 854 MonthViewItem *item ;
850 if ( mAvailItemList.count() ) { 855 if ( mAvailItemList.count() ) {
851 item = mAvailItemList.first(); 856 item = mAvailItemList.first();
852 mAvailItemList.remove( item ); 857 mAvailItemList.remove( item );
853 item->recycle( todo, text ); 858 item->recycle( todo, text );
854 } else { 859 } else {
855 item = new MonthViewItem( todo, text ); 860 item = new MonthViewItem( todo, text );
856 } 861 }
857 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 862 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
858 //item->setPalette( mStandardPalette ); 863 //item->setPalette( mStandardPalette );
859 QPalette pal; 864 QPalette pal;
860 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 865 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
861 QStringList categories = todo->categories(); 866 QStringList categories = todo->categories();
862 QString cat = categories.first(); 867 QString cat = categories.first();
863 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 868 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
864 pal = getPalette(); 869 pal = getPalette();
865 if (cat.isEmpty()) { 870 if (cat.isEmpty()) {
866 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 871 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
867 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 872 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
868 } else { 873 } else {
869 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 874 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
870 } 875 }
871 876
872 } else { 877 } else {
873 if (cat.isEmpty()) { 878 if (cat.isEmpty()) {
874 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 879 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
875 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() )); 880 pal = QPalette(KOPrefs::instance()->defaultColor( todo->calID() ), KOPrefs::instance()->defaultColor( todo->calID() ));
876 } else { 881 } else {
877 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 882 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
878 } 883 }
879 } 884 }
880 885
881 } else { 886 } else {
882 pal = mStandardPalette ; 887 pal = mStandardPalette ;
883 } 888 }
884 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); 889 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
885 item->setPalette( pal ); 890 item->setPalette( pal );
886 item->setRecur( todo->doesRecur() ); 891 item->setRecur( todo->doesRecur() );
887 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 892 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
888 item->setMoreInfo( todo->description().length() > 0 ); 893 item->setMoreInfo( todo->description().length() > 0 );
889 insertItem( item , count()); 894 insertItem( item , count());
890#ifdef DESKTOP_VERSION 895#ifdef DESKTOP_VERSION
891 mToolTip.append( text ); 896 mToolTip.append( text );
892#endif 897#endif
893} 898}
894void MonthViewCell::repaintfinishUpdateCell() 899void MonthViewCell::repaintfinishUpdateCell()
895{ 900{
896 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 901 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
897 while ( mitem ) { 902 while ( mitem ) {
898 mitem->setBlockRepaint( false ); 903 mitem->setBlockRepaint( false );
899 updateItem ( mitem ); 904 updateItem ( mitem );
900 mitem = (MonthViewItem *)mitem->next(); 905 mitem = (MonthViewItem *)mitem->next();
901 } 906 }
902 blockSignals( false ); 907 blockSignals( false );
903} 908}
904void MonthViewCell::finishUpdateCell() 909void MonthViewCell::finishUpdateCell()
905{ 910{
906 911
907 912
908 913
909#ifdef DESKTOP_VERSION 914#ifdef DESKTOP_VERSION
910 if (mToolTip.count() > 0 ) { 915 if (mToolTip.count() > 0 ) {
911 mToolTip.sort(); 916 mToolTip.sort();
912 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 917 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
913 } 918 }
914#endif 919#endif
915 //sort(); 920 //sort();
916 //setMyPalette(); 921 //setMyPalette();
917 setMyPalette(); 922 setMyPalette();
918 923
919 resizeEvent( 0 ); 924 resizeEvent( 0 );
920 925
921} 926}
922void MonthViewCell::updateCell() 927void MonthViewCell::updateCell()
923{ 928{
924 if ( !mMonthView->isUpdatePossible() ) 929 if ( !mMonthView->isUpdatePossible() )
925 return; 930 return;
926 startUpdateCell(); 931 startUpdateCell();
927 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 932 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
928 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 933 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
929 Event *event; 934 Event *event;
930 for( event = events.first(); event; event = events.next() ) { // for event 935 for( event = events.first(); event; event = events.next() ) { // for event
931 insertEvent(event); 936 insertEvent(event);
932 } 937 }
933 // insert due todos 938 // insert due todos
934 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 939 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
935 Todo *todo; 940 Todo *todo;
936 for(todo = todos.first(); todo; todo = todos.next()) { 941 for(todo = todos.first(); todo; todo = todos.next()) {
937 insertTodo( todo ); 942 insertTodo( todo );
938 } 943 }
939 finishUpdateCell(); 944 finishUpdateCell();
940 // if ( isVisible()) 945 // if ( isVisible())
941 //qApp->processEvents(); 946 //qApp->processEvents();
942} 947}
943 948
944void MonthViewCell::updateConfig( bool bigFont ) // = false 949void MonthViewCell::updateConfig( bool bigFont ) // = false
945{ 950{
946 951
947 if ( bigFont ) { 952 if ( bigFont ) {
948 QFont fo = KOPrefs::instance()->mMonthViewFont; 953 QFont fo = KOPrefs::instance()->mMonthViewFont;
949 int ps = fo.pointSize() + 2; 954 int ps = fo.pointSize() + 2;
950 if ( ps < 18 ) 955 if ( ps < 18 )
951 ps += 2; 956 ps += 2;
952 fo.setPointSize( ps ); 957 fo.setPointSize( ps );
953 setFont( fo ); 958 setFont( fo );
954 } else 959 } else
955 setFont( KOPrefs::instance()->mMonthViewFont ); 960 setFont( KOPrefs::instance()->mMonthViewFont );
956 961
957 QFontMetrics fm( font() ); 962 QFontMetrics fm( font() );
958 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); 963 mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
959 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); 964 mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
960 mHolidayPalette = mStandardPalette; 965 mHolidayPalette = mStandardPalette;
961 mPrimaryPalette = mStandardPalette; 966 mPrimaryPalette = mStandardPalette;
962 mNonPrimaryPalette = mStandardPalette; 967 mNonPrimaryPalette = mStandardPalette;
963 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { 968 if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
964 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); 969 mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
965 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); 970 mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
966 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); 971 mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
967 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); 972 mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark());
968 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); 973 mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor);
969 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); 974 mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor);
970 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); 975 mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark());
971 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); 976 mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor);
972 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); 977 mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor);
973 } 978 }
974 //updateCell(); 979 //updateCell();
975} 980}
976 981
977void MonthViewCell::enableScrollBars( bool enabled ) 982void MonthViewCell::enableScrollBars( bool enabled )
978{ 983{
979 984
980 return; 985 return;
981 if ( enabled ) { 986 if ( enabled ) {
982 QListBoxItem *fi = firstItem (); 987 QListBoxItem *fi = firstItem ();
983 if (fi ) { 988 if (fi ) {
984 int ihei = fi->height( this ); 989 int ihei = fi->height( this );
985 int hei = numRows () * ihei; 990 int hei = numRows () * ihei;
986 if ( hei < height() - horizontalScrollBar()->height () ) { 991 if ( hei < height() - horizontalScrollBar()->height () ) {
987 setVScrollBarMode(QScrollView::AlwaysOff); 992 setVScrollBarMode(QScrollView::AlwaysOff);
988 } 993 }
989 else 994 else
990 setVScrollBarMode(QScrollView::Auto); 995 setVScrollBarMode(QScrollView::Auto);
991 if ( ihei *3 > height() ) { 996 if ( ihei *3 > height() ) {
992 setHScrollBarMode(QScrollView::AlwaysOff); 997 setHScrollBarMode(QScrollView::AlwaysOff);
993 } 998 }
994 else { 999 else {
995 setHScrollBarMode(QScrollView::Auto); 1000 setHScrollBarMode(QScrollView::Auto);
996 } 1001 }
997 } else { 1002 } else {
998 setVScrollBarMode(QScrollView::Auto); 1003 setVScrollBarMode(QScrollView::Auto);
999 setHScrollBarMode(QScrollView::Auto); 1004 setHScrollBarMode(QScrollView::Auto);
1000 } 1005 }
1001 } else { 1006 } else {
1002 setVScrollBarMode(QScrollView::AlwaysOff); 1007 setVScrollBarMode(QScrollView::AlwaysOff);
1003 setHScrollBarMode(QScrollView::AlwaysOff); 1008 setHScrollBarMode(QScrollView::AlwaysOff);
1004 } 1009 }
1005} 1010}
1006 1011
1007Incidence *MonthViewCell::selectedIncidence() 1012Incidence *MonthViewCell::selectedIncidence()
1008{ 1013{
1009 int index = currentItem(); 1014 int index = currentItem();
1010 if ( index < 0 ) return 0; 1015 if ( index < 0 ) return 0;
1011 1016
1012 MonthViewItem *mitem = 1017 MonthViewItem *mitem =
1013 static_cast<MonthViewItem *>( item( index ) ); 1018 static_cast<MonthViewItem *>( item( index ) );
1014 1019
1015 if ( !mitem ) return 0; 1020 if ( !mitem ) return 0;
1016 1021
1017 return mitem->incidence(); 1022 return mitem->incidence();
1018} 1023}
1019 1024
1020QDate MonthViewCell::selectedIncidenceDate() 1025QDate MonthViewCell::selectedIncidenceDate()
1021{ 1026{
1022 QDate qd; 1027 QDate qd;
1023 int index = currentItem(); 1028 int index = currentItem();
1024 if ( index < 0 ) return qd; 1029 if ( index < 0 ) return qd;
1025 return mDate; 1030 return mDate;
1026} 1031}
1027 1032
1028void MonthViewCell::deselect() 1033void MonthViewCell::deselect()
1029{ 1034{
1030 clearSelection(); 1035 clearSelection();
1031 enableScrollBars( false ); 1036 enableScrollBars( false );
1032 // updateCell(); 1037 // updateCell();
1033} 1038}
1034void MonthViewCell::select() 1039void MonthViewCell::select()
1035{ 1040{
1036 ;// updateCell(); 1041 ;// updateCell();
1037} 1042}
1038 1043
1039void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1044void MonthViewCell::resizeEvent ( QResizeEvent * e )
1040{ 1045{
1041 if ( !mMonthView->isUpdatePossible() ) 1046 if ( !mMonthView->isUpdatePossible() )
1042 return; 1047 return;
1043 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1048 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1044 deselect(); 1049 deselect();
1045 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1050 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1046 1051
1047 QString text; 1052 QString text;
1048 //mLabel->setText( text ); 1053 //mLabel->setText( text );
1049 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1054 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1050 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 1055 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
1051 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() ); 1056 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() );
1052 mLabel->resize( mLabelBigSize ); 1057 mLabel->resize( mLabelBigSize );
1053 } else { 1058 } else {
1054 mLabel->resize( mLabelSize ); 1059 mLabel->resize( mLabelSize );
1055 text = QString::number( mDate.day() ); 1060 text = QString::number( mDate.day() );
1056 } 1061 }
1057 mLabel->setText( text ); 1062 mLabel->setText( text );
1058 1063
1059 int size = height() - mLabel->height() - lineWidth()-1; 1064 int size = height() - mLabel->height() - lineWidth()-1;
1060 //qDebug("LW %d ", lineWidth()); 1065 //qDebug("LW %d ", lineWidth());
1061 if ( size > 0 ) 1066 if ( size > 0 )
1062 verticalScrollBar()->setMaximumHeight( size ); 1067 verticalScrollBar()->setMaximumHeight( size );
1063 size = width() - mLabel->width() -lineWidth()-1; 1068 size = width() - mLabel->width() -lineWidth()-1;
1064 if ( size > 0 ) 1069 if ( size > 0 )
1065 horizontalScrollBar()->setMaximumWidth( size ); 1070 horizontalScrollBar()->setMaximumWidth( size );
1066 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1071 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1067 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1072 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1068 // mItemList->resize ( width(), height () ); 1073 // mItemList->resize ( width(), height () );
1069 if ( e ) 1074 if ( e )
1070 KNoScrollListBox::resizeEvent ( e ); 1075 KNoScrollListBox::resizeEvent ( e );
1071} 1076}
1072 1077
1073void MonthViewCell::defaultAction( QListBoxItem *item ) 1078void MonthViewCell::defaultAction( QListBoxItem *item )
1074{ 1079{
1075 1080
1076 if ( !item ) { 1081 if ( !item ) {
1077 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1082 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1078 emit newEventSignal( dt ); 1083 emit newEventSignal( dt );
1079 return; 1084 return;
1080 } 1085 }
1081 1086
1082 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1087 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1083 Incidence *incidence = eventItem->incidence(); 1088 Incidence *incidence = eventItem->incidence();
1084 if ( incidence ) mMonthView->defaultAction( incidence ); 1089 if ( incidence ) mMonthView->defaultAction( incidence );
1085} 1090}
1086void MonthViewCell::showDay() 1091void MonthViewCell::showDay()
1087{ 1092{
1088 emit showDaySignal( date() ); 1093 emit showDaySignal( date() );
1089} 1094}
1090void MonthViewCell::newEvent() 1095void MonthViewCell::newEvent()
1091{ 1096{
1092 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1097 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1093 emit newEventSignal( dt ); 1098 emit newEventSignal( dt );
1094} 1099}
1095void MonthViewCell::cellClicked( QListBoxItem *item ) 1100void MonthViewCell::cellClicked( QListBoxItem *item )
1096{ 1101{
1097 mMonthView->setSelectedCell( this ); 1102 mMonthView->setSelectedCell( this );
1098 if ( item == 0 ) { 1103 if ( item == 0 ) {
1099 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1104 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1100 emit newEventSignal( dt ); 1105 emit newEventSignal( dt );
1101 return; 1106 return;
1102 } 1107 }
1103 1108
1104} 1109}
1105 1110
1106void MonthViewCell::contextMenu( QListBoxItem *item ) 1111void MonthViewCell::contextMenu( QListBoxItem *item )
1107{ 1112{
1108 mMonthView->setPopupCell( this ); 1113 mMonthView->setPopupCell( this );
1109 if ( !item ) { 1114 if ( !item ) {
1110 mMonthView->showContextMenu( 0 ); 1115 mMonthView->showContextMenu( 0 );
1111 return; 1116 return;
1112 } 1117 }
1113 //selection( item ); 1118 //selection( item );
1114 //qApp->processEvents(); 1119 //qApp->processEvents();
1115 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1120 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1116 Incidence *incidence = eventItem->incidence(); 1121 Incidence *incidence = eventItem->incidence();
1117 if ( incidence ) { 1122 if ( incidence ) {
1118 mBlockDeselect = true; 1123 mBlockDeselect = true;
1119 mMonthView->showContextMenu( incidence ); 1124 mMonthView->showContextMenu( incidence );
1120 } 1125 }
1121} 1126}
1122 1127
1123void MonthViewCell::selection( QListBoxItem *item ) 1128void MonthViewCell::selection( QListBoxItem *item )
1124{ 1129{
1125 if ( !item ) { 1130 if ( !item ) {