author | zautrix <zautrix> | 2005-07-30 16:36:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-30 16:36:00 (UTC) |
commit | bd2ab556e1a5066524d797856e6a13358155e24b (patch) (unidiff) | |
tree | 334d20a72ff2912d1a49d04671aa73bb424ca539 | |
parent | 6a32c95e5f0a36cd9a681a3f3302bec6e83acce5 (diff) | |
download | kdepimpi-bd2ab556e1a5066524d797856e6a13358155e24b.zip kdepimpi-bd2ab556e1a5066524d797856e6a13358155e24b.tar.gz kdepimpi-bd2ab556e1a5066524d797856e6a13358155e24b.tar.bz2 |
bugfix
-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 28649d9..a1b1d71 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -3013,769 +3013,769 @@ void CalendarView::slotSelectPickerDate( QDate d) | |||
3013 | to->setDtStart(to->dtDue().addDays( -3 )); | 3013 | to->setDtStart(to->dtDue().addDays( -3 )); |
3014 | } | 3014 | } |
3015 | 3015 | ||
3016 | todoChanged( to ); | 3016 | todoChanged( to ); |
3017 | } else if ( mMoveIncidence->typeID() == eventID ) { | 3017 | } else if ( mMoveIncidence->typeID() == eventID ) { |
3018 | if ( mMoveIncidence->doesRecur() ) { | 3018 | if ( mMoveIncidence->doesRecur() ) { |
3019 | #if 0 | 3019 | #if 0 |
3020 | // PENDING implement this | 3020 | // PENDING implement this |
3021 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 3021 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
3022 | mCalendar()->addIncidence( newInc ); | 3022 | mCalendar()->addIncidence( newInc ); |
3023 | if ( mMoveIncidence->typeID() == todoID ) | 3023 | if ( mMoveIncidence->typeID() == todoID ) |
3024 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 3024 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
3025 | else | 3025 | else |
3026 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 3026 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
3027 | mMoveIncidence = newInc; | 3027 | mMoveIncidence = newInc; |
3028 | 3028 | ||
3029 | #endif | 3029 | #endif |
3030 | } | 3030 | } |
3031 | QTime tim = mMoveIncidence->dtStart().time(); | 3031 | QTime tim = mMoveIncidence->dtStart().time(); |
3032 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 3032 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
3033 | QDateTime dt ( d,tim ); | 3033 | QDateTime dt ( d,tim ); |
3034 | mMoveIncidence->setDtStart( dt ); | 3034 | mMoveIncidence->setDtStart( dt ); |
3035 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 3035 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
3036 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 3036 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
3037 | } else if ( mMoveIncidence->typeID() == journalID ) { | 3037 | } else if ( mMoveIncidence->typeID() == journalID ) { |
3038 | QTime tim = mMoveIncidence->dtStart().time(); | 3038 | QTime tim = mMoveIncidence->dtStart().time(); |
3039 | QDateTime dt ( d,tim ); | 3039 | QDateTime dt ( d,tim ); |
3040 | mMoveIncidence->setDtStart( dt ); | 3040 | mMoveIncidence->setDtStart( dt ); |
3041 | updateView(); | 3041 | updateView(); |
3042 | } | 3042 | } |
3043 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 3043 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
3044 | } | 3044 | } |
3045 | } | 3045 | } |
3046 | 3046 | ||
3047 | void CalendarView::removeCategories() | 3047 | void CalendarView::removeCategories() |
3048 | { | 3048 | { |
3049 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3049 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3050 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3050 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3051 | QStringList catIncList; | 3051 | QStringList catIncList; |
3052 | QStringList newCatList; | 3052 | QStringList newCatList; |
3053 | Incidence* inc = incList.first(); | 3053 | Incidence* inc = incList.first(); |
3054 | uint i; | 3054 | uint i; |
3055 | while ( inc ) { | 3055 | while ( inc ) { |
3056 | newCatList.clear(); | 3056 | newCatList.clear(); |
3057 | catIncList = inc->categories() ; | 3057 | catIncList = inc->categories() ; |
3058 | for( i = 0; i< catIncList.count(); ++i ) { | 3058 | for( i = 0; i< catIncList.count(); ++i ) { |
3059 | if ( catList.contains (catIncList[i])) | 3059 | if ( catList.contains (catIncList[i])) |
3060 | newCatList.append( catIncList[i] ); | 3060 | newCatList.append( catIncList[i] ); |
3061 | } | 3061 | } |
3062 | newCatList.sort(); | 3062 | newCatList.sort(); |
3063 | inc->setCategories( newCatList.join(",") ); | 3063 | inc->setCategories( newCatList.join(",") ); |
3064 | inc = incList.next(); | 3064 | inc = incList.next(); |
3065 | } | 3065 | } |
3066 | } | 3066 | } |
3067 | 3067 | ||
3068 | int CalendarView::addCategories() | 3068 | int CalendarView::addCategories() |
3069 | { | 3069 | { |
3070 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 3070 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
3071 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 3071 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
3072 | QStringList catIncList; | 3072 | QStringList catIncList; |
3073 | Incidence* inc = incList.first(); | 3073 | Incidence* inc = incList.first(); |
3074 | uint i; | 3074 | uint i; |
3075 | int count = 0; | 3075 | int count = 0; |
3076 | while ( inc ) { | 3076 | while ( inc ) { |
3077 | catIncList = inc->categories() ; | 3077 | catIncList = inc->categories() ; |
3078 | for( i = 0; i< catIncList.count(); ++i ) { | 3078 | for( i = 0; i< catIncList.count(); ++i ) { |
3079 | if ( !catList.contains (catIncList[i])) { | 3079 | if ( !catList.contains (catIncList[i])) { |
3080 | catList.append( catIncList[i] ); | 3080 | catList.append( catIncList[i] ); |
3081 | //qDebug("add cat %s ", catIncList[i].latin1()); | 3081 | //qDebug("add cat %s ", catIncList[i].latin1()); |
3082 | ++count; | 3082 | ++count; |
3083 | } | 3083 | } |
3084 | } | 3084 | } |
3085 | inc = incList.next(); | 3085 | inc = incList.next(); |
3086 | } | 3086 | } |
3087 | catList.sort(); | 3087 | catList.sort(); |
3088 | KOPrefs::instance()->mCustomCategories = catList; | 3088 | KOPrefs::instance()->mCustomCategories = catList; |
3089 | return count; | 3089 | return count; |
3090 | } | 3090 | } |
3091 | 3091 | ||
3092 | void CalendarView::editCategories() | 3092 | void CalendarView::editCategories() |
3093 | { | 3093 | { |
3094 | qDebug("CalendarView::editCategories() "); | 3094 | qDebug("CalendarView::editCategories() "); |
3095 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); | 3095 | KPIM::CategoryEditDialog ced (KOPrefs::instance(),this ); |
3096 | ced.exec(); | 3096 | ced.exec(); |
3097 | } | 3097 | } |
3098 | void CalendarView::manageCategories() | 3098 | void CalendarView::manageCategories() |
3099 | { | 3099 | { |
3100 | KOCatPrefs* cp = new KOCatPrefs(); | 3100 | KOCatPrefs* cp = new KOCatPrefs(); |
3101 | cp->show(); | 3101 | cp->show(); |
3102 | int w =cp->sizeHint().width() ; | 3102 | int w =cp->sizeHint().width() ; |
3103 | int h = cp->sizeHint().height() ; | 3103 | int h = cp->sizeHint().height() ; |
3104 | int dw = QApplication::desktop()->width(); | 3104 | int dw = QApplication::desktop()->width(); |
3105 | int dh = QApplication::desktop()->height(); | 3105 | int dh = QApplication::desktop()->height(); |
3106 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 3106 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
3107 | if ( !cp->exec() ) { | 3107 | if ( !cp->exec() ) { |
3108 | delete cp; | 3108 | delete cp; |
3109 | return; | 3109 | return; |
3110 | } | 3110 | } |
3111 | int count = 0; | 3111 | int count = 0; |
3112 | if ( cp->addCat() ) { | 3112 | if ( cp->addCat() ) { |
3113 | count = addCategories(); | 3113 | count = addCategories(); |
3114 | if ( count ) { | 3114 | if ( count ) { |
3115 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 3115 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
3116 | writeSettings(); | 3116 | writeSettings(); |
3117 | } else | 3117 | } else |
3118 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 3118 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
3119 | } else { | 3119 | } else { |
3120 | removeCategories(); | 3120 | removeCategories(); |
3121 | updateView(); | 3121 | updateView(); |
3122 | } | 3122 | } |
3123 | delete cp; | 3123 | delete cp; |
3124 | } | 3124 | } |
3125 | 3125 | ||
3126 | void CalendarView::beamIncidence(Incidence * Inc) | 3126 | void CalendarView::beamIncidence(Incidence * Inc) |
3127 | { | 3127 | { |
3128 | QPtrList<Incidence> delSel ; | 3128 | QPtrList<Incidence> delSel ; |
3129 | delSel.append(Inc); | 3129 | delSel.append(Inc); |
3130 | beamIncidenceList( delSel ); | 3130 | beamIncidenceList( delSel ); |
3131 | } | 3131 | } |
3132 | void CalendarView::beamCalendar() | 3132 | void CalendarView::beamCalendar() |
3133 | { | 3133 | { |
3134 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 3134 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
3135 | //qDebug("beamCalendar() "); | 3135 | //qDebug("beamCalendar() "); |
3136 | beamIncidenceList( delSel ); | 3136 | beamIncidenceList( delSel ); |
3137 | } | 3137 | } |
3138 | void CalendarView::beamFilteredCalendar() | 3138 | void CalendarView::beamFilteredCalendar() |
3139 | { | 3139 | { |
3140 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 3140 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
3141 | //qDebug("beamFilteredCalendar() "); | 3141 | //qDebug("beamFilteredCalendar() "); |
3142 | beamIncidenceList( delSel ); | 3142 | beamIncidenceList( delSel ); |
3143 | } | 3143 | } |
3144 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 3144 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
3145 | { | 3145 | { |
3146 | 3146 | ||
3147 | KOBeamPrefs beamDialog; | 3147 | KOBeamPrefs beamDialog; |
3148 | if ( beamDialog.exec () == QDialog::Rejected ) | 3148 | if ( beamDialog.exec () == QDialog::Rejected ) |
3149 | return; | 3149 | return; |
3150 | #ifdef DESKTOP_VERSION | 3150 | #ifdef DESKTOP_VERSION |
3151 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 3151 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
3152 | #else | 3152 | #else |
3153 | QString fn = "/tmp/kopibeamfile"; | 3153 | QString fn = "/tmp/kopibeamfile"; |
3154 | #endif | 3154 | #endif |
3155 | QString mes; | 3155 | QString mes; |
3156 | bool createbup = true; | 3156 | bool createbup = true; |
3157 | if ( createbup ) { | 3157 | if ( createbup ) { |
3158 | QString description = "\n"; | 3158 | QString description = "\n"; |
3159 | CalendarLocal* cal = new CalendarLocal(); | 3159 | CalendarLocal* cal = new CalendarLocal(); |
3160 | if ( beamDialog.beamLocal() ) | 3160 | if ( beamDialog.beamLocal() ) |
3161 | cal->setLocalTime(); | 3161 | cal->setLocalTime(); |
3162 | else | 3162 | else |
3163 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 3163 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
3164 | Incidence *incidence = delSel.first(); | 3164 | Incidence *incidence = delSel.first(); |
3165 | bool addText = false; | 3165 | bool addText = false; |
3166 | if ( delSel.count() < 10 ) | 3166 | if ( delSel.count() < 10 ) |
3167 | addText = true; | 3167 | addText = true; |
3168 | else { | 3168 | else { |
3169 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 3169 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
3170 | } | 3170 | } |
3171 | while ( incidence ) { | 3171 | while ( incidence ) { |
3172 | Incidence *in = incidence->clone(); | 3172 | Incidence *in = incidence->clone(); |
3173 | if ( ! in->summary().isEmpty() ) { | 3173 | if ( ! in->summary().isEmpty() ) { |
3174 | in->setDescription(""); | 3174 | in->setDescription(""); |
3175 | } else { | 3175 | } else { |
3176 | in->setSummary( in->description().left(20)); | 3176 | in->setSummary( in->description().left(20)); |
3177 | in->setDescription(""); | 3177 | in->setDescription(""); |
3178 | } | 3178 | } |
3179 | if ( addText ) | 3179 | if ( addText ) |
3180 | description += in->summary() + "\n"; | 3180 | description += in->summary() + "\n"; |
3181 | cal->addIncidence( in ); | 3181 | cal->addIncidence( in ); |
3182 | incidence = delSel.next(); | 3182 | incidence = delSel.next(); |
3183 | } | 3183 | } |
3184 | if ( beamDialog.beamVcal() ) { | 3184 | if ( beamDialog.beamVcal() ) { |
3185 | fn += ".vcs"; | 3185 | fn += ".vcs"; |
3186 | FileStorage storage( cal, fn, new VCalFormat ); | 3186 | FileStorage storage( cal, fn, new VCalFormat ); |
3187 | storage.save(); | 3187 | storage.save(); |
3188 | } else { | 3188 | } else { |
3189 | fn += ".ics"; | 3189 | fn += ".ics"; |
3190 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 3190 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
3191 | storage.save(); | 3191 | storage.save(); |
3192 | } | 3192 | } |
3193 | delete cal; | 3193 | delete cal; |
3194 | mes = i18n("KO/Pi: Ready for beaming"); | 3194 | mes = i18n("KO/Pi: Ready for beaming"); |
3195 | topLevelWidget()->setCaption(mes); | 3195 | topLevelWidget()->setCaption(mes); |
3196 | KApplication::convert2latin1( fn ); | 3196 | KApplication::convert2latin1( fn ); |
3197 | #ifndef DESKTOP_VERSION | 3197 | #ifndef DESKTOP_VERSION |
3198 | Ir *ir = new Ir( this ); | 3198 | Ir *ir = new Ir( this ); |
3199 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 3199 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
3200 | ir->send( fn, description, "text/x-vCalendar" ); | 3200 | ir->send( fn, description, "text/x-vCalendar" ); |
3201 | #endif | 3201 | #endif |
3202 | } | 3202 | } |
3203 | } | 3203 | } |
3204 | 3204 | ||
3205 | #ifndef DESKTOP_VERSION | 3205 | #ifndef DESKTOP_VERSION |
3206 | void CalendarView::beamDone( Ir *ir ) | 3206 | void CalendarView::beamDone( Ir *ir ) |
3207 | { | 3207 | { |
3208 | delete ir; | 3208 | delete ir; |
3209 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 3209 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
3210 | topLevelWidget()->raise(); | 3210 | topLevelWidget()->raise(); |
3211 | } | 3211 | } |
3212 | #else | 3212 | #else |
3213 | void CalendarView::beamDone( Ir *){;} | 3213 | void CalendarView::beamDone( Ir *){;} |
3214 | #endif | 3214 | #endif |
3215 | void CalendarView::moveIncidence(Incidence * inc ) | 3215 | void CalendarView::moveIncidence(Incidence * inc ) |
3216 | { | 3216 | { |
3217 | if ( !inc ) return; | 3217 | if ( !inc ) return; |
3218 | showDatePickerPopup(); | 3218 | showDatePickerPopup(); |
3219 | mDatePickerMode = 2; | 3219 | mDatePickerMode = 2; |
3220 | mMoveIncidence = inc ; | 3220 | mMoveIncidence = inc ; |
3221 | QDate da; | 3221 | QDate da; |
3222 | if ( mMoveIncidence->typeID() == todoID ) { | 3222 | if ( mMoveIncidence->typeID() == todoID ) { |
3223 | Todo * to = (Todo *) mMoveIncidence; | 3223 | Todo * to = (Todo *) mMoveIncidence; |
3224 | if ( to->hasDueDate() ) | 3224 | if ( to->hasDueDate() ) |
3225 | da = to->dtDue().date(); | 3225 | da = to->dtDue().date(); |
3226 | else | 3226 | else |
3227 | da = QDate::currentDate(); | 3227 | da = QDate::currentDate(); |
3228 | } else { | 3228 | } else { |
3229 | da = mMoveIncidence->dtStart().date(); | 3229 | da = mMoveIncidence->dtStart().date(); |
3230 | } | 3230 | } |
3231 | //PENDING set date for recurring incidence to date of recurrence | 3231 | //PENDING set date for recurring incidence to date of recurrence |
3232 | //mMoveIncidenceOldDate; | 3232 | //mMoveIncidenceOldDate; |
3233 | mDatePicker->setDate( da ); | 3233 | mDatePicker->setDate( da ); |
3234 | } | 3234 | } |
3235 | void CalendarView::showDatePickerPopup() | 3235 | void CalendarView::showDatePickerPopup() |
3236 | { | 3236 | { |
3237 | if ( mDateFrame->isVisible() ) | 3237 | if ( mDateFrame->isVisible() ) |
3238 | mDateFrame->hide(); | 3238 | mDateFrame->hide(); |
3239 | else { | 3239 | else { |
3240 | int offX = 0, offY = 0; | 3240 | int offX = 0, offY = 0; |
3241 | #ifdef DESKTOP_VERSION | 3241 | #ifdef DESKTOP_VERSION |
3242 | int w =mDatePicker->sizeHint().width() ; | 3242 | int w =mDatePicker->sizeHint().width() ; |
3243 | int h = mDatePicker->sizeHint().height() ; | 3243 | int h = mDatePicker->sizeHint().height() ; |
3244 | int dw = topLevelWidget()->width(); | 3244 | int dw = topLevelWidget()->width(); |
3245 | int dh = topLevelWidget()->height(); | 3245 | int dh = topLevelWidget()->height(); |
3246 | offX = topLevelWidget()->x(); | 3246 | offX = topLevelWidget()->x(); |
3247 | offY = topLevelWidget()->y(); | 3247 | offY = topLevelWidget()->y(); |
3248 | #else | 3248 | #else |
3249 | int w =mDatePicker->sizeHint().width() ; | 3249 | int w =mDatePicker->sizeHint().width() ; |
3250 | int h = mDatePicker->sizeHint().height() ; | 3250 | int h = mDatePicker->sizeHint().height() ; |
3251 | int dw = QApplication::desktop()->width(); | 3251 | int dw = QApplication::desktop()->width(); |
3252 | int dh = QApplication::desktop()->height(); | 3252 | int dh = QApplication::desktop()->height(); |
3253 | #endif | 3253 | #endif |
3254 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); | 3254 | mDateFrame->setGeometry( (dw-w)/2+offX, (dh - h )/2+offY ,w,h ); |
3255 | mDateFrame->show(); | 3255 | mDateFrame->show(); |
3256 | } | 3256 | } |
3257 | } | 3257 | } |
3258 | void CalendarView::showDatePicker( ) | 3258 | void CalendarView::showDatePicker( ) |
3259 | { | 3259 | { |
3260 | showDatePickerPopup(); | 3260 | showDatePickerPopup(); |
3261 | mDatePickerMode = 1; | 3261 | mDatePickerMode = 1; |
3262 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 3262 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
3263 | } | 3263 | } |
3264 | 3264 | ||
3265 | void CalendarView::showEventEditor() | 3265 | void CalendarView::showEventEditor() |
3266 | { | 3266 | { |
3267 | #ifdef DESKTOP_VERSION | 3267 | #ifdef DESKTOP_VERSION |
3268 | int x,y,w,h; | 3268 | int x,y,w,h; |
3269 | x = mEventEditor->geometry().x(); | 3269 | x = mEventEditor->geometry().x(); |
3270 | y = mEventEditor->geometry().y(); | 3270 | y = mEventEditor->geometry().y(); |
3271 | w = mEventEditor->width(); | 3271 | w = mEventEditor->width(); |
3272 | h = mEventEditor->height(); | 3272 | h = mEventEditor->height(); |
3273 | mEventEditor->show(); | 3273 | mEventEditor->show(); |
3274 | mEventEditor->setGeometry(x,y,w,h); | 3274 | mEventEditor->setGeometry(x,y,w,h); |
3275 | #else | 3275 | #else |
3276 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 3276 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
3277 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3277 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3278 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 3278 | qDebug("KO: CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
3279 | qApp->processEvents(); | 3279 | qApp->processEvents(); |
3280 | delete mEventEditor; | 3280 | delete mEventEditor; |
3281 | mEventEditor = mDialogManager->getEventEditor(); | 3281 | mEventEditor = mDialogManager->getEventEditor(); |
3282 | topLevelWidget()->setCaption( i18n("") ); | 3282 | topLevelWidget()->setCaption( i18n("") ); |
3283 | } | 3283 | } |
3284 | mEventEditor->showMaximized(); | 3284 | mEventEditor->showMaximized(); |
3285 | #endif | 3285 | #endif |
3286 | } | 3286 | } |
3287 | void CalendarView::showTodoEditor() | 3287 | void CalendarView::showTodoEditor() |
3288 | { | 3288 | { |
3289 | #ifdef DESKTOP_VERSION | 3289 | #ifdef DESKTOP_VERSION |
3290 | int x,y,w,h; | 3290 | int x,y,w,h; |
3291 | x = mTodoEditor->geometry().x(); | 3291 | x = mTodoEditor->geometry().x(); |
3292 | y = mTodoEditor->geometry().y(); | 3292 | y = mTodoEditor->geometry().y(); |
3293 | w = mTodoEditor->width(); | 3293 | w = mTodoEditor->width(); |
3294 | h = mTodoEditor->height(); | 3294 | h = mTodoEditor->height(); |
3295 | mTodoEditor->show(); | 3295 | mTodoEditor->show(); |
3296 | mTodoEditor->setGeometry(x,y,w,h); | 3296 | mTodoEditor->setGeometry(x,y,w,h); |
3297 | #else | 3297 | #else |
3298 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 3298 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
3299 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 3299 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
3300 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 3300 | qDebug("KO: CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
3301 | qApp->processEvents(); | 3301 | qApp->processEvents(); |
3302 | delete mTodoEditor; | 3302 | delete mTodoEditor; |
3303 | mTodoEditor = mDialogManager->getTodoEditor(); | 3303 | mTodoEditor = mDialogManager->getTodoEditor(); |
3304 | topLevelWidget()->setCaption( i18n("") ); | 3304 | topLevelWidget()->setCaption( i18n("") ); |
3305 | } | 3305 | } |
3306 | mTodoEditor->showMaximized(); | 3306 | mTodoEditor->showMaximized(); |
3307 | #endif | 3307 | #endif |
3308 | } | 3308 | } |
3309 | 3309 | ||
3310 | void CalendarView::cloneIncidence() | 3310 | void CalendarView::cloneIncidence() |
3311 | { | 3311 | { |
3312 | Incidence *incidence = currentSelection(); | 3312 | Incidence *incidence = currentSelection(); |
3313 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3313 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3314 | if ( incidence ) { | 3314 | if ( incidence ) { |
3315 | cloneIncidence(incidence); | 3315 | cloneIncidence(incidence); |
3316 | } | 3316 | } |
3317 | } | 3317 | } |
3318 | void CalendarView::moveIncidence() | 3318 | void CalendarView::moveIncidence() |
3319 | { | 3319 | { |
3320 | Incidence *incidence = currentSelection(); | 3320 | Incidence *incidence = currentSelection(); |
3321 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3321 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3322 | if ( incidence ) { | 3322 | if ( incidence ) { |
3323 | moveIncidence(incidence); | 3323 | moveIncidence(incidence); |
3324 | } | 3324 | } |
3325 | } | 3325 | } |
3326 | void CalendarView::beamIncidence() | 3326 | void CalendarView::beamIncidence() |
3327 | { | 3327 | { |
3328 | Incidence *incidence = currentSelection(); | 3328 | Incidence *incidence = currentSelection(); |
3329 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3329 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3330 | if ( incidence ) { | 3330 | if ( incidence ) { |
3331 | beamIncidence(incidence); | 3331 | beamIncidence(incidence); |
3332 | } | 3332 | } |
3333 | } | 3333 | } |
3334 | void CalendarView::toggleCancelIncidence() | 3334 | void CalendarView::toggleCancelIncidence() |
3335 | { | 3335 | { |
3336 | Incidence *incidence = currentSelection(); | 3336 | Incidence *incidence = currentSelection(); |
3337 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3337 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3338 | if ( incidence ) { | 3338 | if ( incidence ) { |
3339 | cancelIncidence(incidence); | 3339 | cancelIncidence(incidence); |
3340 | } | 3340 | } |
3341 | } | 3341 | } |
3342 | 3342 | ||
3343 | 3343 | ||
3344 | void CalendarView::cancelIncidence(Incidence * inc ) | 3344 | void CalendarView::cancelIncidence(Incidence * inc ) |
3345 | { | 3345 | { |
3346 | inc->setCancelled( ! inc->cancelled() ); | 3346 | inc->setCancelled( ! inc->cancelled() ); |
3347 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 3347 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
3348 | updateView(); | 3348 | updateView(); |
3349 | } | 3349 | } |
3350 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 3350 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
3351 | { | 3351 | { |
3352 | Incidence * newInc = orgInc->clone(); | 3352 | Incidence * newInc = orgInc->clone(); |
3353 | newInc->recreate(); | 3353 | newInc->recreate(); |
3354 | 3354 | ||
3355 | if ( newInc->typeID() == todoID ) { | 3355 | if ( newInc->typeID() == todoID ) { |
3356 | Todo* t = (Todo*) newInc; | 3356 | Todo* t = (Todo*) newInc; |
3357 | bool cloneSub = false; | 3357 | bool cloneSub = false; |
3358 | if ( orgInc->relations().count() ) { | 3358 | if ( orgInc->relations().count() ) { |
3359 | int result = KMessageBox::warningYesNoCancel(this, | 3359 | int result = KMessageBox::warningYesNoCancel(this, |
3360 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), | 3360 | i18n("The todo\n%1\nwill be cloned!\nIt has subtodos!\nDo you want to clone\nall subtodos as well?").arg( KGlobal::formatMessage ( newInc->summary(),0 ) ), |
3361 | i18n("Todo has subtodos"), | 3361 | i18n("Todo has subtodos"), |
3362 | i18n("Yes"), | 3362 | i18n("Yes"), |
3363 | i18n("No")); | 3363 | i18n("No")); |
3364 | 3364 | ||
3365 | if ( result == KMessageBox::Cancel ) { | 3365 | if ( result == KMessageBox::Cancel ) { |
3366 | delete t; | 3366 | delete t; |
3367 | return; | 3367 | return; |
3368 | } | 3368 | } |
3369 | if (result == KMessageBox::Yes) cloneSub = true; | 3369 | if (result == KMessageBox::Yes) cloneSub = true; |
3370 | } | 3370 | } |
3371 | showTodoEditor(); | 3371 | showTodoEditor(); |
3372 | mTodoEditor->editTodo( t ); | 3372 | mTodoEditor->editTodo( t ); |
3373 | if ( mTodoEditor->exec() ) { | 3373 | if ( mTodoEditor->exec() ) { |
3374 | if ( cloneSub ) { | 3374 | if ( cloneSub ) { |
3375 | orgInc->cloneRelations( t ); | 3375 | orgInc->cloneRelations( t ); |
3376 | mCalendar->addIncidenceBranch( t ); | 3376 | mCalendar->addIncidenceBranch( t ); |
3377 | updateView(); | 3377 | updateView(); |
3378 | 3378 | ||
3379 | } else { | 3379 | } else { |
3380 | mCalendar->addTodo( t ); | 3380 | mCalendar->addTodo( t ); |
3381 | updateView(); | 3381 | updateView(); |
3382 | } | 3382 | } |
3383 | } else { | 3383 | } else { |
3384 | delete t; | 3384 | delete t; |
3385 | } | 3385 | } |
3386 | } | 3386 | } |
3387 | else if ( newInc->typeID() == eventID ) { | 3387 | else if ( newInc->typeID() == eventID ) { |
3388 | Event* e = (Event*) newInc; | 3388 | Event* e = (Event*) newInc; |
3389 | showEventEditor(); | 3389 | showEventEditor(); |
3390 | mEventEditor->editEvent( e ); | 3390 | mEventEditor->editEvent( e ); |
3391 | if ( mEventEditor->exec() ) { | 3391 | if ( mEventEditor->exec() ) { |
3392 | mCalendar->addEvent( e ); | 3392 | mCalendar->addEvent( e ); |
3393 | updateView(); | 3393 | updateView(); |
3394 | } else { | 3394 | } else { |
3395 | delete e; | 3395 | delete e; |
3396 | } | 3396 | } |
3397 | } if ( newInc->typeID() == journalID ) { | 3397 | } else if ( newInc->typeID() == journalID ) { |
3398 | mCalendar->addJournal( (Journal*) newInc ); | 3398 | mCalendar->addJournal( (Journal*) newInc ); |
3399 | editJournal( (Journal*) newInc ); | 3399 | editJournal( (Journal*) newInc ); |
3400 | } | 3400 | } |
3401 | setActiveWindow(); | 3401 | setActiveWindow(); |
3402 | } | 3402 | } |
3403 | 3403 | ||
3404 | void CalendarView::newEvent() | 3404 | void CalendarView::newEvent() |
3405 | { | 3405 | { |
3406 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 3406 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
3407 | KOAgendaView *aView = mViewManager->agendaView(); | 3407 | KOAgendaView *aView = mViewManager->agendaView(); |
3408 | if (aView) { | 3408 | if (aView) { |
3409 | if (aView->selectionStart().isValid()) { | 3409 | if (aView->selectionStart().isValid()) { |
3410 | if (aView->selectedIsAllDay()) { | 3410 | if (aView->selectedIsAllDay()) { |
3411 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 3411 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
3412 | } else { | 3412 | } else { |
3413 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 3413 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
3414 | } | 3414 | } |
3415 | return; | 3415 | return; |
3416 | } | 3416 | } |
3417 | } | 3417 | } |
3418 | 3418 | ||
3419 | QDate date = mNavigator->selectedDates().first(); | 3419 | QDate date = mNavigator->selectedDates().first(); |
3420 | #if 0 | 3420 | #if 0 |
3421 | QDateTime current = QDateTime::currentDateTime(); | 3421 | QDateTime current = QDateTime::currentDateTime(); |
3422 | if ( date <= current.date() ) { | 3422 | if ( date <= current.date() ) { |
3423 | int hour = current.time().hour() +1; | 3423 | int hour = current.time().hour() +1; |
3424 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 3424 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
3425 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3425 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3426 | } else | 3426 | } else |
3427 | #endif | 3427 | #endif |
3428 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 3428 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
3429 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 3429 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
3430 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 3430 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
3431 | } | 3431 | } |
3432 | 3432 | ||
3433 | void CalendarView::newEvent(QDateTime fh) | 3433 | void CalendarView::newEvent(QDateTime fh) |
3434 | { | 3434 | { |
3435 | newEvent(fh, | 3435 | newEvent(fh, |
3436 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 3436 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
3437 | } | 3437 | } |
3438 | 3438 | ||
3439 | void CalendarView::newEvent(QDate dt) | 3439 | void CalendarView::newEvent(QDate dt) |
3440 | { | 3440 | { |
3441 | newEvent(QDateTime(dt, QTime(0,0,0)), | 3441 | newEvent(QDateTime(dt, QTime(0,0,0)), |
3442 | QDateTime(dt, QTime(0,0,0)), true); | 3442 | QDateTime(dt, QTime(0,0,0)), true); |
3443 | } | 3443 | } |
3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) | 3444 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint) |
3445 | { | 3445 | { |
3446 | newEvent(fromHint, toHint, false); | 3446 | newEvent(fromHint, toHint, false); |
3447 | } | 3447 | } |
3448 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 3448 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
3449 | { | 3449 | { |
3450 | 3450 | ||
3451 | showEventEditor(); | 3451 | showEventEditor(); |
3452 | mEventEditor->newEvent(fromHint,toHint,allDay); | 3452 | mEventEditor->newEvent(fromHint,toHint,allDay); |
3453 | if ( mFilterView->filtersEnabled() ) { | 3453 | if ( mFilterView->filtersEnabled() ) { |
3454 | CalFilter *filter = mFilterView->selectedFilter(); | 3454 | CalFilter *filter = mFilterView->selectedFilter(); |
3455 | if (filter && filter->showCategories()) { | 3455 | if (filter && filter->showCategories()) { |
3456 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 3456 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
3457 | } | 3457 | } |
3458 | if ( filter ) | 3458 | if ( filter ) |
3459 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 3459 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
3460 | } | 3460 | } |
3461 | mEventEditor->exec(); | 3461 | mEventEditor->exec(); |
3462 | setActiveWindow(); | 3462 | setActiveWindow(); |
3463 | } | 3463 | } |
3464 | void CalendarView::todoAdded(Todo * t) | 3464 | void CalendarView::todoAdded(Todo * t) |
3465 | { | 3465 | { |
3466 | 3466 | ||
3467 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 3467 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
3468 | updateTodoViews(); | 3468 | updateTodoViews(); |
3469 | } | 3469 | } |
3470 | void CalendarView::todoChanged(Todo * t) | 3470 | void CalendarView::todoChanged(Todo * t) |
3471 | { | 3471 | { |
3472 | emit todoModified( t, 4 ); | 3472 | emit todoModified( t, 4 ); |
3473 | // updateTodoViews(); | 3473 | // updateTodoViews(); |
3474 | } | 3474 | } |
3475 | void CalendarView::todoToBeDeleted(Todo *) | 3475 | void CalendarView::todoToBeDeleted(Todo *) |
3476 | { | 3476 | { |
3477 | //qDebug("todoToBeDeleted(Todo *) "); | 3477 | //qDebug("todoToBeDeleted(Todo *) "); |
3478 | updateTodoViews(); | 3478 | updateTodoViews(); |
3479 | } | 3479 | } |
3480 | void CalendarView::todoDeleted() | 3480 | void CalendarView::todoDeleted() |
3481 | { | 3481 | { |
3482 | //qDebug(" todoDeleted()"); | 3482 | //qDebug(" todoDeleted()"); |
3483 | updateTodoViews(); | 3483 | updateTodoViews(); |
3484 | } | 3484 | } |
3485 | 3485 | ||
3486 | 3486 | ||
3487 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) | 3487 | void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) |
3488 | { | 3488 | { |
3489 | showTodoEditor(); | 3489 | showTodoEditor(); |
3490 | mTodoEditor->newTodo(dt,0,allday); | 3490 | mTodoEditor->newTodo(dt,0,allday); |
3491 | if ( mFilterView->filtersEnabled() ) { | 3491 | if ( mFilterView->filtersEnabled() ) { |
3492 | CalFilter *filter = mFilterView->selectedFilter(); | 3492 | CalFilter *filter = mFilterView->selectedFilter(); |
3493 | if (filter && filter->showCategories()) { | 3493 | if (filter && filter->showCategories()) { |
3494 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 3494 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
3495 | } | 3495 | } |
3496 | if ( filter ) | 3496 | if ( filter ) |
3497 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 3497 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
3498 | } | 3498 | } |
3499 | mTodoEditor->exec(); | 3499 | mTodoEditor->exec(); |
3500 | setActiveWindow(); | 3500 | setActiveWindow(); |
3501 | } | 3501 | } |
3502 | 3502 | ||
3503 | void CalendarView::newTodo() | 3503 | void CalendarView::newTodo() |
3504 | { | 3504 | { |
3505 | newTodoDateTime( QDateTime(),true ); | 3505 | newTodoDateTime( QDateTime(),true ); |
3506 | } | 3506 | } |
3507 | 3507 | ||
3508 | void CalendarView::newSubTodo() | 3508 | void CalendarView::newSubTodo() |
3509 | { | 3509 | { |
3510 | Todo *todo = selectedTodo(); | 3510 | Todo *todo = selectedTodo(); |
3511 | if ( todo ) newSubTodo( todo ); | 3511 | if ( todo ) newSubTodo( todo ); |
3512 | } | 3512 | } |
3513 | 3513 | ||
3514 | void CalendarView::newSubTodo(Todo *parentEvent) | 3514 | void CalendarView::newSubTodo(Todo *parentEvent) |
3515 | { | 3515 | { |
3516 | 3516 | ||
3517 | showTodoEditor(); | 3517 | showTodoEditor(); |
3518 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); | 3518 | mTodoEditor->newTodo(QDateTime(),parentEvent,true); |
3519 | mTodoEditor->exec(); | 3519 | mTodoEditor->exec(); |
3520 | setActiveWindow(); | 3520 | setActiveWindow(); |
3521 | } | 3521 | } |
3522 | 3522 | ||
3523 | void CalendarView::newFloatingEvent() | 3523 | void CalendarView::newFloatingEvent() |
3524 | { | 3524 | { |
3525 | DateList tmpList = mNavigator->selectedDates(); | 3525 | DateList tmpList = mNavigator->selectedDates(); |
3526 | QDate date = tmpList.first(); | 3526 | QDate date = tmpList.first(); |
3527 | 3527 | ||
3528 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 3528 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
3529 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 3529 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
3530 | } | 3530 | } |
3531 | 3531 | ||
3532 | 3532 | ||
3533 | void CalendarView::editEvent( Event *event ) | 3533 | void CalendarView::editEvent( Event *event ) |
3534 | { | 3534 | { |
3535 | 3535 | ||
3536 | if ( !event ) return; | 3536 | if ( !event ) return; |
3537 | if ( event->isReadOnly() ) { | 3537 | if ( event->isReadOnly() ) { |
3538 | showEvent( event ); | 3538 | showEvent( event ); |
3539 | return; | 3539 | return; |
3540 | } | 3540 | } |
3541 | showEventEditor(); | 3541 | showEventEditor(); |
3542 | mEventEditor->editEvent( event , mFlagEditDescription); | 3542 | mEventEditor->editEvent( event , mFlagEditDescription); |
3543 | mEventEditor->exec(); | 3543 | mEventEditor->exec(); |
3544 | setActiveWindow(); | 3544 | setActiveWindow(); |
3545 | 3545 | ||
3546 | } | 3546 | } |
3547 | void CalendarView::editJournal( Journal *jour ) | 3547 | void CalendarView::editJournal( Journal *jour ) |
3548 | { | 3548 | { |
3549 | if ( !jour ) return; | 3549 | if ( !jour ) return; |
3550 | mDialogManager->hideSearchDialog(); | 3550 | mDialogManager->hideSearchDialog(); |
3551 | mViewManager->showJournalView(); | 3551 | mViewManager->showJournalView(); |
3552 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 3552 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
3553 | } | 3553 | } |
3554 | void CalendarView::editTodo( Todo *todo ) | 3554 | void CalendarView::editTodo( Todo *todo ) |
3555 | { | 3555 | { |
3556 | if ( !todo ) return; | 3556 | if ( !todo ) return; |
3557 | 3557 | ||
3558 | if ( todo->isReadOnly() ) { | 3558 | if ( todo->isReadOnly() ) { |
3559 | showTodo( todo ); | 3559 | showTodo( todo ); |
3560 | return; | 3560 | return; |
3561 | } | 3561 | } |
3562 | showTodoEditor(); | 3562 | showTodoEditor(); |
3563 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | 3563 | mTodoEditor->editTodo( todo ,mFlagEditDescription); |
3564 | mTodoEditor->exec(); | 3564 | mTodoEditor->exec(); |
3565 | setActiveWindow(); | 3565 | setActiveWindow(); |
3566 | 3566 | ||
3567 | } | 3567 | } |
3568 | 3568 | ||
3569 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 3569 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
3570 | { | 3570 | { |
3571 | if ( !mEventViewerDialog ) { | 3571 | if ( !mEventViewerDialog ) { |
3572 | mEventViewerDialog = new KOEventViewerDialog(0); | 3572 | mEventViewerDialog = new KOEventViewerDialog(0); |
3573 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 3573 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
3574 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 3574 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
3575 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 3575 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
3576 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 3576 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
3577 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 3577 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
3578 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 3578 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
3579 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), | 3579 | connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), |
3580 | this, SLOT( slotViewerClosed() ) ); | 3580 | this, SLOT( slotViewerClosed() ) ); |
3581 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), | 3581 | connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), |
3582 | this, SLOT( todoChanged(Todo *) ) ); | 3582 | this, SLOT( todoChanged(Todo *) ) ); |
3583 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); | 3583 | connect( mEventViewerDialog, SIGNAL( showIncidence( QString ) ),SLOT( showIncidence( QString ) )); |
3584 | mEventViewerDialog->resize( 640, 480 ); | 3584 | mEventViewerDialog->resize( 640, 480 ); |
3585 | 3585 | ||
3586 | } | 3586 | } |
3587 | return mEventViewerDialog; | 3587 | return mEventViewerDialog; |
3588 | } | 3588 | } |
3589 | void CalendarView::showEvent(Event *event) | 3589 | void CalendarView::showEvent(Event *event) |
3590 | { | 3590 | { |
3591 | getEventViewerDialog()->setEvent(event); | 3591 | getEventViewerDialog()->setEvent(event); |
3592 | getEventViewerDialog()->showMe(); | 3592 | getEventViewerDialog()->showMe(); |
3593 | } | 3593 | } |
3594 | 3594 | ||
3595 | void CalendarView::showTodo(Todo *event) | 3595 | void CalendarView::showTodo(Todo *event) |
3596 | { | 3596 | { |
3597 | getEventViewerDialog()->setTodo(event); | 3597 | getEventViewerDialog()->setTodo(event); |
3598 | getEventViewerDialog()->showMe(); | 3598 | getEventViewerDialog()->showMe(); |
3599 | } | 3599 | } |
3600 | void CalendarView::showJournal( Journal *jour ) | 3600 | void CalendarView::showJournal( Journal *jour ) |
3601 | { | 3601 | { |
3602 | getEventViewerDialog()->setJournal(jour); | 3602 | getEventViewerDialog()->setJournal(jour); |
3603 | getEventViewerDialog()->showMe(); | 3603 | getEventViewerDialog()->showMe(); |
3604 | 3604 | ||
3605 | } | 3605 | } |
3606 | // void CalendarView::todoModified (Todo *event, int changed) | 3606 | // void CalendarView::todoModified (Todo *event, int changed) |
3607 | // { | 3607 | // { |
3608 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 3608 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
3609 | // // kdDebug() << "Todo modified and open" << endl; | 3609 | // // kdDebug() << "Todo modified and open" << endl; |
3610 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 3610 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
3611 | // // temp->modified (changed); | 3611 | // // temp->modified (changed); |
3612 | 3612 | ||
3613 | // // } | 3613 | // // } |
3614 | 3614 | ||
3615 | // mViewManager->updateView(); | 3615 | // mViewManager->updateView(); |
3616 | // } | 3616 | // } |
3617 | 3617 | ||
3618 | void CalendarView::appointment_show() | 3618 | void CalendarView::appointment_show() |
3619 | { | 3619 | { |
3620 | Event *anEvent = 0; | 3620 | Event *anEvent = 0; |
3621 | 3621 | ||
3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3622 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3623 | 3623 | ||
3624 | if (mViewManager->currentView()->isEventView()) { | 3624 | if (mViewManager->currentView()->isEventView()) { |
3625 | if ( incidence && incidence->typeID() == eventID ) { | 3625 | if ( incidence && incidence->typeID() == eventID ) { |
3626 | anEvent = static_cast<Event *>(incidence); | 3626 | anEvent = static_cast<Event *>(incidence); |
3627 | } | 3627 | } |
3628 | } | 3628 | } |
3629 | 3629 | ||
3630 | if (!anEvent) { | 3630 | if (!anEvent) { |
3631 | KNotifyClient::beep(); | 3631 | KNotifyClient::beep(); |
3632 | return; | 3632 | return; |
3633 | } | 3633 | } |
3634 | 3634 | ||
3635 | showEvent(anEvent); | 3635 | showEvent(anEvent); |
3636 | } | 3636 | } |
3637 | 3637 | ||
3638 | void CalendarView::appointment_edit() | 3638 | void CalendarView::appointment_edit() |
3639 | { | 3639 | { |
3640 | Event *anEvent = 0; | 3640 | Event *anEvent = 0; |
3641 | 3641 | ||
3642 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3642 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3643 | 3643 | ||
3644 | if (mViewManager->currentView()->isEventView()) { | 3644 | if (mViewManager->currentView()->isEventView()) { |
3645 | if ( incidence && incidence->typeID() == eventID ) { | 3645 | if ( incidence && incidence->typeID() == eventID ) { |
3646 | anEvent = static_cast<Event *>(incidence); | 3646 | anEvent = static_cast<Event *>(incidence); |
3647 | } | 3647 | } |
3648 | } | 3648 | } |
3649 | 3649 | ||
3650 | if (!anEvent) { | 3650 | if (!anEvent) { |
3651 | KNotifyClient::beep(); | 3651 | KNotifyClient::beep(); |
3652 | return; | 3652 | return; |
3653 | } | 3653 | } |
3654 | 3654 | ||
3655 | editEvent(anEvent); | 3655 | editEvent(anEvent); |
3656 | } | 3656 | } |
3657 | 3657 | ||
3658 | void CalendarView::appointment_delete() | 3658 | void CalendarView::appointment_delete() |
3659 | { | 3659 | { |
3660 | Event *anEvent = 0; | 3660 | Event *anEvent = 0; |
3661 | 3661 | ||
3662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 3662 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
3663 | 3663 | ||
3664 | if (mViewManager->currentView()->isEventView()) { | 3664 | if (mViewManager->currentView()->isEventView()) { |
3665 | if ( incidence && incidence->typeID() == eventID ) { | 3665 | if ( incidence && incidence->typeID() == eventID ) { |
3666 | anEvent = static_cast<Event *>(incidence); | 3666 | anEvent = static_cast<Event *>(incidence); |
3667 | } | 3667 | } |
3668 | } | 3668 | } |
3669 | 3669 | ||
3670 | if (!anEvent) { | 3670 | if (!anEvent) { |
3671 | KNotifyClient::beep(); | 3671 | KNotifyClient::beep(); |
3672 | return; | 3672 | return; |
3673 | } | 3673 | } |
3674 | 3674 | ||
3675 | deleteEvent(anEvent); | 3675 | deleteEvent(anEvent); |
3676 | } | 3676 | } |
3677 | 3677 | ||
3678 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 3678 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
3679 | { | 3679 | { |
3680 | if (!sub) return; | 3680 | if (!sub) return; |
3681 | if ( sub->relatedTo() == parent ) | 3681 | if ( sub->relatedTo() == parent ) |
3682 | return; | 3682 | return; |
3683 | sub->setRelatedTo(parent); | 3683 | sub->setRelatedTo(parent); |
3684 | sub->updated(); | 3684 | sub->updated(); |
3685 | setModified(true); | 3685 | setModified(true); |
3686 | updateView(); | 3686 | updateView(); |
3687 | } | 3687 | } |
3688 | void CalendarView::todo_unsub(Todo *anTodo ) | 3688 | void CalendarView::todo_unsub(Todo *anTodo ) |
3689 | { | 3689 | { |
3690 | todo_resub( 0, anTodo ); | 3690 | todo_resub( 0, anTodo ); |
3691 | } | 3691 | } |
3692 | 3692 | ||
3693 | void CalendarView::deleteTodo(Todo *todo) | 3693 | void CalendarView::deleteTodo(Todo *todo) |
3694 | { | 3694 | { |
3695 | if (!todo) { | 3695 | if (!todo) { |
3696 | KNotifyClient::beep(); | 3696 | KNotifyClient::beep(); |
3697 | return; | 3697 | return; |
3698 | } | 3698 | } |
3699 | if (KOPrefs::instance()->mConfirm) { | 3699 | if (KOPrefs::instance()->mConfirm) { |
3700 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); | 3700 | QString text = KGlobal::formatMessage ( todo->summary(),0 ); |
3701 | if (!todo->relations().isEmpty()) { | 3701 | if (!todo->relations().isEmpty()) { |
3702 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); | 3702 | text += i18n("\nhas sub-todos.\nAll completed sub-todos\nwill be deleted as well!"); |
3703 | 3703 | ||
3704 | } | 3704 | } |
3705 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { | 3705 | switch (msgItemDelete(i18n("Todo:") +"\n"+text)) { |
3706 | case KMessageBox::Continue: // OK | 3706 | case KMessageBox::Continue: // OK |
3707 | bool deleteT = false; | 3707 | bool deleteT = false; |
3708 | if (!todo->relations().isEmpty()) { | 3708 | if (!todo->relations().isEmpty()) { |
3709 | deleteT = removeCompletedSubTodos( todo ); | 3709 | deleteT = removeCompletedSubTodos( todo ); |
3710 | } | 3710 | } |
3711 | // deleteT == true: todo already deleted in removeCompletedSubTodos | 3711 | // deleteT == true: todo already deleted in removeCompletedSubTodos |
3712 | if ( !deleteT ) { | 3712 | if ( !deleteT ) { |
3713 | checkExternalId( todo ); | 3713 | checkExternalId( todo ); |
3714 | calendar()->deleteTodo(todo); | 3714 | calendar()->deleteTodo(todo); |
3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3715 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3716 | updateView(); | 3716 | updateView(); |
3717 | } | 3717 | } |
3718 | break; | 3718 | break; |
3719 | } // switch | 3719 | } // switch |
3720 | } else { | 3720 | } else { |
3721 | checkExternalId( todo ); | 3721 | checkExternalId( todo ); |
3722 | mCalendar->deleteTodo(todo); | 3722 | mCalendar->deleteTodo(todo); |
3723 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 3723 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
3724 | updateView(); | 3724 | updateView(); |
3725 | } | 3725 | } |
3726 | 3726 | ||
3727 | emit updateSearchDialog(); | 3727 | emit updateSearchDialog(); |
3728 | } | 3728 | } |
3729 | void CalendarView::deleteJournal(Journal *jour) | 3729 | void CalendarView::deleteJournal(Journal *jour) |
3730 | { | 3730 | { |
3731 | if (!jour) { | 3731 | if (!jour) { |
3732 | KNotifyClient::beep(); | 3732 | KNotifyClient::beep(); |
3733 | return; | 3733 | return; |
3734 | } | 3734 | } |
3735 | if (KOPrefs::instance()->mConfirm) { | 3735 | if (KOPrefs::instance()->mConfirm) { |
3736 | 3736 | ||
3737 | QString des; | 3737 | QString des; |
3738 | if ( !jour->summary().isEmpty() ) { | 3738 | if ( !jour->summary().isEmpty() ) { |
3739 | des = jour->summary(); | 3739 | des = jour->summary(); |
3740 | } else { | 3740 | } else { |
3741 | des = jour->description().left(30); | 3741 | des = jour->description().left(30); |
3742 | des = des.simplifyWhiteSpace (); | 3742 | des = des.simplifyWhiteSpace (); |
3743 | des.replace (QRegExp ("\\n"),"" ); | 3743 | des.replace (QRegExp ("\\n"),"" ); |
3744 | des.replace (QRegExp ("\\r"),"" ); | 3744 | des.replace (QRegExp ("\\r"),"" ); |
3745 | } | 3745 | } |
3746 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { | 3746 | switch (msgItemDelete( i18n("Journal:") +"\n"+KGlobal::formatMessage ( des,0 ))) { |
3747 | case KMessageBox::Continue: // OK | 3747 | case KMessageBox::Continue: // OK |
3748 | calendar()->deleteJournal(jour); | 3748 | calendar()->deleteJournal(jour); |
3749 | updateView(); | 3749 | updateView(); |
3750 | break; | 3750 | break; |
3751 | } // switch | 3751 | } // switch |
3752 | } else { | 3752 | } else { |
3753 | calendar()->deleteJournal(jour);; | 3753 | calendar()->deleteJournal(jour);; |
3754 | updateView(); | 3754 | updateView(); |
3755 | } | 3755 | } |
3756 | emit updateSearchDialog(); | 3756 | emit updateSearchDialog(); |
3757 | } | 3757 | } |
3758 | 3758 | ||
3759 | void CalendarView::deleteEvent(Event *anEvent) | 3759 | void CalendarView::deleteEvent(Event *anEvent) |
3760 | { | 3760 | { |
3761 | if (!anEvent) { | 3761 | if (!anEvent) { |
3762 | KNotifyClient::beep(); | 3762 | KNotifyClient::beep(); |
3763 | return; | 3763 | return; |
3764 | } | 3764 | } |
3765 | 3765 | ||
3766 | if (anEvent->doesRecur()) { | 3766 | if (anEvent->doesRecur()) { |
3767 | QDate itemDate = mViewManager->currentSelectionDate(); | 3767 | QDate itemDate = mViewManager->currentSelectionDate(); |
3768 | int km; | 3768 | int km; |
3769 | if (!itemDate.isValid()) { | 3769 | if (!itemDate.isValid()) { |
3770 | //kdDebug() << "Date Not Valid" << endl; | 3770 | //kdDebug() << "Date Not Valid" << endl; |
3771 | if (KOPrefs::instance()->mConfirm) { | 3771 | if (KOPrefs::instance()->mConfirm) { |
3772 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3772 | km = KMessageBox::warningContinueCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3773 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 3773 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
3774 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 3774 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
3775 | if ( km == KMessageBox::Continue ) | 3775 | if ( km == KMessageBox::Continue ) |
3776 | km = KMessageBox::No; // No = all below | 3776 | km = KMessageBox::No; // No = all below |
3777 | } else | 3777 | } else |
3778 | km = KMessageBox::No; | 3778 | km = KMessageBox::No; |
3779 | } else { | 3779 | } else { |
3780 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + | 3780 | km = KMessageBox::warningYesNoCancel(this,KGlobal::formatMessage ( anEvent->summary(),0 ) + |
3781 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 3781 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |