summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-22 19:02:29 (UTC)
committer sandman <sandman>2002-12-22 19:02:29 (UTC)
commitc5de1fcc13b32e7c1f893dc3f8a1385b8698ebaf (patch) (unidiff)
tree3d9373bb500716cb8739e885fe5aa908e14283dc
parent3ae485ccb47ca618bc00d96a0e81c978a1cfbdaf (diff)
downloadopie-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)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp25
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
@@ -550,268 +550,273 @@ void DateBook::initWeekLst() {
550} 550}
551 551
552 552
553void DateBook::initMonth() 553void 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
566void DateBook::loadSettings() 566void 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
586void DateBook::saveSettings() 586void 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
598void DateBook::newDefaultView(QAction *a) { 598void 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
610void DateBook::appMessage(const QCString& msg, const QByteArray& data) 610void 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
703void DateBook::reload() 708void 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
715void DateBook::flush() 720void DateBook::flush()
716{ 721{
717 syncing = TRUE; 722 syncing = TRUE;
718 db->save(); 723 db->save();
719} 724}
720 725
721void DateBook::timerEvent( QTimerEvent *e ) 726void 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
731void DateBook::changeClock( bool newClock ) 736void 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
740void DateBook::changeWeek( bool m ) 745void 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
747void DateBook::slotToday() 752void 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
753void DateBook::closeEvent( QCloseEvent *e ) 758void 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"
782void DateBook::slotNewEventFromKey( const QString &str ) 787void 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}
809void DateBook::slotNewEntry(const QDateTime &start, const QDateTime &end, const QString &str) { 814void 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 );