author | umopapisdn <umopapisdn> | 2003-03-22 00:39:44 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-03-22 00:39:44 (UTC) |
commit | 32458f9d70e8b13a7e8ff46c06af17860c218f23 (patch) (unidiff) | |
tree | 1b1585cf3f5da0cf28680936bae1773f830f2293 | |
parent | 5d488108161a2dfe1377ac38226b5d8a3a438d11 (diff) | |
download | opie-32458f9d70e8b13a7e8ff46c06af17860c218f23.zip opie-32458f9d70e8b13a7e8ff46c06af17860c218f23.tar.gz opie-32458f9d70e8b13a7e8ff46c06af17860c218f23.tar.bz2 |
Bugfix:
Certain events were not correctly displayed, namely those with
"starting minutes" larger than "ending minutes" (for example an event
starting at 07.30 and ending at 18.00) was displayed as ending at 18.30.
Also added more informative text for events in the weekview.
Events starting and ending on the same day is mentioned with start
and end time.
Events that span across multiple days is also mentioned with start
and end dates.
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index ddd41af..e30c776 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -145,110 +145,113 @@ void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) | |||
145 | viewport()->update(); | 145 | viewport()->update(); |
146 | } | 146 | } |
147 | 147 | ||
148 | void DateBookWeekView::moveToHour( int h ) | 148 | void DateBookWeekView::moveToHour( int h ) |
149 | { | 149 | { |
150 | int offset = h*rowHeight; | 150 | int offset = h*rowHeight; |
151 | setContentsPos( 0, offset ); | 151 | setContentsPos( 0, offset ); |
152 | } | 152 | } |
153 | 153 | ||
154 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) | 154 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) |
155 | { | 155 | { |
156 | e->ignore(); | 156 | e->ignore(); |
157 | } | 157 | } |
158 | 158 | ||
159 | void DateBookWeekView::slotChangeClock( bool c ) | 159 | void DateBookWeekView::slotChangeClock( bool c ) |
160 | { | 160 | { |
161 | ampm = c; | 161 | ampm = c; |
162 | viewport()->update(); | 162 | viewport()->update(); |
163 | } | 163 | } |
164 | 164 | ||
165 | static inline int db_round30min( int m ) | 165 | static inline int db_round30min( int m ) |
166 | { | 166 | { |
167 | if ( m < 15 ) | 167 | if ( m < 15 ) |
168 | m = 0; | 168 | m = 0; |
169 | else if ( m < 45 ) | 169 | else if ( m < 45 ) |
170 | m = 1; | 170 | m = 1; |
171 | else | 171 | else |
172 | m = 2; | 172 | m = 2; |
173 | 173 | ||
174 | return m; | 174 | return m; |
175 | } | 175 | } |
176 | 176 | ||
177 | void DateBookWeekView::alterDay( int day ) | 177 | void DateBookWeekView::alterDay( int day ) |
178 | { | 178 | { |
179 | if ( !bOnMonday ) { | 179 | if ( !bOnMonday ) { |
180 | day--; | 180 | day--; |
181 | } | 181 | } |
182 | emit showDay( day ); | 182 | emit showDay( day ); |
183 | } | 183 | } |
184 | 184 | ||
185 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) | 185 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) |
186 | { | 186 | { |
187 | const int Width = 8; | 187 | const int Width = 8; |
188 | const EffectiveEvent ev = i->event(); | 188 | const EffectiveEvent ev = i->event(); |
189 | 189 | ||
190 | // 30 minute intervals | 190 | // 30 minute intervals |
191 | int y = ev.start().hour() * 2; | 191 | int y = ev.start().hour() * 2; |
192 | y += db_round30min( ev.start().minute() ); | 192 | y += db_round30min( ev.start().minute() ); |
193 | int y2 = ev.end().hour() * 2; | ||
194 | y2 += db_round30min( ev.end().minute() ); | ||
193 | if ( y > 47 ) | 195 | if ( y > 47 ) |
194 | y = 47; | 196 | y = 47; |
197 | if ( y2 > 48 ) | ||
198 | y2 = 48; | ||
195 | y = y * rowHeight / 2; | 199 | y = y * rowHeight / 2; |
200 | y2 = y2 * rowHeight / 2; | ||
196 | 201 | ||
197 | int h; | 202 | int h; |
198 | if ( ev.event().type() == Event::AllDay ) { | 203 | if ( ev.event().type() == Event::AllDay ) { |
199 | h = 48; | 204 | h = 48 * rowHeight / 2; |
200 | y = 0; | 205 | y = 0; |
201 | } else { | 206 | } else { |
202 | h = ( ev.end().hour() - ev.start().hour() ) * 2; | 207 | h=y2-y; |
203 | h += db_round30min( ev.end().minute() - ev.start().minute() ); | ||
204 | if ( h < 1 ) h = 1; | 208 | if ( h < 1 ) h = 1; |
205 | } | 209 | } |
206 | h = h * rowHeight / 2; | ||
207 | 210 | ||
208 | int dow = ev.date().dayOfWeek(); | 211 | int dow = ev.date().dayOfWeek(); |
209 | if ( !bOnMonday ) { | 212 | if ( !bOnMonday ) { |
210 | if ( dow == 7 ) | 213 | if ( dow == 7 ) |
211 | dow = 1; | 214 | dow = 1; |
212 | else | 215 | else |
213 | dow++; | 216 | dow++; |
214 | } | 217 | } |
215 | int x = header->sectionPos( dow ) - 1; | 218 | int x = header->sectionPos( dow ) - 1; |
216 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); | 219 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); |
217 | DateBookWeekItem *isect = 0; | 220 | DateBookWeekItem *isect = 0; |
218 | do { | 221 | do { |
219 | i->setGeometry( x, y, Width, h ); | 222 | i->setGeometry( x, y, Width, h ); |
220 | isect = intersects( i ); | 223 | isect = intersects( i ); |
221 | x += Width - 1; | 224 | x += Width - 1; |
222 | } while ( isect && x < xlim ); | 225 | } while ( isect && x < xlim ); |
223 | } | 226 | } |
224 | 227 | ||
225 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) | 228 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) |
226 | { | 229 | { |
227 | QRect geom = item->geometry(); | 230 | QRect geom = item->geometry(); |
228 | 231 | ||
229 | // We allow the edges to overlap | 232 | // We allow the edges to overlap |
230 | geom.moveBy( 1, 1 ); | 233 | geom.moveBy( 1, 1 ); |
231 | geom.setSize( geom.size()-QSize(2,2) ); | 234 | geom.setSize( geom.size()-QSize(2,2) ); |
232 | 235 | ||
233 | QListIterator<DateBookWeekItem> it(items); | 236 | QListIterator<DateBookWeekItem> it(items); |
234 | for ( ; it.current(); ++it ) { | 237 | for ( ; it.current(); ++it ) { |
235 | DateBookWeekItem *i = it.current(); | 238 | DateBookWeekItem *i = it.current(); |
236 | if ( i != item ) { | 239 | if ( i != item ) { |
237 | if ( i->geometry().intersects( geom ) ) { | 240 | if ( i->geometry().intersects( geom ) ) { |
238 | return i; | 241 | return i; |
239 | } | 242 | } |
240 | } | 243 | } |
241 | } | 244 | } |
242 | 245 | ||
243 | return 0; | 246 | return 0; |
244 | } | 247 | } |
245 | 248 | ||
246 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) | 249 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) |
247 | { | 250 | { |
248 | QListIterator<DateBookWeekItem> it(items); | 251 | QListIterator<DateBookWeekItem> it(items); |
249 | for ( ; it.current(); ++it ) { | 252 | for ( ; it.current(); ++it ) { |
250 | DateBookWeekItem *i = it.current(); | 253 | DateBookWeekItem *i = it.current(); |
251 | if ( i->geometry().contains( e->pos() ) ) { | 254 | if ( i->geometry().contains( e->pos() ) ) { |
252 | showingEvent = true; | 255 | showingEvent = true; |
253 | emit signalShowEvent( i->event() ); | 256 | emit signalShowEvent( i->event() ); |
254 | break; | 257 | break; |
@@ -423,113 +426,105 @@ void DateBookWeek::setDate( int y, int m, int d ) | |||
423 | void DateBookWeek::setDate(QDate date) | 426 | void DateBookWeek::setDate(QDate date) |
424 | { | 427 | { |
425 | dow = date.dayOfWeek(); | 428 | dow = date.dayOfWeek(); |
426 | int w, y; | 429 | int w, y; |
427 | calcWeek( date, w, y, bStartOnMonday ); | 430 | calcWeek( date, w, y, bStartOnMonday ); |
428 | header->setDate( y, w ); | 431 | header->setDate( y, w ); |
429 | } | 432 | } |
430 | 433 | ||
431 | void DateBookWeek::dateChanged( int y, int w ) | 434 | void DateBookWeek::dateChanged( int y, int w ) |
432 | { | 435 | { |
433 | year = y; | 436 | year = y; |
434 | _week = w; | 437 | _week = w; |
435 | getEvents(); | 438 | getEvents(); |
436 | } | 439 | } |
437 | 440 | ||
438 | QDate DateBookWeek::date() const | 441 | QDate DateBookWeek::date() const |
439 | { | 442 | { |
440 | QDate d; | 443 | QDate d; |
441 | d = dateFromWeek( _week - 1, year, bStartOnMonday ); | 444 | d = dateFromWeek( _week - 1, year, bStartOnMonday ); |
442 | if ( bStartOnMonday ) | 445 | if ( bStartOnMonday ) |
443 | d = d.addDays( 7 + dow - 1 ); | 446 | d = d.addDays( 7 + dow - 1 ); |
444 | else { | 447 | else { |
445 | if ( dow == 7 ) | 448 | if ( dow == 7 ) |
446 | d = d.addDays( dow ); | 449 | d = d.addDays( dow ); |
447 | else | 450 | else |
448 | d = d.addDays( 7 + dow ); | 451 | d = d.addDays( 7 + dow ); |
449 | } | 452 | } |
450 | return d; | 453 | return d; |
451 | } | 454 | } |
452 | 455 | ||
453 | void DateBookWeek::getEvents() | 456 | void DateBookWeek::getEvents() |
454 | { | 457 | { |
455 | QDate startWeek = weekDate(); | 458 | QDate startWeek = weekDate(); |
456 | 459 | ||
457 | QDate endWeek = startWeek.addDays( 6 ); | 460 | QDate endWeek = startWeek.addDays( 6 ); |
458 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, | 461 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, |
459 | endWeek); | 462 | endWeek); |
460 | view->showEvents( eventList ); | 463 | view->showEvents( eventList ); |
461 | view->moveToHour( startTime ); | 464 | view->moveToHour( startTime ); |
462 | } | 465 | } |
463 | 466 | ||
464 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | 467 | void DateBookWeek::generateAllDayTooltext( QString& text ) { |
465 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 468 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
466 | } | 469 | } |
467 | 470 | ||
468 | void DateBookWeek::generateNormalTooltext( QString& str, | 471 | void DateBookWeek::generateNormalTooltext( QString& str, |
469 | const EffectiveEvent &ev ) { | 472 | const EffectiveEvent &ev ) { |
470 | str += "<b>" + QObject::tr("Start") + "</b>: "; | 473 | str += "<b>" + QObject::tr("Start") + "</b>: "; |
471 | 474 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); | |
472 | if ( ev.startDate() != ev.date() ) { | 475 | if( ev.startDate()!=ev.endDate() ) { |
473 | // multi-day event. Show start date | 476 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; |
474 | str += TimeString::longDateString( ev.startDate() ); | ||
475 | } else { | ||
476 | // Show start time. | ||
477 | str += TimeString::timeString(ev.start(), ampm, FALSE ); | ||
478 | } | 477 | } |
479 | 478 | str += "<br>"; | |
480 | 479 | str += "<b>" + QObject::tr("End") + "</b>: "; | |
481 | str += "<br><b>" + QObject::tr("End") + "</b>: "; | 480 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); |
482 | if ( ev.endDate() != ev.date() ) { | 481 | if( ev.startDate()!=ev.endDate() ) { |
483 | // multi-day event. Show end date | 482 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; |
484 | str += TimeString::longDateString( ev.endDate() ); | ||
485 | } else { | ||
486 | // Show end time. | ||
487 | str += TimeString::timeString( ev.end(), ampm, FALSE ); | ||
488 | } | 483 | } |
489 | } | 484 | } |
490 | 485 | ||
491 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | 486 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) |
492 | { | 487 | { |
493 | if ( tHide->isActive() ) | 488 | if ( tHide->isActive() ) |
494 | tHide->stop(); | 489 | tHide->stop(); |
495 | 490 | ||
496 | // why would someone use "<"? Oh well, fix it up... | 491 | // why would someone use "<"? Oh well, fix it up... |
497 | // I wonder what other things may be messed up... | 492 | // I wonder what other things may be messed up... |
498 | QString strDesc = ev.description(); | 493 | QString strDesc = ev.description(); |
499 | int where = strDesc.find( "<" ); | 494 | int where = strDesc.find( "<" ); |
500 | while ( where != -1 ) { | 495 | while ( where != -1 ) { |
501 | strDesc.remove( where, 1 ); | 496 | strDesc.remove( where, 1 ); |
502 | strDesc.insert( where, "<" ); | 497 | strDesc.insert( where, "<" ); |
503 | where = strDesc.find( "<", where ); | 498 | where = strDesc.find( "<", where ); |
504 | } | 499 | } |
505 | 500 | ||
506 | QString strCat; | 501 | QString strCat; |
507 | // ### FIX later... | 502 | // ### FIX later... |
508 | // QString strCat = ev.category(); | 503 | // QString strCat = ev.category(); |
509 | // where = strCat.find( "<" ); | 504 | // where = strCat.find( "<" ); |
510 | // while ( where != -1 ) { | 505 | // while ( where != -1 ) { |
511 | // strCat.remove( where, 1 ); | 506 | // strCat.remove( where, 1 ); |
512 | // strCat.insert( where, "<" ); | 507 | // strCat.insert( where, "<" ); |
513 | // where = strCat.find( "<", where ); | 508 | // where = strCat.find( "<", where ); |
514 | // } | 509 | // } |
515 | 510 | ||
516 | QString strLocation = ev.location(); | 511 | QString strLocation = ev.location(); |
517 | while ( where != -1 ) { | 512 | while ( where != -1 ) { |
518 | strLocation.remove( where, 1 ); | 513 | strLocation.remove( where, 1 ); |
519 | strLocation.insert( where, "<" ); | 514 | strLocation.insert( where, "<" ); |
520 | where = strLocation.find( "<", where ); | 515 | where = strLocation.find( "<", where ); |
521 | } | 516 | } |
522 | 517 | ||
523 | QString strNote = ev.notes(); | 518 | QString strNote = ev.notes(); |
524 | where = strNote.find( "<" ); | 519 | where = strNote.find( "<" ); |
525 | while ( where != -1 ) { | 520 | while ( where != -1 ) { |
526 | strNote.remove( where, 1 ); | 521 | strNote.remove( where, 1 ); |
527 | strNote.insert( where, "<" ); | 522 | strNote.insert( where, "<" ); |
528 | where = strNote.find( "<", where ); | 523 | where = strNote.find( "<", where ); |
529 | } | 524 | } |
530 | 525 | ||
531 | QString str = "<b>" + strDesc + "</b><br>" | 526 | QString str = "<b>" + strDesc + "</b><br>" |
532 | + strLocation + "<br>" | 527 | + strLocation + "<br>" |
533 | + "<i>" + strCat + "</i>" | 528 | + "<i>" + strCat + "</i>" |
534 | + "<br>" + TimeString::longDateString( ev.date() ) | 529 | + "<br>" + TimeString::longDateString( ev.date() ) |
535 | + "<br>"; | 530 | + "<br>"; |