author | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 12:30:17 (UTC) |
commit | 766b53919de14b8faec22db32b6a750acde0b760 (patch) (unidiff) | |
tree | bb07c0af89b0dddf4257a61e9f5b1cf23c4a282a /korganizer/calendarview.cpp | |
parent | b4d85da57e2d558ec088af6f3b2a34b1854462c0 (diff) | |
download | kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.zip kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.gz kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.bz2 |
fixesss
-rw-r--r-- | korganizer/calendarview.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 9a114d0..e766b8f 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2657,134 +2657,204 @@ void CalendarView::eventAdded(Event *event) | |||
2657 | void CalendarView::eventToBeDeleted(Event *) | 2657 | void CalendarView::eventToBeDeleted(Event *) |
2658 | { | 2658 | { |
2659 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; | 2659 | kdDebug() << "CalendarView::eventToBeDeleted(): to be implemented" << endl; |
2660 | } | 2660 | } |
2661 | 2661 | ||
2662 | void CalendarView::eventDeleted() | 2662 | void CalendarView::eventDeleted() |
2663 | { | 2663 | { |
2664 | changeEventDisplay(0,KOGlobals::EVENTDELETED); | 2664 | changeEventDisplay(0,KOGlobals::EVENTDELETED); |
2665 | } | 2665 | } |
2666 | void CalendarView::changeTodoDisplay(Todo *which, int action) | 2666 | void CalendarView::changeTodoDisplay(Todo *which, int action) |
2667 | { | 2667 | { |
2668 | changeIncidenceDisplay((Incidence *)which, action); | 2668 | changeIncidenceDisplay((Incidence *)which, action); |
2669 | mDateNavigator->updateView(); //LR | 2669 | mDateNavigator->updateView(); //LR |
2670 | //mDialogManager->updateSearchDialog(); | 2670 | //mDialogManager->updateSearchDialog(); |
2671 | 2671 | ||
2672 | if (which) { | 2672 | if (which) { |
2673 | mViewManager->updateWNview(); | 2673 | mViewManager->updateWNview(); |
2674 | //mTodoList->updateView(); | 2674 | //mTodoList->updateView(); |
2675 | } | 2675 | } |
2676 | 2676 | ||
2677 | } | 2677 | } |
2678 | 2678 | ||
2679 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) | 2679 | void CalendarView::changeIncidenceDisplay(Incidence *which, int action) |
2680 | { | 2680 | { |
2681 | updateUnmanagedViews(); | 2681 | updateUnmanagedViews(); |
2682 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); | 2682 | //qDebug(" CalendarView::changeIncidenceDisplay++++++++++++++++++++++++++ %d %d ",which, action ); |
2683 | if ( action == KOGlobals::EVENTDELETED ) { //delete | 2683 | if ( action == KOGlobals::EVENTDELETED ) { //delete |
2684 | mCalendar->checkAlarmForIncidence( 0, true ); | 2684 | mCalendar->checkAlarmForIncidence( 0, true ); |
2685 | if ( mEventViewerDialog ) | 2685 | if ( mEventViewerDialog ) |
2686 | mEventViewerDialog->hide(); | 2686 | mEventViewerDialog->hide(); |
2687 | } | 2687 | } |
2688 | else | 2688 | else |
2689 | mCalendar->checkAlarmForIncidence( which , false ); | 2689 | mCalendar->checkAlarmForIncidence( which , false ); |
2690 | } | 2690 | } |
2691 | 2691 | ||
2692 | // most of the changeEventDisplays() right now just call the view's | 2692 | // most of the changeEventDisplays() right now just call the view's |
2693 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. | 2693 | // total update mode, but they SHOULD be recoded to be more refresh-efficient. |
2694 | void CalendarView::changeEventDisplay(Event *which, int action) | 2694 | void CalendarView::changeEventDisplay(Event *which, int action) |
2695 | { | 2695 | { |
2696 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; | 2696 | // kdDebug() << "CalendarView::changeEventDisplay" << endl; |
2697 | changeIncidenceDisplay((Incidence *)which, action); | 2697 | changeIncidenceDisplay((Incidence *)which, action); |
2698 | 2698 | ||
2699 | 2699 | ||
2700 | static bool clearallviews = false; | 2700 | static bool clearallviews = false; |
2701 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2701 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2702 | if ( clearallviews ) { | 2702 | if ( clearallviews ) { |
2703 | clearAllViews(); | 2703 | clearAllViews(); |
2704 | clearallviews = false; | 2704 | clearallviews = false; |
2705 | } | 2705 | } |
2706 | return; | 2706 | return; |
2707 | } | 2707 | } |
2708 | clearallviews = true; | 2708 | clearallviews = true; |
2709 | 2709 | ||
2710 | 2710 | ||
2711 | 2711 | ||
2712 | mDateNavigator->updateView(); | 2712 | mDateNavigator->updateView(); |
2713 | //mDialogManager->updateSearchDialog(); | 2713 | //mDialogManager->updateSearchDialog(); |
2714 | 2714 | ||
2715 | if (which) { | 2715 | if (which) { |
2716 | // If there is an event view visible update the display | 2716 | // If there is an event view visible update the display |
2717 | mViewManager->currentView()->changeEventDisplay(which,action); | 2717 | mViewManager->currentView()->changeEventDisplay(which,action); |
2718 | // TODO: check, if update needed | 2718 | // TODO: check, if update needed |
2719 | // if (which->getTodoStatus()) { | 2719 | // if (which->getTodoStatus()) { |
2720 | mTodoList->updateView(); | 2720 | mTodoList->updateView(); |
2721 | if ( action != KOGlobals::EVENTDELETED ) { | ||
2722 | mConflictingEvent = which ; | ||
2723 | QTimer::singleShot( 1000, this, SLOT ( checkConflictForEvent() ) ); | ||
2724 | } | ||
2721 | // } | 2725 | // } |
2722 | } else { | 2726 | } else { |
2723 | mViewManager->currentView()->updateView(); | 2727 | mViewManager->currentView()->updateView(); |
2724 | } | 2728 | } |
2725 | } | 2729 | } |
2730 | void CalendarView::checkConflictForEvent() | ||
2731 | { | ||
2732 | |||
2733 | if (!KOPrefs::instance()->mConfirm) | ||
2734 | return; | ||
2735 | if ( ! mConflictingEvent ) return; | ||
2736 | if ( mConflictingEvent->doesFloat() ) { | ||
2737 | mConflictingEvent = 0; | ||
2738 | return; | ||
2739 | } | ||
2740 | bool all = false; | ||
2741 | bool allday = false; | ||
2742 | Event * ev = mConflictingEvent; | ||
2743 | mConflictingEvent = 0; | ||
2744 | QDate start = ev->dtStart().date(); | ||
2745 | QDate end = ev->dtEnd().date().addDays(1); | ||
2746 | while ( start < end ) { | ||
2747 | QPtrList<Event> test = calendar()->events( start ); | ||
2748 | //qDebug("found %d on %s ", eventList.count(), start.toString().latin1()); | ||
2749 | Event * t_ev = test.first(); | ||
2750 | QDateTime es = ev->dtStart(); | ||
2751 | QDateTime ee = ev->dtEnd(); | ||
2752 | if ( ev->doesFloat() ) | ||
2753 | ee = ee.addDays( 1 ); | ||
2754 | if ( ! all ) { | ||
2755 | if ( ev->doesFloat() != allday ) | ||
2756 | t_ev = 0; | ||
2757 | } | ||
2758 | while ( t_ev ) { | ||
2759 | bool skip = false; | ||
2760 | if ( ! all ) { | ||
2761 | if ( t_ev->doesFloat() != allday ) | ||
2762 | skip = true; | ||
2763 | } | ||
2764 | if ( !skip && ev != t_ev ) { | ||
2765 | QDateTime ets = t_ev->dtStart(); | ||
2766 | QDateTime ete = t_ev->dtEnd(); | ||
2767 | if ( t_ev->doesFloat() ) | ||
2768 | ete = ete.addDays( 1 ); | ||
2769 | //qDebug("test %s -- %s -------- %s -- %s ", es.toString().latin1() , ee.toString().latin1(), ets.toString().latin1() , ete.toString().latin1() ); | ||
2770 | if ( es < ete && ets < ee ) { | ||
2771 | QString mess = i18n("The event\n%1\nconflicts with event\n%2\nat date\n%3.\n").arg(KGlobal::formatMessage ( ev->summary(),0 ) ).arg( KGlobal::formatMessage ( t_ev->summary(),0 )).arg(KGlobal::locale()->formatDate(start) ) ; | ||
2772 | qApp->processEvents(); | ||
2773 | int km = KMessageBox::warningContinueCancel(this,mess, | ||
2774 | i18n("KO/Pi Conflict delected"),i18n("Show date"),i18n("No problem!")); | ||
2775 | if ( km != KMessageBox::Continue ) | ||
2776 | return; | ||
2777 | |||
2778 | if ( mViewManager->currentView() != mViewManager->agendaView() || mNavigator->selectedDates().count() > 1 ) | ||
2779 | mViewManager->showDayView(); | ||
2780 | mNavigator->slotDaySelect( start ); | ||
2781 | int hour = es.time().hour(); | ||
2782 | if ( ets > es ) | ||
2783 | hour = ets.time().hour(); | ||
2784 | mViewManager->agendaView()->setStartHour( hour ); | ||
2785 | topLevelWidget()->setCaption( i18n("Conflict %1 <-> %2"). arg( ev->summary().left( 20 ) ).arg( t_ev->summary().left( 20 ) ) ); | ||
2786 | return; | ||
2787 | } | ||
2788 | } | ||
2789 | t_ev = test.next(); | ||
2790 | } | ||
2791 | start = start.addDays( 1 ); | ||
2792 | } | ||
2793 | qDebug("No conflict found "); | ||
2794 | |||
2726 | 2795 | ||
2796 | } | ||
2727 | 2797 | ||
2728 | void CalendarView::updateTodoViews() | 2798 | void CalendarView::updateTodoViews() |
2729 | { | 2799 | { |
2730 | mTodoList->updateView(); | 2800 | mTodoList->updateView(); |
2731 | mViewManager->currentView()->updateView(); | 2801 | mViewManager->currentView()->updateView(); |
2732 | 2802 | ||
2733 | } | 2803 | } |
2734 | 2804 | ||
2735 | 2805 | ||
2736 | 2806 | ||
2737 | void CalendarView::clearAllViews() | 2807 | void CalendarView::clearAllViews() |
2738 | { | 2808 | { |
2739 | mTodoList->clearList(); | 2809 | mTodoList->clearList(); |
2740 | mViewManager->clearAllViews(); | 2810 | mViewManager->clearAllViews(); |
2741 | SearchDialog * sd = mDialogManager->getSearchDialog(); | 2811 | SearchDialog * sd = mDialogManager->getSearchDialog(); |
2742 | if ( sd ) { | 2812 | if ( sd ) { |
2743 | KOListView* kol = sd->listview(); | 2813 | KOListView* kol = sd->listview(); |
2744 | if ( kol ) | 2814 | if ( kol ) |
2745 | kol->clearList(); | 2815 | kol->clearList(); |
2746 | } | 2816 | } |
2747 | } | 2817 | } |
2748 | void CalendarView::updateView() | 2818 | void CalendarView::updateView() |
2749 | { | 2819 | { |
2750 | static bool clearallviews = false; | 2820 | static bool clearallviews = false; |
2751 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { | 2821 | if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { |
2752 | if ( clearallviews ) { | 2822 | if ( clearallviews ) { |
2753 | clearAllViews(); | 2823 | clearAllViews(); |
2754 | clearallviews = false; | 2824 | clearallviews = false; |
2755 | } | 2825 | } |
2756 | return; | 2826 | return; |
2757 | } | 2827 | } |
2758 | clearallviews = true; | 2828 | clearallviews = true; |
2759 | DateList tmpList = mNavigator->selectedDates(); | 2829 | DateList tmpList = mNavigator->selectedDates(); |
2760 | 2830 | ||
2761 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 2831 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
2762 | mTodoList->updateView(); | 2832 | mTodoList->updateView(); |
2763 | // We assume that the navigator only selects consecutive days. | 2833 | // We assume that the navigator only selects consecutive days. |
2764 | updateView( tmpList.first(), tmpList.last() ); | 2834 | updateView( tmpList.first(), tmpList.last() ); |
2765 | } | 2835 | } |
2766 | 2836 | ||
2767 | void CalendarView::updateUnmanagedViews() | 2837 | void CalendarView::updateUnmanagedViews() |
2768 | { | 2838 | { |
2769 | mDateNavigator->updateDayMatrix(); | 2839 | mDateNavigator->updateDayMatrix(); |
2770 | } | 2840 | } |
2771 | 2841 | ||
2772 | int CalendarView::msgItemDelete(const QString name) | 2842 | int CalendarView::msgItemDelete(const QString name) |
2773 | { | 2843 | { |
2774 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ | 2844 | return KMessageBox::warningContinueCancel(this,name +"\n\n"+ |
2775 | i18n("This item will be\npermanently deleted."), | 2845 | i18n("This item will be\npermanently deleted."), |
2776 | i18n("KO/Pi Confirmation"),i18n("Delete")); | 2846 | i18n("KO/Pi Confirmation"),i18n("Delete")); |
2777 | } | 2847 | } |
2778 | 2848 | ||
2779 | 2849 | ||
2780 | void CalendarView::edit_cut() | 2850 | void CalendarView::edit_cut() |
2781 | { | 2851 | { |
2782 | Event *anEvent=0; | 2852 | Event *anEvent=0; |
2783 | 2853 | ||
2784 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2854 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2785 | 2855 | ||
2786 | if (mViewManager->currentView()->isEventView()) { | 2856 | if (mViewManager->currentView()->isEventView()) { |
2787 | if ( incidence && incidence->typeID() == eventID ) { | 2857 | if ( incidence && incidence->typeID() == eventID ) { |
2788 | anEvent = static_cast<Event *>(incidence); | 2858 | anEvent = static_cast<Event *>(incidence); |
2789 | } | 2859 | } |
2790 | } | 2860 | } |