author | zautrix <zautrix> | 2005-07-07 21:34:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 21:34:31 (UTC) |
commit | 3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc (patch) (unidiff) | |
tree | 6fceb199e62afe671ed34acb308749ea09cac578 /korganizer/calendarview.cpp | |
parent | de5621f2fd3924f27c05459ae555b3bd06c5e584 (diff) | |
download | kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.zip kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.tar.gz kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/calendarview.cpp | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 65750af..426e8f9 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -568,234 +568,249 @@ void CalendarView::init() | |||
568 | SLOT( purgeCompleted() ) ); | 568 | SLOT( purgeCompleted() ) ); |
569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), | 569 | connect( mTodoList, SIGNAL( todoModifiedSignal( Todo *, int ) ), |
570 | SIGNAL( todoModified( Todo *, int ) ) ); | 570 | SIGNAL( todoModified( Todo *, int ) ) ); |
571 | 571 | ||
572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), | 572 | connect( mTodoList, SIGNAL( cloneTodoSignal( Incidence * ) ), |
573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); | 573 | this, SLOT ( cloneIncidence( Incidence * ) ) ); |
574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), | 574 | connect( mTodoList, SIGNAL( cancelTodoSignal( Incidence * ) ), |
575 | this, SLOT (cancelIncidence( Incidence * ) ) ); | 575 | this, SLOT (cancelIncidence( Incidence * ) ) ); |
576 | 576 | ||
577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), | 577 | connect( mTodoList, SIGNAL( moveTodoSignal( Incidence * ) ), |
578 | this, SLOT ( moveIncidence( Incidence * ) ) ); | 578 | this, SLOT ( moveIncidence( Incidence * ) ) ); |
579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), | 579 | connect( mTodoList, SIGNAL( beamTodoSignal( Incidence * ) ), |
580 | this, SLOT ( beamIncidence( Incidence * ) ) ); | 580 | this, SLOT ( beamIncidence( Incidence * ) ) ); |
581 | 581 | ||
582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), | 582 | connect( mTodoList, SIGNAL( unparentTodoSignal( Todo * ) ), |
583 | this, SLOT ( todo_unsub( Todo * ) ) ); | 583 | this, SLOT ( todo_unsub( Todo * ) ) ); |
584 | 584 | ||
585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), | 585 | connect( mTodoList, SIGNAL( reparentTodoSignal( Todo *,Todo * ) ), |
586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); | 586 | this, SLOT ( todo_resub( Todo *,Todo * ) ) ); |
587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, | 587 | connect( this, SIGNAL( todoModified( Todo *, int )), mTodoList, |
588 | SLOT( updateTodo( Todo *, int ) ) ); | 588 | SLOT( updateTodo( Todo *, int ) ) ); |
589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, | 589 | connect( this, SIGNAL( todoModified( Todo *, int )), this, |
590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); | 590 | SLOT( changeTodoDisplay( Todo *, int ) ) ); |
591 | 591 | ||
592 | 592 | ||
593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); | 593 | connect( mFilterView, SIGNAL( filterChanged() ), SLOT( updateFilter() ) ); |
594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); | 594 | connect( mFilterView, SIGNAL( editFilters() ), SLOT( editFilters() ) ); |
595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); | 595 | connect( mCalendar, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addAlarm(const QDateTime &, const QString & ) ) ); |
596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); | 596 | connect( mCalendar, SIGNAL( removeAlarm(const QDateTime &, const QString & ) ), SLOT( removeAlarm(const QDateTime &, const QString & ) ) ); |
597 | 597 | ||
598 | 598 | ||
599 | 599 | ||
600 | 600 | ||
601 | 601 | ||
602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), | 602 | connect(QApplication::clipboard(),SIGNAL(dataChanged()), |
603 | SLOT(checkClipboard())); | 603 | SLOT(checkClipboard())); |
604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), | 604 | connect( mTodoList,SIGNAL( incidenceSelected( Incidence * ) ), |
605 | SLOT( processTodoListSelection( Incidence * ) ) ); | 605 | SLOT( processTodoListSelection( Incidence * ) ) ); |
606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); | 606 | connect(mTodoList,SIGNAL(isModified(bool)),SLOT(setModified(bool))); |
607 | 607 | ||
608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; | 608 | // kdDebug() << "CalendarView::CalendarView() done" << endl; |
609 | 609 | ||
610 | mDateFrame = new QVBox(0,0,WType_Popup); | 610 | mDateFrame = new QVBox(0,0,WType_Popup); |
611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); | 611 | //mDateFrame->setFrameStyle(QFrame::PopupPanel | QFrame::Raised); |
612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); | 612 | mDateFrame->setFrameStyle( QFrame::WinPanel |QFrame::Raised ); |
613 | mDateFrame->setLineWidth(3); | 613 | mDateFrame->setLineWidth(3); |
614 | mDateFrame->hide(); | 614 | mDateFrame->hide(); |
615 | mDateFrame->setCaption( i18n( "Pick a date to display")); | 615 | mDateFrame->setCaption( i18n( "Pick a date to display")); |
616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); | 616 | mDatePicker = new KDatePicker ( mDateFrame , QDate::currentDate() ); |
617 | 617 | ||
618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); | 618 | connect(mDatePicker,SIGNAL(dateSelected(QDate)),SLOT(slotSelectPickerDate(QDate))); |
619 | 619 | ||
620 | mEventEditor = mDialogManager->getEventEditor(); | 620 | mEventEditor = mDialogManager->getEventEditor(); |
621 | mTodoEditor = mDialogManager->getTodoEditor(); | 621 | mTodoEditor = mDialogManager->getTodoEditor(); |
622 | 622 | ||
623 | mFlagEditDescription = false; | 623 | mFlagEditDescription = false; |
624 | 624 | ||
625 | mSuspendTimer = new QTimer( this ); | 625 | mSuspendTimer = new QTimer( this ); |
626 | mAlarmTimer = new QTimer( this ); | 626 | mAlarmTimer = new QTimer( this ); |
627 | mRecheckAlarmTimer = new QTimer( this ); | 627 | mRecheckAlarmTimer = new QTimer( this ); |
628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); | 628 | connect( mRecheckAlarmTimer, SIGNAL( timeout () ), SLOT( recheckTimerAlarm() ) ); |
629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); | 629 | connect( mSuspendTimer, SIGNAL( timeout () ), SLOT( suspendAlarm() ) ); |
630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); | 630 | connect( mAlarmTimer, SIGNAL( timeout () ), SLOT( timerAlarm() ) ); |
631 | mAlarmDialog = new AlarmDialog( this ); | 631 | mAlarmDialog = new AlarmDialog( this ); |
632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); | 632 | connect( mAlarmDialog, SIGNAL( addAlarm(const QDateTime &, const QString & ) ), SLOT( addSuspendAlarm(const QDateTime &, const QString & ) ) ); |
633 | mAlarmDialog->setServerNotification( false ); | 633 | mAlarmDialog->setServerNotification( false ); |
634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); | 634 | mAlarmDialog->setSuspendTime( KOPrefs::instance()->mAlarmSuspendTime ); |
635 | 635 | ||
636 | 636 | ||
637 | #ifndef DESKTOP_VERSION | 637 | #ifndef DESKTOP_VERSION |
638 | //US listen for arriving address resultsets | 638 | //US listen for arriving address resultsets |
639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), | 639 | connect(ExternalAppHandler::instance(), SIGNAL(receivedBirthdayListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&)), |
640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); | 640 | this, SLOT(insertBirthdays(const QString&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&, const QStringList&))); |
641 | #endif | 641 | #endif |
642 | mDateNavigator->setCalendar( mCalendar ); | 642 | mDateNavigator->setCalendar( mCalendar ); |
643 | } | 643 | } |
644 | 644 | ||
645 | 645 | ||
646 | CalendarView::~CalendarView() | 646 | CalendarView::~CalendarView() |
647 | { | 647 | { |
648 | // kdDebug() << "~CalendarView()" << endl; | 648 | // kdDebug() << "~CalendarView()" << endl; |
649 | //qDebug("CalendarView::~CalendarView() "); | 649 | //qDebug("CalendarView::~CalendarView() "); |
650 | delete mDialogManager; | 650 | delete mDialogManager; |
651 | delete mViewManager; | 651 | delete mViewManager; |
652 | delete mStorage; | 652 | delete mStorage; |
653 | delete mDateFrame ; | 653 | delete mDateFrame ; |
654 | delete mEventViewerDialog; | 654 | delete mEventViewerDialog; |
655 | //kdDebug() << "~CalendarView() done" << endl; | 655 | //kdDebug() << "~CalendarView() done" << endl; |
656 | } | 656 | } |
657 | void CalendarView::nextConflict( bool all, bool allday ) | 657 | void CalendarView::nextConflict( bool all, bool allday ) |
658 | { | 658 | { |
659 | 659 | ||
660 | QPtrList<Event> testlist = mCalendar->events(); | 660 | QPtrList<Event> testlist = mCalendar->events(); |
661 | Event * test = testlist.first(); | 661 | Event * test = testlist.first(); |
662 | while ( test ) { | 662 | while ( test ) { |
663 | test->setTagged( false ); | 663 | test->setTagged( false ); |
664 | test = testlist.next(); | ||
664 | } | 665 | } |
665 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); | 666 | QDateTime startDT = QDateTime (mNavigator->selectedDates().first().addDays(1), QTime ( 0,0,0)); |
666 | QDateTime conflict; | 667 | QDateTime conflict; |
667 | QDateTime retVal; | 668 | QDateTime retVal; |
668 | bool found = false; | 669 | bool found = false; |
669 | Event * cE = 0; | 670 | Event * cE = 0; |
671 | Event * cE2 = 0; | ||
670 | QPtrList<Event> testlist2 = testlist; | 672 | QPtrList<Event> testlist2 = testlist; |
673 | test = testlist.first(); | ||
674 | bool skip = false; | ||
671 | while ( test ) { | 675 | while ( test ) { |
672 | Event * test2 = testlist2.first(); | 676 | skip = false; |
673 | while ( test2 ) { | 677 | if ( !all ) skip = ( allday != test->doesFloat() ); |
674 | if ( !test2->isTagged() ) { | 678 | if ( !skip ) { |
675 | if ( test->isOverlapping ( test2, &retVal, true ) ) { | 679 | Event * test2 = testlist2.first(); |
676 | if ( ! found ) { | 680 | while ( test2 ) { |
677 | if ( retVal >= startDT ) { | 681 | skip = false; |
678 | conflict = retVal; | 682 | if ( !all ) skip = ( allday != test2->doesFloat() ); |
679 | cE = test; | 683 | if ( !skip ) { |
680 | found = true; | 684 | if ( !test2->isTagged() ) { |
681 | } | 685 | if ( test->isOverlapping ( test2, &retVal, &startDT ) ) { |
682 | } else { | 686 | //qDebug("overlap "); |
683 | if ( retVal >= startDT && retVal < conflict ) { | 687 | if ( ! found ) { |
684 | conflict = retVal; | 688 | if ( retVal >= startDT ) { |
685 | cE = test; | 689 | conflict = retVal; |
690 | cE = test; | ||
691 | cE2 = test2; | ||
692 | found = true; | ||
693 | } | ||
694 | } else { | ||
695 | if ( retVal >= startDT && retVal < conflict ) { | ||
696 | conflict = retVal; | ||
697 | cE = test; | ||
698 | cE2 = test2; | ||
699 | } | ||
700 | } | ||
686 | } | 701 | } |
687 | } | 702 | } |
688 | } | 703 | } |
704 | test2 = testlist2.next(); | ||
689 | } | 705 | } |
690 | test2 = testlist2.next(); | ||
691 | } | 706 | } |
692 | test->setTagged( true ); | 707 | test->setTagged( true ); |
693 | test = testlist.next(); | 708 | test = testlist.next(); |
694 | } | 709 | } |
695 | if ( found ) { | 710 | if ( found ) { |
696 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 711 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
697 | mViewManager->showDayView(); | 712 | mViewManager->showDayView(); |
698 | mNavigator->slotDaySelect( conflict.date() ); | 713 | mNavigator->slotDaySelect( conflict.date() ); |
699 | int hour = conflict.time().hour(); | 714 | int hour = conflict.time().hour(); |
700 | mViewManager->agendaView()->setStartHour( hour ); | 715 | mViewManager->agendaView()->setStartHour( hour ); |
701 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 716 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( cE->summary().left( 20 ) ).arg( cE2->summary().left( 20 ) ) ); |
702 | return; | 717 | return; |
703 | } | 718 | } |
704 | 719 | ||
705 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | 720 | topLevelWidget()->setCaption( i18n("No conflict found") ); |
706 | qDebug("No conflict found "); | 721 | qDebug("No conflict found "); |
707 | return; | 722 | return; |
708 | 723 | ||
709 | 724 | ||
710 | 725 | ||
711 | 726 | ||
712 | 727 | ||
713 | #if 0 | 728 | #if 0 |
714 | 729 | ||
715 | 730 | ||
716 | QDate end = start.addDays( 365*2); | 731 | QDate end = start.addDays( 365*2); |
717 | while ( start < end ) { | 732 | while ( start < end ) { |
718 | QPtrList<Event> eventList = calendar()->events( start ); | 733 | QPtrList<Event> eventList = calendar()->events( start ); |
719 | Event * ev = eventList.first(); | 734 | Event * ev = eventList.first(); |
720 | QPtrList<Event> test = eventList; | 735 | QPtrList<Event> test = eventList; |
721 | while ( ev ) { | 736 | while ( ev ) { |
722 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | 737 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); |
723 | Event * t_ev = test.first(); | 738 | Event * t_ev = test.first(); |
724 | QDateTime es = ev->dtStart(); | 739 | QDateTime es = ev->dtStart(); |
725 | QDateTime ee = ev->dtEnd(); | 740 | QDateTime ee = ev->dtEnd(); |
726 | if ( ev->doesFloat() ) | 741 | if ( ev->doesFloat() ) |
727 | ee = ee.addDays( 1 ); | 742 | ee = ee.addDays( 1 ); |
728 | if ( ! all ) { | 743 | if ( ! all ) { |
729 | if ( ev->doesFloat() != allday ) | 744 | if ( ev->doesFloat() != allday ) |
730 | t_ev = 0; | 745 | t_ev = 0; |
731 | } | 746 | } |
732 | while ( t_ev ) { | 747 | while ( t_ev ) { |
733 | bool skip = false; | 748 | bool skip = false; |
734 | if ( ! all ) { | 749 | if ( ! all ) { |
735 | if ( t_ev->doesFloat() != allday ) | 750 | if ( t_ev->doesFloat() != allday ) |
736 | skip = true; | 751 | skip = true; |
737 | } | 752 | } |
738 | if ( !skip && ev != t_ev ) { | 753 | if ( !skip && ev != t_ev ) { |
739 | QDateTime ets = t_ev->dtStart(); | 754 | QDateTime ets = t_ev->dtStart(); |
740 | QDateTime ete = t_ev->dtEnd(); | 755 | QDateTime ete = t_ev->dtEnd(); |
741 | if ( t_ev->doesFloat() ) | 756 | if ( t_ev->doesFloat() ) |
742 | ete = ete.addDays( 1 ); | 757 | ete = ete.addDays( 1 ); |
743 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | 758 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); |
744 | if ( es < ete && ets < ee ) { | 759 | if ( es < ete && ets < ee ) { |
745 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 760 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
746 | mViewManager->showDayView(); | 761 | mViewManager->showDayView(); |
747 | mNavigator->slotDaySelect( start ); | 762 | mNavigator->slotDaySelect( start ); |
748 | int hour = es.time().hour(); | 763 | int hour = es.time().hour(); |
749 | if ( ets > es ) | 764 | if ( ets > es ) |
750 | hour = ets.time().hour(); | 765 | hour = ets.time().hour(); |
751 | mViewManager->agendaView()->setStartHour( hour ); | 766 | mViewManager->agendaView()->setStartHour( hour ); |
752 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | 767 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); |
753 | return; | 768 | return; |
754 | } | 769 | } |
755 | } | 770 | } |
756 | t_ev = test.next(); | 771 | t_ev = test.next(); |
757 | } | 772 | } |
758 | ev = eventList.next(); | 773 | ev = eventList.next(); |
759 | } | 774 | } |
760 | start = start.addDays( 1 ); | 775 | start = start.addDays( 1 ); |
761 | } | 776 | } |
762 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); | 777 | topLevelWidget()->setCaption( i18n("No conflict found within the next two years") ); |
763 | qDebug("No conflict found "); | 778 | qDebug("No conflict found "); |
764 | #endif | 779 | #endif |
765 | } | 780 | } |
766 | 781 | ||
767 | void CalendarView::conflictAll() | 782 | void CalendarView::conflictAll() |
768 | { | 783 | { |
769 | nextConflict ( true, true ); | 784 | nextConflict ( true, true ); |
770 | } | 785 | } |
771 | void CalendarView::conflictAllday() | 786 | void CalendarView::conflictAllday() |
772 | { | 787 | { |
773 | nextConflict ( false, true ); | 788 | nextConflict ( false, true ); |
774 | } | 789 | } |
775 | void CalendarView::conflictNotAll() | 790 | void CalendarView::conflictNotAll() |
776 | { | 791 | { |
777 | nextConflict ( false, false ); | 792 | nextConflict ( false, false ); |
778 | } | 793 | } |
779 | 794 | ||
780 | void CalendarView::setCalReadOnly( int id, bool readO ) | 795 | void CalendarView::setCalReadOnly( int id, bool readO ) |
781 | { | 796 | { |
782 | if ( readO ) { | 797 | if ( readO ) { |
783 | emit save(); | 798 | emit save(); |
784 | } | 799 | } |
785 | mCalendar->setReadOnly( id, readO ); | 800 | mCalendar->setReadOnly( id, readO ); |
786 | } | 801 | } |
787 | void CalendarView::setScrollBarStep(int val ) | 802 | void CalendarView::setScrollBarStep(int val ) |
788 | { | 803 | { |
789 | #ifdef DESKTOP_VERSION | 804 | #ifdef DESKTOP_VERSION |
790 | mDateScrollBar->setLineStep ( val ); | 805 | mDateScrollBar->setLineStep ( val ); |
791 | #endif | 806 | #endif |
792 | } | 807 | } |
793 | void CalendarView::scrollBarValue(int val ) | 808 | void CalendarView::scrollBarValue(int val ) |
794 | { | 809 | { |
795 | #ifdef DESKTOP_VERSION | 810 | #ifdef DESKTOP_VERSION |
796 | if ( QApplication::desktop()->width() < 800 ) return; | 811 | if ( QApplication::desktop()->width() < 800 ) return; |
797 | static bool block = false; | 812 | static bool block = false; |
798 | if ( block ) return; | 813 | if ( block ) return; |
799 | block = true; | 814 | block = true; |
800 | int count = mNavigator->selectedDates().count(); | 815 | int count = mNavigator->selectedDates().count(); |
801 | int day = mNavigator->selectedDates().first().dayOfYear(); | 816 | int day = mNavigator->selectedDates().first().dayOfYear(); |
@@ -2701,195 +2716,196 @@ void CalendarView::updateConfig() | |||
2701 | 2716 | ||
2702 | 2717 | ||
2703 | void CalendarView::eventChanged(Event *event) | 2718 | void CalendarView::eventChanged(Event *event) |
2704 | { | 2719 | { |
2705 | changeEventDisplay(event,KOGlobals::EVENTEDITED); | 2720 | changeEventDisplay(event,KOGlobals::EVENTEDITED); |
2706 | //updateUnmanagedViews(); | 2721 | //updateUnmanagedViews(); |
2707 | } | 2722 | } |
2708 | 2723 | ||
2709 | void CalendarView::eventAdded(Event *event) | 2724 | void CalendarView::eventAdded(Event *event) |
2710 | { | 2725 | { |
2711 | changeEventDisplay(event,KOGlobals::EVENTADDED); | 2726 | changeEventDisplay(event,KOGlobals::EVENTADDED); |
2712 | } | 2727 | } |
2713 | 2728 | ||
2714 | void CalendarView::eventToBeDeleted(Event *) | 2729 | void CalendarView::eventToBeDeleted(Event *) |
2715 | { | 2730 | { |
2716 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2731 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2717 | } | 2732 | } |
2718 | 2733 | ||
2719 | void CalendarView::eventDeleted() | 2734 | void CalendarView::eventDeleted() |
2720 | { | 2735 | { |
2721 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2736 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2722 | } | 2737 | } |
2723 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2738 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2724 | { | 2739 | { |
2725 | changeIncidenceDisplay((Incidence *)which, action); | 2740 | changeIncidenceDisplay((Incidence *)which, action); |
2726 | mDateNavigator->updateView(); //LR | 2741 | mDateNavigator->updateView(); //LR |
2727 | //mDialogManager->updateSearchDialog(); | 2742 | //mDialogManager->updateSearchDialog(); |
2728 | 2743 | ||
2729 | if (which) { | 2744 | if (which) { |
2730 | mViewManager->updateWNview(); | 2745 | mViewManager->updateWNview(); |
2731 | //mTodoList->updateView(); | 2746 | //mTodoList->updateView(); |
2732 | } | 2747 | } |
2733 | 2748 | ||
2734 | } | 2749 | } |
2735 | 2750 | ||
2736 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2751 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2737 | { | 2752 | { |
2738 | updateUnmanagedViews(); | 2753 | updateUnmanagedViews(); |
2739 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2754 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2740 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2755 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2741 | mCalendar->checkAlarmForIncidence( 0, true ); | 2756 | mCalendar->checkAlarmForIncidence( 0, true ); |
2742 | if ( mEventViewerDialog ) | 2757 | if ( mEventViewerDialog ) |
2743 | mEventViewerDialog->hide(); | 2758 | mEventViewerDialog->hide(); |
2744 | } | 2759 | } |
2745 | else | 2760 | else |
2746 | mCalendar->checkAlarmForIncidence( which , false ); | 2761 | mCalendar->checkAlarmForIncidence( which , false ); |
2747 | } | 2762 | } |
2748 | 2763 | ||
2749 | // most of the changeEventDisplays() right now just call the view's | 2764 | // most of the changeEventDisplays() right now just call the view's |
2750 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2765 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2751 | void CalendarView::changeEventDisplay(Event *which, int action) | 2766 | void CalendarView::changeEventDisplay(Event *which, int action) |
2752 | { | 2767 | { |
2753 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2768 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2754 | changeIncidenceDisplay((Incidence *)which, action); | 2769 | changeIncidenceDisplay((Incidence *)which, action); |
2755 | static bool clearallviews = false; | 2770 | static bool clearallviews = false; |
2756 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2771 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2757 | if ( clearallviews ) { | 2772 | if ( clearallviews ) { |
2758 | clearAllViews(); | 2773 | clearAllViews(); |
2759 | clearallviews = false; | 2774 | clearallviews = false; |
2760 | } | 2775 | } |
2761 | return; | 2776 | return; |
2762 | } | 2777 | } |
2763 | clearallviews = true; | 2778 | clearallviews = true; |
2764 | mDateNavigator->updateView(); | 2779 | mDateNavigator->updateView(); |
2765 | //mDialogManager->updateSearchDialog(); | 2780 | //mDialogManager->updateSearchDialog(); |
2766 | if (which) { | 2781 | if (which) { |
2767 | // If there is an event view visible update the display | 2782 | // If there is an event view visible update the display |
2768 | mViewManager->currentView()->changeEventDisplay(which,action); | 2783 | mViewManager->currentView()->changeEventDisplay(which,action); |
2769 | // TODO: check, if update needed | 2784 | // TODO: check, if update needed |
2770 | // if (which->getTodoStatus()) { | 2785 | // if (which->getTodoStatus()) { |
2771 | mTodoList->updateView(); | 2786 | mTodoList->updateView(); |
2772 | if ( action != KOGlobals::EVENTDELETED ) { | 2787 | if ( action != KOGlobals::EVENTDELETED ) { |
2773 | mConflictingEvent = which ; | 2788 | mConflictingEvent = which ; |
2774 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | 2789 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); |
2775 | } | 2790 | } |
2776 | // } | 2791 | // } |
2777 | } else { | 2792 | } else { |
2778 | mViewManager->currentView()->updateView(); | 2793 | mViewManager->currentView()->updateView(); |
2779 | } | 2794 | } |
2780 | } | 2795 | } |
2781 | void CalendarView::checkConflictForEvent() | 2796 | void CalendarView::checkConflictForEvent() |
2782 | { | 2797 | { |
2783 | 2798 | ||
2784 | if (!KOPrefs::instance()->mConfirm) | 2799 | if (!KOPrefs::instance()->mConfirm) |
2785 | return; | 2800 | return; |
2786 | if ( ! mConflictingEvent ) return; | 2801 | if ( ! mConflictingEvent ) return; |
2787 | if ( mConflictingEvent->doesFloat() ) { | 2802 | if ( mConflictingEvent->doesFloat() ) { |
2788 | mConflictingEvent = 0; | 2803 | mConflictingEvent = 0; |
2789 | return; | 2804 | return; |
2790 | } | 2805 | } |
2791 | QPtrList<Event> testlist = mCalendar->events(); | 2806 | QPtrList<Event> testlist = mCalendar->events(); |
2792 | Event * test = testlist.first(); | 2807 | Event * test = testlist.first(); |
2793 | QDateTime conflict; | 2808 | QDateTime conflict; |
2794 | QDateTime retVal; | 2809 | QDateTime retVal; |
2795 | bool found = false; | 2810 | bool found = false; |
2796 | Event * cE = 0; | 2811 | Event * cE = 0; |
2812 | QDateTime current = QDateTime::currentDateTime(); | ||
2797 | while ( test ) { | 2813 | while ( test ) { |
2798 | if ( !test->doesFloat() ) { | 2814 | if ( !test->doesFloat() ) { |
2799 | if ( mConflictingEvent->isOverlapping ( test, &retVal, true ) ) { | 2815 | if ( mConflictingEvent->isOverlapping ( test, &retVal, ¤t ) ) { |
2800 | if ( ! found ) { | 2816 | if ( ! found ) { |
2801 | conflict = retVal; | 2817 | conflict = retVal; |
2802 | cE = test; | 2818 | cE = test; |
2803 | } else { | 2819 | } else { |
2804 | if ( retVal < conflict ) { | 2820 | if ( retVal < conflict ) { |
2805 | conflict = retVal; | 2821 | conflict = retVal; |
2806 | cE = test; | 2822 | cE = test; |
2807 | } | 2823 | } |
2808 | } | 2824 | } |
2809 | found = true; | 2825 | found = true; |
2810 | } | 2826 | } |
2811 | } | 2827 | } |
2812 | test = testlist.next(); | 2828 | test = testlist.next(); |
2813 | } | 2829 | } |
2814 | if ( found ) { | 2830 | if ( found ) { |
2815 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; | 2831 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( mConflictingEvent->summary(),0 ) ).arg( KGlobal::formatMessage ( cE->summary(),0 )).arg(KGlobal::locale()->formatDate(conflict.date()) ) ; |
2816 | qApp->processEvents(); | 2832 | qApp->processEvents(); |
2817 | int km = KMessageBox::warningContinueCancel(this,mess, | 2833 | int km = KMessageBox::warningContinueCancel(this,mess, |
2818 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | 2834 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); |
2819 | if ( km != KMessageBox::Continue ) | 2835 | if ( km != KMessageBox::Continue ) |
2820 | return; | 2836 | return; |
2821 | 2837 | ||
2822 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | 2838 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) |
2823 | mViewManager->showDayView(); | 2839 | mViewManager->showDayView(); |
2824 | mNavigator->slotDaySelect( conflict.date() ); | 2840 | mNavigator->slotDaySelect( conflict.date() ); |
2825 | int hour = conflict.time().hour(); | 2841 | int hour = conflict.time().hour(); |
2826 | mViewManager->agendaView()->setStartHour( hour ); | 2842 | mViewManager->agendaView()->setStartHour( hour ); |
2827 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); | 2843 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( mConflictingEvent->summary().left( 20 ) ).arg( cE->summary().left( 20 ) ) ); |
2828 | return; | 2844 | return; |
2829 | } | 2845 | } |
2830 | 2846 | ||
2831 | return; | 2847 | return; |
2832 | 2848 | ||
2833 | } | 2849 | } |
2834 | 2850 | ||
2835 | void CalendarView::updateTodoViews() | 2851 | void CalendarView::updateTodoViews() |
2836 | { | 2852 | { |
2837 | mTodoList->updateView(); | 2853 | mTodoList->updateView(); |
2838 | mViewManager->currentView()->updateView(); | 2854 | mViewManager->currentView()->updateView(); |
2839 | 2855 | ||
2840 | } | 2856 | } |
2841 | 2857 | ||
2842 | 2858 | ||
2843 | 2859 | ||
2844 | void CalendarView::clearAllViews() | 2860 | void CalendarView::clearAllViews() |
2845 | { | 2861 | { |
2846 | mTodoList->clearList(); | 2862 | mTodoList->clearList(); |
2847 | mViewManager->clearAllViews(); | 2863 | mViewManager->clearAllViews(); |
2848 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2864 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2849 | if ( sd ) { | 2865 | if ( sd ) { |
2850 | KOListView* kol = sd->listview(); | 2866 | KOListView* kol = sd->listview(); |
2851 | if ( kol ) | 2867 | if ( kol ) |
2852 | kol->clearList(); | 2868 | kol->clearList(); |
2853 | } | 2869 | } |
2854 | } | 2870 | } |
2855 | void CalendarView::updateView() | 2871 | void CalendarView::updateView() |
2856 | { | 2872 | { |
2857 | static bool clearallviews = false; | 2873 | static bool clearallviews = false; |
2858 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2874 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2859 | if ( clearallviews ) { | 2875 | if ( clearallviews ) { |
2860 | clearAllViews(); | 2876 | clearAllViews(); |
2861 | clearallviews = false; | 2877 | clearallviews = false; |
2862 | } | 2878 | } |
2863 | return; | 2879 | return; |
2864 | } | 2880 | } |
2865 | clearallviews = true; | 2881 | clearallviews = true; |
2866 | DateList tmpList = mNavigator->selectedDates(); | 2882 | DateList tmpList = mNavigator->selectedDates(); |
2867 | 2883 | ||
2868 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2884 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2869 | mTodoList->updateView(); | 2885 | mTodoList->updateView(); |
2870 | // We assume that the navigator only selects consecutive days. | 2886 | // We assume that the navigator only selects consecutive days. |
2871 | updateView( tmpList.first(), tmpList.last() ); | 2887 | updateView( tmpList.first(), tmpList.last() ); |
2872 | } | 2888 | } |
2873 | 2889 | ||
2874 | void CalendarView::updateUnmanagedViews() | 2890 | void CalendarView::updateUnmanagedViews() |
2875 | { | 2891 | { |
2876 | mDateNavigator->updateDayMatrix(); | 2892 | mDateNavigator->updateDayMatrix(); |
2877 | } | 2893 | } |
2878 | 2894 | ||
2879 | int CalendarView::msgItemDelete(const QString name) | 2895 | int CalendarView::msgItemDelete(const QString name) |
2880 | { | 2896 | { |
2881 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2897 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2882 | i18n("This item will be\npermanently deleted."), | 2898 | i18n("This item will be\npermanently deleted."), |
2883 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2899 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2884 | } | 2900 | } |
2885 | 2901 | ||
2886 | 2902 | ||
2887 | void CalendarView::edit_cut() | 2903 | void CalendarView::edit_cut() |
2888 | { | 2904 | { |
2889 | Event *anEvent=0; | 2905 | Event *anEvent=0; |
2890 | 2906 | ||
2891 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2907 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2892 | 2908 | ||
2893 | if (mViewManager->currentView()->isEventView()) { | 2909 | if (mViewManager->currentView()->isEventView()) { |
2894 | if ( incidence && incidence->typeID() == eventID ) { | 2910 | if ( incidence && incidence->typeID() == eventID ) { |
2895 | anEvent = static_cast<Event *>(incidence); | 2911 | anEvent = static_cast<Event *>(incidence); |