-rw-r--r-- | korganizer/calendarview.cpp | 4 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 1 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 2 |
3 files changed, 6 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 2321087..3908dbb 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp | |||
@@ -2258,392 +2258,396 @@ void CalendarView::removeCategories() | |||
2258 | inc->setCategories( newCatList.join(",") ); | 2258 | inc->setCategories( newCatList.join(",") ); |
2259 | inc = incList.next(); | 2259 | inc = incList.next(); |
2260 | } | 2260 | } |
2261 | } | 2261 | } |
2262 | 2262 | ||
2263 | int CalendarView::addCategories() | 2263 | int CalendarView::addCategories() |
2264 | { | 2264 | { |
2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); | 2265 | QPtrList<Incidence> incList = mCalendar->rawIncidences(); |
2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; | 2266 | QStringList catList = KOPrefs::instance()->mCustomCategories; |
2267 | QStringList catIncList; | 2267 | QStringList catIncList; |
2268 | Incidence* inc = incList.first(); | 2268 | Incidence* inc = incList.first(); |
2269 | int i; | 2269 | int i; |
2270 | int count = 0; | 2270 | int count = 0; |
2271 | while ( inc ) { | 2271 | while ( inc ) { |
2272 | catIncList = inc->categories() ; | 2272 | catIncList = inc->categories() ; |
2273 | for( i = 0; i< catIncList.count(); ++i ) { | 2273 | for( i = 0; i< catIncList.count(); ++i ) { |
2274 | if ( !catList.contains (catIncList[i])) { | 2274 | if ( !catList.contains (catIncList[i])) { |
2275 | catList.append( catIncList[i] ); | 2275 | catList.append( catIncList[i] ); |
2276 | //qDebug("add cat %s ", catIncList[i].latin1()); | 2276 | //qDebug("add cat %s ", catIncList[i].latin1()); |
2277 | ++count; | 2277 | ++count; |
2278 | } | 2278 | } |
2279 | } | 2279 | } |
2280 | inc = incList.next(); | 2280 | inc = incList.next(); |
2281 | } | 2281 | } |
2282 | catList.sort(); | 2282 | catList.sort(); |
2283 | KOPrefs::instance()->mCustomCategories = catList; | 2283 | KOPrefs::instance()->mCustomCategories = catList; |
2284 | return count; | 2284 | return count; |
2285 | } | 2285 | } |
2286 | 2286 | ||
2287 | void CalendarView::manageCategories() | 2287 | void CalendarView::manageCategories() |
2288 | { | 2288 | { |
2289 | KOCatPrefs* cp = new KOCatPrefs(); | 2289 | KOCatPrefs* cp = new KOCatPrefs(); |
2290 | cp->show(); | 2290 | cp->show(); |
2291 | int w =cp->sizeHint().width() ; | 2291 | int w =cp->sizeHint().width() ; |
2292 | int h = cp->sizeHint().height() ; | 2292 | int h = cp->sizeHint().height() ; |
2293 | int dw = QApplication::desktop()->width(); | 2293 | int dw = QApplication::desktop()->width(); |
2294 | int dh = QApplication::desktop()->height(); | 2294 | int dh = QApplication::desktop()->height(); |
2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2295 | cp->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2296 | if ( !cp->exec() ) { | 2296 | if ( !cp->exec() ) { |
2297 | delete cp; | 2297 | delete cp; |
2298 | return; | 2298 | return; |
2299 | } | 2299 | } |
2300 | int count = 0; | 2300 | int count = 0; |
2301 | if ( cp->addCat() ) { | 2301 | if ( cp->addCat() ) { |
2302 | count = addCategories(); | 2302 | count = addCategories(); |
2303 | if ( count ) { | 2303 | if ( count ) { |
2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); | 2304 | topLevelWidget()->setCaption(QString::number( count )+ i18n(" Categories added to list! ")); |
2305 | writeSettings(); | 2305 | writeSettings(); |
2306 | } else | 2306 | } else |
2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); | 2307 | topLevelWidget()->setCaption(QString::number( 0 )+ i18n(" Categories added to list! ")); |
2308 | } else { | 2308 | } else { |
2309 | removeCategories(); | 2309 | removeCategories(); |
2310 | updateView(); | 2310 | updateView(); |
2311 | } | 2311 | } |
2312 | delete cp; | 2312 | delete cp; |
2313 | } | 2313 | } |
2314 | 2314 | ||
2315 | void CalendarView::beamIncidence(Incidence * Inc) | 2315 | void CalendarView::beamIncidence(Incidence * Inc) |
2316 | { | 2316 | { |
2317 | QPtrList<Incidence> delSel ; | 2317 | QPtrList<Incidence> delSel ; |
2318 | delSel.append(Inc); | 2318 | delSel.append(Inc); |
2319 | beamIncidenceList( delSel ); | 2319 | beamIncidenceList( delSel ); |
2320 | } | 2320 | } |
2321 | void CalendarView::beamCalendar() | 2321 | void CalendarView::beamCalendar() |
2322 | { | 2322 | { |
2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); | 2323 | QPtrList<Incidence> delSel = mCalendar->rawIncidences(); |
2324 | //qDebug("beamCalendar() "); | 2324 | //qDebug("beamCalendar() "); |
2325 | beamIncidenceList( delSel ); | 2325 | beamIncidenceList( delSel ); |
2326 | } | 2326 | } |
2327 | void CalendarView::beamFilteredCalendar() | 2327 | void CalendarView::beamFilteredCalendar() |
2328 | { | 2328 | { |
2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); | 2329 | QPtrList<Incidence> delSel = mCalendar->incidences(); |
2330 | //qDebug("beamFilteredCalendar() "); | 2330 | //qDebug("beamFilteredCalendar() "); |
2331 | beamIncidenceList( delSel ); | 2331 | beamIncidenceList( delSel ); |
2332 | } | 2332 | } |
2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) | 2333 | void CalendarView::beamIncidenceList(QPtrList<Incidence> delSel ) |
2334 | { | 2334 | { |
2335 | if ( beamDialog->exec () == QDialog::Rejected ) | 2335 | if ( beamDialog->exec () == QDialog::Rejected ) |
2336 | return; | 2336 | return; |
2337 | #ifdef DESKTOP_VERSION | 2337 | #ifdef DESKTOP_VERSION |
2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); | 2338 | QString fn = locateLocal( "tmp", "kopibeamfile" ); |
2339 | #else | 2339 | #else |
2340 | QString fn = "/tmp/kopibeamfile"; | 2340 | QString fn = "/tmp/kopibeamfile"; |
2341 | #endif | 2341 | #endif |
2342 | QString mes; | 2342 | QString mes; |
2343 | bool createbup = true; | 2343 | bool createbup = true; |
2344 | if ( createbup ) { | 2344 | if ( createbup ) { |
2345 | QString description = "\n"; | 2345 | QString description = "\n"; |
2346 | CalendarLocal* cal = new CalendarLocal(); | 2346 | CalendarLocal* cal = new CalendarLocal(); |
2347 | if ( beamDialog->beamLocal() ) | 2347 | if ( beamDialog->beamLocal() ) |
2348 | cal->setLocalTime(); | 2348 | cal->setLocalTime(); |
2349 | else | 2349 | else |
2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 2350 | cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
2351 | Incidence *incidence = delSel.first(); | 2351 | Incidence *incidence = delSel.first(); |
2352 | bool addText = false; | 2352 | bool addText = false; |
2353 | if ( delSel.count() < 10 ) | 2353 | if ( delSel.count() < 10 ) |
2354 | addText = true; | 2354 | addText = true; |
2355 | else { | 2355 | else { |
2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); | 2356 | description.sprintf(i18n(" %d items?"),delSel.count() ); |
2357 | } | 2357 | } |
2358 | while ( incidence ) { | 2358 | while ( incidence ) { |
2359 | Incidence *in = incidence->clone(); | 2359 | Incidence *in = incidence->clone(); |
2360 | if ( ! in->summary().isEmpty() ) { | 2360 | if ( ! in->summary().isEmpty() ) { |
2361 | in->setDescription(""); | 2361 | in->setDescription(""); |
2362 | } else { | 2362 | } else { |
2363 | in->setSummary( in->description().left(20)); | 2363 | in->setSummary( in->description().left(20)); |
2364 | in->setDescription(""); | 2364 | in->setDescription(""); |
2365 | } | 2365 | } |
2366 | if ( addText ) | 2366 | if ( addText ) |
2367 | description += in->summary() + "\n"; | 2367 | description += in->summary() + "\n"; |
2368 | cal->addIncidence( in ); | 2368 | cal->addIncidence( in ); |
2369 | incidence = delSel.next(); | 2369 | incidence = delSel.next(); |
2370 | } | 2370 | } |
2371 | if ( beamDialog->beamVcal() ) { | 2371 | if ( beamDialog->beamVcal() ) { |
2372 | fn += ".vcs"; | 2372 | fn += ".vcs"; |
2373 | FileStorage storage( cal, fn, new VCalFormat ); | 2373 | FileStorage storage( cal, fn, new VCalFormat ); |
2374 | storage.save(); | 2374 | storage.save(); |
2375 | } else { | 2375 | } else { |
2376 | fn += ".ics"; | 2376 | fn += ".ics"; |
2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); | 2377 | FileStorage storage( cal, fn, new ICalFormat( ) ); |
2378 | storage.save(); | 2378 | storage.save(); |
2379 | } | 2379 | } |
2380 | delete cal; | 2380 | delete cal; |
2381 | mes = i18n("KO/Pi: Ready for beaming"); | 2381 | mes = i18n("KO/Pi: Ready for beaming"); |
2382 | topLevelWidget()->setCaption(mes); | 2382 | topLevelWidget()->setCaption(mes); |
2383 | KApplication::convert2latin1( fn ); | 2383 | KApplication::convert2latin1( fn ); |
2384 | #ifndef DESKTOP_VERSION | 2384 | #ifndef DESKTOP_VERSION |
2385 | Ir *ir = new Ir( this ); | 2385 | Ir *ir = new Ir( this ); |
2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 2386 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
2387 | ir->send( fn, description, "text/x-vCalendar" ); | 2387 | ir->send( fn, description, "text/x-vCalendar" ); |
2388 | #endif | 2388 | #endif |
2389 | } | 2389 | } |
2390 | } | 2390 | } |
2391 | void CalendarView::beamDone( Ir *ir ) | 2391 | void CalendarView::beamDone( Ir *ir ) |
2392 | { | 2392 | { |
2393 | #ifndef DESKTOP_VERSION | 2393 | #ifndef DESKTOP_VERSION |
2394 | delete ir; | 2394 | delete ir; |
2395 | #endif | 2395 | #endif |
2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); | 2396 | topLevelWidget()->setCaption( i18n("KO/Pi: Beaming done.") ); |
2397 | topLevelWidget()->raise(); | 2397 | topLevelWidget()->raise(); |
2398 | } | 2398 | } |
2399 | 2399 | ||
2400 | void CalendarView::moveIncidence(Incidence * inc ) | 2400 | void CalendarView::moveIncidence(Incidence * inc ) |
2401 | { | 2401 | { |
2402 | if ( !inc ) return; | 2402 | if ( !inc ) return; |
2403 | // qDebug("showDatePickerForIncidence( ) "); | 2403 | // qDebug("showDatePickerForIncidence( ) "); |
2404 | if ( mDateFrame->isVisible() ) | 2404 | if ( mDateFrame->isVisible() ) |
2405 | mDateFrame->hide(); | 2405 | mDateFrame->hide(); |
2406 | else { | 2406 | else { |
2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; | 2407 | int w =mDatePicker->sizeHint().width()+2*mDateFrame->lineWidth() ; |
2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; | 2408 | int h = mDatePicker->sizeHint().height()+2*mDateFrame->lineWidth() ; |
2409 | int dw = QApplication::desktop()->width(); | 2409 | int dw = QApplication::desktop()->width(); |
2410 | int dh = QApplication::desktop()->height(); | 2410 | int dh = QApplication::desktop()->height(); |
2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2411 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2412 | mDateFrame->show(); | 2412 | mDateFrame->show(); |
2413 | } | 2413 | } |
2414 | mDatePickerMode = 2; | 2414 | mDatePickerMode = 2; |
2415 | mMoveIncidence = inc ; | 2415 | mMoveIncidence = inc ; |
2416 | QDate da; | 2416 | QDate da; |
2417 | if ( mMoveIncidence->type() == "Todo" ) { | 2417 | if ( mMoveIncidence->type() == "Todo" ) { |
2418 | Todo * to = (Todo *) mMoveIncidence; | 2418 | Todo * to = (Todo *) mMoveIncidence; |
2419 | if ( to->hasDueDate() ) | 2419 | if ( to->hasDueDate() ) |
2420 | da = to->dtDue().date(); | 2420 | da = to->dtDue().date(); |
2421 | else | 2421 | else |
2422 | da = QDate::currentDate(); | 2422 | da = QDate::currentDate(); |
2423 | } else { | 2423 | } else { |
2424 | da = mMoveIncidence->dtStart().date(); | 2424 | da = mMoveIncidence->dtStart().date(); |
2425 | } | 2425 | } |
2426 | mDatePicker->setDate( da ); | 2426 | mDatePicker->setDate( da ); |
2427 | } | 2427 | } |
2428 | void CalendarView::showDatePicker( ) | 2428 | void CalendarView::showDatePicker( ) |
2429 | { | 2429 | { |
2430 | //qDebug("CalendarView::showDatePicker( ) "); | 2430 | //qDebug("CalendarView::showDatePicker( ) "); |
2431 | if ( mDateFrame->isVisible() ) | 2431 | if ( mDateFrame->isVisible() ) |
2432 | mDateFrame->hide(); | 2432 | mDateFrame->hide(); |
2433 | else { | 2433 | else { |
2434 | int w =mDatePicker->sizeHint().width() ; | 2434 | int w =mDatePicker->sizeHint().width() ; |
2435 | int h = mDatePicker->sizeHint().height() ; | 2435 | int h = mDatePicker->sizeHint().height() ; |
2436 | int dw = QApplication::desktop()->width(); | 2436 | int dw = QApplication::desktop()->width(); |
2437 | int dh = QApplication::desktop()->height(); | 2437 | int dh = QApplication::desktop()->height(); |
2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 2438 | mDateFrame->setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
2439 | mDateFrame->show(); | 2439 | mDateFrame->show(); |
2440 | } | 2440 | } |
2441 | mDatePickerMode = 1; | 2441 | mDatePickerMode = 1; |
2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); | 2442 | mDatePicker->setDate( mNavigator->selectedDates().first() ); |
2443 | } | 2443 | } |
2444 | 2444 | ||
2445 | void CalendarView::showEventEditor() | 2445 | void CalendarView::showEventEditor() |
2446 | { | 2446 | { |
2447 | #ifdef DESKTOP_VERSION | 2447 | #ifdef DESKTOP_VERSION |
2448 | mEventEditor->show(); | 2448 | mEventEditor->show(); |
2449 | #else | 2449 | #else |
2450 | if ( mEventEditor->width() != QApplication::desktop()->width() ) | ||
2451 | mEventEditor->hide(); | ||
2450 | mEventEditor->showMaximized(); | 2452 | mEventEditor->showMaximized(); |
2451 | #endif | 2453 | #endif |
2452 | } | 2454 | } |
2453 | void CalendarView::showTodoEditor() | 2455 | void CalendarView::showTodoEditor() |
2454 | { | 2456 | { |
2455 | #ifdef DESKTOP_VERSION | 2457 | #ifdef DESKTOP_VERSION |
2456 | mTodoEditor->show(); | 2458 | mTodoEditor->show(); |
2457 | #else | 2459 | #else |
2460 | if ( mTodoEditor->width() != QApplication::desktop()->width() ) | ||
2461 | mTodoEditor->hide(); | ||
2458 | mTodoEditor->showMaximized(); | 2462 | mTodoEditor->showMaximized(); |
2459 | #endif | 2463 | #endif |
2460 | } | 2464 | } |
2461 | 2465 | ||
2462 | void CalendarView::cloneIncidence() | 2466 | void CalendarView::cloneIncidence() |
2463 | { | 2467 | { |
2464 | Incidence *incidence = currentSelection(); | 2468 | Incidence *incidence = currentSelection(); |
2465 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2469 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2466 | if ( incidence ) { | 2470 | if ( incidence ) { |
2467 | cloneIncidence(incidence); | 2471 | cloneIncidence(incidence); |
2468 | } | 2472 | } |
2469 | } | 2473 | } |
2470 | void CalendarView::moveIncidence() | 2474 | void CalendarView::moveIncidence() |
2471 | { | 2475 | { |
2472 | Incidence *incidence = currentSelection(); | 2476 | Incidence *incidence = currentSelection(); |
2473 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2477 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2474 | if ( incidence ) { | 2478 | if ( incidence ) { |
2475 | moveIncidence(incidence); | 2479 | moveIncidence(incidence); |
2476 | } | 2480 | } |
2477 | } | 2481 | } |
2478 | void CalendarView::beamIncidence() | 2482 | void CalendarView::beamIncidence() |
2479 | { | 2483 | { |
2480 | Incidence *incidence = currentSelection(); | 2484 | Incidence *incidence = currentSelection(); |
2481 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2485 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2482 | if ( incidence ) { | 2486 | if ( incidence ) { |
2483 | beamIncidence(incidence); | 2487 | beamIncidence(incidence); |
2484 | } | 2488 | } |
2485 | } | 2489 | } |
2486 | void CalendarView::toggleCancelIncidence() | 2490 | void CalendarView::toggleCancelIncidence() |
2487 | { | 2491 | { |
2488 | Incidence *incidence = currentSelection(); | 2492 | Incidence *incidence = currentSelection(); |
2489 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); | 2493 | if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); |
2490 | if ( incidence ) { | 2494 | if ( incidence ) { |
2491 | cancelIncidence(incidence); | 2495 | cancelIncidence(incidence); |
2492 | } | 2496 | } |
2493 | } | 2497 | } |
2494 | 2498 | ||
2495 | 2499 | ||
2496 | void CalendarView::cancelIncidence(Incidence * inc ) | 2500 | void CalendarView::cancelIncidence(Incidence * inc ) |
2497 | { | 2501 | { |
2498 | inc->setCancelled( ! inc->cancelled() ); | 2502 | inc->setCancelled( ! inc->cancelled() ); |
2499 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); | 2503 | changeIncidenceDisplay( inc,KOGlobals::EVENTEDITED ); |
2500 | updateView(); | 2504 | updateView(); |
2501 | } | 2505 | } |
2502 | void CalendarView::cloneIncidence(Incidence * orgInc ) | 2506 | void CalendarView::cloneIncidence(Incidence * orgInc ) |
2503 | { | 2507 | { |
2504 | Incidence * newInc = orgInc->clone(); | 2508 | Incidence * newInc = orgInc->clone(); |
2505 | newInc->recreate(); | 2509 | newInc->recreate(); |
2506 | 2510 | ||
2507 | if ( newInc->type() == "Todo" ) { | 2511 | if ( newInc->type() == "Todo" ) { |
2508 | Todo* t = (Todo*) newInc; | 2512 | Todo* t = (Todo*) newInc; |
2509 | mTodoEditor->editTodo( t ); | 2513 | mTodoEditor->editTodo( t ); |
2510 | showTodoEditor(); | 2514 | showTodoEditor(); |
2511 | if ( mTodoEditor->exec() ) { | 2515 | if ( mTodoEditor->exec() ) { |
2512 | mCalendar->addTodo( t ); | 2516 | mCalendar->addTodo( t ); |
2513 | updateView(); | 2517 | updateView(); |
2514 | } else { | 2518 | } else { |
2515 | delete t; | 2519 | delete t; |
2516 | } | 2520 | } |
2517 | } | 2521 | } |
2518 | else { | 2522 | else { |
2519 | Event* e = (Event*) newInc; | 2523 | Event* e = (Event*) newInc; |
2520 | mEventEditor->editEvent( e ); | 2524 | mEventEditor->editEvent( e ); |
2521 | showEventEditor(); | 2525 | showEventEditor(); |
2522 | if ( mEventEditor->exec() ) { | 2526 | if ( mEventEditor->exec() ) { |
2523 | mCalendar->addEvent( e ); | 2527 | mCalendar->addEvent( e ); |
2524 | updateView(); | 2528 | updateView(); |
2525 | } else { | 2529 | } else { |
2526 | delete e; | 2530 | delete e; |
2527 | } | 2531 | } |
2528 | } | 2532 | } |
2529 | } | 2533 | } |
2530 | 2534 | ||
2531 | void CalendarView::newEvent() | 2535 | void CalendarView::newEvent() |
2532 | { | 2536 | { |
2533 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. | 2537 | // TODO: Replace this code by a common eventDurationHint of KOBaseView. |
2534 | KOAgendaView *aView = mViewManager->agendaView(); | 2538 | KOAgendaView *aView = mViewManager->agendaView(); |
2535 | if (aView) { | 2539 | if (aView) { |
2536 | if (aView->selectionStart().isValid()) { | 2540 | if (aView->selectionStart().isValid()) { |
2537 | if (aView->selectedIsAllDay()) { | 2541 | if (aView->selectedIsAllDay()) { |
2538 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); | 2542 | newEvent(aView->selectionStart(),aView->selectionEnd(),true); |
2539 | } else { | 2543 | } else { |
2540 | newEvent(aView->selectionStart(),aView->selectionEnd()); | 2544 | newEvent(aView->selectionStart(),aView->selectionEnd()); |
2541 | } | 2545 | } |
2542 | return; | 2546 | return; |
2543 | } | 2547 | } |
2544 | } | 2548 | } |
2545 | 2549 | ||
2546 | QDate date = mNavigator->selectedDates().first(); | 2550 | QDate date = mNavigator->selectedDates().first(); |
2547 | QDateTime current = QDateTime::currentDateTime(); | 2551 | QDateTime current = QDateTime::currentDateTime(); |
2548 | if ( date <= current.date() ) { | 2552 | if ( date <= current.date() ) { |
2549 | int hour = current.time().hour() +1; | 2553 | int hour = current.time().hour() +1; |
2550 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), | 2554 | newEvent( QDateTime( current.date(), QTime( hour, 0, 0 ) ), |
2551 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2555 | QDateTime( current.date(), QTime( hour+ KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2552 | } else | 2556 | } else |
2553 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), | 2557 | newEvent( QDateTime( date, QTime( KOPrefs::instance()->mStartTime, 0, 0 ) ), |
2554 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + | 2558 | QDateTime( date, QTime( KOPrefs::instance()->mStartTime + |
2555 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); | 2559 | KOPrefs::instance()->mDefaultDuration, 0, 0 ) ) ); |
2556 | } | 2560 | } |
2557 | 2561 | ||
2558 | void CalendarView::newEvent(QDateTime fh) | 2562 | void CalendarView::newEvent(QDateTime fh) |
2559 | { | 2563 | { |
2560 | newEvent(fh, | 2564 | newEvent(fh, |
2561 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); | 2565 | QDateTime(fh.addSecs(3600*KOPrefs::instance()->mDefaultDuration))); |
2562 | } | 2566 | } |
2563 | 2567 | ||
2564 | void CalendarView::newEvent(QDate dt) | 2568 | void CalendarView::newEvent(QDate dt) |
2565 | { | 2569 | { |
2566 | newEvent(QDateTime(dt, QTime(0,0,0)), | 2570 | newEvent(QDateTime(dt, QTime(0,0,0)), |
2567 | QDateTime(dt, QTime(0,0,0)), true); | 2571 | QDateTime(dt, QTime(0,0,0)), true); |
2568 | } | 2572 | } |
2569 | 2573 | ||
2570 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) | 2574 | void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) |
2571 | { | 2575 | { |
2572 | 2576 | ||
2573 | mEventEditor->newEvent(fromHint,toHint,allDay); | 2577 | mEventEditor->newEvent(fromHint,toHint,allDay); |
2574 | if ( mFilterView->filtersEnabled() ) { | 2578 | if ( mFilterView->filtersEnabled() ) { |
2575 | CalFilter *filter = mFilterView->selectedFilter(); | 2579 | CalFilter *filter = mFilterView->selectedFilter(); |
2576 | if (filter && filter->showCategories()) { | 2580 | if (filter && filter->showCategories()) { |
2577 | mEventEditor->setCategories(filter->categoryList().join(",") ); | 2581 | mEventEditor->setCategories(filter->categoryList().join(",") ); |
2578 | } | 2582 | } |
2579 | if ( filter ) | 2583 | if ( filter ) |
2580 | mEventEditor->setSecrecy( filter->getSecrecy() ); | 2584 | mEventEditor->setSecrecy( filter->getSecrecy() ); |
2581 | } | 2585 | } |
2582 | showEventEditor(); | 2586 | showEventEditor(); |
2583 | } | 2587 | } |
2584 | void CalendarView::todoAdded(Todo * t) | 2588 | void CalendarView::todoAdded(Todo * t) |
2585 | { | 2589 | { |
2586 | 2590 | ||
2587 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); | 2591 | changeTodoDisplay ( t ,KOGlobals::EVENTADDED); |
2588 | updateTodoViews(); | 2592 | updateTodoViews(); |
2589 | } | 2593 | } |
2590 | void CalendarView::todoChanged(Todo * t) | 2594 | void CalendarView::todoChanged(Todo * t) |
2591 | { | 2595 | { |
2592 | emit todoModified( t, 4 ); | 2596 | emit todoModified( t, 4 ); |
2593 | // updateTodoViews(); | 2597 | // updateTodoViews(); |
2594 | } | 2598 | } |
2595 | void CalendarView::todoToBeDeleted(Todo *) | 2599 | void CalendarView::todoToBeDeleted(Todo *) |
2596 | { | 2600 | { |
2597 | //qDebug("todoToBeDeleted(Todo *) "); | 2601 | //qDebug("todoToBeDeleted(Todo *) "); |
2598 | updateTodoViews(); | 2602 | updateTodoViews(); |
2599 | } | 2603 | } |
2600 | void CalendarView::todoDeleted() | 2604 | void CalendarView::todoDeleted() |
2601 | { | 2605 | { |
2602 | //qDebug(" todoDeleted()"); | 2606 | //qDebug(" todoDeleted()"); |
2603 | updateTodoViews(); | 2607 | updateTodoViews(); |
2604 | } | 2608 | } |
2605 | 2609 | ||
2606 | 2610 | ||
2607 | 2611 | ||
2608 | void CalendarView::newTodo() | 2612 | void CalendarView::newTodo() |
2609 | { | 2613 | { |
2610 | 2614 | ||
2611 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); | 2615 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),0,true); |
2612 | if ( mFilterView->filtersEnabled() ) { | 2616 | if ( mFilterView->filtersEnabled() ) { |
2613 | CalFilter *filter = mFilterView->selectedFilter(); | 2617 | CalFilter *filter = mFilterView->selectedFilter(); |
2614 | if (filter && filter->showCategories()) { | 2618 | if (filter && filter->showCategories()) { |
2615 | mTodoEditor->setCategories(filter->categoryList().join(",") ); | 2619 | mTodoEditor->setCategories(filter->categoryList().join(",") ); |
2616 | } | 2620 | } |
2617 | if ( filter ) | 2621 | if ( filter ) |
2618 | mTodoEditor->setSecrecy( filter->getSecrecy() ); | 2622 | mTodoEditor->setSecrecy( filter->getSecrecy() ); |
2619 | } | 2623 | } |
2620 | showTodoEditor(); | 2624 | showTodoEditor(); |
2621 | } | 2625 | } |
2622 | 2626 | ||
2623 | void CalendarView::newSubTodo() | 2627 | void CalendarView::newSubTodo() |
2624 | { | 2628 | { |
2625 | Todo *todo = selectedTodo(); | 2629 | Todo *todo = selectedTodo(); |
2626 | if ( todo ) newSubTodo( todo ); | 2630 | if ( todo ) newSubTodo( todo ); |
2627 | } | 2631 | } |
2628 | 2632 | ||
2629 | void CalendarView::newSubTodo(Todo *parentEvent) | 2633 | void CalendarView::newSubTodo(Todo *parentEvent) |
2630 | { | 2634 | { |
2631 | 2635 | ||
2632 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); | 2636 | mTodoEditor->newTodo(QDateTime::currentDateTime().addDays(7),parentEvent,true); |
2633 | showTodoEditor(); | 2637 | showTodoEditor(); |
2634 | } | 2638 | } |
2635 | 2639 | ||
2636 | void CalendarView::newFloatingEvent() | 2640 | void CalendarView::newFloatingEvent() |
2637 | { | 2641 | { |
2638 | DateList tmpList = mNavigator->selectedDates(); | 2642 | DateList tmpList = mNavigator->selectedDates(); |
2639 | QDate date = tmpList.first(); | 2643 | QDate date = tmpList.first(); |
2640 | 2644 | ||
2641 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), | 2645 | newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), |
2642 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); | 2646 | QDateTime( date, QTime( 12, 0, 0 ) ), true ); |
2643 | } | 2647 | } |
2644 | 2648 | ||
2645 | 2649 | ||
2646 | void CalendarView::editEvent( Event *event ) | 2650 | void CalendarView::editEvent( Event *event ) |
2647 | { | 2651 | { |
2648 | 2652 | ||
2649 | if ( !event ) return; | 2653 | if ( !event ) return; |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index a12acd1..9cafc60 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -185,384 +185,385 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e) | |||
185 | } | 185 | } |
186 | } | 186 | } |
187 | #endif | 187 | #endif |
188 | } | 188 | } |
189 | 189 | ||
190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) | 190 | void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) |
191 | { | 191 | { |
192 | QListView::contentsMousePressEvent(e); | 192 | QListView::contentsMousePressEvent(e); |
193 | #ifndef KORG_NODND | 193 | #ifndef KORG_NODND |
194 | QPoint p(contentsToViewport(e->pos())); | 194 | QPoint p(contentsToViewport(e->pos())); |
195 | QListViewItem *i = itemAt(p); | 195 | QListViewItem *i = itemAt(p); |
196 | if (i) { | 196 | if (i) { |
197 | // if the user clicked into the root decoration of the item, don't | 197 | // if the user clicked into the root decoration of the item, don't |
198 | // try to start a drag! | 198 | // try to start a drag! |
199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + | 199 | if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + |
200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + | 200 | treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + |
201 | itemMargin() || | 201 | itemMargin() || |
202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { | 202 | p.x() < header()->sectionPos(header()->mapToIndex(0))) { |
203 | if (e->button()==Qt::LeftButton) { | 203 | if (e->button()==Qt::LeftButton) { |
204 | mPressPos = e->pos(); | 204 | mPressPos = e->pos(); |
205 | mMousePressed = true; | 205 | mMousePressed = true; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | #endif | 209 | #endif |
210 | } | 210 | } |
211 | 211 | ||
212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) | 212 | void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) |
213 | { | 213 | { |
214 | 214 | ||
215 | #ifndef KORG_NODND | 215 | #ifndef KORG_NODND |
216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; | 216 | // kdDebug() << "KOTodoListView::contentsMouseMoveEvent()" << endl; |
217 | QListView::contentsMouseMoveEvent(e); | 217 | QListView::contentsMouseMoveEvent(e); |
218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > | 218 | if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > |
219 | QApplication::startDragDistance()) { | 219 | QApplication::startDragDistance()) { |
220 | mMousePressed = false; | 220 | mMousePressed = false; |
221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); | 221 | QListViewItem *item = itemAt(contentsToViewport(mPressPos)); |
222 | if (item) { | 222 | if (item) { |
223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; | 223 | // kdDebug() << "Start Drag for item " << item->text(0) << endl; |
224 | DndFactory factory( mCalendar ); | 224 | DndFactory factory( mCalendar ); |
225 | ICalDrag *vd = factory.createDragTodo( | 225 | ICalDrag *vd = factory.createDragTodo( |
226 | ((KOTodoViewItem *)item)->todo(),viewport()); | 226 | ((KOTodoViewItem *)item)->todo(),viewport()); |
227 | if (vd->drag()) { | 227 | if (vd->drag()) { |
228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; | 228 | kdDebug() << "KOTodoListView::contentsMouseMoveEvent(): Delete drag source" << endl; |
229 | } | 229 | } |
230 | /* | 230 | /* |
231 | QString source = fullPath(item); | 231 | QString source = fullPath(item); |
232 | if ( QFile::exists(source) ) { | 232 | if ( QFile::exists(source) ) { |
233 | QUriDrag* ud = new QUriDrag(viewport()); | 233 | QUriDrag* ud = new QUriDrag(viewport()); |
234 | ud->setFilenames( source ); | 234 | ud->setFilenames( source ); |
235 | if ( ud->drag() ) | 235 | if ( ud->drag() ) |
236 | QMessageBox::information( this, "Drag source", | 236 | QMessageBox::information( this, "Drag source", |
237 | QString("Delete ")+source, "Not implemented" ); | 237 | QString("Delete ")+source, "Not implemented" ); |
238 | */ | 238 | */ |
239 | } | 239 | } |
240 | } | 240 | } |
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) | 243 | void KOTodoListView::keyPressEvent ( QKeyEvent * e ) |
244 | { | 244 | { |
245 | 245 | ||
246 | QListViewItem* cn; | 246 | QListViewItem* cn; |
247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { | 247 | if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { |
248 | cn = currentItem(); | 248 | cn = currentItem(); |
249 | if ( cn ) { | 249 | if ( cn ) { |
250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 250 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
251 | if ( ci ){ | 251 | if ( ci ){ |
252 | if ( e->state() == ShiftButton ) | 252 | if ( e->state() == ShiftButton ) |
253 | ci->setOn( false ); | 253 | ci->setOn( false ); |
254 | else | 254 | else |
255 | ci->setOn( true ); | 255 | ci->setOn( true ); |
256 | cn = cn->nextSibling(); | 256 | cn = cn->nextSibling(); |
257 | if ( cn ) { | 257 | if ( cn ) { |
258 | setCurrentItem ( cn ); | 258 | setCurrentItem ( cn ); |
259 | ensureItemVisible ( cn ); | 259 | ensureItemVisible ( cn ); |
260 | } | 260 | } |
261 | 261 | ||
262 | } | 262 | } |
263 | } | 263 | } |
264 | 264 | ||
265 | return; | 265 | return; |
266 | } | 266 | } |
267 | 267 | ||
268 | // qDebug("KOTodoListView::keyPressEvent "); | 268 | // qDebug("KOTodoListView::keyPressEvent "); |
269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { | 269 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { |
270 | switch ( e->key() ) { | 270 | switch ( e->key() ) { |
271 | case Qt::Key_Down: | 271 | case Qt::Key_Down: |
272 | case Qt::Key_Up: | 272 | case Qt::Key_Up: |
273 | QListView::keyPressEvent ( e ); | 273 | QListView::keyPressEvent ( e ); |
274 | break; | 274 | break; |
275 | case Qt::Key_Left: | 275 | case Qt::Key_Left: |
276 | case Qt::Key_Right: | 276 | case Qt::Key_Right: |
277 | QListView::keyPressEvent ( e ); | 277 | QListView::keyPressEvent ( e ); |
278 | e->accept(); | 278 | e->accept(); |
279 | return; | 279 | return; |
280 | break; | 280 | break; |
281 | default: | 281 | default: |
282 | e->ignore(); | 282 | e->ignore(); |
283 | break; | 283 | break; |
284 | } | 284 | } |
285 | return; | 285 | return; |
286 | } | 286 | } |
287 | e->ignore(); | 287 | e->ignore(); |
288 | } | 288 | } |
289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) | 289 | void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) |
290 | { | 290 | { |
291 | QListView::contentsMouseReleaseEvent(e); | 291 | QListView::contentsMouseReleaseEvent(e); |
292 | mMousePressed = false; | 292 | mMousePressed = false; |
293 | } | 293 | } |
294 | 294 | ||
295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) | 295 | void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) |
296 | { | 296 | { |
297 | if (!e) return; | 297 | if (!e) return; |
298 | 298 | ||
299 | QPoint vp = contentsToViewport(e->pos()); | 299 | QPoint vp = contentsToViewport(e->pos()); |
300 | 300 | ||
301 | QListViewItem *item = itemAt(vp); | 301 | QListViewItem *item = itemAt(vp); |
302 | 302 | ||
303 | emit double_Clicked(item); | 303 | emit double_Clicked(item); |
304 | if (!item) return; | 304 | if (!item) return; |
305 | 305 | ||
306 | emit doubleClicked(item,vp,0); | 306 | emit doubleClicked(item,vp,0); |
307 | } | 307 | } |
308 | 308 | ||
309 | ///////////////////////////////////////////////////////////////////////////// | 309 | ///////////////////////////////////////////////////////////////////////////// |
310 | 310 | ||
311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : | 311 | KOQuickTodo::KOQuickTodo(QWidget *parent) : |
312 | QLineEdit(parent) | 312 | QLineEdit(parent) |
313 | { | 313 | { |
314 | setText(i18n("Click to add a new Todo")); | 314 | setText(i18n("Click to add a new Todo")); |
315 | } | 315 | } |
316 | 316 | ||
317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) | 317 | void KOQuickTodo::focusInEvent(QFocusEvent *ev) |
318 | { | 318 | { |
319 | if ( text()==i18n("Click to add a new Todo") ) | 319 | if ( text()==i18n("Click to add a new Todo") ) |
320 | setText(""); | 320 | setText(""); |
321 | QLineEdit::focusInEvent(ev); | 321 | QLineEdit::focusInEvent(ev); |
322 | } | 322 | } |
323 | 323 | ||
324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) | 324 | void KOQuickTodo::focusOutEvent(QFocusEvent *ev) |
325 | { | 325 | { |
326 | setText(i18n("Click to add a new Todo")); | 326 | setText(i18n("Click to add a new Todo")); |
327 | QLineEdit::focusOutEvent(ev); | 327 | QLineEdit::focusOutEvent(ev); |
328 | } | 328 | } |
329 | 329 | ||
330 | ///////////////////////////////////////////////////////////////////////////// | 330 | ///////////////////////////////////////////////////////////////////////////// |
331 | 331 | ||
332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : | 332 | KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : |
333 | KOrg::BaseView(calendar,parent,name) | 333 | KOrg::BaseView(calendar,parent,name) |
334 | { | 334 | { |
335 | QBoxLayout *topLayout = new QVBoxLayout(this); | 335 | QBoxLayout *topLayout = new QVBoxLayout(this); |
336 | mName = QString ( name ); | 336 | mName = QString ( name ); |
337 | mBlockUpdate = false; | 337 | mBlockUpdate = false; |
338 | mQuickAdd = new KOQuickTodo(this); | 338 | mQuickAdd = new KOQuickTodo(this); |
339 | topLayout->addWidget(mQuickAdd); | 339 | topLayout->addWidget(mQuickAdd); |
340 | 340 | ||
341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); | 341 | if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); |
342 | 342 | ||
343 | mTodoListView = new KOTodoListView(calendar,this, name ); | 343 | mTodoListView = new KOTodoListView(calendar,this, name ); |
344 | topLayout->addWidget(mTodoListView); | 344 | topLayout->addWidget(mTodoListView); |
345 | //mTodoListView->header()->setMaximumHeight(30); | 345 | //mTodoListView->header()->setMaximumHeight(30); |
346 | mTodoListView->setRootIsDecorated(true); | 346 | mTodoListView->setRootIsDecorated(true); |
347 | mTodoListView->setAllColumnsShowFocus(true); | 347 | mTodoListView->setAllColumnsShowFocus(true); |
348 | 348 | ||
349 | mTodoListView->setShowSortIndicator(true); | 349 | mTodoListView->setShowSortIndicator(true); |
350 | 350 | ||
351 | mTodoListView->addColumn(i18n("Todo")); | 351 | mTodoListView->addColumn(i18n("Todo")); |
352 | mTodoListView->addColumn(i18n("Prio")); | 352 | mTodoListView->addColumn(i18n("Prio")); |
353 | mTodoListView->setColumnAlignment(1,AlignHCenter); | 353 | mTodoListView->setColumnAlignment(1,AlignHCenter); |
354 | mTodoListView->addColumn(i18n("Complete")); | 354 | mTodoListView->addColumn(i18n("Complete")); |
355 | mTodoListView->setColumnAlignment(2,AlignHCenter); | 355 | mTodoListView->setColumnAlignment(2,AlignHCenter); |
356 | mTodoListView->addColumn(i18n("Due Date")); | 356 | mTodoListView->addColumn(i18n("Due Date")); |
357 | mTodoListView->setColumnAlignment(3,AlignLeft); | 357 | mTodoListView->setColumnAlignment(3,AlignLeft); |
358 | mTodoListView->addColumn(i18n("Due Time")); | 358 | mTodoListView->addColumn(i18n("Due Time")); |
359 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 359 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
360 | mTodoListView->addColumn(i18n("Cancelled")); | 360 | mTodoListView->addColumn(i18n("Cancelled")); |
361 | mTodoListView->addColumn(i18n("Categories")); | 361 | mTodoListView->addColumn(i18n("Categories")); |
362 | #if 0 | 362 | #if 0 |
363 | mTodoListView->addColumn(i18n("Sort Id")); | 363 | mTodoListView->addColumn(i18n("Sort Id")); |
364 | mTodoListView->setColumnAlignment(4,AlignHCenter); | 364 | mTodoListView->setColumnAlignment(4,AlignHCenter); |
365 | #endif | 365 | #endif |
366 | 366 | ||
367 | mTodoListView->setMinimumHeight( 60 ); | 367 | mTodoListView->setMinimumHeight( 60 ); |
368 | mTodoListView->setItemsRenameable( true ); | 368 | mTodoListView->setItemsRenameable( true ); |
369 | mTodoListView->setRenameable( 0 ); | 369 | mTodoListView->setRenameable( 0 ); |
370 | mTodoListView->setColumnWidth( 0, 120 ); | 370 | mTodoListView->setColumnWidth( 0, 120 ); |
371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); | 371 | mTodoListView->setColumnWidthMode(0, QListView::Manual); |
372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); | 372 | mTodoListView->setColumnWidthMode(1, QListView::Manual); |
373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); | 373 | mTodoListView->setColumnWidthMode(2, QListView::Manual); |
374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); | 374 | mTodoListView->setColumnWidthMode(3, QListView::Manual); |
375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); | 375 | mTodoListView->setColumnWidthMode(4, QListView::Manual); |
376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); | 376 | mTodoListView->setColumnWidthMode(5, QListView::Manual); |
377 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | ||
377 | mTodoListView->setColumnAlignment( 2, AlignCenter ); | 378 | mTodoListView->setColumnAlignment( 2, AlignCenter ); |
378 | #if 0 | 379 | #if 0 |
379 | mTodoListView->setColumnWidthMode(6, QListView::Manual); | 380 | mTodoListView->setColumnWidthMode(6, QListView::Manual); |
380 | #endif | 381 | #endif |
381 | 382 | ||
382 | mPriorityPopupMenu = new QPopupMenu(this); | 383 | mPriorityPopupMenu = new QPopupMenu(this); |
383 | for (int i = 1; i <= 5; i++) { | 384 | for (int i = 1; i <= 5; i++) { |
384 | QString label = QString ("%1").arg (i); | 385 | QString label = QString ("%1").arg (i); |
385 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; | 386 | mPriority[mPriorityPopupMenu->insertItem (label)] = i; |
386 | } | 387 | } |
387 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); | 388 | connect (mPriorityPopupMenu, SIGNAL(activated (int)), SLOT (setNewPriority(int))); |
388 | 389 | ||
389 | mPercentageCompletedPopupMenu = new QPopupMenu(this); | 390 | mPercentageCompletedPopupMenu = new QPopupMenu(this); |
390 | for (int i = 0; i <= 100; i+=20) { | 391 | for (int i = 0; i <= 100; i+=20) { |
391 | QString label = QString ("%1 %").arg (i); | 392 | QString label = QString ("%1 %").arg (i); |
392 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; | 393 | mPercentage[mPercentageCompletedPopupMenu->insertItem (label)] = i; |
393 | } | 394 | } |
394 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); | 395 | connect (mPercentageCompletedPopupMenu, SIGNAL (activated (int)), SLOT (setNewPercentage (int))); |
395 | 396 | ||
396 | 397 | ||
397 | 398 | ||
398 | mItemPopupMenu = new QPopupMenu(this); | 399 | mItemPopupMenu = new QPopupMenu(this); |
399 | mItemPopupMenu->insertItem(i18n("Show..."), this, | 400 | mItemPopupMenu->insertItem(i18n("Show..."), this, |
400 | SLOT (showTodo())); | 401 | SLOT (showTodo())); |
401 | mItemPopupMenu->insertItem(i18n("Edit..."), this, | 402 | mItemPopupMenu->insertItem(i18n("Edit..."), this, |
402 | SLOT (editTodo())); | 403 | SLOT (editTodo())); |
403 | mItemPopupMenu->insertItem( i18n("Delete"), this, | 404 | mItemPopupMenu->insertItem( i18n("Delete"), this, |
404 | SLOT (deleteTodo())); | 405 | SLOT (deleteTodo())); |
405 | mItemPopupMenu->insertItem( i18n("Clone..."), this, | 406 | mItemPopupMenu->insertItem( i18n("Clone..."), this, |
406 | SLOT (cloneTodo())); | 407 | SLOT (cloneTodo())); |
407 | mItemPopupMenu->insertItem( i18n("Move..."), this, | 408 | mItemPopupMenu->insertItem( i18n("Move..."), this, |
408 | SLOT (moveTodo())); | 409 | SLOT (moveTodo())); |
409 | mItemPopupMenu->insertItem( i18n("Beam..."), this, | 410 | mItemPopupMenu->insertItem( i18n("Beam..."), this, |
410 | SLOT (beamTodo())); | 411 | SLOT (beamTodo())); |
411 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, | 412 | mItemPopupMenu->insertItem( i18n("Toggle Cancel"), this, |
412 | SLOT (cancelTodo())); | 413 | SLOT (cancelTodo())); |
413 | mItemPopupMenu->insertSeparator(); | 414 | mItemPopupMenu->insertSeparator(); |
414 | 415 | ||
415 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, | 416 | mItemPopupMenu->insertItem( i18n("New Todo..."), this, |
416 | SLOT (newTodo())); | 417 | SLOT (newTodo())); |
417 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, | 418 | mItemPopupMenu->insertItem(i18n("New Sub-Todo..."), this, |
418 | SLOT (newSubTodo())); | 419 | SLOT (newSubTodo())); |
419 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, | 420 | mItemPopupMenu->insertItem(i18n("Unparent Todo"), this, |
420 | SLOT (unparentTodo()),0,21); | 421 | SLOT (unparentTodo()),0,21); |
421 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, | 422 | mItemPopupMenu->insertItem(i18n("Reparent Todo"), this, |
422 | SLOT (reparentTodo()),0,22); | 423 | SLOT (reparentTodo()),0,22); |
423 | mItemPopupMenu->insertSeparator(); | 424 | mItemPopupMenu->insertSeparator(); |
424 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), | 425 | mItemPopupMenu->insertItem(i18n("Delete completed To-Dos","Purge Completed"), |
425 | this, SLOT( purgeCompleted() ) ); | 426 | this, SLOT( purgeCompleted() ) ); |
426 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), | 427 | mItemPopupMenu->insertItem(i18n("toggle completed To-Dos","Show Completed"), |
427 | this, SLOT( toggleCompleted() ),0, 33 ); | 428 | this, SLOT( toggleCompleted() ),0, 33 ); |
428 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 429 | mItemPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
429 | this, SLOT( toggleQuickTodo() ),0, 34 ); | 430 | this, SLOT( toggleQuickTodo() ),0, 34 ); |
430 | 431 | ||
431 | mPopupMenu = new QPopupMenu(this); | 432 | mPopupMenu = new QPopupMenu(this); |
432 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, | 433 | mPopupMenu->insertItem(SmallIconSet("todo"), i18n("New Todo..."), this, |
433 | SLOT (newTodo()),0,1); | 434 | SLOT (newTodo()),0,1); |
434 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), | 435 | mPopupMenu->insertItem(i18n("delete completed To-Dos","Purge Completed"), |
435 | this, SLOT(purgeCompleted()),0,2); | 436 | this, SLOT(purgeCompleted()),0,2); |
436 | mPopupMenu->insertItem(i18n("Show Completed"), | 437 | mPopupMenu->insertItem(i18n("Show Completed"), |
437 | this, SLOT( toggleCompleted() ),0,3 ); | 438 | this, SLOT( toggleCompleted() ),0,3 ); |
438 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), | 439 | mPopupMenu->insertItem(i18n("toggle quick todo","Show Quick Todo"), |
439 | this, SLOT( toggleQuickTodo() ),0,4 ); | 440 | this, SLOT( toggleQuickTodo() ),0,4 ); |
440 | mDocPrefs = new DocPrefs( name ); | 441 | mDocPrefs = new DocPrefs( name ); |
441 | 442 | ||
442 | mPopupMenu->setCheckable( true ); | 443 | mPopupMenu->setCheckable( true ); |
443 | mItemPopupMenu->setCheckable( true ); | 444 | mItemPopupMenu->setCheckable( true ); |
444 | // Double clicking conflicts with opening/closing the subtree | 445 | // Double clicking conflicts with opening/closing the subtree |
445 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), | 446 | connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), |
446 | SLOT( editItem( QListViewItem *) ) ); | 447 | SLOT( editItem( QListViewItem *) ) ); |
447 | /* | 448 | /* |
448 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, | 449 | connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, |
449 | const QPoint &,int ) ), | 450 | const QPoint &,int ) ), |
450 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 451 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
451 | */ | 452 | */ |
452 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, | 453 | connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, |
453 | const QPoint &,int ) ), | 454 | const QPoint &,int ) ), |
454 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); | 455 | SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); |
455 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), | 456 | connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), |
456 | SLOT( itemClicked( QListViewItem * ) ) ); | 457 | SLOT( itemClicked( QListViewItem * ) ) ); |
457 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), | 458 | connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), |
458 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); | 459 | SLOT( itemDoubleClicked( QListViewItem * ) ) ); |
459 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), | 460 | connect( mTodoListView, SIGNAL( todoDropped( Todo * ) ), |
460 | SLOT( updateView() ) ); | 461 | SLOT( updateView() ) ); |
461 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), | 462 | connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), |
462 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 463 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
463 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), | 464 | connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), |
464 | SLOT( itemStateChanged( QListViewItem * ) ) ); | 465 | SLOT( itemStateChanged( QListViewItem * ) ) ); |
465 | 466 | ||
466 | #if 0 | 467 | #if 0 |
467 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), | 468 | connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), |
468 | SLOT(selectionChanged(QListViewItem *))); | 469 | SLOT(selectionChanged(QListViewItem *))); |
469 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), | 470 | connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), |
470 | SLOT(selectionChanged(QListViewItem *))); | 471 | SLOT(selectionChanged(QListViewItem *))); |
471 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), | 472 | connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), |
472 | SLOT(selectionChanged(QListViewItem *))); | 473 | SLOT(selectionChanged(QListViewItem *))); |
473 | #endif | 474 | #endif |
474 | connect( mTodoListView, SIGNAL(selectionChanged() ), | 475 | connect( mTodoListView, SIGNAL(selectionChanged() ), |
475 | SLOT( processSelectionChange() ) ); | 476 | SLOT( processSelectionChange() ) ); |
476 | connect( mQuickAdd, SIGNAL( returnPressed () ), | 477 | connect( mQuickAdd, SIGNAL( returnPressed () ), |
477 | SLOT( addQuickTodo() ) ); | 478 | SLOT( addQuickTodo() ) ); |
478 | // if ( QApplication::desktop()->width() < 480 ) { | 479 | // if ( QApplication::desktop()->width() < 480 ) { |
479 | // setNarrow(); | 480 | // setNarrow(); |
480 | // mTodoListView->setColumnWidth( 0, 100 ); | 481 | // mTodoListView->setColumnWidth( 0, 100 ); |
481 | 482 | ||
482 | // } | 483 | // } |
483 | 484 | ||
484 | } | 485 | } |
485 | 486 | ||
486 | KOTodoView::~KOTodoView() | 487 | KOTodoView::~KOTodoView() |
487 | { | 488 | { |
488 | delete mDocPrefs; | 489 | delete mDocPrefs; |
489 | } | 490 | } |
490 | 491 | ||
491 | void KOTodoView::jumpToDate () | 492 | void KOTodoView::jumpToDate () |
492 | { | 493 | { |
493 | // if (mActiveItem) { | 494 | // if (mActiveItem) { |
494 | // mActiveItem->todo()); | 495 | // mActiveItem->todo()); |
495 | // if ( mActiveItem->todo()->hasDueDate() ) | 496 | // if ( mActiveItem->todo()->hasDueDate() ) |
496 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); | 497 | // emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); |
497 | } | 498 | } |
498 | 499 | ||
499 | void KOTodoView::setNarrow() | 500 | void KOTodoView::setNarrow() |
500 | { | 501 | { |
501 | //mTodoListView->setColumnWidth( 0, 120 ); | 502 | //mTodoListView->setColumnWidth( 0, 120 ); |
502 | mTodoListView->setColumnWidth( 1, 35 ); | 503 | mTodoListView->setColumnWidth( 1, 35 ); |
503 | mTodoListView->setColumnWidth( 2, 40 ); | 504 | mTodoListView->setColumnWidth( 2, 40 ); |
504 | mTodoListView->setColumnWidth( 3, 80 ); | 505 | mTodoListView->setColumnWidth( 3, 80 ); |
505 | mTodoListView->setColumnWidth( 4, 40 ); | 506 | mTodoListView->setColumnWidth( 4, 40 ); |
506 | mTodoListView->setColumnWidth( 5, 90 ); | 507 | mTodoListView->setColumnWidth( 5, 90 ); |
507 | 508 | ||
508 | } | 509 | } |
509 | void KOTodoView::updateView() | 510 | void KOTodoView::updateView() |
510 | { | 511 | { |
511 | pendingSubtodo = 0; | 512 | pendingSubtodo = 0; |
512 | if ( mBlockUpdate ) { | 513 | if ( mBlockUpdate ) { |
513 | //qDebug("blocked "); | 514 | //qDebug("blocked "); |
514 | return; | 515 | return; |
515 | } | 516 | } |
516 | //qDebug("update "); | 517 | //qDebug("update "); |
517 | // kdDebug() << "KOTodoView::updateView()" << endl; | 518 | // kdDebug() << "KOTodoView::updateView()" << endl; |
518 | QFont fo = KOPrefs::instance()->mTodoViewFont; | 519 | QFont fo = KOPrefs::instance()->mTodoViewFont; |
519 | mTodoListView->clear(); | 520 | mTodoListView->clear(); |
520 | if ( mName == "todolistsmall" ) { | 521 | if ( mName == "todolistsmall" ) { |
521 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { | 522 | if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { |
522 | int ps = fo.pointSize() -2; | 523 | int ps = fo.pointSize() -2; |
523 | if ( ps > 12 ) | 524 | if ( ps > 12 ) |
524 | ps -= 2; | 525 | ps -= 2; |
525 | fo.setPointSize( ps ); | 526 | fo.setPointSize( ps ); |
526 | } | 527 | } |
527 | } | 528 | } |
528 | 529 | ||
529 | mTodoListView->setFont( fo ); | 530 | mTodoListView->setFont( fo ); |
530 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); | 531 | // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); |
531 | //mTodoListView->header()->setMaximumHeight(fm.height()); | 532 | //mTodoListView->header()->setMaximumHeight(fm.height()); |
532 | QPtrList<Todo> todoList = calendar()->todos(); | 533 | QPtrList<Todo> todoList = calendar()->todos(); |
533 | 534 | ||
534 | /* | 535 | /* |
535 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; | 536 | kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; |
536 | Event *t; | 537 | Event *t; |
537 | for(t = todoList.first(); t; t = todoList.next()) { | 538 | for(t = todoList.first(); t; t = todoList.next()) { |
538 | kdDebug() << " " << t->getSummary() << endl; | 539 | kdDebug() << " " << t->getSummary() << endl; |
539 | 540 | ||
540 | if (t->getRelatedTo()) { | 541 | if (t->getRelatedTo()) { |
541 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; | 542 | kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; |
542 | } | 543 | } |
543 | 544 | ||
544 | QPtrList<Event> l = t->getRelations(); | 545 | QPtrList<Event> l = t->getRelations(); |
545 | Event *c; | 546 | Event *c; |
546 | for(c=l.first();c;c=l.next()) { | 547 | for(c=l.first();c;c=l.next()) { |
547 | kdDebug() << " - relation: " << c->getSummary() << endl; | 548 | kdDebug() << " - relation: " << c->getSummary() << endl; |
548 | } | 549 | } |
549 | } | 550 | } |
550 | */ | 551 | */ |
551 | 552 | ||
552 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a | 553 | // Put for each Event a KOTodoViewItem in the list view. Don't rely on a |
553 | // specific order of events. That means that we have to generate parent items | 554 | // specific order of events. That means that we have to generate parent items |
554 | // recursively for proper hierarchical display of Todos. | 555 | // recursively for proper hierarchical display of Todos. |
555 | mTodoMap.clear(); | 556 | mTodoMap.clear(); |
556 | Todo *todo; | 557 | Todo *todo; |
557 | todo = todoList.first();// todo; todo = todoList.next()) { | 558 | todo = todoList.first();// todo; todo = todoList.next()) { |
558 | while ( todo ) { | 559 | while ( todo ) { |
559 | bool next = true; | 560 | bool next = true; |
560 | // qDebug("todo %s ", todo->summary().latin1()); | 561 | // qDebug("todo %s ", todo->summary().latin1()); |
561 | Incidence *incidence = todo->relatedTo(); | 562 | Incidence *incidence = todo->relatedTo(); |
562 | while ( incidence ) { | 563 | while ( incidence ) { |
563 | if ( incidence->type() == "Todo") { | 564 | if ( incidence->type() == "Todo") { |
564 | //qDebug("related %s ",incidence->summary().latin1() ); | 565 | //qDebug("related %s ",incidence->summary().latin1() ); |
565 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { | 566 | if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { |
566 | //qDebug("related not found "); | 567 | //qDebug("related not found "); |
567 | todoList.remove( ); | 568 | todoList.remove( ); |
568 | todo = todoList.current(); | 569 | todo = todoList.current(); |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 85647b1..ae0b334 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -1,237 +1,237 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <klocale.h> | 20 | #include <klocale.h> |
21 | #include <kdebug.h> | 21 | #include <kdebug.h> |
22 | #include <qapp.h> | 22 | #include <qapp.h> |
23 | 23 | ||
24 | #include <kiconloader.h> | 24 | #include <kiconloader.h> |
25 | #include "kotodoviewitem.h" | 25 | #include "kotodoviewitem.h" |
26 | #include "kotodoview.h" | 26 | #include "kotodoview.h" |
27 | #include "koprefs.h" | 27 | #include "koprefs.h" |
28 | 28 | ||
29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) | 29 | KOTodoViewItem::KOTodoViewItem( QListView *parent, Todo *todo, KOTodoView *kotodo) |
30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 30 | : QCheckListItem( parent , "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
31 | { | 31 | { |
32 | construct(); | 32 | construct(); |
33 | } | 33 | } |
34 | 34 | ||
35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) | 35 | KOTodoViewItem::KOTodoViewItem( KOTodoViewItem *parent, Todo *todo, KOTodoView *kotodo ) |
36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) | 36 | : QCheckListItem( parent, "", CheckBox ), mTodo( todo ), mTodoView( kotodo ) |
37 | { | 37 | { |
38 | construct(); | 38 | construct(); |
39 | } | 39 | } |
40 | 40 | ||
41 | QString KOTodoViewItem::key(int column,bool) const | 41 | QString KOTodoViewItem::key(int column,bool) const |
42 | { | 42 | { |
43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); | 43 | QMap<int,QString>::ConstIterator it = mKeyMap.find(column); |
44 | if (it == mKeyMap.end()) { | 44 | if (it == mKeyMap.end()) { |
45 | return text(column); | 45 | return text(column).lower(); |
46 | } else { | 46 | } else { |
47 | return *it; | 47 | return *it; |
48 | } | 48 | } |
49 | } | 49 | } |
50 | 50 | ||
51 | void KOTodoViewItem:: setup() | 51 | void KOTodoViewItem:: setup() |
52 | { | 52 | { |
53 | 53 | ||
54 | int h = 20; | 54 | int h = 20; |
55 | if ( listView () ) { | 55 | if ( listView () ) { |
56 | QFontMetrics fm ( listView ()->font () ); | 56 | QFontMetrics fm ( listView ()->font () ); |
57 | h = fm.height(); | 57 | h = fm.height(); |
58 | } | 58 | } |
59 | setHeight( h ); | 59 | setHeight( h ); |
60 | 60 | ||
61 | } | 61 | } |
62 | void KOTodoViewItem::setSortKey(int column,const QString &key) | 62 | void KOTodoViewItem::setSortKey(int column,const QString &key) |
63 | { | 63 | { |
64 | mKeyMap.insert(column,key); | 64 | mKeyMap.insert(column,key); |
65 | } | 65 | } |
66 | 66 | ||
67 | #if QT_VERSION >= 300 | 67 | #if QT_VERSION >= 300 |
68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, | 68 | void KOTodoViewItem::paintBranches(QPainter *p,const QColorGroup & cg,int w, |
69 | int y,int h) | 69 | int y,int h) |
70 | { | 70 | { |
71 | QListViewItem::paintBranches(p,cg,w,y,h); | 71 | QListViewItem::paintBranches(p,cg,w,y,h); |
72 | } | 72 | } |
73 | #else | 73 | #else |
74 | #endif | 74 | #endif |
75 | 75 | ||
76 | void KOTodoViewItem::construct() | 76 | void KOTodoViewItem::construct() |
77 | { | 77 | { |
78 | // qDebug("KOTodoViewItem::construct() "); | 78 | // qDebug("KOTodoViewItem::construct() "); |
79 | m_init = true; | 79 | m_init = true; |
80 | QString keyd = "=="; | 80 | QString keyd = "=="; |
81 | QString keyt = "=="; | 81 | QString keyt = "=="; |
82 | 82 | ||
83 | setOn(mTodo->isCompleted()); | 83 | setOn(mTodo->isCompleted()); |
84 | setText(0,mTodo->summary()); | 84 | setText(0,mTodo->summary()); |
85 | setText(1,QString::number(mTodo->priority())); | 85 | setText(1,QString::number(mTodo->priority())); |
86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 86 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
87 | if (mTodo->percentComplete()<100) { | 87 | if (mTodo->percentComplete()<100) { |
88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 88 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
89 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 89 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
90 | } | 90 | } |
91 | else { | 91 | else { |
92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 92 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
93 | else setSortKey(2,QString::number(99)); | 93 | else setSortKey(2,QString::number(99)); |
94 | } | 94 | } |
95 | if (mTodo->hasDueDate()) { | 95 | if (mTodo->hasDueDate()) { |
96 | setText(3, mTodo->dtDueDateStr()); | 96 | setText(3, mTodo->dtDueDateStr()); |
97 | QDate d = mTodo->dtDue().date(); | 97 | QDate d = mTodo->dtDue().date(); |
98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 98 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
99 | setSortKey(3,keyd); | 99 | setSortKey(3,keyd); |
100 | if (mTodo->doesFloat()) { | 100 | if (mTodo->doesFloat()) { |
101 | setText(4,""); | 101 | setText(4,""); |
102 | } | 102 | } |
103 | else { | 103 | else { |
104 | setText(4,mTodo->dtDueTimeStr()); | 104 | setText(4,mTodo->dtDueTimeStr()); |
105 | QTime t = mTodo->dtDue().time(); | 105 | QTime t = mTodo->dtDue().time(); |
106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 106 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
107 | setSortKey(4,keyt); | 107 | setSortKey(4,keyt); |
108 | } | 108 | } |
109 | } else { | 109 | } else { |
110 | setText(3,""); | 110 | setText(3,""); |
111 | setText(4,""); | 111 | setText(4,""); |
112 | } | 112 | } |
113 | setSortKey(3,keyd); | 113 | setSortKey(3,keyd); |
114 | setSortKey(4,keyt); | 114 | setSortKey(4,keyt); |
115 | 115 | ||
116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); | 116 | if (mTodo->isCompleted()) setSortKey(1,"6" + QString::number(mTodo->priority())+keyd+keyt); |
117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 117 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
118 | 118 | ||
119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); | 119 | setText(5,mTodo->cancelled() ? i18n("Yes") : i18n("No")); |
120 | setText(6,mTodo->categoriesStr()); | 120 | setText(6,mTodo->categoriesStr()); |
121 | 121 | ||
122 | #if 0 | 122 | #if 0 |
123 | // Find sort id in description. It's the text behind the last '#' character | 123 | // Find sort id in description. It's the text behind the last '#' character |
124 | // found in the description. White spaces are removed from beginning and end | 124 | // found in the description. White spaces are removed from beginning and end |
125 | // of sort id. | 125 | // of sort id. |
126 | int pos = mTodo->description().findRev('#'); | 126 | int pos = mTodo->description().findRev('#'); |
127 | if (pos < 0) { | 127 | if (pos < 0) { |
128 | setText(6,""); | 128 | setText(6,""); |
129 | } else { | 129 | } else { |
130 | QString str = mTodo->description().mid(pos+1); | 130 | QString str = mTodo->description().mid(pos+1); |
131 | str.stripWhiteSpace(); | 131 | str.stripWhiteSpace(); |
132 | setText(6,str); | 132 | setText(6,str); |
133 | } | 133 | } |
134 | #endif | 134 | #endif |
135 | 135 | ||
136 | m_known = false; | 136 | m_known = false; |
137 | m_init = false; | 137 | m_init = false; |
138 | 138 | ||
139 | setMyPixmap(); | 139 | setMyPixmap(); |
140 | 140 | ||
141 | } | 141 | } |
142 | void KOTodoViewItem::setMyPixmap() | 142 | void KOTodoViewItem::setMyPixmap() |
143 | { | 143 | { |
144 | int size = 5; | 144 | int size = 5; |
145 | QPixmap pixi = QPixmap( 1, 1 ); | 145 | QPixmap pixi = QPixmap( 1, 1 ); |
146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 146 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
147 | // pixi = SmallIcon("redcross16"); | 147 | // pixi = SmallIcon("redcross16"); |
148 | // } else { | 148 | // } else { |
149 | QPainter p; | 149 | QPainter p; |
150 | 150 | ||
151 | int pixSize = 0; | 151 | int pixSize = 0; |
152 | QPixmap pPix = QPixmap( size, size ); | 152 | QPixmap pPix = QPixmap( size, size ); |
153 | if ( mTodo->description().length() > 0 ) { | 153 | if ( mTodo->description().length() > 0 ) { |
154 | pixi.resize(size, pixSize+size); | 154 | pixi.resize(size, pixSize+size); |
155 | pPix.fill( Qt::darkGreen ); | 155 | pPix.fill( Qt::darkGreen ); |
156 | p.begin( &pixi ); | 156 | p.begin( &pixi ); |
157 | p. drawPixmap ( 0, pixSize, pPix); | 157 | p. drawPixmap ( 0, pixSize, pPix); |
158 | p.end(); | 158 | p.end(); |
159 | pixSize += size; | 159 | pixSize += size; |
160 | } | 160 | } |
161 | if ( mTodo->isAlarmEnabled() ) { | 161 | if ( mTodo->isAlarmEnabled() ) { |
162 | pixi.resize(size, pixSize+size); | 162 | pixi.resize(size, pixSize+size); |
163 | pPix.fill( Qt::red ); | 163 | pPix.fill( Qt::red ); |
164 | p.begin( &pixi ); | 164 | p.begin( &pixi ); |
165 | p. drawPixmap ( 0, pixSize, pPix); | 165 | p. drawPixmap ( 0, pixSize, pPix); |
166 | p.end(); | 166 | p.end(); |
167 | pixSize += size; | 167 | pixSize += size; |
168 | } | 168 | } |
169 | // } | 169 | // } |
170 | if ( pixi.width() > 1 ) { | 170 | if ( pixi.width() > 1 ) { |
171 | setPixmap ( 0,pixi ) ; | 171 | setPixmap ( 0,pixi ) ; |
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | } | 175 | } |
176 | void KOTodoViewItem::stateChange(bool state) | 176 | void KOTodoViewItem::stateChange(bool state) |
177 | { | 177 | { |
178 | // qDebug("KOTodoViewItem::stateChange "); | 178 | // qDebug("KOTodoViewItem::stateChange "); |
179 | // do not change setting on startup | 179 | // do not change setting on startup |
180 | if ( m_init ) return; | 180 | if ( m_init ) return; |
181 | 181 | ||
182 | kdDebug() << "State changed, modified " << state << endl; | 182 | kdDebug() << "State changed, modified " << state << endl; |
183 | QString keyd = "=="; | 183 | QString keyd = "=="; |
184 | QString keyt = "=="; | 184 | QString keyt = "=="; |
185 | 185 | ||
186 | if (state) mTodo->setCompleted(state); | 186 | if (state) mTodo->setCompleted(state); |
187 | else mTodo->setPercentComplete(0); | 187 | else mTodo->setPercentComplete(0); |
188 | if (isOn()!=state) { | 188 | if (isOn()!=state) { |
189 | setOn(state); | 189 | setOn(state); |
190 | } | 190 | } |
191 | 191 | ||
192 | if (mTodo->hasDueDate()) { | 192 | if (mTodo->hasDueDate()) { |
193 | setText(3, mTodo->dtDueDateStr()); | 193 | setText(3, mTodo->dtDueDateStr()); |
194 | QDate d = mTodo->dtDue().date(); | 194 | QDate d = mTodo->dtDue().date(); |
195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 195 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
196 | setSortKey(3,keyd); | 196 | setSortKey(3,keyd); |
197 | if (mTodo->doesFloat()) { | 197 | if (mTodo->doesFloat()) { |
198 | setText(4,""); | 198 | setText(4,""); |
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | setText(4,mTodo->dtDueTimeStr()); | 201 | setText(4,mTodo->dtDueTimeStr()); |
202 | QTime t = mTodo->dtDue().time(); | 202 | QTime t = mTodo->dtDue().time(); |
203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 203 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
204 | setSortKey(4,keyt); | 204 | setSortKey(4,keyt); |
205 | } | 205 | } |
206 | } | 206 | } |
207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 207 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 208 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
209 | 209 | ||
210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 210 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
211 | if (mTodo->percentComplete()<100) { | 211 | if (mTodo->percentComplete()<100) { |
212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 212 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
213 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 213 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
214 | } | 214 | } |
215 | else { | 215 | else { |
216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 216 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
217 | else setSortKey(2,QString::number(99)); | 217 | else setSortKey(2,QString::number(99)); |
218 | } | 218 | } |
219 | QListViewItem * myChild = firstChild(); | 219 | QListViewItem * myChild = firstChild(); |
220 | KOTodoViewItem *item; | 220 | KOTodoViewItem *item; |
221 | while( myChild ) { | 221 | while( myChild ) { |
222 | item = static_cast<KOTodoViewItem*>(myChild); | 222 | item = static_cast<KOTodoViewItem*>(myChild); |
223 | item->stateChange(state); | 223 | item->stateChange(state); |
224 | myChild = myChild->nextSibling(); | 224 | myChild = myChild->nextSibling(); |
225 | } | 225 | } |
226 | mTodoView->modified(true); | 226 | mTodoView->modified(true); |
227 | mTodoView->setTodoModified( mTodo ); | 227 | mTodoView->setTodoModified( mTodo ); |
228 | setMyPixmap(); | 228 | setMyPixmap(); |
229 | } | 229 | } |
230 | 230 | ||
231 | bool KOTodoViewItem::isAlternate() | 231 | bool KOTodoViewItem::isAlternate() |
232 | { | 232 | { |
233 | #ifndef KORG_NOLVALTERNATION | 233 | #ifndef KORG_NOLVALTERNATION |
234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); | 234 | KOTodoListView *lv = static_cast<KOTodoListView *>(listView()); |
235 | if (lv && lv->alternateBackground().isValid()) | 235 | if (lv && lv->alternateBackground().isValid()) |
236 | { | 236 | { |
237 | KOTodoViewItem *above = 0; | 237 | KOTodoViewItem *above = 0; |