summaryrefslogtreecommitdiffabout
path: root/korganizer/calendarview.cpp
authorzautrix <zautrix>2005-07-07 12:30:17 (UTC)
committer zautrix <zautrix>2005-07-07 12:30:17 (UTC)
commit766b53919de14b8faec22db32b6a750acde0b760 (patch) (unidiff)
treebb07c0af89b0dddf4257a61e9f5b1cf23c4a282a /korganizer/calendarview.cpp
parentb4d85da57e2d558ec088af6f3b2a34b1854462c0 (diff)
downloadkdepimpi-766b53919de14b8faec22db32b6a750acde0b760.zip
kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.gz
kdepimpi-766b53919de14b8faec22db32b6a750acde0b760.tar.bz2
fixesss
Diffstat (limited to 'korganizer/calendarview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp70
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
@@ -2593,262 +2593,332 @@ void CalendarView::writeFilterSettings(KConfig *config)
2593 config->writeEntry("Criteria",filter->criteria()); 2593 config->writeEntry("Criteria",filter->criteria());
2594 config->writeEntry("CategoryList",filter->categoryList()); 2594 config->writeEntry("CategoryList",filter->categoryList());
2595 filter = mFilters.next(); 2595 filter = mFilters.next();
2596 } 2596 }
2597 config->setGroup("General"); 2597 config->setGroup("General");
2598 config->writeEntry("CalendarFilters",filterList); 2598 config->writeEntry("CalendarFilters",filterList);
2599 2599
2600 config->setGroup("FilterView"); 2600 config->setGroup("FilterView");
2601 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled()); 2601 config->writeEntry("FilterEnabled",mFilterView->filtersEnabled());
2602 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name()); 2602 config->writeEntry("Current Filter",mFilterView->selectedFilter()->name());
2603} 2603}
2604 2604
2605 2605
2606void CalendarView::goToday() 2606void CalendarView::goToday()
2607{ 2607{
2608 if ( mViewManager->currentView()->isMonthView() ) 2608 if ( mViewManager->currentView()->isMonthView() )
2609 mNavigator->selectTodayMonth(); 2609 mNavigator->selectTodayMonth();
2610 else 2610 else
2611 mNavigator->selectToday(); 2611 mNavigator->selectToday();
2612} 2612}
2613 2613
2614void CalendarView::goNext() 2614void CalendarView::goNext()
2615{ 2615{
2616 mNavigator->selectNext(); 2616 mNavigator->selectNext();
2617} 2617}
2618 2618
2619void CalendarView::goPrevious() 2619void CalendarView::goPrevious()
2620{ 2620{
2621 mNavigator->selectPrevious(); 2621 mNavigator->selectPrevious();
2622} 2622}
2623void CalendarView::goNextMonth() 2623void CalendarView::goNextMonth()
2624{ 2624{
2625 mNavigator->selectNextMonth(); 2625 mNavigator->selectNextMonth();
2626} 2626}
2627 2627
2628void CalendarView::goPreviousMonth() 2628void CalendarView::goPreviousMonth()
2629{ 2629{
2630 mNavigator->selectPreviousMonth(); 2630 mNavigator->selectPreviousMonth();
2631} 2631}
2632 2632
2633void CalendarView::updateConfig() 2633void CalendarView::updateConfig()
2634{ 2634{
2635 if ( KOPrefs::instance()->mUseAppColors ) 2635 if ( KOPrefs::instance()->mUseAppColors )
2636 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true ); 2636 QApplication::setPalette( QPalette (KOPrefs::instance()->mAppColor1, KOPrefs::instance()->mAppColor2), true );
2637 emit configChanged(); 2637 emit configChanged();
2638 mTodoList->updateConfig(); 2638 mTodoList->updateConfig();
2639 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont); 2639 // mDateNavigator->setFont ( KOPrefs::instance()->mDateNavigatorFont);
2640 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2640 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2641 // To make the "fill window" configurations work 2641 // To make the "fill window" configurations work
2642 //mViewManager->raiseCurrentView(); 2642 //mViewManager->raiseCurrentView();
2643} 2643}
2644 2644
2645 2645
2646void CalendarView::eventChanged(Event *event) 2646void CalendarView::eventChanged(Event *event)
2647{ 2647{
2648 changeEventDisplay(event,KOGlobals::EVENTEDITED); 2648 changeEventDisplay(event,KOGlobals::EVENTEDITED);
2649 //updateUnmanagedViews(); 2649 //updateUnmanagedViews();
2650} 2650}
2651 2651
2652void CalendarView::eventAdded(Event *event) 2652void CalendarView::eventAdded(Event *event)
2653{ 2653{
2654 changeEventDisplay(event,KOGlobals::EVENTADDED); 2654 changeEventDisplay(event,KOGlobals::EVENTADDED);
2655} 2655}
2656 2656
2657void CalendarView::eventToBeDeleted(Event *) 2657void 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
2662void CalendarView::eventDeleted() 2662void CalendarView::eventDeleted()
2663{ 2663{
2664 changeEventDisplay(0,KOGlobals::EVENTDELETED); 2664 changeEventDisplay(0,KOGlobals::EVENTDELETED);
2665} 2665}
2666void CalendarView::changeTodoDisplay(Todo *which, int action) 2666void 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
2679void CalendarView::changeIncidenceDisplay(Incidence *which, int action) 2679void 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.
2694void CalendarView::changeEventDisplay(Event *which, int action) 2694void 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}
2730void 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
2728void CalendarView::updateTodoViews() 2798void 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
2737void CalendarView::clearAllViews() 2807void 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}
2748void CalendarView::updateView() 2818void 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
2767void CalendarView::updateUnmanagedViews() 2837void CalendarView::updateUnmanagedViews()
2768{ 2838{
2769 mDateNavigator->updateDayMatrix(); 2839 mDateNavigator->updateDayMatrix();
2770} 2840}
2771 2841
2772int CalendarView::msgItemDelete(const QString name) 2842int 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
2780void CalendarView::edit_cut() 2850void 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 }
2791 2861
2792 if (!anEvent) { 2862 if (!anEvent) {
2793 KNotifyClient::beep(); 2863 KNotifyClient::beep();
2794 return; 2864 return;
2795 } 2865 }
2796 DndFactory factory( mCalendar ); 2866 DndFactory factory( mCalendar );
2797 factory.cutIncidence(anEvent); 2867 factory.cutIncidence(anEvent);
2798 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2868 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2799} 2869}
2800 2870
2801void CalendarView::edit_copy() 2871void CalendarView::edit_copy()
2802{ 2872{
2803 Event *anEvent=0; 2873 Event *anEvent=0;
2804 2874
2805 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2875 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2806 2876
2807 if (mViewManager->currentView()->isEventView()) { 2877 if (mViewManager->currentView()->isEventView()) {
2808 if ( incidence && incidence->typeID() == eventID ) { 2878 if ( incidence && incidence->typeID() == eventID ) {
2809 anEvent = static_cast<Event *>(incidence); 2879 anEvent = static_cast<Event *>(incidence);
2810 } 2880 }
2811 } 2881 }
2812 2882
2813 if (!anEvent) { 2883 if (!anEvent) {
2814 KNotifyClient::beep(); 2884 KNotifyClient::beep();
2815 return; 2885 return;
2816 } 2886 }
2817 DndFactory factory( mCalendar ); 2887 DndFactory factory( mCalendar );
2818 factory.copyIncidence(anEvent); 2888 factory.copyIncidence(anEvent);
2819} 2889}
2820 2890
2821void CalendarView::edit_paste() 2891void CalendarView::edit_paste()
2822{ 2892{
2823 QDate date = mNavigator->selectedDates().first(); 2893 QDate date = mNavigator->selectedDates().first();
2824 2894
2825 DndFactory factory( mCalendar ); 2895 DndFactory factory( mCalendar );
2826 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2896 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2827 2897
2828 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2898 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2829} 2899}
2830void CalendarView::edit_global_options() 2900void CalendarView::edit_global_options()
2831{ 2901{
2832 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2902 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2833 emit save(); 2903 emit save();
2834 emit saveStopTimer(); 2904 emit saveStopTimer();
2835 mDialogManager->showGlobalOptionsDialog(); 2905 mDialogManager->showGlobalOptionsDialog();
2836 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2906 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2837 emit saveStopTimer(); 2907 emit saveStopTimer();
2838 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"), 2908 if ( KMessageBox::Cancel == KMessageBox::warningContinueCancel(this, i18n("The timezone has changed!\nShould the calendar be reloaded\nto shift the time of the events?\nPlease read Menu: Help->FAQ:\n\"How do I change the timezone?\"\nas well!"),
2839 i18n("Timezone settings"),i18n("Reload"))) { 2909 i18n("Timezone settings"),i18n("Reload"))) {
2840 qDebug("KO: TZ reload cancelled "); 2910 qDebug("KO: TZ reload cancelled ");
2841 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2911 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2842 return; 2912 return;
2843 } 2913 }
2844 qDebug("KO: Timezone change "); 2914 qDebug("KO: Timezone change ");
2845 loadCalendars(); 2915 loadCalendars();
2846 setModified(true); 2916 setModified(true);
2847 } 2917 }
2848 else 2918 else
2849 qDebug("KO: No tz change "); 2919 qDebug("KO: No tz change ");
2850} 2920}
2851void CalendarView::edit_options() 2921void CalendarView::edit_options()
2852{ 2922{
2853 mDialogManager->showOptionsDialog(); 2923 mDialogManager->showOptionsDialog();
2854} 2924}