Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 120 |
1 files changed, 39 insertions, 81 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 | |||
@@ -70,12 +70,6 @@ | |||
70 | 70 | ||
71 | #include <stdlib.h> | 71 | #include <stdlib.h> |
72 | 72 | ||
73 | #define DAY 1 | ||
74 | #define WEEK 2 | ||
75 | #define WEEKLST 4 | ||
76 | #define MONTH 3 | ||
77 | |||
78 | |||
79 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | 73 | DateBook::DateBook( QWidget *parent, const char *, WFlags f ) |
80 | : QMainWindow( parent, "datebook", f ), | 74 | : QMainWindow( parent, "datebook", f ), |
81 | aPreset( FALSE ), | 75 | aPreset( FALSE ), |
@@ -166,56 +160,29 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
166 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); | 160 | connect( a, SIGNAL(activated()), this, SLOT(slotFind()) ); |
167 | a->addTo( sub_bar ); | 161 | a->addTo( sub_bar ); |
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() ) ); |
171 | a->addTo( settings ); | 165 | a->addTo( settings ); |
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(); |
170 | if(defaultView==MONTH) viewMonth(); | ||
176 | 171 | ||
177 | Config config("DateBook"); | 172 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); |
178 | config.setGroup("Main"); | 173 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(changeWeek(bool)) ); |
179 | int current=config.readNumEntry("defaultview", DAY); | ||
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 |
209 | 178 | ||
210 | // listen on QPE/System | 179 | // listen on QPE/System |
211 | #if defined(Q_WS_QWS) | 180 | #if defined(Q_WS_QWS) |
212 | #if !defined(QT_NO_COP) | 181 | #if !defined(QT_NO_COP) |
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"); |
220 | #endif | 187 | #endif |
221 | #endif | 188 | #endif |
@@ -272,6 +239,9 @@ void DateBook::slotSettings() | |||
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_) |
276 | frmSettings.showMaximized(); | 246 | frmSettings.showMaximized(); |
277 | #endif | 247 | #endif |
@@ -283,6 +253,8 @@ void DateBook::slotSettings() | |||
283 | startTime = frmSettings.startTime(); | 253 | startTime = frmSettings.startTime(); |
284 | bJumpToCurTime = frmSettings.jumpToCurTime(); | 254 | bJumpToCurTime = frmSettings.jumpToCurTime(); |
285 | rowStyle = frmSettings.rowStyle(); | 255 | rowStyle = frmSettings.rowStyle(); |
256 | defaultView=frmSettings.comboDefaultView->currentItem()+1; | ||
257 | weeklistviewconfig=frmSettings.comboWeekListView->currentItem(); | ||
286 | 258 | ||
287 | if ( dayView ) { | 259 | if ( dayView ) { |
288 | dayView->setStartViewTime( startTime ); | 260 | dayView->setStartViewTime( startTime ); |
@@ -300,6 +272,8 @@ void DateBook::slotSettings() | |||
300 | dayView->redraw(); | 272 | dayView->redraw(); |
301 | else if ( views->visibleWidget() == weekView ) | 273 | else if ( views->visibleWidget() == weekView ) |
302 | weekView->redraw(); | 274 | weekView->redraw(); |
275 | else if ( views->visibleWidget() == weekLstView ) | ||
276 | weekLstView->redraw(); | ||
303 | } | 277 | } |
304 | } | 278 | } |
305 | } | 279 | } |
@@ -383,11 +357,14 @@ void DateBook::view(int v, const QDate &d) { | |||
383 | } | 357 | } |
384 | 358 | ||
385 | void DateBook::viewDefault(const QDate &d) { | 359 | void DateBook::viewDefault(const QDate &d) { |
360 | /* | ||
386 | Config config("DateBook"); | 361 | Config config("DateBook"); |
387 | config.setGroup("Main"); | 362 | config.setGroup("Main"); |
388 | int current=config.readNumEntry("defaultview", DAY); | 363 | int current=config.readNumEntry("defaultview", DAY); |
389 | 364 | ||
390 | view(current,d); | 365 | view(current,d); |
366 | */ | ||
367 | view(defaultView,d); | ||
391 | } | 368 | } |
392 | 369 | ||
393 | void DateBook::viewDay() { | 370 | void DateBook::viewDay() { |
@@ -608,14 +585,11 @@ void DateBook::initMonth() | |||
608 | 585 | ||
609 | void DateBook::loadSettings() | 586 | 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"); |
620 | config.setGroup("Main"); | 594 | config.setGroup("Main"); |
621 | startTime = config.readNumEntry("startviewtime", 8); | 595 | startTime = config.readNumEntry("startviewtime", 8); |
@@ -623,7 +597,8 @@ void DateBook::loadSettings() | |||
623 | presetTime = config.readNumEntry("presettime"); | 597 | presetTime = config.readNumEntry("presettime"); |
624 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); | 598 | bJumpToCurTime = config.readBoolEntry("jumptocurtime"); |
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 | } |
628 | 603 | ||
629 | void DateBook::saveSettings() | 604 | void DateBook::saveSettings() |
@@ -636,18 +611,8 @@ void DateBook::saveSettings() | |||
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); | |
641 | void 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 | } |
652 | 617 | ||
653 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 618 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
@@ -662,8 +627,7 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
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() ) | ||
667 | return; | 631 | return; |
668 | 632 | ||
669 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); | 633 | QValueList<EffectiveEvent> list = db->getEffectiveEvents(when.addSecs(warn*60)); |
@@ -672,8 +636,7 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
672 | bool bSound = FALSE; | 636 | bool bSound = FALSE; |
673 | int stopTimer = 0; | 637 | int stopTimer = 0; |
674 | bool found = FALSE; | 638 | bool found = FALSE; |
675 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); | 639 | for ( QValueList<EffectiveEvent>::ConstIterator it=list.begin(); it!=list.end(); ++it ) { |
676 | it!=list.end(); ++it ) { | ||
677 | if ( (*it).event().hasAlarm() ) { | 640 | if ( (*it).event().hasAlarm() ) { |
678 | found = TRUE; | 641 | found = TRUE; |
679 | msg += "<CENTER><B>" + (*it).description() + "</B>" | 642 | msg += "<CENTER><B>" + (*it).description() + "</B>" |
@@ -696,7 +659,6 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
696 | alarmCounter = 0; | 659 | alarmCounter = 0; |
697 | stopTimer = startTimer( 5000 ); | 660 | stopTimer = startTimer( 5000 ); |
698 | } | 661 | } |
699 | |||
700 | QDialog dlg( this, 0, TRUE ); | 662 | QDialog dlg( this, 0, TRUE ); |
701 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); | 663 | QVBoxLayout *vb = new QVBoxLayout( &dlg ); |
702 | QScrollView *view = new QScrollView( &dlg, "scrollView"); | 664 | QScrollView *view = new QScrollView( &dlg, "scrollView"); |
@@ -720,8 +682,7 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
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 { | ||
725 | QWidget* cur = views->visibleWidget(); | 686 | QWidget* cur = views->visibleWidget(); |
726 | if ( cur ) { | 687 | if ( cur ) { |
727 | if ( cur == dayView ) | 688 | if ( cur == dayView ) |
@@ -751,12 +712,9 @@ void DateBook::appMessage(const QCString& msg, const QByteArray& data) | |||
751 | void DateBook::reload() | 712 | 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(); | ||
758 | else if ( monthAction->isOn() ) | ||
759 | viewMonth(); | ||
760 | syncing = FALSE; | 718 | syncing = FALSE; |
761 | } | 719 | } |
762 | 720 | ||
@@ -771,10 +729,10 @@ void DateBook::timerEvent( QTimerEvent *e ) | |||
771 | if ( alarmCounter < 10 ) { | 729 | if ( alarmCounter < 10 ) { |
772 | alarmCounter++; | 730 | alarmCounter++; |
773 | Sound::soundAlarm(); | 731 | Sound::soundAlarm(); |
774 | } | 732 | } else { |
775 | else | ||
776 | killTimer( e->timerId() ); | 733 | killTimer( e->timerId() ); |
777 | } | 734 | } |
735 | } | ||
778 | 736 | ||
779 | void DateBook::changeClock( bool newClock ) | 737 | void DateBook::changeClock( bool newClock ) |
780 | { | 738 | { |
@@ -795,7 +753,7 @@ void DateBook::changeWeek( bool m ) | |||
795 | void DateBook::slotToday() | 753 | 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 | } |
800 | 758 | ||
801 | void DateBook::closeEvent( QCloseEvent *e ) | 759 | void DateBook::closeEvent( QCloseEvent *e ) |
@@ -809,9 +767,9 @@ void DateBook::closeEvent( QCloseEvent *e ) | |||
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" |