-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index d6918d3..6eaac1c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2589,1400 +2589,1404 @@ void CalendarView::moveIncidence() | |||
2589 | void CalendarView::beamIncidence() | 2589 | void CalendarView::beamIncidence() |
2590 | { | 2590 | { |
2591 | Incidence *incidence = currentSelection(); | 2591 | Incidence *incidence = currentSelection(); |
2592 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2592 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2593 | if ( incidence ) { | 2593 | if ( incidence ) { |
2594 | beamIncidence(incidence); | 2594 | beamIncidence(incidence); |
2595 | } | 2595 | } |
2596 | } | 2596 | } |
2597 | void CalendarView::toggleCancelIncidence() | 2597 | void CalendarView::toggleCancelIncidence() |
2598 | { | 2598 | { |
2599 | Incidence *incidence = currentSelection(); | 2599 | Incidence *incidence = currentSelection(); |
2600 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2600 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2601 | if ( incidence ) { | 2601 | if ( incidence ) { |
2602 | cancelIncidence(incidence); | 2602 | cancelIncidence(incidence); |
2603 | } | 2603 | } |
2604 | } | 2604 | } |
2605 | 2605 | ||
2606 | 2606 | ||
2607 | void CalendarView::cancelIncidence(Incidence * inc ) | 2607 | void CalendarView::cancelIncidence(Incidence * inc ) |
2608 | { | 2608 | { |
2609 | inc->setCancelled( ! inc->cancelled() ); | 2609 | inc->setCancelled( ! inc->cancelled() ); |
2610 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2610 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2611 | updateView(); | 2611 | updateView(); |
2612 | } | 2612 | } |
2613 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2613 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2614 | { | 2614 | { |
2615 | Incidence * newInc = orgInc->clone(); | 2615 | Incidence * newInc = orgInc->clone(); |
2616 | newInc->recreate(); | 2616 | newInc->recreate(); |
2617 | 2617 | ||
2618 | if ( newInc->type() == "Todo" ) { | 2618 | if ( newInc->type() == "Todo" ) { |
2619 | Todo* t = (Todo*) newInc; | 2619 | Todo* t = (Todo*) newInc; |
2620 | showTodoEditor(); | 2620 | showTodoEditor(); |
2621 | mTodoEditor->editTodo( t ); | 2621 | mTodoEditor->editTodo( t ); |
2622 | if ( mTodoEditor->exec() ) { | 2622 | if ( mTodoEditor->exec() ) { |
2623 | mCalendar->addTodo( t ); | 2623 | mCalendar->addTodo( t ); |
2624 | updateView(); | 2624 | updateView(); |
2625 | } else { | 2625 | } else { |
2626 | delete t; | 2626 | delete t; |
2627 | } | 2627 | } |
2628 | } | 2628 | } |
2629 | else { | 2629 | else { |
2630 | Event* e = (Event*) newInc; | 2630 | Event* e = (Event*) newInc; |
2631 | showEventEditor(); | 2631 | showEventEditor(); |
2632 | mEventEditor->editEvent( e ); | 2632 | mEventEditor->editEvent( e ); |
2633 | if ( mEventEditor->exec() ) { | 2633 | if ( mEventEditor->exec() ) { |
2634 | mCalendar->addEvent( e ); | 2634 | mCalendar->addEvent( e ); |
2635 | updateView(); | 2635 | updateView(); |
2636 | } else { | 2636 | } else { |
2637 | delete e; | 2637 | delete e; |
2638 | } | 2638 | } |
2639 | } | 2639 | } |
2640 | setActiveWindow(); | 2640 | setActiveWindow(); |
2641 | } | 2641 | } |
2642 | 2642 | ||
2643 | void CalendarView::newEvent() | 2643 | void CalendarView::newEvent() |
2644 | { | 2644 | { |
2645 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2645 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2646 | KOAgendaView *aView = mViewManager->agendaView(); | 2646 | KOAgendaView *aView = mViewManager->agendaView(); |
2647 | if (aView) { | 2647 | if (aView) { |
2648 | if (aView->selectionStart().isValid()) { | 2648 | if (aView->selectionStart().isValid()) { |
2649 | if (aView->selectedIsAllDay()) { | 2649 | if (aView->selectedIsAllDay()) { |
2650 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2650 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2651 | } else { | 2651 | } else { |
2652 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2652 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2653 | } | 2653 | } |
2654 | return; | 2654 | return; |
2655 | } | 2655 | } |
2656 | } | 2656 | } |
2657 | 2657 | ||
2658 | QDate date = mNavigator->selectedDates().first(); | 2658 | QDate date = mNavigator->selectedDates().first(); |
2659 | QDateTime current = QDateTime::currentDateTime(); | 2659 | QDateTime current = QDateTime::currentDateTime(); |
2660 | if ( date <= current.date() ) { | 2660 | if ( date <= current.date() ) { |
2661 | int hour = current.time().hour() +1; | 2661 | int hour = current.time().hour() +1; |
2662 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2662 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2663 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2663 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2664 | } else | 2664 | } else |
2665 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2665 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2666 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2666 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2667 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2667 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2668 | } | 2668 | } |
2669 | 2669 | ||
2670 | void CalendarView::newEvent(QDateTime fh) | 2670 | void CalendarView::newEvent(QDateTime fh) |
2671 | { | 2671 | { |
2672 | newEvent(fh, | 2672 | newEvent(fh, |
2673 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2673 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | void CalendarView::newEvent(QDate dt) | 2676 | void CalendarView::newEvent(QDate dt) |
2677 | { | 2677 | { |
2678 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2678 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2679 | QDateTime(dt, QTime(0,0,0)), true); | 2679 | QDateTime(dt, QTime(0,0,0)), true); |
2680 | } | 2680 | } |
2681 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 2681 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
2682 | { | 2682 | { |
2683 | newEvent(fromHint, toHint, false); | 2683 | newEvent(fromHint, toHint, false); |
2684 | } | 2684 | } |
2685 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2685 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2686 | { | 2686 | { |
2687 | 2687 | ||
2688 | showEventEditor(); | 2688 | showEventEditor(); |
2689 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2689 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2690 | if ( mFilterView->filtersEnabled() ) { | 2690 | if ( mFilterView->filtersEnabled() ) { |
2691 | CalFilter *filter = mFilterView->selectedFilter(); | 2691 | CalFilter *filter = mFilterView->selectedFilter(); |
2692 | if (filter && filter->showCategories()) { | 2692 | if (filter && filter->showCategories()) { |
2693 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2693 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2694 | } | 2694 | } |
2695 | if ( filter ) | 2695 | if ( filter ) |
2696 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2696 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2697 | } | 2697 | } |
2698 | mEventEditor->exec(); | 2698 | mEventEditor->exec(); |
2699 | setActiveWindow(); | 2699 | setActiveWindow(); |
2700 | } | 2700 | } |
2701 | void CalendarView::todoAdded(Todo * t) | 2701 | void CalendarView::todoAdded(Todo * t) |
2702 | { | 2702 | { |
2703 | 2703 | ||
2704 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2704 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2705 | updateTodoViews(); | 2705 | updateTodoViews(); |
2706 | } | 2706 | } |
2707 | void CalendarView::todoChanged(Todo * t) | 2707 | void CalendarView::todoChanged(Todo * t) |
2708 | { | 2708 | { |
2709 | emit todoModified( t, 4 ); | 2709 | emit todoModified( t, 4 ); |
2710 | // updateTodoViews(); | 2710 | // updateTodoViews(); |
2711 | } | 2711 | } |
2712 | void CalendarView::todoToBeDeleted(Todo *) | 2712 | void CalendarView::todoToBeDeleted(Todo *) |
2713 | { | 2713 | { |
2714 | //qDebug("todoToBeDeleted(Todo *) "); | 2714 | //qDebug("todoToBeDeleted(Todo *) "); |
2715 | updateTodoViews(); | 2715 | updateTodoViews(); |
2716 | } | 2716 | } |
2717 | void CalendarView::todoDeleted() | 2717 | void CalendarView::todoDeleted() |
2718 | { | 2718 | { |
2719 | //qDebug(" todoDeleted()"); | 2719 | //qDebug(" todoDeleted()"); |
2720 | updateTodoViews(); | 2720 | updateTodoViews(); |
2721 | } | 2721 | } |
2722 | 2722 | ||
2723 | 2723 | ||
2724 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 2724 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
2725 | { | 2725 | { |
2726 | showTodoEditor(); | 2726 | showTodoEditor(); |
2727 | mTodoEditor->newTodo(dt,0,allday); | 2727 | mTodoEditor->newTodo(dt,0,allday); |
2728 | if ( mFilterView->filtersEnabled() ) { | 2728 | if ( mFilterView->filtersEnabled() ) { |
2729 | CalFilter *filter = mFilterView->selectedFilter(); | 2729 | CalFilter *filter = mFilterView->selectedFilter(); |
2730 | if (filter && filter->showCategories()) { | 2730 | if (filter && filter->showCategories()) { |
2731 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2731 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2732 | } | 2732 | } |
2733 | if ( filter ) | 2733 | if ( filter ) |
2734 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2734 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2735 | } | 2735 | } |
2736 | mTodoEditor->exec(); | 2736 | mTodoEditor->exec(); |
2737 | setActiveWindow(); | 2737 | setActiveWindow(); |
2738 | } | 2738 | } |
2739 | 2739 | ||
2740 | void CalendarView::newTodo() | 2740 | void CalendarView::newTodo() |
2741 | { | 2741 | { |
2742 | newTodoDateTime( QDateTime(),true ); | 2742 | newTodoDateTime( QDateTime(),true ); |
2743 | } | 2743 | } |
2744 | 2744 | ||
2745 | void CalendarView::newSubTodo() | 2745 | void CalendarView::newSubTodo() |
2746 | { | 2746 | { |
2747 | Todo *todo = selectedTodo(); | 2747 | Todo *todo = selectedTodo(); |
2748 | if ( todo ) newSubTodo( todo ); | 2748 | if ( todo ) newSubTodo( todo ); |
2749 | } | 2749 | } |
2750 | 2750 | ||
2751 | void CalendarView::newSubTodo(Todo *parentEvent) | 2751 | void CalendarView::newSubTodo(Todo *parentEvent) |
2752 | { | 2752 | { |
2753 | 2753 | ||
2754 | showTodoEditor(); | 2754 | showTodoEditor(); |
2755 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 2755 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
2756 | mTodoEditor->exec(); | 2756 | mTodoEditor->exec(); |
2757 | setActiveWindow(); | 2757 | setActiveWindow(); |
2758 | } | 2758 | } |
2759 | 2759 | ||
2760 | void CalendarView::newFloatingEvent() | 2760 | void CalendarView::newFloatingEvent() |
2761 | { | 2761 | { |
2762 | DateList tmpList = mNavigator->selectedDates(); | 2762 | DateList tmpList = mNavigator->selectedDates(); |
2763 | QDate date = tmpList.first(); | 2763 | QDate date = tmpList.first(); |
2764 | 2764 | ||
2765 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2765 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2766 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2766 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2767 | } | 2767 | } |
2768 | 2768 | ||
2769 | 2769 | ||
2770 | void CalendarView::editEvent( Event *event ) | 2770 | void CalendarView::editEvent( Event *event ) |
2771 | { | 2771 | { |
2772 | 2772 | ||
2773 | if ( !event ) return; | 2773 | if ( !event ) return; |
2774 | if ( event->isReadOnly() ) { | 2774 | if ( event->isReadOnly() ) { |
2775 | showEvent( event ); | 2775 | showEvent( event ); |
2776 | return; | 2776 | return; |
2777 | } | 2777 | } |
2778 | showEventEditor(); | 2778 | showEventEditor(); |
2779 | mEventEditor->editEvent( event , mFlagEditDescription); | 2779 | mEventEditor->editEvent( event , mFlagEditDescription); |
2780 | mEventEditor->exec(); | 2780 | mEventEditor->exec(); |
2781 | setActiveWindow(); | 2781 | setActiveWindow(); |
2782 | 2782 | ||
2783 | } | 2783 | } |
2784 | void CalendarView::editJournal( Journal *jour ) | 2784 | void CalendarView::editJournal( Journal *jour ) |
2785 | { | 2785 | { |
2786 | if ( !jour ) return; | 2786 | if ( !jour ) return; |
2787 | mDialogManager->hideSearchDialog(); | 2787 | mDialogManager->hideSearchDialog(); |
2788 | mViewManager->showJournalView(); | 2788 | mViewManager->showJournalView(); |
2789 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2789 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2790 | } | 2790 | } |
2791 | void CalendarView::editTodo( Todo *todo ) | 2791 | void CalendarView::editTodo( Todo *todo ) |
2792 | { | 2792 | { |
2793 | if ( !todo ) return; | 2793 | if ( !todo ) return; |
2794 | 2794 | ||
2795 | if ( todo->isReadOnly() ) { | 2795 | if ( todo->isReadOnly() ) { |
2796 | showTodo( todo ); | 2796 | showTodo( todo ); |
2797 | return; | 2797 | return; |
2798 | } | 2798 | } |
2799 | showTodoEditor(); | 2799 | showTodoEditor(); |
2800 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 2800 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
2801 | mTodoEditor->exec(); | 2801 | mTodoEditor->exec(); |
2802 | setActiveWindow(); | 2802 | setActiveWindow(); |
2803 | 2803 | ||
2804 | } | 2804 | } |
2805 | 2805 | ||
2806 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2806 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2807 | { | 2807 | { |
2808 | if ( !mEventViewerDialog ) { | 2808 | if ( !mEventViewerDialog ) { |
2809 | mEventViewerDialog = new KOEventViewerDialog(0); | 2809 | mEventViewerDialog = new KOEventViewerDialog(0); |
2810 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2810 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2811 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2811 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2812 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2812 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2813 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2813 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2814 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2814 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2815 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2815 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2816 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 2816 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
2817 | this, SLOT( slotViewerClosed() ) ); | 2817 | this, SLOT( slotViewerClosed() ) ); |
2818 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 2818 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
2819 | this, SLOT( todoChanged(Todo *) ) ); | 2819 | this, SLOT( todoChanged(Todo *) ) ); |
2820 | mEventViewerDialog->resize( 640, 480 ); | 2820 | mEventViewerDialog->resize( 640, 480 ); |
2821 | 2821 | ||
2822 | } | 2822 | } |
2823 | return mEventViewerDialog; | 2823 | return mEventViewerDialog; |
2824 | } | 2824 | } |
2825 | void CalendarView::showEvent(Event *event) | 2825 | void CalendarView::showEvent(Event *event) |
2826 | { | 2826 | { |
2827 | getEventViewerDialog()->setEvent(event); | 2827 | getEventViewerDialog()->setEvent(event); |
2828 | getEventViewerDialog()->showMe(); | 2828 | getEventViewerDialog()->showMe(); |
2829 | } | 2829 | } |
2830 | 2830 | ||
2831 | void CalendarView::showTodo(Todo *event) | 2831 | void CalendarView::showTodo(Todo *event) |
2832 | { | 2832 | { |
2833 | getEventViewerDialog()->setTodo(event); | 2833 | getEventViewerDialog()->setTodo(event); |
2834 | getEventViewerDialog()->showMe(); | 2834 | getEventViewerDialog()->showMe(); |
2835 | } | 2835 | } |
2836 | void CalendarView::showJournal( Journal *jour ) | 2836 | void CalendarView::showJournal( Journal *jour ) |
2837 | { | 2837 | { |
2838 | getEventViewerDialog()->setJournal(jour); | 2838 | getEventViewerDialog()->setJournal(jour); |
2839 | getEventViewerDialog()->showMe(); | 2839 | getEventViewerDialog()->showMe(); |
2840 | 2840 | ||
2841 | } | 2841 | } |
2842 | // void CalendarView::todoModified (Todo *event, int changed) | 2842 | // void CalendarView::todoModified (Todo *event, int changed) |
2843 | // { | 2843 | // { |
2844 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2844 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2845 | // // kdDebug() << "Todo modified and open" << endl; | 2845 | // // kdDebug() << "Todo modified and open" << endl; |
2846 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2846 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2847 | // // temp->modified (changed); | 2847 | // // temp->modified (changed); |
2848 | 2848 | ||
2849 | // // } | 2849 | // // } |
2850 | 2850 | ||
2851 | // mViewManager->updateView(); | 2851 | // mViewManager->updateView(); |
2852 | // } | 2852 | // } |
2853 | 2853 | ||
2854 | void CalendarView::appointment_show() | 2854 | void CalendarView::appointment_show() |
2855 | { | 2855 | { |
2856 | Event *anEvent = 0; | 2856 | Event *anEvent = 0; |
2857 | 2857 | ||
2858 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2858 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2859 | 2859 | ||
2860 | if (mViewManager->currentView()->isEventView()) { | 2860 | if (mViewManager->currentView()->isEventView()) { |
2861 | if ( incidence && incidence->type() == "Event" ) { | 2861 | if ( incidence && incidence->type() == "Event" ) { |
2862 | anEvent = static_cast<Event *>(incidence); | 2862 | anEvent = static_cast<Event *>(incidence); |
2863 | } | 2863 | } |
2864 | } | 2864 | } |
2865 | 2865 | ||
2866 | if (!anEvent) { | 2866 | if (!anEvent) { |
2867 | KNotifyClient::beep(); | 2867 | KNotifyClient::beep(); |
2868 | return; | 2868 | return; |
2869 | } | 2869 | } |
2870 | 2870 | ||
2871 | showEvent(anEvent); | 2871 | showEvent(anEvent); |
2872 | } | 2872 | } |
2873 | 2873 | ||
2874 | void CalendarView::appointment_edit() | 2874 | void CalendarView::appointment_edit() |
2875 | { | 2875 | { |
2876 | Event *anEvent = 0; | 2876 | Event *anEvent = 0; |
2877 | 2877 | ||
2878 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2878 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2879 | 2879 | ||
2880 | if (mViewManager->currentView()->isEventView()) { | 2880 | if (mViewManager->currentView()->isEventView()) { |
2881 | if ( incidence && incidence->type() == "Event" ) { | 2881 | if ( incidence && incidence->type() == "Event" ) { |
2882 | anEvent = static_cast<Event *>(incidence); | 2882 | anEvent = static_cast<Event *>(incidence); |
2883 | } | 2883 | } |
2884 | } | 2884 | } |
2885 | 2885 | ||
2886 | if (!anEvent) { | 2886 | if (!anEvent) { |
2887 | KNotifyClient::beep(); | 2887 | KNotifyClient::beep(); |
2888 | return; | 2888 | return; |
2889 | } | 2889 | } |
2890 | 2890 | ||
2891 | editEvent(anEvent); | 2891 | editEvent(anEvent); |
2892 | } | 2892 | } |
2893 | 2893 | ||
2894 | void CalendarView::appointment_delete() | 2894 | void CalendarView::appointment_delete() |
2895 | { | 2895 | { |
2896 | Event *anEvent = 0; | 2896 | Event *anEvent = 0; |
2897 | 2897 | ||
2898 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2898 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2899 | 2899 | ||
2900 | if (mViewManager->currentView()->isEventView()) { | 2900 | if (mViewManager->currentView()->isEventView()) { |
2901 | if ( incidence && incidence->type() == "Event" ) { | 2901 | if ( incidence && incidence->type() == "Event" ) { |
2902 | anEvent = static_cast<Event *>(incidence); | 2902 | anEvent = static_cast<Event *>(incidence); |
2903 | } | 2903 | } |
2904 | } | 2904 | } |
2905 | 2905 | ||
2906 | if (!anEvent) { | 2906 | if (!anEvent) { |
2907 | KNotifyClient::beep(); | 2907 | KNotifyClient::beep(); |
2908 | return; | 2908 | return; |
2909 | } | 2909 | } |
2910 | 2910 | ||
2911 | deleteEvent(anEvent); | 2911 | deleteEvent(anEvent); |
2912 | } | 2912 | } |
2913 | 2913 | ||
2914 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2914 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2915 | { | 2915 | { |
2916 | if (!sub) return; | 2916 | if (!sub) return; |
2917 | if (!parent) return; | 2917 | if (!parent) return; |
2918 | if ( sub->relatedTo() ) | 2918 | if ( sub->relatedTo() ) |
2919 | sub->relatedTo()->removeRelation(sub); | 2919 | sub->relatedTo()->removeRelation(sub); |
2920 | sub->setRelatedTo(parent); | 2920 | sub->setRelatedTo(parent); |
2921 | sub->setRelatedToUid(parent->uid()); | 2921 | sub->setRelatedToUid(parent->uid()); |
2922 | parent->addRelation(sub); | 2922 | parent->addRelation(sub); |
2923 | sub->updated(); | 2923 | sub->updated(); |
2924 | parent->updated(); | 2924 | parent->updated(); |
2925 | setModified(true); | 2925 | setModified(true); |
2926 | updateView(); | 2926 | updateView(); |
2927 | } | 2927 | } |
2928 | void CalendarView::todo_unsub(Todo *anTodo ) | 2928 | void CalendarView::todo_unsub(Todo *anTodo ) |
2929 | { | 2929 | { |
2930 | // Todo *anTodo = selectedTodo(); | 2930 | // Todo *anTodo = selectedTodo(); |
2931 | if (!anTodo) return; | 2931 | if (!anTodo) return; |
2932 | if (!anTodo->relatedTo()) return; | 2932 | if (!anTodo->relatedTo()) return; |
2933 | anTodo->relatedTo()->removeRelation(anTodo); | 2933 | anTodo->relatedTo()->removeRelation(anTodo); |
2934 | anTodo->setRelatedTo(0); | 2934 | anTodo->setRelatedTo(0); |
2935 | anTodo->updated(); | 2935 | anTodo->updated(); |
2936 | anTodo->setRelatedToUid(""); | 2936 | anTodo->setRelatedToUid(""); |
2937 | setModified(true); | 2937 | setModified(true); |
2938 | updateView(); | 2938 | updateView(); |
2939 | } | 2939 | } |
2940 | 2940 | ||
2941 | void CalendarView::deleteTodo(Todo *todo) | 2941 | void CalendarView::deleteTodo(Todo *todo) |
2942 | { | 2942 | { |
2943 | if (!todo) { | 2943 | if (!todo) { |
2944 | KNotifyClient::beep(); | 2944 | KNotifyClient::beep(); |
2945 | return; | 2945 | return; |
2946 | } | 2946 | } |
2947 | if (KOPrefs::instance()->mConfirm) { | 2947 | if (KOPrefs::instance()->mConfirm) { |
2948 | QString text = todo->summary().left(20); | 2948 | QString text = todo->summary().left(20); |
2949 | if (!todo->relations().isEmpty()) { | 2949 | if (!todo->relations().isEmpty()) { |
2950 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 2950 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
2951 | 2951 | ||
2952 | } | 2952 | } |
2953 | switch (msgItemDelete(text)) { | 2953 | switch (msgItemDelete(text)) { |
2954 | case KMessageBox::Continue: // OK | 2954 | case KMessageBox::Continue: // OK |
2955 | bool deleteT = false; | 2955 | bool deleteT = false; |
2956 | if (!todo->relations().isEmpty()) { | 2956 | if (!todo->relations().isEmpty()) { |
2957 | deleteT = removeCompletedSubTodos( todo ); | 2957 | deleteT = removeCompletedSubTodos( todo ); |
2958 | } | 2958 | } |
2959 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 2959 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
2960 | if ( !deleteT ) { | 2960 | if ( !deleteT ) { |
2961 | checkExternalId( todo ); | 2961 | checkExternalId( todo ); |
2962 | calendar()->deleteTodo(todo); | 2962 | calendar()->deleteTodo(todo); |
2963 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2963 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2964 | updateView(); | 2964 | updateView(); |
2965 | } | 2965 | } |
2966 | break; | 2966 | break; |
2967 | } // switch | 2967 | } // switch |
2968 | } else { | 2968 | } else { |
2969 | checkExternalId( todo ); | 2969 | checkExternalId( todo ); |
2970 | mCalendar->deleteTodo(todo); | 2970 | mCalendar->deleteTodo(todo); |
2971 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2971 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2972 | updateView(); | 2972 | updateView(); |
2973 | } | 2973 | } |
2974 | 2974 | ||
2975 | emit updateSearchDialog(); | 2975 | emit updateSearchDialog(); |
2976 | } | 2976 | } |
2977 | void CalendarView::deleteJournal(Journal *jour) | 2977 | void CalendarView::deleteJournal(Journal *jour) |
2978 | { | 2978 | { |
2979 | if (!jour) { | 2979 | if (!jour) { |
2980 | KNotifyClient::beep(); | 2980 | KNotifyClient::beep(); |
2981 | return; | 2981 | return; |
2982 | } | 2982 | } |
2983 | if (KOPrefs::instance()->mConfirm) { | 2983 | if (KOPrefs::instance()->mConfirm) { |
2984 | switch (msgItemDelete( jour->description().left(20))) { | 2984 | switch (msgItemDelete( jour->description().left(20))) { |
2985 | case KMessageBox::Continue: // OK | 2985 | case KMessageBox::Continue: // OK |
2986 | calendar()->deleteJournal(jour); | 2986 | calendar()->deleteJournal(jour); |
2987 | updateView(); | 2987 | updateView(); |
2988 | break; | 2988 | break; |
2989 | } // switch | 2989 | } // switch |
2990 | } else { | 2990 | } else { |
2991 | calendar()->deleteJournal(jour);; | 2991 | calendar()->deleteJournal(jour);; |
2992 | updateView(); | 2992 | updateView(); |
2993 | } | 2993 | } |
2994 | emit updateSearchDialog(); | 2994 | emit updateSearchDialog(); |
2995 | } | 2995 | } |
2996 | 2996 | ||
2997 | void CalendarView::deleteEvent(Event *anEvent) | 2997 | void CalendarView::deleteEvent(Event *anEvent) |
2998 | { | 2998 | { |
2999 | if (!anEvent) { | 2999 | if (!anEvent) { |
3000 | KNotifyClient::beep(); | 3000 | KNotifyClient::beep(); |
3001 | return; | 3001 | return; |
3002 | } | 3002 | } |
3003 | 3003 | ||
3004 | if (anEvent->recurrence()->doesRecur()) { | 3004 | if (anEvent->recurrence()->doesRecur()) { |
3005 | QDate itemDate = mViewManager->currentSelectionDate(); | 3005 | QDate itemDate = mViewManager->currentSelectionDate(); |
3006 | int km; | 3006 | int km; |
3007 | if (!itemDate.isValid()) { | 3007 | if (!itemDate.isValid()) { |
3008 | //kdDebug() << "Date Not Valid" << endl; | 3008 | //kdDebug() << "Date Not Valid" << endl; |
3009 | if (KOPrefs::instance()->mConfirm) { | 3009 | if (KOPrefs::instance()->mConfirm) { |
3010 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3010 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3011 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3011 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3012 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3012 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3013 | if ( km == KMessageBox::Continue ) | 3013 | if ( km == KMessageBox::Continue ) |
3014 | km = KMessageBox::No; // No = all below | 3014 | km = KMessageBox::No; // No = all below |
3015 | } else | 3015 | } else |
3016 | km = KMessageBox::No; | 3016 | km = KMessageBox::No; |
3017 | } else { | 3017 | } else { |
3018 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 3018 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
3019 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3019 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
3020 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 3020 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
3021 | i18n("KO/Pi Confirmation"),i18n("Current"), | 3021 | i18n("KO/Pi Confirmation"),i18n("Current"), |
3022 | i18n("All")); | 3022 | i18n("All")); |
3023 | } | 3023 | } |
3024 | switch(km) { | 3024 | switch(km) { |
3025 | 3025 | ||
3026 | case KMessageBox::No: // Continue // all | 3026 | case KMessageBox::No: // Continue // all |
3027 | //qDebug("KMessageBox::No "); | 3027 | //qDebug("KMessageBox::No "); |
3028 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3028 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3029 | schedule(Scheduler::Cancel,anEvent); | 3029 | schedule(Scheduler::Cancel,anEvent); |
3030 | 3030 | ||
3031 | checkExternalId( anEvent); | 3031 | checkExternalId( anEvent); |
3032 | mCalendar->deleteEvent(anEvent); | 3032 | mCalendar->deleteEvent(anEvent); |
3033 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 3033 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
3034 | break; | 3034 | break; |
3035 | 3035 | ||
3036 | // Disabled because it does not work | 3036 | // Disabled because it does not work |
3037 | //#if 0 | 3037 | //#if 0 |
3038 | case KMessageBox::Yes: // just this one | 3038 | case KMessageBox::Yes: // just this one |
3039 | //QDate qd = mNavigator->selectedDates().first(); | 3039 | //QDate qd = mNavigator->selectedDates().first(); |
3040 | //if (!qd.isValid()) { | 3040 | //if (!qd.isValid()) { |
3041 | // kdDebug() << "no date selected, or invalid date" << endl; | 3041 | // kdDebug() << "no date selected, or invalid date" << endl; |
3042 | // KNotifyClient::beep(); | 3042 | // KNotifyClient::beep(); |
3043 | // return; | 3043 | // return; |
3044 | //} | 3044 | //} |
3045 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 3045 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
3046 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 3046 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
3047 | anEvent->addExDate(itemDate); | 3047 | anEvent->addExDate(itemDate); |
3048 | int duration = anEvent->recurrence()->duration(); | 3048 | int duration = anEvent->recurrence()->duration(); |
3049 | if ( duration > 0 ) { | 3049 | if ( duration > 0 ) { |
3050 | anEvent->recurrence()->setDuration( duration - 1 ); | 3050 | anEvent->recurrence()->setDuration( duration - 1 ); |
3051 | } | 3051 | } |
3052 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 3052 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
3053 | } | 3053 | } |
3054 | break; | 3054 | break; |
3055 | //#endif | 3055 | //#endif |
3056 | } // switch | 3056 | } // switch |
3057 | } else { | 3057 | } else { |
3058 | if (KOPrefs::instance()->mConfirm) { | 3058 | if (KOPrefs::instance()->mConfirm) { |
3059 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 3059 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
3060 | i18n("\nAre you sure you want\nto delete this event?"), | 3060 | i18n("\nAre you sure you want\nto delete this event?"), |
3061 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 3061 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
3062 | case KMessageBox::Continue: // OK | 3062 | case KMessageBox::Continue: // OK |
3063 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3063 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3064 | schedule(Scheduler::Cancel,anEvent); | 3064 | schedule(Scheduler::Cancel,anEvent); |
3065 | checkExternalId( anEvent); | 3065 | checkExternalId( anEvent); |
3066 | mCalendar->deleteEvent(anEvent); | 3066 | mCalendar->deleteEvent(anEvent); |
3067 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3067 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3068 | break; | 3068 | break; |
3069 | } // switch | 3069 | } // switch |
3070 | } else { | 3070 | } else { |
3071 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 3071 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
3072 | schedule(Scheduler::Cancel,anEvent); | 3072 | schedule(Scheduler::Cancel,anEvent); |
3073 | checkExternalId( anEvent); | 3073 | checkExternalId( anEvent); |
3074 | mCalendar->deleteEvent(anEvent); | 3074 | mCalendar->deleteEvent(anEvent); |
3075 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); | 3075 | changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); |
3076 | } | 3076 | } |
3077 | } // if-else | 3077 | } // if-else |
3078 | emit updateSearchDialog(); | 3078 | emit updateSearchDialog(); |
3079 | } | 3079 | } |
3080 | 3080 | ||
3081 | bool CalendarView::deleteEvent(const QString &uid) | 3081 | bool CalendarView::deleteEvent(const QString &uid) |
3082 | { | 3082 | { |
3083 | Event *ev = mCalendar->event(uid); | 3083 | Event *ev = mCalendar->event(uid); |
3084 | if (ev) { | 3084 | if (ev) { |
3085 | deleteEvent(ev); | 3085 | deleteEvent(ev); |
3086 | return true; | 3086 | return true; |
3087 | } else { | 3087 | } else { |
3088 | return false; | 3088 | return false; |
3089 | } | 3089 | } |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | /*****************************************************************************/ | 3092 | /*****************************************************************************/ |
3093 | 3093 | ||
3094 | void CalendarView::action_mail() | 3094 | void CalendarView::action_mail() |
3095 | { | 3095 | { |
3096 | #ifndef KORG_NOMAIL | 3096 | #ifndef KORG_NOMAIL |
3097 | KOMailClient mailClient; | 3097 | KOMailClient mailClient; |
3098 | 3098 | ||
3099 | Incidence *incidence = currentSelection(); | 3099 | Incidence *incidence = currentSelection(); |
3100 | 3100 | ||
3101 | if (!incidence) { | 3101 | if (!incidence) { |
3102 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3102 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3103 | return; | 3103 | return; |
3104 | } | 3104 | } |
3105 | if(incidence->attendeeCount() == 0 ) { | 3105 | if(incidence->attendeeCount() == 0 ) { |
3106 | KMessageBox::sorry(this, | 3106 | KMessageBox::sorry(this, |
3107 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3107 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3108 | return; | 3108 | return; |
3109 | } | 3109 | } |
3110 | 3110 | ||
3111 | CalendarLocal cal_tmp; | 3111 | CalendarLocal cal_tmp; |
3112 | Event *event = 0; | 3112 | Event *event = 0; |
3113 | Event *ev = 0; | 3113 | Event *ev = 0; |
3114 | if ( incidence && incidence->type() == "Event" ) { | 3114 | if ( incidence && incidence->type() == "Event" ) { |
3115 | event = static_cast<Event *>(incidence); | 3115 | event = static_cast<Event *>(incidence); |
3116 | ev = new Event(*event); | 3116 | ev = new Event(*event); |
3117 | cal_tmp.addEvent(ev); | 3117 | cal_tmp.addEvent(ev); |
3118 | } | 3118 | } |
3119 | ICalFormat mForm(); | 3119 | ICalFormat mForm(); |
3120 | QString attachment = mForm.toString( &cal_tmp ); | 3120 | QString attachment = mForm.toString( &cal_tmp ); |
3121 | if (ev) delete(ev); | 3121 | if (ev) delete(ev); |
3122 | 3122 | ||
3123 | mailClient.mailAttendees(currentSelection(), attachment); | 3123 | mailClient.mailAttendees(currentSelection(), attachment); |
3124 | 3124 | ||
3125 | #endif | 3125 | #endif |
3126 | 3126 | ||
3127 | #if 0 | 3127 | #if 0 |
3128 | Event *anEvent = 0; | 3128 | Event *anEvent = 0; |
3129 | if (mViewManager->currentView()->isEventView()) { | 3129 | if (mViewManager->currentView()->isEventView()) { |
3130 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3130 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3131 | } | 3131 | } |
3132 | 3132 | ||
3133 | if (!anEvent) { | 3133 | if (!anEvent) { |
3134 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3134 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3135 | return; | 3135 | return; |
3136 | } | 3136 | } |
3137 | if(anEvent->attendeeCount() == 0 ) { | 3137 | if(anEvent->attendeeCount() == 0 ) { |
3138 | KMessageBox::sorry(this, | 3138 | KMessageBox::sorry(this, |
3139 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3139 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3140 | return; | 3140 | return; |
3141 | } | 3141 | } |
3142 | 3142 | ||
3143 | mailobject.emailEvent(anEvent); | 3143 | mailobject.emailEvent(anEvent); |
3144 | #endif | 3144 | #endif |
3145 | } | 3145 | } |
3146 | 3146 | ||
3147 | 3147 | ||
3148 | void CalendarView::schedule_publish(Incidence *incidence) | 3148 | void CalendarView::schedule_publish(Incidence *incidence) |
3149 | { | 3149 | { |
3150 | Event *event = 0; | 3150 | Event *event = 0; |
3151 | Todo *todo = 0; | 3151 | Todo *todo = 0; |
3152 | 3152 | ||
3153 | if (incidence == 0) { | 3153 | if (incidence == 0) { |
3154 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3154 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3155 | if (incidence == 0) { | 3155 | if (incidence == 0) { |
3156 | incidence = mTodoList->selectedIncidences().first(); | 3156 | incidence = mTodoList->selectedIncidences().first(); |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | if ( incidence && incidence->type() == "Event" ) { | 3159 | if ( incidence && incidence->type() == "Event" ) { |
3160 | event = static_cast<Event *>(incidence); | 3160 | event = static_cast<Event *>(incidence); |
3161 | } else { | 3161 | } else { |
3162 | if ( incidence && incidence->type() == "Todo" ) { | 3162 | if ( incidence && incidence->type() == "Todo" ) { |
3163 | todo = static_cast<Todo *>(incidence); | 3163 | todo = static_cast<Todo *>(incidence); |
3164 | } | 3164 | } |
3165 | } | 3165 | } |
3166 | 3166 | ||
3167 | if (!event && !todo) { | 3167 | if (!event && !todo) { |
3168 | KMessageBox::sorry(this,i18n("No event selected.")); | 3168 | KMessageBox::sorry(this,i18n("No event selected.")); |
3169 | return; | 3169 | return; |
3170 | } | 3170 | } |
3171 | 3171 | ||
3172 | PublishDialog *publishdlg = new PublishDialog(); | 3172 | PublishDialog *publishdlg = new PublishDialog(); |
3173 | if (incidence->attendeeCount()>0) { | 3173 | if (incidence->attendeeCount()>0) { |
3174 | QPtrList<Attendee> attendees = incidence->attendees(); | 3174 | QPtrList<Attendee> attendees = incidence->attendees(); |
3175 | attendees.first(); | 3175 | attendees.first(); |
3176 | while ( attendees.current()!=0 ) { | 3176 | while ( attendees.current()!=0 ) { |
3177 | publishdlg->addAttendee(attendees.current()); | 3177 | publishdlg->addAttendee(attendees.current()); |
3178 | attendees.next(); | 3178 | attendees.next(); |
3179 | } | 3179 | } |
3180 | } | 3180 | } |
3181 | bool send = true; | 3181 | bool send = true; |
3182 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3182 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3183 | if ( publishdlg->exec() != QDialog::Accepted ) | 3183 | if ( publishdlg->exec() != QDialog::Accepted ) |
3184 | send = false; | 3184 | send = false; |
3185 | } | 3185 | } |
3186 | if ( send ) { | 3186 | if ( send ) { |
3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3188 | if ( event ) { | 3188 | if ( event ) { |
3189 | Event *ev = new Event(*event); | 3189 | Event *ev = new Event(*event); |
3190 | ev->registerObserver(0); | 3190 | ev->registerObserver(0); |
3191 | ev->clearAttendees(); | 3191 | ev->clearAttendees(); |
3192 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3192 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3193 | delete(ev); | 3193 | delete(ev); |
3194 | } | 3194 | } |
3195 | } else { | 3195 | } else { |
3196 | if ( todo ) { | 3196 | if ( todo ) { |
3197 | Todo *ev = new Todo(*todo); | 3197 | Todo *ev = new Todo(*todo); |
3198 | ev->registerObserver(0); | 3198 | ev->registerObserver(0); |
3199 | ev->clearAttendees(); | 3199 | ev->clearAttendees(); |
3200 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3200 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3201 | delete(ev); | 3201 | delete(ev); |
3202 | } | 3202 | } |
3203 | } | 3203 | } |
3204 | } | 3204 | } |
3205 | } | 3205 | } |
3206 | delete publishdlg; | 3206 | delete publishdlg; |
3207 | } | 3207 | } |
3208 | 3208 | ||
3209 | void CalendarView::schedule_request(Incidence *incidence) | 3209 | void CalendarView::schedule_request(Incidence *incidence) |
3210 | { | 3210 | { |
3211 | schedule(Scheduler::Request,incidence); | 3211 | schedule(Scheduler::Request,incidence); |
3212 | } | 3212 | } |
3213 | 3213 | ||
3214 | void CalendarView::schedule_refresh(Incidence *incidence) | 3214 | void CalendarView::schedule_refresh(Incidence *incidence) |
3215 | { | 3215 | { |
3216 | schedule(Scheduler::Refresh,incidence); | 3216 | schedule(Scheduler::Refresh,incidence); |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | void CalendarView::schedule_cancel(Incidence *incidence) | 3219 | void CalendarView::schedule_cancel(Incidence *incidence) |
3220 | { | 3220 | { |
3221 | schedule(Scheduler::Cancel,incidence); | 3221 | schedule(Scheduler::Cancel,incidence); |
3222 | } | 3222 | } |
3223 | 3223 | ||
3224 | void CalendarView::schedule_add(Incidence *incidence) | 3224 | void CalendarView::schedule_add(Incidence *incidence) |
3225 | { | 3225 | { |
3226 | schedule(Scheduler::Add,incidence); | 3226 | schedule(Scheduler::Add,incidence); |
3227 | } | 3227 | } |
3228 | 3228 | ||
3229 | void CalendarView::schedule_reply(Incidence *incidence) | 3229 | void CalendarView::schedule_reply(Incidence *incidence) |
3230 | { | 3230 | { |
3231 | schedule(Scheduler::Reply,incidence); | 3231 | schedule(Scheduler::Reply,incidence); |
3232 | } | 3232 | } |
3233 | 3233 | ||
3234 | void CalendarView::schedule_counter(Incidence *incidence) | 3234 | void CalendarView::schedule_counter(Incidence *incidence) |
3235 | { | 3235 | { |
3236 | schedule(Scheduler::Counter,incidence); | 3236 | schedule(Scheduler::Counter,incidence); |
3237 | } | 3237 | } |
3238 | 3238 | ||
3239 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3239 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3240 | { | 3240 | { |
3241 | schedule(Scheduler::Declinecounter,incidence); | 3241 | schedule(Scheduler::Declinecounter,incidence); |
3242 | } | 3242 | } |
3243 | 3243 | ||
3244 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3244 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3245 | { | 3245 | { |
3246 | QDateTime start = QDateTime::currentDateTime(); | 3246 | QDateTime start = QDateTime::currentDateTime(); |
3247 | QDateTime end = start.addDays(daysToPublish); | 3247 | QDateTime end = start.addDays(daysToPublish); |
3248 | 3248 | ||
3249 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3249 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3250 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3250 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3251 | 3251 | ||
3252 | 3252 | ||
3253 | PublishDialog *publishdlg = new PublishDialog(); | 3253 | PublishDialog *publishdlg = new PublishDialog(); |
3254 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3254 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3256 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3256 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3257 | delete(freebusy); | 3257 | delete(freebusy); |
3258 | } | 3258 | } |
3259 | } | 3259 | } |
3260 | delete publishdlg; | 3260 | delete publishdlg; |
3261 | } | 3261 | } |
3262 | 3262 | ||
3263 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3263 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3264 | { | 3264 | { |
3265 | Event *event = 0; | 3265 | Event *event = 0; |
3266 | Todo *todo = 0; | 3266 | Todo *todo = 0; |
3267 | 3267 | ||
3268 | if (incidence == 0) { | 3268 | if (incidence == 0) { |
3269 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3269 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3270 | if (incidence == 0) { | 3270 | if (incidence == 0) { |
3271 | incidence = mTodoList->selectedIncidences().first(); | 3271 | incidence = mTodoList->selectedIncidences().first(); |
3272 | } | 3272 | } |
3273 | } | 3273 | } |
3274 | if ( incidence && incidence->type() == "Event" ) { | 3274 | if ( incidence && incidence->type() == "Event" ) { |
3275 | event = static_cast<Event *>(incidence); | 3275 | event = static_cast<Event *>(incidence); |
3276 | } | 3276 | } |
3277 | if ( incidence && incidence->type() == "Todo" ) { | 3277 | if ( incidence && incidence->type() == "Todo" ) { |
3278 | todo = static_cast<Todo *>(incidence); | 3278 | todo = static_cast<Todo *>(incidence); |
3279 | } | 3279 | } |
3280 | 3280 | ||
3281 | if (!event && !todo) { | 3281 | if (!event && !todo) { |
3282 | KMessageBox::sorry(this,i18n("No event selected.")); | 3282 | KMessageBox::sorry(this,i18n("No event selected.")); |
3283 | return; | 3283 | return; |
3284 | } | 3284 | } |
3285 | 3285 | ||
3286 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3286 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3287 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3287 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3288 | return; | 3288 | return; |
3289 | } | 3289 | } |
3290 | 3290 | ||
3291 | Event *ev = 0; | 3291 | Event *ev = 0; |
3292 | if (event) ev = new Event(*event); | 3292 | if (event) ev = new Event(*event); |
3293 | Todo *to = 0; | 3293 | Todo *to = 0; |
3294 | if (todo) to = new Todo(*todo); | 3294 | if (todo) to = new Todo(*todo); |
3295 | 3295 | ||
3296 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3296 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3297 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3297 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3298 | if (!me) { | 3298 | if (!me) { |
3299 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3299 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3300 | return; | 3300 | return; |
3301 | } | 3301 | } |
3302 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3302 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3303 | StatusDialog *statdlg = new StatusDialog(this); | 3303 | StatusDialog *statdlg = new StatusDialog(this); |
3304 | if (!statdlg->exec()==QDialog::Accepted) return; | 3304 | if (!statdlg->exec()==QDialog::Accepted) return; |
3305 | me->setStatus( statdlg->status() ); | 3305 | me->setStatus( statdlg->status() ); |
3306 | delete(statdlg); | 3306 | delete(statdlg); |
3307 | } | 3307 | } |
3308 | Attendee *menew = new Attendee(*me); | 3308 | Attendee *menew = new Attendee(*me); |
3309 | if (ev) { | 3309 | if (ev) { |
3310 | ev->clearAttendees(); | 3310 | ev->clearAttendees(); |
3311 | ev->addAttendee(menew,false); | 3311 | ev->addAttendee(menew,false); |
3312 | } else { | 3312 | } else { |
3313 | if (to) { | 3313 | if (to) { |
3314 | todo->clearAttendees(); | 3314 | todo->clearAttendees(); |
3315 | todo->addAttendee(menew,false); | 3315 | todo->addAttendee(menew,false); |
3316 | } | 3316 | } |
3317 | } | 3317 | } |
3318 | } | 3318 | } |
3319 | 3319 | ||
3320 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3320 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3321 | if (ev) { | 3321 | if (ev) { |
3322 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3322 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3323 | } else { | 3323 | } else { |
3324 | if (to) { | 3324 | if (to) { |
3325 | if ( !dlg->addMessage(to,method) ) delete(to); | 3325 | if ( !dlg->addMessage(to,method) ) delete(to); |
3326 | } | 3326 | } |
3327 | } | 3327 | } |
3328 | } | 3328 | } |
3329 | 3329 | ||
3330 | void CalendarView::openAddressbook() | 3330 | void CalendarView::openAddressbook() |
3331 | { | 3331 | { |
3332 | KRun::runCommand("kaddressbook"); | 3332 | KRun::runCommand("kaddressbook"); |
3333 | } | 3333 | } |
3334 | 3334 | ||
3335 | void CalendarView::setModified(bool modified) | 3335 | void CalendarView::setModified(bool modified) |
3336 | { | 3336 | { |
3337 | if ( modified ) | 3337 | if ( modified ) |
3338 | emit signalmodified(); | 3338 | emit signalmodified(); |
3339 | if (mModified != modified) { | 3339 | if (mModified != modified) { |
3340 | mModified = modified; | 3340 | mModified = modified; |
3341 | emit modifiedChanged(mModified); | 3341 | emit modifiedChanged(mModified); |
3342 | } | 3342 | } |
3343 | } | 3343 | } |
3344 | 3344 | ||
3345 | bool CalendarView::isReadOnly() | 3345 | bool CalendarView::isReadOnly() |
3346 | { | 3346 | { |
3347 | return mReadOnly; | 3347 | return mReadOnly; |
3348 | } | 3348 | } |
3349 | 3349 | ||
3350 | void CalendarView::setReadOnly(bool readOnly) | 3350 | void CalendarView::setReadOnly(bool readOnly) |
3351 | { | 3351 | { |
3352 | if (mReadOnly != readOnly) { | 3352 | if (mReadOnly != readOnly) { |
3353 | mReadOnly = readOnly; | 3353 | mReadOnly = readOnly; |
3354 | emit readOnlyChanged(mReadOnly); | 3354 | emit readOnlyChanged(mReadOnly); |
3355 | } | 3355 | } |
3356 | } | 3356 | } |
3357 | 3357 | ||
3358 | bool CalendarView::isModified() | 3358 | bool CalendarView::isModified() |
3359 | { | 3359 | { |
3360 | return mModified; | 3360 | return mModified; |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | void CalendarView::printSetup() | 3363 | void CalendarView::printSetup() |
3364 | { | 3364 | { |
3365 | #ifndef KORG_NOPRINTER | 3365 | #ifndef KORG_NOPRINTER |
3366 | createPrinter(); | 3366 | createPrinter(); |
3367 | 3367 | ||
3368 | mCalPrinter->setupPrinter(); | 3368 | mCalPrinter->setupPrinter(); |
3369 | #endif | 3369 | #endif |
3370 | } | 3370 | } |
3371 | 3371 | ||
3372 | void CalendarView::print() | 3372 | void CalendarView::print() |
3373 | { | 3373 | { |
3374 | #ifndef KORG_NOPRINTER | 3374 | #ifndef KORG_NOPRINTER |
3375 | createPrinter(); | 3375 | createPrinter(); |
3376 | 3376 | ||
3377 | DateList tmpDateList = mNavigator->selectedDates(); | 3377 | DateList tmpDateList = mNavigator->selectedDates(); |
3378 | mCalPrinter->print(CalPrinter::Month, | 3378 | mCalPrinter->print(CalPrinter::Month, |
3379 | tmpDateList.first(), tmpDateList.last()); | 3379 | tmpDateList.first(), tmpDateList.last()); |
3380 | #endif | 3380 | #endif |
3381 | } | 3381 | } |
3382 | 3382 | ||
3383 | void CalendarView::printPreview() | 3383 | void CalendarView::printPreview() |
3384 | { | 3384 | { |
3385 | #ifndef KORG_NOPRINTER | 3385 | #ifndef KORG_NOPRINTER |
3386 | kdDebug() << "CalendarView::printPreview()" << endl; | 3386 | kdDebug() << "CalendarView::printPreview()" << endl; |
3387 | 3387 | ||
3388 | createPrinter(); | 3388 | createPrinter(); |
3389 | 3389 | ||
3390 | DateList tmpDateList = mNavigator->selectedDates(); | 3390 | DateList tmpDateList = mNavigator->selectedDates(); |
3391 | 3391 | ||
3392 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3392 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3393 | tmpDateList.last()); | 3393 | tmpDateList.last()); |
3394 | #endif | 3394 | #endif |
3395 | } | 3395 | } |
3396 | 3396 | ||
3397 | void CalendarView::exportICalendar() | 3397 | void CalendarView::exportICalendar() |
3398 | { | 3398 | { |
3399 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3399 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3400 | 3400 | ||
3401 | // Force correct extension | 3401 | // Force correct extension |
3402 | if (filename.right(4) != ".ics") filename += ".ics"; | 3402 | if (filename.right(4) != ".ics") filename += ".ics"; |
3403 | 3403 | ||
3404 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3404 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3405 | storage.save(); | 3405 | storage.save(); |
3406 | } | 3406 | } |
3407 | 3407 | ||
3408 | bool CalendarView::exportVCalendar( QString filename ) | 3408 | bool CalendarView::exportVCalendar( QString filename ) |
3409 | { | 3409 | { |
3410 | if (mCalendar->journals().count() > 0) { | 3410 | if (mCalendar->journals().count() > 0) { |
3411 | int result = KMessageBox::warningContinueCancel(this, | 3411 | int result = KMessageBox::warningContinueCancel(this, |
3412 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3412 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3413 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3413 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3414 | true); | 3414 | true); |
3415 | if (result != KMessageBox::Continue) return false; | 3415 | if (result != KMessageBox::Continue) return false; |
3416 | } | 3416 | } |
3417 | 3417 | ||
3418 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3418 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3419 | 3419 | ||
3420 | // Force correct extension | 3420 | // Force correct extension |
3421 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3421 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3422 | 3422 | ||
3423 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3423 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3424 | return storage.save(); | 3424 | return storage.save(); |
3425 | 3425 | ||
3426 | } | 3426 | } |
3427 | 3427 | ||
3428 | void CalendarView::eventUpdated(Incidence *) | 3428 | void CalendarView::eventUpdated(Incidence *) |
3429 | { | 3429 | { |
3430 | setModified(); | 3430 | setModified(); |
3431 | // Don't call updateView here. The code, which has caused the update of the | 3431 | // Don't call updateView here. The code, which has caused the update of the |
3432 | // event is responsible for updating the view. | 3432 | // event is responsible for updating the view. |
3433 | // updateView(); | 3433 | // updateView(); |
3434 | } | 3434 | } |
3435 | 3435 | ||
3436 | void CalendarView::adaptNavigationUnits() | 3436 | void CalendarView::adaptNavigationUnits() |
3437 | { | 3437 | { |
3438 | if (mViewManager->currentView()->isEventView()) { | 3438 | if (mViewManager->currentView()->isEventView()) { |
3439 | int days = mViewManager->currentView()->currentDateCount(); | 3439 | int days = mViewManager->currentView()->currentDateCount(); |
3440 | if (days == 1) { | 3440 | if (days == 1) { |
3441 | emit changeNavStringPrev(i18n("&Previous Day")); | 3441 | emit changeNavStringPrev(i18n("&Previous Day")); |
3442 | emit changeNavStringNext(i18n("&Next Day")); | 3442 | emit changeNavStringNext(i18n("&Next Day")); |
3443 | } else { | 3443 | } else { |
3444 | emit changeNavStringPrev(i18n("&Previous Week")); | 3444 | emit changeNavStringPrev(i18n("&Previous Week")); |
3445 | emit changeNavStringNext(i18n("&Next Week")); | 3445 | emit changeNavStringNext(i18n("&Next Week")); |
3446 | } | 3446 | } |
3447 | } | 3447 | } |
3448 | } | 3448 | } |
3449 | 3449 | ||
3450 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3450 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3451 | { | 3451 | { |
3452 | if ( incidence ) mTodoList->clearSelection(); | 3452 | if ( incidence ) mTodoList->clearSelection(); |
3453 | processIncidenceSelection( incidence ); | 3453 | processIncidenceSelection( incidence ); |
3454 | } | 3454 | } |
3455 | 3455 | ||
3456 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3456 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3457 | { | 3457 | { |
3458 | if ( incidence && mViewManager->currentView() ) { | 3458 | if ( incidence && mViewManager->currentView() ) { |
3459 | mViewManager->currentView()->clearSelection(); | 3459 | mViewManager->currentView()->clearSelection(); |
3460 | } | 3460 | } |
3461 | processIncidenceSelection( incidence ); | 3461 | processIncidenceSelection( incidence ); |
3462 | } | 3462 | } |
3463 | 3463 | ||
3464 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3464 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3465 | { | 3465 | { |
3466 | if ( incidence == mSelectedIncidence ) return; | 3466 | if ( incidence == mSelectedIncidence ) return; |
3467 | 3467 | ||
3468 | mSelectedIncidence = incidence; | 3468 | mSelectedIncidence = incidence; |
3469 | 3469 | ||
3470 | emit incidenceSelected( mSelectedIncidence ); | 3470 | emit incidenceSelected( mSelectedIncidence ); |
3471 | 3471 | ||
3472 | if ( incidence && incidence->type() == "Event" ) { | 3472 | if ( incidence && incidence->type() == "Event" ) { |
3473 | Event *event = static_cast<Event *>( incidence ); | 3473 | Event *event = static_cast<Event *>( incidence ); |
3474 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3474 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3475 | emit organizerEventsSelected( true ); | 3475 | emit organizerEventsSelected( true ); |
3476 | } else { | 3476 | } else { |
3477 | emit organizerEventsSelected(false); | 3477 | emit organizerEventsSelected(false); |
3478 | } | 3478 | } |
3479 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3479 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3480 | KOPrefs::instance()->email() ) ) { | 3480 | KOPrefs::instance()->email() ) ) { |
3481 | emit groupEventsSelected( true ); | 3481 | emit groupEventsSelected( true ); |
3482 | } else { | 3482 | } else { |
3483 | emit groupEventsSelected(false); | 3483 | emit groupEventsSelected(false); |
3484 | } | 3484 | } |
3485 | return; | 3485 | return; |
3486 | } else { | 3486 | } else { |
3487 | if ( incidence && incidence->type() == "Todo" ) { | 3487 | if ( incidence && incidence->type() == "Todo" ) { |
3488 | emit todoSelected( true ); | 3488 | emit todoSelected( true ); |
3489 | Todo *event = static_cast<Todo *>( incidence ); | 3489 | Todo *event = static_cast<Todo *>( incidence ); |
3490 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3490 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3491 | emit organizerEventsSelected( true ); | 3491 | emit organizerEventsSelected( true ); |
3492 | } else { | 3492 | } else { |
3493 | emit organizerEventsSelected(false); | 3493 | emit organizerEventsSelected(false); |
3494 | } | 3494 | } |
3495 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3495 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3496 | KOPrefs::instance()->email() ) ) { | 3496 | KOPrefs::instance()->email() ) ) { |
3497 | emit groupEventsSelected( true ); | 3497 | emit groupEventsSelected( true ); |
3498 | } else { | 3498 | } else { |
3499 | emit groupEventsSelected(false); | 3499 | emit groupEventsSelected(false); |
3500 | } | 3500 | } |
3501 | return; | 3501 | return; |
3502 | } else { | 3502 | } else { |
3503 | emit todoSelected( false ); | 3503 | emit todoSelected( false ); |
3504 | emit organizerEventsSelected(false); | 3504 | emit organizerEventsSelected(false); |
3505 | emit groupEventsSelected(false); | 3505 | emit groupEventsSelected(false); |
3506 | } | 3506 | } |
3507 | return; | 3507 | return; |
3508 | } | 3508 | } |
3509 | 3509 | ||
3510 | /* if ( incidence && incidence->type() == "Todo" ) { | 3510 | /* if ( incidence && incidence->type() == "Todo" ) { |
3511 | emit todoSelected( true ); | 3511 | emit todoSelected( true ); |
3512 | } else { | 3512 | } else { |
3513 | emit todoSelected( false ); | 3513 | emit todoSelected( false ); |
3514 | }*/ | 3514 | }*/ |
3515 | } | 3515 | } |
3516 | 3516 | ||
3517 | 3517 | ||
3518 | void CalendarView::checkClipboard() | 3518 | void CalendarView::checkClipboard() |
3519 | { | 3519 | { |
3520 | #ifndef KORG_NODND | 3520 | #ifndef KORG_NODND |
3521 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3521 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3522 | emit pasteEnabled(true); | 3522 | emit pasteEnabled(true); |
3523 | } else { | 3523 | } else { |
3524 | emit pasteEnabled(false); | 3524 | emit pasteEnabled(false); |
3525 | } | 3525 | } |
3526 | #endif | 3526 | #endif |
3527 | } | 3527 | } |
3528 | 3528 | ||
3529 | void CalendarView::showDates(const DateList &selectedDates) | 3529 | void CalendarView::showDates(const DateList &selectedDates) |
3530 | { | 3530 | { |
3531 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3531 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3532 | 3532 | ||
3533 | 3533 | ||
3534 | if ( !mBlockShowDates ) { | 3534 | if ( !mBlockShowDates ) { |
3535 | if ( mViewManager->currentView() ) { | 3535 | if ( mViewManager->currentView() ) { |
3536 | updateView( selectedDates.first(), selectedDates.last() ); | 3536 | updateView( selectedDates.first(), selectedDates.last() ); |
3537 | } else { | 3537 | } else { |
3538 | mViewManager->showAgendaView(); | 3538 | mViewManager->showAgendaView(); |
3539 | } | 3539 | } |
3540 | } | 3540 | } |
3541 | 3541 | ||
3542 | QString selDates; | 3542 | QString selDates; |
3543 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3543 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3544 | if (selectedDates.first() < selectedDates.last() ) | 3544 | if (selectedDates.first() < selectedDates.last() ) |
3545 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3545 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3546 | else { | 3546 | else { |
3547 | QString addString; | 3547 | QString addString; |
3548 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3548 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3549 | addString = i18n("Today"); | 3549 | addString = i18n("Today"); |
3550 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3550 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3551 | addString = i18n("Tomorrow"); | 3551 | addString = i18n("Tomorrow"); |
3552 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3552 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3553 | addString = i18n("Yesterday"); | 3553 | addString = i18n("Yesterday"); |
3554 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3554 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3555 | addString = i18n("Day before yesterday"); | 3555 | addString = i18n("Day before yesterday"); |
3556 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3556 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3557 | addString = i18n("Day after tomorrow"); | 3557 | addString = i18n("Day after tomorrow"); |
3558 | if ( !addString.isEmpty() ) { | 3558 | if ( !addString.isEmpty() ) { |
3559 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3559 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3560 | return; | 3560 | return; |
3561 | } | 3561 | } |
3562 | } | 3562 | } |
3563 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3563 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3564 | 3564 | ||
3565 | } | 3565 | } |
3566 | 3566 | ||
3567 | QPtrList<CalFilter> CalendarView::filters() | 3567 | QPtrList<CalFilter> CalendarView::filters() |
3568 | { | 3568 | { |
3569 | return mFilters; | 3569 | return mFilters; |
3570 | 3570 | ||
3571 | } | 3571 | } |
3572 | void CalendarView::editFilters() | 3572 | void CalendarView::editFilters() |
3573 | { | 3573 | { |
3574 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3574 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3575 | 3575 | ||
3576 | CalFilter *filter = mFilters.first(); | 3576 | CalFilter *filter = mFilters.first(); |
3577 | while(filter) { | 3577 | while(filter) { |
3578 | kdDebug() << " Filter: " << filter->name() << endl; | 3578 | kdDebug() << " Filter: " << filter->name() << endl; |
3579 | filter = mFilters.next(); | 3579 | filter = mFilters.next(); |
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | mDialogManager->showFilterEditDialog(&mFilters); | 3582 | mDialogManager->showFilterEditDialog(&mFilters); |
3583 | } | 3583 | } |
3584 | void CalendarView::toggleFilter() | 3584 | void CalendarView::toggleFilter() |
3585 | { | 3585 | { |
3586 | showFilter(! mFilterView->isVisible()); | 3586 | showFilter(! mFilterView->isVisible()); |
3587 | } | 3587 | } |
3588 | 3588 | ||
3589 | KOFilterView *CalendarView::filterView() | 3589 | KOFilterView *CalendarView::filterView() |
3590 | { | 3590 | { |
3591 | return mFilterView; | 3591 | return mFilterView; |
3592 | } | 3592 | } |
3593 | void CalendarView::selectFilter( int fil ) | 3593 | void CalendarView::selectFilter( int fil ) |
3594 | { | 3594 | { |
3595 | mFilterView->setSelectedFilter( fil ); | 3595 | mFilterView->setSelectedFilter( fil ); |
3596 | } | 3596 | } |
3597 | void CalendarView::showFilter(bool visible) | 3597 | void CalendarView::showFilter(bool visible) |
3598 | { | 3598 | { |
3599 | if (visible) mFilterView->show(); | 3599 | if (visible) mFilterView->show(); |
3600 | else mFilterView->hide(); | 3600 | else mFilterView->hide(); |
3601 | } | 3601 | } |
3602 | void CalendarView::toggleFilerEnabled( ) | 3602 | void CalendarView::toggleFilerEnabled( ) |
3603 | { | 3603 | { |
3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3605 | if ( !mFilterView->filtersEnabled() ) | 3605 | if ( !mFilterView->filtersEnabled() ) |
3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3607 | 3607 | ||
3608 | } | 3608 | } |
3609 | void CalendarView::updateFilter() | 3609 | void CalendarView::updateFilter() |
3610 | { | 3610 | { |
3611 | CalFilter *filter = mFilterView->selectedFilter(); | 3611 | CalFilter *filter = mFilterView->selectedFilter(); |
3612 | if (filter) { | 3612 | if (filter) { |
3613 | QString mess; | ||
3613 | if (mFilterView->filtersEnabled()) { | 3614 | if (mFilterView->filtersEnabled()) { |
3614 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3615 | mess = i18n("Filter selected: ")+filter->name(); |
3615 | filter->setEnabled(true); | 3616 | filter->setEnabled(true); |
3616 | } | 3617 | } |
3617 | else filter->setEnabled(false); | 3618 | else filter->setEnabled(false); |
3618 | mCalendar->setFilter(filter); | 3619 | mCalendar->setFilter(filter); |
3619 | updateView(); | 3620 | updateView(); |
3621 | if ( !mess.isEmpty() ) | ||
3622 | topLevelWidget()->setCaption( mess ); | ||
3623 | |||
3620 | } | 3624 | } |
3621 | } | 3625 | } |
3622 | 3626 | ||
3623 | void CalendarView::filterEdited() | 3627 | void CalendarView::filterEdited() |
3624 | { | 3628 | { |
3625 | mFilterView->updateFilters(); | 3629 | mFilterView->updateFilters(); |
3626 | updateFilter(); | 3630 | updateFilter(); |
3627 | writeSettings(); | 3631 | writeSettings(); |
3628 | } | 3632 | } |
3629 | 3633 | ||
3630 | 3634 | ||
3631 | void CalendarView::takeOverEvent() | 3635 | void CalendarView::takeOverEvent() |
3632 | { | 3636 | { |
3633 | Incidence *incidence = currentSelection(); | 3637 | Incidence *incidence = currentSelection(); |
3634 | 3638 | ||
3635 | if (!incidence) return; | 3639 | if (!incidence) return; |
3636 | 3640 | ||
3637 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3641 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3638 | incidence->recreate(); | 3642 | incidence->recreate(); |
3639 | incidence->setReadOnly(false); | 3643 | incidence->setReadOnly(false); |
3640 | 3644 | ||
3641 | updateView(); | 3645 | updateView(); |
3642 | } | 3646 | } |
3643 | 3647 | ||
3644 | void CalendarView::takeOverCalendar() | 3648 | void CalendarView::takeOverCalendar() |
3645 | { | 3649 | { |
3646 | // TODO: Create Calendar::allIncidences() function and use it here | 3650 | // TODO: Create Calendar::allIncidences() function and use it here |
3647 | 3651 | ||
3648 | QPtrList<Event> events = mCalendar->events(); | 3652 | QPtrList<Event> events = mCalendar->events(); |
3649 | for(uint i=0; i<events.count(); ++i) { | 3653 | for(uint i=0; i<events.count(); ++i) { |
3650 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3654 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3651 | events.at(i)->recreate(); | 3655 | events.at(i)->recreate(); |
3652 | events.at(i)->setReadOnly(false); | 3656 | events.at(i)->setReadOnly(false); |
3653 | } | 3657 | } |
3654 | 3658 | ||
3655 | QPtrList<Todo> todos = mCalendar->todos(); | 3659 | QPtrList<Todo> todos = mCalendar->todos(); |
3656 | for(uint i=0; i<todos.count(); ++i) { | 3660 | for(uint i=0; i<todos.count(); ++i) { |
3657 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3661 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3658 | todos.at(i)->recreate(); | 3662 | todos.at(i)->recreate(); |
3659 | todos.at(i)->setReadOnly(false); | 3663 | todos.at(i)->setReadOnly(false); |
3660 | } | 3664 | } |
3661 | 3665 | ||
3662 | QPtrList<Journal> journals = mCalendar->journals(); | 3666 | QPtrList<Journal> journals = mCalendar->journals(); |
3663 | for(uint i=0; i<journals.count(); ++i) { | 3667 | for(uint i=0; i<journals.count(); ++i) { |
3664 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3668 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3665 | journals.at(i)->recreate(); | 3669 | journals.at(i)->recreate(); |
3666 | journals.at(i)->setReadOnly(false); | 3670 | journals.at(i)->setReadOnly(false); |
3667 | } | 3671 | } |
3668 | 3672 | ||
3669 | updateView(); | 3673 | updateView(); |
3670 | } | 3674 | } |
3671 | 3675 | ||
3672 | void CalendarView::showIntro() | 3676 | void CalendarView::showIntro() |
3673 | { | 3677 | { |
3674 | kdDebug() << "To be implemented." << endl; | 3678 | kdDebug() << "To be implemented." << endl; |
3675 | } | 3679 | } |
3676 | 3680 | ||
3677 | QWidgetStack *CalendarView::viewStack() | 3681 | QWidgetStack *CalendarView::viewStack() |
3678 | { | 3682 | { |
3679 | return mRightFrame; | 3683 | return mRightFrame; |
3680 | } | 3684 | } |
3681 | 3685 | ||
3682 | QWidget *CalendarView::leftFrame() | 3686 | QWidget *CalendarView::leftFrame() |
3683 | { | 3687 | { |
3684 | return mLeftFrame; | 3688 | return mLeftFrame; |
3685 | } | 3689 | } |
3686 | 3690 | ||
3687 | DateNavigator *CalendarView::dateNavigator() | 3691 | DateNavigator *CalendarView::dateNavigator() |
3688 | { | 3692 | { |
3689 | return mNavigator; | 3693 | return mNavigator; |
3690 | } | 3694 | } |
3691 | 3695 | ||
3692 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3696 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3693 | { | 3697 | { |
3694 | return mDateNavigator; | 3698 | return mDateNavigator; |
3695 | } | 3699 | } |
3696 | void CalendarView::toggleDateNavigatorWidget() | 3700 | void CalendarView::toggleDateNavigatorWidget() |
3697 | { | 3701 | { |
3698 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3702 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3699 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3703 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3700 | mDateNavigator->hide(); | 3704 | mDateNavigator->hide(); |
3701 | else | 3705 | else |
3702 | mDateNavigator->show(); | 3706 | mDateNavigator->show(); |
3703 | } | 3707 | } |
3704 | void CalendarView::addView(KOrg::BaseView *view) | 3708 | void CalendarView::addView(KOrg::BaseView *view) |
3705 | { | 3709 | { |
3706 | mViewManager->addView(view); | 3710 | mViewManager->addView(view); |
3707 | } | 3711 | } |
3708 | 3712 | ||
3709 | void CalendarView::showView(KOrg::BaseView *view) | 3713 | void CalendarView::showView(KOrg::BaseView *view) |
3710 | { | 3714 | { |
3711 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3715 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3712 | } | 3716 | } |
3713 | 3717 | ||
3714 | Incidence *CalendarView::currentSelection() | 3718 | Incidence *CalendarView::currentSelection() |
3715 | { | 3719 | { |
3716 | return mViewManager->currentSelection(); | 3720 | return mViewManager->currentSelection(); |
3717 | } | 3721 | } |
3718 | void CalendarView::toggleAllDaySize() | 3722 | void CalendarView::toggleAllDaySize() |
3719 | { | 3723 | { |
3720 | /* | 3724 | /* |
3721 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3725 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3722 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3726 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3723 | else | 3727 | else |
3724 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3728 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3725 | */ | 3729 | */ |
3726 | viewManager()->agendaView()->toggleAllDay(); | 3730 | viewManager()->agendaView()->toggleAllDay(); |
3727 | } | 3731 | } |
3728 | void CalendarView::toggleExpand() | 3732 | void CalendarView::toggleExpand() |
3729 | { | 3733 | { |
3730 | // if ( mLeftFrame->isHidden() ) { | 3734 | // if ( mLeftFrame->isHidden() ) { |
3731 | // mLeftFrame->show(); | 3735 | // mLeftFrame->show(); |
3732 | // emit calendarViewExpanded( false ); | 3736 | // emit calendarViewExpanded( false ); |
3733 | // } else { | 3737 | // } else { |
3734 | // mLeftFrame->hide(); | 3738 | // mLeftFrame->hide(); |
3735 | // emit calendarViewExpanded( true ); | 3739 | // emit calendarViewExpanded( true ); |
3736 | // } | 3740 | // } |
3737 | //qDebug(" CalendarView::toggleExpand()"); | 3741 | //qDebug(" CalendarView::toggleExpand()"); |
3738 | globalFlagBlockAgenda = 1; | 3742 | globalFlagBlockAgenda = 1; |
3739 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3743 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3740 | globalFlagBlockAgenda = 5; | 3744 | globalFlagBlockAgenda = 5; |
3741 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3745 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3742 | //mViewManager->showView( 0, true ); | 3746 | //mViewManager->showView( 0, true ); |
3743 | } | 3747 | } |
3744 | 3748 | ||
3745 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3749 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3746 | { | 3750 | { |
3747 | setModified( modified ); | 3751 | setModified( modified ); |
3748 | } | 3752 | } |
3749 | 3753 | ||
3750 | Todo *CalendarView::selectedTodo() | 3754 | Todo *CalendarView::selectedTodo() |
3751 | { | 3755 | { |
3752 | Incidence *incidence = currentSelection(); | 3756 | Incidence *incidence = currentSelection(); |
3753 | if ( incidence && incidence->type() == "Todo" ) { | 3757 | if ( incidence && incidence->type() == "Todo" ) { |
3754 | return static_cast<Todo *>( incidence ); | 3758 | return static_cast<Todo *>( incidence ); |
3755 | } | 3759 | } |
3756 | 3760 | ||
3757 | incidence = mTodoList->selectedIncidences().first(); | 3761 | incidence = mTodoList->selectedIncidences().first(); |
3758 | if ( incidence && incidence->type() == "Todo" ) { | 3762 | if ( incidence && incidence->type() == "Todo" ) { |
3759 | return static_cast<Todo *>( incidence ); | 3763 | return static_cast<Todo *>( incidence ); |
3760 | } | 3764 | } |
3761 | 3765 | ||
3762 | return 0; | 3766 | return 0; |
3763 | } | 3767 | } |
3764 | 3768 | ||
3765 | void CalendarView::dialogClosing(Incidence *in) | 3769 | void CalendarView::dialogClosing(Incidence *in) |
3766 | { | 3770 | { |
3767 | // mDialogList.remove(in); | 3771 | // mDialogList.remove(in); |
3768 | } | 3772 | } |
3769 | 3773 | ||
3770 | void CalendarView::showIncidence() | 3774 | void CalendarView::showIncidence() |
3771 | { | 3775 | { |
3772 | mViewerCallerIsSearchDialog = false; | 3776 | mViewerCallerIsSearchDialog = false; |
3773 | Incidence *incidence = currentSelection(); | 3777 | Incidence *incidence = currentSelection(); |
3774 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3778 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3775 | if ( incidence ) { | 3779 | if ( incidence ) { |
3776 | ShowIncidenceVisitor v; | 3780 | ShowIncidenceVisitor v; |
3777 | v.act( incidence, this ); | 3781 | v.act( incidence, this ); |
3778 | } | 3782 | } |
3779 | } | 3783 | } |
3780 | void CalendarView::editIncidenceDescription() | 3784 | void CalendarView::editIncidenceDescription() |
3781 | { | 3785 | { |
3782 | mFlagEditDescription = true; | 3786 | mFlagEditDescription = true; |
3783 | editIncidence(); | 3787 | editIncidence(); |
3784 | mFlagEditDescription = false; | 3788 | mFlagEditDescription = false; |
3785 | } | 3789 | } |
3786 | void CalendarView::editIncidence() | 3790 | void CalendarView::editIncidence() |
3787 | { | 3791 | { |
3788 | // qDebug("editIncidence() "); | 3792 | // qDebug("editIncidence() "); |
3789 | Incidence *incidence = currentSelection(); | 3793 | Incidence *incidence = currentSelection(); |
3790 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3794 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3791 | if ( incidence ) { | 3795 | if ( incidence ) { |
3792 | EditIncidenceVisitor v; | 3796 | EditIncidenceVisitor v; |
3793 | v.act( incidence, this ); | 3797 | v.act( incidence, this ); |
3794 | } | 3798 | } |
3795 | } | 3799 | } |
3796 | 3800 | ||
3797 | void CalendarView::deleteIncidence() | 3801 | void CalendarView::deleteIncidence() |
3798 | { | 3802 | { |
3799 | Incidence *incidence = currentSelection(); | 3803 | Incidence *incidence = currentSelection(); |
3800 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3804 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3801 | if ( incidence ) { | 3805 | if ( incidence ) { |
3802 | deleteIncidence(incidence); | 3806 | deleteIncidence(incidence); |
3803 | } | 3807 | } |
3804 | } | 3808 | } |
3805 | 3809 | ||
3806 | void CalendarView::showIncidence(Incidence *incidence) | 3810 | void CalendarView::showIncidence(Incidence *incidence) |
3807 | { | 3811 | { |
3808 | mViewerCallerIsSearchDialog = false; | 3812 | mViewerCallerIsSearchDialog = false; |
3809 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3813 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3810 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3814 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3811 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3815 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3812 | mViewerCallerIsSearchDialog = true; | 3816 | mViewerCallerIsSearchDialog = true; |
3813 | } | 3817 | } |
3814 | } | 3818 | } |
3815 | if ( incidence ) { | 3819 | if ( incidence ) { |
3816 | ShowIncidenceVisitor v; | 3820 | ShowIncidenceVisitor v; |
3817 | v.act( incidence, this ); | 3821 | v.act( incidence, this ); |
3818 | } | 3822 | } |
3819 | } | 3823 | } |
3820 | 3824 | ||
3821 | void CalendarView::editIncidence(Incidence *incidence) | 3825 | void CalendarView::editIncidence(Incidence *incidence) |
3822 | { | 3826 | { |
3823 | if ( incidence ) { | 3827 | if ( incidence ) { |
3824 | 3828 | ||
3825 | EditIncidenceVisitor v; | 3829 | EditIncidenceVisitor v; |
3826 | v.act( incidence, this ); | 3830 | v.act( incidence, this ); |
3827 | 3831 | ||
3828 | } | 3832 | } |
3829 | } | 3833 | } |
3830 | 3834 | ||
3831 | void CalendarView::deleteIncidence(Incidence *incidence) | 3835 | void CalendarView::deleteIncidence(Incidence *incidence) |
3832 | { | 3836 | { |
3833 | //qDebug(" CalendarView::deleteIncidence "); | 3837 | //qDebug(" CalendarView::deleteIncidence "); |
3834 | if ( incidence ) { | 3838 | if ( incidence ) { |
3835 | DeleteIncidenceVisitor v; | 3839 | DeleteIncidenceVisitor v; |
3836 | v.act( incidence, this ); | 3840 | v.act( incidence, this ); |
3837 | } | 3841 | } |
3838 | } | 3842 | } |
3839 | 3843 | ||
3840 | 3844 | ||
3841 | void CalendarView::lookForOutgoingMessages() | 3845 | void CalendarView::lookForOutgoingMessages() |
3842 | { | 3846 | { |
3843 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3847 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3844 | ogd->loadMessages(); | 3848 | ogd->loadMessages(); |
3845 | } | 3849 | } |
3846 | 3850 | ||
3847 | void CalendarView::lookForIncomingMessages() | 3851 | void CalendarView::lookForIncomingMessages() |
3848 | { | 3852 | { |
3849 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3853 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3850 | icd->retrieve(); | 3854 | icd->retrieve(); |
3851 | } | 3855 | } |
3852 | 3856 | ||
3853 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3857 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3854 | { | 3858 | { |
3855 | bool deleteTodo = true; | 3859 | bool deleteTodo = true; |
3856 | QPtrList<Incidence> subTodos; | 3860 | QPtrList<Incidence> subTodos; |
3857 | Incidence *aTodo; | 3861 | Incidence *aTodo; |
3858 | subTodos = t->relations(); | 3862 | subTodos = t->relations(); |
3859 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3863 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3860 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3864 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3861 | deleteTodo = false; | 3865 | deleteTodo = false; |
3862 | } | 3866 | } |
3863 | if ( deleteTodo ) { | 3867 | if ( deleteTodo ) { |
3864 | if ( t->isCompleted() && !t->doesRecur()) { | 3868 | if ( t->isCompleted() && !t->doesRecur()) { |
3865 | checkExternalId( t ); | 3869 | checkExternalId( t ); |
3866 | mCalendar->deleteTodo( t ); | 3870 | mCalendar->deleteTodo( t ); |
3867 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3871 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3868 | } | 3872 | } |
3869 | else | 3873 | else |
3870 | deleteTodo = false; | 3874 | deleteTodo = false; |
3871 | } | 3875 | } |
3872 | return deleteTodo; | 3876 | return deleteTodo; |
3873 | 3877 | ||
3874 | } | 3878 | } |
3875 | void CalendarView::purgeCompleted() | 3879 | void CalendarView::purgeCompleted() |
3876 | { | 3880 | { |
3877 | int result = KMessageBox::warningContinueCancel(this, | 3881 | int result = KMessageBox::warningContinueCancel(this, |
3878 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3882 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3879 | 3883 | ||
3880 | if (result == KMessageBox::Continue) { | 3884 | if (result == KMessageBox::Continue) { |
3881 | 3885 | ||
3882 | QPtrList<Todo> todoCal; | 3886 | QPtrList<Todo> todoCal; |
3883 | QPtrList<Todo> rootTodos; | 3887 | QPtrList<Todo> rootTodos; |
3884 | //QPtrList<Incidence> rel; | 3888 | //QPtrList<Incidence> rel; |
3885 | Todo *aTodo;//, *rTodo; | 3889 | Todo *aTodo;//, *rTodo; |
3886 | Incidence *rIncidence; | 3890 | Incidence *rIncidence; |
3887 | bool childDelete = false; | 3891 | bool childDelete = false; |
3888 | bool deletedOne = true; | 3892 | bool deletedOne = true; |
3889 | todoCal = calendar()->todos(); | 3893 | todoCal = calendar()->todos(); |
3890 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3894 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3891 | if ( !aTodo->relatedTo() ) | 3895 | if ( !aTodo->relatedTo() ) |
3892 | rootTodos.append( aTodo ); | 3896 | rootTodos.append( aTodo ); |
3893 | } | 3897 | } |
3894 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3898 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3895 | removeCompletedSubTodos( aTodo ); | 3899 | removeCompletedSubTodos( aTodo ); |
3896 | } | 3900 | } |
3897 | 3901 | ||
3898 | updateView(); | 3902 | updateView(); |
3899 | } | 3903 | } |
3900 | } | 3904 | } |
3901 | 3905 | ||
3902 | void CalendarView::slotCalendarChanged() | 3906 | void CalendarView::slotCalendarChanged() |
3903 | { | 3907 | { |
3904 | ; | 3908 | ; |
3905 | } | 3909 | } |
3906 | 3910 | ||
3907 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3911 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3908 | { | 3912 | { |
3909 | //qDebug(" alendarView::keyPressEvent "); | 3913 | //qDebug(" alendarView::keyPressEvent "); |
3910 | e->ignore(); | 3914 | e->ignore(); |
3911 | } | 3915 | } |
3912 | 3916 | ||
3913 | 3917 | ||
3914 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3918 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3915 | { | 3919 | { |
3916 | // mSyncManager = manager; | 3920 | // mSyncManager = manager; |
3917 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3921 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3918 | qDebug("KO: SyncKDE request detected!"); | 3922 | qDebug("KO: SyncKDE request detected!"); |
3919 | } | 3923 | } |
3920 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3924 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3921 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3925 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3922 | return syncCalendar( filename, mode ); | 3926 | return syncCalendar( filename, mode ); |
3923 | } | 3927 | } |
3924 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3928 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3925 | { | 3929 | { |
3926 | //mSyncManager = manager; | 3930 | //mSyncManager = manager; |
3927 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3931 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3928 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3932 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3929 | if ( resource == "sharp" ) | 3933 | if ( resource == "sharp" ) |
3930 | syncExternal( 0 ); | 3934 | syncExternal( 0 ); |
3931 | if ( resource == "phone" ) | 3935 | if ( resource == "phone" ) |
3932 | syncExternal( 1 ); | 3936 | syncExternal( 1 ); |
3933 | // pending setmodified | 3937 | // pending setmodified |
3934 | return true; | 3938 | return true; |
3935 | } | 3939 | } |
3936 | void CalendarView::setSyncManager(KSyncManager* manager) | 3940 | void CalendarView::setSyncManager(KSyncManager* manager) |
3937 | { | 3941 | { |
3938 | mSyncManager = manager; | 3942 | mSyncManager = manager; |
3939 | } | 3943 | } |
3940 | 3944 | ||
3941 | void CalendarView::removeSyncInfo( QString syncProfile) | 3945 | void CalendarView::removeSyncInfo( QString syncProfile) |
3942 | { | 3946 | { |
3943 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3947 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3944 | mCalendar->removeSyncInfo( syncProfile ); | 3948 | mCalendar->removeSyncInfo( syncProfile ); |
3945 | 3949 | ||
3946 | } | 3950 | } |
3947 | 3951 | ||
3948 | void CalendarView::undo_delete() | 3952 | void CalendarView::undo_delete() |
3949 | { | 3953 | { |
3950 | //qDebug("undo_delete() "); | 3954 | //qDebug("undo_delete() "); |
3951 | Incidence* undo = mCalendar->undoIncidence(); | 3955 | Incidence* undo = mCalendar->undoIncidence(); |
3952 | if ( !undo ) { | 3956 | if ( !undo ) { |
3953 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3957 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3954 | i18n("KO/Pi")); | 3958 | i18n("KO/Pi")); |
3955 | return; | 3959 | return; |
3956 | } | 3960 | } |
3957 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3961 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3958 | i18n("\nAre you sure you want\nto restore this?"), | 3962 | i18n("\nAre you sure you want\nto restore this?"), |
3959 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3963 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3960 | mCalendar->undoDeleteIncidence(); | 3964 | mCalendar->undoDeleteIncidence(); |
3961 | updateView(); | 3965 | updateView(); |
3962 | } | 3966 | } |
3963 | } | 3967 | } |
3964 | 3968 | ||
3965 | void CalendarView::slotViewerClosed() | 3969 | void CalendarView::slotViewerClosed() |
3966 | { | 3970 | { |
3967 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 3971 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
3968 | } | 3972 | } |
3969 | 3973 | ||
3970 | void CalendarView::resetFocus() | 3974 | void CalendarView::resetFocus() |
3971 | { | 3975 | { |
3972 | if ( mViewerCallerIsSearchDialog ) { | 3976 | if ( mViewerCallerIsSearchDialog ) { |
3973 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 3977 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
3974 | mDialogManager->getSearchDialog()->raise(); | 3978 | mDialogManager->getSearchDialog()->raise(); |
3975 | mDialogManager->getSearchDialog()->setActiveWindow(); | 3979 | mDialogManager->getSearchDialog()->setActiveWindow(); |
3976 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 3980 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
3977 | } else | 3981 | } else |
3978 | mViewerCallerIsSearchDialog = false; | 3982 | mViewerCallerIsSearchDialog = false; |
3979 | } | 3983 | } |
3980 | if ( !mViewerCallerIsSearchDialog ) { | 3984 | if ( !mViewerCallerIsSearchDialog ) { |
3981 | //mViewManager->currentView()->setFocus(); | 3985 | //mViewManager->currentView()->setFocus(); |
3982 | //qDebug("sssssssssssssssset focus "); | 3986 | //qDebug("sssssssssssssssset focus "); |
3983 | topLevelWidget()->raise(); | 3987 | topLevelWidget()->raise(); |
3984 | setActiveWindow(); | 3988 | setActiveWindow(); |
3985 | //setFocus(); | 3989 | //setFocus(); |
3986 | } | 3990 | } |
3987 | mViewerCallerIsSearchDialog = false; | 3991 | mViewerCallerIsSearchDialog = false; |
3988 | } | 3992 | } |