Diffstat (limited to 'core/pim/datebook/datebook.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/pim/datebook/datebook.cpp | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/core/pim/datebook/datebook.cpp b/core/pim/datebook/datebook.cpp index 2c2965e..c0d45c9 100644 --- a/core/pim/datebook/datebook.cpp +++ b/core/pim/datebook/datebook.cpp | |||
@@ -125,13 +125,13 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
125 | a->addTo( sub_bar ); | 125 | a->addTo( sub_bar ); |
126 | 126 | ||
127 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); | 127 | a = new QAction( tr( "Today" ), Resource::loadPixmap( "to_day" ), QString::null, 0, g, 0 ); |
128 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); | 128 | connect( a, SIGNAL( activated() ), this, SLOT( slotToday() ) ); |
129 | a->addTo( sub_bar ); | 129 | a->addTo( sub_bar ); |
130 | a->addTo( view ); | 130 | a->addTo( view ); |
131 | 131 | ||
132 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); | 132 | a = new QAction( tr( "Day" ), Resource::loadPixmap( "day" ), QString::null, 0, g, 0 ); |
133 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); | 133 | connect( a, SIGNAL( activated() ), this, SLOT( viewDay() ) ); |
134 | a->addTo( sub_bar ); | 134 | a->addTo( sub_bar ); |
135 | a->addTo( view ); | 135 | a->addTo( view ); |
136 | a->setToggleAction( TRUE ); | 136 | a->setToggleAction( TRUE ); |
137 | a->setOn( TRUE ); | 137 | a->setOn( TRUE ); |
@@ -170,13 +170,13 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
170 | settings->insertItem( tr( "Default View" ),default_view ); | 170 | settings->insertItem( tr( "Default View" ),default_view ); |
171 | default_view->setCheckable(TRUE); | 171 | default_view->setCheckable(TRUE); |
172 | 172 | ||
173 | Config config("DateBook"); | 173 | Config config("DateBook"); |
174 | config.setGroup("Main"); | 174 | config.setGroup("Main"); |
175 | int current=config.readNumEntry("defaultview", DAY); | 175 | int current=config.readNumEntry("defaultview", DAY); |
176 | 176 | ||
177 | QActionGroup *ag = new QActionGroup(this); | 177 | QActionGroup *ag = new QActionGroup(this); |
178 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); | 178 | a = new QAction( tr( "Day" ), QString::null, 0, 0, 0, true ); |
179 | if (current==DAY) a->setOn(true), viewDay(); | 179 | if (current==DAY) a->setOn(true), viewDay(); |
180 | ag->insert(a); | 180 | ag->insert(a); |
181 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); | 181 | a = new QAction( tr( "Week" ), QString::null, 0, 0, 0, true ); |
182 | if (current==WEEK) a->setOn(true), viewWeek(); | 182 | if (current==WEEK) a->setOn(true), viewWeek(); |
@@ -184,41 +184,41 @@ DateBook::DateBook( QWidget *parent, const char *, WFlags f ) | |||
184 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); | 184 | a = new QAction( tr( "WeekLst" ), QString::null, 0, 0, 0, true ); |
185 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); | 185 | if (current==WEEKLST) a->setOn(true), viewWeekLst(); |
186 | ag->insert(a); | 186 | ag->insert(a); |
187 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); | 187 | a = new QAction( tr( "Month" ), QString::null, 0, 0, 0, true ); |
188 | if (current==MONTH) a->setOn(true), viewMonth(); | 188 | if (current==MONTH) a->setOn(true), viewMonth(); |
189 | ag->insert(a); | 189 | ag->insert(a); |
190 | 190 | ||
191 | ag->addTo(default_view); | 191 | ag->addTo(default_view); |
192 | connect(ag, SIGNAL( selected ( QAction * ) ), | 192 | connect(ag, SIGNAL( selected ( QAction * ) ), |
193 | this, SLOT( newDefaultView(QAction *) ) | 193 | this, SLOT( newDefaultView(QAction *) ) |
194 | ); | 194 | ); |
195 | 195 | ||
196 | connect( qApp, SIGNAL(clockChanged(bool)), | 196 | connect( qApp, SIGNAL(clockChanged(bool)), |
197 | this, SLOT(changeClock(bool)) ); | 197 | this, SLOT(changeClock(bool)) ); |
198 | connect( qApp, SIGNAL(weekChanged(bool)), | 198 | connect( qApp, SIGNAL(weekChanged(bool)), |
199 | this, SLOT(changeWeek(bool)) ); | 199 | this, SLOT(changeWeek(bool)) ); |
200 | 200 | ||
201 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 201 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
202 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), | 202 | connect( qApp, SIGNAL(appMessage(const QCString&, const QByteArray&)), |
203 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); | 203 | this, SLOT(appMessage(const QCString&, const QByteArray&)) ); |
204 | #endif | 204 | #endif |
205 | 205 | ||
206 | // listen on QPE/System | 206 | // listen on QPE/System |
207 | #if defined(Q_WS_QWS) | 207 | #if defined(Q_WS_QWS) |
208 | #if !defined(QT_NO_COP) | 208 | #if !defined(QT_NO_COP) |
209 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); | 209 | QCopChannel *channel = new QCopChannel( "QPE/System", this ); |
210 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 210 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
211 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 211 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
212 | channel = new QCopChannel( "QPE/Datebook", this ); | 212 | channel = new QCopChannel( "QPE/Datebook", this ); |
213 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 213 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
214 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 214 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
215 | qDebug("olle\n"); | 215 | qDebug("olle\n"); |
216 | #endif | 216 | #endif |
217 | #endif | 217 | #endif |
218 | 218 | ||
219 | qDebug("done t=%d", t.elapsed() ); | 219 | qDebug("done t=%d", t.elapsed() ); |
220 | 220 | ||
221 | } | 221 | } |
222 | 222 | ||
223 | void DateBook::receive( const QCString &msg, const QByteArray &data ) | 223 | void DateBook::receive( const QCString &msg, const QByteArray &data ) |
224 | { | 224 | { |
@@ -306,13 +306,13 @@ QString DateBook::checkEvent(const Event &e) | |||
306 | return QString::null; | 306 | return QString::null; |
307 | } | 307 | } |
308 | 308 | ||
309 | QDate DateBook::currentDate() | 309 | QDate DateBook::currentDate() |
310 | { | 310 | { |
311 | QDate d = QDate::currentDate(); | 311 | QDate d = QDate::currentDate(); |
312 | 312 | ||
313 | if ( dayView && views->visibleWidget() == dayView ) { | 313 | if ( dayView && views->visibleWidget() == dayView ) { |
314 | d = dayView->date(); | 314 | d = dayView->date(); |
315 | } else if ( weekView && views->visibleWidget() == weekView ) { | 315 | } else if ( weekView && views->visibleWidget() == weekView ) { |
316 | d = weekView->date(); | 316 | d = weekView->date(); |
317 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { | 317 | } else if ( weekLstView && views->visibleWidget() == weekLstView ) { |
318 | d = weekLstView->date(); | 318 | d = weekLstView->date(); |
@@ -403,13 +403,13 @@ void DateBook::editEvent( const Event &e ) | |||
403 | while (editDlg.exec() ) { | 403 | while (editDlg.exec() ) { |
404 | Event newEv = entry->event(); | 404 | Event newEv = entry->event(); |
405 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid | 405 | newEv.setUid(e.uid()); // FIXME: Hack not to clear uid |
406 | QString error = checkEvent(newEv); | 406 | QString error = checkEvent(newEv); |
407 | if (!error.isNull()) { | 407 | if (!error.isNull()) { |
408 | if (QMessageBox::warning(this, "error box", | 408 | if (QMessageBox::warning(this, "error box", |
409 | error, "Fix it", "Continue", | 409 | error, "Fix it", "Continue", |
410 | 0, 0, 1) == 0) | 410 | 0, 0, 1) == 0) |
411 | continue; | 411 | continue; |
412 | } | 412 | } |
413 | db->editEvent(e, newEv); | 413 | db->editEvent(e, newEv); |
414 | emit newEvent(); | 414 | emit newEvent(); |
415 | break; | 415 | break; |
@@ -485,34 +485,34 @@ void DateBook::initWeek() | |||
485 | 485 | ||
486 | int yearNumber, totWeeks; | 486 | int yearNumber, totWeeks; |
487 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); | 487 | calcWeek( currentDate(), totWeeks, yearNumber, onMonday ); |
488 | 488 | ||
489 | QDate d = QDate( yearNumber, 12, 31 ); | 489 | QDate d = QDate( yearNumber, 12, 31 ); |
490 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 490 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
491 | 491 | ||
492 | while ( totWeeks == 1 ) { | 492 | while ( totWeeks == 1 ) { |
493 | d = d.addDays( -1 ); | 493 | d = d.addDays( -1 ); |
494 | calcWeek( d, totWeeks, yearNumber, onMonday ); | 494 | calcWeek( d, totWeeks, yearNumber, onMonday ); |
495 | } | 495 | } |
496 | if ( totWeeks != weekView->totalWeeks() ) | 496 | if ( totWeeks != weekView->totalWeeks() ) |
497 | weekView->setTotalWeeks( totWeeks ); | 497 | weekView->setTotalWeeks( totWeeks ); |
498 | } | 498 | } |
499 | void DateBook::initWeekLst() { | 499 | void DateBook::initWeekLst() { |
500 | if ( !weekLstView ) { | 500 | if ( !weekLstView ) { |
501 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, | 501 | weekLstView = new DateBookWeekLst( ampm, onMonday, db, |
502 | views, "weeklst view" ); | 502 | views, "weeklst view" ); |
503 | views->addWidget( weekLstView, WEEKLST ); | 503 | views->addWidget( weekLstView, WEEKLST ); |
504 | 504 | ||
505 | //weekLstView->setStartViewTime( startTime ); | 505 | //weekLstView->setStartViewTime( startTime ); |
506 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), | 506 | connect( weekLstView, SIGNAL( showDate( int, int, int ) ), |
507 | this, SLOT( showDay( int, int, int ) ) ); | 507 | this, SLOT( showDay( int, int, int ) ) ); |
508 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, | 508 | connect( weekLstView, SIGNAL( addEvent( const QDateTime &, |
509 | const QDateTime &, | 509 | const QDateTime &, |
510 | const QString & ) ), | 510 | const QString & ) ), |
511 | this, SLOT( slotNewEntry( const QDateTime &, | 511 | this, SLOT( slotNewEntry( const QDateTime &, |
512 | const QDateTime &, | 512 | const QDateTime &, |
513 | const QString & ) ) ); | 513 | const QString & ) ) ); |
514 | connect( this, SIGNAL( newEvent() ), | 514 | connect( this, SIGNAL( newEvent() ), |
515 | weekLstView, SLOT( redraw() ) ); | 515 | weekLstView, SLOT( redraw() ) ); |
516 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), | 516 | connect( weekLstView, SIGNAL( editEvent( const Event & ) ), |
517 | this, SLOT( editEvent( const Event & ) ) ); | 517 | this, SLOT( editEvent( const Event & ) ) ); |
518 | } | 518 | } |
@@ -537,13 +537,13 @@ void DateBook::loadSettings() | |||
537 | { | 537 | { |
538 | Config config( "qpe" ); | 538 | Config config( "qpe" ); |
539 | config.setGroup("Time"); | 539 | config.setGroup("Time"); |
540 | ampm = config.readBoolEntry( "AMPM", TRUE ); | 540 | ampm = config.readBoolEntry( "AMPM", TRUE ); |
541 | onMonday = config.readBoolEntry( "MONDAY" ); | 541 | onMonday = config.readBoolEntry( "MONDAY" ); |
542 | } | 542 | } |
543 | 543 | ||
544 | { | 544 | { |
545 | Config config("DateBook"); | 545 | Config config("DateBook"); |
546 | config.setGroup("Main"); | 546 | config.setGroup("Main"); |
547 | startTime = config.readNumEntry("startviewtime", 8); | 547 | startTime = config.readNumEntry("startviewtime", 8); |
548 | aPreset = config.readBoolEntry("alarmpreset"); | 548 | aPreset = config.readBoolEntry("alarmpreset"); |
549 | presetTime = config.readNumEntry("presettime"); | 549 | presetTime = config.readNumEntry("presettime"); |
@@ -563,13 +563,13 @@ void DateBook::saveSettings() | |||
563 | void DateBook::newDefaultView(QAction *a) { | 563 | void DateBook::newDefaultView(QAction *a) { |
564 | int val=DAY; | 564 | int val=DAY; |
565 | if (a->text() == "Day") val=DAY; | 565 | if (a->text() == "Day") val=DAY; |
566 | if (a->text() == "Week") val=WEEK; | 566 | if (a->text() == "Week") val=WEEK; |
567 | if (a->text() == "WeekLst") val=WEEKLST; | 567 | if (a->text() == "WeekLst") val=WEEKLST; |
568 | if (a->text() == "Month") val=MONTH; | 568 | if (a->text() == "Month") val=MONTH; |
569 | 569 | ||
570 | Config configDB( "DateBook" ); | 570 | Config configDB( "DateBook" ); |
571 | configDB.setGroup( "Main" ); | 571 | configDB.setGroup( "Main" ); |
572 | configDB.writeEntry("defaultview",val); | 572 | configDB.writeEntry("defaultview",val); |
573 | } | 573 | } |
574 | 574 | ||
575 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) | 575 | void DateBook::appMessage(const QCString& msg, const QByteArray& data) |
@@ -685,13 +685,13 @@ void DateBook::flush() | |||
685 | 685 | ||
686 | void DateBook::timerEvent( QTimerEvent *e ) | 686 | void DateBook::timerEvent( QTimerEvent *e ) |
687 | { | 687 | { |
688 | if ( alarmCounter < 10 ) { | 688 | if ( alarmCounter < 10 ) { |
689 | alarmCounter++; | 689 | alarmCounter++; |
690 | Sound::soundAlarm(); | 690 | Sound::soundAlarm(); |
691 | } | 691 | } |
692 | else | 692 | else |
693 | killTimer( e->timerId() ); | 693 | killTimer( e->timerId() ); |
694 | } | 694 | } |
695 | 695 | ||
696 | void DateBook::changeClock( bool newClock ) | 696 | void DateBook::changeClock( bool newClock ) |
697 | { | 697 | { |
@@ -973,17 +973,19 @@ Event DateBookDBHack::eventByUID(int uid) { | |||
973 | QDate start; | 973 | QDate start; |
974 | QDate end=start.addDays(-1); | 974 | QDate end=start.addDays(-1); |
975 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); | 975 | QValueList<Event> myEventList=getNonRepeatingEvents(start,end); |
976 | QValueList<Event> myRepeatEvents=getRawRepeats(); | 976 | QValueList<Event> myRepeatEvents=getRawRepeats(); |
977 | 977 | ||
978 | QValueList<Event>::ConstIterator it; | 978 | QValueList<Event>::ConstIterator it; |
979 | 979 | ||
980 | for (it = myEventList.begin(); it != myEventList.end(); it++) { | 980 | for (it = myEventList.begin(); it != myEventList.end(); it++) { |
981 | if ((*it).uid() == uid) return *it; | 981 | if ((*it).uid() == uid) return *it; |
982 | } | 982 | } |
983 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { | 983 | for (it = myRepeatEvents.begin(); it != myRepeatEvents.end(); it++) { |
984 | if ((*it).uid() == uid) return *it; | 984 | if ((*it).uid() == uid) return *it; |
985 | } | 985 | } |
986 | 986 | ||
987 | qDebug("Event not found: uid=%d\n", uid); | 987 | qDebug("Event not found: uid=%d\n", uid); |
988 | Event ev; | ||
989 | return ev; // return at least | ||
988 | } | 990 | } |
989 | 991 | ||