-rw-r--r-- | korganizer/calendarview.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index da1edea..9c10ba6 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2319,398 +2319,400 @@ int CalendarView::addCategories() | |||
2319 | QStringList catIncList; | 2319 | QStringList catIncList; |
2320 | Incidence* inc = incList.first(); | 2320 | Incidence* inc = incList.first(); |
2321 | int i; | 2321 | int i; |
2322 | int count = 0; | 2322 | int count = 0; |
2323 | while ( inc ) { | 2323 | while ( inc ) { |
2324 | catIncList = inc->categories() ; | 2324 | catIncList = inc->categories() ; |
2325 | for( i = 0; i< catIncList.count(); ++i ) { | 2325 | for( i = 0; i< catIncList.count(); ++i ) { |
2326 | if ( !catList.contains (catIncList[i])) { | 2326 | if ( !catList.contains (catIncList[i])) { |
2327 | catList.append( catIncList[i] ); | 2327 | catList.append( catIncList[i] ); |
2328 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2328 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2329 | ++count; | 2329 | ++count; |
2330 | } | 2330 | } |
2331 | } | 2331 | } |
2332 | inc = incList.next(); | 2332 | inc = incList.next(); |
2333 | } | 2333 | } |
2334 | catList.sort(); | 2334 | catList.sort(); |
2335 | KOPrefs::instance()->mCustomCategories = catList; | 2335 | KOPrefs::instance()->mCustomCategories = catList; |
2336 | return count; | 2336 | return count; |
2337 | } | 2337 | } |
2338 | 2338 | ||
2339 | void CalendarView::manageCategories() | 2339 | void CalendarView::manageCategories() |
2340 | { | 2340 | { |
2341 | KOCatPrefs* cp = new KOCatPrefs(); | 2341 | KOCatPrefs* cp = new KOCatPrefs(); |
2342 | cp->show(); | 2342 | cp->show(); |
2343 | int w =cp->sizeHint().width() ; | 2343 | int w =cp->sizeHint().width() ; |
2344 | int h = cp->sizeHint().height() ; | 2344 | int h = cp->sizeHint().height() ; |
2345 | int dw = QApplication::desktop()->width(); | 2345 | int dw = QApplication::desktop()->width(); |
2346 | int dh = QApplication::desktop()->height(); | 2346 | int dh = QApplication::desktop()->height(); |
2347 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2347 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2348 | if ( !cp->exec() ) { | 2348 | if ( !cp->exec() ) { |
2349 | delete cp; | 2349 | delete cp; |
2350 | return; | 2350 | return; |
2351 | } | 2351 | } |
2352 | int count = 0; | 2352 | int count = 0; |
2353 | if ( cp->addCat() ) { | 2353 | if ( cp->addCat() ) { |
2354 | count = addCategories(); | 2354 | count = addCategories(); |
2355 | if ( count ) { | 2355 | if ( count ) { |
2356 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2356 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2357 | writeSettings(); | 2357 | writeSettings(); |
2358 | } else | 2358 | } else |
2359 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2359 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2360 | } else { | 2360 | } else { |
2361 | removeCategories(); | 2361 | removeCategories(); |
2362 | updateView(); | 2362 | updateView(); |
2363 | } | 2363 | } |
2364 | delete cp; | 2364 | delete cp; |
2365 | } | 2365 | } |
2366 | 2366 | ||
2367 | void CalendarView::beamIncidence(Incidence * Inc) | 2367 | void CalendarView::beamIncidence(Incidence * Inc) |
2368 | { | 2368 | { |
2369 | QPtrList<Incidence> delSel ; | 2369 | QPtrList<Incidence> delSel ; |
2370 | delSel.append(Inc); | 2370 | delSel.append(Inc); |
2371 | beamIncidenceList( delSel ); | 2371 | beamIncidenceList( delSel ); |
2372 | } | 2372 | } |
2373 | void CalendarView::beamCalendar() | 2373 | void CalendarView::beamCalendar() |
2374 | { | 2374 | { |
2375 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2375 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2376 | //qDebug("beamCalendar() "); | 2376 | //qDebug("beamCalendar() "); |
2377 | beamIncidenceList( delSel ); | 2377 | beamIncidenceList( delSel ); |
2378 | } | 2378 | } |
2379 | void CalendarView::beamFilteredCalendar() | 2379 | void CalendarView::beamFilteredCalendar() |
2380 | { | 2380 | { |
2381 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2381 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2382 | //qDebug("beamFilteredCalendar() "); | 2382 | //qDebug("beamFilteredCalendar() "); |
2383 | beamIncidenceList( delSel ); | 2383 | beamIncidenceList( delSel ); |
2384 | } | 2384 | } |
2385 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2385 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2386 | { | 2386 | { |
2387 | if ( beamDialog->exec () == QDialog::Rejected ) | 2387 | if ( beamDialog->exec () == QDialog::Rejected ) |
2388 | return; | 2388 | return; |
2389 | #ifdef DESKTOP_VERSION | 2389 | #ifdef DESKTOP_VERSION |
2390 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2390 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2391 | #else | 2391 | #else |
2392 | QString fn = "/tmp/kopibeamfile"; | 2392 | QString fn = "/tmp/kopibeamfile"; |
2393 | #endif | 2393 | #endif |
2394 | QString mes; | 2394 | QString mes; |
2395 | bool createbup = true; | 2395 | bool createbup = true; |
2396 | if ( createbup ) { | 2396 | if ( createbup ) { |
2397 | QString description = "\n"; | 2397 | QString description = "\n"; |
2398 | CalendarLocal* cal = new CalendarLocal(); | 2398 | CalendarLocal* cal = new CalendarLocal(); |
2399 | if ( beamDialog->beamLocal() ) | 2399 | if ( beamDialog->beamLocal() ) |
2400 | cal->setLocalTime(); | 2400 | cal->setLocalTime(); |
2401 | else | 2401 | else |
2402 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2402 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2403 | Incidence *incidence = delSel.first(); | 2403 | Incidence *incidence = delSel.first(); |
2404 | bool addText = false; | 2404 | bool addText = false; |
2405 | if ( delSel.count() < 10 ) | 2405 | if ( delSel.count() < 10 ) |
2406 | addText = true; | 2406 | addText = true; |
2407 | else { | 2407 | else { |
2408 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2408 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2409 | } | 2409 | } |
2410 | while ( incidence ) { | 2410 | while ( incidence ) { |
2411 | Incidence *in = incidence->clone(); | 2411 | Incidence *in = incidence->clone(); |
2412 | if ( ! in->summary().isEmpty() ) { | 2412 | if ( ! in->summary().isEmpty() ) { |
2413 | in->setDescription(""); | 2413 | in->setDescription(""); |
2414 | } else { | 2414 | } else { |
2415 | in->setSummary( in->description().left(20)); | 2415 | in->setSummary( in->description().left(20)); |
2416 | in->setDescription(""); | 2416 | in->setDescription(""); |
2417 | } | 2417 | } |
2418 | if ( addText ) | 2418 | if ( addText ) |
2419 | description += in->summary() + "\n"; | 2419 | description += in->summary() + "\n"; |
2420 | cal->addIncidence( in ); | 2420 | cal->addIncidence( in ); |
2421 | incidence = delSel.next(); | 2421 | incidence = delSel.next(); |
2422 | } | 2422 | } |
2423 | if ( beamDialog->beamVcal() ) { | 2423 | if ( beamDialog->beamVcal() ) { |
2424 | fn += ".vcs"; | 2424 | fn += ".vcs"; |
2425 | FileStorage storage( cal, fn, new VCalFormat ); | 2425 | FileStorage storage( cal, fn, new VCalFormat ); |
2426 | storage.save(); | 2426 | storage.save(); |
2427 | } else { | 2427 | } else { |
2428 | fn += ".ics"; | 2428 | fn += ".ics"; |
2429 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2429 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2430 | storage.save(); | 2430 | storage.save(); |
2431 | } | 2431 | } |
2432 | delete cal; | 2432 | delete cal; |
2433 | mes = i18n("KO/Pi: Ready for beaming"); | 2433 | mes = i18n("KO/Pi: Ready for beaming"); |
2434 | topLevelWidget()->setCaption(mes); | 2434 | topLevelWidget()->setCaption(mes); |
2435 | KApplication::convert2latin1( fn ); | 2435 | KApplication::convert2latin1( fn ); |
2436 | #ifndef DESKTOP_VERSION | 2436 | #ifndef DESKTOP_VERSION |
2437 | Ir *ir = new Ir( this ); | 2437 | Ir *ir = new Ir( this ); |
2438 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2438 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2439 | ir->send( fn, description, "text/x-vCalendar" ); | 2439 | ir->send( fn, description, "text/x-vCalendar" ); |
2440 | #endif | 2440 | #endif |
2441 | } | 2441 | } |
2442 | } | 2442 | } |
2443 | void CalendarView::beamDone( Ir *ir ) | 2443 | void CalendarView::beamDone( Ir *ir ) |
2444 | { | 2444 | { |
2445 | #ifndef DESKTOP_VERSION | 2445 | #ifndef DESKTOP_VERSION |
2446 | delete ir; | 2446 | delete ir; |
2447 | #endif | 2447 | #endif |
2448 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2448 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2449 | topLevelWidget()->raise(); | 2449 | topLevelWidget()->raise(); |
2450 | } | 2450 | } |
2451 | 2451 | ||
2452 | void CalendarView::moveIncidence(Incidence * inc ) | 2452 | void CalendarView::moveIncidence(Incidence * inc ) |
2453 | { | 2453 | { |
2454 | if ( !inc ) return; | 2454 | if ( !inc ) return; |
2455 | // qDebug("showDatePickerForIncidence( ) "); | 2455 | // qDebug("showDatePickerForIncidence( ) "); |
2456 | if ( mDateFrame->isVisible() ) | 2456 | if ( mDateFrame->isVisible() ) |
2457 | mDateFrame->hide(); | 2457 | mDateFrame->hide(); |
2458 | else { | 2458 | else { |
2459 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2459 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2460 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2460 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2461 | int dw = QApplication::desktop()->width(); | 2461 | int dw = QApplication::desktop()->width(); |
2462 | int dh = QApplication::desktop()->height(); | 2462 | int dh = QApplication::desktop()->height(); |
2463 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2463 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2464 | mDateFrame->show(); | 2464 | mDateFrame->show(); |
2465 | } | 2465 | } |
2466 | mDatePickerMode = 2; | 2466 | mDatePickerMode = 2; |
2467 | mMoveIncidence = inc ; | 2467 | mMoveIncidence = inc ; |
2468 | QDate da; | 2468 | QDate da; |
2469 | if ( mMoveIncidence->type() == "Todo" ) { | 2469 | if ( mMoveIncidence->type() == "Todo" ) { |
2470 | Todo * to = (Todo *) mMoveIncidence; | 2470 | Todo * to = (Todo *) mMoveIncidence; |
2471 | if ( to->hasDueDate() ) | 2471 | if ( to->hasDueDate() ) |
2472 | da = to->dtDue().date(); | 2472 | da = to->dtDue().date(); |
2473 | else | 2473 | else |
2474 | da = QDate::currentDate(); | 2474 | da = QDate::currentDate(); |
2475 | } else { | 2475 | } else { |
2476 | da = mMoveIncidence->dtStart().date(); | 2476 | da = mMoveIncidence->dtStart().date(); |
2477 | } | 2477 | } |
2478 | //PENDING set date for recurring incidence to date of recurrence | 2478 | //PENDING set date for recurring incidence to date of recurrence |
2479 | //mMoveIncidenceOldDate; | 2479 | //mMoveIncidenceOldDate; |
2480 | mDatePicker->setDate( da ); | 2480 | mDatePicker->setDate( da ); |
2481 | } | 2481 | } |
2482 | void CalendarView::showDatePicker( ) | 2482 | void CalendarView::showDatePicker( ) |
2483 | { | 2483 | { |
2484 | //qDebug("CalendarView::showDatePicker( ) "); | 2484 | //qDebug("CalendarView::showDatePicker( ) "); |
2485 | if ( mDateFrame->isVisible() ) | 2485 | if ( mDateFrame->isVisible() ) |
2486 | mDateFrame->hide(); | 2486 | mDateFrame->hide(); |
2487 | else { | 2487 | else { |
2488 | int w =mDatePicker->sizeHint().width() ; | 2488 | int w =mDatePicker->sizeHint().width() ; |
2489 | int h = mDatePicker->sizeHint().height() ; | 2489 | int h = mDatePicker->sizeHint().height() ; |
2490 | int dw = QApplication::desktop()->width(); | 2490 | int dw = QApplication::desktop()->width(); |
2491 | int dh = QApplication::desktop()->height(); | 2491 | int dh = QApplication::desktop()->height(); |
2492 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2492 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2493 | mDateFrame->show(); | 2493 | mDateFrame->show(); |
2494 | } | 2494 | } |
2495 | mDatePickerMode = 1; | 2495 | mDatePickerMode = 1; |
2496 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2496 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2497 | } | 2497 | } |
2498 | 2498 | ||
2499 | void CalendarView::showEventEditor() | 2499 | void CalendarView::showEventEditor() |
2500 | { | 2500 | { |
2501 | #ifdef DESKTOP_VERSION | 2501 | #ifdef DESKTOP_VERSION |
2502 | mEventEditor->show(); | 2502 | mEventEditor->show(); |
2503 | #else | 2503 | #else |
2504 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { | 2504 | if ( mEventEditor->width() < QApplication::desktop()->width() -60 || mEventEditor->width() > QApplication::desktop()->width() ) { |
2505 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2505 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2506 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); | 2506 | qDebug("CalendarView: recreate mEventEditor %d %d", mEventEditor->width(), QApplication::desktop()->width() ); |
2507 | delete mEventEditor; | 2507 | delete mEventEditor; |
2508 | mEventEditor = mDialogManager->getEventEditor(); | 2508 | mEventEditor = mDialogManager->getEventEditor(); |
2509 | } | 2509 | } |
2510 | mEventEditor->showMaximized(); | 2510 | mEventEditor->showMaximized(); |
2511 | topLevelWidget()->setCaption( i18n("") ); | ||
2511 | #endif | 2512 | #endif |
2512 | } | 2513 | } |
2513 | void CalendarView::showTodoEditor() | 2514 | void CalendarView::showTodoEditor() |
2514 | { | 2515 | { |
2515 | #ifdef DESKTOP_VERSION | 2516 | #ifdef DESKTOP_VERSION |
2516 | mTodoEditor->show(); | 2517 | mTodoEditor->show(); |
2517 | #else | 2518 | #else |
2518 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { | 2519 | if ( mTodoEditor->width() < QApplication::desktop()->width() -60|| mTodoEditor->width() > QApplication::desktop()->width() ) { |
2519 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); | 2520 | topLevelWidget()->setCaption( i18n("Recreating edit dialog. Please wait...") ); |
2520 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); | 2521 | qDebug("CalendarView: recreate mTodoEditor %d %d ", mTodoEditor->width() ,QApplication::desktop()->width() ); |
2521 | delete mTodoEditor; | 2522 | delete mTodoEditor; |
2522 | mTodoEditor = mDialogManager->getTodoEditor(); | 2523 | mTodoEditor = mDialogManager->getTodoEditor(); |
2523 | } | 2524 | } |
2524 | mTodoEditor->showMaximized(); | 2525 | mTodoEditor->showMaximized(); |
2526 | topLevelWidget()->setCaption( i18n("") ); | ||
2525 | #endif | 2527 | #endif |
2526 | } | 2528 | } |
2527 | 2529 | ||
2528 | void CalendarView::cloneIncidence() | 2530 | void CalendarView::cloneIncidence() |
2529 | { | 2531 | { |
2530 | Incidence *incidence = currentSelection(); | 2532 | Incidence *incidence = currentSelection(); |
2531 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2533 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2532 | if ( incidence ) { | 2534 | if ( incidence ) { |
2533 | cloneIncidence(incidence); | 2535 | cloneIncidence(incidence); |
2534 | } | 2536 | } |
2535 | } | 2537 | } |
2536 | void CalendarView::moveIncidence() | 2538 | void CalendarView::moveIncidence() |
2537 | { | 2539 | { |
2538 | Incidence *incidence = currentSelection(); | 2540 | Incidence *incidence = currentSelection(); |
2539 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2541 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2540 | if ( incidence ) { | 2542 | if ( incidence ) { |
2541 | moveIncidence(incidence); | 2543 | moveIncidence(incidence); |
2542 | } | 2544 | } |
2543 | } | 2545 | } |
2544 | void CalendarView::beamIncidence() | 2546 | void CalendarView::beamIncidence() |
2545 | { | 2547 | { |
2546 | Incidence *incidence = currentSelection(); | 2548 | Incidence *incidence = currentSelection(); |
2547 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2549 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2548 | if ( incidence ) { | 2550 | if ( incidence ) { |
2549 | beamIncidence(incidence); | 2551 | beamIncidence(incidence); |
2550 | } | 2552 | } |
2551 | } | 2553 | } |
2552 | void CalendarView::toggleCancelIncidence() | 2554 | void CalendarView::toggleCancelIncidence() |
2553 | { | 2555 | { |
2554 | Incidence *incidence = currentSelection(); | 2556 | Incidence *incidence = currentSelection(); |
2555 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2557 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2556 | if ( incidence ) { | 2558 | if ( incidence ) { |
2557 | cancelIncidence(incidence); | 2559 | cancelIncidence(incidence); |
2558 | } | 2560 | } |
2559 | } | 2561 | } |
2560 | 2562 | ||
2561 | 2563 | ||
2562 | void CalendarView::cancelIncidence(Incidence * inc ) | 2564 | void CalendarView::cancelIncidence(Incidence * inc ) |
2563 | { | 2565 | { |
2564 | inc->setCancelled( ! inc->cancelled() ); | 2566 | inc->setCancelled( ! inc->cancelled() ); |
2565 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2567 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2566 | updateView(); | 2568 | updateView(); |
2567 | } | 2569 | } |
2568 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2570 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2569 | { | 2571 | { |
2570 | Incidence * newInc = orgInc->clone(); | 2572 | Incidence * newInc = orgInc->clone(); |
2571 | newInc->recreate(); | 2573 | newInc->recreate(); |
2572 | 2574 | ||
2573 | if ( newInc->type() == "Todo" ) { | 2575 | if ( newInc->type() == "Todo" ) { |
2574 | Todo* t = (Todo*) newInc; | 2576 | Todo* t = (Todo*) newInc; |
2575 | showTodoEditor(); | 2577 | showTodoEditor(); |
2576 | mTodoEditor->editTodo( t ); | 2578 | mTodoEditor->editTodo( t ); |
2577 | if ( mTodoEditor->exec() ) { | 2579 | if ( mTodoEditor->exec() ) { |
2578 | mCalendar->addTodo( t ); | 2580 | mCalendar->addTodo( t ); |
2579 | updateView(); | 2581 | updateView(); |
2580 | } else { | 2582 | } else { |
2581 | delete t; | 2583 | delete t; |
2582 | } | 2584 | } |
2583 | } | 2585 | } |
2584 | else { | 2586 | else { |
2585 | Event* e = (Event*) newInc; | 2587 | Event* e = (Event*) newInc; |
2586 | showEventEditor(); | 2588 | showEventEditor(); |
2587 | mEventEditor->editEvent( e ); | 2589 | mEventEditor->editEvent( e ); |
2588 | if ( mEventEditor->exec() ) { | 2590 | if ( mEventEditor->exec() ) { |
2589 | mCalendar->addEvent( e ); | 2591 | mCalendar->addEvent( e ); |
2590 | updateView(); | 2592 | updateView(); |
2591 | } else { | 2593 | } else { |
2592 | delete e; | 2594 | delete e; |
2593 | } | 2595 | } |
2594 | } | 2596 | } |
2595 | } | 2597 | } |
2596 | 2598 | ||
2597 | void CalendarView::newEvent() | 2599 | void CalendarView::newEvent() |
2598 | { | 2600 | { |
2599 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2601 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2600 | KOAgendaView *aView = mViewManager->agendaView(); | 2602 | KOAgendaView *aView = mViewManager->agendaView(); |
2601 | if (aView) { | 2603 | if (aView) { |
2602 | if (aView->selectionStart().isValid()) { | 2604 | if (aView->selectionStart().isValid()) { |
2603 | if (aView->selectedIsAllDay()) { | 2605 | if (aView->selectedIsAllDay()) { |
2604 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2606 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2605 | } else { | 2607 | } else { |
2606 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2608 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2607 | } | 2609 | } |
2608 | return; | 2610 | return; |
2609 | } | 2611 | } |
2610 | } | 2612 | } |
2611 | 2613 | ||
2612 | QDate date = mNavigator->selectedDates().first(); | 2614 | QDate date = mNavigator->selectedDates().first(); |
2613 | QDateTime current = QDateTime::currentDateTime(); | 2615 | QDateTime current = QDateTime::currentDateTime(); |
2614 | if ( date <= current.date() ) { | 2616 | if ( date <= current.date() ) { |
2615 | int hour = current.time().hour() +1; | 2617 | int hour = current.time().hour() +1; |
2616 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2618 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2617 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2619 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2618 | } else | 2620 | } else |
2619 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2621 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2620 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2622 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2621 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2623 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2622 | } | 2624 | } |
2623 | 2625 | ||
2624 | void CalendarView::newEvent(QDateTime fh) | 2626 | void CalendarView::newEvent(QDateTime fh) |
2625 | { | 2627 | { |
2626 | newEvent(fh, | 2628 | newEvent(fh, |
2627 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2629 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2628 | } | 2630 | } |
2629 | 2631 | ||
2630 | void CalendarView::newEvent(QDate dt) | 2632 | void CalendarView::newEvent(QDate dt) |
2631 | { | 2633 | { |
2632 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2634 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2633 | QDateTime(dt, QTime(0,0,0)), true); | 2635 | QDateTime(dt, QTime(0,0,0)), true); |
2634 | } | 2636 | } |
2635 | 2637 | ||
2636 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2638 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2637 | { | 2639 | { |
2638 | 2640 | ||
2639 | showEventEditor(); | 2641 | showEventEditor(); |
2640 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2642 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2641 | if ( mFilterView->filtersEnabled() ) { | 2643 | if ( mFilterView->filtersEnabled() ) { |
2642 | CalFilter *filter = mFilterView->selectedFilter(); | 2644 | CalFilter *filter = mFilterView->selectedFilter(); |
2643 | if (filter && filter->showCategories()) { | 2645 | if (filter && filter->showCategories()) { |
2644 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2646 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2645 | } | 2647 | } |
2646 | if ( filter ) | 2648 | if ( filter ) |
2647 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2649 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2648 | } | 2650 | } |
2649 | } | 2651 | } |
2650 | void CalendarView::todoAdded(Todo * t) | 2652 | void CalendarView::todoAdded(Todo * t) |
2651 | { | 2653 | { |
2652 | 2654 | ||
2653 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2655 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2654 | updateTodoViews(); | 2656 | updateTodoViews(); |
2655 | } | 2657 | } |
2656 | void CalendarView::todoChanged(Todo * t) | 2658 | void CalendarView::todoChanged(Todo * t) |
2657 | { | 2659 | { |
2658 | emit todoModified( t, 4 ); | 2660 | emit todoModified( t, 4 ); |
2659 | // updateTodoViews(); | 2661 | // updateTodoViews(); |
2660 | } | 2662 | } |
2661 | void CalendarView::todoToBeDeleted(Todo *) | 2663 | void CalendarView::todoToBeDeleted(Todo *) |
2662 | { | 2664 | { |
2663 | //qDebug("todoToBeDeleted(Todo *) "); | 2665 | //qDebug("todoToBeDeleted(Todo *) "); |
2664 | updateTodoViews(); | 2666 | updateTodoViews(); |
2665 | } | 2667 | } |
2666 | void CalendarView::todoDeleted() | 2668 | void CalendarView::todoDeleted() |
2667 | { | 2669 | { |
2668 | //qDebug(" todoDeleted()"); | 2670 | //qDebug(" todoDeleted()"); |
2669 | updateTodoViews(); | 2671 | updateTodoViews(); |
2670 | } | 2672 | } |
2671 | 2673 | ||
2672 | 2674 | ||
2673 | 2675 | ||
2674 | void CalendarView::newTodo() | 2676 | void CalendarView::newTodo() |
2675 | { | 2677 | { |
2676 | 2678 | ||
2677 | showTodoEditor(); | 2679 | showTodoEditor(); |
2678 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2680 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2679 | if ( mFilterView->filtersEnabled() ) { | 2681 | if ( mFilterView->filtersEnabled() ) { |
2680 | CalFilter *filter = mFilterView->selectedFilter(); | 2682 | CalFilter *filter = mFilterView->selectedFilter(); |
2681 | if (filter && filter->showCategories()) { | 2683 | if (filter && filter->showCategories()) { |
2682 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2684 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2683 | } | 2685 | } |
2684 | if ( filter ) | 2686 | if ( filter ) |
2685 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2687 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2686 | } | 2688 | } |
2687 | } | 2689 | } |
2688 | 2690 | ||
2689 | void CalendarView::newSubTodo() | 2691 | void CalendarView::newSubTodo() |
2690 | { | 2692 | { |
2691 | Todo *todo = selectedTodo(); | 2693 | Todo *todo = selectedTodo(); |
2692 | if ( todo ) newSubTodo( todo ); | 2694 | if ( todo ) newSubTodo( todo ); |
2693 | } | 2695 | } |
2694 | 2696 | ||
2695 | void CalendarView::newSubTodo(Todo *parentEvent) | 2697 | void CalendarView::newSubTodo(Todo *parentEvent) |
2696 | { | 2698 | { |
2697 | 2699 | ||
2698 | showTodoEditor(); | 2700 | showTodoEditor(); |
2699 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2701 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2700 | } | 2702 | } |
2701 | 2703 | ||
2702 | void CalendarView::newFloatingEvent() | 2704 | void CalendarView::newFloatingEvent() |
2703 | { | 2705 | { |
2704 | DateList tmpList = mNavigator->selectedDates(); | 2706 | DateList tmpList = mNavigator->selectedDates(); |
2705 | QDate date = tmpList.first(); | 2707 | QDate date = tmpList.first(); |
2706 | 2708 | ||
2707 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2709 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2708 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2710 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2709 | } | 2711 | } |
2710 | 2712 | ||
2711 | 2713 | ||
2712 | void CalendarView::editEvent( Event *event ) | 2714 | void CalendarView::editEvent( Event *event ) |
2713 | { | 2715 | { |
2714 | 2716 | ||
2715 | if ( !event ) return; | 2717 | if ( !event ) return; |
2716 | if ( event->isReadOnly() ) { | 2718 | if ( event->isReadOnly() ) { |