summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebook.cpp14
-rw-r--r--core/pim/datebook/datebook.h2
2 files changed, 9 insertions, 7 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp
index 8614b3f..2c2965e 100644
--- a/core/pim/datebook/datebook.cpp
+++ b/core/pim/datebook/datebook.cpp
@@ -52,65 +52,66 @@
52#include <qfile.h> 52#include <qfile.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qlayout.h> 54#include <qlayout.h>
55#include <qmessagebox.h> 55#include <qmessagebox.h>
56#include <qpopupmenu.h> 56#include <qpopupmenu.h>
57#include <qpushbutton.h> 57#include <qpushbutton.h>
58#include <qregexp.h> 58#include <qregexp.h>
59#include <qtextcodec.h> 59#include <qtextcodec.h>
60#include <qtextstream.h> 60#include <qtextstream.h>
61#include <qtl.h> 61#include <qtl.h>
62#include <qwidgetstack.h> 62#include <qwidgetstack.h>
63#include <qwindowsystem_qws.h> 63#include <qwindowsystem_qws.h>
64 64
65#include <sys/stat.h> 65#include <sys/stat.h>
66#include <sys/types.h> 66#include <sys/types.h>
67#include <fcntl.h> 67#include <fcntl.h>
68#include <unistd.h> 68#include <unistd.h>
69 69
70#include <stdlib.h> 70#include <stdlib.h>
71 71
72#define DAY 1 72#define DAY 1
73#define WEEK 2 73#define WEEK 2
74#define WEEKLST 4 74#define WEEKLST 4
75#define MONTH 3 75#define MONTH 3
76 76
77 77
78DateBook::DateBook( QWidget *parent, const char *, WFlags f ) 78DateBook::DateBook( QWidget *parent, const char *, WFlags f )
79 : QMainWindow( parent, "datebook", f ), 79 : QMainWindow( parent, "datebook", f ),
80 aPreset( FALSE ), 80 aPreset( FALSE ),
81 presetTime( -1 ), 81 presetTime( -1 ),
82 startTime( 8 ), // an acceptable default 82 startTime( 8 ), // an acceptable default
83 syncing(FALSE), 83 syncing(FALSE),
84 inSearch(FALSE) 84 inSearch(FALSE),
85 alarmCounter(0)
85{ 86{
86 QTime t; 87 QTime t;
87 t.start(); 88 t.start();
88 db = new DateBookDBHack; 89 db = new DateBookDBHack;
89 qDebug("loading db t=%d", t.elapsed() ); 90 qDebug("loading db t=%d", t.elapsed() );
90 loadSettings(); 91 loadSettings();
91 setCaption( tr("Calendar") ); 92 setCaption( tr("Calendar") );
92 setIcon( Resource::loadPixmap( "datebook_icon" ) ); 93 setIcon( Resource::loadPixmap( "datebook_icon" ) );
93 94
94 setToolBarsMovable( FALSE ); 95 setToolBarsMovable( FALSE );
95 96
96 views = new QWidgetStack( this ); 97 views = new QWidgetStack( this );
97 setCentralWidget( views ); 98 setCentralWidget( views );
98 99
99 dayView = 0; 100 dayView = 0;
100 weekView = 0; 101 weekView = 0;
101 weekLstView = 0; 102 weekLstView = 0;
102 monthView = 0; 103 monthView = 0;
103 104
104 QPEToolBar *bar = new QPEToolBar( this ); 105 QPEToolBar *bar = new QPEToolBar( this );
105 bar->setHorizontalStretchable( TRUE ); 106 bar->setHorizontalStretchable( TRUE );
106 107
107 QPEMenuBar *mb = new QPEMenuBar( bar ); 108 QPEMenuBar *mb = new QPEMenuBar( bar );
108 mb->setMargin( 0 ); 109 mb->setMargin( 0 );
109 110
110 QPEToolBar *sub_bar = new QPEToolBar(this); 111 QPEToolBar *sub_bar = new QPEToolBar(this);
111 112
112 QPopupMenu *view = new QPopupMenu( this ); 113 QPopupMenu *view = new QPopupMenu( this );
113 QPopupMenu *settings = new QPopupMenu( this ); 114 QPopupMenu *settings = new QPopupMenu( this );
114 115
115 mb->insertItem( tr( "View" ), view ); 116 mb->insertItem( tr( "View" ), view );
116 mb->insertItem( tr( "Settings" ), settings ); 117 mb->insertItem( tr( "Settings" ), settings );
@@ -585,64 +586,65 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
585 QDateTime current = QDateTime::currentDateTime(); 586 QDateTime current = QDateTime::currentDateTime();
586 if ( current.time().hour() != when.time().hour() 587 if ( current.time().hour() != when.time().hour()
587 && current.time().minute() != when.time().minute() ) 588 && current.time().minute() != when.time().minute() )
588 return; 589 return;
589 590
590 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); 591 QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60));
591 if ( list.count() > 0 ) { 592 if ( list.count() > 0 ) {
592 QString msg; 593 QString msg;
593 bool bSound = FALSE; 594 bool bSound = FALSE;
594 int stopTimer = 0; 595 int stopTimer = 0;
595 bool found = FALSE; 596 bool found = FALSE;
596 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); 597 for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin();
597 it!=list.end(); ++it ) { 598 it!=list.end(); ++it ) {
598 if ( (*it).event().hasAlarm() ) { 599 if ( (*it).event().hasAlarm() ) {
599 found = TRUE; 600 found = TRUE;
600 msg += "<CENTER><B>" + (*it).description() + "</B>" 601 msg += "<CENTER><B>" + (*it).description() + "</B>"
601 + "<BR>" + (*it).location() + "<BR>" 602 + "<BR>" + (*it).location() + "<BR>"
602 + TimeString::dateString((*it).event().start(),ampm) 603 + TimeString::dateString((*it).event().start(),ampm)
603 + (warn 604 + (warn
604 ? tr(" (in " + QString::number(warn) 605 ? tr(" (in " + QString::number(warn)
605 + tr(" minutes)")) 606 + tr(" minutes)"))
606 : QString("")) 607 : QString(""))
607 + "<BR>" 608 + "<BR>"
608 + (*it).notes() + "</CENTER>"; 609 + (*it).notes() + "</CENTER>";
609 if ( (*it).event().alarmSound() != Event::Silent ) { 610 if ( (*it).event().alarmSound() != Event::Silent ) {
610 bSound = TRUE; 611 bSound = TRUE;
611 } 612 }
612 } 613 }
613 } 614 }
614 if ( found ) { 615 if ( found ) {
615 if ( bSound ) { 616 if ( bSound ) {
616 Sound::soundAlarm(); 617 Sound::soundAlarm();
618 alarmCounter = 0;
617 stopTimer = startTimer( 5000 ); 619 stopTimer = startTimer( 5000 );
618 } 620 }
619 621
620 QDialog dlg( this, 0, TRUE ); 622 QDialog dlg( this, 0, TRUE );
621 QVBoxLayout *vb = new QVBoxLayout( &dlg ); 623 QVBoxLayout *vb = new QVBoxLayout( &dlg );
622 QScrollView *view = new QScrollView( &dlg, "scrollView"); 624 QScrollView *view = new QScrollView( &dlg, "scrollView");
623 view->setResizePolicy( QScrollView::AutoOneFit ); 625 view->setResizePolicy( QScrollView::AutoOneFit );
624 vb->addWidget( view ); 626 vb->addWidget( view );
625 QLabel *lblMsg = new QLabel( msg, &dlg ); 627 QLabel *lblMsg = new QLabel( msg, &dlg );
626 view->addChild( lblMsg ); 628 view->addChild( lblMsg );
627 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg ); 629 QPushButton *cmdOk = new QPushButton( tr("OK"), &dlg );
628 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) ); 630 connect( cmdOk, SIGNAL(clicked()), &dlg, SLOT(accept()) );
629 vb->addWidget( cmdOk ); 631 vb->addWidget( cmdOk );
630 632
631#if defined(Q_WS_QWS) || defined(_WS_QWS_) 633#if defined(Q_WS_QWS) || defined(_WS_QWS_)
632 dlg.showMaximized(); 634 dlg.showMaximized();
633#endif 635#endif
634 needShow = dlg.exec(); 636 needShow = dlg.exec();
635 637
636 if ( bSound ) 638 if ( bSound )
637 killTimer( stopTimer ); 639 killTimer( stopTimer );
638 } 640 }
639 } 641 }
640 } else if ( msg == "nextView()" ) { 642 } else if ( msg == "nextView()" ) {
641 QWidget* cur = views->visibleWidget(); 643 QWidget* cur = views->visibleWidget();
642 if ( cur ) { 644 if ( cur ) {
643 if ( cur == dayView ) 645 if ( cur == dayView )
644 viewWeek(); 646 viewWeek();
645 else if ( cur == weekView ) 647 else if ( cur == weekView )
646 viewWeekLst(); 648 viewWeekLst();
647 else if ( cur == weekLstView ) 649 else if ( cur == weekLstView )
648 viewMonth(); 650 viewMonth();
@@ -654,72 +656,70 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data)
654 if ( needShow ) { 656 if ( needShow ) {
655#if defined(Q_WS_QWS) || defined(_WS_QWS_) 657#if defined(Q_WS_QWS) || defined(_WS_QWS_)
656 showMaximized(); 658 showMaximized();
657#else 659#else
658 show(); 660 show();
659#endif 661#endif
660 raise(); 662 raise();
661 QPEApplication::setKeepRunning(); 663 QPEApplication::setKeepRunning();
662 setActiveWindow(); 664 setActiveWindow();
663 } 665 }
664} 666}
665 667
666void DateBook::reload() 668void DateBook::reload()
667{ 669{
668 db->reload(); 670 db->reload();
669 if ( dayAction->isOn() ) 671 if ( dayAction->isOn() )
670 viewDay(); 672 viewDay();
671 else if ( weekAction->isOn() ) 673 else if ( weekAction->isOn() )
672 viewWeek(); 674 viewWeek();
673 else if ( monthAction->isOn() ) 675 else if ( monthAction->isOn() )
674 viewMonth(); 676 viewMonth();
675 syncing = FALSE; 677 syncing = FALSE;
676} 678}
677 679
678void DateBook::flush() 680void DateBook::flush()
679{ 681{
680 syncing = TRUE; 682 syncing = TRUE;
681 db->save(); 683 db->save();
682} 684}
683 685
684void DateBook::timerEvent( QTimerEvent *e ) 686void DateBook::timerEvent( QTimerEvent *e )
685{ 687{
686 static int stop = 0; 688 if ( alarmCounter < 10 ) {
687 if ( stop < 10 ) { 689 alarmCounter++;
688 Sound::soundAlarm(); 690 Sound::soundAlarm();
689 stop++; 691 }
690 } else { 692 else
691 stop = 0;
692 killTimer( e->timerId() ); 693 killTimer( e->timerId() );
693 }
694} 694}
695 695
696void DateBook::changeClock( bool newClock ) 696void DateBook::changeClock( bool newClock )
697{ 697{
698 ampm = newClock; 698 ampm = newClock;
699 // repaint the affected objects... 699 // repaint the affected objects...
700 if (dayView) dayView->redraw(); 700 if (dayView) dayView->redraw();
701 if (weekView) weekView->redraw(); 701 if (weekView) weekView->redraw();
702 if (weekLstView) weekLstView->redraw(); 702 if (weekLstView) weekLstView->redraw();
703} 703}
704 704
705void DateBook::changeWeek( bool m ) 705void DateBook::changeWeek( bool m )
706{ 706{
707 /* no need to redraw, each widget catches. Do need to 707 /* no need to redraw, each widget catches. Do need to
708 store though for widgets we haven't made yet */ 708 store though for widgets we haven't made yet */
709 onMonday = m; 709 onMonday = m;
710} 710}
711 711
712void DateBook::slotToday() 712void DateBook::slotToday()
713{ 713{
714 // we need to view today using default view 714 // we need to view today using default view
715 viewDefault(QDate::currentDate()); 715 viewDefault(QDate::currentDate());
716} 716}
717 717
718void DateBook::closeEvent( QCloseEvent *e ) 718void DateBook::closeEvent( QCloseEvent *e )
719{ 719{
720 if(syncing) { 720 if(syncing) {
721 /* no need to save, did that at flush */ 721 /* no need to save, did that at flush */
722 e->accept(); 722 e->accept();
723 return; 723 return;
724 } 724 }
725 725
diff --git a/core/pim/datebook/datebook.h b/core/pim/datebook/datebook.h
index d1fe90d..e7be0dd 100644
--- a/core/pim/datebook/datebook.h
+++ b/core/pim/datebook/datebook.h
@@ -91,36 +91,38 @@ private slots:
91 91
92 void receive( const QCString &msg, const QByteArray &data ); 92 void receive( const QCString &msg, const QByteArray &data );
93 void setDocument( const QString & ); 93 void setDocument( const QString & );
94 void beamEvent( const Event &e ); 94 void beamEvent( const Event &e );
95 void beamDone( Ir *ir ); 95 void beamDone( Ir *ir );
96 96
97private: 97private:
98 void addEvent( const Event &e ); 98 void addEvent( const Event &e );
99 void initDay(); 99 void initDay();
100 void initWeek(); 100 void initWeek();
101 void initWeekLst(); 101 void initWeekLst();
102 void initMonth(); 102 void initMonth();
103 void loadSettings(); 103 void loadSettings();
104 void saveSettings(); 104 void saveSettings();
105 105
106private: 106private:
107 DateBookDBHack *db; 107 DateBookDBHack *db;
108 QWidgetStack *views; 108 QWidgetStack *views;
109 DateBookDay *dayView; 109 DateBookDay *dayView;
110 DateBookWeek *weekView; 110 DateBookWeek *weekView;
111 DateBookMonth *monthView; 111 DateBookMonth *monthView;
112 DateBookWeekLst *weekLstView; 112 DateBookWeekLst *weekLstView;
113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction; 113 QAction *dayAction, *weekAction, *weekLstAction, *monthAction;
114 bool aPreset; // have everything set to alarm? 114 bool aPreset; // have everything set to alarm?
115 int presetTime; // the standard time for the alarm 115 int presetTime; // the standard time for the alarm
116 int startTime; 116 int startTime;
117 bool ampm; 117 bool ampm;
118 bool onMonday; 118 bool onMonday;
119 119
120 bool syncing; 120 bool syncing;
121 bool inSearch; 121 bool inSearch;
122 122
123 int alarmCounter;
124
123 QString checkEvent(const Event &); 125 QString checkEvent(const Event &);
124}; 126};
125 127
126#endif 128#endif