summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp65
-rw-r--r--korganizer/komonthview.h4
2 files changed, 54 insertions, 15 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 1c2d6a2..264cf28 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -325,152 +325,165 @@ void MonthViewItem::paint(QPainter *p)
325{ 325{
326 if ( mblockRepaint || !mIncidence ) { 326 if ( mblockRepaint || !mIncidence ) {
327 return; 327 return;
328 } 328 }
329#if QT_VERSION >= 0x030000 329#if QT_VERSION >= 0x030000
330 bool sel = isSelected(); 330 bool sel = isSelected();
331#else 331#else
332 bool sel = selected(); 332 bool sel = selected();
333#endif 333#endif
334 int heihei = height( listBox () ); 334 int heihei = height( listBox () );
335 int x = 1; 335 int x = 1;
336 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel ) 336 if (KOPrefs::instance()->mMonthViewUsesCategoryColor || mDisplayHighlighted || sel )
337 { 337 {
338 338
339 p->setBackgroundColor( palette().color( QPalette::Normal, \ 339 p->setBackgroundColor( palette().color( QPalette::Normal, \
340 sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) ); 340 sel ||mDisplayHighlighted ? QColorGroup::Highlight : QColorGroup::Background ) );
341 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei ); 341 p->eraseRect( 0, 0, listBox()->maxItemWidth(), heihei );
342 } 342 }
343 343
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
374
375
376
377 if ( sel ) p->setPen( Qt::white );
378 else p->setPen( palette().color( QPalette::Normal,QColorGroup::Foreground ) );
379
380#if 0
381 p->setPen( palette().color( QPalette::Normal, sel ? \
382 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
383#endif
384 QColor textColor = p->pen().color();
385
386
373 if ( mMultiday ) { 387 if ( mMultiday ) {
374 int yyy = y+(size/2); 388 int yyy = y+(size/2);
375 int sizeM = size+2; 389 int sizeM = size+2;
376 p->setBrush( QBrush( p->pen().color() ) ); 390 p->setBrush( QBrush( textColor ) );
377 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ; 391 p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
378 if ( mMultiday == 2 || mMultiday == 3 ) { 392 if ( mMultiday == 2 || mMultiday == 3 ) {
379 QPointArray pa ( 3 ); 393 QPointArray pa ( 3 );
380 pa.setPoint (0, x, yyy ); 394 pa.setPoint (0, x, yyy );
381 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 ); 395 pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
382 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 ); 396 pa.setPoint (2, x+sizeM/2, yyy-sizeM/2 );
383 p->drawPolygon( pa ); 397 p->drawPolygon( pa );
384 } 398 }
385 if ( mMultiday == 2 || mMultiday == 1 ) { 399 if ( mMultiday == 2 || mMultiday == 1 ) {
386 QPointArray pa ( 3 ); 400 QPointArray pa ( 3 );
387 pa.setPoint (0, x+sizeM +sizeM/2, yyy ); 401 pa.setPoint (0, x+sizeM +sizeM/2, yyy );
388 pa.setPoint (1, x+sizeM, yyy+sizeM/2 ); 402 pa.setPoint (1, x+sizeM, yyy+sizeM/2 );
389 pa.setPoint (2, x+sizeM, yyy-sizeM/2 ); 403 pa.setPoint (2, x+sizeM, yyy-sizeM/2 );
390 p->drawPolygon( pa ); 404 p->drawPolygon( pa );
391 } 405 }
392 if ( mMultiday == 1 ) { 406 if ( mMultiday == 1 ) {
393 // 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 ) );
394 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 );
395 } 409 }
396 if ( mMultiday == 3 ) { 410 if ( mMultiday == 3 ) {
397 // 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 ) );
398 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 );
399 413
400 } 414 }
401 x += sizeM/2 + 1; 415 x += sizeM/2 + 1;
402 x += sizeM + 1; 416 x += sizeM + 1;
403 } 417 }
404 418
405 if ( mIncidence->typeID() == todoID ){ 419 if ( mIncidence->typeID() == todoID ){
406 Todo* td = ( Todo* ) mIncidence; 420 Todo* td = ( Todo* ) mIncidence;
407 if ( td->isCompleted() ) { 421 if ( td->isCompleted() ) {
408 int half = size/2; 422 int half = size/2;
409 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ; 423 p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
410 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 ) ;
411 x += half+half + 4; 425 x += half+half + 4;
412 426
413 } else { 427 } else {
414 int val = td->percentComplete()/20; 428 int val = td->percentComplete()/20;
415 p->fillRect ( x+1, y-2, val ,size+4,p->pen().color() ); 429 p->fillRect ( x+1, y-2, val ,size+4,textColor );
416 p->drawRect ( x, y-2,7,size+4); 430 p->drawRect ( x, y-2,7,size+4);
417 x += size + 3; 431 x += size + 3;
418 } 432 }
419 } 433 }
420 QFontMetrics fm = p->fontMetrics(); 434 QFontMetrics fm = p->fontMetrics();
421 int yPos; 435 int yPos;
422 int pmheight = size; 436 int pmheight = size;
423 if( pmheight < fm.height() ) 437 if( pmheight < fm.height() )
424 yPos = fm.ascent() + fm.leading()/2; 438 yPos = fm.ascent() + fm.leading()/2;
425 else 439 else
426 yPos = pmheight/2 - fm.height()/2 + fm.ascent(); 440 yPos = pmheight/2 - fm.height()/2 + fm.ascent();
427 p->setPen( palette().color( QPalette::Normal, sel ? \ 441
428 QColorGroup::HighlightedText : QColorGroup::Foreground ) );
429 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) { 442 if ( KOPrefs::instance()->mMonthShowTimes || isWeekItem) {
430 p->drawText( x, yPos, text() ); 443 p->drawText( x, yPos, text() );
431 if ( mIncidence->cancelled() ) { 444 if ( mIncidence->cancelled() ) {
432 int wid = fm.width( text() ); 445 int wid = fm.width( text() );
433 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 446 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
434 } 447 }
435 } else { 448 } else {
436 QString pText = text(); 449 QString pText = text();
437 if( pText.mid(2,1) == ":" ) 450 if( pText.mid(2,1) == ":" )
438 pText = pText.mid( 6 ); 451 pText = pText.mid( 6 );
439 p->drawText( x, yPos, pText ); 452 p->drawText( x, yPos, pText );
440 if ( mIncidence->cancelled() ) { 453 if ( mIncidence->cancelled() ) {
441 int wid = fm.width( pText ); 454 int wid = fm.width( pText );
442 p->drawLine( x, heihei/2 ,x+wid, heihei/2 ); 455 p->drawLine( x, heihei/2 ,x+wid, heihei/2 );
443 } 456 }
444 } 457 }
445} 458}
446 459
447int MonthViewItem::height(const QListBox *lb) const 460int MonthViewItem::height(const QListBox *lb) const
448{ 461{
449 int ret = 10; 462 int ret = 10;
450 if ( lb ) 463 if ( lb )
451 ret = lb->fontMetrics().lineSpacing()+1; 464 ret = lb->fontMetrics().lineSpacing()+1;
452 return ret; 465 return ret;
453} 466}
454 467
455int MonthViewItem::width(const QListBox *lb) const 468int MonthViewItem::width(const QListBox *lb) const
456{ 469{
457 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { 470 if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) {
458 int size = PIXMAP_SIZE; 471 int size = PIXMAP_SIZE;
459 if ( QApplication::desktop()->width() < 300 ) 472 if ( QApplication::desktop()->width() < 300 )
460 size = 3; 473 size = 3;
461 int x = 1; 474 int x = 1;
462 if ( KOPrefs::instance()->mMonthShowIcons ) { 475 if ( KOPrefs::instance()->mMonthShowIcons ) {
463 if ( mInfo ) { 476 if ( mInfo ) {
464 x += size + 1; 477 x += size + 1;
465 } 478 }
466 if( mRecur ) { 479 if( mRecur ) {
467 x += size+1; 480 x += size+1;
468 } 481 }
469 if( mAlarm ) { 482 if( mAlarm ) {
470 x += size+1; 483 x += size+1;
471 } 484 }
472 if( mReply ) { 485 if( mReply ) {
473 x += size+1; 486 x += size+1;
474 } 487 }
475 } 488 }
476 if( mMultiday ) { 489 if( mMultiday ) {
@@ -572,97 +585,97 @@ void MonthViewCell::setMyPalette()
572 585
573 } else { 586 } else {
574 if ( currentPalette == 3 ) return; 587 if ( currentPalette == 3 ) return;
575 setPalette( mNonPrimaryPalette ); 588 setPalette( mNonPrimaryPalette );
576 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 ) ));
577 //mLabel->setPalette( mNonPrimaryPalette );; 590 //mLabel->setPalette( mNonPrimaryPalette );;
578 currentPalette = 3; 591 currentPalette = 3;
579 } 592 }
580 } 593 }
581 //QPalette pal = palette(); 594 //QPalette pal = palette();
582 595
583 //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 ) ));
584} 597}
585QPalette MonthViewCell::getPalette () 598QPalette MonthViewCell::getPalette ()
586{ 599{
587 if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) 600 if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
588 return mStandardPalette; 601 return mStandardPalette;
589 if ( mHoliday) { 602 if ( mHoliday) {
590 return mHolidayPalette ; 603 return mHolidayPalette ;
591 } else { 604 } else {
592 if ( mPrimary ) { 605 if ( mPrimary ) {
593 return mPrimaryPalette ; 606 return mPrimaryPalette ;
594 } 607 }
595 } 608 }
596 return mNonPrimaryPalette; 609 return mNonPrimaryPalette;
597} 610}
598bool MonthViewCell::isPrimary() const 611bool MonthViewCell::isPrimary() const
599{ 612{
600 return mPrimary; 613 return mPrimary;
601} 614}
602 615
603void MonthViewCell::setHoliday( bool holiday ) 616void MonthViewCell::setHoliday( bool holiday )
604{ 617{
605 mHoliday = holiday; 618 mHoliday = holiday;
606 //setMyPalette(); 619 //setMyPalette();
607} 620}
608 621
609void MonthViewCell::setHoliday( const QString &holiday ) 622void MonthViewCell::setHoliday( const QString &holiday )
610{ 623{
611 mHolidayString = holiday; 624 mHolidayString = holiday;
612 625
613 if ( !holiday.isEmpty() ) { 626 if ( !holiday.isEmpty() ) {
614 setHoliday( true ); 627 setHoliday( true );
615 } 628 }
616} 629}
617 630
618void MonthViewCell::startUpdateCell() 631void MonthViewCell::startUpdateCell()
619{ 632{
620 633 blockSignals( true );
621 mdayCount = 0; 634 mdayCount = 0;
622 setFocusPolicy(NoFocus); 635 setFocusPolicy(NoFocus);
623 if ( !mMonthView->isUpdatePossible() ) 636 if ( !mMonthView->isUpdatePossible() )
624 return; 637 return;
625 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 638 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
626 while ( mitem ) { 639 while ( mitem ) {
627 mitem->setBlockRepaint( true ); 640 mitem->setBlockRepaint( true );
628 mitem = (MonthViewItem *)mitem->next(); 641 mitem = (MonthViewItem *)mitem->next();
629 } 642 }
630 if ( mAvailItemList.count() > 20 ) { 643 if ( mAvailItemList.count() > 20 ) {
631 mAvailItemList.setAutoDelete( true ); 644 mAvailItemList.setAutoDelete( true );
632 mAvailItemList.clear(); 645 mAvailItemList.clear();
633 mAvailItemList.setAutoDelete( false ); 646 mAvailItemList.setAutoDelete( false );
634 clear(); 647 clear();
635 } 648 }
636 649
637 setPrimary( mDate.month()%2 ); 650 setPrimary( mDate.month()%2 );
638 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);
639 if ( mDate == QDate::currentDate() ) { 652 if ( mDate == QDate::currentDate() ) {
640 setLineWidth( 3 ); 653 setLineWidth( 3 );
641 } else { 654 } else {
642 setLineWidth( 1 ); 655 setLineWidth( 1 );
643 } 656 }
644 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); 657 MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem ();
645 //clear(); 658 //clear();
646 while ( CurrentAvailItem ) { 659 while ( CurrentAvailItem ) {
647 MonthViewItem *item = CurrentAvailItem; 660 MonthViewItem *item = CurrentAvailItem;
648 //item->setHighlightedFalse(); 661 //item->setHighlightedFalse();
649 item->recycle( 0, ""); 662 item->recycle( 0, "");
650 CurrentAvailItem = (MonthViewItem *)item->next(); 663 CurrentAvailItem = (MonthViewItem *)item->next();
651 mAvailItemList.append( item ); 664 mAvailItemList.append( item );
652 takeItem ( item ); 665 takeItem ( item );
653 } 666 }
654 667
655#ifdef DESKTOP_VERSION 668#ifdef DESKTOP_VERSION
656 QToolTip::remove(this); 669 QToolTip::remove(this);
657#endif 670#endif
658 mToolTip.clear(); 671 mToolTip.clear();
659 //qApp->processEvents(); 672 //qApp->processEvents();
660#if 0 673#if 0
661 if ( !mHolidayString.isEmpty() ) { 674 if ( !mHolidayString.isEmpty() ) {
662 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); 675 MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString );
663 item->setPalette( mHolidayPalette ); 676 item->setPalette( mHolidayPalette );
664 insertItem( item ); 677 insertItem( item );
665 mToolTip.append ( mHolidayString ); 678 mToolTip.append ( mHolidayString );
666 } 679 }
667#endif 680#endif
668} 681}
@@ -836,96 +849,97 @@ void MonthViewCell::insertTodo(Todo *todo)
836 } else { 849 } else {
837 item = new MonthViewItem( todo, text ); 850 item = new MonthViewItem( todo, text );
838 } 851 }
839 //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 852 //MonthViewItem *item = new MonthViewItem( todo, mDate, text );
840 //item->setPalette( mStandardPalette ); 853 //item->setPalette( mStandardPalette );
841 QPalette pal; 854 QPalette pal;
842 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 855 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
843 QStringList categories = todo->categories(); 856 QStringList categories = todo->categories();
844 QString cat = categories.first(); 857 QString cat = categories.first();
845 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { 858 if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) {
846 pal = getPalette(); 859 pal = getPalette();
847 if (cat.isEmpty()) { 860 if (cat.isEmpty()) {
848 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); 861 //pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor);
849 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() )); 862 pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->defaultColor( todo->calID() ));
850 } else { 863 } else {
851 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); 864 pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
852 } 865 }
853 866
854 } else { 867 } else {
855 if (cat.isEmpty()) { 868 if (cat.isEmpty()) {
856 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); 869 //pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
857 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() ));
858 } else { 871 } else {
859 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); 872 pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
860 } 873 }
861 } 874 }
862 875
863 } else { 876 } else {
864 pal = mStandardPalette ; 877 pal = mStandardPalette ;
865 } 878 }
866 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor); 879 pal.setColor(QColorGroup::Highlight, KOPrefs::instance()->mHighlightColor);
867 item->setPalette( pal ); 880 item->setPalette( pal );
868 item->setRecur( todo->recurrence()->doesRecur() ); 881 item->setRecur( todo->recurrence()->doesRecur() );
869 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() ); 882 item->setAlarm( todo->isAlarmEnabled() && todo->alarmEnabled() );
870 item->setMoreInfo( todo->description().length() > 0 ); 883 item->setMoreInfo( todo->description().length() > 0 );
871 insertItem( item , count()); 884 insertItem( item , count());
872#ifdef DESKTOP_VERSION 885#ifdef DESKTOP_VERSION
873 mToolTip.append( text ); 886 mToolTip.append( text );
874#endif 887#endif
875} 888}
876void MonthViewCell::repaintfinishUpdateCell() 889void MonthViewCell::repaintfinishUpdateCell()
877{ 890{
878 MonthViewItem *mitem = (MonthViewItem*) firstItem (); 891 MonthViewItem *mitem = (MonthViewItem*) firstItem ();
879 while ( mitem ) { 892 while ( mitem ) {
880 mitem->setBlockRepaint( false ); 893 mitem->setBlockRepaint( false );
881 updateItem ( mitem ); 894 updateItem ( mitem );
882 mitem = (MonthViewItem *)mitem->next(); 895 mitem = (MonthViewItem *)mitem->next();
883 } 896 }
897 blockSignals( false );
884} 898}
885void MonthViewCell::finishUpdateCell() 899void MonthViewCell::finishUpdateCell()
886{ 900{
887 901
888 902
889 903
890#ifdef DESKTOP_VERSION 904#ifdef DESKTOP_VERSION
891 if (mToolTip.count() > 0 ) { 905 if (mToolTip.count() > 0 ) {
892 mToolTip.sort(); 906 mToolTip.sort();
893 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); 907 QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),"");
894 } 908 }
895#endif 909#endif
896 //sort(); 910 //sort();
897 //setMyPalette(); 911 //setMyPalette();
898 setMyPalette(); 912 setMyPalette();
899 913
900 resizeEvent( 0 ); 914 resizeEvent( 0 );
901 915
902} 916}
903void MonthViewCell::updateCell() 917void MonthViewCell::updateCell()
904{ 918{
905 if ( !mMonthView->isUpdatePossible() ) 919 if ( !mMonthView->isUpdatePossible() )
906 return; 920 return;
907 startUpdateCell(); 921 startUpdateCell();
908 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 922 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
909 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); 923 QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
910 Event *event; 924 Event *event;
911 for( event = events.first(); event; event = events.next() ) { // for event 925 for( event = events.first(); event; event = events.next() ) { // for event
912 insertEvent(event); 926 insertEvent(event);
913 } 927 }
914 // insert due todos 928 // insert due todos
915 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); 929 QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
916 Todo *todo; 930 Todo *todo;
917 for(todo = todos.first(); todo; todo = todos.next()) { 931 for(todo = todos.first(); todo; todo = todos.next()) {
918 insertTodo( todo ); 932 insertTodo( todo );
919 } 933 }
920 finishUpdateCell(); 934 finishUpdateCell();
921 // if ( isVisible()) 935 // if ( isVisible())
922 //qApp->processEvents(); 936 //qApp->processEvents();
923} 937}
924 938
925void MonthViewCell::updateConfig( bool bigFont ) // = false 939void MonthViewCell::updateConfig( bool bigFont ) // = false
926{ 940{
927 941
928 if ( bigFont ) { 942 if ( bigFont ) {
929 QFont fo = KOPrefs::instance()->mMonthViewFont; 943 QFont fo = KOPrefs::instance()->mMonthViewFont;
930 int ps = fo.pointSize() + 2; 944 int ps = fo.pointSize() + 2;
931 if ( ps < 18 ) 945 if ( ps < 18 )
@@ -981,105 +995,104 @@ void MonthViewCell::enableScrollBars( bool enabled )
981 } 995 }
982 } else { 996 } else {
983 setVScrollBarMode(QScrollView::AlwaysOff); 997 setVScrollBarMode(QScrollView::AlwaysOff);
984 setHScrollBarMode(QScrollView::AlwaysOff); 998 setHScrollBarMode(QScrollView::AlwaysOff);
985 } 999 }
986} 1000}
987 1001
988Incidence *MonthViewCell::selectedIncidence() 1002Incidence *MonthViewCell::selectedIncidence()
989{ 1003{
990 int index = currentItem(); 1004 int index = currentItem();
991 if ( index < 0 ) return 0; 1005 if ( index < 0 ) return 0;
992 1006
993 MonthViewItem *mitem = 1007 MonthViewItem *mitem =
994 static_cast<MonthViewItem *>( item( index ) ); 1008 static_cast<MonthViewItem *>( item( index ) );
995 1009
996 if ( !mitem ) return 0; 1010 if ( !mitem ) return 0;
997 1011
998 return mitem->incidence(); 1012 return mitem->incidence();
999} 1013}
1000 1014
1001QDate MonthViewCell::selectedIncidenceDate() 1015QDate MonthViewCell::selectedIncidenceDate()
1002{ 1016{
1003 QDate qd; 1017 QDate qd;
1004 int index = currentItem(); 1018 int index = currentItem();
1005 if ( index < 0 ) return qd; 1019 if ( index < 0 ) return qd;
1006 return mDate; 1020 return mDate;
1007} 1021}
1008 1022
1009void MonthViewCell::deselect() 1023void MonthViewCell::deselect()
1010{ 1024{
1011 clearSelection(); 1025 clearSelection();
1012 enableScrollBars( false ); 1026 enableScrollBars( false );
1013 // updateCell(); 1027 // updateCell();
1014} 1028}
1015void MonthViewCell::select() 1029void MonthViewCell::select()
1016{ 1030{
1017 ;// updateCell(); 1031 ;// updateCell();
1018} 1032}
1019 1033
1020void MonthViewCell::resizeEvent ( QResizeEvent * e ) 1034void MonthViewCell::resizeEvent ( QResizeEvent * e )
1021{ 1035{
1022 if ( !mMonthView->isUpdatePossible() ) 1036 if ( !mMonthView->isUpdatePossible() )
1023 return; 1037 return;
1024 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 1038 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
1025 deselect(); 1039 deselect();
1026 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 1040 mLabel->setMaximumHeight( height() - lineWidth()*2 );
1027 1041
1028 QString text; 1042 QString text;
1029 mLabel->setText( text ); 1043 //mLabel->setText( text );
1030 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 1044 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
1031 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) {
1032 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 1046 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " " + QString::number( mDate.day() );
1033 mLabel->resize( mLabelBigSize ); 1047 mLabel->resize( mLabelBigSize );
1034 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
1035 } else { 1048 } else {
1036 mLabel->resize( mLabelSize ); 1049 mLabel->resize( mLabelSize );
1037 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 1050 text = QString::number( mDate.day() );
1038 } 1051 }
1039 mLabel->setText( text ); 1052 mLabel->setText( text );
1040 1053
1041 int size = height() - mLabel->height() - lineWidth()-1; 1054 int size = height() - mLabel->height() - lineWidth()-1;
1042 //qDebug("LW %d ", lineWidth()); 1055 //qDebug("LW %d ", lineWidth());
1043 if ( size > 0 ) 1056 if ( size > 0 )
1044 verticalScrollBar()->setMaximumHeight( size ); 1057 verticalScrollBar()->setMaximumHeight( size );
1045 size = width() - mLabel->width() -lineWidth()-1; 1058 size = width() - mLabel->width() -lineWidth()-1;
1046 if ( size > 0 ) 1059 if ( size > 0 )
1047 horizontalScrollBar()->setMaximumWidth( size ); 1060 horizontalScrollBar()->setMaximumWidth( size );
1048 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 1061 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
1049 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 1062 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
1050 // mItemList->resize ( width(), height () ); 1063 // mItemList->resize ( width(), height () );
1051 if ( e ) 1064 if ( e )
1052 KNoScrollListBox::resizeEvent ( e ); 1065 KNoScrollListBox::resizeEvent ( e );
1053} 1066}
1054 1067
1055void MonthViewCell::defaultAction( QListBoxItem *item ) 1068void MonthViewCell::defaultAction( QListBoxItem *item )
1056{ 1069{
1057 1070
1058 if ( !item ) { 1071 if ( !item ) {
1059 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1072 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1060 emit newEventSignal( dt ); 1073 emit newEventSignal( dt );
1061 return; 1074 return;
1062 } 1075 }
1063 1076
1064 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 1077 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
1065 Incidence *incidence = eventItem->incidence(); 1078 Incidence *incidence = eventItem->incidence();
1066 if ( incidence ) mMonthView->defaultAction( incidence ); 1079 if ( incidence ) mMonthView->defaultAction( incidence );
1067} 1080}
1068void MonthViewCell::showDay() 1081void MonthViewCell::showDay()
1069{ 1082{
1070 emit showDaySignal( date() ); 1083 emit showDaySignal( date() );
1071} 1084}
1072void MonthViewCell::newEvent() 1085void MonthViewCell::newEvent()
1073{ 1086{
1074 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1087 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1075 emit newEventSignal( dt ); 1088 emit newEventSignal( dt );
1076} 1089}
1077void MonthViewCell::cellClicked( QListBoxItem *item ) 1090void MonthViewCell::cellClicked( QListBoxItem *item )
1078{ 1091{
1079 mMonthView->setSelectedCell( this ); 1092 mMonthView->setSelectedCell( this );
1080 if ( item == 0 ) { 1093 if ( item == 0 ) {
1081 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 1094 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
1082 emit newEventSignal( dt ); 1095 emit newEventSignal( dt );
1083 return; 1096 return;
1084 } 1097 }
1085 1098
@@ -1292,143 +1305,168 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
1292 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false); 1305 mNewItemMenu->insertItem( SmallIcon( pathString +"newtodo" ),i18n("New Todo..."),this,SLOT(slotNewTodo()),false);
1293 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false); 1306 mNewItemMenu->insertItem( SmallIcon( pathString +"journal" ),i18n("Journal"),this,SLOT(slotEditJournal()),false);
1294 1307
1295 // updateConfig(); //useless here... 1308 // updateConfig(); //useless here...
1296 // ... but we need mWidthLongDayLabel computed 1309 // ... but we need mWidthLongDayLabel computed
1297 QFontMetrics fontmetric(mDayLabels[0]->font()); 1310 QFontMetrics fontmetric(mDayLabels[0]->font());
1298 mWidthLongDayLabel = 0; 1311 mWidthLongDayLabel = 0;
1299 for (int i = 0; i < 7; i++) { 1312 for (int i = 0; i < 7; i++) {
1300 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); 1313 int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
1301 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; 1314 if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
1302 } 1315 }
1303 1316
1304 //mWeekLabels[mNumWeeks]->setText( i18n("W")); 1317 //mWeekLabels[mNumWeeks]->setText( i18n("W"));
1305 1318
1306#if 0 1319#if 0
1307 if ( mShowWeekView ) 1320 if ( mShowWeekView )
1308 mWidStack->raiseWidget( mWeekView ); 1321 mWidStack->raiseWidget( mWeekView );
1309 else 1322 else
1310 mWidStack->raiseWidget( mMonthView ); 1323 mWidStack->raiseWidget( mMonthView );
1311#endif 1324#endif
1312 1325
1313 emit incidenceSelected( 0 ); 1326 emit incidenceSelected( 0 );
1314 1327
1315 mComputeLayoutTimer = new QTimer( this ); 1328 mComputeLayoutTimer = new QTimer( this );
1316 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout())); 1329 connect (mComputeLayoutTimer ,SIGNAL(timeout()), this, SLOT ( slotComputeLayout()));
1317 1330
1318 1331
1319#ifndef DESKTOP_VERSION 1332#ifndef DESKTOP_VERSION
1320 resize( QApplication::desktop()->size() ); 1333 resize( QApplication::desktop()->size() );
1321#else 1334#else
1322 resize(640, 480 ); 1335 resize(640, 480 );
1323 updatePossible = true; 1336 updatePossible = true;
1324#endif 1337#endif
1325 computeLayout(); 1338 computeLayout();
1326 1339
1327 if ( mShowWeekView ) 1340 if ( mShowWeekView )
1328 mWidStack->raiseWidget( mWeekView ); 1341 mWidStack->raiseWidget( mWeekView );
1329 else 1342 else
1330 mWidStack->raiseWidget( mMonthView ); 1343 mWidStack->raiseWidget( mMonthView );
1331} 1344}
1332 1345
1333KOMonthView::~KOMonthView() 1346KOMonthView::~KOMonthView()
1334{ 1347{
1335 delete mContextMenu; 1348 delete mContextMenu;
1336} 1349}
1337 1350
1338void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday ) 1351void KOMonthView::incidenceHighlighted( Incidence * inc , MonthViewCell* mc, int mday )
1339{ 1352{
1340 qDebug("11 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1341 static Incidence * lastInc = 0; 1353 static Incidence * lastInc = 0;
1342 static MonthViewCell * lastCell = 0; 1354 static MonthViewCell * lastCell = 0;
1343 1355
1344 if ( lastInc == inc && lastCell == mc ) 1356 if ( lastInc == inc && lastCell == mc )
1345 return; 1357 return;
1346 lastInc = inc; 1358 lastInc = inc;
1347 lastCell = mc; 1359 lastCell = mc;
1348 qDebug("222 KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday ); 1360 //qDebug("KOMonthView::incidenceHighlighted %d %d %d", inc, mc, mday );
1349 1361
1350 bool weekview = false; 1362 bool weekview = false;
1351 int index = 0; 1363 int index = 0;
1352 for (uint i = 0; i < mCellsW.count(); ++i) { 1364 for (uint i = 0; i < mCellsW.count(); ++i) {
1353 if ( mCellsW[i] == mc ) { 1365 if ( mCellsW[i] == mc ) {
1354 weekview = true; 1366 weekview = true;
1355 index = i; 1367 index = i;
1356 break; 1368 break;
1357 } 1369 }
1358 } 1370 }
1359 QPtrVector<MonthViewCell> *cells; 1371 QPtrVector<MonthViewCell> *cells;
1360 if ( weekview ) 1372 if ( weekview )
1361 cells = &mCellsW; 1373 cells = &mCellsW;
1362 else { 1374 else {
1363 for (uint i = 0; i < mCells.count(); ++i) { 1375 for (uint i = 0; i < mCells.count(); ++i) {
1364 if ( mCells[i] == mc ) { 1376 if ( mCells[i] == mc ) {
1365 index = i; 1377 index = i;
1366 break; 1378 break;
1367 } 1379 }
1368 } 1380 }
1369 cells = &mCells; 1381 cells = &mCells;
1370 } 1382 }
1371 for (uint i = 0; i < (*cells).count(); ++i) { 1383 for (uint i = 0; i < (*cells).count(); ++i) {
1372 (*cells)[i]->deHighLight(); 1384 (*cells)[i]->deHighLight();
1373 } 1385 }
1374 if ( ! inc ) 1386 if ( ! inc )
1375 return; 1387 return;
1388
1389 int count = (*cells).count();
1390 bool goLeft = (mday > 1 && index > 0);
1391 bool goRight = (mday < 3 && mday > 0 && index < count -1);
1392 for (uint iii = 1; iii < count; ++iii) {
1393 if ( goLeft ) {
1394 int left = index - iii;
1395 if ( left >= 0 ) {
1396 if ( (*cells)[(uint)left]->doHighLight(inc) )
1397 goLeft = false;
1398 } else
1399 goLeft = false;
1400 }
1401 if ( goRight ) {
1402 int right = index + iii;
1403 if ( right < count ) {
1404 if ( (*cells)[right]->doHighLight(inc) )
1405 goRight = false;
1406
1407 } else
1408 goRight = false;
1409 }
1410
1411 }
1412#if 0
1376 if ( mday > 1 && index > 0 ) 1413 if ( mday > 1 && index > 0 )
1377 for (int i = index-1; i >= 0; --i) { 1414 for (int i = index-1; i >= 0; --i) {
1378 //qDebug("index %d iii %d ", index, i); 1415 //qDebug("index %d iii %d ", index, i);
1379 if ( (*cells)[(uint)i]->doHighLight(inc) ) 1416 if ( (*cells)[(uint)i]->doHighLight(inc) )
1380 break; 1417 break;
1381 } 1418 }
1382 if ( mday < 3 && mday > 0 && index < (*cells).count()-1) 1419 if ( mday < 3 && mday > 0 && index < (*cells).count()-1)
1383 for (uint i = index+1; i < (*cells).count(); ++i) { 1420 for (uint i = index+1; i < (*cells).count(); ++i) {
1384 if ( (*cells)[i]->doHighLight(inc) ) 1421 if ( (*cells)[i]->doHighLight(inc) )
1385 break; 1422 break;
1386 } 1423 }
1424#endif
1387 1425
1388} 1426}
1389void KOMonthView::selectInternalWeekNum ( int n ) 1427void KOMonthView::selectInternalWeekNum ( int n )
1390{ 1428{
1391 switchView(); 1429 switchView();
1392 if ( !KOPrefs::instance()->mMonthViewWeek ) 1430 if ( !KOPrefs::instance()->mMonthViewWeek )
1393 emit selectMonth (); 1431 emit selectMonth ();
1394 else 1432 else
1395 emit selectWeekNum ( n ); 1433 emit selectWeekNum ( n );
1396} 1434}
1397 1435
1398int KOMonthView::currentWeek() 1436int KOMonthView::currentWeek()
1399{ 1437{
1400 if ( mShowWeekView ) 1438 if ( mShowWeekView )
1401 return mWeekLabelsW[0]->getWeekNum(); 1439 return mWeekLabelsW[0]->getWeekNum();
1402 return mWeekLabels[0]->getWeekNum(); 1440 return mWeekLabels[0]->getWeekNum();
1403} 1441}
1404void KOMonthView::switchView() 1442void KOMonthView::switchView()
1405{ 1443{
1406 if ( selectedCell( ) ) 1444 if ( selectedCell( ) )
1407 selectedCell()->deselect(); 1445 selectedCell()->deselect();
1408 mShowWeekView = !mShowWeekView; 1446 mShowWeekView = !mShowWeekView;
1409 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 1447 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
1410 if ( clPending ) { 1448 if ( clPending ) {
1411 computeLayout(); 1449 computeLayout();
1412 updateConfig(); 1450 updateConfig();
1413 } 1451 }
1414 if ( mShowWeekView ) 1452 if ( mShowWeekView )
1415 mWidStack->raiseWidget( mWeekView ); 1453 mWidStack->raiseWidget( mWeekView );
1416 else 1454 else
1417 mWidStack->raiseWidget( mMonthView ); 1455 mWidStack->raiseWidget( mMonthView );
1418 clPending = false; 1456 clPending = false;
1419} 1457}
1420 1458
1421int KOMonthView::maxDatesHint() 1459int KOMonthView::maxDatesHint()
1422{ 1460{
1423 return mNumCells; 1461 return mNumCells;
1424} 1462}
1425 1463
1426int KOMonthView::currentDateCount() 1464int KOMonthView::currentDateCount()
1427{ 1465{
1428 return mNumCells; 1466 return mNumCells;
1429} 1467}
1430 1468
1431QPtrList<Incidence> KOMonthView::selectedIncidences() 1469QPtrList<Incidence> KOMonthView::selectedIncidences()
1432{ 1470{
1433 QPtrList<Incidence> selected; 1471 QPtrList<Incidence> selected;
1434 1472
@@ -1676,97 +1714,98 @@ void KOMonthView::updateView()
1676 } 1714 }
1677 if ( last ) 1715 if ( last )
1678 break; 1716 break;
1679 bool ok; 1717 bool ok;
1680 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1718 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1681 if ( ! ok ) 1719 if ( ! ok )
1682 break; 1720 break;
1683 if ( incidenceStart.date() > endDate ) 1721 if ( incidenceStart.date() > endDate )
1684 break; 1722 break;
1685 } 1723 }
1686 } else { // no recur 1724 } else { // no recur
1687 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") ) 1725 if ( !KOPrefs::instance()->mShowSyncEvents && event->uid().left(2) == QString("la") )
1688 if ( event->uid().left(15) == QString("last-syncEvent-") ) 1726 if ( event->uid().left(15) == QString("last-syncEvent-") )
1689 continue; 1727 continue;
1690 int st = event->dtStart().date().daysTo( endDate ); 1728 int st = event->dtStart().date().daysTo( endDate );
1691 if ( st >= 0 ) { // start before timeend 1729 if ( st >= 0 ) { // start before timeend
1692 int end = mStartDate.daysTo( event->dtEnd().date() ); 1730 int end = mStartDate.daysTo( event->dtEnd().date() );
1693 if ( end >= 0 ) { // end after timestart --- got one! 1731 if ( end >= 0 ) { // end after timestart --- got one!
1694 //normalize 1732 //normalize
1695 st = timeSpan - st; 1733 st = timeSpan - st;
1696 if ( st < 0 ) st = 0; 1734 if ( st < 0 ) st = 0;
1697 if ( end > timeSpan ) end = timeSpan; 1735 if ( end > timeSpan ) end = timeSpan;
1698 int iii; 1736 int iii;
1699 for ( iii = st;iii<= end;++iii) 1737 for ( iii = st;iii<= end;++iii)
1700 (*cells)[iii]->insertEvent( event ); 1738 (*cells)[iii]->insertEvent( event );
1701 } 1739 }
1702 } 1740 }
1703 } 1741 }
1704 } 1742 }
1705 // insert due todos 1743 // insert due todos
1706 QPtrList<Todo> todos = calendar()->todos( ); 1744 QPtrList<Todo> todos = calendar()->todos( );
1707 Todo *todo; 1745 Todo *todo;
1708 for(todo = todos.first(); todo; todo = todos.next()) { 1746 for(todo = todos.first(); todo; todo = todos.next()) {
1709 //insertTodo( todo ); 1747 //insertTodo( todo );
1710 if ( todo->hasDueDate() ) { 1748 if ( todo->hasDueDate() ) {
1711 int day = mStartDate.daysTo( todo->dtDue().date() ); 1749 int day = mStartDate.daysTo( todo->dtDue().date() );
1712 if ( day >= 0 && day < timeSpan + 1) { 1750 if ( day >= 0 && day < timeSpan + 1) {
1713 (*cells)[day]->insertTodo( todo ); 1751 (*cells)[day]->insertTodo( todo );
1714 } 1752 }
1715 } 1753 }
1716 } 1754 }
1717 1755
1718 for( i = 0; i < timeSpan+1; ++i ) { 1756 for( i = 0; i < timeSpan+1; ++i ) {
1719 (*cells)[i]->finishUpdateCell(); 1757 (*cells)[i]->finishUpdateCell();
1720 } 1758 }
1721 processSelectionChange(); 1759 processSelectionChange();
1722 //qApp->processEvents(); 1760 //qApp->processEvents();
1723 for( i = 0; i < timeSpan+1; ++i ) { 1761 for( i = 0; i < timeSpan+1; ++i ) {
1724 (*cells)[i]->repaintfinishUpdateCell(); 1762 //(*cells)[i]->repaintfinishUpdateCell();
1763 QTimer::singleShot( 0, (*cells)[i], SLOT ( repaintfinishUpdateCell() ) );
1725 } 1764 }
1726 setKeyBFocus(); 1765 setKeyBFocus();
1727#else 1766#else
1728 // old code 1767 // old code
1729 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); 1768 //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
1730 int i; 1769 int i;
1731 for( i = 0; i < (*cells).count(); ++i ) { 1770 for( i = 0; i < (*cells).count(); ++i ) {
1732 (*cells)[i]->updateCell(); 1771 (*cells)[i]->updateCell();
1733 } 1772 }
1734 1773
1735 //qDebug("KOMonthView::updateView() "); 1774 //qDebug("KOMonthView::updateView() ");
1736 processSelectionChange(); 1775 processSelectionChange();
1737 // qDebug("---------------------------------------------------------------------+ "); 1776 // qDebug("---------------------------------------------------------------------+ ");
1738 (*cells)[0]->setFocus(); 1777 (*cells)[0]->setFocus();
1739#endif 1778#endif
1740 1779
1741 //qDebug("update time %d ", ti.elapsed()); 1780 //qDebug("update time %d ", ti.elapsed());
1742} 1781}
1743 1782
1744void KOMonthView::setKeyBoardFocus() 1783void KOMonthView::setKeyBoardFocus()
1745{ 1784{
1746 //qDebug("KOMonthView::setKeyBoardFocus() "); 1785 //qDebug("KOMonthView::setKeyBoardFocus() ");
1747 bool shootAgain = false; 1786 bool shootAgain = false;
1748 if ( mShowWeekView ) { 1787 if ( mShowWeekView ) {
1749 shootAgain = !mWeekLabelsW[1]->hasFocus(); 1788 shootAgain = !mWeekLabelsW[1]->hasFocus();
1750 mWeekLabelsW[1]->setFocus(); 1789 mWeekLabelsW[1]->setFocus();
1751 } 1790 }
1752 else { 1791 else {
1753 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); 1792 shootAgain = !mWeekLabels[mNumWeeks]->hasFocus();
1754 mWeekLabels[mNumWeeks]->setFocus(); 1793 mWeekLabels[mNumWeeks]->setFocus();
1755 } 1794 }
1756 if ( shootAgain ) { 1795 if ( shootAgain ) {
1757 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); 1796 QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
1758 } 1797 }
1759} 1798}
1760void KOMonthView::setKeyBFocus() 1799void KOMonthView::setKeyBFocus()
1761{ 1800{
1762 //qDebug("KOMonthView::setKeyBFocus() "); 1801 //qDebug("KOMonthView::setKeyBFocus() ");
1763 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); 1802 QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
1764} 1803}
1765void KOMonthView::resizeEvent(QResizeEvent * e) 1804void KOMonthView::resizeEvent(QResizeEvent * e)
1766{ 1805{
1767 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height()); 1806 //qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
1768 if ( isVisible() ) { 1807 if ( isVisible() ) {
1769 //qDebug("KOMonthView::isVisible "); 1808 //qDebug("KOMonthView::isVisible ");
1770 slotComputeLayout(); 1809 slotComputeLayout();
1771 } else 1810 } else
1772 mComputeLayoutTimer->start( 100 ); 1811 mComputeLayoutTimer->start( 100 );
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 0f3aa54..0bd6b1c 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -122,125 +122,125 @@ class MonthViewItem: public QListBoxItem
122 QPalette palette() const { return mPalette; } 122 QPalette palette() const { return mPalette; }
123 bool setHighlightedFalse(); 123 bool setHighlightedFalse();
124 Incidence *incidence() const { return mIncidence; } 124 Incidence *incidence() const { return mIncidence; }
125 125
126 protected: 126 protected:
127 virtual void paint(QPainter *); 127 virtual void paint(QPainter *);
128 virtual int height(const QListBox *) const; 128 virtual int height(const QListBox *) const;
129 virtual int width(const QListBox *) const; 129 virtual int width(const QListBox *) const;
130 130
131 private: 131 private:
132 int mdayPos; 132 int mdayPos;
133 bool isWeekItem; 133 bool isWeekItem;
134 bool mblockRepaint; 134 bool mblockRepaint;
135 int mMultiday; 135 int mMultiday;
136 bool mRecur; 136 bool mRecur;
137 bool mAlarm; 137 bool mAlarm;
138 bool mReply; 138 bool mReply;
139 bool mInfo; 139 bool mInfo;
140 bool mDisplayHighlighted; 140 bool mDisplayHighlighted;
141 141
142 QPalette mPalette; 142 QPalette mPalette;
143 QDate mDate; 143 QDate mDate;
144 144
145 Incidence *mIncidence; 145 Incidence *mIncidence;
146}; 146};
147 147
148 148
149class KOMonthView; 149class KOMonthView;
150 150
151class MonthViewCell : public KNoScrollListBox 151class MonthViewCell : public KNoScrollListBox
152{ 152{
153 Q_OBJECT 153 Q_OBJECT
154 public: 154 public:
155 MonthViewCell(KOMonthView *,QWidget* ); 155 MonthViewCell(KOMonthView *,QWidget* );
156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} 156 ~MonthViewCell() {mAvailItemList.setAutoDelete( true );}
157 157
158 void setDate( const QDate & ); 158 void setDate( const QDate & );
159 QDate date() const; 159 QDate date() const;
160 160
161 void setPrimary( bool ); 161 void setPrimary( bool );
162 bool isPrimary() const; 162 bool isPrimary() const;
163 163
164 void setHoliday( bool ); 164 void setHoliday( bool );
165 void setHoliday( const QString & ); 165 void setHoliday( const QString & );
166 166
167 void updateCell(); 167 void updateCell();
168 void startUpdateCell(); 168 void startUpdateCell();
169 void finishUpdateCell(); 169 void finishUpdateCell();
170 void repaintfinishUpdateCell();
171 int insertEvent(Event *); 170 int insertEvent(Event *);
172 void insertTodo(Todo *); 171 void insertTodo(Todo *);
173 172
174 void updateConfig( bool bigFont = false ); 173 void updateConfig( bool bigFont = false );
175 174
176 void enableScrollBars( bool ); 175 void enableScrollBars( bool );
177 176
178 Incidence *selectedIncidence(); 177 Incidence *selectedIncidence();
179 QDate selectedIncidenceDate(); 178 QDate selectedIncidenceDate();
180 QPushButton * dateLabel() { return mLabel; } 179 QPushButton * dateLabel() { return mLabel; }
181 void deHighLight();
182 bool doHighLight( Incidence *); 180 bool doHighLight( Incidence *);
183 void deselect(); 181 void deselect();
184 void select(); 182 void select();
185#ifdef DESKTOP_VERSION 183#ifdef DESKTOP_VERSION
186 static QToolTipGroup *toolTipGroup(); 184 static QToolTipGroup *toolTipGroup();
187#endif 185#endif
188 signals: 186 signals:
189 void defaultAction( Incidence * ); 187 void defaultAction( Incidence * );
190 void newEventSignal( QDateTime ); 188 void newEventSignal( QDateTime );
191 void showDaySignal( QDate ); 189 void showDaySignal( QDate );
192 190
193 protected: 191 protected:
194 QStringList mToolTip; 192 QStringList mToolTip;
195 void resizeEvent( QResizeEvent * ); 193 void resizeEvent( QResizeEvent * );
196 194
197public slots: 195public slots:
198 void showDay(); 196 void showDay();
197 void deHighLight();
198 void repaintfinishUpdateCell();
199 protected slots: 199 protected slots:
200 void defaultAction( QListBoxItem * ); 200 void defaultAction( QListBoxItem * );
201 void contextMenu( QListBoxItem * ); 201 void contextMenu( QListBoxItem * );
202 void selection( QListBoxItem * ); 202 void selection( QListBoxItem * );
203 void cellClicked( QListBoxItem * ); 203 void cellClicked( QListBoxItem * );
204 void newEvent(); 204 void newEvent();
205 205
206 private: 206 private:
207 int mdayCount; 207 int mdayCount;
208 QPtrList <MonthViewItem> mAvailItemList; 208 QPtrList <MonthViewItem> mAvailItemList;
209 KOMonthView *mMonthView; 209 KOMonthView *mMonthView;
210 int currentPalette; 210 int currentPalette;
211 211
212 QDate mDate; 212 QDate mDate;
213 bool mPrimary; 213 bool mPrimary;
214 bool mHoliday; 214 bool mHoliday;
215 QString mHolidayString; 215 QString mHolidayString;
216 216
217 //QLabel *mLabel; 217 //QLabel *mLabel;
218 QPushButton *mLabel; 218 QPushButton *mLabel;
219 //QListBox *mItemList; 219 //QListBox *mItemList;
220#ifdef DESKTOP_VERSION 220#ifdef DESKTOP_VERSION
221 static QToolTipGroup *mToolTipGroup; 221 static QToolTipGroup *mToolTipGroup;
222#endif 222#endif
223 QSize mLabelSize; 223 QSize mLabelSize;
224 QSize mLabelBigSize; 224 QSize mLabelBigSize;
225 QPalette mHolidayPalette; 225 QPalette mHolidayPalette;
226 QPalette mStandardPalette; 226 QPalette mStandardPalette;
227 QPalette mPrimaryPalette; 227 QPalette mPrimaryPalette;
228 QPalette mNonPrimaryPalette; 228 QPalette mNonPrimaryPalette;
229 void setMyPalette(); 229 void setMyPalette();
230 QPalette getPalette (); 230 QPalette getPalette ();
231 231
232}; 232};
233 233
234 234
235class KOMonthView: public KOEventView 235class KOMonthView: public KOEventView
236{ 236{
237 Q_OBJECT 237 Q_OBJECT
238 public: 238 public:
239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 239 KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
240 ~KOMonthView(); 240 ~KOMonthView();
241 241
242 /** Returns maximum number of days supported by the komonthview */ 242 /** Returns maximum number of days supported by the komonthview */
243 virtual int maxDatesHint(); 243 virtual int maxDatesHint();
244 244
245 /** Returns number of currently shown dates. */ 245 /** Returns number of currently shown dates. */
246 virtual int currentDateCount(); 246 virtual int currentDateCount();