summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp27
-rw-r--r--korganizer/kolistview.cpp6
2 files changed, 26 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 98e0ac1..bc1c0c7 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -2630,1095 +2630,1112 @@ void CalendarView::changeEventDisplay(Event *which, int action)
2630 // kdDebug() << "CalendarView::changeEventDisplay" << endl; 2630 // kdDebug() << "CalendarView::changeEventDisplay" << endl;
2631 changeIncidenceDisplay((Incidence *)which, action); 2631 changeIncidenceDisplay((Incidence *)which, action);
2632 2632
2633 2633
2634 static bool clearallviews = false; 2634 static bool clearallviews = false;
2635 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2635 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2636 if ( clearallviews ) { 2636 if ( clearallviews ) {
2637 clearAllViews(); 2637 clearAllViews();
2638 clearallviews = false; 2638 clearallviews = false;
2639 } 2639 }
2640 return; 2640 return;
2641 } 2641 }
2642 clearallviews = true; 2642 clearallviews = true;
2643 2643
2644 2644
2645 2645
2646 mDateNavigator->updateView(); 2646 mDateNavigator->updateView();
2647 //mDialogManager->updateSearchDialog(); 2647 //mDialogManager->updateSearchDialog();
2648 2648
2649 if (which) { 2649 if (which) {
2650 // If there is an event view visible update the display 2650 // If there is an event view visible update the display
2651 mViewManager->currentView()->changeEventDisplay(which,action); 2651 mViewManager->currentView()->changeEventDisplay(which,action);
2652 // TODO: check, if update needed 2652 // TODO: check, if update needed
2653 // if (which->getTodoStatus()) { 2653 // if (which->getTodoStatus()) {
2654 mTodoList->updateView(); 2654 mTodoList->updateView();
2655 // } 2655 // }
2656 } else { 2656 } else {
2657 mViewManager->currentView()->updateView(); 2657 mViewManager->currentView()->updateView();
2658 } 2658 }
2659} 2659}
2660 2660
2661 2661
2662void CalendarView::updateTodoViews() 2662void CalendarView::updateTodoViews()
2663{ 2663{
2664 mTodoList->updateView(); 2664 mTodoList->updateView();
2665 mViewManager->currentView()->updateView(); 2665 mViewManager->currentView()->updateView();
2666 2666
2667} 2667}
2668 2668
2669 2669
2670 2670
2671void CalendarView::clearAllViews() 2671void CalendarView::clearAllViews()
2672{ 2672{
2673 mTodoList->clearList(); 2673 mTodoList->clearList();
2674 mViewManager->clearAllViews(); 2674 mViewManager->clearAllViews();
2675 SearchDialog * sd = mDialogManager->getSearchDialog(); 2675 SearchDialog * sd = mDialogManager->getSearchDialog();
2676 if ( sd ) { 2676 if ( sd ) {
2677 KOListView* kol = sd->listview(); 2677 KOListView* kol = sd->listview();
2678 if ( kol ) 2678 if ( kol )
2679 kol->clearList(); 2679 kol->clearList();
2680 } 2680 }
2681} 2681}
2682void CalendarView::updateView() 2682void CalendarView::updateView()
2683{ 2683{
2684 static bool clearallviews = false; 2684 static bool clearallviews = false;
2685 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) { 2685 if ( KOPrefs::instance()->mGlobalUpdateDisabled ) {
2686 if ( clearallviews ) { 2686 if ( clearallviews ) {
2687 clearAllViews(); 2687 clearAllViews();
2688 clearallviews = false; 2688 clearallviews = false;
2689 } 2689 }
2690 return; 2690 return;
2691 } 2691 }
2692 clearallviews = true; 2692 clearallviews = true;
2693 DateList tmpList = mNavigator->selectedDates(); 2693 DateList tmpList = mNavigator->selectedDates();
2694 2694
2695 if ( KOPrefs::instance()->mHideNonStartedTodos ) 2695 if ( KOPrefs::instance()->mHideNonStartedTodos )
2696 mTodoList->updateView(); 2696 mTodoList->updateView();
2697 // We assume that the navigator only selects consecutive days. 2697 // We assume that the navigator only selects consecutive days.
2698 updateView( tmpList.first(), tmpList.last() ); 2698 updateView( tmpList.first(), tmpList.last() );
2699} 2699}
2700 2700
2701void CalendarView::updateUnmanagedViews() 2701void CalendarView::updateUnmanagedViews()
2702{ 2702{
2703 mDateNavigator->updateDayMatrix(); 2703 mDateNavigator->updateDayMatrix();
2704} 2704}
2705 2705
2706int CalendarView::msgItemDelete(const QString name) 2706int CalendarView::msgItemDelete(const QString name)
2707{ 2707{
2708 return KMessageBox::warningContinueCancel(this,name +"\n\n"+ 2708 return KMessageBox::warningContinueCancel(this,name +"\n\n"+
2709 i18n("This item will be\npermanently deleted."), 2709 i18n("This item will be\npermanently deleted."),
2710 i18n("KO/Pi Confirmation"),i18n("Delete")); 2710 i18n("KO/Pi Confirmation"),i18n("Delete"));
2711} 2711}
2712 2712
2713 2713
2714void CalendarView::edit_cut() 2714void CalendarView::edit_cut()
2715{ 2715{
2716 Event *anEvent=0; 2716 Event *anEvent=0;
2717 2717
2718 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2718 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2719 2719
2720 if (mViewManager->currentView()->isEventView()) { 2720 if (mViewManager->currentView()->isEventView()) {
2721 if ( incidence && incidence->typeID() == eventID ) { 2721 if ( incidence && incidence->typeID() == eventID ) {
2722 anEvent = static_cast<Event *>(incidence); 2722 anEvent = static_cast<Event *>(incidence);
2723 } 2723 }
2724 } 2724 }
2725 2725
2726 if (!anEvent) { 2726 if (!anEvent) {
2727 KNotifyClient::beep(); 2727 KNotifyClient::beep();
2728 return; 2728 return;
2729 } 2729 }
2730 DndFactory factory( mCalendar ); 2730 DndFactory factory( mCalendar );
2731 factory.cutIncidence(anEvent); 2731 factory.cutIncidence(anEvent);
2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 2732 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
2733} 2733}
2734 2734
2735void CalendarView::edit_copy() 2735void CalendarView::edit_copy()
2736{ 2736{
2737 Event *anEvent=0; 2737 Event *anEvent=0;
2738 2738
2739 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 2739 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
2740 2740
2741 if (mViewManager->currentView()->isEventView()) { 2741 if (mViewManager->currentView()->isEventView()) {
2742 if ( incidence && incidence->typeID() == eventID ) { 2742 if ( incidence && incidence->typeID() == eventID ) {
2743 anEvent = static_cast<Event *>(incidence); 2743 anEvent = static_cast<Event *>(incidence);
2744 } 2744 }
2745 } 2745 }
2746 2746
2747 if (!anEvent) { 2747 if (!anEvent) {
2748 KNotifyClient::beep(); 2748 KNotifyClient::beep();
2749 return; 2749 return;
2750 } 2750 }
2751 DndFactory factory( mCalendar ); 2751 DndFactory factory( mCalendar );
2752 factory.copyIncidence(anEvent); 2752 factory.copyIncidence(anEvent);
2753} 2753}
2754 2754
2755void CalendarView::edit_paste() 2755void CalendarView::edit_paste()
2756{ 2756{
2757 QDate date = mNavigator->selectedDates().first(); 2757 QDate date = mNavigator->selectedDates().first();
2758 2758
2759 DndFactory factory( mCalendar ); 2759 DndFactory factory( mCalendar );
2760 Event *pastedEvent = (Event *)factory.pasteIncidence( date ); 2760 Event *pastedEvent = (Event *)factory.pasteIncidence( date );
2761 2761
2762 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED ); 2762 changeEventDisplay( pastedEvent, KOGlobals::EVENTADDED );
2763} 2763}
2764void CalendarView::edit_global_options() 2764void CalendarView::edit_global_options()
2765{ 2765{
2766 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId; 2766 QString tz = KPimGlobalPrefs::instance()->mTimeZoneId;
2767 emit save(); 2767 emit save();
2768 emit saveStopTimer(); 2768 emit saveStopTimer();
2769 mDialogManager->showGlobalOptionsDialog(); 2769 mDialogManager->showGlobalOptionsDialog();
2770 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) { 2770 if ( tz != KPimGlobalPrefs::instance()->mTimeZoneId) {
2771 emit saveStopTimer(); 2771 emit saveStopTimer();
2772 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!"), 2772 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!"),
2773 i18n("Timezone settings"),i18n("Reload"))) { 2773 i18n("Timezone settings"),i18n("Reload"))) {
2774 qDebug("KO: TZ reload cancelled "); 2774 qDebug("KO: TZ reload cancelled ");
2775 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2775 mCalendar->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2776 return; 2776 return;
2777 } 2777 }
2778 qDebug("KO: Timezone change "); 2778 qDebug("KO: Timezone change ");
2779 loadCalendars(); 2779 loadCalendars();
2780 setModified(true); 2780 setModified(true);
2781 } 2781 }
2782 else 2782 else
2783 qDebug("KO: No tz change "); 2783 qDebug("KO: No tz change ");
2784} 2784}
2785void CalendarView::edit_options() 2785void CalendarView::edit_options()
2786{ 2786{
2787 mDialogManager->showOptionsDialog(); 2787 mDialogManager->showOptionsDialog();
2788} 2788}
2789 2789
2790 2790
2791void CalendarView::slotSelectPickerDate( QDate d) 2791void CalendarView::slotSelectPickerDate( QDate d)
2792{ 2792{
2793 mDateFrame->hide(); 2793 mDateFrame->hide();
2794 if ( mDatePickerMode == 1 ) { 2794 if ( mDatePickerMode == 1 ) {
2795 mNavigator->slotDaySelect( d ); 2795 mNavigator->slotDaySelect( d );
2796 } else if ( mDatePickerMode == 2 ) { 2796 } else if ( mDatePickerMode == 2 ) {
2797 if ( mMoveIncidence->typeID() == todoID ) { 2797 if ( mMoveIncidence->typeID() == todoID ) {
2798 Todo * to = (Todo *) mMoveIncidence; 2798 Todo * to = (Todo *) mMoveIncidence;
2799 QTime tim; 2799 QTime tim;
2800 int len = 0; 2800 int len = 0;
2801 if ( to->hasStartDate() && to->hasDueDate() ) 2801 if ( to->hasStartDate() && to->hasDueDate() )
2802 len = to->dtStart().secsTo( to->dtDue()); 2802 len = to->dtStart().secsTo( to->dtDue());
2803 if ( to->hasDueDate() ) 2803 if ( to->hasDueDate() )
2804 tim = to->dtDue().time(); 2804 tim = to->dtDue().time();
2805 else { 2805 else {
2806 tim = QTime ( 0,0,0 ); 2806 tim = QTime ( 0,0,0 );
2807 to->setFloats( true ); 2807 to->setFloats( true );
2808 to->setHasDueDate( true ); 2808 to->setHasDueDate( true );
2809 } 2809 }
2810 QDateTime dt ( d,tim ); 2810 QDateTime dt ( d,tim );
2811 to->setDtDue( dt ); 2811 to->setDtDue( dt );
2812 2812
2813 if ( to->hasStartDate() ) { 2813 if ( to->hasStartDate() ) {
2814 if ( len>0 ) 2814 if ( len>0 )
2815 to->setDtStart(to->dtDue().addSecs( -len )); 2815 to->setDtStart(to->dtDue().addSecs( -len ));
2816 else 2816 else
2817 if (to->dtStart() > to->dtDue() ) 2817 if (to->dtStart() > to->dtDue() )
2818 to->setDtStart(to->dtDue().addDays( -3 )); 2818 to->setDtStart(to->dtDue().addDays( -3 ));
2819 } 2819 }
2820 2820
2821 todoChanged( to ); 2821 todoChanged( to );
2822 } else { 2822 } else if ( mMoveIncidence->typeID() == eventID ) {
2823 if ( mMoveIncidence->doesRecur() ) { 2823 if ( mMoveIncidence->doesRecur() ) {
2824#if 0 2824#if 0
2825 // PENDING implement this 2825 // PENDING implement this
2826 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); 2826 Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate );
2827 mCalendar()->addIncidence( newInc ); 2827 mCalendar()->addIncidence( newInc );
2828 if ( mMoveIncidence->typeID() == todoID ) 2828 if ( mMoveIncidence->typeID() == todoID )
2829 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); 2829 emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED );
2830 else 2830 else
2831 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); 2831 emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED);
2832 mMoveIncidence = newInc; 2832 mMoveIncidence = newInc;
2833 2833
2834#endif 2834#endif
2835 } 2835 }
2836 QTime tim = mMoveIncidence->dtStart().time(); 2836 QTime tim = mMoveIncidence->dtStart().time();
2837 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); 2837 int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd());
2838 QDateTime dt ( d,tim ); 2838 QDateTime dt ( d,tim );
2839 mMoveIncidence->setDtStart( dt ); 2839 mMoveIncidence->setDtStart( dt );
2840 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); 2840 ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) );
2841 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); 2841 changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED);
2842 } else if ( mMoveIncidence->typeID() == journalID ) {
2843 QTime tim = mMoveIncidence->dtStart().time();
2844 QDateTime dt ( d,tim );
2845 mMoveIncidence->setDtStart( dt );
2846 updateView();
2842 } 2847 }
2843
2844 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); 2848 mMoveIncidence->setRevision( mMoveIncidence->revision()+1 );
2845 } 2849 }
2846} 2850}
2847 2851
2848void CalendarView::removeCategories() 2852void CalendarView::removeCategories()
2849{ 2853{
2850 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2854 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2851 QStringList catList = KOPrefs::instance()->mCustomCategories; 2855 QStringList catList = KOPrefs::instance()->mCustomCategories;
2852 QStringList catIncList; 2856 QStringList catIncList;
2853 QStringList newCatList; 2857 QStringList newCatList;
2854 Incidence* inc = incList.first(); 2858 Incidence* inc = incList.first();
2855 uint i; 2859 uint i;
2856 while ( inc ) { 2860 while ( inc ) {
2857 newCatList.clear(); 2861 newCatList.clear();
2858 catIncList = inc->categories() ; 2862 catIncList = inc->categories() ;
2859 for( i = 0; i< catIncList.count(); ++i ) { 2863 for( i = 0; i< catIncList.count(); ++i ) {
2860 if ( catList.contains (catIncList[i])) 2864 if ( catList.contains (catIncList[i]))
2861 newCatList.append( catIncList[i] ); 2865 newCatList.append( catIncList[i] );
2862 } 2866 }
2863 newCatList.sort(); 2867 newCatList.sort();
2864 inc->setCategories( newCatList.join(",") ); 2868 inc->setCategories( newCatList.join(",") );
2865 inc = incList.next(); 2869 inc = incList.next();
2866 } 2870 }
2867} 2871}
2868 2872
2869int CalendarView::addCategories() 2873int CalendarView::addCategories()
2870{ 2874{
2871 QPtrList<Incidence> incList = mCalendar->rawIncidences(); 2875 QPtrList<Incidence> incList = mCalendar->rawIncidences();
2872 QStringList catList = KOPrefs::instance()->mCustomCategories; 2876 QStringList catList = KOPrefs::instance()->mCustomCategories;
2873 QStringList catIncList; 2877 QStringList catIncList;
2874 Incidence* inc = incList.first(); 2878 Incidence* inc = incList.first();
2875 uint i; 2879 uint i;
2876 int count = 0; 2880 int count = 0;
2877 while ( inc ) { 2881 while ( inc ) {
2878 catIncList = inc->categories() ; 2882 catIncList = inc->categories() ;
2879 for( i = 0; i< catIncList.count(); ++i ) { 2883 for( i = 0; i< catIncList.count(); ++i ) {
2880 if ( !catList.contains (catIncList[i])) { 2884 if ( !catList.contains (catIncList[i])) {
2881 catList.append( catIncList[i] ); 2885 catList.append( catIncList[i] );
2882 //qDebug("add cat %s ", catIncList[i].latin1()); 2886 //qDebug("add cat %s ", catIncList[i].latin1());
2883 ++count; 2887 ++count;
2884 } 2888 }
2885 } 2889 }
2886 inc = incList.next(); 2890 inc = incList.next();
2887 } 2891 }
2888 catList.sort(); 2892 catList.sort();
2889 KOPrefs::instance()->mCustomCategories = catList; 2893 KOPrefs::instance()->mCustomCategories = catList;
2890 return count; 2894 return count;
2891} 2895}
2892 2896
2893void CalendarView::editCategories() 2897void CalendarView::editCategories()
2894{ 2898{
2895 qDebug("CalendarView::editCategories() "); 2899 qDebug("CalendarView::editCategories() ");
2896 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); 2900 KPIM::CategoryEditDialog ced (KOPrefs::instance(),this );
2897 ced.exec(); 2901 ced.exec();
2898} 2902}
2899void CalendarView::manageCategories() 2903void CalendarView::manageCategories()
2900{ 2904{
2901 KOCatPrefs* cp = new KOCatPrefs(); 2905 KOCatPrefs* cp = new KOCatPrefs();
2902 cp->show(); 2906 cp->show();
2903 int w =cp->sizeHint().width() ; 2907 int w =cp->sizeHint().width() ;
2904 int h = cp->sizeHint().height() ; 2908 int h = cp->sizeHint().height() ;
2905 int dw = QApplication::desktop()->width(); 2909 int dw = QApplication::desktop()->width();
2906 int dh = QApplication::desktop()->height(); 2910 int dh = QApplication::desktop()->height();
2907 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 2911 cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
2908 if ( !cp->exec() ) { 2912 if ( !cp->exec() ) {
2909 delete cp; 2913 delete cp;
2910 return; 2914 return;
2911 } 2915 }
2912 int count = 0; 2916 int count = 0;
2913 if ( cp->addCat() ) { 2917 if ( cp->addCat() ) {
2914 count = addCategories(); 2918 count = addCategories();
2915 if ( count ) { 2919 if ( count ) {
2916 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); 2920 topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! "));
2917 writeSettings(); 2921 writeSettings();
2918 } else 2922 } else
2919 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); 2923 topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! "));
2920 } else { 2924 } else {
2921 removeCategories(); 2925 removeCategories();
2922 updateView(); 2926 updateView();
2923 } 2927 }
2924 delete cp; 2928 delete cp;
2925} 2929}
2926 2930
2927void CalendarView::beamIncidence(Incidence * Inc) 2931void CalendarView::beamIncidence(Incidence * Inc)
2928{ 2932{
2929 QPtrList<Incidence> delSel ; 2933 QPtrList<Incidence> delSel ;
2930 delSel.append(Inc); 2934 delSel.append(Inc);
2931 beamIncidenceList( delSel ); 2935 beamIncidenceList( delSel );
2932} 2936}
2933void CalendarView::beamCalendar() 2937void CalendarView::beamCalendar()
2934{ 2938{
2935 QPtrList<Incidence> delSel = mCalendar->rawIncidences(); 2939 QPtrList<Incidence> delSel = mCalendar->rawIncidences();
2936 //qDebug("beamCalendar() "); 2940 //qDebug("beamCalendar() ");
2937 beamIncidenceList( delSel ); 2941 beamIncidenceList( delSel );
2938} 2942}
2939void CalendarView::beamFilteredCalendar() 2943void CalendarView::beamFilteredCalendar()
2940{ 2944{
2941 QPtrList<Incidence> delSel = mCalendar->incidences(); 2945 QPtrList<Incidence> delSel = mCalendar->incidences();
2942 //qDebug("beamFilteredCalendar() "); 2946 //qDebug("beamFilteredCalendar() ");
2943 beamIncidenceList( delSel ); 2947 beamIncidenceList( delSel );
2944} 2948}
2945void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) 2949void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel )
2946{ 2950{
2947 2951
2948 KOBeamPrefs beamDialog; 2952 KOBeamPrefs beamDialog;
2949 if ( beamDialog.exec () == QDialog::Rejected ) 2953 if ( beamDialog.exec () == QDialog::Rejected )
2950 return; 2954 return;
2951#ifdef DESKTOP_VERSION 2955#ifdef DESKTOP_VERSION
2952 QString fn = locateLocal( "tmp", "kopibeamfile" ); 2956 QString fn = locateLocal( "tmp", "kopibeamfile" );
2953#else 2957#else
2954 QString fn = "/tmp/kopibeamfile"; 2958 QString fn = "/tmp/kopibeamfile";
2955#endif 2959#endif
2956 QString mes; 2960 QString mes;
2957 bool createbup = true; 2961 bool createbup = true;
2958 if ( createbup ) { 2962 if ( createbup ) {
2959 QString description = "\n"; 2963 QString description = "\n";
2960 CalendarLocal* cal = new CalendarLocal(); 2964 CalendarLocal* cal = new CalendarLocal();
2961 if ( beamDialog.beamLocal() ) 2965 if ( beamDialog.beamLocal() )
2962 cal->setLocalTime(); 2966 cal->setLocalTime();
2963 else 2967 else
2964 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 2968 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
2965 Incidence *incidence = delSel.first(); 2969 Incidence *incidence = delSel.first();
2966 bool addText = false; 2970 bool addText = false;
2967 if ( delSel.count() < 10 ) 2971 if ( delSel.count() < 10 )
2968 addText = true; 2972 addText = true;
2969 else { 2973 else {
2970 description.sprintf(i18n(" %d items?"),delSel.count() ); 2974 description.sprintf(i18n(" %d items?"),delSel.count() );
2971 } 2975 }
2972 while ( incidence ) { 2976 while ( incidence ) {
2973 Incidence *in = incidence->clone(); 2977 Incidence *in = incidence->clone();
2974 if ( ! in->summary().isEmpty() ) { 2978 if ( ! in->summary().isEmpty() ) {
2975 in->setDescription(""); 2979 in->setDescription("");
2976 } else { 2980 } else {
2977 in->setSummary( in->description().left(20)); 2981 in->setSummary( in->description().left(20));
2978 in->setDescription(""); 2982 in->setDescription("");
2979 } 2983 }
2980 if ( addText ) 2984 if ( addText )
2981 description += in->summary() + "\n"; 2985 description += in->summary() + "\n";
2982 cal->addIncidence( in ); 2986 cal->addIncidence( in );
2983 incidence = delSel.next(); 2987 incidence = delSel.next();
2984 } 2988 }
2985 if ( beamDialog.beamVcal() ) { 2989 if ( beamDialog.beamVcal() ) {
2986 fn += ".vcs"; 2990 fn += ".vcs";
2987 FileStorage storage( cal, fn, new VCalFormat ); 2991 FileStorage storage( cal, fn, new VCalFormat );
2988 storage.save(); 2992 storage.save();
2989 } else { 2993 } else {
2990 fn += ".ics"; 2994 fn += ".ics";
2991 FileStorage storage( cal, fn, new ICalFormat( ) ); 2995 FileStorage storage( cal, fn, new ICalFormat( ) );
2992 storage.save(); 2996 storage.save();
2993 } 2997 }
2994 delete cal; 2998 delete cal;
2995 mes = i18n("KO/Pi: Ready for beaming"); 2999 mes = i18n("KO/Pi: Ready for beaming");
2996 topLevelWidget()->setCaption(mes); 3000 topLevelWidget()->setCaption(mes);
2997 KApplication::convert2latin1( fn ); 3001 KApplication::convert2latin1( fn );
2998#ifndef DESKTOP_VERSION 3002#ifndef DESKTOP_VERSION
2999 Ir *ir = new Ir( this ); 3003 Ir *ir = new Ir( this );
3000 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 3004 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
3001 ir->send( fn, description, "text/x-vCalendar" ); 3005 ir->send( fn, description, "text/x-vCalendar" );
3002#endif 3006#endif
3003 } 3007 }
3004} 3008}
3005 3009
3006#ifndef DESKTOP_VERSION 3010#ifndef DESKTOP_VERSION
3007void CalendarView::beamDone( Ir *ir ) 3011void CalendarView::beamDone( Ir *ir )
3008{ 3012{
3009 delete ir; 3013 delete ir;
3010 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); 3014 topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") );
3011 topLevelWidget()->raise(); 3015 topLevelWidget()->raise();
3012} 3016}
3013#else 3017#else
3014void CalendarView::beamDone( Ir *){;} 3018void CalendarView::beamDone( Ir *){;}
3015#endif 3019#endif
3016void CalendarView::moveIncidence(Incidence * inc ) 3020void CalendarView::moveIncidence(Incidence * inc )
3017{ 3021{
3018 if ( !inc ) return; 3022 if ( !inc ) return;
3019 showDatePickerPopup(); 3023 showDatePickerPopup();
3020 mDatePickerMode = 2; 3024 mDatePickerMode = 2;
3021 mMoveIncidence = inc ; 3025 mMoveIncidence = inc ;
3022 QDate da; 3026 QDate da;
3023 if ( mMoveIncidence->typeID() == todoID ) { 3027 if ( mMoveIncidence->typeID() == todoID ) {
3024 Todo * to = (Todo *) mMoveIncidence; 3028 Todo * to = (Todo *) mMoveIncidence;
3025 if ( to->hasDueDate() ) 3029 if ( to->hasDueDate() )
3026 da = to->dtDue().date(); 3030 da = to->dtDue().date();
3027 else 3031 else
3028 da = QDate::currentDate(); 3032 da = QDate::currentDate();
3029 } else { 3033 } else {
3030 da = mMoveIncidence->dtStart().date(); 3034 da = mMoveIncidence->dtStart().date();
3031 } 3035 }
3032 //PENDING set date for recurring incidence to date of recurrence 3036 //PENDING set date for recurring incidence to date of recurrence
3033 //mMoveIncidenceOldDate; 3037 //mMoveIncidenceOldDate;
3034 mDatePicker->setDate( da ); 3038 mDatePicker->setDate( da );
3035} 3039}
3036void CalendarView::showDatePickerPopup() 3040void CalendarView::showDatePickerPopup()
3037{ 3041{
3038 if ( mDateFrame->isVisible() ) 3042 if ( mDateFrame->isVisible() )
3039 mDateFrame->hide(); 3043 mDateFrame->hide();
3040 else { 3044 else {
3041 int offX = 0, offY = 0; 3045 int offX = 0, offY = 0;
3042#ifdef DESKTOP_VERSION 3046#ifdef DESKTOP_VERSION
3043 int w =mDatePicker->sizeHint().width() ; 3047 int w =mDatePicker->sizeHint().width() ;
3044 int h = mDatePicker->sizeHint().height() ; 3048 int h = mDatePicker->sizeHint().height() ;
3045 int dw = topLevelWidget()->width(); 3049 int dw = topLevelWidget()->width();
3046 int dh = topLevelWidget()->height(); 3050 int dh = topLevelWidget()->height();
3047 offX = topLevelWidget()->x(); 3051 offX = topLevelWidget()->x();
3048 offY = topLevelWidget()->y(); 3052 offY = topLevelWidget()->y();
3049#else 3053#else
3050 int w =mDatePicker->sizeHint().width() ; 3054 int w =mDatePicker->sizeHint().width() ;
3051 int h = mDatePicker->sizeHint().height() ; 3055 int h = mDatePicker->sizeHint().height() ;
3052 int dw = QApplication::desktop()->width(); 3056 int dw = QApplication::desktop()->width();
3053 int dh = QApplication::desktop()->height(); 3057 int dh = QApplication::desktop()->height();
3054#endif 3058#endif
3055 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); 3059 mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h );
3056 mDateFrame->show(); 3060 mDateFrame->show();
3057 } 3061 }
3058} 3062}
3059void CalendarView::showDatePicker( ) 3063void CalendarView::showDatePicker( )
3060{ 3064{
3061 showDatePickerPopup(); 3065 showDatePickerPopup();
3062 mDatePickerMode = 1; 3066 mDatePickerMode = 1;
3063 mDatePicker->setDate( mNavigator->selectedDates().first() ); 3067 mDatePicker->setDate( mNavigator->selectedDates().first() );
3064} 3068}
3065 3069
3066void CalendarView::showEventEditor() 3070void CalendarView::showEventEditor()
3067{ 3071{
3068#ifdef DESKTOP_VERSION 3072#ifdef DESKTOP_VERSION
3069 int x,y,w,h; 3073 int x,y,w,h;
3070 x = mEventEditor->geometry().x(); 3074 x = mEventEditor->geometry().x();
3071 y = mEventEditor->geometry().y(); 3075 y = mEventEditor->geometry().y();
3072 w = mEventEditor->width(); 3076 w = mEventEditor->width();
3073 h = mEventEditor->height(); 3077 h = mEventEditor->height();
3074 mEventEditor->show(); 3078 mEventEditor->show();
3075 mEventEditor->setGeometry(x,y,w,h); 3079 mEventEditor->setGeometry(x,y,w,h);
3076#else 3080#else
3077 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { 3081 if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) {
3078 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3082 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3079 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); 3083 qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() );
3080 qApp->processEvents(); 3084 qApp->processEvents();
3081 delete mEventEditor; 3085 delete mEventEditor;
3082 mEventEditor = mDialogManager->getEventEditor(); 3086 mEventEditor = mDialogManager->getEventEditor();
3083 topLevelWidget()->setCaption( i18n("") ); 3087 topLevelWidget()->setCaption( i18n("") );
3084 } 3088 }
3085 mEventEditor->showMaximized(); 3089 mEventEditor->showMaximized();
3086#endif 3090#endif
3087} 3091}
3088void CalendarView::showTodoEditor() 3092void CalendarView::showTodoEditor()
3089{ 3093{
3090#ifdef DESKTOP_VERSION 3094#ifdef DESKTOP_VERSION
3091 int x,y,w,h; 3095 int x,y,w,h;
3092 x = mTodoEditor->geometry().x(); 3096 x = mTodoEditor->geometry().x();
3093 y = mTodoEditor->geometry().y(); 3097 y = mTodoEditor->geometry().y();
3094 w = mTodoEditor->width(); 3098 w = mTodoEditor->width();
3095 h = mTodoEditor->height(); 3099 h = mTodoEditor->height();
3096 mTodoEditor->show(); 3100 mTodoEditor->show();
3097 mTodoEditor->setGeometry(x,y,w,h); 3101 mTodoEditor->setGeometry(x,y,w,h);
3098#else 3102#else
3099 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { 3103 if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) {
3100 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); 3104 topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") );
3101 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); 3105 qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() );
3102 qApp->processEvents(); 3106 qApp->processEvents();
3103 delete mTodoEditor; 3107 delete mTodoEditor;
3104 mTodoEditor = mDialogManager->getTodoEditor(); 3108 mTodoEditor = mDialogManager->getTodoEditor();
3105 topLevelWidget()->setCaption( i18n("") ); 3109 topLevelWidget()->setCaption( i18n("") );
3106 } 3110 }
3107 mTodoEditor->showMaximized(); 3111 mTodoEditor->showMaximized();
3108#endif 3112#endif
3109} 3113}
3110 3114
3111void CalendarView::cloneIncidence() 3115void CalendarView::cloneIncidence()
3112{ 3116{
3113 Incidence *incidence = currentSelection(); 3117 Incidence *incidence = currentSelection();
3114 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3118 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3115 if ( incidence ) { 3119 if ( incidence ) {
3116 cloneIncidence(incidence); 3120 cloneIncidence(incidence);
3117 } 3121 }
3118} 3122}
3119void CalendarView::moveIncidence() 3123void CalendarView::moveIncidence()
3120{ 3124{
3121 Incidence *incidence = currentSelection(); 3125 Incidence *incidence = currentSelection();
3122 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3126 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3123 if ( incidence ) { 3127 if ( incidence ) {
3124 moveIncidence(incidence); 3128 moveIncidence(incidence);
3125 } 3129 }
3126} 3130}
3127void CalendarView::beamIncidence() 3131void CalendarView::beamIncidence()
3128{ 3132{
3129 Incidence *incidence = currentSelection(); 3133 Incidence *incidence = currentSelection();
3130 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3134 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3131 if ( incidence ) { 3135 if ( incidence ) {
3132 beamIncidence(incidence); 3136 beamIncidence(incidence);
3133 } 3137 }
3134} 3138}
3135void CalendarView::toggleCancelIncidence() 3139void CalendarView::toggleCancelIncidence()
3136{ 3140{
3137 Incidence *incidence = currentSelection(); 3141 Incidence *incidence = currentSelection();
3138 if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); 3142 if ( !incidence ) incidence = mTodoList->selectedIncidences().first();
3139 if ( incidence ) { 3143 if ( incidence ) {
3140 cancelIncidence(incidence); 3144 cancelIncidence(incidence);
3141 } 3145 }
3142} 3146}
3143 3147
3144 3148
3145void CalendarView::cancelIncidence(Incidence * inc ) 3149void CalendarView::cancelIncidence(Incidence * inc )
3146{ 3150{
3147 inc->setCancelled( ! inc->cancelled() ); 3151 inc->setCancelled( ! inc->cancelled() );
3148 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); 3152 changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED );
3149 updateView(); 3153 updateView();
3150} 3154}
3151void CalendarView::cloneIncidence(Incidence * orgInc ) 3155void CalendarView::cloneIncidence(Incidence * orgInc )
3152{ 3156{
3153 Incidence * newInc = orgInc->clone(); 3157 Incidence * newInc = orgInc->clone();
3154 newInc->recreate(); 3158 newInc->recreate();
3155 3159
3156 if ( newInc->typeID() == todoID ) { 3160 if ( newInc->typeID() == todoID ) {
3157 Todo* t = (Todo*) newInc; 3161 Todo* t = (Todo*) newInc;
3158 bool cloneSub = false; 3162 bool cloneSub = false;
3159 if ( orgInc->relations().count() ) { 3163 if ( orgInc->relations().count() ) {
3160 int result = KMessageBox::warningYesNoCancel(this, 3164 int result = KMessageBox::warningYesNoCancel(this,
3161 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ), 3165 i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( newInc->summary().left ( 25 ) ),
3162 i18n("Todo has subtodos"), 3166 i18n("Todo has subtodos"),
3163 i18n("Yes"), 3167 i18n("Yes"),
3164 i18n("No")); 3168 i18n("No"));
3165 3169
3166 if ( result == KMessageBox::Cancel ) { 3170 if ( result == KMessageBox::Cancel ) {
3167 delete t; 3171 delete t;
3168 return; 3172 return;
3169 } 3173 }
3170 if (result == KMessageBox::Yes) cloneSub = true; 3174 if (result == KMessageBox::Yes) cloneSub = true;
3171 } 3175 }
3172 showTodoEditor(); 3176 showTodoEditor();
3173 mTodoEditor->editTodo( t ); 3177 mTodoEditor->editTodo( t );
3174 if ( mTodoEditor->exec() ) { 3178 if ( mTodoEditor->exec() ) {
3175 if ( cloneSub ) { 3179 if ( cloneSub ) {
3176 orgInc->cloneRelations( t ); 3180 orgInc->cloneRelations( t );
3177 mCalendar->addIncidenceBranch( t ); 3181 mCalendar->addIncidenceBranch( t );
3178 updateView(); 3182 updateView();
3179 3183
3180 } else { 3184 } else {
3181 mCalendar->addTodo( t ); 3185 mCalendar->addTodo( t );
3182 updateView(); 3186 updateView();
3183 } 3187 }
3184 } else { 3188 } else {
3185 delete t; 3189 delete t;
3186 } 3190 }
3187 } 3191 }
3188 else { 3192 else if ( newInc->typeID() == eventID ) {
3189 Event* e = (Event*) newInc; 3193 Event* e = (Event*) newInc;
3190 showEventEditor(); 3194 showEventEditor();
3191 mEventEditor->editEvent( e ); 3195 mEventEditor->editEvent( e );
3192 if ( mEventEditor->exec() ) { 3196 if ( mEventEditor->exec() ) {
3193 mCalendar->addEvent( e ); 3197 mCalendar->addEvent( e );
3194 updateView(); 3198 updateView();
3195 } else { 3199 } else {
3196 delete e; 3200 delete e;
3197 } 3201 }
3202 } if ( newInc->typeID() == journalID ) {
3203 mCalendar->addJournal( (Journal*) newInc );
3204 editJournal( (Journal*) newInc );
3198 } 3205 }
3199 setActiveWindow(); 3206 setActiveWindow();
3200} 3207}
3201 3208
3202void CalendarView::newEvent() 3209void CalendarView::newEvent()
3203{ 3210{
3204 // TODO: Replace this code by a common eventDurationHint of KOBaseView. 3211 // TODO: Replace this code by a common eventDurationHint of KOBaseView.
3205 KOAgendaView *aView = mViewManager->agendaView(); 3212 KOAgendaView *aView = mViewManager->agendaView();
3206 if (aView) { 3213 if (aView) {
3207 if (aView->selectionStart().isValid()) { 3214 if (aView->selectionStart().isValid()) {
3208 if (aView->selectedIsAllDay()) { 3215 if (aView->selectedIsAllDay()) {
3209 newEvent(aView->selectionStart(),aView->selectionEnd(),true); 3216 newEvent(aView->selectionStart(),aView->selectionEnd(),true);
3210 } else { 3217 } else {
3211 newEvent(aView->selectionStart(),aView->selectionEnd()); 3218 newEvent(aView->selectionStart(),aView->selectionEnd());
3212 } 3219 }
3213 return; 3220 return;
3214 } 3221 }
3215 } 3222 }
3216 3223
3217 QDate date = mNavigator->selectedDates().first(); 3224 QDate date = mNavigator->selectedDates().first();
3218 QDateTime current = QDateTime::currentDateTime(); 3225 QDateTime current = QDateTime::currentDateTime();
3219 if ( date <= current.date() ) { 3226 if ( date <= current.date() ) {
3220 int hour = current.time().hour() +1; 3227 int hour = current.time().hour() +1;
3221 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), 3228 newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ),
3222 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3229 QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3223 } else 3230 } else
3224 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), 3231 newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ),
3225 QDateTime( date, QTime( KOPrefs::instance()->mStartTime + 3232 QDateTime( date, QTime( KOPrefs::instance()->mStartTime +
3226 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); 3233 KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) );
3227} 3234}
3228 3235
3229void CalendarView::newEvent(QDateTime fh) 3236void CalendarView::newEvent(QDateTime fh)
3230{ 3237{
3231 newEvent(fh, 3238 newEvent(fh,
3232 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); 3239 QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration)));
3233} 3240}
3234 3241
3235void CalendarView::newEvent(QDate dt) 3242void CalendarView::newEvent(QDate dt)
3236{ 3243{
3237 newEvent(QDateTime(dt, QTime(0,0,0)), 3244 newEvent(QDateTime(dt, QTime(0,0,0)),
3238 QDateTime(dt, QTime(0,0,0)), true); 3245 QDateTime(dt, QTime(0,0,0)), true);
3239} 3246}
3240void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) 3247void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint)
3241{ 3248{
3242 newEvent(fromHint, toHint, false); 3249 newEvent(fromHint, toHint, false);
3243} 3250}
3244void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) 3251void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay)
3245{ 3252{
3246 3253
3247 showEventEditor(); 3254 showEventEditor();
3248 mEventEditor->newEvent(fromHint,toHint,allDay); 3255 mEventEditor->newEvent(fromHint,toHint,allDay);
3249 if ( mFilterView->filtersEnabled() ) { 3256 if ( mFilterView->filtersEnabled() ) {
3250 CalFilter *filter = mFilterView->selectedFilter(); 3257 CalFilter *filter = mFilterView->selectedFilter();
3251 if (filter && filter->showCategories()) { 3258 if (filter && filter->showCategories()) {
3252 mEventEditor->setCategories(filter->categoryList().join(",") ); 3259 mEventEditor->setCategories(filter->categoryList().join(",") );
3253 } 3260 }
3254 if ( filter ) 3261 if ( filter )
3255 mEventEditor->setSecrecy( filter->getSecrecy() ); 3262 mEventEditor->setSecrecy( filter->getSecrecy() );
3256 } 3263 }
3257 mEventEditor->exec(); 3264 mEventEditor->exec();
3258 setActiveWindow(); 3265 setActiveWindow();
3259} 3266}
3260void CalendarView::todoAdded(Todo * t) 3267void CalendarView::todoAdded(Todo * t)
3261{ 3268{
3262 3269
3263 changeTodoDisplay ( t ,KOGlobals::EVENTADDED); 3270 changeTodoDisplay ( t ,KOGlobals::EVENTADDED);
3264 updateTodoViews(); 3271 updateTodoViews();
3265} 3272}
3266void CalendarView::todoChanged(Todo * t) 3273void CalendarView::todoChanged(Todo * t)
3267{ 3274{
3268 emit todoModified( t, 4 ); 3275 emit todoModified( t, 4 );
3269 // updateTodoViews(); 3276 // updateTodoViews();
3270} 3277}
3271void CalendarView::todoToBeDeleted(Todo *) 3278void CalendarView::todoToBeDeleted(Todo *)
3272{ 3279{
3273 //qDebug("todoToBeDeleted(Todo *) "); 3280 //qDebug("todoToBeDeleted(Todo *) ");
3274 updateTodoViews(); 3281 updateTodoViews();
3275} 3282}
3276void CalendarView::todoDeleted() 3283void CalendarView::todoDeleted()
3277{ 3284{
3278 //qDebug(" todoDeleted()"); 3285 //qDebug(" todoDeleted()");
3279 updateTodoViews(); 3286 updateTodoViews();
3280} 3287}
3281 3288
3282 3289
3283void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) 3290void CalendarView::newTodoDateTime( QDateTime dt, bool allday )
3284{ 3291{
3285 showTodoEditor(); 3292 showTodoEditor();
3286 mTodoEditor->newTodo(dt,0,allday); 3293 mTodoEditor->newTodo(dt,0,allday);
3287 if ( mFilterView->filtersEnabled() ) { 3294 if ( mFilterView->filtersEnabled() ) {
3288 CalFilter *filter = mFilterView->selectedFilter(); 3295 CalFilter *filter = mFilterView->selectedFilter();
3289 if (filter && filter->showCategories()) { 3296 if (filter && filter->showCategories()) {
3290 mTodoEditor->setCategories(filter->categoryList().join(",") ); 3297 mTodoEditor->setCategories(filter->categoryList().join(",") );
3291 } 3298 }
3292 if ( filter ) 3299 if ( filter )
3293 mTodoEditor->setSecrecy( filter->getSecrecy() ); 3300 mTodoEditor->setSecrecy( filter->getSecrecy() );
3294 } 3301 }
3295 mTodoEditor->exec(); 3302 mTodoEditor->exec();
3296 setActiveWindow(); 3303 setActiveWindow();
3297} 3304}
3298 3305
3299void CalendarView::newTodo() 3306void CalendarView::newTodo()
3300{ 3307{
3301 newTodoDateTime( QDateTime(),true ); 3308 newTodoDateTime( QDateTime(),true );
3302} 3309}
3303 3310
3304void CalendarView::newSubTodo() 3311void CalendarView::newSubTodo()
3305{ 3312{
3306 Todo *todo = selectedTodo(); 3313 Todo *todo = selectedTodo();
3307 if ( todo ) newSubTodo( todo ); 3314 if ( todo ) newSubTodo( todo );
3308} 3315}
3309 3316
3310void CalendarView::newSubTodo(Todo *parentEvent) 3317void CalendarView::newSubTodo(Todo *parentEvent)
3311{ 3318{
3312 3319
3313 showTodoEditor(); 3320 showTodoEditor();
3314 mTodoEditor->newTodo(QDateTime(),parentEvent,true); 3321 mTodoEditor->newTodo(QDateTime(),parentEvent,true);
3315 mTodoEditor->exec(); 3322 mTodoEditor->exec();
3316 setActiveWindow(); 3323 setActiveWindow();
3317} 3324}
3318 3325
3319void CalendarView::newFloatingEvent() 3326void CalendarView::newFloatingEvent()
3320{ 3327{
3321 DateList tmpList = mNavigator->selectedDates(); 3328 DateList tmpList = mNavigator->selectedDates();
3322 QDate date = tmpList.first(); 3329 QDate date = tmpList.first();
3323 3330
3324 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), 3331 newEvent( QDateTime( date, QTime( 12, 0, 0 ) ),
3325 QDateTime( date, QTime( 12, 0, 0 ) ), true ); 3332 QDateTime( date, QTime( 12, 0, 0 ) ), true );
3326} 3333}
3327 3334
3328 3335
3329void CalendarView::editEvent( Event *event ) 3336void CalendarView::editEvent( Event *event )
3330{ 3337{
3331 3338
3332 if ( !event ) return; 3339 if ( !event ) return;
3333 if ( event->isReadOnly() ) { 3340 if ( event->isReadOnly() ) {
3334 showEvent( event ); 3341 showEvent( event );
3335 return; 3342 return;
3336 } 3343 }
3337 showEventEditor(); 3344 showEventEditor();
3338 mEventEditor->editEvent( event , mFlagEditDescription); 3345 mEventEditor->editEvent( event , mFlagEditDescription);
3339 mEventEditor->exec(); 3346 mEventEditor->exec();
3340 setActiveWindow(); 3347 setActiveWindow();
3341 3348
3342} 3349}
3343void CalendarView::editJournal( Journal *jour ) 3350void CalendarView::editJournal( Journal *jour )
3344{ 3351{
3345 if ( !jour ) return; 3352 if ( !jour ) return;
3346 mDialogManager->hideSearchDialog(); 3353 mDialogManager->hideSearchDialog();
3347 mViewManager->showJournalView(); 3354 mViewManager->showJournalView();
3348 mNavigator->slotDaySelect( jour->dtStart().date() ); 3355 mNavigator->slotDaySelect( jour->dtStart().date() );
3349} 3356}
3350void CalendarView::editTodo( Todo *todo ) 3357void CalendarView::editTodo( Todo *todo )
3351{ 3358{
3352 if ( !todo ) return; 3359 if ( !todo ) return;
3353 3360
3354 if ( todo->isReadOnly() ) { 3361 if ( todo->isReadOnly() ) {
3355 showTodo( todo ); 3362 showTodo( todo );
3356 return; 3363 return;
3357 } 3364 }
3358 showTodoEditor(); 3365 showTodoEditor();
3359 mTodoEditor->editTodo( todo ,mFlagEditDescription); 3366 mTodoEditor->editTodo( todo ,mFlagEditDescription);
3360 mTodoEditor->exec(); 3367 mTodoEditor->exec();
3361 setActiveWindow(); 3368 setActiveWindow();
3362 3369
3363} 3370}
3364 3371
3365KOEventViewerDialog* CalendarView::getEventViewerDialog() 3372KOEventViewerDialog* CalendarView::getEventViewerDialog()
3366{ 3373{
3367 if ( !mEventViewerDialog ) { 3374 if ( !mEventViewerDialog ) {
3368 mEventViewerDialog = new KOEventViewerDialog(0); 3375 mEventViewerDialog = new KOEventViewerDialog(0);
3369 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); 3376 connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) );
3370 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); 3377 connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig()));
3371 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), 3378 connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)),
3372 dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); 3379 dateNavigator(), SLOT( selectWeek( const QDate & ) ) );
3373 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), 3380 connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ),
3374 viewManager(), SLOT( showAgendaView( bool ) ) ); 3381 viewManager(), SLOT( showAgendaView( bool ) ) );
3375 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), 3382 connect( mEventViewerDialog, SIGNAL(signalViewerClosed()),
3376 this, SLOT( slotViewerClosed() ) ); 3383 this, SLOT( slotViewerClosed() ) );
3377 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), 3384 connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ),
3378 this, SLOT( todoChanged(Todo *) ) ); 3385 this, SLOT( todoChanged(Todo *) ) );
3379 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); 3386 connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) ));
3380 mEventViewerDialog->resize( 640, 480 ); 3387 mEventViewerDialog->resize( 640, 480 );
3381 3388
3382 } 3389 }
3383 return mEventViewerDialog; 3390 return mEventViewerDialog;
3384} 3391}
3385void CalendarView::showEvent(Event *event) 3392void CalendarView::showEvent(Event *event)
3386{ 3393{
3387 getEventViewerDialog()->setEvent(event); 3394 getEventViewerDialog()->setEvent(event);
3388 getEventViewerDialog()->showMe(); 3395 getEventViewerDialog()->showMe();
3389} 3396}
3390 3397
3391void CalendarView::showTodo(Todo *event) 3398void CalendarView::showTodo(Todo *event)
3392{ 3399{
3393 getEventViewerDialog()->setTodo(event); 3400 getEventViewerDialog()->setTodo(event);
3394 getEventViewerDialog()->showMe(); 3401 getEventViewerDialog()->showMe();
3395} 3402}
3396void CalendarView::showJournal( Journal *jour ) 3403void CalendarView::showJournal( Journal *jour )
3397{ 3404{
3398 getEventViewerDialog()->setJournal(jour); 3405 getEventViewerDialog()->setJournal(jour);
3399 getEventViewerDialog()->showMe(); 3406 getEventViewerDialog()->showMe();
3400 3407
3401} 3408}
3402// void CalendarView::todoModified (Todo *event, int changed) 3409// void CalendarView::todoModified (Todo *event, int changed)
3403// { 3410// {
3404// // if (mDialogList.find (event) != mDialogList.end ()) { 3411// // if (mDialogList.find (event) != mDialogList.end ()) {
3405// // kdDebug() << "Todo modified and open" << endl; 3412// // kdDebug() << "Todo modified and open" << endl;
3406// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; 3413// // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event];
3407// // temp->modified (changed); 3414// // temp->modified (changed);
3408 3415
3409// // } 3416// // }
3410 3417
3411// mViewManager->updateView(); 3418// mViewManager->updateView();
3412// } 3419// }
3413 3420
3414void CalendarView::appointment_show() 3421void CalendarView::appointment_show()
3415{ 3422{
3416 Event *anEvent = 0; 3423 Event *anEvent = 0;
3417 3424
3418 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3425 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3419 3426
3420 if (mViewManager->currentView()->isEventView()) { 3427 if (mViewManager->currentView()->isEventView()) {
3421 if ( incidence && incidence->typeID() == eventID ) { 3428 if ( incidence && incidence->typeID() == eventID ) {
3422 anEvent = static_cast<Event *>(incidence); 3429 anEvent = static_cast<Event *>(incidence);
3423 } 3430 }
3424 } 3431 }
3425 3432
3426 if (!anEvent) { 3433 if (!anEvent) {
3427 KNotifyClient::beep(); 3434 KNotifyClient::beep();
3428 return; 3435 return;
3429 } 3436 }
3430 3437
3431 showEvent(anEvent); 3438 showEvent(anEvent);
3432} 3439}
3433 3440
3434void CalendarView::appointment_edit() 3441void CalendarView::appointment_edit()
3435{ 3442{
3436 Event *anEvent = 0; 3443 Event *anEvent = 0;
3437 3444
3438 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3445 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3439 3446
3440 if (mViewManager->currentView()->isEventView()) { 3447 if (mViewManager->currentView()->isEventView()) {
3441 if ( incidence && incidence->typeID() == eventID ) { 3448 if ( incidence && incidence->typeID() == eventID ) {
3442 anEvent = static_cast<Event *>(incidence); 3449 anEvent = static_cast<Event *>(incidence);
3443 } 3450 }
3444 } 3451 }
3445 3452
3446 if (!anEvent) { 3453 if (!anEvent) {
3447 KNotifyClient::beep(); 3454 KNotifyClient::beep();
3448 return; 3455 return;
3449 } 3456 }
3450 3457
3451 editEvent(anEvent); 3458 editEvent(anEvent);
3452} 3459}
3453 3460
3454void CalendarView::appointment_delete() 3461void CalendarView::appointment_delete()
3455{ 3462{
3456 Event *anEvent = 0; 3463 Event *anEvent = 0;
3457 3464
3458 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); 3465 Incidence *incidence = mViewManager->currentView()->selectedIncidences().first();
3459 3466
3460 if (mViewManager->currentView()->isEventView()) { 3467 if (mViewManager->currentView()->isEventView()) {
3461 if ( incidence && incidence->typeID() == eventID ) { 3468 if ( incidence && incidence->typeID() == eventID ) {
3462 anEvent = static_cast<Event *>(incidence); 3469 anEvent = static_cast<Event *>(incidence);
3463 } 3470 }
3464 } 3471 }
3465 3472
3466 if (!anEvent) { 3473 if (!anEvent) {
3467 KNotifyClient::beep(); 3474 KNotifyClient::beep();
3468 return; 3475 return;
3469 } 3476 }
3470 3477
3471 deleteEvent(anEvent); 3478 deleteEvent(anEvent);
3472} 3479}
3473 3480
3474void CalendarView::todo_resub( Todo * parent, Todo * sub ) 3481void CalendarView::todo_resub( Todo * parent, Todo * sub )
3475{ 3482{
3476 if (!sub) return; 3483 if (!sub) return;
3477 if ( sub->relatedTo() == parent ) 3484 if ( sub->relatedTo() == parent )
3478 return; 3485 return;
3479 sub->setRelatedTo(parent); 3486 sub->setRelatedTo(parent);
3480 sub->updated(); 3487 sub->updated();
3481 setModified(true); 3488 setModified(true);
3482 updateView(); 3489 updateView();
3483} 3490}
3484void CalendarView::todo_unsub(Todo *anTodo ) 3491void CalendarView::todo_unsub(Todo *anTodo )
3485{ 3492{
3486 todo_resub( 0, anTodo ); 3493 todo_resub( 0, anTodo );
3487} 3494}
3488 3495
3489void CalendarView::deleteTodo(Todo *todo) 3496void CalendarView::deleteTodo(Todo *todo)
3490{ 3497{
3491 if (!todo) { 3498 if (!todo) {
3492 KNotifyClient::beep(); 3499 KNotifyClient::beep();
3493 return; 3500 return;
3494 } 3501 }
3495 if (KOPrefs::instance()->mConfirm) { 3502 if (KOPrefs::instance()->mConfirm) {
3496 QString text = todo->summary().left(20); 3503 QString text = todo->summary().left(20);
3497 if (!todo->relations().isEmpty()) { 3504 if (!todo->relations().isEmpty()) {
3498 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); 3505 text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!");
3499 3506
3500 } 3507 }
3501 switch (msgItemDelete(text)) { 3508 switch (msgItemDelete(i18n("Todo:") +"\n"+text)) {
3502 case KMessageBox::Continue: // OK 3509 case KMessageBox::Continue: // OK
3503 bool deleteT = false; 3510 bool deleteT = false;
3504 if (!todo->relations().isEmpty()) { 3511 if (!todo->relations().isEmpty()) {
3505 deleteT = removeCompletedSubTodos( todo ); 3512 deleteT = removeCompletedSubTodos( todo );
3506 } 3513 }
3507 // deleteT == true: todo already deleted in removeCompletedSubTodos 3514 // deleteT == true: todo already deleted in removeCompletedSubTodos
3508 if ( !deleteT ) { 3515 if ( !deleteT ) {
3509 checkExternalId( todo ); 3516 checkExternalId( todo );
3510 calendar()->deleteTodo(todo); 3517 calendar()->deleteTodo(todo);
3511 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3518 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3512 updateView(); 3519 updateView();
3513 } 3520 }
3514 break; 3521 break;
3515 } // switch 3522 } // switch
3516 } else { 3523 } else {
3517 checkExternalId( todo ); 3524 checkExternalId( todo );
3518 mCalendar->deleteTodo(todo); 3525 mCalendar->deleteTodo(todo);
3519 changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); 3526 changeTodoDisplay( todo,KOGlobals::EVENTDELETED );
3520 updateView(); 3527 updateView();
3521 } 3528 }
3522 3529
3523 emit updateSearchDialog(); 3530 emit updateSearchDialog();
3524} 3531}
3525void CalendarView::deleteJournal(Journal *jour) 3532void CalendarView::deleteJournal(Journal *jour)
3526{ 3533{
3527 if (!jour) { 3534 if (!jour) {
3528 KNotifyClient::beep(); 3535 KNotifyClient::beep();
3529 return; 3536 return;
3530 } 3537 }
3531 if (KOPrefs::instance()->mConfirm) { 3538 if (KOPrefs::instance()->mConfirm) {
3532 switch (msgItemDelete( jour->description().left(20))) { 3539
3540 QString des;
3541 if ( !jour->summary().isEmpty() ) {
3542 des = jour->summary();
3543 } else {
3544 des = jour->description().left(30);
3545 des = des.simplifyWhiteSpace ();
3546 des.replace (QRegExp ("\\n"),"" );
3547 des.replace (QRegExp ("\\r"),"" );
3548 }
3549 switch (msgItemDelete( i18n("Journal:") +"\n"+des.left(20))) {
3533 case KMessageBox::Continue: // OK 3550 case KMessageBox::Continue: // OK
3534 calendar()->deleteJournal(jour); 3551 calendar()->deleteJournal(jour);
3535 updateView(); 3552 updateView();
3536 break; 3553 break;
3537 } // switch 3554 } // switch
3538 } else { 3555 } else {
3539 calendar()->deleteJournal(jour);; 3556 calendar()->deleteJournal(jour);;
3540 updateView(); 3557 updateView();
3541 } 3558 }
3542 emit updateSearchDialog(); 3559 emit updateSearchDialog();
3543} 3560}
3544 3561
3545void CalendarView::deleteEvent(Event *anEvent) 3562void CalendarView::deleteEvent(Event *anEvent)
3546{ 3563{
3547 if (!anEvent) { 3564 if (!anEvent) {
3548 KNotifyClient::beep(); 3565 KNotifyClient::beep();
3549 return; 3566 return;
3550 } 3567 }
3551 3568
3552 if (anEvent->recurrence()->doesRecur()) { 3569 if (anEvent->recurrence()->doesRecur()) {
3553 QDate itemDate = mViewManager->currentSelectionDate(); 3570 QDate itemDate = mViewManager->currentSelectionDate();
3554 int km; 3571 int km;
3555 if (!itemDate.isValid()) { 3572 if (!itemDate.isValid()) {
3556 //kdDebug() << "Date Not Valid" << endl; 3573 //kdDebug() << "Date Not Valid" << endl;
3557 if (KOPrefs::instance()->mConfirm) { 3574 if (KOPrefs::instance()->mConfirm) {
3558 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3575 km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3559 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), 3576 i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"),
3560 i18n("KO/Pi Confirmation"),i18n("Delete All")); 3577 i18n("KO/Pi Confirmation"),i18n("Delete All"));
3561 if ( km == KMessageBox::Continue ) 3578 if ( km == KMessageBox::Continue )
3562 km = KMessageBox::No; // No = all below 3579 km = KMessageBox::No; // No = all below
3563 } else 3580 } else
3564 km = KMessageBox::No; 3581 km = KMessageBox::No;
3565 } else { 3582 } else {
3566 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + 3583 km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) +
3567 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ 3584 i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+
3568 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), 3585 KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"),
3569 i18n("KO/Pi Confirmation"),i18n("Current"), 3586 i18n("KO/Pi Confirmation"),i18n("Current"),
3570 i18n("All")); 3587 i18n("All"));
3571 } 3588 }
3572 switch(km) { 3589 switch(km) {
3573 3590
3574 case KMessageBox::No: // Continue // all 3591 case KMessageBox::No: // Continue // all
3575 //qDebug("KMessageBox::No "); 3592 //qDebug("KMessageBox::No ");
3576 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3593 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3577 schedule(Scheduler::Cancel,anEvent); 3594 schedule(Scheduler::Cancel,anEvent);
3578 3595
3579 checkExternalId( anEvent); 3596 checkExternalId( anEvent);
3580 mCalendar->deleteEvent(anEvent); 3597 mCalendar->deleteEvent(anEvent);
3581 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); 3598 changeEventDisplay(anEvent,KOGlobals::EVENTDELETED);
3582 break; 3599 break;
3583 3600
3584 // Disabled because it does not work 3601 // Disabled because it does not work
3585 //#if 0 3602 //#if 0
3586 case KMessageBox::Yes: // just this one 3603 case KMessageBox::Yes: // just this one
3587 //QDate qd = mNavigator->selectedDates().first(); 3604 //QDate qd = mNavigator->selectedDates().first();
3588 //if (!qd.isValid()) { 3605 //if (!qd.isValid()) {
3589 // kdDebug() << "no date selected, or invalid date" << endl; 3606 // kdDebug() << "no date selected, or invalid date" << endl;
3590 // KNotifyClient::beep(); 3607 // KNotifyClient::beep();
3591 // return; 3608 // return;
3592 //} 3609 //}
3593 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); 3610 //while (!anEvent->recursOn(qd)) qd = qd.addDays(1);
3594 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { 3611 if (itemDate!=QDate(1,1,1) || itemDate.isValid()) {
3595 anEvent->addExDate(itemDate); 3612 anEvent->addExDate(itemDate);
3596 int duration = anEvent->recurrence()->duration(); 3613 int duration = anEvent->recurrence()->duration();
3597 if ( duration > 0 ) { 3614 if ( duration > 0 ) {
3598 anEvent->recurrence()->setDuration( duration - 1 ); 3615 anEvent->recurrence()->setDuration( duration - 1 );
3599 } 3616 }
3600 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); 3617 changeEventDisplay(anEvent, KOGlobals::EVENTEDITED);
3601 } 3618 }
3602 break; 3619 break;
3603 //#endif 3620 //#endif
3604 } // switch 3621 } // switch
3605 } else { 3622 } else {
3606 if (KOPrefs::instance()->mConfirm) { 3623 if (KOPrefs::instance()->mConfirm) {
3607 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + 3624 switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) +
3608 i18n("\nAre you sure you want\nto delete this event?"), 3625 i18n("\nAre you sure you want\nto delete this event?"),
3609 i18n("KO/Pi Confirmation"),i18n("Delete"))) { 3626 i18n("KO/Pi Confirmation"),i18n("Delete"))) {
3610 case KMessageBox::Continue: // OK 3627 case KMessageBox::Continue: // OK
3611 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3628 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3612 schedule(Scheduler::Cancel,anEvent); 3629 schedule(Scheduler::Cancel,anEvent);
3613 checkExternalId( anEvent); 3630 checkExternalId( anEvent);
3614 mCalendar->deleteEvent(anEvent); 3631 mCalendar->deleteEvent(anEvent);
3615 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3632 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3616 break; 3633 break;
3617 } // switch 3634 } // switch
3618 } else { 3635 } else {
3619 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) 3636 if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0)
3620 schedule(Scheduler::Cancel,anEvent); 3637 schedule(Scheduler::Cancel,anEvent);
3621 checkExternalId( anEvent); 3638 checkExternalId( anEvent);
3622 mCalendar->deleteEvent(anEvent); 3639 mCalendar->deleteEvent(anEvent);
3623 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED); 3640 changeEventDisplay(anEvent, KOGlobals::EVENTDELETED);
3624 } 3641 }
3625 } // if-else 3642 } // if-else
3626 emit updateSearchDialog(); 3643 emit updateSearchDialog();
3627} 3644}
3628 3645
3629bool CalendarView::deleteEvent(const QString &uid) 3646bool CalendarView::deleteEvent(const QString &uid)
3630{ 3647{
3631 Event *ev = mCalendar->event(uid); 3648 Event *ev = mCalendar->event(uid);
3632 if (ev) { 3649 if (ev) {
3633 deleteEvent(ev); 3650 deleteEvent(ev);
3634 return true; 3651 return true;
3635 } else { 3652 } else {
3636 return false; 3653 return false;
3637 } 3654 }
3638} 3655}
3639 3656
3640/*****************************************************************************/ 3657/*****************************************************************************/
3641 3658
3642void CalendarView::action_mail() 3659void CalendarView::action_mail()
3643{ 3660{
3644#ifndef KORG_NOMAIL 3661#ifndef KORG_NOMAIL
3645 KOMailClient mailClient; 3662 KOMailClient mailClient;
3646 3663
3647 Incidence *incidence = currentSelection(); 3664 Incidence *incidence = currentSelection();
3648 3665
3649 if (!incidence) { 3666 if (!incidence) {
3650 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3667 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3651 return; 3668 return;
3652 } 3669 }
3653 if(incidence->attendeeCount() == 0 ) { 3670 if(incidence->attendeeCount() == 0 ) {
3654 KMessageBox::sorry(this, 3671 KMessageBox::sorry(this,
3655 i18n("Can't generate mail:\nNo attendees defined.\n")); 3672 i18n("Can't generate mail:\nNo attendees defined.\n"));
3656 return; 3673 return;
3657 } 3674 }
3658 3675
3659 CalendarLocal cal_tmp; 3676 CalendarLocal cal_tmp;
3660 Event *event = 0; 3677 Event *event = 0;
3661 Event *ev = 0; 3678 Event *ev = 0;
3662 if ( incidence && incidence->typeID() == eventID ) { 3679 if ( incidence && incidence->typeID() == eventID ) {
3663 event = static_cast<Event *>(incidence); 3680 event = static_cast<Event *>(incidence);
3664 ev = new Event(*event); 3681 ev = new Event(*event);
3665 cal_tmp.addEvent(ev); 3682 cal_tmp.addEvent(ev);
3666 } 3683 }
3667 ICalFormat mForm(); 3684 ICalFormat mForm();
3668 QString attachment = mForm.toString( &cal_tmp ); 3685 QString attachment = mForm.toString( &cal_tmp );
3669 if (ev) delete(ev); 3686 if (ev) delete(ev);
3670 3687
3671 mailClient.mailAttendees(currentSelection(), attachment); 3688 mailClient.mailAttendees(currentSelection(), attachment);
3672 3689
3673#endif 3690#endif
3674 3691
3675#if 0 3692#if 0
3676 Event *anEvent = 0; 3693 Event *anEvent = 0;
3677 if (mViewManager->currentView()->isEventView()) { 3694 if (mViewManager->currentView()->isEventView()) {
3678 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); 3695 anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first());
3679 } 3696 }
3680 3697
3681 if (!anEvent) { 3698 if (!anEvent) {
3682 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); 3699 KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected."));
3683 return; 3700 return;
3684 } 3701 }
3685 if(anEvent->attendeeCount() == 0 ) { 3702 if(anEvent->attendeeCount() == 0 ) {
3686 KMessageBox::sorry(this, 3703 KMessageBox::sorry(this,
3687 i18n("Can't generate mail:\nNo attendees defined.\n")); 3704 i18n("Can't generate mail:\nNo attendees defined.\n"));
3688 return; 3705 return;
3689 } 3706 }
3690 3707
3691 mailobject.emailEvent(anEvent); 3708 mailobject.emailEvent(anEvent);
3692#endif 3709#endif
3693} 3710}
3694 3711
3695 3712
3696void CalendarView::schedule_publish(Incidence *incidence) 3713void CalendarView::schedule_publish(Incidence *incidence)
3697{ 3714{
3698 Event *event = 0; 3715 Event *event = 0;
3699 Todo *todo = 0; 3716 Todo *todo = 0;
3700 3717
3701 if (incidence == 0) { 3718 if (incidence == 0) {
3702 incidence = mViewManager->currentView()->selectedIncidences().first(); 3719 incidence = mViewManager->currentView()->selectedIncidences().first();
3703 if (incidence == 0) { 3720 if (incidence == 0) {
3704 incidence = mTodoList->selectedIncidences().first(); 3721 incidence = mTodoList->selectedIncidences().first();
3705 } 3722 }
3706 } 3723 }
3707 if ( incidence && incidence->typeID() == eventID ) { 3724 if ( incidence && incidence->typeID() == eventID ) {
3708 event = static_cast<Event *>(incidence); 3725 event = static_cast<Event *>(incidence);
3709 } else { 3726 } else {
3710 if ( incidence && incidence->typeID() == todoID ) { 3727 if ( incidence && incidence->typeID() == todoID ) {
3711 todo = static_cast<Todo *>(incidence); 3728 todo = static_cast<Todo *>(incidence);
3712 } 3729 }
3713 } 3730 }
3714 3731
3715 if (!event && !todo) { 3732 if (!event && !todo) {
3716 KMessageBox::sorry(this,i18n("No event selected.")); 3733 KMessageBox::sorry(this,i18n("No event selected."));
3717 return; 3734 return;
3718 } 3735 }
3719 3736
3720 PublishDialog *publishdlg = new PublishDialog(); 3737 PublishDialog *publishdlg = new PublishDialog();
3721 if (incidence->attendeeCount()>0) { 3738 if (incidence->attendeeCount()>0) {
3722 QPtrList<Attendee> attendees = incidence->attendees(); 3739 QPtrList<Attendee> attendees = incidence->attendees();
3723 attendees.first(); 3740 attendees.first();
3724 while ( attendees.current()!=0 ) { 3741 while ( attendees.current()!=0 ) {
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5f90dc6..7783dd4 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -782,411 +782,413 @@ void KOListView::writeToFile( bool iCal )
782 782
783 if ( fn == "" ) 783 if ( fn == "" )
784 return; 784 return;
785 QFileInfo info; 785 QFileInfo info;
786 info.setFile( fn ); 786 info.setFile( fn );
787 QString mes; 787 QString mes;
788 bool createbup = true; 788 bool createbup = true;
789 if ( info. exists() ) { 789 if ( info. exists() ) {
790 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 790 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
791 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 791 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
792 i18n("Overwrite!"), i18n("Cancel"), 0, 792 i18n("Overwrite!"), i18n("Cancel"), 0,
793 0, 1 ); 793 0, 1 );
794 if ( result != 0 ) { 794 if ( result != 0 ) {
795 createbup = false; 795 createbup = false;
796 } 796 }
797 } 797 }
798 if ( createbup ) { 798 if ( createbup ) {
799 CalendarLocal cal; 799 CalendarLocal cal;
800 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 800 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
801 Incidence *incidence = delSel.first(); 801 Incidence *incidence = delSel.first();
802 while ( incidence ) { 802 while ( incidence ) {
803 cal.addIncidence( incidence->clone() ); 803 cal.addIncidence( incidence->clone() );
804 incidence = delSel.next(); 804 incidence = delSel.next();
805 } 805 }
806 if ( iCal ) { 806 if ( iCal ) {
807 ICalFormat format; 807 ICalFormat format;
808 format.save( &cal, fn ); 808 format.save( &cal, fn );
809 } else { 809 } else {
810 810
811 VCalFormat format; 811 VCalFormat format;
812 format.save( &cal, fn ); 812 format.save( &cal, fn );
813 } 813 }
814 mes = i18n("KO/Pi:Saved %1").arg(fn ); 814 mes = i18n("KO/Pi:Saved %1").arg(fn );
815 KOPrefs::instance()->mLastSaveFile = fn; 815 KOPrefs::instance()->mLastSaveFile = fn;
816 topLevelWidget()->setCaption(mes); 816 topLevelWidget()->setCaption(mes);
817 } 817 }
818 } 818 }
819 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 819 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
820} 820}
821void KOListView::hideAll() 821void KOListView::hideAll()
822{ 822{
823 QPtrList<QListViewItem> delSel ; 823 QPtrList<QListViewItem> delSel ;
824 QListViewItem *item = mListView->firstChild (); 824 QListViewItem *item = mListView->firstChild ();
825 while ( item ) { 825 while ( item ) {
826 if ( item->isSelected() ) { 826 if ( item->isSelected() ) {
827 delSel.append(item); 827 delSel.append(item);
828 } 828 }
829 item = item->nextSibling(); 829 item = item->nextSibling();
830 } 830 }
831 item = delSel.first() ; 831 item = delSel.first() ;
832 while ( item ) { 832 while ( item ) {
833 QListViewItem * del = item; 833 QListViewItem * del = item;
834 item = delSel.next(); 834 item = delSel.next();
835 delete del; 835 delete del;
836 } 836 }
837} 837}
838void KOListView::printList() 838void KOListView::printList()
839{ 839{
840 mListView->printList(); 840 mListView->printList();
841} 841}
842void KOListView::deleteAll() 842void KOListView::deleteAll()
843{ 843{
844 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;; 844 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
845 if ( delSel.count() ) { 845 if ( delSel.count() ) {
846 int icount = delSel.count(); 846 int icount = delSel.count();
847 Incidence *incidence = delSel.first(); 847 Incidence *incidence = delSel.first();
848 Incidence *toDelete; 848 Incidence *toDelete;
849 KOPrefs *p = KOPrefs::instance(); 849 KOPrefs *p = KOPrefs::instance();
850 bool confirm = p->mConfirm; 850 bool confirm = p->mConfirm;
851 QString mess; 851 QString mess;
852 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 852 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
853 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 853 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
854 p->mConfirm = false; 854 p->mConfirm = false;
855 int delCounter = 0; 855 int delCounter = 0;
856 QDialog dia ( this, "p-dialog", true ); 856 QDialog dia ( this, "p-dialog", true );
857 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 857 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
858 QVBoxLayout lay( &dia ); 858 QVBoxLayout lay( &dia );
859 lay.setMargin(7); 859 lay.setMargin(7);
860 lay.setSpacing(7); 860 lay.setSpacing(7);
861 lay.addWidget( &lab); 861 lay.addWidget( &lab);
862 QProgressBar bar( icount, &dia ); 862 QProgressBar bar( icount, &dia );
863 lay.addWidget( &bar); 863 lay.addWidget( &bar);
864 int w = 220; 864 int w = 220;
865 int h = 50; 865 int h = 50;
866 int dw = QApplication::desktop()->width(); 866 int dw = QApplication::desktop()->width();
867 int dh = QApplication::desktop()->height(); 867 int dh = QApplication::desktop()->height();
868 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 868 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
869 //dia.resize( 240,50 ); 869 //dia.resize( 240,50 );
870 dia.show(); 870 dia.show();
871 KOPrefs::instance()->mGlobalUpdateDisabled = true; 871 KOPrefs::instance()->mGlobalUpdateDisabled = true;
872 while ( incidence ) { 872 while ( incidence ) {
873 bar.setProgress( delCounter ); 873 bar.setProgress( delCounter );
874 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 874 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
875 dia.setCaption( mess ); 875 dia.setCaption( mess );
876 qApp->processEvents(); 876 qApp->processEvents();
877 toDelete = (incidence); 877 toDelete = (incidence);
878 incidence = delSel.next(); 878 incidence = delSel.next();
879 emit deleteIncidenceSignal(toDelete ); 879 emit deleteIncidenceSignal(toDelete );
880 if ( dia.result() != 0 ) 880 if ( dia.result() != 0 )
881 break; 881 break;
882 882
883 } 883 }
884 KOPrefs::instance()->mGlobalUpdateDisabled = false; 884 KOPrefs::instance()->mGlobalUpdateDisabled = false;
885 emit deleteIncidenceSignal( 0 ); 885 emit deleteIncidenceSignal( 0 );
886 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 886 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
887 topLevelWidget ()->setCaption( mess ); 887 topLevelWidget ()->setCaption( mess );
888 p->mConfirm = confirm; 888 p->mConfirm = confirm;
889 } 889 }
890 } 890 }
891 891
892 892
893} 893}
894int KOListView::maxDatesHint() 894int KOListView::maxDatesHint()
895{ 895{
896 return 0; 896 return 0;
897} 897}
898 898
899int KOListView::currentDateCount() 899int KOListView::currentDateCount()
900{ 900{
901 return 0; 901 return 0;
902} 902}
903 903
904QPtrList<Incidence> KOListView::selectedIncidences() 904QPtrList<Incidence> KOListView::selectedIncidences()
905{ 905{
906 QPtrList<Incidence> eventList; 906 QPtrList<Incidence> eventList;
907 QListViewItem *item = mListView->firstChild (); 907 QListViewItem *item = mListView->firstChild ();
908 while ( item ) { 908 while ( item ) {
909 if ( item->isSelected() ) { 909 if ( item->isSelected() ) {
910 eventList.append(((KOListViewItem *)item)->data()); 910 eventList.append(((KOListViewItem *)item)->data());
911 } 911 }
912 912
913 item = item->nextSibling(); 913 item = item->nextSibling();
914 } 914 }
915 915
916 // // QListViewItem *item = mListView->selectedItem(); 916 // // QListViewItem *item = mListView->selectedItem();
917 //if (item) eventList.append(((KOListViewItem *)item)->data()); 917 //if (item) eventList.append(((KOListViewItem *)item)->data());
918 918
919 return eventList; 919 return eventList;
920} 920}
921 921
922DateList KOListView::selectedDates() 922DateList KOListView::selectedDates()
923{ 923{
924 DateList eventList; 924 DateList eventList;
925 return eventList; 925 return eventList;
926} 926}
927 927
928void KOListView::showDates(bool show) 928void KOListView::showDates(bool show)
929{ 929{
930 // Shouldn't we set it to a value greater 0? When showDates is called with 930 // Shouldn't we set it to a value greater 0? When showDates is called with
931 // show == true at first, then the columnwidths are set to zero. 931 // show == true at first, then the columnwidths are set to zero.
932 static int oldColWidth1 = 0; 932 static int oldColWidth1 = 0;
933 static int oldColWidth3 = 0; 933 static int oldColWidth3 = 0;
934 934
935 if (!show) { 935 if (!show) {
936 oldColWidth1 = mListView->columnWidth(1); 936 oldColWidth1 = mListView->columnWidth(1);
937 oldColWidth3 = mListView->columnWidth(3); 937 oldColWidth3 = mListView->columnWidth(3);
938 mListView->setColumnWidth(1, 0); 938 mListView->setColumnWidth(1, 0);
939 mListView->setColumnWidth(3, 0); 939 mListView->setColumnWidth(3, 0);
940 } else { 940 } else {
941 mListView->setColumnWidth(1, oldColWidth1); 941 mListView->setColumnWidth(1, oldColWidth1);
942 mListView->setColumnWidth(3, oldColWidth3); 942 mListView->setColumnWidth(3, oldColWidth3);
943 } 943 }
944 mListView->repaint(); 944 mListView->repaint();
945} 945}
946 946
947void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd, 947void KOListView::printPreview(CalPrinter *calPrinter, const QDate &fd,
948 const QDate &td) 948 const QDate &td)
949{ 949{
950#ifndef KORG_NOPRINTER 950#ifndef KORG_NOPRINTER
951 calPrinter->preview(CalPrinter::Day, fd, td); 951 calPrinter->preview(CalPrinter::Day, fd, td);
952#endif 952#endif
953} 953}
954 954
955void KOListView::showDates() 955void KOListView::showDates()
956{ 956{
957 showDates(true); 957 showDates(true);
958} 958}
959 959
960void KOListView::hideDates() 960void KOListView::hideDates()
961{ 961{
962 showDates(false); 962 showDates(false);
963} 963}
964 964
965void KOListView::resetFocus() 965void KOListView::resetFocus()
966{ 966{
967 topLevelWidget()->setActiveWindow(); 967 topLevelWidget()->setActiveWindow();
968 topLevelWidget()->raise(); 968 topLevelWidget()->raise();
969 mListView->setFocus(); 969 mListView->setFocus();
970} 970}
971void KOListView::updateView() 971void KOListView::updateView()
972{ 972{
973 mListView->setFocus(); 973 mListView->setFocus();
974 if ( mListView->firstChild () ) 974 if ( mListView->firstChild () ) {
975 mListView->setCurrentItem( mListView->firstChild () ); 975 mListView->setCurrentItem( mListView->firstChild () );
976 }
977 processSelectionChange( mListView->firstChild () );
976} 978}
977void KOListView::updateConfig() 979void KOListView::updateConfig()
978{ 980{
979 981
980 mListView->setFont ( KOPrefs::instance()->mListViewFont ); 982 mListView->setFont ( KOPrefs::instance()->mListViewFont );
981 updateView(); 983 updateView();
982 984
983} 985}
984void KOListView::setStartDate(const QDate &start) 986void KOListView::setStartDate(const QDate &start)
985{ 987{
986 mStartDate = start; 988 mStartDate = start;
987} 989}
988 990
989void KOListView::showDates(const QDate &start, const QDate &end) 991void KOListView::showDates(const QDate &start, const QDate &end)
990{ 992{
991 clear(); 993 clear();
992 mStartDate = start; 994 mStartDate = start;
993 QDate date = start; 995 QDate date = start;
994 while( date <= end ) { 996 while( date <= end ) {
995 addEvents(calendar()->events(date)); 997 addEvents(calendar()->events(date));
996 addTodos(calendar()->todos(date)); 998 addTodos(calendar()->todos(date));
997 addJournals( calendar()->journals4Date(date) ); 999 addJournals( calendar()->journals4Date(date) );
998 date = date.addDays( 1 ); 1000 date = date.addDays( 1 );
999 } 1001 }
1000 emit incidenceSelected( 0 ); 1002 //emit incidenceSelected( 0 );
1001 updateView(); 1003 updateView();
1002 1004
1003} 1005}
1004 1006
1005void KOListView::addEvents(QPtrList<Event> eventList) 1007void KOListView::addEvents(QPtrList<Event> eventList)
1006{ 1008{
1007 1009
1008 Event *ev; 1010 Event *ev;
1009 for(ev = eventList.first(); ev; ev = eventList.next()) { 1011 for(ev = eventList.first(); ev; ev = eventList.next()) {
1010 addIncidence(ev); 1012 addIncidence(ev);
1011 } 1013 }
1012 if ( !mListView->currentItem() ){ 1014 if ( !mListView->currentItem() ){
1013 updateView(); 1015 updateView();
1014 } 1016 }
1015} 1017}
1016 1018
1017void KOListView::addTodos(QPtrList<Todo> eventList) 1019void KOListView::addTodos(QPtrList<Todo> eventList)
1018{ 1020{
1019 Todo *ev; 1021 Todo *ev;
1020 for(ev = eventList.first(); ev; ev = eventList.next()) { 1022 for(ev = eventList.first(); ev; ev = eventList.next()) {
1021 addIncidence(ev); 1023 addIncidence(ev);
1022 } 1024 }
1023 if ( !mListView->currentItem() ){ 1025 if ( !mListView->currentItem() ){
1024 updateView(); 1026 updateView();
1025 } 1027 }
1026} 1028}
1027void KOListView::addJournals(QPtrList<Journal> eventList) 1029void KOListView::addJournals(QPtrList<Journal> eventList)
1028{ 1030{
1029 Journal *ev; 1031 Journal *ev;
1030 for(ev = eventList.first(); ev; ev = eventList.next()) { 1032 for(ev = eventList.first(); ev; ev = eventList.next()) {
1031 addIncidence(ev); 1033 addIncidence(ev);
1032 } 1034 }
1033 if ( !mListView->currentItem() ){ 1035 if ( !mListView->currentItem() ){
1034 updateView(); 1036 updateView();
1035 } 1037 }
1036} 1038}
1037 1039
1038void KOListView::showCompletedTodos() 1040void KOListView::showCompletedTodos()
1039{ 1041{
1040 mForceShowCompletedTodos = true; 1042 mForceShowCompletedTodos = true;
1041} 1043}
1042void KOListView::addIncidence(Incidence *incidence) 1044void KOListView::addIncidence(Incidence *incidence)
1043{ 1045{
1044 if ( mUidDict.find( incidence->uid() ) ) return; 1046 if ( mUidDict.find( incidence->uid() ) ) return;
1045 1047
1046 // mListView->setFont ( KOPrefs::instance()->mListViewFont ); 1048 // mListView->setFont ( KOPrefs::instance()->mListViewFont );
1047 if ( incidence->typeID() == todoID ) { 1049 if ( incidence->typeID() == todoID ) {
1048 if ( ! mForceShowCompletedTodos ) { 1050 if ( ! mForceShowCompletedTodos ) {
1049 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() ) 1051 if ( !KOPrefs::instance()->mShowCompletedTodo && ((Todo*)incidence)->isCompleted() )
1050 return; 1052 return;
1051 } 1053 }
1052 } 1054 }
1053 mUidDict.insert( incidence->uid(), incidence ); 1055 mUidDict.insert( incidence->uid(), incidence );
1054 KOListViewItem *item = new KOListViewItem( incidence, mListView ); 1056 KOListViewItem *item = new KOListViewItem( incidence, mListView );
1055 ListItemVisitor v(item, mStartDate ); 1057 ListItemVisitor v(item, mStartDate );
1056 if (incidence->accept(v)) { 1058 if (incidence->accept(v)) {
1057 return; 1059 return;
1058 } 1060 }
1059 else delete item; 1061 else delete item;
1060} 1062}
1061 1063
1062void KOListView::showEvents(QPtrList<Event> eventList) 1064void KOListView::showEvents(QPtrList<Event> eventList)
1063{ 1065{
1064 clear(); 1066 clear();
1065 1067
1066 addEvents(eventList); 1068 addEvents(eventList);
1067 1069
1068 // After new creation of list view no events are selected. 1070 // After new creation of list view no events are selected.
1069 emit incidenceSelected( 0 ); 1071 emit incidenceSelected( 0 );
1070} 1072}
1071int KOListView::count() 1073int KOListView::count()
1072{ 1074{
1073 return mListView->childCount(); 1075 return mListView->childCount();
1074} 1076}
1075 1077
1076void KOListView::changeEventDisplay(Event *event, int action) 1078void KOListView::changeEventDisplay(Event *event, int action)
1077{ 1079{
1078 KOListViewItem *item; 1080 KOListViewItem *item;
1079 1081
1080 switch(action) { 1082 switch(action) {
1081 case KOGlobals::EVENTADDED: 1083 case KOGlobals::EVENTADDED:
1082 addIncidence( event ); 1084 addIncidence( event );
1083 break; 1085 break;
1084 case KOGlobals::EVENTEDITED: 1086 case KOGlobals::EVENTEDITED:
1085 item = getItemForEvent(event); 1087 item = getItemForEvent(event);
1086 if (item) { 1088 if (item) {
1087 ListItemVisitor v(item, mStartDate ); 1089 ListItemVisitor v(item, mStartDate );
1088 ((Incidence*)event)->accept(v); 1090 ((Incidence*)event)->accept(v);
1089 } 1091 }
1090 break; 1092 break;
1091 case KOGlobals::EVENTDELETED: 1093 case KOGlobals::EVENTDELETED:
1092 item = getItemForEvent(event); 1094 item = getItemForEvent(event);
1093 if (item) { 1095 if (item) {
1094 mUidDict.remove( event->uid() ); 1096 mUidDict.remove( event->uid() );
1095 delete item; 1097 delete item;
1096 } 1098 }
1097 break; 1099 break;
1098 default: 1100 default:
1099 ; 1101 ;
1100 } 1102 }
1101} 1103}
1102 1104
1103KOListViewItem *KOListView::getItemForEvent(Incidence *event) 1105KOListViewItem *KOListView::getItemForEvent(Incidence *event)
1104{ 1106{
1105 KOListViewItem *item = (KOListViewItem *)mListView->firstChild(); 1107 KOListViewItem *item = (KOListViewItem *)mListView->firstChild();
1106 while (item) { 1108 while (item) {
1107 if (item->data() == event) return item; 1109 if (item->data() == event) return item;
1108 item = (KOListViewItem *)item->nextSibling(); 1110 item = (KOListViewItem *)item->nextSibling();
1109 } 1111 }
1110 return 0; 1112 return 0;
1111} 1113}
1112 1114
1113void KOListView::defaultItemAction(QListViewItem *i) 1115void KOListView::defaultItemAction(QListViewItem *i)
1114{ 1116{
1115 KOListViewItem *item = static_cast<KOListViewItem *>( i ); 1117 KOListViewItem *item = static_cast<KOListViewItem *>( i );
1116 if ( item ) defaultAction( item->data() ); 1118 if ( item ) defaultAction( item->data() );
1117 1119
1118} 1120}
1119 1121
1120void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) 1122void KOListView::popupMenu(QListViewItem *item,const QPoint &,int)
1121{ 1123{
1122 mActiveItem = (KOListViewItem *)item; 1124 mActiveItem = (KOListViewItem *)item;
1123 if (mActiveItem) { 1125 if (mActiveItem) {
1124 Incidence *incidence = mActiveItem->data(); 1126 Incidence *incidence = mActiveItem->data();
1125 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); 1127 mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) );
1126 mPopupMenu->showIncidencePopup(incidence); 1128 mPopupMenu->showIncidencePopup(incidence);
1127 1129
1128 /* 1130 /*
1129 if ( incidence && incidence->type() == "Event" ) { 1131 if ( incidence && incidence->type() == "Event" ) {
1130 Event *event = static_cast<Event *>( incidence ); 1132 Event *event = static_cast<Event *>( incidence );
1131 mPopupMenu->showEventPopup(event); 1133 mPopupMenu->showEventPopup(event);
1132 } 1134 }
1133 */ 1135 */
1134 } 1136 }
1135} 1137}
1136 1138
1137void KOListView::readSettings(KConfig *config, QString setting) 1139void KOListView::readSettings(KConfig *config, QString setting)
1138{ 1140{
1139 // qDebug("KOListView::readSettings "); 1141 // qDebug("KOListView::readSettings ");
1140 mListView->restoreLayout(config,setting); 1142 mListView->restoreLayout(config,setting);
1141} 1143}
1142 1144
1143void KOListView::writeSettings(KConfig *config, QString setting) 1145void KOListView::writeSettings(KConfig *config, QString setting)
1144{ 1146{
1145 // qDebug("KOListView::writeSettings "); 1147 // qDebug("KOListView::writeSettings ");
1146 mListView->saveLayout(config, setting); 1148 mListView->saveLayout(config, setting);
1147} 1149}
1148 1150
1149void KOListView::processSelectionChange(QListViewItem *) 1151void KOListView::processSelectionChange(QListViewItem *)
1150{ 1152{
1151 1153
1152 KOListViewItem *item = 1154 KOListViewItem *item =
1153 static_cast<KOListViewItem *>( mListView->currentItem() ); 1155 static_cast<KOListViewItem *>( mListView->currentItem() );
1154 1156
1155 if ( !item ) { 1157 if ( !item ) {
1156 emit incidenceSelected( 0 ); 1158 emit incidenceSelected( 0 );
1157 } else { 1159 } else {
1158 emit incidenceSelected( item->data() ); 1160 emit incidenceSelected( item->data() );
1159 } 1161 }
1160} 1162}
1161 1163
1162void KOListView::clearSelection() 1164void KOListView::clearSelection()
1163{ 1165{
1164 mListView->selectAll( false ); 1166 mListView->selectAll( false );
1165} 1167}
1166void KOListView::allSelection() 1168void KOListView::allSelection()
1167{ 1169{
1168 mListView->selectAll( true ); 1170 mListView->selectAll( true );
1169} 1171}
1170 1172
1171void KOListView::clear() 1173void KOListView::clear()
1172{ 1174{
1173 mListView->clear(); 1175 mListView->clear();
1174 mUidDict.clear(); 1176 mUidDict.clear();
1175} 1177}
1176 1178
1177Incidence* KOListView::currentItem() 1179Incidence* KOListView::currentItem()
1178{ 1180{
1179 if ( mListView->currentItem() ) 1181 if ( mListView->currentItem() )
1180 return ((KOListViewItem*) mListView->currentItem())->data(); 1182 return ((KOListViewItem*) mListView->currentItem())->data();
1181 return 0; 1183 return 0;
1182} 1184}
1183void KOListView::keyPressEvent ( QKeyEvent *e) 1185void KOListView::keyPressEvent ( QKeyEvent *e)
1184{ 1186{
1185 1187
1186 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) { 1188 if ( e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace ) {
1187 deleteAll(); 1189 deleteAll();
1188 return; 1190 return;
1189 } 1191 }
1190 1192
1191 e->ignore(); 1193 e->ignore();
1192} 1194}