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
@@ -2726,214 +2726,218 @@ void CalendarView::edit_cut()
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()
@@ -3092,202 +3096,205 @@ void CalendarView::showTodoEditor()
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() );
@@ -3405,224 +3412,234 @@ void CalendarView::showJournal( Journal *jour )
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
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5f90dc6..7783dd4 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -878,219 +878,221 @@ void KOListView::deleteAll()
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 }