author | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-12-13 12:35:00 (UTC) |
commit | 7ac6c21e832b7d16bd0888d0b66252b6e152005a (patch) (unidiff) | |
tree | c7610e0e25020f19af82ac6257c2debab2638316 /korganizer | |
parent | 17b25691f0332e648dd1d800e89ccf4e1da8955d (diff) | |
download | kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.zip kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.gz kdepimpi-7ac6c21e832b7d16bd0888d0b66252b6e152005a.tar.bz2 |
many bugfixes
-rw-r--r-- | korganizer/calendarview.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 15c5dd9..a46cd87 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2220,746 +2220,748 @@ void CalendarView::edit_options() | |||
2220 | void CalendarView::slotSelectPickerDate( QDate d) | 2220 | void CalendarView::slotSelectPickerDate( QDate d) |
2221 | { | 2221 | { |
2222 | mDateFrame->hide(); | 2222 | mDateFrame->hide(); |
2223 | if ( mDatePickerMode == 1 ) { | 2223 | if ( mDatePickerMode == 1 ) { |
2224 | mNavigator->slotDaySelect( d ); | 2224 | mNavigator->slotDaySelect( d ); |
2225 | } else if ( mDatePickerMode == 2 ) { | 2225 | } else if ( mDatePickerMode == 2 ) { |
2226 | if ( mMoveIncidence->type() == "Todo" ) { | 2226 | if ( mMoveIncidence->type() == "Todo" ) { |
2227 | Todo * to = (Todo *) mMoveIncidence; | 2227 | Todo * to = (Todo *) mMoveIncidence; |
2228 | QTime tim; | 2228 | QTime tim; |
2229 | if ( to->hasDueDate() ) | 2229 | if ( to->hasDueDate() ) |
2230 | tim = to->dtDue().time(); | 2230 | tim = to->dtDue().time(); |
2231 | else { | 2231 | else { |
2232 | tim = QTime ( 0,0,0 ); | 2232 | tim = QTime ( 0,0,0 ); |
2233 | to->setFloats( true ); | 2233 | to->setFloats( true ); |
2234 | to->setHasDueDate( true ); | 2234 | to->setHasDueDate( true ); |
2235 | } | 2235 | } |
2236 | QDateTime dt ( d,tim ); | 2236 | QDateTime dt ( d,tim ); |
2237 | to->setDtDue( dt ); | 2237 | to->setDtDue( dt ); |
2238 | todoChanged( to ); | 2238 | todoChanged( to ); |
2239 | } else { | 2239 | } else { |
2240 | if ( mMoveIncidence->doesRecur() ) { | 2240 | if ( mMoveIncidence->doesRecur() ) { |
2241 | #if 0 | 2241 | #if 0 |
2242 | // PENDING implement this | 2242 | // PENDING implement this |
2243 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); | 2243 | Incidence* newInc = mMoveIncidence->recreateCloneException( mMoveIncidenceOldDate ); |
2244 | mCalendar()->addIncidence( newInc ); | 2244 | mCalendar()->addIncidence( newInc ); |
2245 | if ( mMoveIncidence->type() == "Todo" ) | 2245 | if ( mMoveIncidence->type() == "Todo" ) |
2246 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); | 2246 | emit todoMoved((Todo*)mMoveIncidence, KOGlobals::EVENTEDITED ); |
2247 | else | 2247 | else |
2248 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); | 2248 | emit incidenceChanged(mMoveIncidence, KOGlobals::EVENTEDITED); |
2249 | mMoveIncidence = newInc; | 2249 | mMoveIncidence = newInc; |
2250 | 2250 | ||
2251 | #endif | 2251 | #endif |
2252 | } | 2252 | } |
2253 | QTime tim = mMoveIncidence->dtStart().time(); | 2253 | QTime tim = mMoveIncidence->dtStart().time(); |
2254 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); | 2254 | int secs = mMoveIncidence->dtStart().secsTo( mMoveIncidence->dtEnd()); |
2255 | QDateTime dt ( d,tim ); | 2255 | QDateTime dt ( d,tim ); |
2256 | mMoveIncidence->setDtStart( dt ); | 2256 | mMoveIncidence->setDtStart( dt ); |
2257 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); | 2257 | ((Event*)mMoveIncidence)->setDtEnd( dt.addSecs( secs ) ); |
2258 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); | 2258 | changeEventDisplay((Event*)mMoveIncidence, KOGlobals::EVENTEDITED); |
2259 | } | 2259 | } |
2260 | 2260 | ||
2261 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); | 2261 | mMoveIncidence->setRevision( mMoveIncidence->revision()+1 ); |
2262 | } | 2262 | } |
2263 | } | 2263 | } |
2264 | 2264 | ||
2265 | void CalendarView::removeCategories() | 2265 | void CalendarView::removeCategories() |
2266 | { | 2266 | { |
2267 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2267 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2268 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2268 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2269 | QStringList catIncList; | 2269 | QStringList catIncList; |
2270 | QStringList newCatList; | 2270 | QStringList newCatList; |
2271 | Incidence* inc = incList.first(); | 2271 | Incidence* inc = incList.first(); |
2272 | int i; | 2272 | int i; |
2273 | int count = 0; | 2273 | int count = 0; |
2274 | while ( inc ) { | 2274 | while ( inc ) { |
2275 | newCatList.clear(); | 2275 | newCatList.clear(); |
2276 | catIncList = inc->categories() ; | 2276 | catIncList = inc->categories() ; |
2277 | for( i = 0; i< catIncList.count(); ++i ) { | 2277 | for( i = 0; i< catIncList.count(); ++i ) { |
2278 | if ( catList.contains (catIncList[i])) | 2278 | if ( catList.contains (catIncList[i])) |
2279 | newCatList.append( catIncList[i] ); | 2279 | newCatList.append( catIncList[i] ); |
2280 | } | 2280 | } |
2281 | newCatList.sort(); | 2281 | newCatList.sort(); |
2282 | inc->setCategories( newCatList.join(",") ); | 2282 | inc->setCategories( newCatList.join(",") ); |
2283 | inc = incList.next(); | 2283 | inc = incList.next(); |
2284 | } | 2284 | } |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | int CalendarView::addCategories() | 2287 | int CalendarView::addCategories() |
2288 | { | 2288 | { |
2289 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2289 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2290 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2290 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2291 | QStringList catIncList; | 2291 | QStringList catIncList; |
2292 | Incidence* inc = incList.first(); | 2292 | Incidence* inc = incList.first(); |
2293 | int i; | 2293 | int i; |
2294 | int count = 0; | 2294 | int count = 0; |
2295 | while ( inc ) { | 2295 | while ( inc ) { |
2296 | catIncList = inc->categories() ; | 2296 | catIncList = inc->categories() ; |
2297 | for( i = 0; i< catIncList.count(); ++i ) { | 2297 | for( i = 0; i< catIncList.count(); ++i ) { |
2298 | if ( !catList.contains (catIncList[i])) { | 2298 | if ( !catList.contains (catIncList[i])) { |
2299 | catList.append( catIncList[i] ); | 2299 | catList.append( catIncList[i] ); |
2300 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2300 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2301 | ++count; | 2301 | ++count; |
2302 | } | 2302 | } |
2303 | } | 2303 | } |
2304 | inc = incList.next(); | 2304 | inc = incList.next(); |
2305 | } | 2305 | } |
2306 | catList.sort(); | 2306 | catList.sort(); |
2307 | KOPrefs::instance()->mCustomCategories = catList; | 2307 | KOPrefs::instance()->mCustomCategories = catList; |
2308 | return count; | 2308 | return count; |
2309 | } | 2309 | } |
2310 | 2310 | ||
2311 | void CalendarView::manageCategories() | 2311 | void CalendarView::manageCategories() |
2312 | { | 2312 | { |
2313 | KOCatPrefs* cp = new KOCatPrefs(); | 2313 | KOCatPrefs* cp = new KOCatPrefs(); |
2314 | cp->show(); | 2314 | cp->show(); |
2315 | int w =cp->sizeHint().width() ; | 2315 | int w =cp->sizeHint().width() ; |
2316 | int h = cp->sizeHint().height() ; | 2316 | int h = cp->sizeHint().height() ; |
2317 | int dw = QApplication::desktop()->width(); | 2317 | int dw = QApplication::desktop()->width(); |
2318 | int dh = QApplication::desktop()->height(); | 2318 | int dh = QApplication::desktop()->height(); |
2319 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2319 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2320 | if ( !cp->exec() ) { | 2320 | if ( !cp->exec() ) { |
2321 | delete cp; | 2321 | delete cp; |
2322 | return; | 2322 | return; |
2323 | } | 2323 | } |
2324 | int count = 0; | 2324 | int count = 0; |
2325 | if ( cp->addCat() ) { | 2325 | if ( cp->addCat() ) { |
2326 | count = addCategories(); | 2326 | count = addCategories(); |
2327 | if ( count ) { | 2327 | if ( count ) { |
2328 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2328 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2329 | writeSettings(); | 2329 | writeSettings(); |
2330 | } else | 2330 | } else |
2331 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2331 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2332 | } else { | 2332 | } else { |
2333 | removeCategories(); | 2333 | removeCategories(); |
2334 | updateView(); | 2334 | updateView(); |
2335 | } | 2335 | } |
2336 | delete cp; | 2336 | delete cp; |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | void CalendarView::beamIncidence(Incidence * Inc) | 2339 | void CalendarView::beamIncidence(Incidence * Inc) |
2340 | { | 2340 | { |
2341 | QPtrList<Incidence> delSel ; | 2341 | QPtrList<Incidence> delSel ; |
2342 | delSel.append(Inc); | 2342 | delSel.append(Inc); |
2343 | beamIncidenceList( delSel ); | 2343 | beamIncidenceList( delSel ); |
2344 | } | 2344 | } |
2345 | void CalendarView::beamCalendar() | 2345 | void CalendarView::beamCalendar() |
2346 | { | 2346 | { |
2347 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2347 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2348 | //qDebug("beamCalendar() "); | 2348 | //qDebug("beamCalendar() "); |
2349 | beamIncidenceList( delSel ); | 2349 | beamIncidenceList( delSel ); |
2350 | } | 2350 | } |
2351 | void CalendarView::beamFilteredCalendar() | 2351 | void CalendarView::beamFilteredCalendar() |
2352 | { | 2352 | { |
2353 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2353 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2354 | //qDebug("beamFilteredCalendar() "); | 2354 | //qDebug("beamFilteredCalendar() "); |
2355 | beamIncidenceList( delSel ); | 2355 | beamIncidenceList( delSel ); |
2356 | } | 2356 | } |
2357 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2357 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2358 | { | 2358 | { |
2359 | if ( beamDialog->exec () == QDialog::Rejected ) | 2359 | if ( beamDialog->exec () == QDialog::Rejected ) |
2360 | return; | 2360 | return; |
2361 | #ifdef DESKTOP_VERSION | 2361 | #ifdef DESKTOP_VERSION |
2362 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2362 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2363 | #else | 2363 | #else |
2364 | QString fn = "/tmp/kopibeamfile"; | 2364 | QString fn = "/tmp/kopibeamfile"; |
2365 | #endif | 2365 | #endif |
2366 | QString mes; | 2366 | QString mes; |
2367 | bool createbup = true; | 2367 | bool createbup = true; |
2368 | if ( createbup ) { | 2368 | if ( createbup ) { |
2369 | QString description = "\n"; | 2369 | QString description = "\n"; |
2370 | CalendarLocal* cal = new CalendarLocal(); | 2370 | CalendarLocal* cal = new CalendarLocal(); |
2371 | if ( beamDialog->beamLocal() ) | 2371 | if ( beamDialog->beamLocal() ) |
2372 | cal->setLocalTime(); | 2372 | cal->setLocalTime(); |
2373 | else | 2373 | else |
2374 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2374 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2375 | Incidence *incidence = delSel.first(); | 2375 | Incidence *incidence = delSel.first(); |
2376 | bool addText = false; | 2376 | bool addText = false; |
2377 | if ( delSel.count() < 10 ) | 2377 | if ( delSel.count() < 10 ) |
2378 | addText = true; | 2378 | addText = true; |
2379 | else { | 2379 | else { |
2380 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2380 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2381 | } | 2381 | } |
2382 | while ( incidence ) { | 2382 | while ( incidence ) { |
2383 | Incidence *in = incidence->clone(); | 2383 | Incidence *in = incidence->clone(); |
2384 | if ( ! in->summary().isEmpty() ) { | 2384 | if ( ! in->summary().isEmpty() ) { |
2385 | in->setDescription(""); | 2385 | in->setDescription(""); |
2386 | } else { | 2386 | } else { |
2387 | in->setSummary( in->description().left(20)); | 2387 | in->setSummary( in->description().left(20)); |
2388 | in->setDescription(""); | 2388 | in->setDescription(""); |
2389 | } | 2389 | } |
2390 | if ( addText ) | 2390 | if ( addText ) |
2391 | description += in->summary() + "\n"; | 2391 | description += in->summary() + "\n"; |
2392 | cal->addIncidence( in ); | 2392 | cal->addIncidence( in ); |
2393 | incidence = delSel.next(); | 2393 | incidence = delSel.next(); |
2394 | } | 2394 | } |
2395 | if ( beamDialog->beamVcal() ) { | 2395 | if ( beamDialog->beamVcal() ) { |
2396 | fn += ".vcs"; | 2396 | fn += ".vcs"; |
2397 | FileStorage storage( cal, fn, new VCalFormat ); | 2397 | FileStorage storage( cal, fn, new VCalFormat ); |
2398 | storage.save(); | 2398 | storage.save(); |
2399 | } else { | 2399 | } else { |
2400 | fn += ".ics"; | 2400 | fn += ".ics"; |
2401 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2401 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2402 | storage.save(); | 2402 | storage.save(); |
2403 | } | 2403 | } |
2404 | delete cal; | 2404 | delete cal; |
2405 | mes = i18n("KO/Pi: Ready for beaming"); | 2405 | mes = i18n("KO/Pi: Ready for beaming"); |
2406 | topLevelWidget()->setCaption(mes); | 2406 | topLevelWidget()->setCaption(mes); |
2407 | KApplication::convert2latin1( fn ); | 2407 | KApplication::convert2latin1( fn ); |
2408 | #ifndef DESKTOP_VERSION | 2408 | #ifndef DESKTOP_VERSION |
2409 | Ir *ir = new Ir( this ); | 2409 | Ir *ir = new Ir( this ); |
2410 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2410 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2411 | ir->send( fn, description, "text/x-vCalendar" ); | 2411 | ir->send( fn, description, "text/x-vCalendar" ); |
2412 | #endif | 2412 | #endif |
2413 | } | 2413 | } |
2414 | } | 2414 | } |
2415 | void CalendarView::beamDone( Ir *ir ) | 2415 | void CalendarView::beamDone( Ir *ir ) |
2416 | { | 2416 | { |
2417 | #ifndef DESKTOP_VERSION | 2417 | #ifndef DESKTOP_VERSION |
2418 | delete ir; | 2418 | delete ir; |
2419 | #endif | 2419 | #endif |
2420 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2420 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2421 | topLevelWidget()->raise(); | 2421 | topLevelWidget()->raise(); |
2422 | } | 2422 | } |
2423 | 2423 | ||
2424 | void CalendarView::moveIncidence(Incidence * inc ) | 2424 | void CalendarView::moveIncidence(Incidence * inc ) |
2425 | { | 2425 | { |
2426 | if ( !inc ) return; | 2426 | if ( !inc ) return; |
2427 | // qDebug("showDatePickerForIncidence( ) "); | 2427 | // qDebug("showDatePickerForIncidence( ) "); |
2428 | if ( mDateFrame->isVisible() ) | 2428 | if ( mDateFrame->isVisible() ) |
2429 | mDateFrame->hide(); | 2429 | mDateFrame->hide(); |
2430 | else { | 2430 | else { |
2431 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2431 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2432 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2432 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2433 | int dw = QApplication::desktop()->width(); | 2433 | int dw = QApplication::desktop()->width(); |
2434 | int dh = QApplication::desktop()->height(); | 2434 | int dh = QApplication::desktop()->height(); |
2435 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2435 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2436 | mDateFrame->show(); | 2436 | mDateFrame->show(); |
2437 | } | 2437 | } |
2438 | mDatePickerMode = 2; | 2438 | mDatePickerMode = 2; |
2439 | mMoveIncidence = inc ; | 2439 | mMoveIncidence = inc ; |
2440 | QDate da; | 2440 | QDate da; |
2441 | if ( mMoveIncidence->type() == "Todo" ) { | 2441 | if ( mMoveIncidence->type() == "Todo" ) { |
2442 | Todo * to = (Todo *) mMoveIncidence; | 2442 | Todo * to = (Todo *) mMoveIncidence; |
2443 | if ( to->hasDueDate() ) | 2443 | if ( to->hasDueDate() ) |
2444 | da = to->dtDue().date(); | 2444 | da = to->dtDue().date(); |
2445 | else | 2445 | else |
2446 | da = QDate::currentDate(); | 2446 | da = QDate::currentDate(); |
2447 | } else { | 2447 | } else { |
2448 | da = mMoveIncidence->dtStart().date(); | 2448 | da = mMoveIncidence->dtStart().date(); |
2449 | } | 2449 | } |
2450 | //PENDING set date for recurring incidence to date of recurrence | 2450 | //PENDING set date for recurring incidence to date of recurrence |
2451 | //mMoveIncidenceOldDate; | 2451 | //mMoveIncidenceOldDate; |
2452 | mDatePicker->setDate( da ); | 2452 | mDatePicker->setDate( da ); |
2453 | } | 2453 | } |
2454 | void CalendarView::showDatePicker( ) | 2454 | void CalendarView::showDatePicker( ) |
2455 | { | 2455 | { |
2456 | //qDebug("CalendarView::showDatePicker( ) "); | 2456 | //qDebug("CalendarView::showDatePicker( ) "); |
2457 | if ( mDateFrame->isVisible() ) | 2457 | if ( mDateFrame->isVisible() ) |
2458 | mDateFrame->hide(); | 2458 | mDateFrame->hide(); |
2459 | else { | 2459 | else { |
2460 | int w =mDatePicker->sizeHint().width() ; | 2460 | int w =mDatePicker->sizeHint().width() ; |
2461 | int h = mDatePicker->sizeHint().height() ; | 2461 | int h = mDatePicker->sizeHint().height() ; |
2462 | int dw = QApplication::desktop()->width(); | 2462 | int dw = QApplication::desktop()->width(); |
2463 | int dh = QApplication::desktop()->height(); | 2463 | int dh = QApplication::desktop()->height(); |
2464 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2464 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2465 | mDateFrame->show(); | 2465 | mDateFrame->show(); |
2466 | } | 2466 | } |
2467 | mDatePickerMode = 1; | 2467 | mDatePickerMode = 1; |
2468 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2468 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2469 | } | 2469 | } |
2470 | 2470 | ||
2471 | void CalendarView::showEventEditor() | 2471 | void CalendarView::showEventEditor() |
2472 | { | 2472 | { |
2473 | #ifdef DESKTOP_VERSION | 2473 | #ifdef DESKTOP_VERSION |
2474 | mEventEditor->show(); | 2474 | mEventEditor->show(); |
2475 | #else | 2475 | #else |
2476 | if ( mEventEditor->width() != QApplication::desktop()->width() ) { | 2476 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2477 | qDebug("CalendarView: recreate mEventEditor "); | 2477 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2478 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | ||
2478 | delete mEventEditor; | 2479 | delete mEventEditor; |
2479 | mEventEditor = mDialogManager->getEventEditor(); | 2480 | mEventEditor = mDialogManager->getEventEditor(); |
2480 | } | 2481 | } |
2481 | mEventEditor->showMaximized(); | 2482 | mEventEditor->showMaximized(); |
2482 | #endif | 2483 | #endif |
2483 | } | 2484 | } |
2484 | void CalendarView::showTodoEditor() | 2485 | void CalendarView::showTodoEditor() |
2485 | { | 2486 | { |
2486 | #ifdef DESKTOP_VERSION | 2487 | #ifdef DESKTOP_VERSION |
2487 | mTodoEditor->show(); | 2488 | mTodoEditor->show(); |
2488 | #else | 2489 | #else |
2489 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) { | 2490 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2490 | qDebug("CalendarView: recreate mTodoEditor "); | 2491 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2492 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | ||
2491 | delete mTodoEditor; | 2493 | delete mTodoEditor; |
2492 | mTodoEditor = mDialogManager->getTodoEditor(); | 2494 | mTodoEditor = mDialogManager->getTodoEditor(); |
2493 | } | 2495 | } |
2494 | mTodoEditor->showMaximized(); | 2496 | mTodoEditor->showMaximized(); |
2495 | #endif | 2497 | #endif |
2496 | } | 2498 | } |
2497 | 2499 | ||
2498 | void CalendarView::cloneIncidence() | 2500 | void CalendarView::cloneIncidence() |
2499 | { | 2501 | { |
2500 | Incidence *incidence = currentSelection(); | 2502 | Incidence *incidence = currentSelection(); |
2501 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2503 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2502 | if ( incidence ) { | 2504 | if ( incidence ) { |
2503 | cloneIncidence(incidence); | 2505 | cloneIncidence(incidence); |
2504 | } | 2506 | } |
2505 | } | 2507 | } |
2506 | void CalendarView::moveIncidence() | 2508 | void CalendarView::moveIncidence() |
2507 | { | 2509 | { |
2508 | Incidence *incidence = currentSelection(); | 2510 | Incidence *incidence = currentSelection(); |
2509 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2511 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2510 | if ( incidence ) { | 2512 | if ( incidence ) { |
2511 | moveIncidence(incidence); | 2513 | moveIncidence(incidence); |
2512 | } | 2514 | } |
2513 | } | 2515 | } |
2514 | void CalendarView::beamIncidence() | 2516 | void CalendarView::beamIncidence() |
2515 | { | 2517 | { |
2516 | Incidence *incidence = currentSelection(); | 2518 | Incidence *incidence = currentSelection(); |
2517 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2519 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2518 | if ( incidence ) { | 2520 | if ( incidence ) { |
2519 | beamIncidence(incidence); | 2521 | beamIncidence(incidence); |
2520 | } | 2522 | } |
2521 | } | 2523 | } |
2522 | void CalendarView::toggleCancelIncidence() | 2524 | void CalendarView::toggleCancelIncidence() |
2523 | { | 2525 | { |
2524 | Incidence *incidence = currentSelection(); | 2526 | Incidence *incidence = currentSelection(); |
2525 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2527 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2526 | if ( incidence ) { | 2528 | if ( incidence ) { |
2527 | cancelIncidence(incidence); | 2529 | cancelIncidence(incidence); |
2528 | } | 2530 | } |
2529 | } | 2531 | } |
2530 | 2532 | ||
2531 | 2533 | ||
2532 | void CalendarView::cancelIncidence(Incidence * inc ) | 2534 | void CalendarView::cancelIncidence(Incidence * inc ) |
2533 | { | 2535 | { |
2534 | inc->setCancelled( ! inc->cancelled() ); | 2536 | inc->setCancelled( ! inc->cancelled() ); |
2535 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2537 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2536 | updateView(); | 2538 | updateView(); |
2537 | } | 2539 | } |
2538 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2540 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2539 | { | 2541 | { |
2540 | Incidence * newInc = orgInc->clone(); | 2542 | Incidence * newInc = orgInc->clone(); |
2541 | newInc->recreate(); | 2543 | newInc->recreate(); |
2542 | 2544 | ||
2543 | if ( newInc->type() == "Todo" ) { | 2545 | if ( newInc->type() == "Todo" ) { |
2544 | Todo* t = (Todo*) newInc; | 2546 | Todo* t = (Todo*) newInc; |
2545 | mTodoEditor->editTodo( t ); | ||
2546 | showTodoEditor(); | 2547 | showTodoEditor(); |
2548 | mTodoEditor->editTodo( t ); | ||
2547 | if ( mTodoEditor->exec() ) { | 2549 | if ( mTodoEditor->exec() ) { |
2548 | mCalendar->addTodo( t ); | 2550 | mCalendar->addTodo( t ); |
2549 | updateView(); | 2551 | updateView(); |
2550 | } else { | 2552 | } else { |
2551 | delete t; | 2553 | delete t; |
2552 | } | 2554 | } |
2553 | } | 2555 | } |
2554 | else { | 2556 | else { |
2555 | Event* e = (Event*) newInc; | 2557 | Event* e = (Event*) newInc; |
2556 | mEventEditor->editEvent( e ); | ||
2557 | showEventEditor(); | 2558 | showEventEditor(); |
2559 | mEventEditor->editEvent( e ); | ||
2558 | if ( mEventEditor->exec() ) { | 2560 | if ( mEventEditor->exec() ) { |
2559 | mCalendar->addEvent( e ); | 2561 | mCalendar->addEvent( e ); |
2560 | updateView(); | 2562 | updateView(); |
2561 | } else { | 2563 | } else { |
2562 | delete e; | 2564 | delete e; |
2563 | } | 2565 | } |
2564 | } | 2566 | } |
2565 | } | 2567 | } |
2566 | 2568 | ||
2567 | void CalendarView::newEvent() | 2569 | void CalendarView::newEvent() |
2568 | { | 2570 | { |
2569 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2571 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2570 | KOAgendaView *aView = mViewManager->agendaView(); | 2572 | KOAgendaView *aView = mViewManager->agendaView(); |
2571 | if (aView) { | 2573 | if (aView) { |
2572 | if (aView->selectionStart().isValid()) { | 2574 | if (aView->selectionStart().isValid()) { |
2573 | if (aView->selectedIsAllDay()) { | 2575 | if (aView->selectedIsAllDay()) { |
2574 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2576 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2575 | } else { | 2577 | } else { |
2576 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2578 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2577 | } | 2579 | } |
2578 | return; | 2580 | return; |
2579 | } | 2581 | } |
2580 | } | 2582 | } |
2581 | 2583 | ||
2582 | QDate date = mNavigator->selectedDates().first(); | 2584 | QDate date = mNavigator->selectedDates().first(); |
2583 | QDateTime current = QDateTime::currentDateTime(); | 2585 | QDateTime current = QDateTime::currentDateTime(); |
2584 | if ( date <= current.date() ) { | 2586 | if ( date <= current.date() ) { |
2585 | int hour = current.time().hour() +1; | 2587 | int hour = current.time().hour() +1; |
2586 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2588 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2587 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2589 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2588 | } else | 2590 | } else |
2589 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2591 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2590 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2592 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2591 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2593 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2592 | } | 2594 | } |
2593 | 2595 | ||
2594 | void CalendarView::newEvent(QDateTime fh) | 2596 | void CalendarView::newEvent(QDateTime fh) |
2595 | { | 2597 | { |
2596 | newEvent(fh, | 2598 | newEvent(fh, |
2597 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2599 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2598 | } | 2600 | } |
2599 | 2601 | ||
2600 | void CalendarView::newEvent(QDate dt) | 2602 | void CalendarView::newEvent(QDate dt) |
2601 | { | 2603 | { |
2602 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2604 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2603 | QDateTime(dt, QTime(0,0,0)), true); | 2605 | QDateTime(dt, QTime(0,0,0)), true); |
2604 | } | 2606 | } |
2605 | 2607 | ||
2606 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2608 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2607 | { | 2609 | { |
2608 | 2610 | ||
2611 | showEventEditor(); | ||
2609 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2612 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2610 | if ( mFilterView->filtersEnabled() ) { | 2613 | if ( mFilterView->filtersEnabled() ) { |
2611 | CalFilter *filter = mFilterView->selectedFilter(); | 2614 | CalFilter *filter = mFilterView->selectedFilter(); |
2612 | if (filter && filter->showCategories()) { | 2615 | if (filter && filter->showCategories()) { |
2613 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2616 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2614 | } | 2617 | } |
2615 | if ( filter ) | 2618 | if ( filter ) |
2616 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2619 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2617 | } | 2620 | } |
2618 | showEventEditor(); | ||
2619 | } | 2621 | } |
2620 | void CalendarView::todoAdded(Todo * t) | 2622 | void CalendarView::todoAdded(Todo * t) |
2621 | { | 2623 | { |
2622 | 2624 | ||
2623 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2625 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2624 | updateTodoViews(); | 2626 | updateTodoViews(); |
2625 | } | 2627 | } |
2626 | void CalendarView::todoChanged(Todo * t) | 2628 | void CalendarView::todoChanged(Todo * t) |
2627 | { | 2629 | { |
2628 | emit todoModified( t, 4 ); | 2630 | emit todoModified( t, 4 ); |
2629 | // updateTodoViews(); | 2631 | // updateTodoViews(); |
2630 | } | 2632 | } |
2631 | void CalendarView::todoToBeDeleted(Todo *) | 2633 | void CalendarView::todoToBeDeleted(Todo *) |
2632 | { | 2634 | { |
2633 | //qDebug("todoToBeDeleted(Todo *) "); | 2635 | //qDebug("todoToBeDeleted(Todo *) "); |
2634 | updateTodoViews(); | 2636 | updateTodoViews(); |
2635 | } | 2637 | } |
2636 | void CalendarView::todoDeleted() | 2638 | void CalendarView::todoDeleted() |
2637 | { | 2639 | { |
2638 | //qDebug(" todoDeleted()"); | 2640 | //qDebug(" todoDeleted()"); |
2639 | updateTodoViews(); | 2641 | updateTodoViews(); |
2640 | } | 2642 | } |
2641 | 2643 | ||
2642 | 2644 | ||
2643 | 2645 | ||
2644 | void CalendarView::newTodo() | 2646 | void CalendarView::newTodo() |
2645 | { | 2647 | { |
2646 | 2648 | ||
2649 | showTodoEditor(); | ||
2647 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2650 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2648 | if ( mFilterView->filtersEnabled() ) { | 2651 | if ( mFilterView->filtersEnabled() ) { |
2649 | CalFilter *filter = mFilterView->selectedFilter(); | 2652 | CalFilter *filter = mFilterView->selectedFilter(); |
2650 | if (filter && filter->showCategories()) { | 2653 | if (filter && filter->showCategories()) { |
2651 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2654 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2652 | } | 2655 | } |
2653 | if ( filter ) | 2656 | if ( filter ) |
2654 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2657 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2655 | } | 2658 | } |
2656 | showTodoEditor(); | ||
2657 | } | 2659 | } |
2658 | 2660 | ||
2659 | void CalendarView::newSubTodo() | 2661 | void CalendarView::newSubTodo() |
2660 | { | 2662 | { |
2661 | Todo *todo = selectedTodo(); | 2663 | Todo *todo = selectedTodo(); |
2662 | if ( todo ) newSubTodo( todo ); | 2664 | if ( todo ) newSubTodo( todo ); |
2663 | } | 2665 | } |
2664 | 2666 | ||
2665 | void CalendarView::newSubTodo(Todo *parentEvent) | 2667 | void CalendarView::newSubTodo(Todo *parentEvent) |
2666 | { | 2668 | { |
2667 | 2669 | ||
2668 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | ||
2669 | showTodoEditor(); | 2670 | showTodoEditor(); |
2671 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | ||
2670 | } | 2672 | } |
2671 | 2673 | ||
2672 | void CalendarView::newFloatingEvent() | 2674 | void CalendarView::newFloatingEvent() |
2673 | { | 2675 | { |
2674 | DateList tmpList = mNavigator->selectedDates(); | 2676 | DateList tmpList = mNavigator->selectedDates(); |
2675 | QDate date = tmpList.first(); | 2677 | QDate date = tmpList.first(); |
2676 | 2678 | ||
2677 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2679 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2678 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2680 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2679 | } | 2681 | } |
2680 | 2682 | ||
2681 | 2683 | ||
2682 | void CalendarView::editEvent( Event *event ) | 2684 | void CalendarView::editEvent( Event *event ) |
2683 | { | 2685 | { |
2684 | 2686 | ||
2685 | if ( !event ) return; | 2687 | if ( !event ) return; |
2686 | if ( event->isReadOnly() ) { | 2688 | if ( event->isReadOnly() ) { |
2687 | showEvent( event ); | 2689 | showEvent( event ); |
2688 | return; | 2690 | return; |
2689 | } | 2691 | } |
2690 | mEventEditor->editEvent( event , mFlagEditDescription); | ||
2691 | showEventEditor(); | 2692 | showEventEditor(); |
2693 | mEventEditor->editEvent( event , mFlagEditDescription); | ||
2692 | } | 2694 | } |
2693 | void CalendarView::editJournal( Journal *jour ) | 2695 | void CalendarView::editJournal( Journal *jour ) |
2694 | { | 2696 | { |
2695 | if ( !jour ) return; | 2697 | if ( !jour ) return; |
2696 | mDialogManager->hideSearchDialog(); | 2698 | mDialogManager->hideSearchDialog(); |
2697 | mViewManager->showJournalView(); | 2699 | mViewManager->showJournalView(); |
2698 | mNavigator->slotDaySelect( jour->dtStart().date() ); | 2700 | mNavigator->slotDaySelect( jour->dtStart().date() ); |
2699 | } | 2701 | } |
2700 | void CalendarView::editTodo( Todo *todo ) | 2702 | void CalendarView::editTodo( Todo *todo ) |
2701 | { | 2703 | { |
2702 | if ( !todo ) return; | 2704 | if ( !todo ) return; |
2703 | 2705 | ||
2704 | if ( todo->isReadOnly() ) { | 2706 | if ( todo->isReadOnly() ) { |
2705 | showTodo( todo ); | 2707 | showTodo( todo ); |
2706 | return; | 2708 | return; |
2707 | } | 2709 | } |
2708 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | ||
2709 | showTodoEditor(); | 2710 | showTodoEditor(); |
2711 | mTodoEditor->editTodo( todo ,mFlagEditDescription); | ||
2710 | 2712 | ||
2711 | } | 2713 | } |
2712 | 2714 | ||
2713 | KOEventViewerDialog* CalendarView::getEventViewerDialog() | 2715 | KOEventViewerDialog* CalendarView::getEventViewerDialog() |
2714 | { | 2716 | { |
2715 | if ( !mEventViewerDialog ) { | 2717 | if ( !mEventViewerDialog ) { |
2716 | mEventViewerDialog = new KOEventViewerDialog(this); | 2718 | mEventViewerDialog = new KOEventViewerDialog(this); |
2717 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); | 2719 | connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); |
2718 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); | 2720 | connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); |
2719 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), | 2721 | connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), |
2720 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); | 2722 | dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); |
2721 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), | 2723 | connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), |
2722 | viewManager(), SLOT( showAgendaView( bool ) ) ); | 2724 | viewManager(), SLOT( showAgendaView( bool ) ) ); |
2723 | mEventViewerDialog->resize( 640, 480 ); | 2725 | mEventViewerDialog->resize( 640, 480 ); |
2724 | 2726 | ||
2725 | } | 2727 | } |
2726 | return mEventViewerDialog; | 2728 | return mEventViewerDialog; |
2727 | } | 2729 | } |
2728 | void CalendarView::showEvent(Event *event) | 2730 | void CalendarView::showEvent(Event *event) |
2729 | { | 2731 | { |
2730 | getEventViewerDialog()->setEvent(event); | 2732 | getEventViewerDialog()->setEvent(event); |
2731 | getEventViewerDialog()->showMe(); | 2733 | getEventViewerDialog()->showMe(); |
2732 | } | 2734 | } |
2733 | 2735 | ||
2734 | void CalendarView::showTodo(Todo *event) | 2736 | void CalendarView::showTodo(Todo *event) |
2735 | { | 2737 | { |
2736 | getEventViewerDialog()->setTodo(event); | 2738 | getEventViewerDialog()->setTodo(event); |
2737 | getEventViewerDialog()->showMe(); | 2739 | getEventViewerDialog()->showMe(); |
2738 | } | 2740 | } |
2739 | void CalendarView::showJournal( Journal *jour ) | 2741 | void CalendarView::showJournal( Journal *jour ) |
2740 | { | 2742 | { |
2741 | getEventViewerDialog()->setJournal(jour); | 2743 | getEventViewerDialog()->setJournal(jour); |
2742 | getEventViewerDialog()->showMe(); | 2744 | getEventViewerDialog()->showMe(); |
2743 | 2745 | ||
2744 | } | 2746 | } |
2745 | // void CalendarView::todoModified (Todo *event, int changed) | 2747 | // void CalendarView::todoModified (Todo *event, int changed) |
2746 | // { | 2748 | // { |
2747 | // // if (mDialogList.find (event) != mDialogList.end ()) { | 2749 | // // if (mDialogList.find (event) != mDialogList.end ()) { |
2748 | // // kdDebug() << "Todo modified and open" << endl; | 2750 | // // kdDebug() << "Todo modified and open" << endl; |
2749 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; | 2751 | // // KOTodoEditor* temp = (KOTodoEditor *) mDialogList[event]; |
2750 | // // temp->modified (changed); | 2752 | // // temp->modified (changed); |
2751 | 2753 | ||
2752 | // // } | 2754 | // // } |
2753 | 2755 | ||
2754 | // mViewManager->updateView(); | 2756 | // mViewManager->updateView(); |
2755 | // } | 2757 | // } |
2756 | 2758 | ||
2757 | void CalendarView::appointment_show() | 2759 | void CalendarView::appointment_show() |
2758 | { | 2760 | { |
2759 | Event *anEvent = 0; | 2761 | Event *anEvent = 0; |
2760 | 2762 | ||
2761 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2763 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2762 | 2764 | ||
2763 | if (mViewManager->currentView()->isEventView()) { | 2765 | if (mViewManager->currentView()->isEventView()) { |
2764 | if ( incidence && incidence->type() == "Event" ) { | 2766 | if ( incidence && incidence->type() == "Event" ) { |
2765 | anEvent = static_cast<Event *>(incidence); | 2767 | anEvent = static_cast<Event *>(incidence); |
2766 | } | 2768 | } |
2767 | } | 2769 | } |
2768 | 2770 | ||
2769 | if (!anEvent) { | 2771 | if (!anEvent) { |
2770 | KNotifyClient::beep(); | 2772 | KNotifyClient::beep(); |
2771 | return; | 2773 | return; |
2772 | } | 2774 | } |
2773 | 2775 | ||
2774 | showEvent(anEvent); | 2776 | showEvent(anEvent); |
2775 | } | 2777 | } |
2776 | 2778 | ||
2777 | void CalendarView::appointment_edit() | 2779 | void CalendarView::appointment_edit() |
2778 | { | 2780 | { |
2779 | Event *anEvent = 0; | 2781 | Event *anEvent = 0; |
2780 | 2782 | ||
2781 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2783 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2782 | 2784 | ||
2783 | if (mViewManager->currentView()->isEventView()) { | 2785 | if (mViewManager->currentView()->isEventView()) { |
2784 | if ( incidence && incidence->type() == "Event" ) { | 2786 | if ( incidence && incidence->type() == "Event" ) { |
2785 | anEvent = static_cast<Event *>(incidence); | 2787 | anEvent = static_cast<Event *>(incidence); |
2786 | } | 2788 | } |
2787 | } | 2789 | } |
2788 | 2790 | ||
2789 | if (!anEvent) { | 2791 | if (!anEvent) { |
2790 | KNotifyClient::beep(); | 2792 | KNotifyClient::beep(); |
2791 | return; | 2793 | return; |
2792 | } | 2794 | } |
2793 | 2795 | ||
2794 | editEvent(anEvent); | 2796 | editEvent(anEvent); |
2795 | } | 2797 | } |
2796 | 2798 | ||
2797 | void CalendarView::appointment_delete() | 2799 | void CalendarView::appointment_delete() |
2798 | { | 2800 | { |
2799 | Event *anEvent = 0; | 2801 | Event *anEvent = 0; |
2800 | 2802 | ||
2801 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); | 2803 | Incidence *incidence = mViewManager->currentView()->selectedIncidences().first(); |
2802 | 2804 | ||
2803 | if (mViewManager->currentView()->isEventView()) { | 2805 | if (mViewManager->currentView()->isEventView()) { |
2804 | if ( incidence && incidence->type() == "Event" ) { | 2806 | if ( incidence && incidence->type() == "Event" ) { |
2805 | anEvent = static_cast<Event *>(incidence); | 2807 | anEvent = static_cast<Event *>(incidence); |
2806 | } | 2808 | } |
2807 | } | 2809 | } |
2808 | 2810 | ||
2809 | if (!anEvent) { | 2811 | if (!anEvent) { |
2810 | KNotifyClient::beep(); | 2812 | KNotifyClient::beep(); |
2811 | return; | 2813 | return; |
2812 | } | 2814 | } |
2813 | 2815 | ||
2814 | deleteEvent(anEvent); | 2816 | deleteEvent(anEvent); |
2815 | } | 2817 | } |
2816 | 2818 | ||
2817 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) | 2819 | void CalendarView::todo_resub( Todo * parent, Todo * sub ) |
2818 | { | 2820 | { |
2819 | if (!sub) return; | 2821 | if (!sub) return; |
2820 | if (!parent) return; | 2822 | if (!parent) return; |
2821 | if ( sub->relatedTo() ) | 2823 | if ( sub->relatedTo() ) |
2822 | sub->relatedTo()->removeRelation(sub); | 2824 | sub->relatedTo()->removeRelation(sub); |
2823 | sub->setRelatedTo(parent); | 2825 | sub->setRelatedTo(parent); |
2824 | sub->setRelatedToUid(parent->uid()); | 2826 | sub->setRelatedToUid(parent->uid()); |
2825 | parent->addRelation(sub); | 2827 | parent->addRelation(sub); |
2826 | sub->updated(); | 2828 | sub->updated(); |
2827 | parent->updated(); | 2829 | parent->updated(); |
2828 | setModified(true); | 2830 | setModified(true); |
2829 | updateView(); | 2831 | updateView(); |
2830 | } | 2832 | } |
2831 | void CalendarView::todo_unsub(Todo *anTodo ) | 2833 | void CalendarView::todo_unsub(Todo *anTodo ) |
2832 | { | 2834 | { |
2833 | // Todo *anTodo = selectedTodo(); | 2835 | // Todo *anTodo = selectedTodo(); |
2834 | if (!anTodo) return; | 2836 | if (!anTodo) return; |
2835 | if (!anTodo->relatedTo()) return; | 2837 | if (!anTodo->relatedTo()) return; |
2836 | anTodo->relatedTo()->removeRelation(anTodo); | 2838 | anTodo->relatedTo()->removeRelation(anTodo); |
2837 | anTodo->setRelatedTo(0); | 2839 | anTodo->setRelatedTo(0); |
2838 | anTodo->updated(); | 2840 | anTodo->updated(); |
2839 | anTodo->setRelatedToUid(""); | 2841 | anTodo->setRelatedToUid(""); |
2840 | setModified(true); | 2842 | setModified(true); |
2841 | updateView(); | 2843 | updateView(); |
2842 | } | 2844 | } |
2843 | 2845 | ||
2844 | void CalendarView::deleteTodo(Todo *todo) | 2846 | void CalendarView::deleteTodo(Todo *todo) |
2845 | { | 2847 | { |
2846 | if (!todo) { | 2848 | if (!todo) { |
2847 | KNotifyClient::beep(); | 2849 | KNotifyClient::beep(); |
2848 | return; | 2850 | return; |
2849 | } | 2851 | } |
2850 | if (KOPrefs::instance()->mConfirm) { | 2852 | if (KOPrefs::instance()->mConfirm) { |
2851 | switch (msgItemDelete()) { | 2853 | switch (msgItemDelete()) { |
2852 | case KMessageBox::Continue: // OK | 2854 | case KMessageBox::Continue: // OK |
2853 | if (!todo->relations().isEmpty()) { | 2855 | if (!todo->relations().isEmpty()) { |
2854 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2856 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2855 | i18n("Delete To-Do")); | 2857 | i18n("Delete To-Do")); |
2856 | } else { | 2858 | } else { |
2857 | checkExternalId( todo ); | 2859 | checkExternalId( todo ); |
2858 | calendar()->deleteTodo(todo); | 2860 | calendar()->deleteTodo(todo); |
2859 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2861 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2860 | updateView(); | 2862 | updateView(); |
2861 | } | 2863 | } |
2862 | break; | 2864 | break; |
2863 | } // switch | 2865 | } // switch |
2864 | } else { | 2866 | } else { |
2865 | if (!todo->relations().isEmpty()) { | 2867 | if (!todo->relations().isEmpty()) { |
2866 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), | 2868 | KMessageBox::sorry(this,i18n("Cannot delete To-Do\nwhich has children."), |
2867 | i18n("Delete To-Do")); | 2869 | i18n("Delete To-Do")); |
2868 | } else { | 2870 | } else { |
2869 | checkExternalId( todo ); | 2871 | checkExternalId( todo ); |
2870 | mCalendar->deleteTodo(todo); | 2872 | mCalendar->deleteTodo(todo); |
2871 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); | 2873 | changeTodoDisplay( todo,KOGlobals::EVENTDELETED ); |
2872 | updateView(); | 2874 | updateView(); |
2873 | } | 2875 | } |
2874 | } | 2876 | } |
2875 | emit updateSearchDialog(); | 2877 | emit updateSearchDialog(); |
2876 | } | 2878 | } |
2877 | void CalendarView::deleteJournal(Journal *jour) | 2879 | void CalendarView::deleteJournal(Journal *jour) |
2878 | { | 2880 | { |
2879 | if (!jour) { | 2881 | if (!jour) { |
2880 | KNotifyClient::beep(); | 2882 | KNotifyClient::beep(); |
2881 | return; | 2883 | return; |
2882 | } | 2884 | } |
2883 | if (KOPrefs::instance()->mConfirm) { | 2885 | if (KOPrefs::instance()->mConfirm) { |
2884 | switch (msgItemDelete()) { | 2886 | switch (msgItemDelete()) { |
2885 | case KMessageBox::Continue: // OK | 2887 | case KMessageBox::Continue: // OK |
2886 | calendar()->deleteJournal(jour); | 2888 | calendar()->deleteJournal(jour); |
2887 | updateView(); | 2889 | updateView(); |
2888 | break; | 2890 | break; |
2889 | } // switch | 2891 | } // switch |
2890 | } else { | 2892 | } else { |
2891 | calendar()->deleteJournal(jour);; | 2893 | calendar()->deleteJournal(jour);; |
2892 | updateView(); | 2894 | updateView(); |
2893 | } | 2895 | } |
2894 | emit updateSearchDialog(); | 2896 | emit updateSearchDialog(); |
2895 | } | 2897 | } |
2896 | 2898 | ||
2897 | void CalendarView::deleteEvent(Event *anEvent) | 2899 | void CalendarView::deleteEvent(Event *anEvent) |
2898 | { | 2900 | { |
2899 | if (!anEvent) { | 2901 | if (!anEvent) { |
2900 | KNotifyClient::beep(); | 2902 | KNotifyClient::beep(); |
2901 | return; | 2903 | return; |
2902 | } | 2904 | } |
2903 | 2905 | ||
2904 | if (anEvent->recurrence()->doesRecur()) { | 2906 | if (anEvent->recurrence()->doesRecur()) { |
2905 | QDate itemDate = mViewManager->currentSelectionDate(); | 2907 | QDate itemDate = mViewManager->currentSelectionDate(); |
2906 | int km; | 2908 | int km; |
2907 | if (!itemDate.isValid()) { | 2909 | if (!itemDate.isValid()) { |
2908 | //kdDebug() << "Date Not Valid" << endl; | 2910 | //kdDebug() << "Date Not Valid" << endl; |
2909 | if (KOPrefs::instance()->mConfirm) { | 2911 | if (KOPrefs::instance()->mConfirm) { |
2910 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2912 | km = KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2911 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), | 2913 | i18n("\nThis event recurs\nover multiple dates.\nAre you sure you want\nto delete this event\nand all its recurrences?"), |
2912 | i18n("KO/Pi Confirmation"),i18n("Delete All")); | 2914 | i18n("KO/Pi Confirmation"),i18n("Delete All")); |
2913 | if ( km == KMessageBox::Continue ) | 2915 | if ( km == KMessageBox::Continue ) |
2914 | km = KMessageBox::No; // No = all below | 2916 | km = KMessageBox::No; // No = all below |
2915 | } else | 2917 | } else |
2916 | km = KMessageBox::No; | 2918 | km = KMessageBox::No; |
2917 | } else { | 2919 | } else { |
2918 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + | 2920 | km = KMessageBox::warningYesNoCancel(this,anEvent->summary().left(25) + |
2919 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ | 2921 | i18n("\nThis event recurs\nover multiple dates.\nDo you want to delete\nall it's recurrences,\nor only the current one on:\n")+ |
2920 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), | 2922 | KGlobal::locale()->formatDate(itemDate)+i18n(" ?\n\nDelete:\n"), |
2921 | i18n("KO/Pi Confirmation"),i18n("Current"), | 2923 | i18n("KO/Pi Confirmation"),i18n("Current"), |
2922 | i18n("All")); | 2924 | i18n("All")); |
2923 | } | 2925 | } |
2924 | switch(km) { | 2926 | switch(km) { |
2925 | 2927 | ||
2926 | case KMessageBox::No: // Continue // all | 2928 | case KMessageBox::No: // Continue // all |
2927 | //qDebug("KMessageBox::No "); | 2929 | //qDebug("KMessageBox::No "); |
2928 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2930 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2929 | schedule(Scheduler::Cancel,anEvent); | 2931 | schedule(Scheduler::Cancel,anEvent); |
2930 | 2932 | ||
2931 | checkExternalId( anEvent); | 2933 | checkExternalId( anEvent); |
2932 | mCalendar->deleteEvent(anEvent); | 2934 | mCalendar->deleteEvent(anEvent); |
2933 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); | 2935 | changeEventDisplay(anEvent,KOGlobals::EVENTDELETED); |
2934 | break; | 2936 | break; |
2935 | 2937 | ||
2936 | // Disabled because it does not work | 2938 | // Disabled because it does not work |
2937 | //#if 0 | 2939 | //#if 0 |
2938 | case KMessageBox::Yes: // just this one | 2940 | case KMessageBox::Yes: // just this one |
2939 | //QDate qd = mNavigator->selectedDates().first(); | 2941 | //QDate qd = mNavigator->selectedDates().first(); |
2940 | //if (!qd.isValid()) { | 2942 | //if (!qd.isValid()) { |
2941 | // kdDebug() << "no date selected, or invalid date" << endl; | 2943 | // kdDebug() << "no date selected, or invalid date" << endl; |
2942 | // KNotifyClient::beep(); | 2944 | // KNotifyClient::beep(); |
2943 | // return; | 2945 | // return; |
2944 | //} | 2946 | //} |
2945 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); | 2947 | //while (!anEvent->recursOn(qd)) qd = qd.addDays(1); |
2946 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { | 2948 | if (itemDate!=QDate(1,1,1) || itemDate.isValid()) { |
2947 | anEvent->addExDate(itemDate); | 2949 | anEvent->addExDate(itemDate); |
2948 | int duration = anEvent->recurrence()->duration(); | 2950 | int duration = anEvent->recurrence()->duration(); |
2949 | if ( duration > 0 ) { | 2951 | if ( duration > 0 ) { |
2950 | anEvent->recurrence()->setDuration( duration - 1 ); | 2952 | anEvent->recurrence()->setDuration( duration - 1 ); |
2951 | } | 2953 | } |
2952 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); | 2954 | changeEventDisplay(anEvent, KOGlobals::EVENTEDITED); |
2953 | } | 2955 | } |
2954 | break; | 2956 | break; |
2955 | //#endif | 2957 | //#endif |
2956 | } // switch | 2958 | } // switch |
2957 | } else { | 2959 | } else { |
2958 | if (KOPrefs::instance()->mConfirm) { | 2960 | if (KOPrefs::instance()->mConfirm) { |
2959 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + | 2961 | switch (KMessageBox::warningContinueCancel(this,anEvent->summary().left(25) + |
2960 | i18n("\nAre you sure you want\nto delete this event?"), | 2962 | i18n("\nAre you sure you want\nto delete this event?"), |
2961 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { | 2963 | i18n("KO/Pi Confirmation"),i18n("Delete"))) { |
2962 | case KMessageBox::Continue: // OK | 2964 | case KMessageBox::Continue: // OK |
2963 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) | 2965 | if (anEvent->organizer()==KOPrefs::instance()->email() && anEvent->attendeeCount()>0) |
2964 | schedule(Scheduler::Cancel,anEvent); | 2966 | schedule(Scheduler::Cancel,anEvent); |
2965 | checkExternalId( anEvent); | 2967 | checkExternalId( anEvent); |