author | sandman <sandman> | 2002-12-22 19:02:29 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-22 19:02:29 (UTC) |
commit | c5de1fcc13b32e7c1f893dc3f8a1385b8698ebaf (patch) (unidiff) | |
tree | 3d9373bb500716cb8739e885fe5aa908e14283dc | |
parent | 3ae485ccb47ca618bc00d96a0e81c978a1cfbdaf (diff) | |
download | opie-c5de1fcc13b32e7c1f893dc3f8a1385b8698ebaf.zip opie-c5de1fcc13b32e7c1f893dc3f8a1385b8698ebaf.tar.gz opie-c5de1fcc13b32e7c1f893dc3f8a1385b8698ebaf.tar.bz2 |
correct implementation for QCop "nextView()":
- if we are not active, raise the window
- if we are active, switch to the next view
(this is needed for the new appskey framework)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index c0a744a..7dcf156 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -486,396 +486,401 @@ void DateBook::initDay() | |||
486 | dayView->setRowStyle( rowStyle ); | 486 | dayView->setRowStyle( rowStyle ); |
487 | connect( this, SIGNAL( newEvent() ), | 487 | connect( this, SIGNAL( newEvent() ), |
488 | dayView, SLOT( redraw() ) ); | 488 | dayView, SLOT( redraw() ) ); |
489 | connect( dayView, SIGNAL( newEvent() ), | 489 | connect( dayView, SIGNAL( newEvent() ), |
490 | this, SLOT( fileNew() ) ); | 490 | this, SLOT( fileNew() ) ); |
491 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), | 491 | connect( dayView, SIGNAL( removeEvent( const Event & ) ), |
492 | this, SLOT( removeEvent( const Event & ) ) ); | 492 | this, SLOT( removeEvent( const Event & ) ) ); |
493 | connect( dayView, SIGNAL( editEvent( const Event & ) ), | 493 | connect( dayView, SIGNAL( editEvent( const Event & ) ), |
494 | this, SLOT( editEvent( const Event & ) ) ); | 494 | this, SLOT( editEvent( const Event & ) ) ); |
495 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), | 495 | connect( dayView, SIGNAL( beamEvent( const Event & ) ), |
496 | this, SLOT( beamEvent( const Event & ) ) ); | 496 | this, SLOT( beamEvent( const Event & ) ) ); |
497 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), | 497 | connect( dayView, SIGNAL(sigNewEvent(const QString &)), |
498 | this, SLOT(slotNewEventFromKey(const QString &)) ); | 498 | this, SLOT(slotNewEventFromKey(const QString &)) ); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | void DateBook::initWeek() | 502 | void DateBook::initWeek() |
503 | { | 503 | { |
504 | if ( !weekView ) { | 504 | if ( !weekView ) { |
505 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); | 505 | weekView = new DateBookWeek( ampm, onMonday, db, views, "week view" ); |
506 | weekView->setStartViewTime( startTime ); | 506 | weekView->setStartViewTime( startTime ); |
507 | views->addWidget( weekView, WEEK ); | 507 | views->addWidget( weekView, WEEK ); |
508 | connect( weekView, SIGNAL( showDate( int, int, int ) ), | 508 | connect( weekView, SIGNAL( showDate( int, int, int ) ), |
509 | this, SLOT( showDay( int, int, int ) ) ); | 509 | this, SLOT( showDay( int, int, int ) ) ); |
510 | connect( this, SIGNAL( newEvent() ), | 510 | connect( this, SIGNAL( newEvent() ), |
511 | weekView, SLOT( redraw() ) ); | 511 | weekView, SLOT( redraw() ) ); |
512 | } | 512 | } |
513 | //But also get it right: the year that we display can be different | 513 | //But also get it right: the year that we display can be different |
514 | //from the year of the current date. So, first find the year | 514 | //from the year of the current date. So, first find the year |
515 | //number of the current week. | 515 | //number of the current week. |
516 | 516 | ||
517 | int yearNumber, totWeeks; | 517 | int yearNumber, totWeeks; |
518 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 518 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
519 | 519 | ||
520 | QDate d = QDate( yearNumber, 12, 31 ); | 520 | QDate d = QDate( yearNumber, 12, 31 ); |
521 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 521 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
522 | 522 | ||
523 | while ( totWeeks == 1 ) { | 523 | while ( totWeeks == 1 ) { |
524 | d = d.addDays( -1 ); | 524 | d = d.addDays( -1 ); |
525 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 525 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
526 | } | 526 | } |
527 | if ( totWeeks != weekView->totalWeeks() ) | 527 | if ( totWeeks != weekView->totalWeeks() ) |
528 | weekView->setTotalWeeks( totWeeks ); | 528 | weekView->setTotalWeeks( totWeeks ); |
529 | } | 529 | } |
530 | void DateBook::initWeekLst() { | 530 | void DateBook::initWeekLst() { |
531 | if ( !weekLstView ) { | 531 | if ( !weekLstView ) { |
532 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 532 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, |
533 | views, "weeklst view" ); | 533 | views, "weeklst view" ); |
534 | views->addWidget( weekLstView, WEEKLST ); | 534 | views->addWidget( weekLstView, WEEKLST ); |
535 | 535 | ||
536 | //weekLstView->setStartViewTime( startTime ); | 536 | //weekLstView->setStartViewTime( startTime ); |
537 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 537 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), |
538 | this, SLOT( showDay( int, int, int ) ) ); | 538 | this, SLOT( showDay( int, int, int ) ) ); |
539 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 539 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, |
540 | const QDateTime &, | 540 | const QDateTime &, |
541 | const QString & ) ), | 541 | const QString & ) ), |
542 | this, SLOT( slotNewEntry( const QDateTime &, | 542 | this, SLOT( slotNewEntry( const QDateTime &, |
543 | const QDateTime &, | 543 | const QDateTime &, |
544 | const QString & ) ) ); | 544 | const QString & ) ) ); |
545 | connect( this, SIGNAL( newEvent() ), | 545 | connect( this, SIGNAL( newEvent() ), |
546 | weekLstView, SLOT( redraw() ) ); | 546 | weekLstView, SLOT( redraw() ) ); |
547 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | 547 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), |
548 | this, SLOT( editEvent( const Event & ) ) ); | 548 | this, SLOT( editEvent( const Event & ) ) ); |
549 | } | 549 | } |
550 | } | 550 | } |
551 | 551 | ||
552 | 552 | ||
553 | void DateBook::initMonth() | 553 | void DateBook::initMonth() |
554 | { | 554 | { |
555 | if ( !monthView ) { | 555 | if ( !monthView ) { |
556 | monthView = new DateBookMonth( views, "month view", FALSE, db ); | 556 | monthView = new DateBookMonth( views, "month view", FALSE, db ); |
557 | views->addWidget( monthView, MONTH ); | 557 | views->addWidget( monthView, MONTH ); |
558 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), | 558 | connect( monthView, SIGNAL( dateClicked( int, int, int ) ), |
559 | this, SLOT( showDay( int, int, int ) ) ); | 559 | this, SLOT( showDay( int, int, int ) ) ); |
560 | connect( this, SIGNAL( newEvent() ), | 560 | connect( this, SIGNAL( newEvent() ), |
561 | monthView, SLOT( redraw() ) ); | 561 | monthView, SLOT( redraw() ) ); |
562 | qApp->processEvents(); | 562 | qApp->processEvents(); |
563 | } | 563 | } |
564 | } | 564 | } |
565 | 565 | ||
566 | void DateBook::loadSettings() | 566 | void DateBook::loadSettings() |
567 | { | 567 | { |
568 | { | 568 | { |
569 | Config config( "qpe" ); | 569 | Config config( "qpe" ); |
570 | config.setGroup("Time"); | 570 | config.setGroup("Time"); |
571 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 571 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
572 | onMonday = config.readBoolEntry( "MONDAY" ); | 572 | onMonday = config.readBoolEntry( "MONDAY" ); |
573 | } | 573 | } |
574 | 574 | ||
575 | { | 575 | { |
576 | Config config("DateBook"); | 576 | Config config("DateBook"); |
577 | config.setGroup("Main"); | 577 | config.setGroup("Main"); |
578 | startTime = config.readNumEntry("startviewtime", 8); | 578 | startTime = config.readNumEntry("startviewtime", 8); |
579 | aPreset = config.readBoolEntry("alarmpreset"); | 579 | aPreset = config.readBoolEntry("alarmpreset"); |
580 | presetTime = config.readNumEntry("presettime"); | 580 | presetTime = config.readNumEntry("presettime"); |
581 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 581 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
582 | rowStyle = config.readNumEntry("rowstyle"); | 582 | rowStyle = config.readNumEntry("rowstyle"); |
583 | } | 583 | } |
584 | } | 584 | } |
585 | 585 | ||
586 | void DateBook::saveSettings() | 586 | void DateBook::saveSettings() |
587 | { | 587 | { |
588 | Config config( "qpe" ); | 588 | Config config( "qpe" ); |
589 | Config configDB( "DateBook" ); | 589 | Config configDB( "DateBook" ); |
590 | configDB.setGroup( "Main" ); | 590 | configDB.setGroup( "Main" ); |
591 | configDB.writeEntry("startviewtime",startTime); | 591 | configDB.writeEntry("startviewtime",startTime); |
592 | configDB.writeEntry("alarmpreset",aPreset); | 592 | configDB.writeEntry("alarmpreset",aPreset); |
593 | configDB.writeEntry("presettime",presetTime); | 593 | configDB.writeEntry("presettime",presetTime); |
594 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); | 594 | configDB.writeEntry("jumptocurtime", bJumpToCurTime); |
595 | configDB.writeEntry("rowstyle", rowStyle); | 595 | configDB.writeEntry("rowstyle", rowStyle); |
596 | } | 596 | } |
597 | 597 | ||
598 | void DateBook::newDefaultView(QAction *a) { | 598 | void DateBook::newDefaultView(QAction *a) { |
599 | int val=DAY; | 599 | int val=DAY; |
600 | if (a->text() == "Day") val=DAY; | 600 | if (a->text() == "Day") val=DAY; |
601 | if (a->text() == "Week") val=WEEK; | 601 | if (a->text() == "Week") val=WEEK; |
602 | if (a->text() == "WeekLst") val=WEEKLST; | 602 | if (a->text() == "WeekLst") val=WEEKLST; |
603 | if (a->text() == "Month") val=MONTH; | 603 | if (a->text() == "Month") val=MONTH; |
604 | 604 | ||
605 | Config configDB( "DateBook" ); | 605 | Config configDB( "DateBook" ); |
606 | configDB.setGroup( "Main" ); | 606 | configDB.setGroup( "Main" ); |
607 | configDB.writeEntry("defaultview",val); | 607 | configDB.writeEntry("defaultview",val); |
608 | } | 608 | } |
609 | 609 | ||
610 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 610 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
611 | { | 611 | { |
612 | bool needShow = FALSE; | 612 | bool needShow = FALSE; |
613 | if ( msg == "alarm(QDateTime,int)" ) { | 613 | if ( msg == "alarm(QDateTime,int)" ) { |
614 | QDataStream ds(data,IO_ReadOnly); | 614 | QDataStream ds(data,IO_ReadOnly); |
615 | QDateTime when; int warn; | 615 | QDateTime when; int warn; |
616 | ds >> when >> warn; | 616 | ds >> when >> warn; |
617 | 617 | ||
618 | // check to make it's okay to continue, | 618 | // check to make it's okay to continue, |
619 | // this is the case that the time was set ahead, and | 619 | // this is the case that the time was set ahead, and |
620 | // we are forced given a stale alarm... | 620 | // we are forced given a stale alarm... |
621 | QDateTime current = QDateTime::currentDateTime(); | 621 | QDateTime current = QDateTime::currentDateTime(); |
622 | if ( current.time().hour() != when.time().hour() | 622 | if ( current.time().hour() != when.time().hour() |
623 | && current.time().minute() != when.time().minute() ) | 623 | && current.time().minute() != when.time().minute() ) |
624 | return; | 624 | return; |
625 | 625 | ||
626 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 626 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
627 | if ( list.count() > 0 ) { | 627 | if ( list.count() > 0 ) { |
628 | QString msg; | 628 | QString msg; |
629 | bool bSound = FALSE; | 629 | bool bSound = FALSE; |
630 | int stopTimer = 0; | 630 | int stopTimer = 0; |
631 | bool found = FALSE; | 631 | bool found = FALSE; |
632 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 632 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); |
633 | it!=list.end(); ++it ) { | 633 | it!=list.end(); ++it ) { |
634 | if ( (*it).event().hasAlarm() ) { | 634 | if ( (*it).event().hasAlarm() ) { |
635 | found = TRUE; | 635 | found = TRUE; |
636 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 636 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
637 | + "<BR>" + (*it).location() + "<BR>" | 637 | + "<BR>" + (*it).location() + "<BR>" |
638 | + TimeString::dateString((*it).event().start(),ampm) | 638 | + TimeString::dateString((*it).event().start(),ampm) |
639 | + (warn | 639 | + (warn |
640 | ? tr(" (in " + QString::number(warn) | 640 | ? tr(" (in " + QString::number(warn) |
641 | + tr(" minutes)")) | 641 | + tr(" minutes)")) |
642 | : QString("")) | 642 | : QString("")) |
643 | + "<BR>" | 643 | + "<BR>" |
644 | + (*it).notes() + "</CENTER>"; | 644 | + (*it).notes() + "</CENTER>"; |
645 | if ( (*it).event().alarmSound() != Event::Silent ) { | 645 | if ( (*it).event().alarmSound() != Event::Silent ) { |
646 | bSound = TRUE; | 646 | bSound = TRUE; |
647 | } | 647 | } |
648 | } | 648 | } |
649 | } | 649 | } |
650 | if ( found ) { | 650 | if ( found ) { |
651 | if ( bSound ) { | 651 | if ( bSound ) { |
652 | Sound::soundAlarm(); | 652 | Sound::soundAlarm(); |
653 | alarmCounter = 0; | 653 | alarmCounter = 0; |
654 | stopTimer = startTimer( 5000 ); | 654 | stopTimer = startTimer( 5000 ); |
655 | } | 655 | } |
656 | 656 | ||
657 | QDialog dlg( this, 0, TRUE ); | 657 | QDialog dlg( this, 0, TRUE ); |
658 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 658 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
659 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 659 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
660 | view->setResizePolicy( QScrollView::AutoOneFit ); | 660 | view->setResizePolicy( QScrollView::AutoOneFit ); |
661 | vb->addWidget( view ); | 661 | vb->addWidget( view ); |
662 | QLabel *lblMsg = new QLabel( msg, &dlg ); | 662 | QLabel *lblMsg = new QLabel( msg, &dlg ); |
663 | view->addChild( lblMsg ); | 663 | view->addChild( lblMsg ); |
664 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); | 664 | QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); |
665 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); | 665 | connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); |
666 | vb->addWidget( cmdOk ); | 666 | vb->addWidget( cmdOk ); |
667 | 667 | ||
668 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 668 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
669 | dlg.showMaximized(); | 669 | dlg.showMaximized(); |
670 | #endif | 670 | #endif |
671 | needShow = dlg.exec(); | 671 | needShow = dlg.exec(); |
672 | 672 | ||
673 | if ( bSound ) | 673 | if ( bSound ) |
674 | killTimer( stopTimer ); | 674 | killTimer( stopTimer ); |
675 | } | 675 | } |
676 | } | 676 | } |
677 | } else if ( msg == "nextView()" ) { | 677 | } else if ( msg == "nextView()" ) { |
678 | QWidget* cur = views->visibleWidget(); | 678 | if ( !qApp-> activeWindow ( )) { |
679 | if ( cur ) { | ||
680 | if ( cur == dayView ) | ||
681 | viewWeek(); | ||
682 | else if ( cur == weekView ) | ||
683 | viewWeekLst(); | ||
684 | else if ( cur == weekLstView ) | ||
685 | viewMonth(); | ||
686 | else if ( cur == monthView ) | ||
687 | viewDay(); | ||
688 | needShow = TRUE; | 679 | needShow = TRUE; |
689 | } | 680 | } |
681 | else { | ||
682 | QWidget* cur = views->visibleWidget(); | ||
683 | if ( cur ) { | ||
684 | if ( cur == dayView ) | ||
685 | viewWeek(); | ||
686 | else if ( cur == weekView ) | ||
687 | viewWeekLst(); | ||
688 | else if ( cur == weekLstView ) | ||
689 | viewMonth(); | ||
690 | else if ( cur == monthView ) | ||
691 | viewDay(); | ||
692 | needShow = TRUE; | ||
693 | } | ||
694 | } | ||
690 | } | 695 | } |
691 | if ( needShow ) { | 696 | if ( needShow ) { |
692 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 697 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
693 | showMaximized(); | 698 | showMaximized(); |
694 | #else | 699 | #else |
695 | show(); | 700 | show(); |
696 | #endif | 701 | #endif |
697 | raise(); | 702 | raise(); |
698 | QPEApplication::setKeepRunning(); | 703 | QPEApplication::setKeepRunning(); |
699 | setActiveWindow(); | 704 | setActiveWindow(); |
700 | } | 705 | } |
701 | } | 706 | } |
702 | 707 | ||
703 | void DateBook::reload() | 708 | void DateBook::reload() |
704 | { | 709 | { |
705 | db->reload(); | 710 | db->reload(); |
706 | if ( dayAction->isOn() ) | 711 | if ( dayAction->isOn() ) |
707 | viewDay(); | 712 | viewDay(); |
708 | else if ( weekAction->isOn() ) | 713 | else if ( weekAction->isOn() ) |
709 | viewWeek(); | 714 | viewWeek(); |
710 | else if ( monthAction->isOn() ) | 715 | else if ( monthAction->isOn() ) |
711 | viewMonth(); | 716 | viewMonth(); |
712 | syncing = FALSE; | 717 | syncing = FALSE; |
713 | } | 718 | } |
714 | 719 | ||
715 | void DateBook::flush() | 720 | void DateBook::flush() |
716 | { | 721 | { |
717 | syncing = TRUE; | 722 | syncing = TRUE; |
718 | db->save(); | 723 | db->save(); |
719 | } | 724 | } |
720 | 725 | ||
721 | void DateBook::timerEvent( QTimerEvent *e ) | 726 | void DateBook::timerEvent( QTimerEvent *e ) |
722 | { | 727 | { |
723 | if ( alarmCounter < 10 ) { | 728 | if ( alarmCounter < 10 ) { |
724 | alarmCounter++; | 729 | alarmCounter++; |
725 | Sound::soundAlarm(); | 730 | Sound::soundAlarm(); |
726 | } | 731 | } |
727 | else | 732 | else |
728 | killTimer( e->timerId() ); | 733 | killTimer( e->timerId() ); |
729 | } | 734 | } |
730 | 735 | ||
731 | void DateBook::changeClock( bool newClock ) | 736 | void DateBook::changeClock( bool newClock ) |
732 | { | 737 | { |
733 | ampm = newClock; | 738 | ampm = newClock; |
734 | // repaint the affected objects... | 739 | // repaint the affected objects... |
735 | if (dayView) dayView->redraw(); | 740 | if (dayView) dayView->redraw(); |
736 | if (weekView) weekView->redraw(); | 741 | if (weekView) weekView->redraw(); |
737 | if (weekLstView) weekLstView->redraw(); | 742 | if (weekLstView) weekLstView->redraw(); |
738 | } | 743 | } |
739 | 744 | ||
740 | void DateBook::changeWeek( bool m ) | 745 | void DateBook::changeWeek( bool m ) |
741 | { | 746 | { |
742 | /* no need to redraw, each widget catches. Do need to | 747 | /* no need to redraw, each widget catches. Do need to |
743 | store though for widgets we haven't made yet */ | 748 | store though for widgets we haven't made yet */ |
744 | onMonday = m; | 749 | onMonday = m; |
745 | } | 750 | } |
746 | 751 | ||
747 | void DateBook::slotToday() | 752 | void DateBook::slotToday() |
748 | { | 753 | { |
749 | // we need to view today using default view | 754 | // we need to view today using default view |
750 | viewDefault(QDate::currentDate()); | 755 | viewDefault(QDate::currentDate()); |
751 | } | 756 | } |
752 | 757 | ||
753 | void DateBook::closeEvent( QCloseEvent *e ) | 758 | void DateBook::closeEvent( QCloseEvent *e ) |
754 | { | 759 | { |
755 | if(syncing) { | 760 | if(syncing) { |
756 | /* no need to save, did that at flush */ | 761 | /* no need to save, did that at flush */ |
757 | e->accept(); | 762 | e->accept(); |
758 | return; | 763 | return; |
759 | } | 764 | } |
760 | 765 | ||
761 | // save settings will generate it's own error messages, no | 766 | // save settings will generate it's own error messages, no |
762 | // need to do checking ourselves. | 767 | // need to do checking ourselves. |
763 | saveSettings(); | 768 | saveSettings(); |
764 | if ( db->save() ) | 769 | if ( db->save() ) |
765 | e->accept(); | 770 | e->accept(); |
766 | else { | 771 | else { |
767 | if ( QMessageBox::critical( this, tr( "Out of space" ), | 772 | if ( QMessageBox::critical( this, tr( "Out of space" ), |
768 | tr("Calendar was unable to save\n" | 773 | tr("Calendar was unable to save\n" |
769 | "your changes.\n" | 774 | "your changes.\n" |
770 | "Free up some space and try again.\n" | 775 | "Free up some space and try again.\n" |
771 | "\nQuit anyway?"), | 776 | "\nQuit anyway?"), |
772 | QMessageBox::Yes|QMessageBox::Escape, | 777 | QMessageBox::Yes|QMessageBox::Escape, |
773 | QMessageBox::No|QMessageBox::Default ) | 778 | QMessageBox::No|QMessageBox::Default ) |
774 | != QMessageBox::No ) | 779 | != QMessageBox::No ) |
775 | e->accept(); | 780 | e->accept(); |
776 | else | 781 | else |
777 | e->ignore(); | 782 | e->ignore(); |
778 | } | 783 | } |
779 | } | 784 | } |
780 | 785 | ||
781 | // Entering directly from the "keyboard" | 786 | // Entering directly from the "keyboard" |
782 | void DateBook::slotNewEventFromKey( const QString &str ) | 787 | void DateBook::slotNewEventFromKey( const QString &str ) |
783 | { | 788 | { |
784 | if (syncing) { | 789 | if (syncing) { |
785 | QMessageBox::warning( this, tr("Calendar"), | 790 | QMessageBox::warning( this, tr("Calendar"), |
786 | tr( "Can not edit data, currently syncing") ); | 791 | tr( "Can not edit data, currently syncing") ); |
787 | return; | 792 | return; |
788 | } | 793 | } |
789 | 794 | ||
790 | // We get to here from a key pressed in the Day View | 795 | // We get to here from a key pressed in the Day View |
791 | // So we can assume some things. We want the string | 796 | // So we can assume some things. We want the string |
792 | // passed in to be part of the description. | 797 | // passed in to be part of the description. |
793 | QDateTime start, end; | 798 | QDateTime start, end; |
794 | if ( views->visibleWidget() == dayView ) { | 799 | if ( views->visibleWidget() == dayView ) { |
795 | dayView->selectedDates( start, end ); | 800 | dayView->selectedDates( start, end ); |
796 | } else if ( views->visibleWidget() == monthView ) { | 801 | } else if ( views->visibleWidget() == monthView ) { |
797 | QDate d = monthView->selectedDate(); | 802 | QDate d = monthView->selectedDate(); |
798 | start = end = d; | 803 | start = end = d; |
799 | start.setTime( QTime( 10, 0 ) ); | 804 | start.setTime( QTime( 10, 0 ) ); |
800 | end.setTime( QTime( 12, 0 ) ); | 805 | end.setTime( QTime( 12, 0 ) ); |
801 | } else if ( views->visibleWidget() == weekView ) { | 806 | } else if ( views->visibleWidget() == weekView ) { |
802 | QDate d = weekView->date(); | 807 | QDate d = weekView->date(); |
803 | start = end = d; | 808 | start = end = d; |
804 | start.setTime( QTime( 10, 0 ) ); | 809 | start.setTime( QTime( 10, 0 ) ); |
805 | end.setTime( QTime( 12, 0 ) ); | 810 | end.setTime( QTime( 12, 0 ) ); |
806 | } | 811 | } |
807 | slotNewEntry(start, end, str); | 812 | slotNewEntry(start, end, str); |
808 | } | 813 | } |
809 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { | 814 | void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { |
810 | // argh! This really needs to be encapsulated in a class | 815 | // argh! This really needs to be encapsulated in a class |
811 | // or function. | 816 | // or function. |
812 | QDialog newDlg( this, 0, TRUE ); | 817 | QDialog newDlg( this, 0, TRUE ); |
813 | newDlg.setCaption( DateEntryBase::tr("New Event") ); | 818 | newDlg.setCaption( DateEntryBase::tr("New Event") ); |
814 | DateEntry *e; | 819 | DateEntry *e; |
815 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); | 820 | QVBoxLayout *vb = new QVBoxLayout( &newDlg ); |
816 | QScrollView *sv = new QScrollView( &newDlg ); | 821 | QScrollView *sv = new QScrollView( &newDlg ); |
817 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 822 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
818 | sv->setFrameStyle( QFrame::NoFrame ); | 823 | sv->setFrameStyle( QFrame::NoFrame ); |
819 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); | 824 | sv->setHScrollBarMode( QScrollView::AlwaysOff ); |
820 | vb->addWidget( sv ); | 825 | vb->addWidget( sv ); |
821 | 826 | ||
822 | Event ev; | 827 | Event ev; |
823 | ev.setDescription( str ); | 828 | ev.setDescription( str ); |
824 | // When the new gui comes in, change this... | 829 | // When the new gui comes in, change this... |
825 | ev.setLocation( tr("(Unknown)") ); | 830 | ev.setLocation( tr("(Unknown)") ); |
826 | ev.setStart( start ); | 831 | ev.setStart( start ); |
827 | ev.setEnd( end ); | 832 | ev.setEnd( end ); |
828 | 833 | ||
829 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); | 834 | e = new DateEntry( onMonday, ev, ampm, &newDlg ); |
830 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); | 835 | e->setAlarmEnabled( aPreset, presetTime, Event::Loud ); |
831 | sv->addChild( e ); | 836 | sv->addChild( e ); |
832 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) | 837 | #if defined(Q_WS_QWS) || defined(_WS_QWS_) |
833 | newDlg.showMaximized(); | 838 | newDlg.showMaximized(); |
834 | #endif | 839 | #endif |
835 | while (newDlg.exec()) { | 840 | while (newDlg.exec()) { |
836 | ev = e->event(); | 841 | ev = e->event(); |
837 | ev.assignUid(); | 842 | ev.assignUid(); |
838 | QString error = checkEvent( ev ); | 843 | QString error = checkEvent( ev ); |
839 | if ( !error.isNull() ) { | 844 | if ( !error.isNull() ) { |
840 | if ( QMessageBox::warning( this, tr("Error!"), | 845 | if ( QMessageBox::warning( this, tr("Error!"), |
841 | error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) | 846 | error, tr("Fix it"), tr("Continue"), 0, 0, 1 ) == 0 ) |
842 | continue; | 847 | continue; |
843 | } | 848 | } |
844 | db->addEvent( ev ); | 849 | db->addEvent( ev ); |
845 | emit newEvent(); | 850 | emit newEvent(); |
846 | break; | 851 | break; |
847 | } | 852 | } |
848 | } | 853 | } |
849 | 854 | ||
850 | void DateBook::setDocument( const QString &filename ) | 855 | void DateBook::setDocument( const QString &filename ) |
851 | { | 856 | { |
852 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; | 857 | if ( filename.find(".vcs") != int(filename.length()) - 4 ) return; |
853 | 858 | ||
854 | QValueList<Event> tl = Event::readVCalendar( filename ); | 859 | QValueList<Event> tl = Event::readVCalendar( filename ); |
855 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { | 860 | for( QValueList<Event>::Iterator it = tl.begin(); it != tl.end(); ++it ) { |
856 | db->addEvent( *it ); | 861 | db->addEvent( *it ); |
857 | } | 862 | } |
858 | } | 863 | } |
859 | 864 | ||
860 | static const char * beamfile = "/tmp/obex/event.vcs"; | 865 | static const char * beamfile = "/tmp/obex/event.vcs"; |
861 | 866 | ||
862 | void DateBook::beamEvent( const Event &e ) | 867 | void DateBook::beamEvent( const Event &e ) |
863 | { | 868 | { |
864 | qDebug("trying to beamn"); | 869 | qDebug("trying to beamn"); |
865 | unlink( beamfile ); // delete if exists | 870 | unlink( beamfile ); // delete if exists |
866 | mkdir("/tmp/obex/", 0755); | 871 | mkdir("/tmp/obex/", 0755); |
867 | Event::writeVCalendar( beamfile, e ); | 872 | Event::writeVCalendar( beamfile, e ); |
868 | Ir *ir = new Ir( this ); | 873 | Ir *ir = new Ir( this ); |
869 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); | 874 | connect( ir, SIGNAL( done( Ir * ) ), this, SLOT( beamDone( Ir * ) ) ); |
870 | QString description = e.description(); | 875 | QString description = e.description(); |
871 | ir->send( beamfile, description, "text/x-vCalendar" ); | 876 | ir->send( beamfile, description, "text/x-vCalendar" ); |
872 | } | 877 | } |
873 | 878 | ||
874 | void DateBook::beamDone( Ir *ir ) | 879 | void DateBook::beamDone( Ir *ir ) |
875 | { | 880 | { |
876 | delete ir; | 881 | delete ir; |
877 | unlink( beamfile ); | 882 | unlink( beamfile ); |
878 | } | 883 | } |
879 | 884 | ||
880 | void DateBook::slotFind() | 885 | void DateBook::slotFind() |
881 | { | 886 | { |