summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebook.cpp
authorumopapisdn <umopapisdn>2003-04-12 03:56:46 (UTC)
committer umopapisdn <umopapisdn>2003-04-12 03:56:46 (UTC)
commit8c690a7bb709773217ba3d39d3ef769a2414cc72 (patch) (unidiff)
treea34bae70ee8dc46f40f60150e1703088fbc4da36 /core/pim/datebook/datebook.cpp
parent212aef7fd20182fe926644af2ab10a4b49549440 (diff)
downloadopie-8c690a7bb709773217ba3d39d3ef769a2414cc72.zip
opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.gz
opie-8c690a7bb709773217ba3d39d3ef769a2414cc72.tar.bz2
New feature:
Added a configurable option to make the weeklist view display either no times at all, only start times, or both start and end time. Also moved the configuration of default view from the menu into the preference dialog.
Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp380
1 files changed, 169 insertions, 211 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 829f8f8..4fbcb10 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -72,8 +72,2 @@
72 72
73#define DAY 1
74#define WEEK 2
75#define WEEKLST 4
76#define MONTH 3
77
78
79DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 73DateBook::DateBook( QWidget *parent, const char *, WFlags f )
@@ -168,3 +162,3 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
168 162
169 a = new QAction( tr( "Alarm and Start Time..." ), QString::null, 0, 0 ); 163 a = new QAction( tr( "Edit..." ), QString::null, 0, 0 );
170 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) ); 164 connect( a, SIGNAL( activated() ), this, SLOT( slotSettings() ) );
@@ -172,37 +166,12 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
172 166
173 QPopupMenu *default_view = new QPopupMenu(this); 167 if(defaultView==DAY) viewDay();
174 settings->insertItem( tr( "Default View" ),default_view ); 168 if(defaultView==WEEK) needEvilHack=true;// viewWeek();
175 default_view->setCheckable(TRUE); 169 if(defaultView==WEEKLST) viewWeekLst();
176 170 if(defaultView==MONTH) viewMonth();
177 Config config("DateBook"); 171
178 config.setGroup("Main"); 172 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) );
179 int current=config.readNumEntry("defaultview", DAY); 173 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) );
180
181 QActionGroup *ag = new QActionGroup(this);
182 a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true );
183 if (current==DAY) a->setOn(true), viewDay();
184 ag->insert(a);
185 a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true );
186 if (current==WEEK) a->setOn(true), /*viewWeek(),*/ needEvilHack = true;
187 ag->insert(a);
188 a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true );
189 if (current==WEEKLST) a->setOn(true), viewWeekLst();
190 ag->insert(a);
191 a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true );
192 if (current==MONTH) a->setOn(true), viewMonth();
193 ag->insert(a);
194
195 ag->addTo(default_view);
196 connect(ag, SIGNAL( selected ( QAction * ) ),
197 this, SLOT( newDefaultView(QAction *) )
198 );
199
200 connect( qApp, SIGNAL(clockChanged(bool)),
201 this, SLOT(changeClock(bool)) );
202 connect( qApp, SIGNAL(weekChanged(bool)),
203 this, SLOT(changeWeek(bool)) );
204 174
205#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 175#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
206 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), 176 connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), this, SLOT(appMessage(const QCString&, const QByteArray&)) );
207 this, SLOT(appMessage(const QCString&, const QByteArray&)) );
208#endif 177#endif
@@ -213,7 +182,5 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f )
213 QCopChannel *channel = new QCopChannel( "QPE/System", this ); 182 QCopChannel *channel = new QCopChannel( "QPE/System", this );
214 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 183 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
215 this, SLOT(receive(const QCString&, const QByteArray&)) );
216 channel = new QCopChannel( "QPE/Datebook", this ); 184 channel = new QCopChannel( "QPE/Datebook", this );
217 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), 185 connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) );
218 this, SLOT(receive(const QCString&, const QByteArray&)) );
219 qDebug("olle\n"); 186 qDebug("olle\n");
@@ -269,7 +236,10 @@ void DateBook::slotSettings()
269{ 236{
270 DateBookSettings frmSettings( ampm, this ); 237 DateBookSettings frmSettings( ampm, this );
271 frmSettings.setStartTime( startTime ); 238 frmSettings.setStartTime( startTime );
272 frmSettings.setAlarmPreset( aPreset, presetTime ); 239 frmSettings.setAlarmPreset( aPreset, presetTime );
273 frmSettings.setJumpToCurTime( bJumpToCurTime ); 240 frmSettings.setJumpToCurTime( bJumpToCurTime );
274 frmSettings.setRowStyle( rowStyle ); 241 frmSettings.setRowStyle( rowStyle );
242 frmSettings.comboDefaultView->setCurrentItem(defaultView-1);
243 frmSettings.comboWeekListView->setCurrentItem(weeklistviewconfig);
244
275#if defined (Q_WS_QWS) || defined(_WS_QWS_) 245#if defined (Q_WS_QWS) || defined(_WS_QWS_)
@@ -285,2 +255,4 @@ void DateBook::slotSettings()
285 rowStyle = frmSettings.rowStyle(); 255 rowStyle = frmSettings.rowStyle();
256 defaultView=frmSettings.comboDefaultView->currentItem()+1;
257 weeklistviewconfig=frmSettings.comboWeekListView->currentItem();
286 258
@@ -302,2 +274,4 @@ void DateBook::slotSettings()
302 weekView->redraw(); 274 weekView->redraw();
275 else if ( views->visibleWidget() == weekLstView )
276 weekLstView->redraw();
303 } 277 }
@@ -385,2 +359,3 @@ void DateBook::view(int v, const QDate &d) {
385void DateBook::viewDefault(const QDate &d) { 359void DateBook::viewDefault(const QDate &d) {
360/*
386 Config config("DateBook"); 361 Config config("DateBook");
@@ -390,2 +365,4 @@ void DateBook::viewDefault(const QDate &d) {
390 view(current,d); 365 view(current,d);
366*/
367 view(defaultView,d);
391} 368}
@@ -610,10 +587,7 @@ void DateBook::loadSettings()
610{ 587{
611 { 588 Config qpeconfig( "qpe" );
612 Config config( "qpe" ); 589 qpeconfig.setGroup("Time");
613 config.setGroup("Time"); 590 ampm = qpeconfig.readBoolEntry( "AMPM", TRUE );
614 ampm = config.readBoolEntry( "AMPM", TRUE ); 591 onMonday = qpeconfig.readBoolEntry( "MONDAY" );
615 onMonday = config.readBoolEntry( "MONDAY" );
616 }
617 592
618 {
619 Config config("DateBook"); 593 Config config("DateBook");
@@ -625,3 +599,4 @@ void DateBook::loadSettings()
625 rowStyle = config.readNumEntry("rowstyle"); 599 rowStyle = config.readNumEntry("rowstyle");
626 } 600 defaultView = config.readNumEntry("defaultview",DAY);
601 weeklistviewconfig = config.readNumEntry("weeklistviewconfig",NORMAL);
627} 602}
@@ -630,22 +605,12 @@ void DateBook::saveSettings()
630{ 605{
631 Config config( "qpe" ); 606 Config config( "qpe" );
632 Config configDB( "DateBook" ); 607 Config configDB( "DateBook" );
633 configDB.setGroup( "Main" ); 608 configDB.setGroup( "Main" );
634 configDB.writeEntry("startviewtime",startTime); 609 configDB.writeEntry("startviewtime",startTime);
635 configDB.writeEntry("alarmpreset",aPreset); 610 configDB.writeEntry("alarmpreset",aPreset);
636 configDB.writeEntry("presettime",presetTime); 611 configDB.writeEntry("presettime",presetTime);
637 configDB.writeEntry("jumptocurtime", bJumpToCurTime); 612 configDB.writeEntry("jumptocurtime", bJumpToCurTime);
638 configDB.writeEntry("rowstyle", rowStyle); 613 configDB.writeEntry("rowstyle", rowStyle);
639} 614 configDB.writeEntry("defaultview",defaultView);
640 615 configDB.writeEntry("weeklistviewconfig",weeklistviewconfig);
641void DateBook::newDefaultView(QAction *a) {
642 int val=DAY;
643 if (a->text() == "Day") val=DAY;
644 if (a->text() == "Week") val=WEEK;
645 if (a->text() == "WeekLst") val=WEEKLST;
646 if (a->text() == "Month") val=MONTH;
647
648 Config configDB( "DateBook" );
649 configDB.setGroup( "Main" );
650 configDB.writeEntry("defaultview",val);
651} 616}
@@ -654,85 +619,81 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
654{ 619{
655 bool needShow = FALSE; 620 bool needShow = FALSE;
656 if ( msg == "alarm(QDateTime,int)" ) { 621 if ( msg == "alarm(QDateTime,int)" ) {
657 QDataStream ds(data,IO_ReadOnly); 622 QDataStream ds(data,IO_ReadOnly);
658 QDateTime when; int warn; 623 QDateTime when; int warn;
659 ds >> when >> warn; 624 ds >> when >> warn;
660 625
661 // check to make it's okay to continue, 626 // check to make it's okay to continue,
662 // this is the case that the time was set ahead, and 627 // this is the case that the time was set ahead, and
663 // we are forced given a stale alarm... 628 // we are forced given a stale alarm...
664 QDateTime current = QDateTime::currentDateTime(); 629 QDateTime current = QDateTime::currentDateTime();
665 if ( current.time().hour() != when.time().hour() 630 if ( current.time().hour() != when.time().hour() && current.time().minute() != when.time().minute() )
666 && current.time().minute() != when.time().minute() ) 631 return;
667 return; 632
668 633 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
669 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 634 if ( list.count() > 0 ) {
670 if ( list.count() > 0 ) { 635 QString msg;
671 QString msg; 636 bool bSound = FALSE;
672 bool bSound = FALSE; 637 int stopTimer = 0;
673 int stopTimer = 0; 638 bool found = FALSE;
674 bool found = FALSE; 639 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) {
675 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 640 if ( (*it).event().hasAlarm() ) {
676 it!=list.end(); ++it ) { 641 found = TRUE;
677 if ( (*it).event().hasAlarm() ) { 642 msg += "<CENTER><B>" + (*it).description() + "</B>"
678 found = TRUE; 643 + "<BR>" + (*it).location() + "<BR>"
679 msg += "<CENTER><B>" + (*it).description() + "</B>" 644 + TimeString::dateString((*it).event().start(),ampm)
680 + "<BR>" + (*it).location() + "<BR>" 645 + (warn
681 + TimeString::dateString((*it).event().start(),ampm) 646 ? tr(" (in " + QString::number(warn)
682 + (warn 647 + tr(" minutes)"))
683 ? tr(" (in " + QString::number(warn) 648 : QString(""))
684 + tr(" minutes)")) 649 + "<BR>"
685 : QString("")) 650 + (*it).notes() + "</CENTER>";
686 + "<BR>" 651 if ( (*it).event().alarmSound() != Event::Silent ) {
687 + (*it).notes() + "</CENTER>"; 652 bSound = TRUE;
688 if ( (*it).event().alarmSound() != Event::Silent ) { 653 }
689 bSound = TRUE; 654 }
690 } 655 }
691 } 656 if ( found ) {
692 } 657 if ( bSound ) {
693 if ( found ) { 658 Sound::soundAlarm();
694 if ( bSound ) { 659 alarmCounter = 0;
695 Sound::soundAlarm(); 660 stopTimer = startTimer( 5000 );
696 alarmCounter = 0; 661 }
697 stopTimer = startTimer( 5000 ); 662 QDialog dlg( this, 0, TRUE );
698 } 663 QVBoxLayout *vb = new QVBoxLayout( &dlg );
699 664 QScrollView *view = new QScrollView( &dlg, "scrollView");
700 QDialog dlg( this, 0, TRUE ); 665 view->setResizePolicy( QScrollView::AutoOneFit );
701 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 666 vb->addWidget( view );
702 QScrollView *view = new QScrollView( &dlg, "scrollView"); 667 QLabel *lblMsg = new QLabel( msg, &dlg );
703 view->setResizePolicy( QScrollView::AutoOneFit ); 668 view->addChild( lblMsg );
704 vb->addWidget( view ); 669 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
705 QLabel *lblMsg = new QLabel( msg, &dlg ); 670 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
706 view->addChild( lblMsg ); 671 vb->addWidget( cmdOk );
707 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
708 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
709 vb->addWidget( cmdOk );
710 672
711#if defined(Q_WS_QWS) || defined(_WS_QWS_) 673#if defined(Q_WS_QWS) || defined(_WS_QWS_)
712 dlg.showMaximized(); 674 dlg.showMaximized();
713#endif 675#endif
714 needShow = dlg.exec(); 676 needShow = dlg.exec();
715 677
716 if ( bSound ) 678 if ( bSound )
717 killTimer( stopTimer ); 679 killTimer( stopTimer );
718 } 680 }
719 } 681 }
720 } else if ( msg == "nextView()" ) { 682 } else if ( msg == "nextView()" ) {
721 if ( !qApp-> activeWindow ( )) { 683 if ( !qApp-> activeWindow ( )) {
722 needShow = TRUE; 684 needShow = TRUE;
723 } 685 } else {
724 else { 686 QWidget* cur = views->visibleWidget();
725 QWidget* cur = views->visibleWidget(); 687 if ( cur ) {
726 if ( cur ) { 688 if ( cur == dayView )
727 if ( cur == dayView ) 689 viewWeek();
728 viewWeek(); 690 else if ( cur == weekView )
729 else if ( cur == weekView ) 691 viewWeekLst();
730 viewWeekLst(); 692 else if ( cur == weekLstView )
731 else if ( cur == weekLstView ) 693 viewMonth();
732 viewMonth(); 694 else if ( cur == monthView )
733 else if ( cur == monthView ) 695 viewDay();
734 viewDay(); 696 needShow = TRUE;
735 needShow = TRUE; 697 }
736 } 698 }
737 }
738 } 699 }
@@ -740,10 +701,10 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
740#if defined(Q_WS_QWS) || defined(_WS_QWS_) 701#if defined(Q_WS_QWS) || defined(_WS_QWS_)
741 showMaximized(); 702 showMaximized();
742#else 703#else
743 show(); 704 show();
744#endif 705#endif
745 raise(); 706 raise();
746 QPEApplication::setKeepRunning(); 707 QPEApplication::setKeepRunning();
747 setActiveWindow(); 708 setActiveWindow();
748 } 709 }
749} 710}
@@ -752,10 +713,7 @@ void DateBook::reload()
752{ 713{
753 db->reload(); 714 db->reload();
754 if ( dayAction->isOn() ) 715 if ( dayAction->isOn() ) viewDay();
755 viewDay(); 716 else if ( weekAction->isOn() ) viewWeek();
756 else if ( weekAction->isOn() ) 717 else if ( monthAction->isOn() ) viewMonth();
757 viewWeek(); 718 syncing = FALSE;
758 else if ( monthAction->isOn() )
759 viewMonth();
760 syncing = FALSE;
761} 719}
@@ -764,4 +722,4 @@ void DateBook::flush()
764{ 722{
765 syncing = TRUE; 723 syncing = TRUE;
766 db->save(); 724 db->save();
767} 725}
@@ -770,8 +728,8 @@ void DateBook::timerEvent( QTimerEvent *e )
770{ 728{
771 if ( alarmCounter < 10 ) { 729 if ( alarmCounter < 10 ) {
772 alarmCounter++; 730 alarmCounter++;
773 Sound::soundAlarm(); 731 Sound::soundAlarm();
774 } 732 } else {
775 else 733 killTimer( e->timerId() );
776 killTimer( e->timerId() ); 734 }
777} 735}
@@ -780,7 +738,7 @@ void DateBook::changeClock( bool newClock )
780{ 738{
781 ampm = newClock; 739 ampm = newClock;
782 // repaint the affected objects... 740 // repaint the affected objects...
783 if (dayView) dayView->redraw(); 741 if (dayView) dayView->redraw();
784 if (weekView) weekView->redraw(); 742 if (weekView) weekView->redraw();
785 if (weekLstView) weekLstView->redraw(); 743 if (weekLstView) weekLstView->redraw();
786} 744}
@@ -789,5 +747,5 @@ void DateBook::changeWeek( bool m )
789{ 747{
790 /* no need to redraw, each widget catches. Do need to 748 /* no need to redraw, each widget catches. Do need to
791 store though for widgets we haven't made yet */ 749 store though for widgets we haven't made yet */
792 onMonday = m; 750 onMonday = m;
793} 751}
@@ -796,4 +754,4 @@ void DateBook::slotToday()
796{ 754{
797 // we need to view today using default view 755 // we need to view today using default view
798 viewDefault(QDate::currentDate()); 756 view(defaultView,QDate::currentDate());
799} 757}
@@ -802,25 +760,25 @@ void DateBook::closeEvent( QCloseEvent *e )
802{ 760{
803 if(syncing) { 761 if(syncing) {
804 /* no need to save, did that at flush */ 762 /* no need to save, did that at flush */
805 e->accept(); 763 e->accept();
806 return; 764 return;
807 } 765 }
808 766
809 // save settings will generate it's own error messages, no 767 // save settings will generate it's own error messages, no
810 // need to do checking ourselves. 768 // need to do checking ourselves.
811 saveSettings(); 769 saveSettings();
812 if ( db->save() ) 770 if ( db->save() ) {
813 e->accept(); 771 e->accept();
814 else { 772 } else {
815 if ( QMessageBox::critical( this, tr( "Out of space" ), 773 if ( QMessageBox::critical( this, tr( "Out of space" ),
816 tr("Calendar was unable to save\n" 774 tr("Calendar was unable to save\n"
817 "your changes.\n" 775 "your changes.\n"
818 "Free up some space and try again.\n" 776 "Free up some space and try again.\n"
819 "\nQuit anyway?"), 777 "\nQuit anyway?"),
820 QMessageBox::Yes|QMessageBox::Escape, 778 QMessageBox::Yes|QMessageBox::Escape,
821 QMessageBox::No|QMessageBox::Default ) 779 QMessageBox::No|QMessageBox::Default )
822 != QMessageBox::No ) 780 != QMessageBox::No )
823 e->accept(); 781 e->accept();
824 else 782 else
825 e->ignore(); 783 e->ignore();
826 } 784 }