summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kolistview.cpp108
-rw-r--r--korganizer/kolistview.h1
2 files changed, 51 insertions, 58 deletions
diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp
index 5797d1b..1f3b4c6 100644
--- a/korganizer/kolistview.cpp
+++ b/korganizer/kolistview.cpp
@@ -344,96 +344,97 @@ KOListView::KOListView(Calendar *calendar, QWidget *parent,
344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)), 344 QObject::connect(mListView,SIGNAL(currentChanged(QListViewItem *)),
345 SLOT(processSelectionChange(QListViewItem *))); 345 SLOT(processSelectionChange(QListViewItem *)));
346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)), 346 QObject::connect(mListView,SIGNAL(showIncidence(Incidence *)),
347 SIGNAL(showIncidenceSignal(Incidence *)) ); 347 SIGNAL(showIncidenceSignal(Incidence *)) );
348 348
349 readSettings(KOGlobals::config(),"KOListView Layout"); 349 readSettings(KOGlobals::config(),"KOListView Layout");
350} 350}
351 351
352KOListView::~KOListView() 352KOListView::~KOListView()
353{ 353{
354 delete mPopupMenu; 354 delete mPopupMenu;
355#if QT_VERSION >= 0x030000 355#if QT_VERSION >= 0x030000
356 356
357#else 357#else
358 delete mKOListViewWhatsThis; 358 delete mKOListViewWhatsThis;
359#endif 359#endif
360} 360}
361 361
362QString KOListView::getWhatsThisText(QPoint p) 362QString KOListView::getWhatsThisText(QPoint p)
363{ 363{
364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p ); 364 KOListViewItem* item = ( KOListViewItem* ) mListView->itemAt( p );
365 if ( item ) 365 if ( item )
366 return KIncidenceFormatter::instance()->getFormattedText( item->data(), 366 return KIncidenceFormatter::instance()->getFormattedText( item->data(),
367 KOPrefs::instance()->mWTshowDetails, 367 KOPrefs::instance()->mWTshowDetails,
368 KOPrefs::instance()->mWTshowCreated, 368 KOPrefs::instance()->mWTshowCreated,
369 KOPrefs::instance()->mWTshowChanged); 369 KOPrefs::instance()->mWTshowChanged);
370 return i18n("That is the list view" ); 370 return i18n("That is the list view" );
371 371
372} 372}
373 373
374void KOListView::updateList() 374void KOListView::updateList()
375{ 375{
376 // qDebug(" KOListView::updateList() "); 376 // qDebug(" KOListView::updateList() ");
377 377
378} 378}
379 379
380void KOListView::clearList() 380void KOListView::clearList()
381{ 381{
382 clear (); 382 clear ();
383} 383}
384void KOListView::addCat( ) 384void KOListView::addCat( )
385{ 385{
386 setCategories( false ); 386 setCategories( false );
387} 387}
388void KOListView::setCat() 388void KOListView::setCat()
389{ 389{
390 setCategories( true ); 390 setCategories( true );
391} 391}
392
392void KOListView::setAlarm() 393void KOListView::setAlarm()
393{ 394{
394 KOAlarmPrefs kap( this); 395 KOAlarmPrefs kap( this);
395 if ( !kap.exec() ) 396 if ( !kap.exec() )
396 return; 397 return;
397 QStringList itemList; 398 QStringList itemList;
398 QPtrList<KOListViewItem> sel ; 399 QPtrList<KOListViewItem> sel ;
399 QListViewItem *qitem = mListView->firstChild (); 400 QListViewItem *qitem = mListView->firstChild ();
400 while ( qitem ) { 401 while ( qitem ) {
401 if ( qitem->isSelected() ) { 402 if ( qitem->isSelected() ) {
402 Incidence* inc = ((KOListViewItem *) qitem)->data(); 403 Incidence* inc = ((KOListViewItem *) qitem)->data();
403 if ( inc->typeID() != journalID ) { 404 if ( inc->typeID() != journalID ) {
404 if ( inc->typeID() == todoID ) { 405 if ( inc->typeID() == todoID ) {
405 if ( ((Todo*)inc)->hasDueDate() ) 406 if ( ((Todo*)inc)->hasDueDate() )
406 sel.append(((KOListViewItem *)qitem)); 407 sel.append(((KOListViewItem *)qitem));
407 } else 408 } else
408 sel.append(((KOListViewItem *)qitem)); 409 sel.append(((KOListViewItem *)qitem));
409 } 410 }
410 } 411 }
411 qitem = qitem->nextSibling(); 412 qitem = qitem->nextSibling();
412 } 413 }
413 int count = 0; 414 int count = 0;
414 KOListViewItem * item, *temp; 415 KOListViewItem * item, *temp;
415 item = sel.first(); 416 item = sel.first();
416 Incidence* inc; 417 Incidence* inc;
417 while ( item ) { 418 while ( item ) {
418 inc = item->data(); 419 inc = item->data();
419 ++count; 420 ++count;
420 if (kap.mAlarmButton->isChecked()) { 421 if (kap.mAlarmButton->isChecked()) {
421 if (inc->alarms().count() == 0) 422 if (inc->alarms().count() == 0)
422 inc->newAlarm(); 423 inc->newAlarm();
423 QPtrList<Alarm> alarms = inc->alarms(); 424 QPtrList<Alarm> alarms = inc->alarms();
424 Alarm *alarm; 425 Alarm *alarm;
425 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 426 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
426 alarm->setEnabled(true); 427 alarm->setEnabled(true);
427 int j = kap.mAlarmTimeEdit->value()* -60; 428 int j = kap.mAlarmTimeEdit->value()* -60;
428 if (kap.mAlarmIncrCombo->currentItem() == 1) 429 if (kap.mAlarmIncrCombo->currentItem() == 1)
429 j = j * 60; 430 j = j * 60;
430 else if (kap.mAlarmIncrCombo->currentItem() == 2) 431 else if (kap.mAlarmIncrCombo->currentItem() == 2)
431 j = j * (60 * 24); 432 j = j * (60 * 24);
432 alarm->setStartOffset( j ); 433 alarm->setStartOffset( j );
433 434
434 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) { 435 if (!kap.mAlarmProgram.isEmpty() && kap.mAlarmProgramButton->isOn()) {
435 alarm->setProcedureAlarm(kap.mAlarmProgram); 436 alarm->setProcedureAlarm(kap.mAlarmProgram);
436 } 437 }
437 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn()) 438 else if (!kap.mAlarmSound.isEmpty() && kap.mAlarmSoundButton->isOn())
438 alarm->setAudioAlarm(kap.mAlarmSound); 439 alarm->setAudioAlarm(kap.mAlarmSound);
439 else 440 else
@@ -469,380 +470,371 @@ void KOListView::setCategories( bool removeOld )
469 } 470 }
470 QStringList catList = csd->selectedCategories(); 471 QStringList catList = csd->selectedCategories();
471 delete csd; 472 delete csd;
472 // if ( catList.count() == 0 ) 473 // if ( catList.count() == 0 )
473 // return; 474 // return;
474 //catList.sort(); 475 //catList.sort();
475 QString categoriesStr = catList.join(","); 476 QString categoriesStr = catList.join(",");
476 int i; 477 int i;
477 QStringList itemList; 478 QStringList itemList;
478 QPtrList<KOListViewItem> sel ; 479 QPtrList<KOListViewItem> sel ;
479 QListViewItem *qitem = mListView->firstChild (); 480 QListViewItem *qitem = mListView->firstChild ();
480 while ( qitem ) { 481 while ( qitem ) {
481 if ( qitem->isSelected() ) { 482 if ( qitem->isSelected() ) {
482 sel.append(((KOListViewItem *)qitem)); 483 sel.append(((KOListViewItem *)qitem));
483 } 484 }
484 qitem = qitem->nextSibling(); 485 qitem = qitem->nextSibling();
485 } 486 }
486 KOListViewItem * item, *temp; 487 KOListViewItem * item, *temp;
487 item = sel.first(); 488 item = sel.first();
488 if( item ) { 489 if( item ) {
489 Incidence* inc = item->data() ; 490 Incidence* inc = item->data() ;
490 bool setSub = false; 491 bool setSub = false;
491 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) { 492 if( inc->typeID() == todoID && sel.count() == 1 && inc->relations().count() > 0 ) {
492 int result = KMessageBox::warningYesNoCancel(this, 493 int result = KMessageBox::warningYesNoCancel(this,
493 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ), 494 i18n("The todo\n%1\nhas subtodos!\nDo you want to set\nthe categories for\nall subtodos as well?").arg( inc->summary().left ( 25 ) ),
494 i18n("Todo has subtodos"), 495 i18n("Todo has subtodos"),
495 i18n("Yes"), 496 i18n("Yes"),
496 i18n("No")); 497 i18n("No"));
497 if (result == KMessageBox::Cancel) item = 0; 498 if (result == KMessageBox::Cancel) item = 0;
498 if (result == KMessageBox::Yes) setSub = true; 499 if (result == KMessageBox::Yes) setSub = true;
499 } 500 }
500 while ( item ) { 501 while ( item ) {
501 inc = item->data(); 502 inc = item->data();
502 if ( removeOld ) { 503 if ( removeOld ) {
503 inc->setCategories( catList, setSub ); 504 inc->setCategories( catList, setSub );
504 } else { 505 } else {
505 inc->addCategories( catList, setSub ); 506 inc->addCategories( catList, setSub );
506 } 507 }
507 ListItemVisitor v(item, mStartDate ); 508 ListItemVisitor v(item, mStartDate );
508 inc->accept(v); 509 inc->accept(v);
509 item = sel.next(); 510 item = sel.next();
510 } 511 }
511 } 512 }
512 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 513 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
513} 514}
514 515
515void KOListView::beamSelected() 516void KOListView::beamSelected()
516{ 517{
517 int icount = 0; 518 QPtrList<Incidence> delSel = getSelectedIncidences() ;
518 QPtrList<Incidence> delSel ; 519 int icount = delSel.count();
519 QListViewItem *item = mListView->firstChild ();
520 while ( item ) {
521 if ( item->isSelected() ) {
522 delSel.append(((KOListViewItem *)item)->data());
523 ++icount;
524 }
525
526 item = item->nextSibling();
527 }
528 if ( icount ) { 520 if ( icount ) {
529 emit beamIncidenceList( delSel ); 521 emit beamIncidenceList( delSel );
530 return; 522 return;
531 QString fn ; 523 QString fn ;
532 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs"; 524 fn = QDir::homeDirPath()+"/kopitempbeamfile.vcs";
533 QString mes; 525 QString mes;
534 bool createbup = true; 526 bool createbup = true;
535 if ( createbup ) { 527 if ( createbup ) {
536 QString description = "\n"; 528 QString description = "\n";
537 CalendarLocal* cal = new CalendarLocal(); 529 CalendarLocal* cal = new CalendarLocal();
538 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 530 cal->setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
539 Incidence *incidence = delSel.first(); 531 Incidence *incidence = delSel.first();
540 while ( incidence ) { 532 while ( incidence ) {
541 Incidence *in = incidence->clone(); 533 Incidence *in = incidence->clone();
542 description += in->summary() + "\n"; 534 description += in->summary() + "\n";
543 cal->addIncidence( in ); 535 cal->addIncidence( in );
544 incidence = delSel.next(); 536 incidence = delSel.next();
545 } 537 }
546 FileStorage storage( cal, fn, new VCalFormat ); 538 FileStorage storage( cal, fn, new VCalFormat );
547 storage.save(); 539 storage.save();
548 delete cal; 540 delete cal;
549 mes = i18n("KO/Pi: Ready for beaming"); 541 mes = i18n("KO/Pi: Ready for beaming");
550 topLevelWidget()->setCaption(mes); 542 topLevelWidget()->setCaption(mes);
551 543
552#ifndef DESKTOP_VERSION 544#ifndef DESKTOP_VERSION
553 Ir *ir = new Ir( this ); 545 Ir *ir = new Ir( this );
554 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); 546 connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) );
555 ir->send( fn, description, "text/x-vCalendar" ); 547 ir->send( fn, description, "text/x-vCalendar" );
556#endif 548#endif
557 } 549 }
558 } 550 }
559} 551}
560void KOListView::beamDone( Ir *ir ) 552void KOListView::beamDone( Ir *ir )
561{ 553{
562#ifndef DESKTOP_VERSION 554#ifndef DESKTOP_VERSION
563 delete ir; 555 delete ir;
564#endif 556#endif
565 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done")); 557 topLevelWidget()->setCaption(i18n("KO/Pi:Beaming done"));
566} 558}
567 559
568void KOListView::saveDescriptionToFile() 560void KOListView::saveDescriptionToFile()
569{ 561{
570 562
571 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"), 563 int result = QMessageBox::warning( this, i18n("KO/Pi: Information!"),
572 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."), 564 i18n("This saves the text/details of selected\nJournals and Events/Todos\nto a text file."),
573 i18n("Continue"), i18n("Cancel"), 0, 565 i18n("Continue"), i18n("Cancel"), 0,
574 0, 1 ); 566 0, 1 );
575 if ( result != 0 ) { 567 if ( result != 0 ) {
576 return; 568 return;
577 } 569 }
578 int icount = 0; 570 QPtrList<Incidence> delSel = getSelectedIncidences() ;
579 QPtrList<Incidence> delSel ; 571 int icount = delSel.count();
580 QListViewItem *item = mListView->firstChild ();
581 while ( item ) {
582 if ( item->isSelected() ) {
583 delSel.append(((KOListViewItem *)item)->data());
584 ++icount;
585 }
586
587 item = item->nextSibling();
588 }
589 if ( icount ) { 572 if ( icount ) {
590 QString fn = KOPrefs::instance()->mLastSaveFile; 573 QString fn = KOPrefs::instance()->mLastSaveFile;
591 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 574 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
592 575
593 if ( fn == "" ) 576 if ( fn == "" )
594 return; 577 return;
595 QFileInfo info; 578 QFileInfo info;
596 info.setFile( fn ); 579 info.setFile( fn );
597 QString mes; 580 QString mes;
598 bool createbup = true; 581 bool createbup = true;
599 if ( info. exists() ) { 582 if ( info. exists() ) {
600 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 583 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
601 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 584 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
602 i18n("Overwrite!"), i18n("Cancel"), 0, 585 i18n("Overwrite!"), i18n("Cancel"), 0,
603 0, 1 ); 586 0, 1 );
604 if ( result != 0 ) { 587 if ( result != 0 ) {
605 createbup = false; 588 createbup = false;
606 } 589 }
607 } 590 }
608 if ( createbup ) { 591 if ( createbup ) {
609 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") + 592 QString text = i18n("KO/Pi Description/Journal save file.\nSave date: ") +
610 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false); 593 KGlobal::locale()->formatDateTime(QDateTime::currentDateTime(), false);
611 Incidence *incidence = delSel.first(); 594 Incidence *incidence = delSel.first();
612 icount = 0; 595 icount = 0;
613 while ( incidence ) { 596 while ( incidence ) {
614 if ( incidence->typeID() == journalID ) { 597 if ( incidence->typeID() == journalID ) {
615 text += "\n************************************\n"; 598 text += "\n************************************\n";
616 text += i18n("Journal from: ") +incidence->dtStartDateStr( false ); 599 text += i18n("Journal from: ") +incidence->dtStartDateStr( false );
617 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 600 text +="\n" + i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
618 text +="\n" + i18n("Description: ") + "\n"+ incidence->description(); 601 text +="\n" + i18n("Description: ") + "\n"+ incidence->description();
619 ++icount; 602 ++icount;
620 603
621 } else { 604 } else {
622 if ( !incidence->description().isEmpty() ) { 605 if ( !incidence->description().isEmpty() ) {
623 text += "\n************************************\n"; 606 text += "\n************************************\n";
624 if ( incidence->typeID() == todoID ) 607 if ( incidence->typeID() == todoID )
625 text += i18n("To-Do: "); 608 text += i18n("To-Do: ");
626 text += incidence->summary(); 609 text += incidence->summary();
627 if ( incidence->hasStartDate() ) 610 if ( incidence->hasStartDate() )
628 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false ); 611 text +="\n"+ i18n("Start Date: ") + incidence->dtStartStr( false );
629 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false); 612 text +="\n"+ i18n("Last modified: ") +KGlobal::locale()->formatDateTime(incidence->lastModified(), false);
630 if ( !incidence->location().isEmpty() ) 613 if ( !incidence->location().isEmpty() )
631 text += "\n" +i18n("Location: ") + incidence->location(); 614 text += "\n" +i18n("Location: ") + incidence->location();
632 text += "\n" + i18n("Description: ") + "\n" + incidence->description(); 615 text += "\n" + i18n("Description: ") + "\n" + incidence->description();
633 ++icount; 616 ++icount;
634 617
635 } 618 }
636 } 619 }
637 incidence = delSel.next(); 620 incidence = delSel.next();
638 } 621 }
639 QFile file( fn ); 622 QFile file( fn );
640 if (!file.open( IO_WriteOnly ) ) { 623 if (!file.open( IO_WriteOnly ) ) {
641 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") ); 624 topLevelWidget()->setCaption(i18n("File open error - nothing saved!") );
642 return; 625 return;
643 } 626 }
644 QTextStream ts( &file ); 627 QTextStream ts( &file );
645 ts << text; 628 ts << text;
646 file.close(); 629 file.close();
647 //qDebug("%s ", text.latin1()); 630 //qDebug("%s ", text.latin1());
648 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount ); 631 mes = i18n("KO/Pi:Saved %1 descriptions/journals").arg(icount );
649 KOPrefs::instance()->mLastSaveFile = fn; 632 KOPrefs::instance()->mLastSaveFile = fn;
650 topLevelWidget()->setCaption(mes); 633 topLevelWidget()->setCaption(mes);
651 } 634 }
652 } 635 }
653} 636}
654void KOListView::saveToFileVCS() 637void KOListView::saveToFileVCS()
655{ 638{
656 writeToFile( false ); 639 writeToFile( false );
657} 640}
658void KOListView::saveToFile() 641void KOListView::saveToFile()
659{ 642{
660 writeToFile( true ); 643 writeToFile( true );
661} 644}
662void KOListView::writeToFile( bool iCal ) 645QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents, bool includeTodos, bool includeJournals, bool onlyDueTodos )
663{ 646{
664
665 int icount = 0;
666 QPtrList<Incidence> delSel ; 647 QPtrList<Incidence> delSel ;
667 QListViewItem *item = mListView->firstChild ();
668 bool journal = iCal; // warn only for vCal
669 bool addSubTodos = false; 648 bool addSubTodos = false;
670 bool askSubTodos = true; 649 bool askSubTodos = true;
650 QListViewItem *item = mListView->firstChild ();
671 while ( item ) { 651 while ( item ) {
672 if ( item->isSelected() ) { 652 if ( item->isSelected() ) {
673 if ( !journal )
674 if ( ((KOListViewItem *)item)->data()->typeID() == journalID )
675 journal = true;
676 Incidence* inc = ((KOListViewItem *)item)->data(); 653 Incidence* inc = ((KOListViewItem *)item)->data();
677 if ( addSubTodos ) { 654 if ( ( addSubTodos && delSel.findRef( inc ) == -1) || !addSubTodos ) {
678 if ( delSel.findRef( inc ) == -1 ) 655 if ( (inc->typeID() == todoID && includeTodos) ||
679 delSel.append( inc ); 656 (inc->typeID() == eventID && includeEvents) ||
680 } else 657 (inc->typeID() == journalID && includeJournals) ) {
681 delSel.append(inc); 658 if ( inc->typeID() == todoID && onlyDueTodos ) {
659 if ( ((Todo*)inc)->hasDueDate() )
660 delSel.append( inc );
661 } else
662 delSel.append( inc );
663
664 }
665 }
682 if ( inc->typeID() == todoID ) { 666 if ( inc->typeID() == todoID ) {
683 Todo * todo = (Todo*) inc; 667 Todo * todo = (Todo*) inc;
684 if ( todo->relations().count() ) { 668 if ( todo->relations().count() ) {
685 if ( askSubTodos ) { 669 if ( askSubTodos ) {
686 int result = KMessageBox::warningYesNoCancel(this, 670 int result = KMessageBox::warningYesNoCancel(this,
687 i18n("A selected todo has subtodos!\nDo you want to export\nall subtodos of all\nselected todos as well?"), 671 i18n("One (or more) selected\ntodo has subtodos!\nDo you want to select\nall subtodos of all\nselected todos as well?"),
688 i18n("Todo has subtodos"), 672 i18n("Todo has subtodos"),
689 i18n("Yes"), 673 i18n("Yes"),
690 i18n("No")); 674 i18n("No"));
691 if ( result == KMessageBox::Cancel ) { 675 if ( result == KMessageBox::Cancel ) {
692 return; 676 delSel.clear();
677 return delSel;
693 } 678 }
694 if (result == KMessageBox::Yes) 679 if (result == KMessageBox::Yes)
695 addSubTodos = true; 680 addSubTodos = true;
696 askSubTodos = false; 681 askSubTodos = false;
697 } 682 }
698 if ( addSubTodos ) { 683 if ( addSubTodos ) {
699 inc->addRelationsToList( &delSel ); 684 inc->addRelationsToList( &delSel );
700 } 685 }
701 } 686 }
702 } 687 }
703 ++icount;
704 } 688 }
705 item = item->nextSibling(); 689 item = item->nextSibling();
706 } 690 }
707 if ( !iCal && journal ) { 691 return delSel;
708 int result = KMessageBox::warningContinueCancel(this, 692}
709 i18n("The journal entries can not be\nexported to a vCalendar file."), 693
710 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"), 694void KOListView::writeToFile( bool iCal )
711 true); 695{
712 if (result != KMessageBox::Continue) return; 696 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;
697 if ( !iCal ) {
698 bool journal = false;
699 Incidence *incidence = delSel.first();
700 while ( incidence ) {
701 if ( incidence->typeID() == journalID ) {
702 journal = true;
703 break;
704 }
705 incidence = delSel.next();
706 }
707 if ( journal ) {
708 int result = KMessageBox::warningContinueCancel(this,
709 i18n("The journal entries can not be\nexported to a vCalendar file."),
710 i18n("Data Loss Warning"),i18n("Proceed"),i18n("Cancel"),
711 true);
712 if (result != KMessageBox::Continue) return;
713 }
713 } 714 }
714 if ( icount ) { 715 if ( delSel.count() ) {
715 QString fn = KOPrefs::instance()->mLastSaveFile; 716 QString fn = KOPrefs::instance()->mLastSaveFile;
716 QString extension; 717 QString extension;
717 if ( iCal ) { 718 if ( iCal ) {
718 if ( fn.right( 4 ).lower() == ".vcs" ) { 719 if ( fn.right( 4 ).lower() == ".vcs" ) {
719 fn = fn.left( fn.length() -3) + "ics"; 720 fn = fn.left( fn.length() -3) + "ics";
720 } 721 }
721 } else { 722 } else {
722 if ( fn.right( 4 ).lower() == ".ics" ) { 723 if ( fn.right( 4 ).lower() == ".ics" ) {
723 fn = fn.left( fn.length() -3) + "vcs"; 724 fn = fn.left( fn.length() -3) + "vcs";
724 } 725 }
725 } 726 }
726 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this ); 727 fn = KFileDialog::getSaveFileName( fn, i18n("Save filename"), this );
727 728
728 if ( fn == "" ) 729 if ( fn == "" )
729 return; 730 return;
730 QFileInfo info; 731 QFileInfo info;
731 info.setFile( fn ); 732 info.setFile( fn );
732 QString mes; 733 QString mes;
733 bool createbup = true; 734 bool createbup = true;
734 if ( info. exists() ) { 735 if ( info. exists() ) {
735 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); 736 mes = i18n("File already exists!\nOld file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) );
736 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, 737 int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes,
737 i18n("Overwrite!"), i18n("Cancel"), 0, 738 i18n("Overwrite!"), i18n("Cancel"), 0,
738 0, 1 ); 739 0, 1 );
739 if ( result != 0 ) { 740 if ( result != 0 ) {
740 createbup = false; 741 createbup = false;
741 } 742 }
742 } 743 }
743 if ( createbup ) { 744 if ( createbup ) {
744 CalendarLocal cal; 745 CalendarLocal cal;
745 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId); 746 cal.setTimeZoneId(KPimGlobalPrefs::instance()->mTimeZoneId);
746 Incidence *incidence = delSel.first(); 747 Incidence *incidence = delSel.first();
747 while ( incidence ) { 748 while ( incidence ) {
748 cal.addIncidence( incidence->clone() ); 749 cal.addIncidence( incidence->clone() );
749 incidence = delSel.next(); 750 incidence = delSel.next();
750 } 751 }
751 if ( iCal ) { 752 if ( iCal ) {
752 ICalFormat format; 753 ICalFormat format;
753 format.save( &cal, fn ); 754 format.save( &cal, fn );
754 } else { 755 } else {
755 756
756 VCalFormat format; 757 VCalFormat format;
757 format.save( &cal, fn ); 758 format.save( &cal, fn );
758 } 759 }
759 mes = i18n("KO/Pi:Saved %1").arg(fn ); 760 mes = i18n("KO/Pi:Saved %1").arg(fn );
760 KOPrefs::instance()->mLastSaveFile = fn; 761 KOPrefs::instance()->mLastSaveFile = fn;
761 topLevelWidget()->setCaption(mes); 762 topLevelWidget()->setCaption(mes);
762 } 763 }
763 } 764 }
764 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) ); 765 QTimer::singleShot( 1, this, SLOT ( resetFocus() ) );
765} 766}
766void KOListView::hideAll() 767void KOListView::hideAll()
767{ 768{
768 QPtrList<QListViewItem> delSel ; 769 QPtrList<QListViewItem> delSel ;
769 QListViewItem *item = mListView->firstChild (); 770 QListViewItem *item = mListView->firstChild ();
770 while ( item ) { 771 while ( item ) {
771 if ( item->isSelected() ) { 772 if ( item->isSelected() ) {
772 delSel.append(item); 773 delSel.append(item);
773 } 774 }
774 item = item->nextSibling(); 775 item = item->nextSibling();
775 } 776 }
776 item = delSel.first() ; 777 item = delSel.first() ;
777 while ( item ) { 778 while ( item ) {
778 QListViewItem * del = item; 779 QListViewItem * del = item;
779 item = delSel.next(); 780 item = delSel.next();
780 delete del; 781 delete del;
781 } 782 }
782} 783}
783void KOListView::printList() 784void KOListView::printList()
784{ 785{
785 mListView->printList(); 786 mListView->printList();
786} 787}
787void KOListView::deleteAll() 788void KOListView::deleteAll()
788{ 789{
789 int icount = 0; 790 QPtrList<Incidence> delSel = getSelectedIncidences(); // all inc allowed;;
790 QPtrList<Incidence> delSel ; 791 if ( delSel.count() ) {
791 QListViewItem *item = mListView->firstChild (); 792 int icount = delSel.count();
792 while ( item ) {
793 if ( item->isSelected() ) {
794 delSel.append(((KOListViewItem *)item)->data());
795 ++icount;
796 }
797
798 item = item->nextSibling();
799 }
800 if ( icount ) {
801 Incidence *incidence = delSel.first(); 793 Incidence *incidence = delSel.first();
802 Incidence *toDelete; 794 Incidence *toDelete;
803 KOPrefs *p = KOPrefs::instance(); 795 KOPrefs *p = KOPrefs::instance();
804 bool confirm = p->mConfirm; 796 bool confirm = p->mConfirm;
805 QString mess; 797 QString mess;
806 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount ); 798 mess = mess.sprintf( i18n("You have %d item(s) selected.\n"), icount );
807 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) { 799 if ( KMessageBox::Continue == KMessageBox::warningContinueCancel(this, mess + i18n("All selected items will be\npermanently deleted.\n(Deleting items will take\nsome time on a PDA)\n"), i18n("KO/Pi Confirmation"),i18n("Delete")) ) {
808 p->mConfirm = false; 800 p->mConfirm = false;
809 int delCounter = 0; 801 int delCounter = 0;
810 QDialog dia ( this, "p-dialog", true ); 802 QDialog dia ( this, "p-dialog", true );
811 QLabel lab (i18n("Close dialog to abort deletion!"), &dia ); 803 QLabel lab (i18n("Close dialog to abort deletion!"), &dia );
812 QVBoxLayout lay( &dia ); 804 QVBoxLayout lay( &dia );
813 lay.setMargin(7); 805 lay.setMargin(7);
814 lay.setSpacing(7); 806 lay.setSpacing(7);
815 lay.addWidget( &lab); 807 lay.addWidget( &lab);
816 QProgressBar bar( icount, &dia ); 808 QProgressBar bar( icount, &dia );
817 lay.addWidget( &bar); 809 lay.addWidget( &bar);
818 int w = 220; 810 int w = 220;
819 int h = 50; 811 int h = 50;
820 int dw = QApplication::desktop()->width(); 812 int dw = QApplication::desktop()->width();
821 int dh = QApplication::desktop()->height(); 813 int dh = QApplication::desktop()->height();
822 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 814 dia.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
823 //dia.resize( 240,50 ); 815 //dia.resize( 240,50 );
824 dia.show(); 816 dia.show();
825 817
826 while ( incidence ) { 818 while ( incidence ) {
827 bar.setProgress( delCounter ); 819 bar.setProgress( delCounter );
828 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter ); 820 mess = mess.sprintf( i18n("Deleting item %d ..."), ++delCounter );
829 dia.setCaption( mess ); 821 dia.setCaption( mess );
830 qApp->processEvents(); 822 qApp->processEvents();
831 toDelete = (incidence); 823 toDelete = (incidence);
832 incidence = delSel.next(); 824 incidence = delSel.next();
833 emit deleteIncidenceSignal(toDelete ); 825 emit deleteIncidenceSignal(toDelete );
834 if ( dia.result() != 0 ) 826 if ( dia.result() != 0 )
835 break; 827 break;
836 828
837 } 829 }
838 mess = mess.sprintf( i18n("%d items remaining in list."), count() ); 830 mess = mess.sprintf( i18n("%d items remaining in list."), count() );
839 topLevelWidget ()->setCaption( mess ); 831 topLevelWidget ()->setCaption( mess );
840 p->mConfirm = confirm; 832 p->mConfirm = confirm;
841 } 833 }
842 } 834 }
843 835
844 836
845} 837}
846int KOListView::maxDatesHint() 838int KOListView::maxDatesHint()
847{ 839{
848 return 0; 840 return 0;
diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h
index c25592d..9da5497 100644
--- a/korganizer/kolistview.h
+++ b/korganizer/kolistview.h
@@ -217,96 +217,97 @@ class KOListViewListView : public KListView
217 KOListViewListView(KOListView * lv ); 217 KOListViewListView(KOListView * lv );
218 bool hasMultiSelection(QListViewItem*); 218 bool hasMultiSelection(QListViewItem*);
219 void printList(); 219 void printList();
220 signals: 220 signals:
221 void newEvent(); 221 void newEvent();
222 void showIncidence( Incidence* ); 222 void showIncidence( Incidence* );
223 public slots: 223 public slots:
224 void popupMenu(); 224 void popupMenu();
225 private: 225 private:
226 QPoint mEventPos; 226 QPoint mEventPos;
227 QPoint mEventGlobalPos; 227 QPoint mEventGlobalPos;
228 QTimer* mPopupTimer; 228 QTimer* mPopupTimer;
229 int mYMousePos; 229 int mYMousePos;
230 void keyPressEvent ( QKeyEvent * ) ; 230 void keyPressEvent ( QKeyEvent * ) ;
231 void contentsMouseDoubleClickEvent(QMouseEvent *e); 231 void contentsMouseDoubleClickEvent(QMouseEvent *e);
232 void contentsMousePressEvent(QMouseEvent *e); 232 void contentsMousePressEvent(QMouseEvent *e);
233 void contentsMouseReleaseEvent(QMouseEvent *e); 233 void contentsMouseReleaseEvent(QMouseEvent *e);
234 void contentsMouseMoveEvent(QMouseEvent *e); 234 void contentsMouseMoveEvent(QMouseEvent *e);
235 bool mMouseDown; 235 bool mMouseDown;
236}; 236};
237 237
238class KOListView : public KOEventView 238class KOListView : public KOEventView
239{ 239{
240 Q_OBJECT 240 Q_OBJECT
241 public: 241 public:
242 KOListView(Calendar *calendar, QWidget *parent = 0, 242 KOListView(Calendar *calendar, QWidget *parent = 0,
243 const char *name = 0); 243 const char *name = 0);
244 ~KOListView(); 244 ~KOListView();
245 245
246 virtual int maxDatesHint(); 246 virtual int maxDatesHint();
247 virtual int currentDateCount(); 247 virtual int currentDateCount();
248 virtual QPtrList<Incidence> selectedIncidences(); 248 virtual QPtrList<Incidence> selectedIncidences();
249 virtual DateList selectedDates(); 249 virtual DateList selectedDates();
250 250
251 void showDates(bool show); 251 void showDates(bool show);
252 Incidence* currentItem(); 252 Incidence* currentItem();
253 void addTodos(QPtrList<Todo> eventList); 253 void addTodos(QPtrList<Todo> eventList);
254 void addJournals(QPtrList<Journal> eventList); 254 void addJournals(QPtrList<Journal> eventList);
255 virtual void printPreview(CalPrinter *calPrinter, 255 virtual void printPreview(CalPrinter *calPrinter,
256 const QDate &, const QDate &); 256 const QDate &, const QDate &);
257 257
258 void readSettings(KConfig *config, QString setting = "KOListView Layout"); 258 void readSettings(KConfig *config, QString setting = "KOListView Layout");
259 void writeSettings(KConfig *config, QString setting = "KOListView Layout"); 259 void writeSettings(KConfig *config, QString setting = "KOListView Layout");
260 void updateList(); 260 void updateList();
261 void clearList(); 261 void clearList();
262 void setStartDate(const QDate &start); 262 void setStartDate(const QDate &start);
263 int count(); 263 int count();
264 QString getWhatsThisText(QPoint p); 264 QString getWhatsThisText(QPoint p);
265 QPtrList<Incidence> KOListView::getSelectedIncidences( bool includeEvents = true, bool includeTodos = true , bool includeJournals = true, bool onlyDueTodos = false );
265 signals: 266 signals:
266 void signalNewEvent(); 267 void signalNewEvent();
267 void beamIncidenceList(QPtrList<Incidence>); 268 void beamIncidenceList(QPtrList<Incidence>);
268 269
269 public slots: 270 public slots:
270 void hideAll(); 271 void hideAll();
271 void printList(); 272 void printList();
272 void resetFocus(); 273 void resetFocus();
273 virtual void updateView(); 274 virtual void updateView();
274 virtual void showDates(const QDate &start, const QDate &end); 275 virtual void showDates(const QDate &start, const QDate &end);
275 virtual void showEvents(QPtrList<Event> eventList); 276 virtual void showEvents(QPtrList<Event> eventList);
276 void clearSelection(); 277 void clearSelection();
277 void allSelection(); 278 void allSelection();
278 279
279 void clear(); 280 void clear();
280 void beamDone( Ir *ir ); 281 void beamDone( Ir *ir );
281 void showDates(); 282 void showDates();
282 void hideDates(); 283 void hideDates();
283 void deleteAll(); 284 void deleteAll();
284 void saveToFile(); 285 void saveToFile();
285 void saveToFileVCS(); 286 void saveToFileVCS();
286 void saveDescriptionToFile(); 287 void saveDescriptionToFile();
287 void beamSelected(); 288 void beamSelected();
288 void updateConfig(); 289 void updateConfig();
289 void addCat(); 290 void addCat();
290 void setCat(); 291 void setCat();
291 void setAlarm(); 292 void setAlarm();
292 void setCategories( bool removeOld ); 293 void setCategories( bool removeOld );
293 void changeEventDisplay(Event *, int); 294 void changeEventDisplay(Event *, int);
294 295
295 void defaultItemAction(QListViewItem *item); 296 void defaultItemAction(QListViewItem *item);
296 void popupMenu(QListViewItem *item,const QPoint &,int); 297 void popupMenu(QListViewItem *item,const QPoint &,int);
297 298
298 protected slots: 299 protected slots:
299 void processSelectionChange(QListViewItem *); 300 void processSelectionChange(QListViewItem *);
300 301
301 protected: 302 protected:
302 void writeToFile( bool iCal ); 303 void writeToFile( bool iCal );
303 void addEvents(QPtrList<Event> eventList); 304 void addEvents(QPtrList<Event> eventList);
304 void addIncidence(Incidence *); 305 void addIncidence(Incidence *);
305 KOListViewItem *getItemForEvent(Event *event); 306 KOListViewItem *getItemForEvent(Event *event);
306 307
307 private: 308 private:
308 KOListViewWhatsThis *mKOListViewWhatsThis; 309 KOListViewWhatsThis *mKOListViewWhatsThis;
309 KOListViewListView *mListView; 310 KOListViewListView *mListView;
310 KOEventPopupMenu *mPopupMenu; 311 KOEventPopupMenu *mPopupMenu;
311 KOListViewItem *mActiveItem; 312 KOListViewItem *mActiveItem;
312 QDict<Incidence> mUidDict; 313 QDict<Incidence> mUidDict;