author | zautrix <zautrix> | 2005-07-01 20:58:33 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-01 20:58:33 (UTC) |
commit | 5c03b6da2ff31c72d8c8b37d3e94f666a22081d0 (patch) (unidiff) | |
tree | fb0197957a16aed93322ba61f7c6db2edd453011 | |
parent | 541878bcf52030d8597d5e79afb6ae1185b2ac2c (diff) | |
download | kdepimpi-5c03b6da2ff31c72d8c8b37d3e94f666a22081d0.zip kdepimpi-5c03b6da2ff31c72d8c8b37d3e94f666a22081d0.tar.gz kdepimpi-5c03b6da2ff31c72d8c8b37d3e94f666a22081d0.tar.bz2 |
more fixes
-rw-r--r-- | korganizer/kolistview.cpp | 102 |
1 files changed, 50 insertions, 52 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 4c815d8..1b4397f 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp | |||
@@ -378,421 +378,419 @@ KOListView::~KOListView() | |||
378 | #else | 378 | #else |
379 | delete mKOListViewWhatsThis; | 379 | delete mKOListViewWhatsThis; |
380 | #endif | 380 | #endif |
381 | } | 381 | } |
382 | 382 | ||
383 | QString KOListView::getWhatsThisText(QPoint p) | 383 | QString KOListView::getWhatsThisText(QPoint p) |
384 | { | 384 | { |
385 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); | 385 | KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); |
386 | if ( item ) | 386 | if ( item ) |
387 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), | 387 | return KIncidenceFormatter::instance()->getFormattedText( item->data(), |
388 | KOPrefs::instance()->mWTshowDetails, | 388 | KOPrefs::instance()->mWTshowDetails, |
389 | KOPrefs::instance()->mWTshowCreated, | 389 | KOPrefs::instance()->mWTshowCreated, |
390 | KOPrefs::instance()->mWTshowChanged); | 390 | KOPrefs::instance()->mWTshowChanged); |
391 | return i18n("That is the list view" ); | 391 | return i18n("That is the list view" ); |
392 | 392 | ||
393 | } | 393 | } |
394 | 394 | ||
395 | void KOListView::setCalendar( int c ) | 395 | void KOListView::setCalendar( int c ) |
396 | { | 396 | { |
397 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 397 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
398 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), | 398 | i18n("This adds the selected\nitems to the calendar\n%1\nand removes them from\ntheir current calendar!").arg( KOPrefs::instance()->calName( c ) ), |
399 | i18n("Continue"), i18n("Cancel"), 0, | 399 | i18n("Continue"), i18n("Cancel"), 0, |
400 | 0, 1 ); | 400 | 0, 1 ); |
401 | if ( result != 0 ) { | 401 | if ( result != 0 ) { |
402 | return; | 402 | return; |
403 | } | 403 | } |
404 | 404 | ||
405 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 405 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
406 | int icount = delSel.count(); | 406 | int icount = delSel.count(); |
407 | if ( icount ) { | 407 | if ( icount ) { |
408 | Incidence *incidence = delSel.first(); | 408 | Incidence *incidence = delSel.first(); |
409 | while ( incidence ) { | 409 | while ( incidence ) { |
410 | incidence->setCalID( c ); | 410 | incidence->setCalID( c ); |
411 | KOListViewItem * item = getItemForEvent( incidence ); | 411 | KOListViewItem * item = getItemForEvent( incidence ); |
412 | if ( item ) { | 412 | if ( item ) { |
413 | ListItemVisitor v(item, mStartDate ); | 413 | ListItemVisitor v(item, mStartDate ); |
414 | incidence->accept(v); | 414 | incidence->accept(v); |
415 | } | 415 | } |
416 | incidence = delSel.next(); | 416 | incidence = delSel.next(); |
417 | } | 417 | } |
418 | } | 418 | } |
419 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; | 419 | QPtrList<KopiCalendarFile> calendars = KOPrefs::instance()->mCalendars; |
420 | KopiCalendarFile * cal = calendars.first(); | 420 | KopiCalendarFile * cal = calendars.first(); |
421 | while ( cal ) { | 421 | while ( cal ) { |
422 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); | 422 | mCalendar->setCalendarEnabled( cal->mCalNumber,cal->isEnabled ); |
423 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); | 423 | mCalendar->setAlarmEnabled( cal->mCalNumber, cal->isAlarmEnabled ); |
424 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); | 424 | mCalendar->setReadOnly( cal->mCalNumber, cal->isReadOnly ); |
425 | if ( cal->isStandard ) | 425 | if ( cal->isStandard ) |
426 | mCalendar->setDefaultCalendar( cal->mCalNumber ); | 426 | mCalendar->setDefaultCalendar( cal->mCalNumber ); |
427 | cal = calendars.next(); | 427 | cal = calendars.next(); |
428 | } | 428 | } |
429 | mCalendar->setSyncEventsReadOnly(); | 429 | mCalendar->setSyncEventsReadOnly(); |
430 | mCalendar->reInitAlarmSettings(); | 430 | mCalendar->reInitAlarmSettings(); |
431 | 431 | ||
432 | } | 432 | } |
433 | void KOListView::populateCalPopup() | 433 | void KOListView::populateCalPopup() |
434 | { | 434 | { |
435 | mCalPopup->clear(); | 435 | mCalPopup->clear(); |
436 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 436 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
437 | while ( kkf ) { | 437 | while ( kkf ) { |
438 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); | 438 | int index = mCalPopup->insertItem( kkf->mName+"...", kkf->mCalNumber); |
439 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) | 439 | if ( kkf->mErrorOnLoad || kkf->isReadOnly ) |
440 | mCalPopup->setItemEnabled( index, false ); | 440 | mCalPopup->setItemEnabled( index, false ); |
441 | kkf = KOPrefs::instance()->mCalendars.next(); | 441 | kkf = KOPrefs::instance()->mCalendars.next(); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | void KOListView::updateList() | 444 | void KOListView::updateList() |
445 | { | 445 | { |
446 | // qDebug(" KOListView::updateList() "); | 446 | // qDebug(" KOListView::updateList() "); |
447 | 447 | ||
448 | } | 448 | } |
449 | 449 | ||
450 | void KOListView::clearList() | 450 | void KOListView::clearList() |
451 | { | 451 | { |
452 | clear (); | 452 | clear (); |
453 | } | 453 | } |
454 | 454 | ||
455 | void KOListView::setCat() | 455 | void KOListView::setCat() |
456 | { | 456 | { |
457 | 457 | ||
458 | bool set = true; | 458 | bool set = true; |
459 | int result = KMessageBox::warningYesNoCancel(this, | 459 | int result = KMessageBox::warningYesNoCancel(this, |
460 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), | 460 | i18n("Do you want to <b>add</b> categories to the selected items or <b>reset</b> the list (i.e. remove current categories)?"), |
461 | i18n("Set categories"), | 461 | i18n("Set categories"), |
462 | i18n("Add"), | 462 | i18n("Add"), |
463 | i18n("Reset")); | 463 | i18n("Reset")); |
464 | if (result == KMessageBox::Cancel) return; | 464 | if (result == KMessageBox::Cancel) return; |
465 | if (result == KMessageBox::Yes) set = false; | 465 | if (result == KMessageBox::Yes) set = false; |
466 | setCategories( set ); | 466 | setCategories( set ); |
467 | } | 467 | } |
468 | 468 | ||
469 | void KOListView::setAlarm() | 469 | void KOListView::setAlarm() |
470 | { | 470 | { |
471 | KOAlarmPrefs kap( this); | 471 | KOAlarmPrefs kap( this); |
472 | if ( !kap.exec() ) | 472 | if ( !kap.exec() ) |
473 | return; | 473 | return; |
474 | QPtrList<KOListViewItem> sel ; | 474 | QPtrList<Incidence> delSel = getSelectedIncidences( true, true, false, true ); // no journals, only due todos |
475 | QListViewItem *qitem = mListView->firstChild (); | 475 | Incidence* inc = delSel.first(); |
476 | while ( qitem ) { | ||
477 | if ( qitem->isSelected() ) { | ||
478 | Incidence* inc = ((KOListViewItem *) qitem)->data(); | ||
479 | if ( inc->typeID() != journalID ) { | ||
480 | if ( inc->typeID() == todoID ) { | ||
481 | if ( ((Todo*)inc)->hasDueDate() ) | ||
482 | sel.append(((KOListViewItem *)qitem)); | ||
483 | } else | ||
484 | sel.append(((KOListViewItem *)qitem)); | ||
485 | } | ||
486 | } | ||
487 | qitem = qitem->nextSibling(); | ||
488 | } | ||
489 | int count = 0; | 476 | int count = 0; |
490 | KOListViewItem * item, *temp; | 477 | while ( inc ) { |
491 | item = sel.first(); | 478 | ++count; |
492 | Incidence* inc; | 479 | if (kap.mAlarmButton->isChecked()) { |
493 | while ( item ) { | 480 | if (inc->alarms().count() == 0) |
494 | inc = item->data(); | 481 | inc->newAlarm(); |
495 | ++count; | 482 | QPtrList<Alarm> alarms = inc->alarms(); |
496 | if (kap.mAlarmButton->isChecked()) { | 483 | Alarm *alarm; |
497 | if (inc->alarms().count() == 0) | 484 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { |
498 | inc->newAlarm(); | 485 | alarm->setEnabled(true); |
499 | QPtrList<Alarm> alarms = inc->alarms(); | 486 | int j = kap.mAlarmTimeEdit->value()* -60; |
500 | Alarm *alarm; | 487 | if (kap.mAlarmIncrCombo->currentItem() == 1) |
501 | for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { | 488 | j = j * 60; |
502 | alarm->setEnabled(true); | 489 | else if (kap.mAlarmIncrCombo->currentItem() == 2) |
503 | int j = kap.mAlarmTimeEdit->value()* -60; | 490 | j = j * (60 * 24); |
504 | if (kap.mAlarmIncrCombo->currentItem() == 1) | 491 | alarm->setStartOffset( j ); |
505 | j = j * 60; | 492 | |
506 | else if (kap.mAlarmIncrCombo->currentItem() == 2) | 493 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { |
507 | j = j * (60 * 24); | 494 | alarm->setProcedureAlarm(kap.mAlarmProgram); |
508 | alarm->setStartOffset( j ); | ||
509 | |||
510 | if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { | ||
511 | alarm->setProcedureAlarm(kap.mAlarmProgram); | ||
512 | } | ||
513 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) | ||
514 | alarm->setAudioAlarm(kap.mAlarmSound); | ||
515 | else | ||
516 | alarm->setType(Alarm::Invalid); | ||
517 | //alarm->setAudioAlarm("default"); | ||
518 | // TODO: Deal with multiple alarms | ||
519 | break; // For now, stop after the first alarm | ||
520 | } | 495 | } |
521 | } else { | 496 | else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) |
522 | Alarm* alarm = inc->alarms().first(); | 497 | alarm->setAudioAlarm(kap.mAlarmSound); |
523 | if ( alarm ) { | 498 | else |
524 | alarm->setEnabled(false); | ||
525 | alarm->setType(Alarm::Invalid); | 499 | alarm->setType(Alarm::Invalid); |
526 | } | 500 | //alarm->setAudioAlarm("default"); |
501 | // TODO: Deal with multiple alarms | ||
502 | break; // For now, stop after the first alarm | ||
527 | } | 503 | } |
504 | } else { | ||
505 | Alarm* alarm = inc->alarms().first(); | ||
506 | if ( alarm ) { | ||
507 | alarm->setEnabled(false); | ||
508 | alarm->setType(Alarm::Invalid); | ||
509 | } | ||
510 | } | ||
511 | KOListViewItem* item = getItemForEvent(inc); | ||
512 | if (item) { | ||
528 | ListItemVisitor v(item, mStartDate ); | 513 | ListItemVisitor v(item, mStartDate ); |
529 | inc->accept(v); | 514 | inc->accept(v); |
530 | item = sel.next(); | 515 | } |
516 | inc = delSel.next(); | ||
531 | } | 517 | } |
532 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); | 518 | topLevelWidget()->setCaption( i18n("Changed alarm for %1 items").arg( count ) ); |
533 | qDebug("KO: Set alarm for %d items", count); | 519 | qDebug("KO: Set alarm for %d items", count); |
534 | calendar()->reInitAlarmSettings(); | 520 | calendar()->reInitAlarmSettings(); |
535 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 521 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
536 | } | 522 | } |
537 | void KOListView::setCategories( bool removeOld ) | 523 | void KOListView::setCategories( bool removeOld ) |
538 | { | 524 | { |
539 | 525 | ||
540 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); | 526 | KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); |
541 | csd->setColorEnabled(); | 527 | csd->setColorEnabled(); |
542 | if (! csd->exec()) { | 528 | if (! csd->exec()) { |
543 | delete csd; | 529 | delete csd; |
544 | return; | 530 | return; |
545 | } | 531 | } |
546 | QStringList catList = csd->selectedCategories(); | 532 | QStringList catList = csd->selectedCategories(); |
547 | delete csd; | 533 | delete csd; |
548 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 534 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
549 | Incidence* inc = delSel.first(); | 535 | Incidence* inc = delSel.first(); |
550 | while ( inc ) { | 536 | while ( inc ) { |
551 | if ( removeOld ) { | 537 | if ( removeOld ) { |
552 | inc->setCategories( catList, false ); | 538 | inc->setCategories( catList, false ); |
553 | } else { | 539 | } else { |
554 | inc->addCategories( catList, false ); | 540 | inc->addCategories( catList, false ); |
555 | } | 541 | } |
556 | KOListViewItem* item = getItemForEvent(inc); | 542 | KOListViewItem* item = getItemForEvent(inc); |
557 | if (item) { | 543 | if (item) { |
558 | ListItemVisitor v(item, mStartDate ); | 544 | ListItemVisitor v(item, mStartDate ); |
559 | inc->accept(v); | 545 | inc->accept(v); |
560 | } | 546 | } |
561 | inc = delSel.next(); | 547 | inc = delSel.next(); |
562 | } | 548 | } |
563 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 549 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
564 | } | 550 | } |
565 | 551 | ||
566 | void KOListView::beamSelected() | 552 | void KOListView::beamSelected() |
567 | { | 553 | { |
568 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 554 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
569 | if ( delSel.count() ) | 555 | if ( delSel.count() ) |
570 | emit beamIncidenceList( delSel ); | 556 | emit beamIncidenceList( delSel ); |
571 | } | 557 | } |
572 | 558 | ||
573 | void KOListView::saveDescriptionToFile() | 559 | void KOListView::saveDescriptionToFile() |
574 | { | 560 | { |
575 | 561 | ||
576 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), | 562 | int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), |
577 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), | 563 | i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), |
578 | i18n("Continue"), i18n("Cancel"), 0, | 564 | i18n("Continue"), i18n("Cancel"), 0, |
579 | 0, 1 ); | 565 | 0, 1 ); |
580 | if ( result != 0 ) { | 566 | if ( result != 0 ) { |
581 | return; | 567 | return; |
582 | } | 568 | } |
583 | QPtrList<Incidence> delSel = getSelectedIncidences() ; | 569 | QPtrList<Incidence> delSel = getSelectedIncidences() ; |
584 | int icount = delSel.count(); | 570 | int icount = delSel.count(); |
585 | if ( icount ) { | 571 | if ( icount ) { |
586 | QString fn = KOPrefs::instance()->mLastSaveFile; | 572 | QString fn = KOPrefs::instance()->mLastSaveFile; |
587 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 573 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
588 | 574 | ||
589 | if ( fn == "" ) | 575 | if ( fn == "" ) |
590 | return; | 576 | return; |
591 | QFileInfo info; | 577 | QFileInfo info; |
592 | info.setFile( fn ); | 578 | info.setFile( fn ); |
593 | QString mes; | 579 | QString mes; |
594 | bool createbup = true; | 580 | bool createbup = true; |
595 | if ( info. exists() ) { | 581 | if ( info. exists() ) { |
596 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 582 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
597 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 583 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
598 | i18n("Overwrite!"), i18n("Cancel"), 0, | 584 | i18n("Overwrite!"), i18n("Cancel"), 0, |
599 | 0, 1 ); | 585 | 0, 1 ); |
600 | if ( result != 0 ) { | 586 | if ( result != 0 ) { |
601 | createbup = false; | 587 | createbup = false; |
602 | } | 588 | } |
603 | } | 589 | } |
604 | if ( createbup ) { | 590 | if ( createbup ) { |
605 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + | 591 | QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + |
606 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); | 592 | KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); |
607 | Incidence *incidence = delSel.first(); | 593 | Incidence *incidence = delSel.first(); |
608 | icount = 0; | 594 | icount = 0; |
609 | while ( incidence ) { | 595 | while ( incidence ) { |
610 | if ( incidence->typeID() == journalID ) { | 596 | if ( incidence->typeID() == journalID ) { |
611 | text += "\n************************************\n"; | 597 | text += "\n************************************\n"; |
612 | if ( !incidence->summary().isEmpty() ) | 598 | if ( !incidence->summary().isEmpty() ) |
613 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); | 599 | text += i18n("Journal: %1 from ").arg( incidence->summary() ) +incidence->dtStartDateStr( false ); |
614 | else | 600 | else |
615 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); | 601 | text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); |
616 | if ( !incidence->location().isEmpty() ) | 602 | if ( !incidence->location().isEmpty() ) |
617 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 603 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
618 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 604 | text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
619 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); | 605 | text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); |
620 | ++icount; | 606 | ++icount; |
621 | 607 | ||
622 | } else { | 608 | } else { |
623 | if ( !incidence->description().isEmpty() ) { | 609 | if ( !incidence->description().isEmpty() ) { |
624 | text += "\n************************************\n"; | 610 | text += "\n************************************\n"; |
625 | if ( incidence->typeID() == todoID ) | 611 | if ( incidence->typeID() == todoID ) |
626 | text += i18n("To-Do: "); | 612 | text += i18n("To-Do: "); |
627 | text += incidence->summary(); | 613 | text += incidence->summary(); |
628 | if ( !incidence->location().isEmpty() ) | 614 | if ( !incidence->location().isEmpty() ) |
629 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; | 615 | text +="\n(" + i18n("Location: ") + incidence->location()+ ")"; |
630 | if ( incidence->hasStartDate() ) | 616 | if ( incidence->hasStartDate() ) |
631 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); | 617 | text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); |
632 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); | 618 | text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); |
633 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); | 619 | text += "\n" + i18n("Description: ") + "\n" + incidence->description(); |
634 | ++icount; | 620 | ++icount; |
635 | 621 | ||
636 | } | 622 | } |
637 | } | 623 | } |
638 | incidence = delSel.next(); | 624 | incidence = delSel.next(); |
639 | } | 625 | } |
640 | QFile file( fn ); | 626 | QFile file( fn ); |
641 | if (!file.open( IO_WriteOnly ) ) { | 627 | if (!file.open( IO_WriteOnly ) ) { |
642 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); | 628 | topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); |
643 | return; | 629 | return; |
644 | } | 630 | } |
645 | QTextStream ts( &file ); | 631 | QTextStream ts( &file ); |
646 | ts << text; | 632 | ts << text; |
647 | file.close(); | 633 | file.close(); |
648 | //qDebug("%s ", text.latin1()); | 634 | //qDebug("%s ", text.latin1()); |
649 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); | 635 | mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); |
650 | KOPrefs::instance()->mLastSaveFile = fn; | 636 | KOPrefs::instance()->mLastSaveFile = fn; |
651 | topLevelWidget()->setCaption(mes); | 637 | topLevelWidget()->setCaption(mes); |
652 | } | 638 | } |
653 | } | 639 | } |
654 | } | 640 | } |
655 | void KOListView::saveToFileVCS() | 641 | void KOListView::saveToFileVCS() |
656 | { | 642 | { |
657 | writeToFile( false ); | 643 | writeToFile( false ); |
658 | } | 644 | } |
659 | void KOListView::saveToFile() | 645 | void KOListView::saveToFile() |
660 | { | 646 | { |
661 | writeToFile( true ); | 647 | writeToFile( true ); |
662 | } | 648 | } |
663 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) | 649 | QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos ) |
664 | { | 650 | { |
665 | QPtrList<Incidence> delSel ; | 651 | QPtrList<Incidence> delSel ; |
666 | bool addSubTodos = false; | 652 | bool addSubTodos = false; |
667 | bool askSubTodos = true; | 653 | bool askSubTodos = true; |
668 | QListViewItem *item = mListView->firstChild (); | 654 | QListViewItem *item = mListView->firstChild (); |
669 | while ( item ) { | 655 | while ( item ) { |
670 | if ( item->isSelected() ) { | 656 | if ( item->isSelected() ) { |
671 | Incidence* inc = ((KOListViewItem *)item)->data(); | 657 | Incidence* inc = ((KOListViewItem *)item)->data(); |
672 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { | 658 | if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) { |
673 | if ( (inc->typeID() == todoID && includeTodos) || | 659 | if ( (inc->typeID() == todoID && includeTodos) || |
674 | (inc->typeID() == eventID && includeEvents) || | 660 | (inc->typeID() == eventID && includeEvents) || |
675 | (inc->typeID() == journalID && includeJournals) ) { | 661 | (inc->typeID() == journalID && includeJournals) ) { |
676 | if ( inc->typeID() == todoID && onlyDueTodos ) { | 662 | if ( inc->typeID() == todoID && onlyDueTodos ) { |
677 | if ( ((Todo*)inc)->hasDueDate() ) | 663 | if ( ((Todo*)inc)->hasDueDate() ) |
678 | delSel.append( inc ); | 664 | delSel.append( inc ); |
679 | } else | 665 | } else |
680 | delSel.append( inc ); | 666 | delSel.append( inc ); |
681 | 667 | ||
682 | } | 668 | } |
683 | } | 669 | } |
684 | if ( inc->typeID() == todoID ) { | 670 | if ( inc->typeID() == todoID ) { |
685 | Todo * todo = (Todo*) inc; | 671 | Todo * todo = (Todo*) inc; |
686 | if ( todo->relations().count() ) { | 672 | if ( todo->relations().count() ) { |
687 | if ( askSubTodos ) { | 673 | if ( askSubTodos ) { |
688 | int result = KMessageBox::warningYesNoCancel(this, | 674 | int result = KMessageBox::warningYesNoCancel(this, |
689 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), | 675 | i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"), |
690 | i18n("Todo has subtodos"), | 676 | i18n("Todo has subtodos"), |
691 | i18n("Yes"), | 677 | i18n("Yes"), |
692 | i18n("No")); | 678 | i18n("No")); |
693 | if ( result == KMessageBox::Cancel ) { | 679 | if ( result == KMessageBox::Cancel ) { |
694 | delSel.clear(); | 680 | delSel.clear(); |
695 | return delSel; | 681 | return delSel; |
696 | } | 682 | } |
697 | if (result == KMessageBox::Yes) | 683 | if (result == KMessageBox::Yes) |
698 | addSubTodos = true; | 684 | addSubTodos = true; |
699 | askSubTodos = false; | 685 | askSubTodos = false; |
700 | } | 686 | } |
701 | if ( addSubTodos ) { | 687 | if ( addSubTodos ) { |
702 | inc->addRelationsToList( &delSel ); | 688 | QPtrList<Incidence> tempSel ; |
689 | inc->addRelationsToList( &tempSel ); | ||
690 | Incidence* tempinc = tempSel.first(); | ||
691 | while ( tempinc ) { | ||
692 | if ( delSel.findRef( tempinc ) == -1 ) { | ||
693 | if ( tempinc->typeID() == todoID && onlyDueTodos ) { | ||
694 | if ( ((Todo*)tempinc)->hasDueDate() ) | ||
695 | delSel.append( tempinc ); | ||
696 | } else | ||
697 | delSel.append( tempinc ); | ||
698 | } | ||
699 | tempinc = tempSel.next(); | ||
700 | } | ||
703 | } | 701 | } |
704 | } | 702 | } |
705 | } | 703 | } |
706 | } | 704 | } |
707 | item = item->nextSibling(); | 705 | item = item->nextSibling(); |
708 | } | 706 | } |
709 | return delSel; | 707 | return delSel; |
710 | } | 708 | } |
711 | 709 | ||
712 | void KOListView::writeToFile( bool iCal ) | 710 | void KOListView::writeToFile( bool iCal ) |
713 | { | 711 | { |
714 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; | 712 | QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed; |
715 | if ( !iCal ) { | 713 | if ( !iCal ) { |
716 | bool journal = false; | 714 | bool journal = false; |
717 | Incidence *incidence = delSel.first(); | 715 | Incidence *incidence = delSel.first(); |
718 | while ( incidence ) { | 716 | while ( incidence ) { |
719 | if ( incidence->typeID() == journalID ) { | 717 | if ( incidence->typeID() == journalID ) { |
720 | journal = true; | 718 | journal = true; |
721 | break; | 719 | break; |
722 | } | 720 | } |
723 | incidence = delSel.next(); | 721 | incidence = delSel.next(); |
724 | } | 722 | } |
725 | if ( journal ) { | 723 | if ( journal ) { |
726 | int result = KMessageBox::warningContinueCancel(this, | 724 | int result = KMessageBox::warningContinueCancel(this, |
727 | i18n("The journal entries can not be\nexported to a vCalendar file."), | 725 | i18n("The journal entries can not be\nexported to a vCalendar file."), |
728 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), | 726 | i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), |
729 | true); | 727 | true); |
730 | if (result != KMessageBox::Continue) return; | 728 | if (result != KMessageBox::Continue) return; |
731 | } | 729 | } |
732 | } | 730 | } |
733 | if ( delSel.count() ) { | 731 | if ( delSel.count() ) { |
734 | QString fn = KOPrefs::instance()->mLastSaveFile; | 732 | QString fn = KOPrefs::instance()->mLastSaveFile; |
735 | QString extension; | 733 | QString extension; |
736 | if ( iCal ) { | 734 | if ( iCal ) { |
737 | if ( fn.right( 4 ).lower() == ".vcs" ) { | 735 | if ( fn.right( 4 ).lower() == ".vcs" ) { |
738 | fn = fn.left( fn.length() -3) + "ics"; | 736 | fn = fn.left( fn.length() -3) + "ics"; |
739 | } | 737 | } |
740 | } else { | 738 | } else { |
741 | if ( fn.right( 4 ).lower() == ".ics" ) { | 739 | if ( fn.right( 4 ).lower() == ".ics" ) { |
742 | fn = fn.left( fn.length() -3) + "vcs"; | 740 | fn = fn.left( fn.length() -3) + "vcs"; |
743 | } | 741 | } |
744 | } | 742 | } |
745 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); | 743 | fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); |
746 | 744 | ||
747 | if ( fn == "" ) | 745 | if ( fn == "" ) |
748 | return; | 746 | return; |
749 | QFileInfo info; | 747 | QFileInfo info; |
750 | info.setFile( fn ); | 748 | info.setFile( fn ); |
751 | QString mes; | 749 | QString mes; |
752 | bool createbup = true; | 750 | bool createbup = true; |
753 | if ( info. exists() ) { | 751 | if ( info. exists() ) { |
754 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); | 752 | mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); |
755 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, | 753 | int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, |
756 | i18n("Overwrite!"), i18n("Cancel"), 0, | 754 | i18n("Overwrite!"), i18n("Cancel"), 0, |
757 | 0, 1 ); | 755 | 0, 1 ); |
758 | if ( result != 0 ) { | 756 | if ( result != 0 ) { |
759 | createbup = false; | 757 | createbup = false; |
760 | } | 758 | } |
761 | } | 759 | } |
762 | if ( createbup ) { | 760 | if ( createbup ) { |
763 | CalendarLocal cal; | 761 | CalendarLocal cal; |
764 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); | 762 | cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); |
765 | Incidence *incidence = delSel.first(); | 763 | Incidence *incidence = delSel.first(); |
766 | while ( incidence ) { | 764 | while ( incidence ) { |
767 | cal.addIncidence( incidence->clone() ); | 765 | cal.addIncidence( incidence->clone() ); |
768 | incidence = delSel.next(); | 766 | incidence = delSel.next(); |
769 | } | 767 | } |
770 | if ( iCal ) { | 768 | if ( iCal ) { |
771 | ICalFormat format; | 769 | ICalFormat format; |
772 | format.save( &cal, fn ); | 770 | format.save( &cal, fn ); |
773 | } else { | 771 | } else { |
774 | 772 | ||
775 | VCalFormat format; | 773 | VCalFormat format; |
776 | format.save( &cal, fn ); | 774 | format.save( &cal, fn ); |
777 | } | 775 | } |
778 | mes = i18n("KO/Pi:Saved %1").arg(fn ); | 776 | mes = i18n("KO/Pi:Saved %1").arg(fn ); |
779 | KOPrefs::instance()->mLastSaveFile = fn; | 777 | KOPrefs::instance()->mLastSaveFile = fn; |
780 | topLevelWidget()->setCaption(mes); | 778 | topLevelWidget()->setCaption(mes); |
781 | } | 779 | } |
782 | } | 780 | } |
783 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); | 781 | QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); |
784 | } | 782 | } |
785 | void KOListView::hideAll() | 783 | void KOListView::hideAll() |
786 | { | 784 | { |
787 | QPtrList<QListViewItem> delSel ; | 785 | QPtrList<QListViewItem> delSel ; |
788 | QListViewItem *item = mListView->firstChild (); | 786 | QListViewItem *item = mListView->firstChild (); |
789 | while ( item ) { | 787 | while ( item ) { |
790 | if ( item->isSelected() ) { | 788 | if ( item->isSelected() ) { |
791 | delSel.append(item); | 789 | delSel.append(item); |
792 | } | 790 | } |
793 | item = item->nextSibling(); | 791 | item = item->nextSibling(); |
794 | } | 792 | } |
795 | item = delSel.first() ; | 793 | item = delSel.first() ; |
796 | while ( item ) { | 794 | while ( item ) { |
797 | QListViewItem * del = item; | 795 | QListViewItem * del = item; |
798 | item = delSel.next(); | 796 | item = delSel.next(); |