-rw-r--r-- | korganizer/kolistview.cpp | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index bbf83d9..fd86095 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -350,50 +350,48 @@ QString KOListView::getWhatsThisText(QPoint p) | |||
350 | KOPrefs::instance()->mWTshowChanged); | 350 | KOPrefs::instance()->mWTshowChanged); |
351 | return i18n("That is the list view" ); | 351 | return i18n("That is the list view" ); |
352 | 352 | ||
353 | } | 353 | } |
354 | 354 | ||
355 | void KOListView::updateList() | 355 | void KOListView::updateList() |
356 | { | 356 | { |
357 | // qDebug(" KOListView::updateList() "); | 357 | // qDebug(" KOListView::updateList() "); |
358 | 358 | ||
359 | } | 359 | } |
360 | 360 | ||
361 | void KOListView::addCat( ) | 361 | void KOListView::addCat( ) |
362 | { | 362 | { |
363 | setCategories( false ); | 363 | setCategories( false ); |
364 | } | 364 | } |
365 | void KOListView::setCat() | 365 | void KOListView::setCat() |
366 | { | 366 | { |
367 | setCategories( true ); | 367 | setCategories( true ); |
368 | } | 368 | } |
369 | void KOListView::setAlarm() | 369 | void KOListView::setAlarm() |
370 | { | 370 | { |
371 | KOAlarmPrefs kap( this); | 371 | KOAlarmPrefs kap( this); |
372 | if ( !kap.exec() ) | 372 | if ( !kap.exec() ) |
373 | return; | 373 | return; |
374 | |||
375 | |||
376 | QStringList itemList; | 374 | QStringList itemList; |
377 | QPtrList<KOListViewItem> sel ; | 375 | QPtrList<KOListViewItem> sel ; |
378 | QListViewItem *qitem = mListView->firstChild (); | 376 | QListViewItem *qitem = mListView->firstChild (); |
379 | while ( qitem ) { | 377 | while ( qitem ) { |
380 | if ( qitem->isSelected() ) { | 378 | if ( qitem->isSelected() ) { |
381 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | 379 | Incidence* inc = ((KOListViewItem *) qitem)->data(); |
382 | if ( inc->type() != "Journal" ) { | 380 | if ( inc->type() != "Journal" ) { |
383 | if ( inc->type() == "Todo" ) { | 381 | if ( inc->type() == "Todo" ) { |
384 | if ( ((Todo*)inc)->hasDueDate() ) | 382 | if ( ((Todo*)inc)->hasDueDate() ) |
385 | sel.append(((KOListViewItem *)qitem)); | 383 | sel.append(((KOListViewItem *)qitem)); |
386 | } else | 384 | } else |
387 | sel.append(((KOListViewItem *)qitem)); | 385 | sel.append(((KOListViewItem *)qitem)); |
388 | } | 386 | } |
389 | } | 387 | } |
390 | qitem = qitem->nextSibling(); | 388 | qitem = qitem->nextSibling(); |
391 | } | 389 | } |
392 | int count = 0; | 390 | int count = 0; |
393 | KOListViewItem * item, *temp; | 391 | KOListViewItem * item, *temp; |
394 | item = sel.first(); | 392 | item = sel.first(); |
395 | Incidence* inc; | 393 | Incidence* inc; |
396 | while ( item ) { | 394 | while ( item ) { |
397 | inc = item->data(); | 395 | inc = item->data(); |
398 | ++count; | 396 | ++count; |
399 | if (kap.mAlarmButton->isChecked()) { | 397 | if (kap.mAlarmButton->isChecked()) { |
@@ -407,104 +405,107 @@ void KOListView::setAlarm() | |||
407 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 405 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
408 | j = j * 60; | 406 | j = j * 60; |
409 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 407 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
410 | j = j * (60 * 24); | 408 | j = j * (60 * 24); |
411 | alarm->setStartOffset( j ); | 409 | alarm->setStartOffset( j ); |
412 | 410 | ||
413 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | 411 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
414 | alarm->setProcedureAlarm(kap.mAlarmProgram); | 412 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
415 | } | 413 | } |
416 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | 414 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
417 | alarm->setAudioAlarm(kap.mAlarmSound); | 415 | alarm->setAudioAlarm(kap.mAlarmSound); |
418 | else | 416 | else |
419 | alarm->setType(Alarm::Invalid); | 417 | alarm->setType(Alarm::Invalid); |
420 | //alarm->setAudioAlarm("default"); | 418 | //alarm->setAudioAlarm("default"); |
421 | // TODO: Deal with multiple alarms | 419 | // TODO: Deal with multiple alarms |
422 | break; // For now, stop after the first alarm | 420 | break; // For now, stop after the first alarm |
423 | } | 421 | } |
424 | } else { | 422 | } else { |
425 | Alarm* alarm = inc->alarms().first(); | 423 | Alarm* alarm = inc->alarms().first(); |
426 | if ( alarm ) { | 424 | if ( alarm ) { |
427 | alarm->setEnabled(false); | 425 | alarm->setEnabled(false); |
428 | alarm->setType(Alarm::Invalid); | 426 | alarm->setType(Alarm::Invalid); |
429 | } | 427 | } |
430 | } | 428 | } |
431 | temp = item; | 429 | ListItemVisitor v(item, mStartDate ); |
430 | inc->accept(v); | ||
432 | item = sel.next(); | 431 | item = sel.next(); |
433 | mUidDict.remove( inc->uid() ); | ||
434 | delete temp;; | ||
435 | addIncidence( inc ); | ||
436 | } | 432 | } |
437 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); | 433 | topLevelWidget()->setCaption( i18n("Canged alarm for %1 items").arg( count ) ); |
438 | qDebug("KO: Set alarm for %d items", count); | 434 | qDebug("KO: Set alarm for %d items", count); |
439 | calendar()->reInitAlarmSettings(); | 435 | calendar()->reInitAlarmSettings(); |
440 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 436 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
441 | } | 437 | } |
442 | void KOListView::setCategories( bool removeOld ) | 438 | void KOListView::setCategories( bool removeOld ) |
443 | { | 439 | { |
444 | 440 | ||
445 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 441 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
442 | csd->setColorEnabled(); | ||
446 | if (! csd->exec()) { | 443 | if (! csd->exec()) { |
447 | delete csd; | 444 | delete csd; |
448 | return; | 445 | return; |
449 | } | 446 | } |
450 | QStringList catList = csd->selectedCategories(); | 447 | QStringList catList = csd->selectedCategories(); |
451 | delete csd; | 448 | delete csd; |
452 | // if ( catList.count() == 0 ) | 449 | // if ( catList.count() == 0 ) |
453 | // return; | 450 | // return; |
454 | catList.sort(); | 451 | //catList.sort(); |
455 | QString categoriesStr = catList.join(","); | 452 | QString categoriesStr = catList.join(","); |
456 | int i; | 453 | int i; |
457 | QStringList itemList; | 454 | QStringList itemList; |
458 | QPtrList<KOListViewItem> sel ; | 455 | QPtrList<KOListViewItem> sel ; |
459 | QListViewItem *qitem = mListView->firstChild (); | 456 | QListViewItem *qitem = mListView->firstChild (); |
460 | while ( qitem ) { | 457 | while ( qitem ) { |
461 | if ( qitem->isSelected() ) { | 458 | if ( qitem->isSelected() ) { |
462 | sel.append(((KOListViewItem *)qitem)); | 459 | sel.append(((KOListViewItem *)qitem)); |
463 | } | 460 | } |
464 | qitem = qitem->nextSibling(); | 461 | qitem = qitem->nextSibling(); |
465 | } | 462 | } |
466 | KOListViewItem * item, *temp; | 463 | KOListViewItem * item, *temp; |
467 | item = sel.first(); | 464 | item = sel.first(); |
468 | Incidence* inc; | 465 | if( item ) { |
466 | Incidence* inc = item->data() ; | ||
467 | bool setSub = false; | ||
468 | if( inc->type() == "Todo" && sel.count() == 1 && inc->relations().count() > 0 ) { | ||
469 | int result = KMessageBox::warningYesNoCancel(this, | ||
470 | i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), | ||
471 | i18n("Todo has subtodos"), | ||
472 | i18n("Yes"), | ||
473 | i18n("No")); | ||
474 | if (result == KMessageBox::Cancel) item = 0; | ||
475 | if (result == KMessageBox::Yes) setSub = true; | ||
476 | } | ||
469 | while ( item ) { | 477 | while ( item ) { |
470 | inc = item->data(); | 478 | inc = item->data(); |
471 | if ( removeOld ) { | 479 | if ( removeOld ) { |
472 | inc->setCategories( categoriesStr ); | 480 | inc->setCategories( catList, setSub ); |
473 | } else { | 481 | } else { |
474 | itemList = QStringList::split (",", inc->categoriesStr() ); | 482 | inc->addCategories( catList, setSub ); |
475 | for( i = 0; i< catList.count(); ++i ) { | ||
476 | if ( !itemList.contains (catList[i])) | ||
477 | itemList.append( catList[i] ); | ||
478 | } | ||
479 | itemList.sort(); | ||
480 | inc->setCategories( itemList.join(",") ); | ||
481 | } | 483 | } |
482 | temp = item; | 484 | ListItemVisitor v(item, mStartDate ); |
485 | inc->accept(v); | ||
483 | item = sel.next(); | 486 | item = sel.next(); |
484 | mUidDict.remove( inc->uid() ); | 487 | } |
485 | delete temp;; | ||
486 | addIncidence( inc ); | ||
487 | } | 488 | } |
488 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 489 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
489 | } | 490 | } |
490 | 491 | ||
491 | void KOListView::beamSelected() | 492 | void KOListView::beamSelected() |
492 | { | 493 | { |
493 | int icount = 0; | 494 | int icount = 0; |
494 | QPtrList<Incidence> delSel ; | 495 | QPtrList<Incidence> delSel ; |
495 | QListViewItem *item = mListView->firstChild (); | 496 | QListViewItem *item = mListView->firstChild (); |
496 | while ( item ) { | 497 | while ( item ) { |
497 | if ( item->isSelected() ) { | 498 | if ( item->isSelected() ) { |
498 | delSel.append(((KOListViewItem *)item)->data()); | 499 | delSel.append(((KOListViewItem *)item)->data()); |
499 | ++icount; | 500 | ++icount; |
500 | } | 501 | } |
501 | 502 | ||
502 | item = item->nextSibling(); | 503 | item = item->nextSibling(); |
503 | } | 504 | } |
504 | if ( icount ) { | 505 | if ( icount ) { |
505 | emit beamIncidenceList( delSel ); | 506 | emit beamIncidenceList( delSel ); |
506 | return; | 507 | return; |
507 | QString fn ; | 508 | QString fn ; |
508 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; | 509 | fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; |
509 | QString mes; | 510 | QString mes; |
510 | bool createbup = true; | 511 | bool createbup = true; |