-rw-r--r-- | core/pim/datebook/datebook.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 47be523..3e18374 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -472,260 +472,260 @@ void DateBook::editEvent( const Event &e ) | |||
472 | DateEntry *entry; | 472 | DateEntry *entry; |
473 | editDlg.setCaption( tr("Edit Event") ); | 473 | editDlg.setCaption( tr("Edit Event") ); |
474 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); | 474 | QVBoxLayout *vb = new QVBoxLayout( &editDlg ); |
475 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); | 475 | QScrollView *sv = new QScrollView( &editDlg, "scrollview" ); |
476 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 476 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
477 | // KLUDGE!!! | 477 | // KLUDGE!!! |
478 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 478 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
479 | vb->addWidget( sv ); | 479 | vb->addWidget( sv ); |
480 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); | 480 | entry = new DateEntry( onMonday, e, ampm, &editDlg, "editor" ); |
481 | entry->timezone->setEnabled( FALSE ); | 481 | entry->timezone->setEnabled( FALSE ); |
482 | sv->addChild( entry ); | 482 | sv->addChild( entry ); |
483 | 483 | ||
484 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 484 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
485 | editDlg.showMaximized(); | 485 | editDlg.showMaximized(); |
486 | #endif | 486 | #endif |
487 | while (editDlg.exec() ) { | 487 | while (editDlg.exec() ) { |
488 | Event newEv = entry->event(); | 488 | Event newEv = entry->event(); |
489 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) | 489 | if(newEv.description().isEmpty() && newEv.notes().isEmpty() ) |
490 | break; | 490 | break; |
491 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 491 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
492 | QString error = checkEvent(newEv); | 492 | QString error = checkEvent(newEv); |
493 | if (!error.isNull()) { | 493 | if (!error.isNull()) { |
494 | if (QMessageBox::warning(this, "error box", | 494 | if (QMessageBox::warning(this, "error box", |
495 | error, "Fix it", "Continue", | 495 | error, "Fix it", "Continue", |
496 | 0, 0, 1) == 0) | 496 | 0, 0, 1) == 0) |
497 | continue; | 497 | continue; |
498 | } | 498 | } |
499 | db->editEvent(e, newEv); | 499 | db->editEvent(e, newEv); |
500 | emit newEvent(); | 500 | emit newEvent(); |
501 | break; | 501 | break; |
502 | } | 502 | } |
503 | } | 503 | } |
504 | 504 | ||
505 | void DateBook::removeEvent( const Event &e ) | 505 | void DateBook::removeEvent( const Event &e ) |
506 | { | 506 | { |
507 | if (syncing) { | 507 | if (syncing) { |
508 | QMessageBox::warning( this, tr("Calendar"), | 508 | QMessageBox::warning( this, tr("Calendar"), |
509 | tr( "Can not edit data, currently syncing") ); | 509 | tr( "Can not edit data, currently syncing") ); |
510 | return; | 510 | return; |
511 | } | 511 | } |
512 | 512 | ||
513 | QString strName = e.description(); | 513 | QString strName = e.description(); |
514 | 514 | ||
515 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) | 515 | if ( !QPEMessageBox::confirmDelete( this, tr( "Calendar" ),strName ) ) |
516 | return; | 516 | return; |
517 | 517 | ||
518 | db->removeEvent( e ); | 518 | db->removeEvent( e ); |
519 | if ( views->visibleWidget() == dayView && dayView ) | 519 | if ( views->visibleWidget() == dayView && dayView ) |
520 | dayView->redraw(); | 520 | dayView->redraw(); |
521 | } | 521 | } |
522 | 522 | ||
523 | void DateBook::addEvent( const Event &e ) | 523 | void DateBook::addEvent( const Event &e ) |
524 | { | 524 | { |
525 | QDate d = e.start().date(); | 525 | QDate d = e.start().date(); |
526 | initDay(); | 526 | initDay(); |
527 | dayView->setDate( d ); | 527 | dayView->setDate( d ); |
528 | } | 528 | } |
529 | 529 | ||
530 | void DateBook::showDay( int year, int month, int day ) | 530 | void DateBook::showDay( int year, int month, int day ) |
531 | { | 531 | { |
532 | QDate d(year, month, day); | 532 | QDate d(year, month, day); |
533 | view(DAY,d); | 533 | view(DAY,d); |
534 | } | 534 | } |
535 | 535 | ||
536 | void DateBook::initDay() | 536 | void DateBook::initDay() |
537 | { | 537 | { |
538 | if ( !dayView ) { | 538 | if ( !dayView ) { |
539 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); | 539 | dayView = new DateBookDay( ampm, onMonday, db, views, "day view" ); |
540 | views->addWidget( dayView, DAY ); | 540 | views->addWidget( dayView, DAY ); |
541 | dayView->setStartViewTime( startTime ); | 541 | dayView->setStartViewTime( startTime ); |
542 | dayView->setJumpToCurTime( bJumpToCurTime ); | 542 | dayView->setJumpToCurTime( bJumpToCurTime ); |
543 | dayView->setRowStyle( rowStyle ); | 543 | dayView->setRowStyle( rowStyle ); |
544 | connect( this, SIGNAL( newEvent() ), | 544 | connect( this, SIGNAL( newEvent() ), |
545 | dayView, SLOT( redraw() ) ); | 545 | dayView, SLOT( redraw() ) ); |
546 | connect( dayView, SIGNAL( newEvent() ), | 546 | connect( dayView, SIGNAL( newEvent() ), |
547 | this, SLOT( fileNew() ) ); | 547 | this, SLOT( fileNew() ) ); |
548 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 548 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), |
549 | this, SLOT( removeEvent( const Event & ) ) ); | 549 | this, SLOT( removeEvent( const Event & ) ) ); |
550 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 550 | connect( dayView, SIGNAL( editEvent( const Event & ) ), |
551 | this, SLOT( editEvent( const Event & ) ) ); | 551 | this, SLOT( editEvent( const Event & ) ) ); |
552 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), | 552 | connect( dayView, SIGNAL( duplicateEvent( const Event & ) ), |
553 | this, SLOT( duplicateEvent( const Event & ) ) ); | 553 | this, SLOT( duplicateEvent( const Event & ) ) ); |
554 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | 554 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), |
555 | this, SLOT( beamEvent( const Event & ) ) ); | 555 | this, SLOT( beamEvent( const Event & ) ) ); |
556 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | 556 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), |
557 | this, SLOT(slotNewEventFromKey(const QString &)) ); | 557 | this, SLOT(slotNewEventFromKey(const QString &)) ); |
558 | } | 558 | } |
559 | } | 559 | } |
560 | 560 | ||
561 | void DateBook::initWeek() | 561 | void DateBook::initWeek() |
562 | { | 562 | { |
563 | if ( !weekView ) { | 563 | if ( !weekView ) { |
564 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 564 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
565 | weekView->setStartViewTime( startTime ); | 565 | weekView->setStartViewTime( startTime ); |
566 | views->addWidget( weekView, WEEK ); | 566 | views->addWidget( weekView, WEEK ); |
567 | connect( weekView, SIGNAL( showDate( int, int, int ) ), | 567 | connect( weekView, SIGNAL( showDate( int, int, int ) ), |
568 | this, SLOT( showDay( int, int, int ) ) ); | 568 | this, SLOT( showDay( int, int, int ) ) ); |
569 | connect( this, SIGNAL( newEvent() ), | 569 | connect( this, SIGNAL( newEvent() ), |
570 | weekView, SLOT( redraw() ) ); | 570 | weekView, SLOT( redraw() ) ); |
571 | } | 571 | } |
572 | //But also get it right: the year that we display can be different | 572 | //But also get it right: the year that we display can be different |
573 | //from the year of the current date. So, first find the year | 573 | //from the year of the current date. So, first find the year |
574 | //number of the current week. | 574 | //number of the current week. |
575 | 575 | ||
576 | int yearNumber, totWeeks; | 576 | int yearNumber, totWeeks; |
577 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 577 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
578 | 578 | ||
579 | QDate d = QDate( yearNumber, 12, 31 ); | 579 | QDate d = QDate( yearNumber, 12, 31 ); |
580 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 580 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
581 | 581 | ||
582 | while ( totWeeks == 1 ) { | 582 | while ( totWeeks == 1 ) { |
583 | d = d.addDays( -1 ); | 583 | d = d.addDays( -1 ); |
584 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 584 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
585 | } | 585 | } |
586 | if ( totWeeks != weekView->totalWeeks() ) | 586 | if ( totWeeks != weekView->totalWeeks() ) |
587 | weekView->setTotalWeeks( totWeeks ); | 587 | weekView->setTotalWeeks( totWeeks ); |
588 | } | 588 | } |
589 | void DateBook::initWeekLst() { | 589 | void DateBook::initWeekLst() { |
590 | if ( !weekLstView ) { | 590 | if ( !weekLstView ) { |
591 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 591 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, |
592 | views, "weeklst view" ); | 592 | views, "weeklst view" ); |
593 | views->addWidget( weekLstView, WEEKLST ); | 593 | views->addWidget( weekLstView, WEEKLST ); |
594 | 594 | ||
595 | //weekLstView->setStartViewTime( startTime ); | 595 | //weekLstView->setStartViewTime( startTime ); |
596 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 596 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), |
597 | this, SLOT( showDay( int, int, int ) ) ); | 597 | this, SLOT( showDay( int, int, int ) ) ); |
598 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 598 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, |
599 | const QDateTime &, | 599 | const QDateTime &, |
600 | const QString & ) ), | 600 | const QString & , const QString &) ), |
601 | this, SLOT( slotNewEntry( const QDateTime &, | 601 | this, SLOT( slotNewEntry( const QDateTime &, |
602 | const QDateTime &, | 602 | const QDateTime &, |
603 | const QString & ) ) ); | 603 | const QString & , const QString &) ) ); |
604 | connect( this, SIGNAL( newEvent() ), | 604 | connect( this, SIGNAL( newEvent() ), |
605 | weekLstView, SLOT( redraw() ) ); | 605 | weekLstView, SLOT( redraw() ) ); |
606 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | 606 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), |
607 | this, SLOT( editEvent( const Event & ) ) ); | 607 | this, SLOT( editEvent( const Event & ) ) ); |
608 | } | 608 | } |
609 | } | 609 | } |
610 | 610 | ||
611 | 611 | ||
612 | void DateBook::initMonth() | 612 | void DateBook::initMonth() |
613 | { | 613 | { |
614 | if ( !monthView ) { | 614 | if ( !monthView ) { |
615 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 615 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
616 | views->addWidget( monthView, MONTH ); | 616 | views->addWidget( monthView, MONTH ); |
617 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), | 617 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), |
618 | this, SLOT( showDay( int, int, int ) ) ); | 618 | this, SLOT( showDay( int, int, int ) ) ); |
619 | connect( this, SIGNAL( newEvent() ), | 619 | connect( this, SIGNAL( newEvent() ), |
620 | monthView, SLOT( redraw() ) ); | 620 | monthView, SLOT( redraw() ) ); |
621 | qApp->processEvents(); | 621 | qApp->processEvents(); |
622 | } | 622 | } |
623 | } | 623 | } |
624 | 624 | ||
625 | void DateBook::loadSettings() | 625 | void DateBook::loadSettings() |
626 | { | 626 | { |
627 | { | 627 | { |
628 | Config config( "qpe" ); | 628 | Config config( "qpe" ); |
629 | config.setGroup("Time"); | 629 | config.setGroup("Time"); |
630 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 630 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
631 | onMonday = config.readBoolEntry( "MONDAY" ); | 631 | onMonday = config.readBoolEntry( "MONDAY" ); |
632 | } | 632 | } |
633 | 633 | ||
634 | { | 634 | { |
635 | Config config("DateBook"); | 635 | Config config("DateBook"); |
636 | config.setGroup("Main"); | 636 | config.setGroup("Main"); |
637 | startTime = config.readNumEntry("startviewtime", 8); | 637 | startTime = config.readNumEntry("startviewtime", 8); |
638 | aPreset = config.readBoolEntry("alarmpreset"); | 638 | aPreset = config.readBoolEntry("alarmpreset"); |
639 | presetTime = config.readNumEntry("presettime"); | 639 | presetTime = config.readNumEntry("presettime"); |
640 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 640 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
641 | rowStyle = config.readNumEntry("rowstyle"); | 641 | rowStyle = config.readNumEntry("rowstyle"); |
642 | } | 642 | } |
643 | } | 643 | } |
644 | 644 | ||
645 | void DateBook::saveSettings() | 645 | void DateBook::saveSettings() |
646 | { | 646 | { |
647 | Config config( "qpe" ); | 647 | Config config( "qpe" ); |
648 | Config configDB( "DateBook" ); | 648 | Config configDB( "DateBook" ); |
649 | configDB.setGroup( "Main" ); | 649 | configDB.setGroup( "Main" ); |
650 | configDB.writeEntry("startviewtime",startTime); | 650 | configDB.writeEntry("startviewtime",startTime); |
651 | configDB.writeEntry("alarmpreset",aPreset); | 651 | configDB.writeEntry("alarmpreset",aPreset); |
652 | configDB.writeEntry("presettime",presetTime); | 652 | configDB.writeEntry("presettime",presetTime); |
653 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 653 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
654 | configDB.writeEntry("rowstyle", rowStyle); | 654 | configDB.writeEntry("rowstyle", rowStyle); |
655 | } | 655 | } |
656 | 656 | ||
657 | void DateBook::newDefaultView(QAction *a) { | 657 | void DateBook::newDefaultView(QAction *a) { |
658 | int val=DAY; | 658 | int val=DAY; |
659 | if (a->text() == "Day") val=DAY; | 659 | if (a->text() == "Day") val=DAY; |
660 | if (a->text() == "Week") val=WEEK; | 660 | if (a->text() == "Week") val=WEEK; |
661 | if (a->text() == "WeekLst") val=WEEKLST; | 661 | if (a->text() == "WeekLst") val=WEEKLST; |
662 | if (a->text() == "Month") val=MONTH; | 662 | if (a->text() == "Month") val=MONTH; |
663 | 663 | ||
664 | Config configDB( "DateBook" ); | 664 | Config configDB( "DateBook" ); |
665 | configDB.setGroup( "Main" ); | 665 | configDB.setGroup( "Main" ); |
666 | configDB.writeEntry("defaultview",val); | 666 | configDB.writeEntry("defaultview",val); |
667 | } | 667 | } |
668 | 668 | ||
669 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 669 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
670 | { | 670 | { |
671 | bool needShow = FALSE; | 671 | bool needShow = FALSE; |
672 | if ( msg == "alarm(QDateTime,int)" ) { | 672 | if ( msg == "alarm(QDateTime,int)" ) { |
673 | QDataStream ds(data,IO_ReadOnly); | 673 | QDataStream ds(data,IO_ReadOnly); |
674 | QDateTime when; int warn; | 674 | QDateTime when; int warn; |
675 | ds >> when >> warn; | 675 | ds >> when >> warn; |
676 | 676 | ||
677 | // check to make it's okay to continue, | 677 | // check to make it's okay to continue, |
678 | // this is the case that the time was set ahead, and | 678 | // this is the case that the time was set ahead, and |
679 | // we are forced given a stale alarm... | 679 | // we are forced given a stale alarm... |
680 | QDateTime current = QDateTime::currentDateTime(); | 680 | QDateTime current = QDateTime::currentDateTime(); |
681 | if ( current.time().hour() != when.time().hour() | 681 | if ( current.time().hour() != when.time().hour() |
682 | && current.time().minute() != when.time().minute() ) | 682 | && current.time().minute() != when.time().minute() ) |
683 | return; | 683 | return; |
684 | 684 | ||
685 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 685 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
686 | if ( list.count() > 0 ) { | 686 | if ( list.count() > 0 ) { |
687 | QString msg; | 687 | QString msg; |
688 | bool bSound = FALSE; | 688 | bool bSound = FALSE; |
689 | int stopTimer = 0; | 689 | int stopTimer = 0; |
690 | bool found = FALSE; | 690 | bool found = FALSE; |
691 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 691 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
692 | it!=list.end(); ++it ) { | 692 | it!=list.end(); ++it ) { |
693 | if ( (*it).event().hasAlarm() ) { | 693 | if ( (*it).event().hasAlarm() ) { |
694 | found = TRUE; | 694 | found = TRUE; |
695 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 695 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
696 | + "<BR>" + (*it).location() + "<BR>" | 696 | + "<BR>" + (*it).location() + "<BR>" |
697 | + TimeString::dateString((*it).event().start(),ampm) | 697 | + TimeString::dateString((*it).event().start(),ampm) |
698 | + (warn | 698 | + (warn |
699 | ? tr(" (in " + QString::number(warn) | 699 | ? tr(" (in " + QString::number(warn) |
700 | + tr(" minutes)")) | 700 | + tr(" minutes)")) |
701 | : QString("")) | 701 | : QString("")) |
702 | + "<BR>" | 702 | + "<BR>" |
703 | + (*it).notes() + "</CENTER>"; | 703 | + (*it).notes() + "</CENTER>"; |
704 | if ( (*it).event().alarmSound() != Event::Silent ) { | 704 | if ( (*it).event().alarmSound() != Event::Silent ) { |
705 | bSound = TRUE; | 705 | bSound = TRUE; |
706 | } | 706 | } |
707 | } | 707 | } |
708 | } | 708 | } |
709 | if ( found ) { | 709 | if ( found ) { |
710 | if ( bSound ) { | 710 | if ( bSound ) { |
711 | Sound::soundAlarm(); | 711 | Sound::soundAlarm(); |
712 | alarmCounter = 0; | 712 | alarmCounter = 0; |
713 | stopTimer = startTimer( 5000 ); | 713 | stopTimer = startTimer( 5000 ); |
714 | } | 714 | } |
715 | 715 | ||
716 | QDialog dlg( this, 0, TRUE ); | 716 | QDialog dlg( this, 0, TRUE ); |
717 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 717 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
718 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 718 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
719 | view->setResizePolicy( QScrollView::AutoOneFit ); | 719 | view->setResizePolicy( QScrollView::AutoOneFit ); |
720 | vb->addWidget( view ); | 720 | vb->addWidget( view ); |
721 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 721 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
722 | view->addChild( lblMsg ); | 722 | view->addChild( lblMsg ); |
723 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 723 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
724 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 724 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
725 | vb->addWidget( cmdOk ); | 725 | vb->addWidget( cmdOk ); |
726 | 726 | ||
727 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 727 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
728 | dlg.showMaximized(); | 728 | dlg.showMaximized(); |
729 | #endif | 729 | #endif |
730 | needShow = dlg.exec(); | 730 | needShow = dlg.exec(); |
731 | 731 | ||