author | zautrix <zautrix> | 2005-03-17 20:00:15 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-17 20:00:15 (UTC) |
commit | de34f05c4545688dec24f8d75fc03e42f38b94d1 (patch) (unidiff) | |
tree | 141a403ad18583748284b1aff745b4dcb30c67b5 | |
parent | 81295ee3a5e7e90fb4c6baf27ecbb65bee1de5b5 (diff) | |
download | kdepimpi-de34f05c4545688dec24f8d75fc03e42f38b94d1.zip kdepimpi-de34f05c4545688dec24f8d75fc03e42f38b94d1.tar.gz kdepimpi-de34f05c4545688dec24f8d75fc03e42f38b94d1.tar.bz2 |
filter fix
-rw-r--r-- | korganizer/calendarview.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index d6918d3..6eaac1c 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -3101,888 +3101,892 @@ void CalendarView::action_mail() | |||
3101 | if (!incidence) { | 3101 | if (!incidence) { |
3102 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3102 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3103 | return; | 3103 | return; |
3104 | } | 3104 | } |
3105 | if(incidence->attendeeCount() == 0 ) { | 3105 | if(incidence->attendeeCount() == 0 ) { |
3106 | KMessageBox::sorry(this, | 3106 | KMessageBox::sorry(this, |
3107 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3107 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3108 | return; | 3108 | return; |
3109 | } | 3109 | } |
3110 | 3110 | ||
3111 | CalendarLocal cal_tmp; | 3111 | CalendarLocal cal_tmp; |
3112 | Event *event = 0; | 3112 | Event *event = 0; |
3113 | Event *ev = 0; | 3113 | Event *ev = 0; |
3114 | if ( incidence && incidence->type() == "Event" ) { | 3114 | if ( incidence && incidence->type() == "Event" ) { |
3115 | event = static_cast<Event *>(incidence); | 3115 | event = static_cast<Event *>(incidence); |
3116 | ev = new Event(*event); | 3116 | ev = new Event(*event); |
3117 | cal_tmp.addEvent(ev); | 3117 | cal_tmp.addEvent(ev); |
3118 | } | 3118 | } |
3119 | ICalFormat mForm(); | 3119 | ICalFormat mForm(); |
3120 | QString attachment = mForm.toString( &cal_tmp ); | 3120 | QString attachment = mForm.toString( &cal_tmp ); |
3121 | if (ev) delete(ev); | 3121 | if (ev) delete(ev); |
3122 | 3122 | ||
3123 | mailClient.mailAttendees(currentSelection(), attachment); | 3123 | mailClient.mailAttendees(currentSelection(), attachment); |
3124 | 3124 | ||
3125 | #endif | 3125 | #endif |
3126 | 3126 | ||
3127 | #if 0 | 3127 | #if 0 |
3128 | Event *anEvent = 0; | 3128 | Event *anEvent = 0; |
3129 | if (mViewManager->currentView()->isEventView()) { | 3129 | if (mViewManager->currentView()->isEventView()) { |
3130 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); | 3130 | anEvent = dynamic_cast<Event *>((mViewManager->currentView()->selectedIncidences()).first()); |
3131 | } | 3131 | } |
3132 | 3132 | ||
3133 | if (!anEvent) { | 3133 | if (!anEvent) { |
3134 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); | 3134 | KMessageBox::sorry(this,i18n("Can't generate mail:\nNo event selected.")); |
3135 | return; | 3135 | return; |
3136 | } | 3136 | } |
3137 | if(anEvent->attendeeCount() == 0 ) { | 3137 | if(anEvent->attendeeCount() == 0 ) { |
3138 | KMessageBox::sorry(this, | 3138 | KMessageBox::sorry(this, |
3139 | i18n("Can't generate mail:\nNo attendees defined.\n")); | 3139 | i18n("Can't generate mail:\nNo attendees defined.\n")); |
3140 | return; | 3140 | return; |
3141 | } | 3141 | } |
3142 | 3142 | ||
3143 | mailobject.emailEvent(anEvent); | 3143 | mailobject.emailEvent(anEvent); |
3144 | #endif | 3144 | #endif |
3145 | } | 3145 | } |
3146 | 3146 | ||
3147 | 3147 | ||
3148 | void CalendarView::schedule_publish(Incidence *incidence) | 3148 | void CalendarView::schedule_publish(Incidence *incidence) |
3149 | { | 3149 | { |
3150 | Event *event = 0; | 3150 | Event *event = 0; |
3151 | Todo *todo = 0; | 3151 | Todo *todo = 0; |
3152 | 3152 | ||
3153 | if (incidence == 0) { | 3153 | if (incidence == 0) { |
3154 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3154 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3155 | if (incidence == 0) { | 3155 | if (incidence == 0) { |
3156 | incidence = mTodoList->selectedIncidences().first(); | 3156 | incidence = mTodoList->selectedIncidences().first(); |
3157 | } | 3157 | } |
3158 | } | 3158 | } |
3159 | if ( incidence && incidence->type() == "Event" ) { | 3159 | if ( incidence && incidence->type() == "Event" ) { |
3160 | event = static_cast<Event *>(incidence); | 3160 | event = static_cast<Event *>(incidence); |
3161 | } else { | 3161 | } else { |
3162 | if ( incidence && incidence->type() == "Todo" ) { | 3162 | if ( incidence && incidence->type() == "Todo" ) { |
3163 | todo = static_cast<Todo *>(incidence); | 3163 | todo = static_cast<Todo *>(incidence); |
3164 | } | 3164 | } |
3165 | } | 3165 | } |
3166 | 3166 | ||
3167 | if (!event && !todo) { | 3167 | if (!event && !todo) { |
3168 | KMessageBox::sorry(this,i18n("No event selected.")); | 3168 | KMessageBox::sorry(this,i18n("No event selected.")); |
3169 | return; | 3169 | return; |
3170 | } | 3170 | } |
3171 | 3171 | ||
3172 | PublishDialog *publishdlg = new PublishDialog(); | 3172 | PublishDialog *publishdlg = new PublishDialog(); |
3173 | if (incidence->attendeeCount()>0) { | 3173 | if (incidence->attendeeCount()>0) { |
3174 | QPtrList<Attendee> attendees = incidence->attendees(); | 3174 | QPtrList<Attendee> attendees = incidence->attendees(); |
3175 | attendees.first(); | 3175 | attendees.first(); |
3176 | while ( attendees.current()!=0 ) { | 3176 | while ( attendees.current()!=0 ) { |
3177 | publishdlg->addAttendee(attendees.current()); | 3177 | publishdlg->addAttendee(attendees.current()); |
3178 | attendees.next(); | 3178 | attendees.next(); |
3179 | } | 3179 | } |
3180 | } | 3180 | } |
3181 | bool send = true; | 3181 | bool send = true; |
3182 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { | 3182 | if ( KOPrefs::instance()->mMailClient == KOPrefs::MailClientSendmail ) { |
3183 | if ( publishdlg->exec() != QDialog::Accepted ) | 3183 | if ( publishdlg->exec() != QDialog::Accepted ) |
3184 | send = false; | 3184 | send = false; |
3185 | } | 3185 | } |
3186 | if ( send ) { | 3186 | if ( send ) { |
3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3187 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3188 | if ( event ) { | 3188 | if ( event ) { |
3189 | Event *ev = new Event(*event); | 3189 | Event *ev = new Event(*event); |
3190 | ev->registerObserver(0); | 3190 | ev->registerObserver(0); |
3191 | ev->clearAttendees(); | 3191 | ev->clearAttendees(); |
3192 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3192 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3193 | delete(ev); | 3193 | delete(ev); |
3194 | } | 3194 | } |
3195 | } else { | 3195 | } else { |
3196 | if ( todo ) { | 3196 | if ( todo ) { |
3197 | Todo *ev = new Todo(*todo); | 3197 | Todo *ev = new Todo(*todo); |
3198 | ev->registerObserver(0); | 3198 | ev->registerObserver(0); |
3199 | ev->clearAttendees(); | 3199 | ev->clearAttendees(); |
3200 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { | 3200 | if (!dlg->addMessage(ev,Scheduler::Publish,publishdlg->addresses())) { |
3201 | delete(ev); | 3201 | delete(ev); |
3202 | } | 3202 | } |
3203 | } | 3203 | } |
3204 | } | 3204 | } |
3205 | } | 3205 | } |
3206 | delete publishdlg; | 3206 | delete publishdlg; |
3207 | } | 3207 | } |
3208 | 3208 | ||
3209 | void CalendarView::schedule_request(Incidence *incidence) | 3209 | void CalendarView::schedule_request(Incidence *incidence) |
3210 | { | 3210 | { |
3211 | schedule(Scheduler::Request,incidence); | 3211 | schedule(Scheduler::Request,incidence); |
3212 | } | 3212 | } |
3213 | 3213 | ||
3214 | void CalendarView::schedule_refresh(Incidence *incidence) | 3214 | void CalendarView::schedule_refresh(Incidence *incidence) |
3215 | { | 3215 | { |
3216 | schedule(Scheduler::Refresh,incidence); | 3216 | schedule(Scheduler::Refresh,incidence); |
3217 | } | 3217 | } |
3218 | 3218 | ||
3219 | void CalendarView::schedule_cancel(Incidence *incidence) | 3219 | void CalendarView::schedule_cancel(Incidence *incidence) |
3220 | { | 3220 | { |
3221 | schedule(Scheduler::Cancel,incidence); | 3221 | schedule(Scheduler::Cancel,incidence); |
3222 | } | 3222 | } |
3223 | 3223 | ||
3224 | void CalendarView::schedule_add(Incidence *incidence) | 3224 | void CalendarView::schedule_add(Incidence *incidence) |
3225 | { | 3225 | { |
3226 | schedule(Scheduler::Add,incidence); | 3226 | schedule(Scheduler::Add,incidence); |
3227 | } | 3227 | } |
3228 | 3228 | ||
3229 | void CalendarView::schedule_reply(Incidence *incidence) | 3229 | void CalendarView::schedule_reply(Incidence *incidence) |
3230 | { | 3230 | { |
3231 | schedule(Scheduler::Reply,incidence); | 3231 | schedule(Scheduler::Reply,incidence); |
3232 | } | 3232 | } |
3233 | 3233 | ||
3234 | void CalendarView::schedule_counter(Incidence *incidence) | 3234 | void CalendarView::schedule_counter(Incidence *incidence) |
3235 | { | 3235 | { |
3236 | schedule(Scheduler::Counter,incidence); | 3236 | schedule(Scheduler::Counter,incidence); |
3237 | } | 3237 | } |
3238 | 3238 | ||
3239 | void CalendarView::schedule_declinecounter(Incidence *incidence) | 3239 | void CalendarView::schedule_declinecounter(Incidence *incidence) |
3240 | { | 3240 | { |
3241 | schedule(Scheduler::Declinecounter,incidence); | 3241 | schedule(Scheduler::Declinecounter,incidence); |
3242 | } | 3242 | } |
3243 | 3243 | ||
3244 | void CalendarView::schedule_publish_freebusy(int daysToPublish) | 3244 | void CalendarView::schedule_publish_freebusy(int daysToPublish) |
3245 | { | 3245 | { |
3246 | QDateTime start = QDateTime::currentDateTime(); | 3246 | QDateTime start = QDateTime::currentDateTime(); |
3247 | QDateTime end = start.addDays(daysToPublish); | 3247 | QDateTime end = start.addDays(daysToPublish); |
3248 | 3248 | ||
3249 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); | 3249 | FreeBusy *freebusy = new FreeBusy(mCalendar, start, end); |
3250 | freebusy->setOrganizer(KOPrefs::instance()->email()); | 3250 | freebusy->setOrganizer(KOPrefs::instance()->email()); |
3251 | 3251 | ||
3252 | 3252 | ||
3253 | PublishDialog *publishdlg = new PublishDialog(); | 3253 | PublishDialog *publishdlg = new PublishDialog(); |
3254 | if ( publishdlg->exec() == QDialog::Accepted ) { | 3254 | if ( publishdlg->exec() == QDialog::Accepted ) { |
3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3255 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3256 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { | 3256 | if (!dlg->addMessage(freebusy,Scheduler::Publish,publishdlg->addresses())) { |
3257 | delete(freebusy); | 3257 | delete(freebusy); |
3258 | } | 3258 | } |
3259 | } | 3259 | } |
3260 | delete publishdlg; | 3260 | delete publishdlg; |
3261 | } | 3261 | } |
3262 | 3262 | ||
3263 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) | 3263 | void CalendarView::schedule(Scheduler::Method method, Incidence *incidence) |
3264 | { | 3264 | { |
3265 | Event *event = 0; | 3265 | Event *event = 0; |
3266 | Todo *todo = 0; | 3266 | Todo *todo = 0; |
3267 | 3267 | ||
3268 | if (incidence == 0) { | 3268 | if (incidence == 0) { |
3269 | incidence = mViewManager->currentView()->selectedIncidences().first(); | 3269 | incidence = mViewManager->currentView()->selectedIncidences().first(); |
3270 | if (incidence == 0) { | 3270 | if (incidence == 0) { |
3271 | incidence = mTodoList->selectedIncidences().first(); | 3271 | incidence = mTodoList->selectedIncidences().first(); |
3272 | } | 3272 | } |
3273 | } | 3273 | } |
3274 | if ( incidence && incidence->type() == "Event" ) { | 3274 | if ( incidence && incidence->type() == "Event" ) { |
3275 | event = static_cast<Event *>(incidence); | 3275 | event = static_cast<Event *>(incidence); |
3276 | } | 3276 | } |
3277 | if ( incidence && incidence->type() == "Todo" ) { | 3277 | if ( incidence && incidence->type() == "Todo" ) { |
3278 | todo = static_cast<Todo *>(incidence); | 3278 | todo = static_cast<Todo *>(incidence); |
3279 | } | 3279 | } |
3280 | 3280 | ||
3281 | if (!event && !todo) { | 3281 | if (!event && !todo) { |
3282 | KMessageBox::sorry(this,i18n("No event selected.")); | 3282 | KMessageBox::sorry(this,i18n("No event selected.")); |
3283 | return; | 3283 | return; |
3284 | } | 3284 | } |
3285 | 3285 | ||
3286 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { | 3286 | if( incidence->attendeeCount() == 0 && method != Scheduler::Publish ) { |
3287 | KMessageBox::sorry(this,i18n("The event has no attendees.")); | 3287 | KMessageBox::sorry(this,i18n("The event has no attendees.")); |
3288 | return; | 3288 | return; |
3289 | } | 3289 | } |
3290 | 3290 | ||
3291 | Event *ev = 0; | 3291 | Event *ev = 0; |
3292 | if (event) ev = new Event(*event); | 3292 | if (event) ev = new Event(*event); |
3293 | Todo *to = 0; | 3293 | Todo *to = 0; |
3294 | if (todo) to = new Todo(*todo); | 3294 | if (todo) to = new Todo(*todo); |
3295 | 3295 | ||
3296 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { | 3296 | if (method == Scheduler::Reply || method == Scheduler::Refresh) { |
3297 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); | 3297 | Attendee *me = incidence->attendeeByMails(KOPrefs::instance()->mAdditionalMails,KOPrefs::instance()->email()); |
3298 | if (!me) { | 3298 | if (!me) { |
3299 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); | 3299 | KMessageBox::sorry(this,i18n("Could not find your attendee entry.\nPlease check the emails.")); |
3300 | return; | 3300 | return; |
3301 | } | 3301 | } |
3302 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { | 3302 | if (me->status()==Attendee::NeedsAction && me->RSVP() && method==Scheduler::Reply) { |
3303 | StatusDialog *statdlg = new StatusDialog(this); | 3303 | StatusDialog *statdlg = new StatusDialog(this); |
3304 | if (!statdlg->exec()==QDialog::Accepted) return; | 3304 | if (!statdlg->exec()==QDialog::Accepted) return; |
3305 | me->setStatus( statdlg->status() ); | 3305 | me->setStatus( statdlg->status() ); |
3306 | delete(statdlg); | 3306 | delete(statdlg); |
3307 | } | 3307 | } |
3308 | Attendee *menew = new Attendee(*me); | 3308 | Attendee *menew = new Attendee(*me); |
3309 | if (ev) { | 3309 | if (ev) { |
3310 | ev->clearAttendees(); | 3310 | ev->clearAttendees(); |
3311 | ev->addAttendee(menew,false); | 3311 | ev->addAttendee(menew,false); |
3312 | } else { | 3312 | } else { |
3313 | if (to) { | 3313 | if (to) { |
3314 | todo->clearAttendees(); | 3314 | todo->clearAttendees(); |
3315 | todo->addAttendee(menew,false); | 3315 | todo->addAttendee(menew,false); |
3316 | } | 3316 | } |
3317 | } | 3317 | } |
3318 | } | 3318 | } |
3319 | 3319 | ||
3320 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); | 3320 | OutgoingDialog *dlg = mDialogManager->outgoingDialog(); |
3321 | if (ev) { | 3321 | if (ev) { |
3322 | if ( !dlg->addMessage(ev,method) ) delete(ev); | 3322 | if ( !dlg->addMessage(ev,method) ) delete(ev); |
3323 | } else { | 3323 | } else { |
3324 | if (to) { | 3324 | if (to) { |
3325 | if ( !dlg->addMessage(to,method) ) delete(to); | 3325 | if ( !dlg->addMessage(to,method) ) delete(to); |
3326 | } | 3326 | } |
3327 | } | 3327 | } |
3328 | } | 3328 | } |
3329 | 3329 | ||
3330 | void CalendarView::openAddressbook() | 3330 | void CalendarView::openAddressbook() |
3331 | { | 3331 | { |
3332 | KRun::runCommand("kaddressbook"); | 3332 | KRun::runCommand("kaddressbook"); |
3333 | } | 3333 | } |
3334 | 3334 | ||
3335 | void CalendarView::setModified(bool modified) | 3335 | void CalendarView::setModified(bool modified) |
3336 | { | 3336 | { |
3337 | if ( modified ) | 3337 | if ( modified ) |
3338 | emit signalmodified(); | 3338 | emit signalmodified(); |
3339 | if (mModified != modified) { | 3339 | if (mModified != modified) { |
3340 | mModified = modified; | 3340 | mModified = modified; |
3341 | emit modifiedChanged(mModified); | 3341 | emit modifiedChanged(mModified); |
3342 | } | 3342 | } |
3343 | } | 3343 | } |
3344 | 3344 | ||
3345 | bool CalendarView::isReadOnly() | 3345 | bool CalendarView::isReadOnly() |
3346 | { | 3346 | { |
3347 | return mReadOnly; | 3347 | return mReadOnly; |
3348 | } | 3348 | } |
3349 | 3349 | ||
3350 | void CalendarView::setReadOnly(bool readOnly) | 3350 | void CalendarView::setReadOnly(bool readOnly) |
3351 | { | 3351 | { |
3352 | if (mReadOnly != readOnly) { | 3352 | if (mReadOnly != readOnly) { |
3353 | mReadOnly = readOnly; | 3353 | mReadOnly = readOnly; |
3354 | emit readOnlyChanged(mReadOnly); | 3354 | emit readOnlyChanged(mReadOnly); |
3355 | } | 3355 | } |
3356 | } | 3356 | } |
3357 | 3357 | ||
3358 | bool CalendarView::isModified() | 3358 | bool CalendarView::isModified() |
3359 | { | 3359 | { |
3360 | return mModified; | 3360 | return mModified; |
3361 | } | 3361 | } |
3362 | 3362 | ||
3363 | void CalendarView::printSetup() | 3363 | void CalendarView::printSetup() |
3364 | { | 3364 | { |
3365 | #ifndef KORG_NOPRINTER | 3365 | #ifndef KORG_NOPRINTER |
3366 | createPrinter(); | 3366 | createPrinter(); |
3367 | 3367 | ||
3368 | mCalPrinter->setupPrinter(); | 3368 | mCalPrinter->setupPrinter(); |
3369 | #endif | 3369 | #endif |
3370 | } | 3370 | } |
3371 | 3371 | ||
3372 | void CalendarView::print() | 3372 | void CalendarView::print() |
3373 | { | 3373 | { |
3374 | #ifndef KORG_NOPRINTER | 3374 | #ifndef KORG_NOPRINTER |
3375 | createPrinter(); | 3375 | createPrinter(); |
3376 | 3376 | ||
3377 | DateList tmpDateList = mNavigator->selectedDates(); | 3377 | DateList tmpDateList = mNavigator->selectedDates(); |
3378 | mCalPrinter->print(CalPrinter::Month, | 3378 | mCalPrinter->print(CalPrinter::Month, |
3379 | tmpDateList.first(), tmpDateList.last()); | 3379 | tmpDateList.first(), tmpDateList.last()); |
3380 | #endif | 3380 | #endif |
3381 | } | 3381 | } |
3382 | 3382 | ||
3383 | void CalendarView::printPreview() | 3383 | void CalendarView::printPreview() |
3384 | { | 3384 | { |
3385 | #ifndef KORG_NOPRINTER | 3385 | #ifndef KORG_NOPRINTER |
3386 | kdDebug() << "CalendarView::printPreview()" << endl; | 3386 | kdDebug() << "CalendarView::printPreview()" << endl; |
3387 | 3387 | ||
3388 | createPrinter(); | 3388 | createPrinter(); |
3389 | 3389 | ||
3390 | DateList tmpDateList = mNavigator->selectedDates(); | 3390 | DateList tmpDateList = mNavigator->selectedDates(); |
3391 | 3391 | ||
3392 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), | 3392 | mViewManager->currentView()->printPreview(mCalPrinter,tmpDateList.first(), |
3393 | tmpDateList.last()); | 3393 | tmpDateList.last()); |
3394 | #endif | 3394 | #endif |
3395 | } | 3395 | } |
3396 | 3396 | ||
3397 | void CalendarView::exportICalendar() | 3397 | void CalendarView::exportICalendar() |
3398 | { | 3398 | { |
3399 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); | 3399 | QString filename = KFileDialog::getSaveFileName("icalout.ics",i18n("*.ics|ICalendars"),this); |
3400 | 3400 | ||
3401 | // Force correct extension | 3401 | // Force correct extension |
3402 | if (filename.right(4) != ".ics") filename += ".ics"; | 3402 | if (filename.right(4) != ".ics") filename += ".ics"; |
3403 | 3403 | ||
3404 | FileStorage storage( mCalendar, filename, new ICalFormat() ); | 3404 | FileStorage storage( mCalendar, filename, new ICalFormat() ); |
3405 | storage.save(); | 3405 | storage.save(); |
3406 | } | 3406 | } |
3407 | 3407 | ||
3408 | bool CalendarView::exportVCalendar( QString filename ) | 3408 | bool CalendarView::exportVCalendar( QString filename ) |
3409 | { | 3409 | { |
3410 | if (mCalendar->journals().count() > 0) { | 3410 | if (mCalendar->journals().count() > 0) { |
3411 | int result = KMessageBox::warningContinueCancel(this, | 3411 | int result = KMessageBox::warningContinueCancel(this, |
3412 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 3412 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
3413 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 3413 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
3414 | true); | 3414 | true); |
3415 | if (result != KMessageBox::Continue) return false; | 3415 | if (result != KMessageBox::Continue) return false; |
3416 | } | 3416 | } |
3417 | 3417 | ||
3418 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); | 3418 | //QString filename = KFileDialog::getSaveFileName("vcalout.vcs",i18n("*.vcs|VCalendars"),this); |
3419 | 3419 | ||
3420 | // Force correct extension | 3420 | // Force correct extension |
3421 | if (filename.right(4) != ".vcs") filename += ".vcs"; | 3421 | if (filename.right(4) != ".vcs") filename += ".vcs"; |
3422 | 3422 | ||
3423 | FileStorage storage( mCalendar, filename, new VCalFormat ); | 3423 | FileStorage storage( mCalendar, filename, new VCalFormat ); |
3424 | return storage.save(); | 3424 | return storage.save(); |
3425 | 3425 | ||
3426 | } | 3426 | } |
3427 | 3427 | ||
3428 | void CalendarView::eventUpdated(Incidence *) | 3428 | void CalendarView::eventUpdated(Incidence *) |
3429 | { | 3429 | { |
3430 | setModified(); | 3430 | setModified(); |
3431 | // Don't call updateView here. The code, which has caused the update of the | 3431 | // Don't call updateView here. The code, which has caused the update of the |
3432 | // event is responsible for updating the view. | 3432 | // event is responsible for updating the view. |
3433 | // updateView(); | 3433 | // updateView(); |
3434 | } | 3434 | } |
3435 | 3435 | ||
3436 | void CalendarView::adaptNavigationUnits() | 3436 | void CalendarView::adaptNavigationUnits() |
3437 | { | 3437 | { |
3438 | if (mViewManager->currentView()->isEventView()) { | 3438 | if (mViewManager->currentView()->isEventView()) { |
3439 | int days = mViewManager->currentView()->currentDateCount(); | 3439 | int days = mViewManager->currentView()->currentDateCount(); |
3440 | if (days == 1) { | 3440 | if (days == 1) { |
3441 | emit changeNavStringPrev(i18n("&Previous Day")); | 3441 | emit changeNavStringPrev(i18n("&Previous Day")); |
3442 | emit changeNavStringNext(i18n("&Next Day")); | 3442 | emit changeNavStringNext(i18n("&Next Day")); |
3443 | } else { | 3443 | } else { |
3444 | emit changeNavStringPrev(i18n("&Previous Week")); | 3444 | emit changeNavStringPrev(i18n("&Previous Week")); |
3445 | emit changeNavStringNext(i18n("&Next Week")); | 3445 | emit changeNavStringNext(i18n("&Next Week")); |
3446 | } | 3446 | } |
3447 | } | 3447 | } |
3448 | } | 3448 | } |
3449 | 3449 | ||
3450 | void CalendarView::processMainViewSelection( Incidence *incidence ) | 3450 | void CalendarView::processMainViewSelection( Incidence *incidence ) |
3451 | { | 3451 | { |
3452 | if ( incidence ) mTodoList->clearSelection(); | 3452 | if ( incidence ) mTodoList->clearSelection(); |
3453 | processIncidenceSelection( incidence ); | 3453 | processIncidenceSelection( incidence ); |
3454 | } | 3454 | } |
3455 | 3455 | ||
3456 | void CalendarView::processTodoListSelection( Incidence *incidence ) | 3456 | void CalendarView::processTodoListSelection( Incidence *incidence ) |
3457 | { | 3457 | { |
3458 | if ( incidence && mViewManager->currentView() ) { | 3458 | if ( incidence && mViewManager->currentView() ) { |
3459 | mViewManager->currentView()->clearSelection(); | 3459 | mViewManager->currentView()->clearSelection(); |
3460 | } | 3460 | } |
3461 | processIncidenceSelection( incidence ); | 3461 | processIncidenceSelection( incidence ); |
3462 | } | 3462 | } |
3463 | 3463 | ||
3464 | void CalendarView::processIncidenceSelection( Incidence *incidence ) | 3464 | void CalendarView::processIncidenceSelection( Incidence *incidence ) |
3465 | { | 3465 | { |
3466 | if ( incidence == mSelectedIncidence ) return; | 3466 | if ( incidence == mSelectedIncidence ) return; |
3467 | 3467 | ||
3468 | mSelectedIncidence = incidence; | 3468 | mSelectedIncidence = incidence; |
3469 | 3469 | ||
3470 | emit incidenceSelected( mSelectedIncidence ); | 3470 | emit incidenceSelected( mSelectedIncidence ); |
3471 | 3471 | ||
3472 | if ( incidence && incidence->type() == "Event" ) { | 3472 | if ( incidence && incidence->type() == "Event" ) { |
3473 | Event *event = static_cast<Event *>( incidence ); | 3473 | Event *event = static_cast<Event *>( incidence ); |
3474 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3474 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3475 | emit organizerEventsSelected( true ); | 3475 | emit organizerEventsSelected( true ); |
3476 | } else { | 3476 | } else { |
3477 | emit organizerEventsSelected(false); | 3477 | emit organizerEventsSelected(false); |
3478 | } | 3478 | } |
3479 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3479 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3480 | KOPrefs::instance()->email() ) ) { | 3480 | KOPrefs::instance()->email() ) ) { |
3481 | emit groupEventsSelected( true ); | 3481 | emit groupEventsSelected( true ); |
3482 | } else { | 3482 | } else { |
3483 | emit groupEventsSelected(false); | 3483 | emit groupEventsSelected(false); |
3484 | } | 3484 | } |
3485 | return; | 3485 | return; |
3486 | } else { | 3486 | } else { |
3487 | if ( incidence && incidence->type() == "Todo" ) { | 3487 | if ( incidence && incidence->type() == "Todo" ) { |
3488 | emit todoSelected( true ); | 3488 | emit todoSelected( true ); |
3489 | Todo *event = static_cast<Todo *>( incidence ); | 3489 | Todo *event = static_cast<Todo *>( incidence ); |
3490 | if ( event->organizer() == KOPrefs::instance()->email() ) { | 3490 | if ( event->organizer() == KOPrefs::instance()->email() ) { |
3491 | emit organizerEventsSelected( true ); | 3491 | emit organizerEventsSelected( true ); |
3492 | } else { | 3492 | } else { |
3493 | emit organizerEventsSelected(false); | 3493 | emit organizerEventsSelected(false); |
3494 | } | 3494 | } |
3495 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, | 3495 | if (event->attendeeByMails( KOPrefs::instance()->mAdditionalMails, |
3496 | KOPrefs::instance()->email() ) ) { | 3496 | KOPrefs::instance()->email() ) ) { |
3497 | emit groupEventsSelected( true ); | 3497 | emit groupEventsSelected( true ); |
3498 | } else { | 3498 | } else { |
3499 | emit groupEventsSelected(false); | 3499 | emit groupEventsSelected(false); |
3500 | } | 3500 | } |
3501 | return; | 3501 | return; |
3502 | } else { | 3502 | } else { |
3503 | emit todoSelected( false ); | 3503 | emit todoSelected( false ); |
3504 | emit organizerEventsSelected(false); | 3504 | emit organizerEventsSelected(false); |
3505 | emit groupEventsSelected(false); | 3505 | emit groupEventsSelected(false); |
3506 | } | 3506 | } |
3507 | return; | 3507 | return; |
3508 | } | 3508 | } |
3509 | 3509 | ||
3510 | /* if ( incidence && incidence->type() == "Todo" ) { | 3510 | /* if ( incidence && incidence->type() == "Todo" ) { |
3511 | emit todoSelected( true ); | 3511 | emit todoSelected( true ); |
3512 | } else { | 3512 | } else { |
3513 | emit todoSelected( false ); | 3513 | emit todoSelected( false ); |
3514 | }*/ | 3514 | }*/ |
3515 | } | 3515 | } |
3516 | 3516 | ||
3517 | 3517 | ||
3518 | void CalendarView::checkClipboard() | 3518 | void CalendarView::checkClipboard() |
3519 | { | 3519 | { |
3520 | #ifndef KORG_NODND | 3520 | #ifndef KORG_NODND |
3521 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { | 3521 | if (ICalDrag::canDecode(QApplication::clipboard()->data())) { |
3522 | emit pasteEnabled(true); | 3522 | emit pasteEnabled(true); |
3523 | } else { | 3523 | } else { |
3524 | emit pasteEnabled(false); | 3524 | emit pasteEnabled(false); |
3525 | } | 3525 | } |
3526 | #endif | 3526 | #endif |
3527 | } | 3527 | } |
3528 | 3528 | ||
3529 | void CalendarView::showDates(const DateList &selectedDates) | 3529 | void CalendarView::showDates(const DateList &selectedDates) |
3530 | { | 3530 | { |
3531 | // kdDebug() << "CalendarView::selectDates()" << endl; | 3531 | // kdDebug() << "CalendarView::selectDates()" << endl; |
3532 | 3532 | ||
3533 | 3533 | ||
3534 | if ( !mBlockShowDates ) { | 3534 | if ( !mBlockShowDates ) { |
3535 | if ( mViewManager->currentView() ) { | 3535 | if ( mViewManager->currentView() ) { |
3536 | updateView( selectedDates.first(), selectedDates.last() ); | 3536 | updateView( selectedDates.first(), selectedDates.last() ); |
3537 | } else { | 3537 | } else { |
3538 | mViewManager->showAgendaView(); | 3538 | mViewManager->showAgendaView(); |
3539 | } | 3539 | } |
3540 | } | 3540 | } |
3541 | 3541 | ||
3542 | QString selDates; | 3542 | QString selDates; |
3543 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); | 3543 | selDates = KGlobal::locale()->formatDate( selectedDates.first(), true); |
3544 | if (selectedDates.first() < selectedDates.last() ) | 3544 | if (selectedDates.first() < selectedDates.last() ) |
3545 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); | 3545 | selDates += " - " + KGlobal::locale()->formatDate( selectedDates.last(),true); |
3546 | else { | 3546 | else { |
3547 | QString addString; | 3547 | QString addString; |
3548 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) | 3548 | if ( selectedDates.first() == QDateTime::currentDateTime().date() ) |
3549 | addString = i18n("Today"); | 3549 | addString = i18n("Today"); |
3550 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) | 3550 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) |
3551 | addString = i18n("Tomorrow"); | 3551 | addString = i18n("Tomorrow"); |
3552 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) | 3552 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) |
3553 | addString = i18n("Yesterday"); | 3553 | addString = i18n("Yesterday"); |
3554 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) | 3554 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) |
3555 | addString = i18n("Day before yesterday"); | 3555 | addString = i18n("Day before yesterday"); |
3556 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) | 3556 | else if ( selectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) |
3557 | addString = i18n("Day after tomorrow"); | 3557 | addString = i18n("Day after tomorrow"); |
3558 | if ( !addString.isEmpty() ) { | 3558 | if ( !addString.isEmpty() ) { |
3559 | topLevelWidget()->setCaption( addString+", " + selDates ); | 3559 | topLevelWidget()->setCaption( addString+", " + selDates ); |
3560 | return; | 3560 | return; |
3561 | } | 3561 | } |
3562 | } | 3562 | } |
3563 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); | 3563 | topLevelWidget()->setCaption( i18n("Dates: ") + selDates ); |
3564 | 3564 | ||
3565 | } | 3565 | } |
3566 | 3566 | ||
3567 | QPtrList<CalFilter> CalendarView::filters() | 3567 | QPtrList<CalFilter> CalendarView::filters() |
3568 | { | 3568 | { |
3569 | return mFilters; | 3569 | return mFilters; |
3570 | 3570 | ||
3571 | } | 3571 | } |
3572 | void CalendarView::editFilters() | 3572 | void CalendarView::editFilters() |
3573 | { | 3573 | { |
3574 | // kdDebug() << "CalendarView::editFilters()" << endl; | 3574 | // kdDebug() << "CalendarView::editFilters()" << endl; |
3575 | 3575 | ||
3576 | CalFilter *filter = mFilters.first(); | 3576 | CalFilter *filter = mFilters.first(); |
3577 | while(filter) { | 3577 | while(filter) { |
3578 | kdDebug() << " Filter: " << filter->name() << endl; | 3578 | kdDebug() << " Filter: " << filter->name() << endl; |
3579 | filter = mFilters.next(); | 3579 | filter = mFilters.next(); |
3580 | } | 3580 | } |
3581 | 3581 | ||
3582 | mDialogManager->showFilterEditDialog(&mFilters); | 3582 | mDialogManager->showFilterEditDialog(&mFilters); |
3583 | } | 3583 | } |
3584 | void CalendarView::toggleFilter() | 3584 | void CalendarView::toggleFilter() |
3585 | { | 3585 | { |
3586 | showFilter(! mFilterView->isVisible()); | 3586 | showFilter(! mFilterView->isVisible()); |
3587 | } | 3587 | } |
3588 | 3588 | ||
3589 | KOFilterView *CalendarView::filterView() | 3589 | KOFilterView *CalendarView::filterView() |
3590 | { | 3590 | { |
3591 | return mFilterView; | 3591 | return mFilterView; |
3592 | } | 3592 | } |
3593 | void CalendarView::selectFilter( int fil ) | 3593 | void CalendarView::selectFilter( int fil ) |
3594 | { | 3594 | { |
3595 | mFilterView->setSelectedFilter( fil ); | 3595 | mFilterView->setSelectedFilter( fil ); |
3596 | } | 3596 | } |
3597 | void CalendarView::showFilter(bool visible) | 3597 | void CalendarView::showFilter(bool visible) |
3598 | { | 3598 | { |
3599 | if (visible) mFilterView->show(); | 3599 | if (visible) mFilterView->show(); |
3600 | else mFilterView->hide(); | 3600 | else mFilterView->hide(); |
3601 | } | 3601 | } |
3602 | void CalendarView::toggleFilerEnabled( ) | 3602 | void CalendarView::toggleFilerEnabled( ) |
3603 | { | 3603 | { |
3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); | 3604 | mFilterView->setFiltersEnabled ( !mFilterView->filtersEnabled() ); |
3605 | if ( !mFilterView->filtersEnabled() ) | 3605 | if ( !mFilterView->filtersEnabled() ) |
3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); | 3606 | topLevelWidget()->setCaption( i18n("Filter disabled ") ); |
3607 | 3607 | ||
3608 | } | 3608 | } |
3609 | void CalendarView::updateFilter() | 3609 | void CalendarView::updateFilter() |
3610 | { | 3610 | { |
3611 | CalFilter *filter = mFilterView->selectedFilter(); | 3611 | CalFilter *filter = mFilterView->selectedFilter(); |
3612 | if (filter) { | 3612 | if (filter) { |
3613 | QString mess; | ||
3613 | if (mFilterView->filtersEnabled()) { | 3614 | if (mFilterView->filtersEnabled()) { |
3614 | topLevelWidget()->setCaption( i18n("Filter selected: ")+filter->name() ); | 3615 | mess = i18n("Filter selected: ")+filter->name(); |
3615 | filter->setEnabled(true); | 3616 | filter->setEnabled(true); |
3616 | } | 3617 | } |
3617 | else filter->setEnabled(false); | 3618 | else filter->setEnabled(false); |
3618 | mCalendar->setFilter(filter); | 3619 | mCalendar->setFilter(filter); |
3619 | updateView(); | 3620 | updateView(); |
3621 | if ( !mess.isEmpty() ) | ||
3622 | topLevelWidget()->setCaption( mess ); | ||
3623 | |||
3620 | } | 3624 | } |
3621 | } | 3625 | } |
3622 | 3626 | ||
3623 | void CalendarView::filterEdited() | 3627 | void CalendarView::filterEdited() |
3624 | { | 3628 | { |
3625 | mFilterView->updateFilters(); | 3629 | mFilterView->updateFilters(); |
3626 | updateFilter(); | 3630 | updateFilter(); |
3627 | writeSettings(); | 3631 | writeSettings(); |
3628 | } | 3632 | } |
3629 | 3633 | ||
3630 | 3634 | ||
3631 | void CalendarView::takeOverEvent() | 3635 | void CalendarView::takeOverEvent() |
3632 | { | 3636 | { |
3633 | Incidence *incidence = currentSelection(); | 3637 | Incidence *incidence = currentSelection(); |
3634 | 3638 | ||
3635 | if (!incidence) return; | 3639 | if (!incidence) return; |
3636 | 3640 | ||
3637 | incidence->setOrganizer(KOPrefs::instance()->email()); | 3641 | incidence->setOrganizer(KOPrefs::instance()->email()); |
3638 | incidence->recreate(); | 3642 | incidence->recreate(); |
3639 | incidence->setReadOnly(false); | 3643 | incidence->setReadOnly(false); |
3640 | 3644 | ||
3641 | updateView(); | 3645 | updateView(); |
3642 | } | 3646 | } |
3643 | 3647 | ||
3644 | void CalendarView::takeOverCalendar() | 3648 | void CalendarView::takeOverCalendar() |
3645 | { | 3649 | { |
3646 | // TODO: Create Calendar::allIncidences() function and use it here | 3650 | // TODO: Create Calendar::allIncidences() function and use it here |
3647 | 3651 | ||
3648 | QPtrList<Event> events = mCalendar->events(); | 3652 | QPtrList<Event> events = mCalendar->events(); |
3649 | for(uint i=0; i<events.count(); ++i) { | 3653 | for(uint i=0; i<events.count(); ++i) { |
3650 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3654 | events.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3651 | events.at(i)->recreate(); | 3655 | events.at(i)->recreate(); |
3652 | events.at(i)->setReadOnly(false); | 3656 | events.at(i)->setReadOnly(false); |
3653 | } | 3657 | } |
3654 | 3658 | ||
3655 | QPtrList<Todo> todos = mCalendar->todos(); | 3659 | QPtrList<Todo> todos = mCalendar->todos(); |
3656 | for(uint i=0; i<todos.count(); ++i) { | 3660 | for(uint i=0; i<todos.count(); ++i) { |
3657 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3661 | todos.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3658 | todos.at(i)->recreate(); | 3662 | todos.at(i)->recreate(); |
3659 | todos.at(i)->setReadOnly(false); | 3663 | todos.at(i)->setReadOnly(false); |
3660 | } | 3664 | } |
3661 | 3665 | ||
3662 | QPtrList<Journal> journals = mCalendar->journals(); | 3666 | QPtrList<Journal> journals = mCalendar->journals(); |
3663 | for(uint i=0; i<journals.count(); ++i) { | 3667 | for(uint i=0; i<journals.count(); ++i) { |
3664 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); | 3668 | journals.at(i)->setOrganizer(KOPrefs::instance()->email()); |
3665 | journals.at(i)->recreate(); | 3669 | journals.at(i)->recreate(); |
3666 | journals.at(i)->setReadOnly(false); | 3670 | journals.at(i)->setReadOnly(false); |
3667 | } | 3671 | } |
3668 | 3672 | ||
3669 | updateView(); | 3673 | updateView(); |
3670 | } | 3674 | } |
3671 | 3675 | ||
3672 | void CalendarView::showIntro() | 3676 | void CalendarView::showIntro() |
3673 | { | 3677 | { |
3674 | kdDebug() << "To be implemented." << endl; | 3678 | kdDebug() << "To be implemented." << endl; |
3675 | } | 3679 | } |
3676 | 3680 | ||
3677 | QWidgetStack *CalendarView::viewStack() | 3681 | QWidgetStack *CalendarView::viewStack() |
3678 | { | 3682 | { |
3679 | return mRightFrame; | 3683 | return mRightFrame; |
3680 | } | 3684 | } |
3681 | 3685 | ||
3682 | QWidget *CalendarView::leftFrame() | 3686 | QWidget *CalendarView::leftFrame() |
3683 | { | 3687 | { |
3684 | return mLeftFrame; | 3688 | return mLeftFrame; |
3685 | } | 3689 | } |
3686 | 3690 | ||
3687 | DateNavigator *CalendarView::dateNavigator() | 3691 | DateNavigator *CalendarView::dateNavigator() |
3688 | { | 3692 | { |
3689 | return mNavigator; | 3693 | return mNavigator; |
3690 | } | 3694 | } |
3691 | 3695 | ||
3692 | KDateNavigator* CalendarView::dateNavigatorWidget() | 3696 | KDateNavigator* CalendarView::dateNavigatorWidget() |
3693 | { | 3697 | { |
3694 | return mDateNavigator; | 3698 | return mDateNavigator; |
3695 | } | 3699 | } |
3696 | void CalendarView::toggleDateNavigatorWidget() | 3700 | void CalendarView::toggleDateNavigatorWidget() |
3697 | { | 3701 | { |
3698 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; | 3702 | KOPrefs::instance()->mShowDateNavigator = !KOPrefs::instance()->mShowDateNavigator ; |
3699 | if (!KOPrefs::instance()->mShowDateNavigator ) | 3703 | if (!KOPrefs::instance()->mShowDateNavigator ) |
3700 | mDateNavigator->hide(); | 3704 | mDateNavigator->hide(); |
3701 | else | 3705 | else |
3702 | mDateNavigator->show(); | 3706 | mDateNavigator->show(); |
3703 | } | 3707 | } |
3704 | void CalendarView::addView(KOrg::BaseView *view) | 3708 | void CalendarView::addView(KOrg::BaseView *view) |
3705 | { | 3709 | { |
3706 | mViewManager->addView(view); | 3710 | mViewManager->addView(view); |
3707 | } | 3711 | } |
3708 | 3712 | ||
3709 | void CalendarView::showView(KOrg::BaseView *view) | 3713 | void CalendarView::showView(KOrg::BaseView *view) |
3710 | { | 3714 | { |
3711 | mViewManager->showView(view, mLeftFrame->isVisible()); | 3715 | mViewManager->showView(view, mLeftFrame->isVisible()); |
3712 | } | 3716 | } |
3713 | 3717 | ||
3714 | Incidence *CalendarView::currentSelection() | 3718 | Incidence *CalendarView::currentSelection() |
3715 | { | 3719 | { |
3716 | return mViewManager->currentSelection(); | 3720 | return mViewManager->currentSelection(); |
3717 | } | 3721 | } |
3718 | void CalendarView::toggleAllDaySize() | 3722 | void CalendarView::toggleAllDaySize() |
3719 | { | 3723 | { |
3720 | /* | 3724 | /* |
3721 | if ( KOPrefs::instance()->mAllDaySize > 47 ) | 3725 | if ( KOPrefs::instance()->mAllDaySize > 47 ) |
3722 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; | 3726 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize /2; |
3723 | else | 3727 | else |
3724 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; | 3728 | KOPrefs::instance()->mAllDaySize = KOPrefs::instance()->mAllDaySize *2; |
3725 | */ | 3729 | */ |
3726 | viewManager()->agendaView()->toggleAllDay(); | 3730 | viewManager()->agendaView()->toggleAllDay(); |
3727 | } | 3731 | } |
3728 | void CalendarView::toggleExpand() | 3732 | void CalendarView::toggleExpand() |
3729 | { | 3733 | { |
3730 | // if ( mLeftFrame->isHidden() ) { | 3734 | // if ( mLeftFrame->isHidden() ) { |
3731 | // mLeftFrame->show(); | 3735 | // mLeftFrame->show(); |
3732 | // emit calendarViewExpanded( false ); | 3736 | // emit calendarViewExpanded( false ); |
3733 | // } else { | 3737 | // } else { |
3734 | // mLeftFrame->hide(); | 3738 | // mLeftFrame->hide(); |
3735 | // emit calendarViewExpanded( true ); | 3739 | // emit calendarViewExpanded( true ); |
3736 | // } | 3740 | // } |
3737 | //qDebug(" CalendarView::toggleExpand()"); | 3741 | //qDebug(" CalendarView::toggleExpand()"); |
3738 | globalFlagBlockAgenda = 1; | 3742 | globalFlagBlockAgenda = 1; |
3739 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); | 3743 | emit calendarViewExpanded( !mLeftFrame->isHidden() ); |
3740 | globalFlagBlockAgenda = 5; | 3744 | globalFlagBlockAgenda = 5; |
3741 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); | 3745 | mViewManager->raiseCurrentView( !mLeftFrame->isHidden() ); |
3742 | //mViewManager->showView( 0, true ); | 3746 | //mViewManager->showView( 0, true ); |
3743 | } | 3747 | } |
3744 | 3748 | ||
3745 | void CalendarView::calendarModified( bool modified, Calendar * ) | 3749 | void CalendarView::calendarModified( bool modified, Calendar * ) |
3746 | { | 3750 | { |
3747 | setModified( modified ); | 3751 | setModified( modified ); |
3748 | } | 3752 | } |
3749 | 3753 | ||
3750 | Todo *CalendarView::selectedTodo() | 3754 | Todo *CalendarView::selectedTodo() |
3751 | { | 3755 | { |
3752 | Incidence *incidence = currentSelection(); | 3756 | Incidence *incidence = currentSelection(); |
3753 | if ( incidence && incidence->type() == "Todo" ) { | 3757 | if ( incidence && incidence->type() == "Todo" ) { |
3754 | return static_cast<Todo *>( incidence ); | 3758 | return static_cast<Todo *>( incidence ); |
3755 | } | 3759 | } |
3756 | 3760 | ||
3757 | incidence = mTodoList->selectedIncidences().first(); | 3761 | incidence = mTodoList->selectedIncidences().first(); |
3758 | if ( incidence && incidence->type() == "Todo" ) { | 3762 | if ( incidence && incidence->type() == "Todo" ) { |
3759 | return static_cast<Todo *>( incidence ); | 3763 | return static_cast<Todo *>( incidence ); |
3760 | } | 3764 | } |
3761 | 3765 | ||
3762 | return 0; | 3766 | return 0; |
3763 | } | 3767 | } |
3764 | 3768 | ||
3765 | void CalendarView::dialogClosing(Incidence *in) | 3769 | void CalendarView::dialogClosing(Incidence *in) |
3766 | { | 3770 | { |
3767 | // mDialogList.remove(in); | 3771 | // mDialogList.remove(in); |
3768 | } | 3772 | } |
3769 | 3773 | ||
3770 | void CalendarView::showIncidence() | 3774 | void CalendarView::showIncidence() |
3771 | { | 3775 | { |
3772 | mViewerCallerIsSearchDialog = false; | 3776 | mViewerCallerIsSearchDialog = false; |
3773 | Incidence *incidence = currentSelection(); | 3777 | Incidence *incidence = currentSelection(); |
3774 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3778 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3775 | if ( incidence ) { | 3779 | if ( incidence ) { |
3776 | ShowIncidenceVisitor v; | 3780 | ShowIncidenceVisitor v; |
3777 | v.act( incidence, this ); | 3781 | v.act( incidence, this ); |
3778 | } | 3782 | } |
3779 | } | 3783 | } |
3780 | void CalendarView::editIncidenceDescription() | 3784 | void CalendarView::editIncidenceDescription() |
3781 | { | 3785 | { |
3782 | mFlagEditDescription = true; | 3786 | mFlagEditDescription = true; |
3783 | editIncidence(); | 3787 | editIncidence(); |
3784 | mFlagEditDescription = false; | 3788 | mFlagEditDescription = false; |
3785 | } | 3789 | } |
3786 | void CalendarView::editIncidence() | 3790 | void CalendarView::editIncidence() |
3787 | { | 3791 | { |
3788 | // qDebug("editIncidence() "); | 3792 | // qDebug("editIncidence() "); |
3789 | Incidence *incidence = currentSelection(); | 3793 | Incidence *incidence = currentSelection(); |
3790 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3794 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3791 | if ( incidence ) { | 3795 | if ( incidence ) { |
3792 | EditIncidenceVisitor v; | 3796 | EditIncidenceVisitor v; |
3793 | v.act( incidence, this ); | 3797 | v.act( incidence, this ); |
3794 | } | 3798 | } |
3795 | } | 3799 | } |
3796 | 3800 | ||
3797 | void CalendarView::deleteIncidence() | 3801 | void CalendarView::deleteIncidence() |
3798 | { | 3802 | { |
3799 | Incidence *incidence = currentSelection(); | 3803 | Incidence *incidence = currentSelection(); |
3800 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 3804 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
3801 | if ( incidence ) { | 3805 | if ( incidence ) { |
3802 | deleteIncidence(incidence); | 3806 | deleteIncidence(incidence); |
3803 | } | 3807 | } |
3804 | } | 3808 | } |
3805 | 3809 | ||
3806 | void CalendarView::showIncidence(Incidence *incidence) | 3810 | void CalendarView::showIncidence(Incidence *incidence) |
3807 | { | 3811 | { |
3808 | mViewerCallerIsSearchDialog = false; | 3812 | mViewerCallerIsSearchDialog = false; |
3809 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); | 3813 | //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); |
3810 | if ( sender() && mDialogManager->getSearchDialog() ) { | 3814 | if ( sender() && mDialogManager->getSearchDialog() ) { |
3811 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { | 3815 | if ( sender () == mDialogManager->getSearchDialog()->listview() ) { |
3812 | mViewerCallerIsSearchDialog = true; | 3816 | mViewerCallerIsSearchDialog = true; |
3813 | } | 3817 | } |
3814 | } | 3818 | } |
3815 | if ( incidence ) { | 3819 | if ( incidence ) { |
3816 | ShowIncidenceVisitor v; | 3820 | ShowIncidenceVisitor v; |
3817 | v.act( incidence, this ); | 3821 | v.act( incidence, this ); |
3818 | } | 3822 | } |
3819 | } | 3823 | } |
3820 | 3824 | ||
3821 | void CalendarView::editIncidence(Incidence *incidence) | 3825 | void CalendarView::editIncidence(Incidence *incidence) |
3822 | { | 3826 | { |
3823 | if ( incidence ) { | 3827 | if ( incidence ) { |
3824 | 3828 | ||
3825 | EditIncidenceVisitor v; | 3829 | EditIncidenceVisitor v; |
3826 | v.act( incidence, this ); | 3830 | v.act( incidence, this ); |
3827 | 3831 | ||
3828 | } | 3832 | } |
3829 | } | 3833 | } |
3830 | 3834 | ||
3831 | void CalendarView::deleteIncidence(Incidence *incidence) | 3835 | void CalendarView::deleteIncidence(Incidence *incidence) |
3832 | { | 3836 | { |
3833 | //qDebug(" CalendarView::deleteIncidence "); | 3837 | //qDebug(" CalendarView::deleteIncidence "); |
3834 | if ( incidence ) { | 3838 | if ( incidence ) { |
3835 | DeleteIncidenceVisitor v; | 3839 | DeleteIncidenceVisitor v; |
3836 | v.act( incidence, this ); | 3840 | v.act( incidence, this ); |
3837 | } | 3841 | } |
3838 | } | 3842 | } |
3839 | 3843 | ||
3840 | 3844 | ||
3841 | void CalendarView::lookForOutgoingMessages() | 3845 | void CalendarView::lookForOutgoingMessages() |
3842 | { | 3846 | { |
3843 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); | 3847 | OutgoingDialog *ogd = mDialogManager->outgoingDialog(); |
3844 | ogd->loadMessages(); | 3848 | ogd->loadMessages(); |
3845 | } | 3849 | } |
3846 | 3850 | ||
3847 | void CalendarView::lookForIncomingMessages() | 3851 | void CalendarView::lookForIncomingMessages() |
3848 | { | 3852 | { |
3849 | IncomingDialog *icd = mDialogManager->incomingDialog(); | 3853 | IncomingDialog *icd = mDialogManager->incomingDialog(); |
3850 | icd->retrieve(); | 3854 | icd->retrieve(); |
3851 | } | 3855 | } |
3852 | 3856 | ||
3853 | bool CalendarView::removeCompletedSubTodos( Todo* t ) | 3857 | bool CalendarView::removeCompletedSubTodos( Todo* t ) |
3854 | { | 3858 | { |
3855 | bool deleteTodo = true; | 3859 | bool deleteTodo = true; |
3856 | QPtrList<Incidence> subTodos; | 3860 | QPtrList<Incidence> subTodos; |
3857 | Incidence *aTodo; | 3861 | Incidence *aTodo; |
3858 | subTodos = t->relations(); | 3862 | subTodos = t->relations(); |
3859 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { | 3863 | for (aTodo = subTodos.first(); aTodo; aTodo = subTodos.next()) { |
3860 | if (! removeCompletedSubTodos( (Todo*) aTodo )) | 3864 | if (! removeCompletedSubTodos( (Todo*) aTodo )) |
3861 | deleteTodo = false; | 3865 | deleteTodo = false; |
3862 | } | 3866 | } |
3863 | if ( deleteTodo ) { | 3867 | if ( deleteTodo ) { |
3864 | if ( t->isCompleted() && !t->doesRecur()) { | 3868 | if ( t->isCompleted() && !t->doesRecur()) { |
3865 | checkExternalId( t ); | 3869 | checkExternalId( t ); |
3866 | mCalendar->deleteTodo( t ); | 3870 | mCalendar->deleteTodo( t ); |
3867 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); | 3871 | changeTodoDisplay( t,KOGlobals::EVENTDELETED ); |
3868 | } | 3872 | } |
3869 | else | 3873 | else |
3870 | deleteTodo = false; | 3874 | deleteTodo = false; |
3871 | } | 3875 | } |
3872 | return deleteTodo; | 3876 | return deleteTodo; |
3873 | 3877 | ||
3874 | } | 3878 | } |
3875 | void CalendarView::purgeCompleted() | 3879 | void CalendarView::purgeCompleted() |
3876 | { | 3880 | { |
3877 | int result = KMessageBox::warningContinueCancel(this, | 3881 | int result = KMessageBox::warningContinueCancel(this, |
3878 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); | 3882 | i18n("Delete all\ncompleted To-Dos?"),i18n("Purge To-Dos"),i18n("Purge")); |
3879 | 3883 | ||
3880 | if (result == KMessageBox::Continue) { | 3884 | if (result == KMessageBox::Continue) { |
3881 | 3885 | ||
3882 | QPtrList<Todo> todoCal; | 3886 | QPtrList<Todo> todoCal; |
3883 | QPtrList<Todo> rootTodos; | 3887 | QPtrList<Todo> rootTodos; |
3884 | //QPtrList<Incidence> rel; | 3888 | //QPtrList<Incidence> rel; |
3885 | Todo *aTodo;//, *rTodo; | 3889 | Todo *aTodo;//, *rTodo; |
3886 | Incidence *rIncidence; | 3890 | Incidence *rIncidence; |
3887 | bool childDelete = false; | 3891 | bool childDelete = false; |
3888 | bool deletedOne = true; | 3892 | bool deletedOne = true; |
3889 | todoCal = calendar()->todos(); | 3893 | todoCal = calendar()->todos(); |
3890 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { | 3894 | for (aTodo = todoCal.first(); aTodo; aTodo = todoCal.next()) { |
3891 | if ( !aTodo->relatedTo() ) | 3895 | if ( !aTodo->relatedTo() ) |
3892 | rootTodos.append( aTodo ); | 3896 | rootTodos.append( aTodo ); |
3893 | } | 3897 | } |
3894 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { | 3898 | for (aTodo = rootTodos.first(); aTodo; aTodo = rootTodos.next()) { |
3895 | removeCompletedSubTodos( aTodo ); | 3899 | removeCompletedSubTodos( aTodo ); |
3896 | } | 3900 | } |
3897 | 3901 | ||
3898 | updateView(); | 3902 | updateView(); |
3899 | } | 3903 | } |
3900 | } | 3904 | } |
3901 | 3905 | ||
3902 | void CalendarView::slotCalendarChanged() | 3906 | void CalendarView::slotCalendarChanged() |
3903 | { | 3907 | { |
3904 | ; | 3908 | ; |
3905 | } | 3909 | } |
3906 | 3910 | ||
3907 | void CalendarView::keyPressEvent ( QKeyEvent *e) | 3911 | void CalendarView::keyPressEvent ( QKeyEvent *e) |
3908 | { | 3912 | { |
3909 | //qDebug(" alendarView::keyPressEvent "); | 3913 | //qDebug(" alendarView::keyPressEvent "); |
3910 | e->ignore(); | 3914 | e->ignore(); |
3911 | } | 3915 | } |
3912 | 3916 | ||
3913 | 3917 | ||
3914 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) | 3918 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode) |
3915 | { | 3919 | { |
3916 | // mSyncManager = manager; | 3920 | // mSyncManager = manager; |
3917 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { | 3921 | if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |
3918 | qDebug("KO: SyncKDE request detected!"); | 3922 | qDebug("KO: SyncKDE request detected!"); |
3919 | } | 3923 | } |
3920 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3924 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3921 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3925 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3922 | return syncCalendar( filename, mode ); | 3926 | return syncCalendar( filename, mode ); |
3923 | } | 3927 | } |
3924 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) | 3928 | bool CalendarView::syncExternal(KSyncManager* manager, QString resource) |
3925 | { | 3929 | { |
3926 | //mSyncManager = manager; | 3930 | //mSyncManager = manager; |
3927 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); | 3931 | mCurrentSyncDevice = mSyncManager->getCurrentSyncDevice(); |
3928 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); | 3932 | mCurrentSyncName = mSyncManager->getCurrentSyncName(); |
3929 | if ( resource == "sharp" ) | 3933 | if ( resource == "sharp" ) |
3930 | syncExternal( 0 ); | 3934 | syncExternal( 0 ); |
3931 | if ( resource == "phone" ) | 3935 | if ( resource == "phone" ) |
3932 | syncExternal( 1 ); | 3936 | syncExternal( 1 ); |
3933 | // pending setmodified | 3937 | // pending setmodified |
3934 | return true; | 3938 | return true; |
3935 | } | 3939 | } |
3936 | void CalendarView::setSyncManager(KSyncManager* manager) | 3940 | void CalendarView::setSyncManager(KSyncManager* manager) |
3937 | { | 3941 | { |
3938 | mSyncManager = manager; | 3942 | mSyncManager = manager; |
3939 | } | 3943 | } |
3940 | 3944 | ||
3941 | void CalendarView::removeSyncInfo( QString syncProfile) | 3945 | void CalendarView::removeSyncInfo( QString syncProfile) |
3942 | { | 3946 | { |
3943 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); | 3947 | qDebug("KO: removeSyncInfo for profile %s ", syncProfile.latin1()); |
3944 | mCalendar->removeSyncInfo( syncProfile ); | 3948 | mCalendar->removeSyncInfo( syncProfile ); |
3945 | 3949 | ||
3946 | } | 3950 | } |
3947 | 3951 | ||
3948 | void CalendarView::undo_delete() | 3952 | void CalendarView::undo_delete() |
3949 | { | 3953 | { |
3950 | //qDebug("undo_delete() "); | 3954 | //qDebug("undo_delete() "); |
3951 | Incidence* undo = mCalendar->undoIncidence(); | 3955 | Incidence* undo = mCalendar->undoIncidence(); |
3952 | if ( !undo ) { | 3956 | if ( !undo ) { |
3953 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), | 3957 | KMessageBox::sorry(this,i18n("There is nothing to undo!"), |
3954 | i18n("KO/Pi")); | 3958 | i18n("KO/Pi")); |
3955 | return; | 3959 | return; |
3956 | } | 3960 | } |
3957 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + | 3961 | if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + |
3958 | i18n("\nAre you sure you want\nto restore this?"), | 3962 | i18n("\nAre you sure you want\nto restore this?"), |
3959 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { | 3963 | i18n("KO/Pi Confirmation"),i18n("Restore"))) { |
3960 | mCalendar->undoDeleteIncidence(); | 3964 | mCalendar->undoDeleteIncidence(); |
3961 | updateView(); | 3965 | updateView(); |
3962 | } | 3966 | } |
3963 | } | 3967 | } |
3964 | 3968 | ||
3965 | void CalendarView::slotViewerClosed() | 3969 | void CalendarView::slotViewerClosed() |
3966 | { | 3970 | { |
3967 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); | 3971 | QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); |
3968 | } | 3972 | } |
3969 | 3973 | ||
3970 | void CalendarView::resetFocus() | 3974 | void CalendarView::resetFocus() |
3971 | { | 3975 | { |
3972 | if ( mViewerCallerIsSearchDialog ) { | 3976 | if ( mViewerCallerIsSearchDialog ) { |
3973 | if ( mDialogManager->getSearchDialog()->isVisible() ){ | 3977 | if ( mDialogManager->getSearchDialog()->isVisible() ){ |
3974 | mDialogManager->getSearchDialog()->raise(); | 3978 | mDialogManager->getSearchDialog()->raise(); |
3975 | mDialogManager->getSearchDialog()->setActiveWindow(); | 3979 | mDialogManager->getSearchDialog()->setActiveWindow(); |
3976 | mDialogManager->getSearchDialog()->listview()->resetFocus(); | 3980 | mDialogManager->getSearchDialog()->listview()->resetFocus(); |
3977 | } else | 3981 | } else |
3978 | mViewerCallerIsSearchDialog = false; | 3982 | mViewerCallerIsSearchDialog = false; |
3979 | } | 3983 | } |
3980 | if ( !mViewerCallerIsSearchDialog ) { | 3984 | if ( !mViewerCallerIsSearchDialog ) { |
3981 | //mViewManager->currentView()->setFocus(); | 3985 | //mViewManager->currentView()->setFocus(); |
3982 | //qDebug("sssssssssssssssset focus "); | 3986 | //qDebug("sssssssssssssssset focus "); |
3983 | topLevelWidget()->raise(); | 3987 | topLevelWidget()->raise(); |
3984 | setActiveWindow(); | 3988 | setActiveWindow(); |
3985 | //setFocus(); | 3989 | //setFocus(); |
3986 | } | 3990 | } |
3987 | mViewerCallerIsSearchDialog = false; | 3991 | mViewerCallerIsSearchDialog = false; |
3988 | } | 3992 | } |