-rw-r--r-- | korganizer/komonthview.cpp | 4 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 1 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 1 |
3 files changed, 2 insertions, 4 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 6646b98..4cff23a 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -515,213 +515,212 @@ void MonthViewCell::insertEvent(Event *event) | |||
515 | item->setReply(true); | 515 | item->setReply(true); |
516 | else | 516 | else |
517 | item->setReply(false); | 517 | item->setReply(false); |
518 | } else | 518 | } else |
519 | item->setReply(false); | 519 | item->setReply(false); |
520 | #endif | 520 | #endif |
521 | mItemList->insertItem( item ); | 521 | mItemList->insertItem( item ); |
522 | mToolTip += "\n"; | 522 | mToolTip += "\n"; |
523 | } | 523 | } |
524 | void MonthViewCell::insertTodo(Todo *todo) | 524 | void MonthViewCell::insertTodo(Todo *todo) |
525 | { | 525 | { |
526 | QString text; | 526 | QString text; |
527 | if (todo->hasDueDate()) { | 527 | if (todo->hasDueDate()) { |
528 | if (!todo->doesFloat()) { | 528 | if (!todo->doesFloat()) { |
529 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 529 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
530 | text += " "; | 530 | text += " "; |
531 | } | 531 | } |
532 | } | 532 | } |
533 | text += i18n("To-Do: %1").arg(todo->summary()); | 533 | text += i18n("To-Do: %1").arg(todo->summary()); |
534 | 534 | ||
535 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 535 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
536 | //item->setPalette( mStandardPalette ); | 536 | //item->setPalette( mStandardPalette ); |
537 | QPalette pal; | 537 | QPalette pal; |
538 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 538 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
539 | QStringList categories = todo->categories(); | 539 | QStringList categories = todo->categories(); |
540 | QString cat = categories.first(); | 540 | QString cat = categories.first(); |
541 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 541 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
542 | pal = getPalette(); | 542 | pal = getPalette(); |
543 | if (cat.isEmpty()) { | 543 | if (cat.isEmpty()) { |
544 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 544 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
545 | } else { | 545 | } else { |
546 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 546 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
547 | } | 547 | } |
548 | 548 | ||
549 | } else { | 549 | } else { |
550 | if (cat.isEmpty()) { | 550 | if (cat.isEmpty()) { |
551 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 551 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
552 | } else { | 552 | } else { |
553 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 553 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | } else { | 557 | } else { |
558 | pal = mStandardPalette ; | 558 | pal = mStandardPalette ; |
559 | } | 559 | } |
560 | item->setPalette( pal ); | 560 | item->setPalette( pal ); |
561 | mItemList->insertItem( item ); | 561 | mItemList->insertItem( item ); |
562 | mToolTip += text+"\n"; | 562 | mToolTip += text+"\n"; |
563 | } | 563 | } |
564 | void MonthViewCell::finishUpdateCell() | 564 | void MonthViewCell::finishUpdateCell() |
565 | { | 565 | { |
566 | #ifdef DESKTOP_VERSION | 566 | #ifdef DESKTOP_VERSION |
567 | if (mToolTip != "") | 567 | if (mToolTip != "") |
568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 568 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
569 | #endif | 569 | #endif |
570 | 570 | ||
571 | //setMyPalette(); | 571 | //setMyPalette(); |
572 | setMyPalette(); | 572 | setMyPalette(); |
573 | QString text; | 573 | QString text; |
574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 574 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
575 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 575 | if ( KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 576 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
577 | mLabel->resize( mLabelBigSize ); | 577 | mLabel->resize( mLabelBigSize ); |
578 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 578 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
579 | } else { | 579 | } else { |
580 | mLabel->resize( mLabelSize ); | 580 | mLabel->resize( mLabelSize ); |
581 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 581 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
582 | } | 582 | } |
583 | 583 | ||
584 | mLabel->setText( text ); | 584 | mLabel->setText( text ); |
585 | resizeEvent( 0 ); | 585 | resizeEvent( 0 ); |
586 | } | 586 | } |
587 | void MonthViewCell::updateCell() | 587 | void MonthViewCell::updateCell() |
588 | { | 588 | { |
589 | if ( !mMonthView->isUpdatePossible() ) | 589 | if ( !mMonthView->isUpdatePossible() ) |
590 | return; | 590 | return; |
591 | startUpdateCell(); | 591 | startUpdateCell(); |
592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 592 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 593 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
594 | Event *event; | 594 | Event *event; |
595 | for( event = events.first(); event; event = events.next() ) { // for event | 595 | for( event = events.first(); event; event = events.next() ) { // for event |
596 | insertEvent(event); | 596 | insertEvent(event); |
597 | } | 597 | } |
598 | // insert due todos | 598 | // insert due todos |
599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 599 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
600 | Todo *todo; | 600 | Todo *todo; |
601 | for(todo = todos.first(); todo; todo = todos.next()) { | 601 | for(todo = todos.first(); todo; todo = todos.next()) { |
602 | insertTodo( todo ); | 602 | insertTodo( todo ); |
603 | } | 603 | } |
604 | finishUpdateCell(); | 604 | finishUpdateCell(); |
605 | // if ( isVisible()) | 605 | // if ( isVisible()) |
606 | //qApp->processEvents(); | 606 | //qApp->processEvents(); |
607 | } | 607 | } |
608 | 608 | ||
609 | void MonthViewCell::updateConfig() | 609 | void MonthViewCell::updateConfig() |
610 | { | 610 | { |
611 | qDebug("MonthViewCell::updateConfig() "); | ||
612 | setFont( KOPrefs::instance()->mMonthViewFont ); | 611 | setFont( KOPrefs::instance()->mMonthViewFont ); |
613 | 612 | ||
614 | QFontMetrics fm( font() ); | 613 | QFontMetrics fm( font() ); |
615 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 614 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
616 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 615 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
617 | mHolidayPalette = mStandardPalette; | 616 | mHolidayPalette = mStandardPalette; |
618 | mPrimaryPalette = mStandardPalette; | 617 | mPrimaryPalette = mStandardPalette; |
619 | mNonPrimaryPalette = mStandardPalette; | 618 | mNonPrimaryPalette = mStandardPalette; |
620 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 619 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
621 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 620 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
622 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 621 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
623 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 622 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
624 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 623 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
625 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 624 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
626 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 625 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
627 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 626 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
628 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 627 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
629 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 628 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
630 | } | 629 | } |
631 | updateCell(); | 630 | //updateCell(); |
632 | } | 631 | } |
633 | 632 | ||
634 | void MonthViewCell::enableScrollBars( bool enabled ) | 633 | void MonthViewCell::enableScrollBars( bool enabled ) |
635 | { | 634 | { |
636 | if ( enabled ) { | 635 | if ( enabled ) { |
637 | mItemList->setVScrollBarMode(QScrollView::Auto); | 636 | mItemList->setVScrollBarMode(QScrollView::Auto); |
638 | mItemList->setHScrollBarMode(QScrollView::Auto); | 637 | mItemList->setHScrollBarMode(QScrollView::Auto); |
639 | } else { | 638 | } else { |
640 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 639 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
641 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 640 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
642 | } | 641 | } |
643 | } | 642 | } |
644 | 643 | ||
645 | Incidence *MonthViewCell::selectedIncidence() | 644 | Incidence *MonthViewCell::selectedIncidence() |
646 | { | 645 | { |
647 | int index = mItemList->currentItem(); | 646 | int index = mItemList->currentItem(); |
648 | if ( index < 0 ) return 0; | 647 | if ( index < 0 ) return 0; |
649 | 648 | ||
650 | MonthViewItem *item = | 649 | MonthViewItem *item = |
651 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 650 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
652 | 651 | ||
653 | if ( !item ) return 0; | 652 | if ( !item ) return 0; |
654 | 653 | ||
655 | return item->incidence(); | 654 | return item->incidence(); |
656 | } | 655 | } |
657 | 656 | ||
658 | QDate MonthViewCell::selectedIncidenceDate() | 657 | QDate MonthViewCell::selectedIncidenceDate() |
659 | { | 658 | { |
660 | QDate qd; | 659 | QDate qd; |
661 | int index = mItemList->currentItem(); | 660 | int index = mItemList->currentItem(); |
662 | if ( index < 0 ) return qd; | 661 | if ( index < 0 ) return qd; |
663 | 662 | ||
664 | MonthViewItem *item = | 663 | MonthViewItem *item = |
665 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 664 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
666 | 665 | ||
667 | if ( !item ) return qd; | 666 | if ( !item ) return qd; |
668 | 667 | ||
669 | return item->incidenceDate(); | 668 | return item->incidenceDate(); |
670 | } | 669 | } |
671 | 670 | ||
672 | void MonthViewCell::deselect() | 671 | void MonthViewCell::deselect() |
673 | { | 672 | { |
674 | mItemList->clearSelection(); | 673 | mItemList->clearSelection(); |
675 | enableScrollBars( false ); | 674 | enableScrollBars( false ); |
676 | // updateCell(); | 675 | // updateCell(); |
677 | } | 676 | } |
678 | void MonthViewCell::select() | 677 | void MonthViewCell::select() |
679 | { | 678 | { |
680 | ;// updateCell(); | 679 | ;// updateCell(); |
681 | } | 680 | } |
682 | 681 | ||
683 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 682 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
684 | { | 683 | { |
685 | if ( !mMonthView->isUpdatePossible() ) | 684 | if ( !mMonthView->isUpdatePossible() ) |
686 | return; | 685 | return; |
687 | #ifndef DESKTOP_VERSION | 686 | #ifndef DESKTOP_VERSION |
688 | if ( !isVisible() ){ | 687 | if ( !isVisible() ){ |
689 | return; | 688 | return; |
690 | } | 689 | } |
691 | #endif | 690 | #endif |
692 | int size = height() - mLabel->height(); | 691 | int size = height() - mLabel->height(); |
693 | if ( size > 0 ) | 692 | if ( size > 0 ) |
694 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 693 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
695 | size = width() - mLabel->width(); | 694 | size = width() - mLabel->width(); |
696 | if ( size > 0 ) | 695 | if ( size > 0 ) |
697 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 696 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
698 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 697 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
699 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 698 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
700 | } | 699 | } |
701 | 700 | ||
702 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 701 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
703 | { | 702 | { |
704 | if ( !item ) return; | 703 | if ( !item ) return; |
705 | 704 | ||
706 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 705 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
707 | Incidence *incidence = eventItem->incidence(); | 706 | Incidence *incidence = eventItem->incidence(); |
708 | if ( incidence ) mMonthView->defaultAction( incidence ); | 707 | if ( incidence ) mMonthView->defaultAction( incidence ); |
709 | } | 708 | } |
710 | void MonthViewCell::showDay() | 709 | void MonthViewCell::showDay() |
711 | { | 710 | { |
712 | emit showDaySignal( date() ); | 711 | emit showDaySignal( date() ); |
713 | } | 712 | } |
714 | void MonthViewCell::newEvent() | 713 | void MonthViewCell::newEvent() |
715 | { | 714 | { |
716 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 715 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
717 | emit newEventSignal( dt ); | 716 | emit newEventSignal( dt ); |
718 | } | 717 | } |
719 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 718 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
720 | { | 719 | { |
721 | static QListBoxItem * lastClicked = 0; | 720 | static QListBoxItem * lastClicked = 0; |
722 | if ( item == 0 ) { | 721 | if ( item == 0 ) { |
723 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 722 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
724 | emit newEventSignal( dt ); | 723 | emit newEventSignal( dt ); |
725 | return; | 724 | return; |
726 | } | 725 | } |
727 | /* | 726 | /* |
@@ -804,192 +803,193 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | |||
804 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 803 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
805 | int row, col; | 804 | int row, col; |
806 | mCells.resize( mNumCells ); | 805 | mCells.resize( mNumCells ); |
807 | for( row = 0; row < mNumWeeks; ++row ) { | 806 | for( row = 0; row < mNumWeeks; ++row ) { |
808 | for( col = 0; col < mDaysPerWeek; ++col ) { | 807 | for( col = 0; col < mDaysPerWeek; ++col ) { |
809 | MonthViewCell *cell = new MonthViewCell( this ); | 808 | MonthViewCell *cell = new MonthViewCell( this ); |
810 | mCells.insert( row * mDaysPerWeek + col, cell ); | 809 | mCells.insert( row * mDaysPerWeek + col, cell ); |
811 | 810 | ||
812 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 811 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
813 | SLOT( defaultAction( Incidence * ) ) ); | 812 | SLOT( defaultAction( Incidence * ) ) ); |
814 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 813 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
815 | SIGNAL( newEventSignal( QDateTime ) ) ); | 814 | SIGNAL( newEventSignal( QDateTime ) ) ); |
816 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 815 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
817 | SIGNAL( showDaySignal( QDate ) ) ); | 816 | SIGNAL( showDaySignal( QDate ) ) ); |
818 | } | 817 | } |
819 | } | 818 | } |
820 | 819 | ||
821 | mContextMenu = eventPopup(); | 820 | mContextMenu = eventPopup(); |
822 | // updateConfig(); //useless here | 821 | // updateConfig(); //useless here |
823 | 822 | ||
824 | emit incidenceSelected( 0 ); | 823 | emit incidenceSelected( 0 ); |
825 | } | 824 | } |
826 | 825 | ||
827 | KOMonthView::~KOMonthView() | 826 | KOMonthView::~KOMonthView() |
828 | { | 827 | { |
829 | delete mContextMenu; | 828 | delete mContextMenu; |
830 | } | 829 | } |
831 | 830 | ||
832 | int KOMonthView::maxDatesHint() | 831 | int KOMonthView::maxDatesHint() |
833 | { | 832 | { |
834 | return mNumCells; | 833 | return mNumCells; |
835 | } | 834 | } |
836 | 835 | ||
837 | int KOMonthView::currentDateCount() | 836 | int KOMonthView::currentDateCount() |
838 | { | 837 | { |
839 | return mNumCells; | 838 | return mNumCells; |
840 | } | 839 | } |
841 | 840 | ||
842 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 841 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
843 | { | 842 | { |
844 | QPtrList<Incidence> selected; | 843 | QPtrList<Incidence> selected; |
845 | 844 | ||
846 | if ( mSelectedCell ) { | 845 | if ( mSelectedCell ) { |
847 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 846 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
848 | if ( incidence ) selected.append( incidence ); | 847 | if ( incidence ) selected.append( incidence ); |
849 | } | 848 | } |
850 | 849 | ||
851 | return selected; | 850 | return selected; |
852 | } | 851 | } |
853 | 852 | ||
854 | DateList KOMonthView::selectedDates() | 853 | DateList KOMonthView::selectedDates() |
855 | { | 854 | { |
856 | DateList selected; | 855 | DateList selected; |
857 | 856 | ||
858 | if ( mSelectedCell ) { | 857 | if ( mSelectedCell ) { |
859 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 858 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
860 | if ( qd.isValid() ) selected.append( qd ); | 859 | if ( qd.isValid() ) selected.append( qd ); |
861 | } | 860 | } |
862 | 861 | ||
863 | return selected; | 862 | return selected; |
864 | } | 863 | } |
865 | 864 | ||
866 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 865 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
867 | const QDate &td) | 866 | const QDate &td) |
868 | { | 867 | { |
869 | #ifndef KORG_NOPRINTER | 868 | #ifndef KORG_NOPRINTER |
870 | calPrinter->preview(CalPrinter::Month, fd, td); | 869 | calPrinter->preview(CalPrinter::Month, fd, td); |
871 | #endif | 870 | #endif |
872 | } | 871 | } |
873 | 872 | ||
874 | void KOMonthView::updateConfig() | 873 | void KOMonthView::updateConfig() |
875 | { | 874 | { |
876 | 875 | ||
877 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 876 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
878 | 877 | ||
879 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 878 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
880 | mWidthLongDayLabel = 0; | 879 | mWidthLongDayLabel = 0; |
881 | 880 | ||
882 | for (int i = 0; i < 7; i++) { | 881 | for (int i = 0; i < 7; i++) { |
883 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 882 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
884 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 883 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
885 | } | 884 | } |
886 | bool temp = mShowSatSunComp ; | 885 | bool temp = mShowSatSunComp ; |
887 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 886 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
888 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 887 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
889 | computeLayout(); | 888 | computeLayout(); |
890 | updateDayLabels(); | 889 | updateDayLabels(); |
891 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 890 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
892 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 891 | int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
893 | //resizeEvent( 0 ); | 892 | //resizeEvent( 0 ); |
894 | for (uint i = 0; i < mCells.count(); ++i) { | 893 | for (uint i = 0; i < mCells.count(); ++i) { |
895 | mCells[i]->updateConfig(); | 894 | mCells[i]->updateConfig(); |
896 | } | 895 | } |
897 | #ifdef DESKTOP_VERSION | 896 | #ifdef DESKTOP_VERSION |
898 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 897 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
899 | #endif | 898 | #endif |
899 | updateView(); | ||
900 | } | 900 | } |
901 | 901 | ||
902 | void KOMonthView::updateDayLabels() | 902 | void KOMonthView::updateDayLabels() |
903 | { | 903 | { |
904 | 904 | ||
905 | for (int i = 0; i < 7; i++) { | 905 | for (int i = 0; i < 7; i++) { |
906 | if (mWeekStartsMonday) { | 906 | if (mWeekStartsMonday) { |
907 | bool show = mShortDayLabels; | 907 | bool show = mShortDayLabels; |
908 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) | 908 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() ) |
909 | show = true; | 909 | show = true; |
910 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 910 | mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
911 | } else { | 911 | } else { |
912 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 912 | if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
913 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 913 | else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
914 | 914 | ||
915 | } | 915 | } |
916 | } | 916 | } |
917 | } | 917 | } |
918 | 918 | ||
919 | void KOMonthView::showDates(const QDate &start, const QDate &) | 919 | void KOMonthView::showDates(const QDate &start, const QDate &) |
920 | { | 920 | { |
921 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 921 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
922 | 922 | ||
923 | 923 | ||
924 | mStartDate = start; | 924 | mStartDate = start; |
925 | 925 | ||
926 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 926 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
927 | 927 | ||
928 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 928 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
929 | mStartDate = mStartDate.addDays( -1 ); | 929 | mStartDate = mStartDate.addDays( -1 ); |
930 | } | 930 | } |
931 | 931 | ||
932 | bool primary = false; | 932 | bool primary = false; |
933 | uint i; | 933 | uint i; |
934 | for( i = 0; i < mCells.size(); ++i ) { | 934 | for( i = 0; i < mCells.size(); ++i ) { |
935 | QDate date = mStartDate.addDays( i ); | 935 | QDate date = mStartDate.addDays( i ); |
936 | mCells[i]->setDate( date ); | 936 | mCells[i]->setDate( date ); |
937 | 937 | ||
938 | #ifndef KORG_NOPLUGINS | 938 | #ifndef KORG_NOPLUGINS |
939 | // add holiday, if present | 939 | // add holiday, if present |
940 | QString hstring(KOCore::self()->holiday(date)); | 940 | QString hstring(KOCore::self()->holiday(date)); |
941 | mCells[i]->setHoliday( hstring ); | 941 | mCells[i]->setHoliday( hstring ); |
942 | #endif | 942 | #endif |
943 | 943 | ||
944 | } | 944 | } |
945 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 945 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
946 | for( i = 0; i < 6; ++i ) { | 946 | for( i = 0; i < 6; ++i ) { |
947 | int wno; | 947 | int wno; |
948 | // remember, according to ISO 8601, the first week of the year is the | 948 | // remember, according to ISO 8601, the first week of the year is the |
949 | // first week that contains a thursday. Thus we must subtract off 4, | 949 | // first week that contains a thursday. Thus we must subtract off 4, |
950 | // not just 1. | 950 | // not just 1. |
951 | int dayOfYear = date.dayOfYear(); | 951 | int dayOfYear = date.dayOfYear(); |
952 | if (dayOfYear % 7 != 0) | 952 | if (dayOfYear % 7 != 0) |
953 | wno = dayOfYear / 7 + 1; | 953 | wno = dayOfYear / 7 + 1; |
954 | else | 954 | else |
955 | wno =dayOfYear / 7; | 955 | wno =dayOfYear / 7; |
956 | mWeekLabels[i]->setWeekNum( wno ); | 956 | mWeekLabels[i]->setWeekNum( wno ); |
957 | date = date.addDays( 7 ); | 957 | date = date.addDays( 7 ); |
958 | } | 958 | } |
959 | updateView(); | 959 | updateView(); |
960 | } | 960 | } |
961 | 961 | ||
962 | void KOMonthView::showEvents(QPtrList<Event>) | 962 | void KOMonthView::showEvents(QPtrList<Event>) |
963 | { | 963 | { |
964 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 964 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
965 | } | 965 | } |
966 | 966 | ||
967 | void KOMonthView::changeEventDisplay(Event *, int) | 967 | void KOMonthView::changeEventDisplay(Event *, int) |
968 | { | 968 | { |
969 | // this should be re-written to be much more efficient, but this | 969 | // this should be re-written to be much more efficient, but this |
970 | // quick-and-dirty-hack gets the job done for right now. | 970 | // quick-and-dirty-hack gets the job done for right now. |
971 | updateView(); | 971 | updateView(); |
972 | } | 972 | } |
973 | 973 | ||
974 | void KOMonthView::updateView() | 974 | void KOMonthView::updateView() |
975 | { | 975 | { |
976 | 976 | ||
977 | if ( !updatePossible ) | 977 | if ( !updatePossible ) |
978 | return; | 978 | return; |
979 | QTime ti; | 979 | QTime ti; |
980 | ti.start(); | 980 | ti.start(); |
981 | #if 1 | 981 | #if 1 |
982 | int i; | 982 | int i; |
983 | for( i = 0; i < mCells.count(); ++i ) { | 983 | for( i = 0; i < mCells.count(); ++i ) { |
984 | mCells[i]->startUpdateCell(); | 984 | mCells[i]->startUpdateCell(); |
985 | } | 985 | } |
986 | 986 | ||
987 | QPtrList<Event> events = calendar()->events(); | 987 | QPtrList<Event> events = calendar()->events(); |
988 | Event *event; | 988 | Event *event; |
989 | QDateTime dt; | 989 | QDateTime dt; |
990 | bool ok; | 990 | bool ok; |
991 | int timeSpan = mCells.size()-1; | 991 | int timeSpan = mCells.size()-1; |
992 | QDate endDate = mStartDate.addDays( timeSpan ); | 992 | QDate endDate = mStartDate.addDays( timeSpan ); |
993 | for( event = events.first(); event; event = events.next() ) { // for event | 993 | for( event = events.first(); event; event = events.next() ) { // for event |
994 | if ( event->doesRecur() ) { | 994 | if ( event->doesRecur() ) { |
995 | bool last; | 995 | bool last; |
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index c95917f..db23882 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp | |||
@@ -26,193 +26,192 @@ | |||
26 | #include <qwidgetstack.h> | 26 | #include <qwidgetstack.h> |
27 | 27 | ||
28 | #include <kconfig.h> | 28 | #include <kconfig.h> |
29 | #include <kglobal.h> | 29 | #include <kglobal.h> |
30 | #ifndef DESKTOP_VERSION | 30 | #ifndef DESKTOP_VERSION |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #else | 32 | #else |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #endif | 34 | #endif |
35 | #include <qdatetime.h> | 35 | #include <qdatetime.h> |
36 | #include "calendarview.h" | 36 | #include "calendarview.h" |
37 | #include "datenavigator.h" | 37 | #include "datenavigator.h" |
38 | #include "kotodoview.h" | 38 | #include "kotodoview.h" |
39 | #include "koagendaview.h" | 39 | #include "koagendaview.h" |
40 | #include "kodialogmanager.h" | 40 | #include "kodialogmanager.h" |
41 | #include "komonthview.h" | 41 | #include "komonthview.h" |
42 | #include "kolistview.h" | 42 | #include "kolistview.h" |
43 | #include "kowhatsnextview.h" | 43 | #include "kowhatsnextview.h" |
44 | #include "kojournalview.h" | 44 | #include "kojournalview.h" |
45 | #include "kotimespanview.h" | 45 | #include "kotimespanview.h" |
46 | #include "koprefs.h" | 46 | #include "koprefs.h" |
47 | #include "navigatorbar.h" | 47 | #include "navigatorbar.h" |
48 | #include "kdatenavigator.h" | 48 | #include "kdatenavigator.h" |
49 | 49 | ||
50 | #include "koviewmanager.h" | 50 | #include "koviewmanager.h" |
51 | //extern bool externFlagMonthviewBlockPainting; | 51 | //extern bool externFlagMonthviewBlockPainting; |
52 | 52 | ||
53 | //bool globalFlagBlockPainting = false; | 53 | //bool globalFlagBlockPainting = false; |
54 | int globalFlagBlockAgenda = 0; | 54 | int globalFlagBlockAgenda = 0; |
55 | int globalFlagBlockLabel = 0; | 55 | int globalFlagBlockLabel = 0; |
56 | int globalFlagBlockAgendaItemPaint = 1; | 56 | int globalFlagBlockAgendaItemPaint = 1; |
57 | int globalFlagBlockAgendaItemUpdate = 1; | 57 | int globalFlagBlockAgendaItemUpdate = 1; |
58 | 58 | ||
59 | 59 | ||
60 | KOViewManager::KOViewManager( CalendarView *mainView ) : | 60 | KOViewManager::KOViewManager( CalendarView *mainView ) : |
61 | QObject(), mMainView( mainView ) | 61 | QObject(), mMainView( mainView ) |
62 | { | 62 | { |
63 | mCurrentView = 0; | 63 | mCurrentView = 0; |
64 | 64 | ||
65 | mWhatsNextView = 0; | 65 | mWhatsNextView = 0; |
66 | mTodoView = 0; | 66 | mTodoView = 0; |
67 | mAgendaView = 0; | 67 | mAgendaView = 0; |
68 | mMonthView = 0; | 68 | mMonthView = 0; |
69 | mListView = 0; | 69 | mListView = 0; |
70 | mJournalView = 0; | 70 | mJournalView = 0; |
71 | mTimeSpanView = 0; | 71 | mTimeSpanView = 0; |
72 | mCurrentAgendaView = 0 ; | 72 | mCurrentAgendaView = 0 ; |
73 | mFlagShowNextxDays = false; | 73 | mFlagShowNextxDays = false; |
74 | } | 74 | } |
75 | 75 | ||
76 | KOViewManager::~KOViewManager() | 76 | KOViewManager::~KOViewManager() |
77 | { | 77 | { |
78 | } | 78 | } |
79 | 79 | ||
80 | 80 | ||
81 | KOrg::BaseView *KOViewManager::currentView() | 81 | KOrg::BaseView *KOViewManager::currentView() |
82 | { | 82 | { |
83 | return mCurrentView; | 83 | return mCurrentView; |
84 | } | 84 | } |
85 | 85 | ||
86 | void KOViewManager::readSettings(KConfig *config) | 86 | void KOViewManager::readSettings(KConfig *config) |
87 | { | 87 | { |
88 | config->setGroup("General"); | 88 | config->setGroup("General"); |
89 | QString view = config->readEntry("Current View"); | 89 | QString view = config->readEntry("Current View"); |
90 | if (view == "WhatsNext") showWhatsNextView(); | 90 | if (view == "WhatsNext") showWhatsNextView(); |
91 | else if (view == "Month") showMonthView(); | 91 | else if (view == "Month") showMonthView(); |
92 | else if (view == "List") showListView(); | 92 | else if (view == "List") showListView(); |
93 | else if (view == "Journal") showJournalView(); | 93 | else if (view == "Journal") showJournalView(); |
94 | else if (view == "TimeSpan") showTimeSpanView(); | 94 | else if (view == "TimeSpan") showTimeSpanView(); |
95 | else if (view == "Todo") showTodoView(); | 95 | else if (view == "Todo") showTodoView(); |
96 | else { | 96 | else { |
97 | showAgendaView(); | 97 | showAgendaView(); |
98 | } | 98 | } |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void KOViewManager::showDateView( int view, QDate date) | 102 | void KOViewManager::showDateView( int view, QDate date) |
103 | { | 103 | { |
104 | 104 | ||
105 | //qDebug("date %d %s", view, date.toString().latin1()); | 105 | //qDebug("date %d %s", view, date.toString().latin1()); |
106 | #if 0 | 106 | #if 0 |
107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 107 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); | 108 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); |
109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); | 109 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); |
110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); | 110 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); |
111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 111 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
112 | #endif | 112 | #endif |
113 | if ( view == 3 ) { | 113 | if ( view == 3 ) { |
114 | mMainView->showDay( date ); | 114 | mMainView->showDay( date ); |
115 | } else if (view == 4 ) { | 115 | } else if (view == 4 ) { |
116 | mMainView->dateNavigator()->selectDates( date, 7 ); | 116 | mMainView->dateNavigator()->selectDates( date, 7 ); |
117 | } else if (view == 5 ) { | 117 | } else if (view == 5 ) { |
118 | mMainView->dateNavigator()->selectDates( date, 14); | 118 | mMainView->dateNavigator()->selectDates( date, 14); |
119 | } else if (view == 6 ) { | 119 | } else if (view == 6 ) { |
120 | mMainView->dateNavigator()->blockSignals( true ); | 120 | mMainView->dateNavigator()->blockSignals( true ); |
121 | showMonthView(); | 121 | showMonthView(); |
122 | qApp->processEvents(); | ||
123 | mMainView->dateNavigator()->selectMonthByDate( date ); | 122 | mMainView->dateNavigator()->selectMonthByDate( date ); |
124 | mMainView->dateNavigator()->blockSignals( false ); | 123 | mMainView->dateNavigator()->blockSignals( false ); |
125 | mMainView->dateNavigator()->selectDate( date ); | 124 | mMainView->dateNavigator()->selectDate( date ); |
126 | } else if (view == 7 ) { | 125 | } else if (view == 7 ) { |
127 | mMainView->dateNavigator()->selectDate( date ); | 126 | mMainView->dateNavigator()->selectDate( date ); |
128 | showJournalView(); | 127 | showJournalView(); |
129 | } else if (view == 8 ) { | 128 | } else if (view == 8 ) { |
130 | globalFlagBlockAgenda = 1; | 129 | globalFlagBlockAgenda = 1; |
131 | if ( mCurrentAgendaView != 3 ) | 130 | if ( mCurrentAgendaView != 3 ) |
132 | mCurrentAgendaView = -1; | 131 | mCurrentAgendaView = -1; |
133 | showAgendaView(KOPrefs::instance()->mFullViewMonth); | 132 | showAgendaView(KOPrefs::instance()->mFullViewMonth); |
134 | globalFlagBlockAgenda = 2; | 133 | globalFlagBlockAgenda = 2; |
135 | mMainView->dateNavigator()->selectDates( date , | 134 | mMainView->dateNavigator()->selectDates( date , |
136 | KOPrefs::instance()->mNextXDays ); | 135 | KOPrefs::instance()->mNextXDays ); |
137 | mFlagShowNextxDays = true; | 136 | mFlagShowNextxDays = true; |
138 | mCurrentAgendaView = 3 ; | 137 | mCurrentAgendaView = 3 ; |
139 | } | 138 | } |
140 | 139 | ||
141 | #if 0 | 140 | #if 0 |
142 | dateNavigator()->blockSignals( true ); | 141 | dateNavigator()->blockSignals( true ); |
143 | dateNavigator()->selectDate( d ); | 142 | dateNavigator()->selectDate( d ); |
144 | dateNavigator()->blockSignals( false ); | 143 | dateNavigator()->blockSignals( false ); |
145 | mViewManager->showDayView(); | 144 | mViewManager->showDayView(); |
146 | #endif | 145 | #endif |
147 | 146 | ||
148 | } | 147 | } |
149 | 148 | ||
150 | 149 | ||
151 | 150 | ||
152 | void KOViewManager::writeSettings(KConfig *config) | 151 | void KOViewManager::writeSettings(KConfig *config) |
153 | { | 152 | { |
154 | config->setGroup("General"); | 153 | config->setGroup("General"); |
155 | 154 | ||
156 | QString view; | 155 | QString view; |
157 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; | 156 | if (mCurrentView == mWhatsNextView) view = "WhatsNext"; |
158 | else if (mCurrentView == mMonthView) view = "Month"; | 157 | else if (mCurrentView == mMonthView) view = "Month"; |
159 | else if (mCurrentView == mListView) view = "List"; | 158 | else if (mCurrentView == mListView) view = "List"; |
160 | else if (mCurrentView == mJournalView) view = "Journal"; | 159 | else if (mCurrentView == mJournalView) view = "Journal"; |
161 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; | 160 | else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; |
162 | else if (mCurrentView == mTodoView) view = "Todo"; | 161 | else if (mCurrentView == mTodoView) view = "Todo"; |
163 | else view = "Agenda"; | 162 | else view = "Agenda"; |
164 | 163 | ||
165 | config->writeEntry("Current View",view); | 164 | config->writeEntry("Current View",view); |
166 | 165 | ||
167 | if (mAgendaView) { | 166 | if (mAgendaView) { |
168 | mAgendaView->writeSettings(config); | 167 | mAgendaView->writeSettings(config); |
169 | } | 168 | } |
170 | if (mTimeSpanView) { | 169 | if (mTimeSpanView) { |
171 | mTimeSpanView->writeSettings(config); | 170 | mTimeSpanView->writeSettings(config); |
172 | } | 171 | } |
173 | if (mListView) { | 172 | if (mListView) { |
174 | mListView->writeSettings(config); | 173 | mListView->writeSettings(config); |
175 | } | 174 | } |
176 | if (mTodoView) { | 175 | if (mTodoView) { |
177 | mTodoView->saveLayout(config,"Todo View"); | 176 | mTodoView->saveLayout(config,"Todo View"); |
178 | } | 177 | } |
179 | } | 178 | } |
180 | 179 | ||
181 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) | 180 | void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) |
182 | { | 181 | { |
183 | 182 | ||
184 | //mFlagShowNextxDays = false; | 183 | //mFlagShowNextxDays = false; |
185 | //if(view == mCurrentView) return; | 184 | //if(view == mCurrentView) return; |
186 | if ( view == 0 ) { | 185 | if ( view == 0 ) { |
187 | view = mCurrentView; | 186 | view = mCurrentView; |
188 | if ( view == 0 ) | 187 | if ( view == 0 ) |
189 | return; | 188 | return; |
190 | } | 189 | } |
191 | bool full = fullScreen; | 190 | bool full = fullScreen; |
192 | if(view == mCurrentView && view != mWhatsNextView ) { | 191 | if(view == mCurrentView && view != mWhatsNextView ) { |
193 | if ( mCurrentAgendaView < 0 ) | 192 | if ( mCurrentAgendaView < 0 ) |
194 | return; | 193 | return; |
195 | full = mMainView->leftFrame()->isVisible(); | 194 | full = mMainView->leftFrame()->isVisible(); |
196 | } else { | 195 | } else { |
197 | mCurrentView = view; | 196 | mCurrentView = view; |
198 | // bool full = fullScreen; | 197 | // bool full = fullScreen; |
199 | bool isFull = !mMainView->leftFrame()->isVisible(); | 198 | bool isFull = !mMainView->leftFrame()->isVisible(); |
200 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) | 199 | if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) |
201 | full = true; | 200 | full = true; |
202 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) | 201 | if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) |
203 | full = false; | 202 | full = false; |
204 | } | 203 | } |
205 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); | 204 | if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); |
206 | //raiseCurrentView( full ); | 205 | //raiseCurrentView( full ); |
207 | mMainView->processIncidenceSelection( 0 ); | 206 | mMainView->processIncidenceSelection( 0 ); |
208 | //mMainView->updateView(); | 207 | //mMainView->updateView(); |
209 | raiseCurrentView( full, true ); | 208 | raiseCurrentView( full, true ); |
210 | mMainView->adaptNavigationUnits(); | 209 | mMainView->adaptNavigationUnits(); |
211 | } | 210 | } |
212 | 211 | ||
213 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) | 212 | void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) |
214 | { | 213 | { |
215 | mCurrentAgendaView = 0; | 214 | mCurrentAgendaView = 0; |
216 | int wid = mMainView->width() ; | 215 | int wid = mMainView->width() ; |
217 | int hei = mMainView->height(); | 216 | int hei = mMainView->height(); |
218 | if ( mCurrentView == mMonthView ) { | 217 | if ( mCurrentView == mMonthView ) { |
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index e75154b..0eba6a9 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -494,193 +494,192 @@ void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, | |||
494 | Incidence *incidence, | 494 | Incidence *incidence, |
495 | const QDateTime &from, | 495 | const QDateTime &from, |
496 | const QDateTime &to ) | 496 | const QDateTime &to ) |
497 | { | 497 | { |
498 | 498 | ||
499 | QPtrList<Alarm> alarmList = incidence->alarms(); | 499 | QPtrList<Alarm> alarmList = incidence->alarms(); |
500 | Alarm *alarm; | 500 | Alarm *alarm; |
501 | QDateTime qdt; | 501 | QDateTime qdt; |
502 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { | 502 | for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { |
503 | if (incidence->recursOn(from.date())) { | 503 | if (incidence->recursOn(from.date())) { |
504 | qdt.setTime(alarm->time().time()); | 504 | qdt.setTime(alarm->time().time()); |
505 | qdt.setDate(from.date()); | 505 | qdt.setDate(from.date()); |
506 | } | 506 | } |
507 | else qdt = alarm->time(); | 507 | else qdt = alarm->time(); |
508 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); | 508 | // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); |
509 | if ( alarm->enabled() ) { | 509 | if ( alarm->enabled() ) { |
510 | if ( qdt >= from && qdt <= to ) { | 510 | if ( qdt >= from && qdt <= to ) { |
511 | alarms.append( alarm ); | 511 | alarms.append( alarm ); |
512 | } | 512 | } |
513 | } | 513 | } |
514 | } | 514 | } |
515 | } | 515 | } |
516 | 516 | ||
517 | 517 | ||
518 | /****************************** PROTECTED METHODS ****************************/ | 518 | /****************************** PROTECTED METHODS ****************************/ |
519 | 519 | ||
520 | // after changes are made to an event, this should be called. | 520 | // after changes are made to an event, this should be called. |
521 | void CalendarLocal::update( IncidenceBase *incidence ) | 521 | void CalendarLocal::update( IncidenceBase *incidence ) |
522 | { | 522 | { |
523 | incidence->setSyncStatus( Event::SYNCMOD ); | 523 | incidence->setSyncStatus( Event::SYNCMOD ); |
524 | incidence->setLastModified( QDateTime::currentDateTime() ); | 524 | incidence->setLastModified( QDateTime::currentDateTime() ); |
525 | // we should probably update the revision number here, | 525 | // we should probably update the revision number here, |
526 | // or internally in the Event itself when certain things change. | 526 | // or internally in the Event itself when certain things change. |
527 | // need to verify with ical documentation. | 527 | // need to verify with ical documentation. |
528 | 528 | ||
529 | setModified( true ); | 529 | setModified( true ); |
530 | } | 530 | } |
531 | 531 | ||
532 | void CalendarLocal::insertEvent( Event *event ) | 532 | void CalendarLocal::insertEvent( Event *event ) |
533 | { | 533 | { |
534 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); | 534 | if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); |
535 | } | 535 | } |
536 | 536 | ||
537 | 537 | ||
538 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) | 538 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) |
539 | { | 539 | { |
540 | QPtrList<Event> eventList; | 540 | QPtrList<Event> eventList; |
541 | 541 | ||
542 | Event *event; | 542 | Event *event; |
543 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 543 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
544 | if ( event->doesRecur() ) { | 544 | if ( event->doesRecur() ) { |
545 | if ( event->isMultiDay() ) { | 545 | if ( event->isMultiDay() ) { |
546 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); | 546 | int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); |
547 | int i; | 547 | int i; |
548 | for ( i = 0; i <= extraDays; i++ ) { | 548 | for ( i = 0; i <= extraDays; i++ ) { |
549 | if ( event->recursOn( qd.addDays( -i ) ) ) { | 549 | if ( event->recursOn( qd.addDays( -i ) ) ) { |
550 | eventList.append( event ); | 550 | eventList.append( event ); |
551 | break; | 551 | break; |
552 | } | 552 | } |
553 | } | 553 | } |
554 | } else { | 554 | } else { |
555 | if ( event->recursOn( qd ) ) | 555 | if ( event->recursOn( qd ) ) |
556 | eventList.append( event ); | 556 | eventList.append( event ); |
557 | } | 557 | } |
558 | } else { | 558 | } else { |
559 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { | 559 | if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { |
560 | eventList.append( event ); | 560 | eventList.append( event ); |
561 | } | 561 | } |
562 | } | 562 | } |
563 | } | 563 | } |
564 | 564 | ||
565 | if ( !sorted ) { | 565 | if ( !sorted ) { |
566 | return eventList; | 566 | return eventList; |
567 | } | 567 | } |
568 | 568 | ||
569 | // kdDebug(5800) << "Sorting events for date\n" << endl; | 569 | // kdDebug(5800) << "Sorting events for date\n" << endl; |
570 | // now, we have to sort it based on dtStart.time() | 570 | // now, we have to sort it based on dtStart.time() |
571 | QPtrList<Event> eventListSorted; | 571 | QPtrList<Event> eventListSorted; |
572 | Event *sortEvent; | 572 | Event *sortEvent; |
573 | for ( event = eventList.first(); event; event = eventList.next() ) { | 573 | for ( event = eventList.first(); event; event = eventList.next() ) { |
574 | sortEvent = eventListSorted.first(); | 574 | sortEvent = eventListSorted.first(); |
575 | int i = 0; | 575 | int i = 0; |
576 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) | 576 | while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) |
577 | { | 577 | { |
578 | i++; | 578 | i++; |
579 | sortEvent = eventListSorted.next(); | 579 | sortEvent = eventListSorted.next(); |
580 | } | 580 | } |
581 | eventListSorted.insert( i, event ); | 581 | eventListSorted.insert( i, event ); |
582 | } | 582 | } |
583 | return eventListSorted; | 583 | return eventListSorted; |
584 | } | 584 | } |
585 | 585 | ||
586 | 586 | ||
587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, | 587 | QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, |
588 | bool inclusive ) | 588 | bool inclusive ) |
589 | { | 589 | { |
590 | qDebug("CalendarLocal::rawEvents called "); | ||
591 | Event *event = 0; | 590 | Event *event = 0; |
592 | 591 | ||
593 | QPtrList<Event> eventList; | 592 | QPtrList<Event> eventList; |
594 | 593 | ||
595 | // Get non-recurring events | 594 | // Get non-recurring events |
596 | for( event = mEventList.first(); event; event = mEventList.next() ) { | 595 | for( event = mEventList.first(); event; event = mEventList.next() ) { |
597 | if ( event->doesRecur() ) { | 596 | if ( event->doesRecur() ) { |
598 | QDate rStart = event->dtStart().date(); | 597 | QDate rStart = event->dtStart().date(); |
599 | bool found = false; | 598 | bool found = false; |
600 | if ( inclusive ) { | 599 | if ( inclusive ) { |
601 | if ( rStart >= start && rStart <= end ) { | 600 | if ( rStart >= start && rStart <= end ) { |
602 | // Start date of event is in range. Now check for end date. | 601 | // Start date of event is in range. Now check for end date. |
603 | // if duration is negative, event recurs forever, so do not include it. | 602 | // if duration is negative, event recurs forever, so do not include it. |
604 | if ( event->recurrence()->duration() == 0 ) { // End date set | 603 | if ( event->recurrence()->duration() == 0 ) { // End date set |
605 | QDate rEnd = event->recurrence()->endDate(); | 604 | QDate rEnd = event->recurrence()->endDate(); |
606 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 605 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
607 | found = true; | 606 | found = true; |
608 | } | 607 | } |
609 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set | 608 | } else if ( event->recurrence()->duration() > 0 ) { // Duration set |
610 | // TODO: Calculate end date from duration. Should be done in Event | 609 | // TODO: Calculate end date from duration. Should be done in Event |
611 | // For now exclude all events with a duration. | 610 | // For now exclude all events with a duration. |
612 | } | 611 | } |
613 | } | 612 | } |
614 | } else { | 613 | } else { |
615 | bool founOne; | 614 | bool founOne; |
616 | QDate next = event->getNextOccurence( start, &founOne ).date(); | 615 | QDate next = event->getNextOccurence( start, &founOne ).date(); |
617 | if ( founOne ) { | 616 | if ( founOne ) { |
618 | if ( next <= end ) { | 617 | if ( next <= end ) { |
619 | found = true; | 618 | found = true; |
620 | } | 619 | } |
621 | } | 620 | } |
622 | 621 | ||
623 | /* | 622 | /* |
624 | // crap !!! | 623 | // crap !!! |
625 | if ( rStart <= end ) { // Start date not after range | 624 | if ( rStart <= end ) { // Start date not after range |
626 | if ( rStart >= start ) { // Start date within range | 625 | if ( rStart >= start ) { // Start date within range |
627 | found = true; | 626 | found = true; |
628 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever | 627 | } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever |
629 | found = true; | 628 | found = true; |
630 | } else if ( event->recurrence()->duration() == 0 ) { // End date set | 629 | } else if ( event->recurrence()->duration() == 0 ) { // End date set |
631 | QDate rEnd = event->recurrence()->endDate(); | 630 | QDate rEnd = event->recurrence()->endDate(); |
632 | if ( rEnd >= start && rEnd <= end ) { // End date within range | 631 | if ( rEnd >= start && rEnd <= end ) { // End date within range |
633 | found = true; | 632 | found = true; |
634 | } | 633 | } |
635 | } else { // Duration set | 634 | } else { // Duration set |
636 | // TODO: Calculate end date from duration. Should be done in Event | 635 | // TODO: Calculate end date from duration. Should be done in Event |
637 | // For now include all events with a duration. | 636 | // For now include all events with a duration. |
638 | found = true; | 637 | found = true; |
639 | } | 638 | } |
640 | } | 639 | } |
641 | */ | 640 | */ |
642 | 641 | ||
643 | } | 642 | } |
644 | 643 | ||
645 | if ( found ) eventList.append( event ); | 644 | if ( found ) eventList.append( event ); |
646 | } else { | 645 | } else { |
647 | QDate s = event->dtStart().date(); | 646 | QDate s = event->dtStart().date(); |
648 | QDate e = event->dtEnd().date(); | 647 | QDate e = event->dtEnd().date(); |
649 | 648 | ||
650 | if ( inclusive ) { | 649 | if ( inclusive ) { |
651 | if ( s >= start && e <= end ) { | 650 | if ( s >= start && e <= end ) { |
652 | eventList.append( event ); | 651 | eventList.append( event ); |
653 | } | 652 | } |
654 | } else { | 653 | } else { |
655 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { | 654 | if ( ( s >= start && s <= end ) || ( e >= start && e <= end ) ) { |
656 | eventList.append( event ); | 655 | eventList.append( event ); |
657 | } | 656 | } |
658 | } | 657 | } |
659 | } | 658 | } |
660 | } | 659 | } |
661 | 660 | ||
662 | return eventList; | 661 | return eventList; |
663 | } | 662 | } |
664 | 663 | ||
665 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) | 664 | QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) |
666 | { | 665 | { |
667 | return rawEventsForDate( qdt.date() ); | 666 | return rawEventsForDate( qdt.date() ); |
668 | } | 667 | } |
669 | 668 | ||
670 | QPtrList<Event> CalendarLocal::rawEvents() | 669 | QPtrList<Event> CalendarLocal::rawEvents() |
671 | { | 670 | { |
672 | return mEventList; | 671 | return mEventList; |
673 | } | 672 | } |
674 | 673 | ||
675 | bool CalendarLocal::addJournal(Journal *journal) | 674 | bool CalendarLocal::addJournal(Journal *journal) |
676 | { | 675 | { |
677 | if ( journal->dtStart().isValid()) | 676 | if ( journal->dtStart().isValid()) |
678 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; | 677 | kdDebug(5800) << "Adding Journal on " << journal->dtStart().toString() << endl; |
679 | else | 678 | else |
680 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; | 679 | kdDebug(5800) << "Adding Journal without a DTSTART" << endl; |
681 | 680 | ||
682 | mJournalList.append(journal); | 681 | mJournalList.append(journal); |
683 | 682 | ||
684 | journal->registerObserver( this ); | 683 | journal->registerObserver( this ); |
685 | 684 | ||
686 | setModified( true ); | 685 | setModified( true ); |