-rw-r--r-- | core/pim/todo/mainwindow.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/pim/todo/mainwindow.cpp b/core/pim/todo/mainwindow.cpp index 924fde1..2002e87 100644 --- a/core/pim/todo/mainwindow.cpp +++ b/core/pim/todo/mainwindow.cpp | |||
@@ -401,641 +401,642 @@ void MainWindow::closeEvent( QCloseEvent* e ) { | |||
401 | config.writeEntry( "ShowDeadLine", showDeadline()); | 401 | config.writeEntry( "ShowDeadLine", showDeadline()); |
402 | config.writeEntry( "ShowOverDue", showOverDue() ); | 402 | config.writeEntry( "ShowOverDue", showOverDue() ); |
403 | config.writeEntry( "ShowQuickTask", showQuickTask() ); | 403 | config.writeEntry( "ShowQuickTask", showQuickTask() ); |
404 | /* save templates */ | 404 | /* save templates */ |
405 | templateManager()->save(); | 405 | templateManager()->save(); |
406 | e->accept(); | 406 | e->accept(); |
407 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); | 407 | QTimer::singleShot(0, qApp, SLOT(closeAllWindows()) ); |
408 | } | 408 | } |
409 | } | 409 | } |
410 | void MainWindow::populateTemplates() { | 410 | void MainWindow::populateTemplates() { |
411 | m_template->clear(); | 411 | m_template->clear(); |
412 | QStringList list = templateManager()->templates(); | 412 | QStringList list = templateManager()->templates(); |
413 | QStringList::Iterator it; | 413 | QStringList::Iterator it; |
414 | for ( it = list.begin(); it != list.end(); ++it ) { | 414 | for ( it = list.begin(); it != list.end(); ++it ) { |
415 | m_template->insertItem( (*it) ); | 415 | m_template->insertItem( (*it) ); |
416 | } | 416 | } |
417 | } | 417 | } |
418 | /* | 418 | /* |
419 | * slotNewFromTemplate | 419 | * slotNewFromTemplate |
420 | * We use the edit widget to do | 420 | * We use the edit widget to do |
421 | * the config but we setUid(1) | 421 | * the config but we setUid(1) |
422 | * to get a new uid | 422 | * to get a new uid |
423 | */ | 423 | */ |
424 | /* | 424 | /* |
425 | * first we get the name of the template | 425 | * first we get the name of the template |
426 | * then we will use the TemplateManager | 426 | * then we will use the TemplateManager |
427 | */ | 427 | */ |
428 | void MainWindow::slotNewFromTemplate( int id ) { | 428 | void MainWindow::slotNewFromTemplate( int id ) { |
429 | QString name = m_template->text( id ); | 429 | QString name = m_template->text( id ); |
430 | 430 | ||
431 | OPimTodo event = templateManager()->templateEvent( name ); | 431 | OPimTodo event = templateManager()->templateEvent( name ); |
432 | event = currentEditor()->edit(this, | 432 | event = currentEditor()->edit(this, |
433 | event ); | 433 | event ); |
434 | 434 | ||
435 | if ( currentEditor()->accepted() ) { | 435 | if ( currentEditor()->accepted() ) { |
436 | /* assign new todo */ | 436 | /* assign new todo */ |
437 | event.setUid( 1 ); | 437 | event.setUid( 1 ); |
438 | handleAlarms( OPimTodo(), event ); | 438 | handleAlarms( OPimTodo(), event ); |
439 | m_todoMgr.add( event ); | 439 | m_todoMgr.add( event ); |
440 | currentView()->addEvent( event ); | 440 | currentView()->addEvent( event ); |
441 | 441 | ||
442 | populateCategories(); | 442 | populateCategories(); |
443 | } | 443 | } |
444 | raiseCurrentView(); | 444 | raiseCurrentView(); |
445 | } | 445 | } |
446 | void MainWindow::slotNew() { | 446 | void MainWindow::slotNew() { |
447 | create(); | 447 | create(); |
448 | } | 448 | } |
449 | void MainWindow::slotDuplicate() { | 449 | void MainWindow::slotDuplicate() { |
450 | if(m_syncing) { | 450 | if(m_syncing) { |
451 | QMessageBox::warning(this, QWidget::tr("Todo"), | 451 | QMessageBox::warning(this, QWidget::tr("Todo"), |
452 | QWidget::tr("Data can not be edited, currently syncing")); | 452 | QWidget::tr("Data can not be edited, currently syncing")); |
453 | return; | 453 | return; |
454 | } | 454 | } |
455 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); | 455 | OPimTodo ev = m_todoMgr.event( currentView()->current() ); |
456 | /* let's generate a new uid */ | 456 | /* let's generate a new uid */ |
457 | ev.setUid(1); | 457 | ev.setUid(1); |
458 | m_todoMgr.add( ev ); | 458 | m_todoMgr.add( ev ); |
459 | 459 | ||
460 | currentView()->addEvent( ev ); | 460 | currentView()->addEvent( ev ); |
461 | raiseCurrentView(); | 461 | raiseCurrentView(); |
462 | } | 462 | } |
463 | void MainWindow::slotDelete() { | 463 | void MainWindow::slotDelete() { |
464 | if (!currentView()->current() ) | 464 | if (!currentView()->current() ) |
465 | return; | 465 | return; |
466 | 466 | ||
467 | if(m_syncing) { | 467 | if(m_syncing) { |
468 | QMessageBox::warning(this, QWidget::tr("Todo"), | 468 | QMessageBox::warning(this, QWidget::tr("Todo"), |
469 | QWidget::tr("Data can not be edited, currently syncing")); | 469 | QWidget::tr("Data can not be edited, currently syncing")); |
470 | return; | 470 | return; |
471 | } | 471 | } |
472 | QString strName = currentView()->currentRepresentation(); | 472 | QString strName = currentView()->currentRepresentation(); |
473 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) | 473 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), strName ) ) |
474 | return; | 474 | return; |
475 | 475 | ||
476 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); | 476 | handleAlarms( m_todoMgr.event( currentView()->current() ), OPimTodo() ); |
477 | m_todoMgr.remove( currentView()->current() ); | 477 | m_todoMgr.remove( currentView()->current() ); |
478 | currentView()->removeEvent( currentView()->current() ); | 478 | currentView()->removeEvent( currentView()->current() ); |
479 | raiseCurrentView(); | 479 | raiseCurrentView(); |
480 | } | 480 | } |
481 | void MainWindow::slotDelete(int uid ) { | 481 | void MainWindow::slotDelete(int uid ) { |
482 | if( uid == 0 ) return; | 482 | if( uid == 0 ) return; |
483 | if(m_syncing) { | 483 | if(m_syncing) { |
484 | QMessageBox::warning(this, QWidget::tr("Todo"), | 484 | QMessageBox::warning(this, QWidget::tr("Todo"), |
485 | QWidget::tr("Data can not be edited, currently syncing")); | 485 | QWidget::tr("Data can not be edited, currently syncing")); |
486 | return; | 486 | return; |
487 | } | 487 | } |
488 | OPimTodo to = m_todoMgr.event(uid); | 488 | OPimTodo to = m_todoMgr.event(uid); |
489 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) | 489 | if (!QPEMessageBox::confirmDelete(this, QWidget::tr("Todo"), to.toShortText() ) ) |
490 | return; | 490 | return; |
491 | 491 | ||
492 | handleAlarms(to, OPimTodo() ); | 492 | handleAlarms(to, OPimTodo() ); |
493 | m_todoMgr.remove( to.uid() ); | 493 | m_todoMgr.remove( to.uid() ); |
494 | currentView()->removeEvent( to.uid() ); | 494 | currentView()->removeEvent( to.uid() ); |
495 | raiseCurrentView(); | 495 | raiseCurrentView(); |
496 | } | 496 | } |
497 | void MainWindow::slotDeleteAll() { | 497 | void MainWindow::slotDeleteAll() { |
498 | if(m_syncing) { | 498 | if(m_syncing) { |
499 | QMessageBox::warning(this, QWidget::tr("Todo"), | 499 | QMessageBox::warning(this, QWidget::tr("Todo"), |
500 | QWidget::tr("Data can not be edited, currently syncing")); | 500 | QWidget::tr("Data can not be edited, currently syncing")); |
501 | return; | 501 | return; |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
505 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) | 505 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all tasks?") ) ) |
506 | return; | 506 | return; |
507 | 507 | ||
508 | m_todoMgr.removeAll(); | 508 | m_todoMgr.removeAll(); |
509 | currentView()->clear(); | 509 | currentView()->clear(); |
510 | 510 | ||
511 | raiseCurrentView(); | 511 | raiseCurrentView(); |
512 | } | 512 | } |
513 | void MainWindow::slotDeleteCompleted() { | 513 | void MainWindow::slotDeleteCompleted() { |
514 | if(m_syncing) { | 514 | if(m_syncing) { |
515 | QMessageBox::warning(this, QWidget::tr("Todo"), | 515 | QMessageBox::warning(this, QWidget::tr("Todo"), |
516 | QWidget::tr("Data can not be edited, currently syncing")); | 516 | QWidget::tr("Data can not be edited, currently syncing")); |
517 | return; | 517 | return; |
518 | } | 518 | } |
519 | 519 | ||
520 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) | 520 | if ( !QPEMessageBox::confirmDelete( this, QWidget::tr( "Todo" ), QWidget::tr("all completed tasks?") ) ) |
521 | return; | 521 | return; |
522 | 522 | ||
523 | 523 | ||
524 | m_todoMgr.removeCompleted(); | 524 | m_todoMgr.removeCompleted(); |
525 | currentView()->updateView( ); | 525 | currentView()->updateView( ); |
526 | } | 526 | } |
527 | void MainWindow::slotFind() { | 527 | void MainWindow::slotFind() { |
528 | 528 | ||
529 | } | 529 | } |
530 | void MainWindow::slotEdit() { | 530 | void MainWindow::slotEdit() { |
531 | slotEdit( currentView()->current() ); | 531 | slotEdit( currentView()->current() ); |
532 | } | 532 | } |
533 | /* | 533 | /* |
534 | * set the category | 534 | * set the category |
535 | */ | 535 | */ |
536 | void MainWindow::setCategory( int c) { | 536 | void MainWindow::setCategory( int c) { |
537 | if ( c <= 0 ) return; | 537 | if ( c <= 0 ) return; |
538 | 538 | ||
539 | 539 | ||
540 | owarn << "Iterating over cats " << c << oendl; | 540 | owarn << "Iterating over cats " << c << oendl; |
541 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) | 541 | for ( unsigned int i = 1; i < m_catMenu->count(); i++ ) |
542 | m_catMenu->setItemChecked(i, c == (int)i ); | 542 | m_catMenu->setItemChecked(i, c == (int)i ); |
543 | 543 | ||
544 | if (c == 1 ) { | 544 | if (c == 1 ) { |
545 | m_curCat = QString::null; | 545 | m_curCat = QString::null; |
546 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); | 546 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("All Categories" ) ); |
547 | 547 | ||
548 | }else if ( c == (int)m_catMenu->count() - 1 ) { | 548 | }else if ( c == (int)m_catMenu->count() - 1 ) { |
549 | m_curCat = QWidget::tr("Unfiled"); | 549 | m_curCat = QWidget::tr("Unfiled"); |
550 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); | 550 | setCaption( QWidget::tr("Todo") + " - " + QWidget::tr("Unfiled") ); |
551 | }else { | 551 | }else { |
552 | m_curCat = m_todoMgr.categories()[c-2]; | 552 | m_curCat = m_todoMgr.categories()[c-2]; |
553 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); | 553 | setCaption( QWidget::tr("Todo") + " - " + m_curCat ); |
554 | } | 554 | } |
555 | m_catMenu->setItemChecked( c, true ); | 555 | m_catMenu->setItemChecked( c, true ); |
556 | 556 | ||
557 | currentView()->setShowCategory( m_curCat ); | 557 | currentView()->setShowCategory( m_curCat ); |
558 | raiseCurrentView(); | 558 | raiseCurrentView(); |
559 | } | 559 | } |
560 | void MainWindow::slotShowDeadLine( bool dead) { | 560 | void MainWindow::slotShowDeadLine( bool dead) { |
561 | m_deadline = dead; | 561 | m_deadline = dead; |
562 | currentView()->setShowDeadline( dead ); | 562 | currentView()->setShowDeadline( dead ); |
563 | } | 563 | } |
564 | void MainWindow::slotShowCompleted( bool show) { | 564 | void MainWindow::slotShowCompleted( bool show) { |
565 | m_completed = show; | 565 | m_completed = show; |
566 | currentView()->setShowCompleted( m_completed ); | 566 | currentView()->setShowCompleted( m_completed ); |
567 | } | 567 | } |
568 | void MainWindow::slotShowQuickTask( bool show ) { | 568 | void MainWindow::slotShowQuickTask( bool show ) { |
569 | m_quicktask = show; | 569 | m_quicktask = show; |
570 | if ( m_quicktask ) | 570 | if ( m_quicktask ) |
571 | m_curQuick->widget()->show(); | 571 | m_curQuick->widget()->show(); |
572 | else | 572 | else |
573 | m_curQuick->widget()->hide(); | 573 | m_curQuick->widget()->hide(); |
574 | } | 574 | } |
575 | bool MainWindow::showOverDue()const { | 575 | bool MainWindow::showOverDue()const { |
576 | return m_overdue; | 576 | return m_overdue; |
577 | } | 577 | } |
578 | void MainWindow::setDocument( const QString& fi) { | 578 | void MainWindow::setDocument( const QString& fi) { |
579 | DocLnk doc(fi); | 579 | DocLnk doc(fi); |
580 | if (doc.isValid() ) | 580 | if (doc.isValid() ) |
581 | receiveFile(doc.file() ); | 581 | receiveFile(doc.file() ); |
582 | else | 582 | else |
583 | receiveFile(fi ); | 583 | receiveFile(fi ); |
584 | } | 584 | } |
585 | 585 | ||
586 | static const char *beamfile = "/tmp/opie-todo.vcs"; | 586 | static const char *beamfile = "/tmp/opie-todo.vcs"; |
587 | void MainWindow::slotBeam() { | 587 | void MainWindow::slotBeam() { |
588 | beam( currentView()->current() ); | 588 | beam( currentView()->current() ); |
589 | } | 589 | } |
590 | void MainWindow::beamDone( Ir* ir) { | 590 | void MainWindow::beamDone( Ir* ir) { |
591 | delete ir; | 591 | delete ir; |
592 | ::unlink( beamfile ); | 592 | ::unlink( beamfile ); |
593 | } | 593 | } |
594 | void MainWindow::receiveFile( const QString& filename ) { | 594 | void MainWindow::receiveFile( const QString& filename ) { |
595 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); | 595 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(filename ); |
596 | 596 | ||
597 | OPimTodoAccess acc( cal ); | 597 | OPimTodoAccess acc( cal ); |
598 | acc.load(); | 598 | acc.load(); |
599 | OPimTodoAccess::List list = acc.allRecords(); | 599 | OPimTodoAccess::List list = acc.allRecords(); |
600 | 600 | ||
601 | if (list.count()){ | 601 | if (list.count()){ |
602 | 602 | ||
603 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); | 603 | QString message = QWidget::tr("<P>%1 new tasks arrived.<p>Would you like to add them to your Todolist?").arg(list.count() ); |
604 | 604 | ||
605 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), | 605 | if ( QMessageBox::information(this, QWidget::tr("New Tasks"), |
606 | message, QMessageBox::Ok, | 606 | message, QMessageBox::Ok, |
607 | QMessageBox::Cancel ) == QMessageBox::Ok ) { | 607 | QMessageBox::Cancel ) == QMessageBox::Ok ) { |
608 | OPimTodoAccess::List::Iterator it; | 608 | OPimTodoAccess::List::Iterator it; |
609 | for ( it = list.begin(); it != list.end(); ++it ) | 609 | for ( it = list.begin(); it != list.end(); ++it ) |
610 | m_todoMgr.add( (*it) ); | 610 | m_todoMgr.add( (*it) ); |
611 | 611 | ||
612 | currentView()->updateView(); | 612 | currentView()->updateView(); |
613 | } | 613 | } |
614 | } | 614 | } |
615 | } | 615 | } |
616 | 616 | ||
617 | void MainWindow::slotFlush() { | 617 | void MainWindow::slotFlush() { |
618 | m_syncing = TRUE; | 618 | m_syncing = TRUE; |
619 | m_todoMgr.save(); | 619 | m_todoMgr.save(); |
620 | } | 620 | } |
621 | void MainWindow::slotShowDetails() { | 621 | void MainWindow::slotShowDetails() { |
622 | slotShow( currentView()->current() ); | 622 | slotShow( currentView()->current() ); |
623 | } | 623 | } |
624 | /* | 624 | /* |
625 | * populate the Categories | 625 | * populate the Categories |
626 | * Menu | 626 | * Menu |
627 | */ | 627 | */ |
628 | void MainWindow::populateCategories() { | 628 | void MainWindow::populateCategories() { |
629 | m_todoMgr.load(); | 629 | m_todoMgr.load(); |
630 | 630 | ||
631 | m_catMenu->clear(); | 631 | m_catMenu->clear(); |
632 | int id, rememberId; | 632 | int id, rememberId; |
633 | id = 1; | 633 | id = 1; |
634 | rememberId = 1; | 634 | rememberId = 1; |
635 | 635 | ||
636 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); | 636 | m_catMenu->insertItem( QWidget::tr( "All Categories" ), id++ ); |
637 | m_catMenu->insertSeparator(); | 637 | m_catMenu->insertSeparator(); |
638 | QStringList categories = m_todoMgr.categories(); | 638 | QStringList categories = m_todoMgr.categories(); |
639 | categories.append( QWidget::tr( "Unfiled" ) ); | 639 | categories.append( QWidget::tr( "Unfiled" ) ); |
640 | for ( QStringList::Iterator it = categories.begin(); | 640 | for ( QStringList::Iterator it = categories.begin(); |
641 | it != categories.end(); ++it ) { | 641 | it != categories.end(); ++it ) { |
642 | m_catMenu->insertItem( *it, id ); | 642 | m_catMenu->insertItem( *it, id ); |
643 | if ( *it == currentCategory() ) | 643 | if ( *it == currentCategory() ) |
644 | rememberId = id; | 644 | rememberId = id; |
645 | ++id; | 645 | ++id; |
646 | } | 646 | } |
647 | setCategory( rememberId ); | 647 | setCategory( rememberId ); |
648 | } | 648 | } |
649 | bool MainWindow::showCompleted()const { | 649 | bool MainWindow::showCompleted()const { |
650 | return m_completed; | 650 | return m_completed; |
651 | } | 651 | } |
652 | bool MainWindow::showDeadline()const { | 652 | bool MainWindow::showDeadline()const { |
653 | return m_deadline; | 653 | return m_deadline; |
654 | } | 654 | } |
655 | bool MainWindow::showQuickTask()const { | 655 | bool MainWindow::showQuickTask()const { |
656 | return m_quicktask; | 656 | return m_quicktask; |
657 | } | 657 | } |
658 | QString MainWindow::currentCategory()const { | 658 | QString MainWindow::currentCategory()const { |
659 | return m_curCat; | 659 | return m_curCat; |
660 | } | 660 | } |
661 | int MainWindow::currentCatId() { | 661 | int MainWindow::currentCatId() { |
662 | return m_todoMgr.catId( m_curCat ); | 662 | return m_todoMgr.catId( m_curCat ); |
663 | } | 663 | } |
664 | ViewBase* MainWindow::currentView() { | 664 | ViewBase* MainWindow::currentView() { |
665 | return m_curView; | 665 | return m_curView; |
666 | } | 666 | } |
667 | void MainWindow::raiseCurrentView() { | 667 | void MainWindow::raiseCurrentView() { |
668 | // due QPE/Application/todolist show(int) | 668 | // due QPE/Application/todolist show(int) |
669 | // we might not have the populateCategories slot called once | 669 | // we might not have the populateCategories slot called once |
670 | // we would show the otodo but then imediately switch to the currentView | 670 | // we would show the otodo but then imediately switch to the currentView |
671 | // if we're initially showing we shouldn't raise the table | 671 | // if we're initially showing we shouldn't raise the table |
672 | // in returnFromView we fix up m_showing | 672 | // in returnFromView we fix up m_showing |
673 | if (m_showing ) return; | 673 | if (m_showing ) return; |
674 | 674 | ||
675 | m_stack->raiseWidget( m_curView->widget() ); | 675 | m_stack->raiseWidget( m_curView->widget() ); |
676 | } | 676 | } |
677 | void MainWindow::slotShowDue(bool ov) { | 677 | void MainWindow::slotShowDue(bool ov) { |
678 | m_overdue = ov; | 678 | m_overdue = ov; |
679 | currentView()->showOverDue( ov ); | 679 | currentView()->showOverDue( ov ); |
680 | raiseCurrentView(); | 680 | raiseCurrentView(); |
681 | } | 681 | } |
682 | void MainWindow::slotShow( int uid ) { | 682 | void MainWindow::slotShow( int uid ) { |
683 | if ( uid == 0 ) return; | 683 | if ( uid == 0 ) return; |
684 | 684 | ||
685 | 685 | ||
686 | owarn << "slotShow" << oendl; | 686 | owarn << "slotShow" << oendl; |
687 | currentShow()->slotShow( event( uid ) ); | 687 | currentShow()->slotShow( event( uid ) ); |
688 | m_stack->raiseWidget( currentShow()->widget() ); | 688 | m_stack->raiseWidget( currentShow()->widget() ); |
689 | } | 689 | } |
690 | void MainWindow::slotShowNext() { | 690 | void MainWindow::slotShowNext() { |
691 | int l = currentView()->next(); | 691 | int l = currentView()->next(); |
692 | if (l!=0) | 692 | if (l!=0) |
693 | slotShow(l); | 693 | slotShow(l); |
694 | } | 694 | } |
695 | void MainWindow::slotShowPrev() { | 695 | void MainWindow::slotShowPrev() { |
696 | int l = currentView()->prev(); | 696 | int l = currentView()->prev(); |
697 | if (l!=0) | 697 | if (l!=0) |
698 | slotShow(l); | 698 | slotShow(l); |
699 | } | 699 | } |
700 | void MainWindow::slotEdit( int uid ) { | 700 | void MainWindow::slotEdit( int uid ) { |
701 | if (uid == 0 ) return; | 701 | if (uid == 0 ) return; |
702 | if(m_syncing) { | 702 | if(m_syncing) { |
703 | QMessageBox::warning(this, QWidget::tr("Todo"), | 703 | QMessageBox::warning(this, QWidget::tr("Todo"), |
704 | QWidget::tr("Data can't be edited, currently syncing")); | 704 | QWidget::tr("Data can't be edited, currently syncing")); |
705 | return; | 705 | return; |
706 | } | 706 | } |
707 | 707 | ||
708 | OPimTodo old_todo = m_todoMgr.event( uid ); | 708 | OPimTodo old_todo = m_todoMgr.event( uid ); |
709 | 709 | ||
710 | OPimTodo todo = currentEditor()->edit(this, old_todo ); | 710 | OPimTodo todo = currentEditor()->edit(this, old_todo ); |
711 | 711 | ||
712 | /* if completed */ | 712 | /* if completed */ |
713 | if ( currentEditor()->accepted() ) { | 713 | if ( currentEditor()->accepted() ) { |
714 | handleAlarms( old_todo, todo ); | 714 | handleAlarms( old_todo, todo ); |
715 | m_todoMgr.update( todo.uid(), todo ); | 715 | m_todoMgr.update( todo.uid(), todo ); |
716 | currentView()->replaceEvent( todo ); | 716 | currentView()->replaceEvent( todo ); |
717 | /* a Category might have changed */ | 717 | /* a Category might have changed */ |
718 | populateCategories(); | 718 | populateCategories(); |
719 | } | 719 | } |
720 | 720 | ||
721 | raiseCurrentView(); | 721 | raiseCurrentView(); |
722 | } | 722 | } |
723 | /* | 723 | /* |
724 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { | 724 | void MainWindow::slotUpdate1( int uid, const SmallTodo& ev) { |
725 | m_todoMgr.update( uid, ev ); | 725 | m_todoMgr.update( uid, ev ); |
726 | } | 726 | } |
727 | */ | 727 | */ |
728 | void MainWindow::updateTodo( const OPimTodo& ev) { | 728 | void MainWindow::updateTodo( const OPimTodo& ev) { |
729 | m_todoMgr.update( ev.uid() , ev ); | 729 | m_todoMgr.update( ev.uid() , ev ); |
730 | } | 730 | } |
731 | /* The view changed it's configuration | 731 | /* The view changed it's configuration |
732 | * update the view menu | 732 | * update the view menu |
733 | */ | 733 | */ |
734 | void MainWindow::slotUpdate3( QWidget* ) { | 734 | void MainWindow::slotUpdate3( QWidget* ) { |
735 | 735 | ||
736 | } | 736 | } |
737 | void MainWindow::updateList() { | 737 | void MainWindow::updateList() { |
738 | m_todoMgr.updateList(); | 738 | m_todoMgr.updateList(); |
739 | } | 739 | } |
740 | void MainWindow::setReadAhead( uint count ) { | 740 | void MainWindow::setReadAhead( uint count ) { |
741 | if (m_todoMgr.todoDB() ) | 741 | if (m_todoMgr.todoDB() ) |
742 | m_todoMgr.todoDB()->setReadAhead( count ); | 742 | m_todoMgr.todoDB()->setReadAhead( count ); |
743 | } | 743 | } |
744 | void MainWindow::slotQuickEntered() { | 744 | void MainWindow::slotQuickEntered() { |
745 | owarn << "entered" << oendl; | 745 | owarn << "entered" << oendl; |
746 | OPimTodo todo = quickEditor()->todo(); | 746 | OPimTodo todo = quickEditor()->todo(); |
747 | if (todo.isEmpty() ) | 747 | if (todo.isEmpty() ) |
748 | return; | 748 | return; |
749 | 749 | ||
750 | m_todoMgr.add( todo ); | 750 | m_todoMgr.add( todo ); |
751 | currentView()->addEvent( todo ); | 751 | currentView()->addEvent( todo ); |
752 | raiseCurrentView(); | 752 | raiseCurrentView(); |
753 | } | 753 | } |
754 | QuickEditBase* MainWindow::quickEditor() { | 754 | QuickEditBase* MainWindow::quickEditor() { |
755 | return m_curQuick; | 755 | return m_curQuick; |
756 | } | 756 | } |
757 | void MainWindow::slotComplete( int uid ) { | 757 | void MainWindow::slotComplete( int uid ) { |
758 | slotComplete( event(uid) ); | 758 | slotComplete( event(uid) ); |
759 | } | 759 | } |
760 | void MainWindow::slotComplete( const OPimTodo& todo ) { | 760 | void MainWindow::slotComplete( const OPimTodo& todo ) { |
761 | OPimTodo to = todo; | 761 | OPimTodo to = todo; |
762 | to.setCompleted( !to.isCompleted() ); | 762 | to.setCompleted( !to.isCompleted() ); |
763 | to.setCompletedDate( QDate::currentDate() ); | 763 | to.setCompletedDate( QDate::currentDate() ); |
764 | 764 | ||
765 | /* | 765 | /* |
766 | * if the item does recur | 766 | * if the item does recur |
767 | * we need to spin it off | 767 | * we need to spin it off |
768 | * and update the items duedate to the next | 768 | * and update the items duedate to the next |
769 | * possible recurrance of this item... | 769 | * possible recurrance of this item... |
770 | * the spinned off one will loose the | 770 | * the spinned off one will loose the |
771 | * recurrence. | 771 | * recurrence. |
772 | * We calculate the difference between the old due date and the | 772 | * We calculate the difference between the old due date and the |
773 | * new one and add this diff to start, completed and alarm dates | 773 | * new one and add this diff to start, completed and alarm dates |
774 | * -zecke | 774 | * -zecke |
775 | */ | 775 | */ |
776 | if ( to.hasRecurrence() && to.isCompleted() ) { | 776 | if ( to.hasRecurrence() && to.isCompleted() ) { |
777 | OPimTodo to2( to ); | 777 | OPimTodo to2( to ); |
778 | 778 | ||
779 | /* the spinned off one won't recur anymore */ | 779 | /* the spinned off one won't recur anymore */ |
780 | to.setRecurrence( OPimRecurrence() ); | 780 | to.setRecurrence( OPimRecurrence() ); |
781 | 781 | ||
782 | OPimRecurrence rec = to2.recurrence(); | 782 | OPimRecurrence rec = to2.recurrence(); |
783 | rec.setStart( to.dueDate() ); | 783 | rec.setStart( to.dueDate() ); |
784 | to2.setRecurrence( rec ); | 784 | to2.setRecurrence( rec ); |
785 | /* | 785 | /* |
786 | * if there is a next occurence | 786 | * if there is a next occurence |
787 | * from the duedate of the last recurrance | 787 | * from the duedate of the last recurrance |
788 | */ | 788 | */ |
789 | QDate date; | 789 | QDate date; |
790 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { | 790 | if ( to2.recurrence().nextOcurrence( to2.dueDate().addDays(1), date ) ) { |
791 | int dayDiff = to.dueDate().daysTo( date ); | 791 | int dayDiff = to.dueDate().daysTo( date ); |
792 | owarn << "day diff is " << dayDiff << oendl; | 792 | owarn << "day diff is " << dayDiff << oendl; |
793 | QDate inval; | 793 | QDate inval; |
794 | /* generate a new uid for the old record */ | 794 | /* generate a new uid for the old record */ |
795 | to.setUid( 1 ); | 795 | to.setUid( 1 ); |
796 | 796 | ||
797 | /* add the old one cause it has a new UID here cause it was spin off */ | 797 | /* add the old one cause it has a new UID here cause it was spin off */ |
798 | m_todoMgr.add( to ); | 798 | m_todoMgr.add( to ); |
799 | 799 | ||
800 | /* | 800 | /* |
801 | * update the due date | 801 | * update the due date |
802 | * start date | 802 | * start date |
803 | * and complete date | 803 | * and complete date |
804 | */ | 804 | */ |
805 | to2.setDueDate( date ); | 805 | to2.setDueDate( date ); |
806 | rec.setStart( date ); | 806 | rec.setStart( date ); |
807 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week | 807 | to2.setRecurrence( rec ); // could be Monday, TuesDay, Thursday every week |
808 | 808 | ||
809 | /* move start date */ | 809 | /* move start date */ |
810 | if (to2.hasStartDate() ) | 810 | if (to2.hasStartDate() ) |
811 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); | 811 | to2.setStartDate( to2.startDate().addDays( dayDiff ) ); |
812 | 812 | ||
813 | /* now the alarms */ | 813 | /* now the alarms */ |
814 | if (to2.hasNotifiers() ) { | 814 | if (to2.hasNotifiers() ) { |
815 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); | 815 | OPimNotifyManager::Alarms _als = to2.notifiers().alarms(); |
816 | OPimNotifyManager::Alarms als; | 816 | OPimNotifyManager::Alarms als; |
817 | 817 | ||
818 | /* for every alarm move the day */ | 818 | /* for every alarm move the day */ |
819 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { | 819 | for ( OPimNotifyManager::Alarms::Iterator it = _als.begin(); it != _als.end(); ++it ) { |
820 | OPimAlarm al = (*it); | 820 | OPimAlarm al = (*it); |
821 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); | 821 | al.setDateTime( al.dateTime().addDays( dayDiff ) ); |
822 | als.append( al ); | 822 | als.append( al ); |
823 | } | 823 | } |
824 | to2.notifiers().setAlarms( als ); | 824 | to2.notifiers().setAlarms( als ); |
825 | handleAlarms( OPimTodo(), todo ); | 825 | handleAlarms( OPimTodo(), todo ); |
826 | } | 826 | } |
827 | to2.setCompletedDate( inval ); | 827 | to2.setCompletedDate( inval ); |
828 | to2.setCompleted( false ); | 828 | to2.setCompleted( false ); |
829 | 829 | ||
830 | updateTodo( to2 ); | 830 | updateTodo( to2 ); |
831 | }else | 831 | }else |
832 | updateTodo( to ); | 832 | updateTodo( to ); |
833 | }else | 833 | }else |
834 | updateTodo( to ); | 834 | updateTodo( to ); |
835 | 835 | ||
836 | currentView()->updateView(); | 836 | currentView()->updateView(); |
837 | raiseCurrentView(); | 837 | raiseCurrentView(); |
838 | } | 838 | } |
839 | void MainWindow::flush() { | 839 | void MainWindow::flush() { |
840 | slotFlush(); | 840 | slotFlush(); |
841 | } | 841 | } |
842 | void MainWindow::reload() { | 842 | void MainWindow::reload() { |
843 | slotReload(); | 843 | slotReload(); |
844 | } | 844 | } |
845 | int MainWindow::create() { | 845 | int MainWindow::create() { |
846 | int uid = 0; | 846 | int uid = 0; |
847 | if(m_syncing) { | 847 | if(m_syncing) { |
848 | QMessageBox::warning(this, QWidget::tr("Todo"), | 848 | QMessageBox::warning(this, QWidget::tr("Todo"), |
849 | QWidget::tr("Data can not be edited, currently syncing")); | 849 | QWidget::tr("Data can not be edited, currently syncing")); |
850 | return uid; | 850 | return uid; |
851 | } | 851 | } |
852 | m_todoMgr.load(); | 852 | m_todoMgr.load(); |
853 | 853 | ||
854 | 854 | ||
855 | OPimTodo todo = currentEditor()->newTodo( currentCatId(), | 855 | OPimTodo todo = currentEditor()->newTodo( currentCatId(), |
856 | this ); | 856 | this ); |
857 | 857 | ||
858 | if ( currentEditor()->accepted() ) { | 858 | if ( currentEditor()->accepted() ) { |
859 | //todo.assignUid(); | 859 | //todo.assignUid(); |
860 | uid = todo.uid(); | 860 | uid = todo.uid(); |
861 | handleAlarms( OPimTodo(), todo ); | 861 | handleAlarms( OPimTodo(), todo ); |
862 | m_todoMgr.add( todo ); | 862 | m_todoMgr.add( todo ); |
863 | currentView()->addEvent( todo ); | 863 | currentView()->addEvent( todo ); |
864 | 864 | ||
865 | 865 | ||
866 | // I'm afraid we must call this every time now, otherwise | 866 | // I'm afraid we must call this every time now, otherwise |
867 | // spend expensive time comparing all these strings... | 867 | // spend expensive time comparing all these strings... |
868 | // but only call if we changed something -zecke | 868 | // but only call if we changed something -zecke |
869 | populateCategories(); | 869 | populateCategories(); |
870 | } | 870 | } |
871 | raiseCurrentView( ); | 871 | raiseCurrentView( ); |
872 | 872 | ||
873 | return uid; | 873 | return uid; |
874 | } | 874 | } |
875 | /* delete it silently... */ | 875 | /* delete it silently... */ |
876 | bool MainWindow::remove( int uid ) { | 876 | bool MainWindow::remove( int uid ) { |
877 | if (m_syncing) return false; | 877 | if (m_syncing) return false; |
878 | 878 | ||
879 | /* argh need to get the whole OEvent... to disable alarms -zecke */ | 879 | /* argh need to get the whole OEvent... to disable alarms -zecke */ |
880 | handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); | 880 | handleAlarms( OPimTodo(), m_todoMgr.event( uid ) ); |
881 | 881 | ||
882 | return m_todoMgr.remove( uid ); | 882 | return m_todoMgr.remove( uid ); |
883 | } | 883 | } |
884 | void MainWindow::beam( int uid) { | 884 | void MainWindow::beam( int uid) { |
885 | if( uid == 0 ) return; | 885 | if( uid == 0 ) return; |
886 | 886 | ||
887 | ::unlink( beamfile ); | 887 | ::unlink( beamfile ); |
888 | m_todoMgr.load(); | 888 | m_todoMgr.load(); |
889 | 889 | ||
890 | OPimTodo todo = event( uid ); | 890 | OPimTodo todo = event( uid ); |
891 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); | 891 | OPimTodoAccessVCal* cal = new OPimTodoAccessVCal(QString::fromLatin1(beamfile) ); |
892 | OPimTodoAccess acc( cal ); | 892 | OPimTodoAccess acc( cal ); |
893 | acc.load(); | 893 | acc.load(); |
894 | acc.add( todo ); | 894 | acc.add( todo ); |
895 | acc.save(); | 895 | acc.save(); |
896 | Ir* ir = new Ir(this ); | 896 | Ir* ir = new Ir(this ); |
897 | connect(ir, SIGNAL(done(Ir*) ), | 897 | connect(ir, SIGNAL(done(Ir*) ), |
898 | this, SLOT(beamDone(Ir*) ) ); | 898 | this, SLOT(beamDone(Ir*) ) ); |
899 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); | 899 | ir->send(beamfile, todo.summary(), "text/x-vCalendar" ); |
900 | } | 900 | } |
901 | void MainWindow::show( int uid ) { | 901 | void MainWindow::show( int uid ) { |
902 | m_todoMgr.load(); // might not be loaded yet | 902 | m_todoMgr.load(); // might not be loaded yet |
903 | m_showing = true; | 903 | m_showing = true; |
904 | slotShow( uid ); | 904 | slotShow( uid ); |
905 | raise(); | 905 | raise(); |
906 | QPEApplication::setKeepRunning(); | 906 | QPEApplication::setKeepRunning(); |
907 | } | 907 | } |
908 | void MainWindow::edit( int uid ) { | 908 | void MainWindow::edit( int uid ) { |
909 | m_todoMgr.load(); | 909 | m_todoMgr.load(); |
910 | slotEdit( uid ); | 910 | slotEdit( uid ); |
911 | } | 911 | } |
912 | void MainWindow::add( const OPimRecord& rec) { | 912 | void MainWindow::add( const OPimRecord& rec) { |
913 | if ( rec.rtti() != OPimTodo::rtti() ) return; | 913 | OPimTodo test; |
914 | if ( rec.rtti() != test.rtti() ) return; | ||
914 | m_todoMgr.load(); // might not be loaded | 915 | m_todoMgr.load(); // might not be loaded |
915 | 916 | ||
916 | const OPimTodo& todo = static_cast<const OPimTodo&>(rec); | 917 | const OPimTodo& todo = static_cast<const OPimTodo&>(rec); |
917 | 918 | ||
918 | m_todoMgr.add(todo ); | 919 | m_todoMgr.add(todo ); |
919 | currentView()->addEvent( todo ); | 920 | currentView()->addEvent( todo ); |
920 | 921 | ||
921 | 922 | ||
922 | // I'm afraid we must call this every time now, otherwise | 923 | // I'm afraid we must call this every time now, otherwise |
923 | // spend expensive time comparing all these strings... | 924 | // spend expensive time comparing all these strings... |
924 | // but only call if we changed something -zecke | 925 | // but only call if we changed something -zecke |
925 | populateCategories(); | 926 | populateCategories(); |
926 | } | 927 | } |
927 | void MainWindow::slotReturnFromView() { | 928 | void MainWindow::slotReturnFromView() { |
928 | m_showing = false; | 929 | m_showing = false; |
929 | raiseCurrentView(); | 930 | raiseCurrentView(); |
930 | } | 931 | } |
931 | 932 | ||
932 | namespace { | 933 | namespace { |
933 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, | 934 | OPimNotifyManager::Alarms findNonMatching( const OPimNotifyManager::Alarms& oldAls, |
934 | const OPimNotifyManager::Alarms& newAls ) { | 935 | const OPimNotifyManager::Alarms& newAls ) { |
935 | OPimNotifyManager::Alarms nonMatching; | 936 | OPimNotifyManager::Alarms nonMatching; |
936 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); | 937 | OPimNotifyManager::Alarms::ConstIterator oldIt = oldAls.begin(); |
937 | OPimNotifyManager::Alarms::ConstIterator newIt; | 938 | OPimNotifyManager::Alarms::ConstIterator newIt; |
938 | for ( ; oldIt != oldAls.end(); ++oldIt ) { | 939 | for ( ; oldIt != oldAls.end(); ++oldIt ) { |
939 | bool found = false; | 940 | bool found = false; |
940 | QDateTime oldDt = (*oldIt).dateTime(); | 941 | QDateTime oldDt = (*oldIt).dateTime(); |
941 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { | 942 | for (newIt= newAls.begin(); newIt != newAls.end(); ++newIt ) { |
942 | if ( oldDt == (*newIt).dateTime() ) { | 943 | if ( oldDt == (*newIt).dateTime() ) { |
943 | found = true; | 944 | found = true; |
944 | break; | 945 | break; |
945 | } | 946 | } |
946 | } | 947 | } |
947 | if (!found) | 948 | if (!found) |
948 | nonMatching.append( (*oldIt) ); | 949 | nonMatching.append( (*oldIt) ); |
949 | } | 950 | } |
950 | return nonMatching; | 951 | return nonMatching; |
951 | } | 952 | } |
952 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 953 | void addAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
953 | OPimNotifyManager::Alarms::ConstIterator it; | 954 | OPimNotifyManager::Alarms::ConstIterator it; |
954 | for ( it = als.begin(); it != als.end(); ++it ) { | 955 | for ( it = als.begin(); it != als.end(); ++it ) { |
955 | owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; | 956 | owarn << "Adding alarm for " << (*it).dateTime().toString() << oendl; |
956 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 957 | AlarmServer::addAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
957 | } | 958 | } |
958 | 959 | ||
959 | } | 960 | } |
960 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { | 961 | void removeAlarms( const OPimNotifyManager::Alarms& als, int uid ) { |
961 | OPimNotifyManager::Alarms::ConstIterator it; | 962 | OPimNotifyManager::Alarms::ConstIterator it; |
962 | for ( it = als.begin(); it != als.end(); ++it ) { | 963 | for ( it = als.begin(); it != als.end(); ++it ) { |
963 | owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; | 964 | owarn << "Removinf alarm for " << (*it).dateTime().toString() << oendl; |
964 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); | 965 | AlarmServer::deleteAlarm( (*it).dateTime(), "QPE/Application/todolist", "alarm(QDateTime,int)", uid ); |
965 | } | 966 | } |
966 | } | 967 | } |
967 | } | 968 | } |
968 | 969 | ||
969 | void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { | 970 | void MainWindow::handleAlarms( const OPimTodo& oldTodo, const OPimTodo& newTodo) { |
970 | /* | 971 | /* |
971 | * if oldTodo is not empty and has notifiers we need to find the deleted ones | 972 | * if oldTodo is not empty and has notifiers we need to find the deleted ones |
972 | */ | 973 | */ |
973 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { | 974 | if(!oldTodo.isEmpty() && oldTodo.hasNotifiers() ) { |
974 | OPimNotifyManager::Alarms removed; | 975 | OPimNotifyManager::Alarms removed; |
975 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); | 976 | OPimNotifyManager::Alarms oldAls = oldTodo.notifiers().alarms(); |
976 | if (!newTodo.hasNotifiers() ) | 977 | if (!newTodo.hasNotifiers() ) |
977 | removed = oldAls; | 978 | removed = oldAls; |
978 | else | 979 | else |
979 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); | 980 | removed = findNonMatching( oldAls, newTodo.notifiers().alarms() ); |
980 | 981 | ||
981 | removeAlarms( removed, oldTodo.uid() ); | 982 | removeAlarms( removed, oldTodo.uid() ); |
982 | } | 983 | } |
983 | if ( newTodo.hasNotifiers() ) { | 984 | if ( newTodo.hasNotifiers() ) { |
984 | OPimNotifyManager::Alarms added; | 985 | OPimNotifyManager::Alarms added; |
985 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) | 986 | if ( oldTodo.isEmpty() || !oldTodo.hasNotifiers() ) |
986 | added = newTodo.notifiers().alarms(); | 987 | added = newTodo.notifiers().alarms(); |
987 | else | 988 | else |
988 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); | 989 | added = findNonMatching( newTodo.notifiers().alarms(), oldTodo.notifiers().alarms() ); |
989 | 990 | ||
990 | addAlarms( added, newTodo.uid() ); | 991 | addAlarms( added, newTodo.uid() ); |
991 | } | 992 | } |
992 | } | 993 | } |
993 | /* we might have not loaded the db */ | 994 | /* we might have not loaded the db */ |
994 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { | 995 | void MainWindow::doAlarm( const QDateTime& dt, int uid ) { |
995 | m_todoMgr.load(); | 996 | m_todoMgr.load(); |
996 | 997 | ||
997 | OPimTodo todo = m_todoMgr.event( uid ); | 998 | OPimTodo todo = m_todoMgr.event( uid ); |
998 | if (!todo.hasNotifiers() ) return; | 999 | if (!todo.hasNotifiers() ) return; |
999 | 1000 | ||
1000 | /* | 1001 | /* |
1001 | * let's find the right alarm and find out if silent | 1002 | * let's find the right alarm and find out if silent |
1002 | * then show a richtext widget | 1003 | * then show a richtext widget |
1003 | */ | 1004 | */ |
1004 | bool loud = false; | 1005 | bool loud = false; |
1005 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); | 1006 | OPimNotifyManager::Alarms als = todo.notifiers().alarms(); |
1006 | OPimNotifyManager::Alarms::Iterator it; | 1007 | OPimNotifyManager::Alarms::Iterator it; |
1007 | for ( it = als.begin(); it != als.end(); ++it ) { | 1008 | for ( it = als.begin(); it != als.end(); ++it ) { |
1008 | if ( (*it).dateTime() == dt ) { | 1009 | if ( (*it).dateTime() == dt ) { |
1009 | loud = ( (*it).sound() == OPimAlarm::Loud ); | 1010 | loud = ( (*it).sound() == OPimAlarm::Loud ); |
1010 | break; | 1011 | break; |
1011 | } | 1012 | } |
1012 | } | 1013 | } |
1013 | if (loud) | 1014 | if (loud) |
1014 | startAlarm(); | 1015 | startAlarm(); |
1015 | 1016 | ||
1016 | QDialog dlg(this, 0, TRUE ); | 1017 | QDialog dlg(this, 0, TRUE ); |
1017 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); | 1018 | QVBoxLayout* lay = new QVBoxLayout( &dlg ); |
1018 | QTextView* view = new QTextView( &dlg ); | 1019 | QTextView* view = new QTextView( &dlg ); |
1019 | lay->addWidget( view ); | 1020 | lay->addWidget( view ); |
1020 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); | 1021 | QPushButton* btnOk = new QPushButton( tr("Ok"), &dlg ); |
1021 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); | 1022 | connect( btnOk, SIGNAL(clicked() ), &dlg, SLOT(accept() ) ); |
1022 | lay->addWidget( btnOk ); | 1023 | lay->addWidget( btnOk ); |
1023 | 1024 | ||
1024 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); | 1025 | QString text = tr("<h1>Alarm at %1</h1><br>").arg( TimeString::dateString( dt ) ); |
1025 | text += todo.toRichText(); | 1026 | text += todo.toRichText(); |
1026 | view->setText( text ); | 1027 | view->setText( text ); |
1027 | 1028 | ||
1028 | bool needToStay = QPEApplication::execDialog( &dlg ); | 1029 | bool needToStay = QPEApplication::execDialog( &dlg ); |
1029 | 1030 | ||
1030 | if (loud) | 1031 | if (loud) |
1031 | killAlarm(); | 1032 | killAlarm(); |
1032 | 1033 | ||
1033 | if (needToStay) { | 1034 | if (needToStay) { |
1034 | // showMaximized(); | 1035 | // showMaximized(); |
1035 | // raise(); | 1036 | // raise(); |
1036 | QPEApplication::setKeepRunning(); | 1037 | QPEApplication::setKeepRunning(); |
1037 | // setActiveWindow(); | 1038 | // setActiveWindow(); |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | } | 1041 | } |
1041 | 1042 | ||