author | umopapisdn <umopapisdn> | 2003-05-13 23:05:33 (UTC) |
---|---|---|
committer | umopapisdn <umopapisdn> | 2003-05-13 23:05:33 (UTC) |
commit | 81a58bae78d693b67679d94d2f7fcdb300e12d4f (patch) (unidiff) | |
tree | e34959f08d7f7d2f3a5c5d86d7115f805d9eed88 | |
parent | 3cd39cd981c4691c559042075c5223d09c87007e (diff) | |
download | opie-81a58bae78d693b67679d94d2f7fcdb300e12d4f.zip opie-81a58bae78d693b67679d94d2f7fcdb300e12d4f.tar.gz opie-81a58bae78d693b67679d94d2f7fcdb300e12d4f.tar.bz2 |
Just a removal of a debug message.
-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 1 |
1 files changed, 0 insertions, 1 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 12f57a0..e49ed28 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp | |||
@@ -155,513 +155,512 @@ void DateBookWeekView::moveToHour( int h ) | |||
155 | 155 | ||
156 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) | 156 | void DateBookWeekView::keyPressEvent( QKeyEvent *e ) |
157 | { | 157 | { |
158 | e->ignore(); | 158 | e->ignore(); |
159 | } | 159 | } |
160 | 160 | ||
161 | void DateBookWeekView::slotChangeClock( bool c ) | 161 | void DateBookWeekView::slotChangeClock( bool c ) |
162 | { | 162 | { |
163 | ampm = c; | 163 | ampm = c; |
164 | viewport()->update(); | 164 | viewport()->update(); |
165 | } | 165 | } |
166 | 166 | ||
167 | static inline int db_round30min( int m ) | 167 | static inline int db_round30min( int m ) |
168 | { | 168 | { |
169 | if ( m < 15 ) | 169 | if ( m < 15 ) |
170 | m = 0; | 170 | m = 0; |
171 | else if ( m < 45 ) | 171 | else if ( m < 45 ) |
172 | m = 1; | 172 | m = 1; |
173 | else | 173 | else |
174 | m = 2; | 174 | m = 2; |
175 | 175 | ||
176 | return m; | 176 | return m; |
177 | } | 177 | } |
178 | 178 | ||
179 | void DateBookWeekView::alterDay( int day ) | 179 | void DateBookWeekView::alterDay( int day ) |
180 | { | 180 | { |
181 | if ( !bOnMonday ) { | 181 | if ( !bOnMonday ) { |
182 | day--; | 182 | day--; |
183 | } | 183 | } |
184 | emit showDay( day ); | 184 | emit showDay( day ); |
185 | } | 185 | } |
186 | 186 | ||
187 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) | 187 | void DateBookWeekView::positionItem( DateBookWeekItem *i ) |
188 | { | 188 | { |
189 | const int Width = 8; | 189 | const int Width = 8; |
190 | const EffectiveEvent ev = i->event(); | 190 | const EffectiveEvent ev = i->event(); |
191 | 191 | ||
192 | // 30 minute intervals | 192 | // 30 minute intervals |
193 | int y = ev.start().hour() * 2; | 193 | int y = ev.start().hour() * 2; |
194 | y += db_round30min( ev.start().minute() ); | 194 | y += db_round30min( ev.start().minute() ); |
195 | int y2 = ev.end().hour() * 2; | 195 | int y2 = ev.end().hour() * 2; |
196 | y2 += db_round30min( ev.end().minute() ); | 196 | y2 += db_round30min( ev.end().minute() ); |
197 | if ( y > 47 ) y = 47; | 197 | if ( y > 47 ) y = 47; |
198 | if ( y2 > 48 ) y2 = 48; | 198 | if ( y2 > 48 ) y2 = 48; |
199 | y = (y * rowHeight) / 2; | 199 | y = (y * rowHeight) / 2; |
200 | y2 = (y2 * rowHeight) / 2; | 200 | y2 = (y2 * rowHeight) / 2; |
201 | 201 | ||
202 | int h; | 202 | int h; |
203 | if ( ev.event().type() == Event::AllDay ) { | 203 | if ( ev.event().type() == Event::AllDay ) { |
204 | h = (48 * rowHeight) / 2; | 204 | h = (48 * rowHeight) / 2; |
205 | y = 0; | 205 | y = 0; |
206 | } else { | 206 | } else { |
207 | h=y2-y; | 207 | h=y2-y; |
208 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; | 208 | if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; |
209 | } | 209 | } |
210 | 210 | ||
211 | int dow = ev.date().dayOfWeek(); | 211 | int dow = ev.date().dayOfWeek(); |
212 | if ( !bOnMonday ) { | 212 | if ( !bOnMonday ) { |
213 | if ( dow == 7 ) | 213 | if ( dow == 7 ) |
214 | dow = 1; | 214 | dow = 1; |
215 | else | 215 | else |
216 | dow++; | 216 | dow++; |
217 | } | 217 | } |
218 | int x = header->sectionPos( dow ) - 1; | 218 | int x = header->sectionPos( dow ) - 1; |
219 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); | 219 | int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); |
220 | DateBookWeekItem *isect = 0; | 220 | DateBookWeekItem *isect = 0; |
221 | do { | 221 | do { |
222 | i->setGeometry( x, y, Width, h ); | 222 | i->setGeometry( x, y, Width, h ); |
223 | isect = intersects( i ); | 223 | isect = intersects( i ); |
224 | x += Width - 1; | 224 | x += Width - 1; |
225 | } while ( isect && x < xlim ); | 225 | } while ( isect && x < xlim ); |
226 | } | 226 | } |
227 | 227 | ||
228 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) | 228 | DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) |
229 | { | 229 | { |
230 | QRect geom = item->geometry(); | 230 | QRect geom = item->geometry(); |
231 | 231 | ||
232 | // We allow the edges to overlap | 232 | // We allow the edges to overlap |
233 | geom.moveBy( 1, 1 ); | 233 | geom.moveBy( 1, 1 ); |
234 | geom.setSize( geom.size()-QSize(2,2) ); | 234 | geom.setSize( geom.size()-QSize(2,2) ); |
235 | 235 | ||
236 | QListIterator<DateBookWeekItem> it(items); | 236 | QListIterator<DateBookWeekItem> it(items); |
237 | for ( ; it.current(); ++it ) { | 237 | for ( ; it.current(); ++it ) { |
238 | DateBookWeekItem *i = it.current(); | 238 | DateBookWeekItem *i = it.current(); |
239 | if ( i != item ) { | 239 | if ( i != item ) { |
240 | if ( i->geometry().intersects( geom ) ) { | 240 | if ( i->geometry().intersects( geom ) ) { |
241 | return i; | 241 | return i; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | 245 | ||
246 | return 0; | 246 | return 0; |
247 | } | 247 | } |
248 | 248 | ||
249 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) | 249 | void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) |
250 | { | 250 | { |
251 | QListIterator<DateBookWeekItem> it(items); | 251 | QListIterator<DateBookWeekItem> it(items); |
252 | for ( ; it.current(); ++it ) { | 252 | for ( ; it.current(); ++it ) { |
253 | DateBookWeekItem *i = it.current(); | 253 | DateBookWeekItem *i = it.current(); |
254 | if ( i->geometry().contains( e->pos() ) ) { | 254 | if ( i->geometry().contains( e->pos() ) ) { |
255 | showingEvent = true; | 255 | showingEvent = true; |
256 | emit signalShowEvent( i->event() ); | 256 | emit signalShowEvent( i->event() ); |
257 | break; | 257 | break; |
258 | } | 258 | } |
259 | } | 259 | } |
260 | } | 260 | } |
261 | 261 | ||
262 | void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) | 262 | void DateBookWeekView::contentsMouseReleaseEvent( QMouseEvent *e ) |
263 | { | 263 | { |
264 | if ( showingEvent ) { | 264 | if ( showingEvent ) { |
265 | showingEvent = false; | 265 | showingEvent = false; |
266 | emit signalHideEvent(); | 266 | emit signalHideEvent(); |
267 | } else { | 267 | } else { |
268 | int d = header->sectionAt( e->pos().x() ); | 268 | int d = header->sectionAt( e->pos().x() ); |
269 | if ( d > 0 ) { | 269 | if ( d > 0 ) { |
270 | // if ( !bOnMonday ) | 270 | // if ( !bOnMonday ) |
271 | // d--; | 271 | // d--; |
272 | emit showDay( d ); | 272 | emit showDay( d ); |
273 | } | 273 | } |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) | 277 | void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch ) |
278 | { | 278 | { |
279 | QRect ur( cx, cy, cw, ch ); | 279 | QRect ur( cx, cy, cw, ch ); |
280 | p->setPen( lightGray ); | 280 | p->setPen( lightGray ); |
281 | for ( int i = 1; i <= 7; i++ ) | 281 | for ( int i = 1; i <= 7; i++ ) |
282 | p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); | 282 | p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); |
283 | 283 | ||
284 | p->setPen( black ); | 284 | p->setPen( black ); |
285 | for ( int t = 0; t < 24; t++ ) { | 285 | for ( int t = 0; t < 24; t++ ) { |
286 | int y = t*rowHeight; | 286 | int y = t*rowHeight; |
287 | if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { | 287 | if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { |
288 | QString s; | 288 | QString s; |
289 | if ( ampm ) { | 289 | if ( ampm ) { |
290 | if ( t == 0 ) | 290 | if ( t == 0 ) |
291 | s = QString::number( 12 ); | 291 | s = QString::number( 12 ); |
292 | else if ( t == 12 ) | 292 | else if ( t == 12 ) |
293 | s = QString::number(12) + tr( "p" ); | 293 | s = QString::number(12) + tr( "p" ); |
294 | else if ( t > 12 ) { | 294 | else if ( t > 12 ) { |
295 | if ( t - 12 < 10 ) | 295 | if ( t - 12 < 10 ) |
296 | s = " "; | 296 | s = " "; |
297 | else | 297 | else |
298 | s = ""; | 298 | s = ""; |
299 | s += QString::number( t - 12 ) + tr("p"); | 299 | s += QString::number( t - 12 ) + tr("p"); |
300 | } else { | 300 | } else { |
301 | if ( 12 - t < 3 ) | 301 | if ( 12 - t < 3 ) |
302 | s = ""; | 302 | s = ""; |
303 | else | 303 | else |
304 | s = " "; | 304 | s = " "; |
305 | s += QString::number( t ); | 305 | s += QString::number( t ); |
306 | } | 306 | } |
307 | } else { | 307 | } else { |
308 | s = QString::number( t ); | 308 | s = QString::number( t ); |
309 | if ( s.length() == 1 ) | 309 | if ( s.length() == 1 ) |
310 | s.prepend( "0" ); | 310 | s.prepend( "0" ); |
311 | } | 311 | } |
312 | p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); | 312 | p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); |
313 | } | 313 | } |
314 | } | 314 | } |
315 | 315 | ||
316 | QListIterator<DateBookWeekItem> it(items); | 316 | QListIterator<DateBookWeekItem> it(items); |
317 | for ( ; it.current(); ++it ) { | 317 | for ( ; it.current(); ++it ) { |
318 | DateBookWeekItem *i = it.current(); | 318 | DateBookWeekItem *i = it.current(); |
319 | if ( i->geometry().intersects( ur ) ) { | 319 | if ( i->geometry().intersects( ur ) ) { |
320 | p->setBrush( i->color() ); | 320 | p->setBrush( i->color() ); |
321 | p->drawRect( i->geometry() ); | 321 | p->drawRect( i->geometry() ); |
322 | } | 322 | } |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | void DateBookWeekView::resizeEvent( QResizeEvent *e ) | 326 | void DateBookWeekView::resizeEvent( QResizeEvent *e ) |
327 | { | 327 | { |
328 | const int hourWidth = 20; | 328 | const int hourWidth = 20; |
329 | QScrollView::resizeEvent( e ); | 329 | QScrollView::resizeEvent( e ); |
330 | int avail = width()-qApp->style().scrollBarExtent().width()-1; | 330 | int avail = width()-qApp->style().scrollBarExtent().width()-1; |
331 | header->setGeometry( 0, 0, avail, header->sizeHint().height() ); | 331 | header->setGeometry( 0, 0, avail, header->sizeHint().height() ); |
332 | setMargins( 0, header->height(), 0, 0 ); | 332 | setMargins( 0, header->height(), 0, 0 ); |
333 | header->resizeSection( 0, hourWidth ); | 333 | header->resizeSection( 0, hourWidth ); |
334 | int sw = (avail - hourWidth) / 7; | 334 | int sw = (avail - hourWidth) / 7; |
335 | for ( int i = 1; i < 7; i++ ) | 335 | for ( int i = 1; i < 7; i++ ) |
336 | header->resizeSection( i, sw ); | 336 | header->resizeSection( i, sw ); |
337 | header->resizeSection( 7, avail - hourWidth - sw*6 ); | 337 | header->resizeSection( 7, avail - hourWidth - sw*6 ); |
338 | } | 338 | } |
339 | 339 | ||
340 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) | 340 | void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) |
341 | { | 341 | { |
342 | bOnMonday = bStartOnMonday; | 342 | bOnMonday = bStartOnMonday; |
343 | initNames(); | 343 | initNames(); |
344 | } | 344 | } |
345 | 345 | ||
346 | //------------------------------------------------------------------- | 346 | //------------------------------------------------------------------- |
347 | 347 | ||
348 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, | 348 | DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, |
349 | QWidget *parent, const char *name ) | 349 | QWidget *parent, const char *name ) |
350 | : QWidget( parent, name ), | 350 | : QWidget( parent, name ), |
351 | db( newDB ), | 351 | db( newDB ), |
352 | startTime( 0 ), | 352 | startTime( 0 ), |
353 | ampm( ap ), | 353 | ampm( ap ), |
354 | bStartOnMonday( startOnMonday ) | 354 | bStartOnMonday( startOnMonday ) |
355 | { | 355 | { |
356 | setFocusPolicy(StrongFocus); | 356 | setFocusPolicy(StrongFocus); |
357 | QVBoxLayout *vb = new QVBoxLayout( this ); | 357 | QVBoxLayout *vb = new QVBoxLayout( this ); |
358 | header = new DateBookWeekHeader( bStartOnMonday, this ); | 358 | header = new DateBookWeekHeader( bStartOnMonday, this ); |
359 | view = new DateBookWeekView( ampm, startOnMonday, this ); | 359 | view = new DateBookWeekView( ampm, startOnMonday, this ); |
360 | vb->addWidget( header ); | 360 | vb->addWidget( header ); |
361 | vb->addWidget( view ); | 361 | vb->addWidget( view ); |
362 | 362 | ||
363 | lblDesc = new QLabel( this, "event label" ); | 363 | lblDesc = new QLabel( this, "event label" ); |
364 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); | 364 | lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); |
365 | lblDesc->setBackgroundColor( yellow ); | 365 | lblDesc->setBackgroundColor( yellow ); |
366 | lblDesc->hide(); | 366 | lblDesc->hide(); |
367 | 367 | ||
368 | tHide = new QTimer( this ); | 368 | tHide = new QTimer( this ); |
369 | 369 | ||
370 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); | 370 | connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); |
371 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); | 371 | connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); |
372 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); | 372 | connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); |
373 | connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); | 373 | connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); |
374 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); | 374 | connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); |
375 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); | 375 | connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); |
376 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); | 376 | connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); |
377 | setDate(QDate::currentDate()); | 377 | setDate(QDate::currentDate()); |
378 | } | 378 | } |
379 | 379 | ||
380 | void DateBookWeek::keyPressEvent(QKeyEvent *e) | 380 | void DateBookWeek::keyPressEvent(QKeyEvent *e) |
381 | { | 381 | { |
382 | switch(e->key()) { | 382 | switch(e->key()) { |
383 | case Key_Up: | 383 | case Key_Up: |
384 | view->scrollBy(0, -20); | 384 | view->scrollBy(0, -20); |
385 | break; | 385 | break; |
386 | case Key_Down: | 386 | case Key_Down: |
387 | view->scrollBy(0, 20); | 387 | view->scrollBy(0, 20); |
388 | break; | 388 | break; |
389 | case Key_Left: | 389 | case Key_Left: |
390 | setDate(date().addDays(-7)); | 390 | setDate(date().addDays(-7)); |
391 | break; | 391 | break; |
392 | case Key_Right: | 392 | case Key_Right: |
393 | setDate(date().addDays(7)); | 393 | setDate(date().addDays(7)); |
394 | break; | 394 | break; |
395 | default: | 395 | default: |
396 | e->ignore(); | 396 | e->ignore(); |
397 | } | 397 | } |
398 | } | 398 | } |
399 | 399 | ||
400 | void DateBookWeek::showDay( int day ) | 400 | void DateBookWeek::showDay( int day ) |
401 | { | 401 | { |
402 | QDate d=bdate; | 402 | QDate d=bdate; |
403 | 403 | ||
404 | // Calculate offset to first day of week. | 404 | // Calculate offset to first day of week. |
405 | int dayoffset=d.dayOfWeek(); | 405 | int dayoffset=d.dayOfWeek(); |
406 | if(bStartOnMonday) dayoffset--; | 406 | if(bStartOnMonday) dayoffset--; |
407 | 407 | ||
408 | day--; | 408 | day--; |
409 | d=d.addDays(day-dayoffset); | 409 | d=d.addDays(day-dayoffset); |
410 | emit showDate( d.year(), d.month(), d.day() ); | 410 | emit showDate( d.year(), d.month(), d.day() ); |
411 | qDebug("%4d-%02d-%02d / Day %d\n",d.year(),d.month(),d.day(),day); | ||
412 | } | 411 | } |
413 | 412 | ||
414 | void DateBookWeek::setDate( int y, int m, int d ) | 413 | void DateBookWeek::setDate( int y, int m, int d ) |
415 | { | 414 | { |
416 | setDate(QDate(y, m, d)); | 415 | setDate(QDate(y, m, d)); |
417 | } | 416 | } |
418 | 417 | ||
419 | void DateBookWeek::setDate(QDate newdate) | 418 | void DateBookWeek::setDate(QDate newdate) |
420 | { | 419 | { |
421 | bdate=newdate; | 420 | bdate=newdate; |
422 | dow = newdate.dayOfWeek(); | 421 | dow = newdate.dayOfWeek(); |
423 | header->setDate( newdate ); | 422 | header->setDate( newdate ); |
424 | } | 423 | } |
425 | 424 | ||
426 | void DateBookWeek::dateChanged( QDate &newdate ) | 425 | void DateBookWeek::dateChanged( QDate &newdate ) |
427 | { | 426 | { |
428 | bdate=newdate; | 427 | bdate=newdate; |
429 | getEvents(); | 428 | getEvents(); |
430 | } | 429 | } |
431 | 430 | ||
432 | QDate DateBookWeek::date() const | 431 | QDate DateBookWeek::date() const |
433 | { | 432 | { |
434 | return bdate; | 433 | return bdate; |
435 | } | 434 | } |
436 | 435 | ||
437 | void DateBookWeek::getEvents() | 436 | void DateBookWeek::getEvents() |
438 | { | 437 | { |
439 | QDate startWeek = weekDate(); | 438 | QDate startWeek = weekDate(); |
440 | 439 | ||
441 | QDate endWeek = startWeek.addDays( 6 ); | 440 | QDate endWeek = startWeek.addDays( 6 ); |
442 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); | 441 | QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); |
443 | view->showEvents( eventList ); | 442 | view->showEvents( eventList ); |
444 | view->moveToHour( startTime ); | 443 | view->moveToHour( startTime ); |
445 | } | 444 | } |
446 | 445 | ||
447 | void DateBookWeek::generateAllDayTooltext( QString& text ) { | 446 | void DateBookWeek::generateAllDayTooltext( QString& text ) { |
448 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; | 447 | text += "<b>" + tr("This is an all day event.") + "</b><br>"; |
449 | } | 448 | } |
450 | 449 | ||
451 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { | 450 | void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { |
452 | str += "<b>" + QObject::tr("Start") + "</b>: "; | 451 | str += "<b>" + QObject::tr("Start") + "</b>: "; |
453 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); | 452 | str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); |
454 | if( ev.startDate()!=ev.endDate() ) { | 453 | if( ev.startDate()!=ev.endDate() ) { |
455 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; | 454 | str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; |
456 | } | 455 | } |
457 | str += "<br>"; | 456 | str += "<br>"; |
458 | str += "<b>" + QObject::tr("End") + "</b>: "; | 457 | str += "<b>" + QObject::tr("End") + "</b>: "; |
459 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); | 458 | str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); |
460 | if( ev.startDate()!=ev.endDate() ) { | 459 | if( ev.startDate()!=ev.endDate() ) { |
461 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; | 460 | str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; |
462 | } | 461 | } |
463 | } | 462 | } |
464 | 463 | ||
465 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) | 464 | void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) |
466 | { | 465 | { |
467 | if ( tHide->isActive() ) | 466 | if ( tHide->isActive() ) |
468 | tHide->stop(); | 467 | tHide->stop(); |
469 | 468 | ||
470 | // why would someone use "<"? Oh well, fix it up... | 469 | // why would someone use "<"? Oh well, fix it up... |
471 | // I wonder what other things may be messed up... | 470 | // I wonder what other things may be messed up... |
472 | QString strDesc = ev.description(); | 471 | QString strDesc = ev.description(); |
473 | int where = strDesc.find( "<" ); | 472 | int where = strDesc.find( "<" ); |
474 | while ( where != -1 ) { | 473 | while ( where != -1 ) { |
475 | strDesc.remove( where, 1 ); | 474 | strDesc.remove( where, 1 ); |
476 | strDesc.insert( where, "<" ); | 475 | strDesc.insert( where, "<" ); |
477 | where = strDesc.find( "<", where ); | 476 | where = strDesc.find( "<", where ); |
478 | } | 477 | } |
479 | 478 | ||
480 | QString strCat; | 479 | QString strCat; |
481 | // ### FIX later... | 480 | // ### FIX later... |
482 | // QString strCat = ev.category(); | 481 | // QString strCat = ev.category(); |
483 | // where = strCat.find( "<" ); | 482 | // where = strCat.find( "<" ); |
484 | // while ( where != -1 ) { | 483 | // while ( where != -1 ) { |
485 | // strCat.remove( where, 1 ); | 484 | // strCat.remove( where, 1 ); |
486 | // strCat.insert( where, "<" ); | 485 | // strCat.insert( where, "<" ); |
487 | // where = strCat.find( "<", where ); | 486 | // where = strCat.find( "<", where ); |
488 | // } | 487 | // } |
489 | 488 | ||
490 | QString strLocation = ev.location(); | 489 | QString strLocation = ev.location(); |
491 | while ( where != -1 ) { | 490 | while ( where != -1 ) { |
492 | strLocation.remove( where, 1 ); | 491 | strLocation.remove( where, 1 ); |
493 | strLocation.insert( where, "<" ); | 492 | strLocation.insert( where, "<" ); |
494 | where = strLocation.find( "<", where ); | 493 | where = strLocation.find( "<", where ); |
495 | } | 494 | } |
496 | 495 | ||
497 | QString strNote = ev.notes(); | 496 | QString strNote = ev.notes(); |
498 | where = strNote.find( "<" ); | 497 | where = strNote.find( "<" ); |
499 | while ( where != -1 ) { | 498 | while ( where != -1 ) { |
500 | strNote.remove( where, 1 ); | 499 | strNote.remove( where, 1 ); |
501 | strNote.insert( where, "<" ); | 500 | strNote.insert( where, "<" ); |
502 | where = strNote.find( "<", where ); | 501 | where = strNote.find( "<", where ); |
503 | } | 502 | } |
504 | 503 | ||
505 | QString str = "<b>" + strDesc + "</b><br>" | 504 | QString str = "<b>" + strDesc + "</b><br>" |
506 | + strLocation + "<br>" | 505 | + strLocation + "<br>" |
507 | + "<i>" + strCat + "</i>" | 506 | + "<i>" + strCat + "</i>" |
508 | + "<br>" + TimeString::longDateString( ev.date() ) | 507 | + "<br>" + TimeString::longDateString( ev.date() ) |
509 | + "<br>"; | 508 | + "<br>"; |
510 | 509 | ||
511 | if (ev.event().type() == Event::Normal ) | 510 | if (ev.event().type() == Event::Normal ) |
512 | generateNormalTooltext( str, ev ); | 511 | generateNormalTooltext( str, ev ); |
513 | else | 512 | else |
514 | generateAllDayTooltext( str ); | 513 | generateAllDayTooltext( str ); |
515 | 514 | ||
516 | str += "<br><br>" + strNote; | 515 | str += "<br><br>" + strNote; |
517 | 516 | ||
518 | lblDesc->setText( str ); | 517 | lblDesc->setText( str ); |
519 | lblDesc->resize( lblDesc->sizeHint() ); | 518 | lblDesc->resize( lblDesc->sizeHint() ); |
520 | // move the label so it is "centerd" horizontally... | 519 | // move the label so it is "centerd" horizontally... |
521 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); | 520 | lblDesc->move( QMAX(0,(width() - lblDesc->width()) / 2), 0 ); |
522 | lblDesc->show(); | 521 | lblDesc->show(); |
523 | } | 522 | } |
524 | 523 | ||
525 | void DateBookWeek::slotHideEvent() | 524 | void DateBookWeek::slotHideEvent() |
526 | { | 525 | { |
527 | tHide->start( 2000, true ); | 526 | tHide->start( 2000, true ); |
528 | } | 527 | } |
529 | 528 | ||
530 | void DateBookWeek::setStartViewTime( int startHere ) | 529 | void DateBookWeek::setStartViewTime( int startHere ) |
531 | { | 530 | { |
532 | startTime = startHere; | 531 | startTime = startHere; |
533 | view->moveToHour( startTime ); | 532 | view->moveToHour( startTime ); |
534 | } | 533 | } |
535 | 534 | ||
536 | int DateBookWeek::startViewTime() const | 535 | int DateBookWeek::startViewTime() const |
537 | { | 536 | { |
538 | return startTime; | 537 | return startTime; |
539 | } | 538 | } |
540 | 539 | ||
541 | void DateBookWeek::redraw() | 540 | void DateBookWeek::redraw() |
542 | { | 541 | { |
543 | getEvents(); | 542 | getEvents(); |
544 | } | 543 | } |
545 | 544 | ||
546 | void DateBookWeek::slotYearChanged( int y ) | 545 | void DateBookWeek::slotYearChanged( int y ) |
547 | { | 546 | { |
548 | int totWeek; | 547 | int totWeek; |
549 | QDate d( y, 12, 31 ); | 548 | QDate d( y, 12, 31 ); |
550 | int throwAway; | 549 | int throwAway; |
551 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 550 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
552 | while ( totWeek == 1 ) { | 551 | while ( totWeek == 1 ) { |
553 | d = d.addDays( -1 ); | 552 | d = d.addDays( -1 ); |
554 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); | 553 | calcWeek( d, totWeek, throwAway, bStartOnMonday ); |
555 | } | 554 | } |
556 | } | 555 | } |
557 | 556 | ||
558 | void DateBookWeek::slotWeekChanged( bool onMonday ) | 557 | void DateBookWeek::slotWeekChanged( bool onMonday ) |
559 | { | 558 | { |
560 | bStartOnMonday = onMonday; | 559 | bStartOnMonday = onMonday; |
561 | view->setStartOfWeek( bStartOnMonday ); | 560 | view->setStartOfWeek( bStartOnMonday ); |
562 | header->setStartOfWeek( bStartOnMonday ); | 561 | header->setStartOfWeek( bStartOnMonday ); |
563 | redraw(); | 562 | redraw(); |
564 | } | 563 | } |
565 | 564 | ||
566 | void DateBookWeek::slotClockChanged( bool ap ) | 565 | void DateBookWeek::slotClockChanged( bool ap ) |
567 | { | 566 | { |
568 | ampm = ap; | 567 | ampm = ap; |
569 | } | 568 | } |
570 | 569 | ||
571 | // return the date at the beginning of the week... | 570 | // return the date at the beginning of the week... |
572 | QDate DateBookWeek::weekDate() const | 571 | QDate DateBookWeek::weekDate() const |
573 | { | 572 | { |
574 | QDate d=bdate; | 573 | QDate d=bdate; |
575 | 574 | ||
576 | // Calculate offset to first day of week. | 575 | // Calculate offset to first day of week. |
577 | int dayoffset=d.dayOfWeek(); | 576 | int dayoffset=d.dayOfWeek(); |
578 | if(bStartOnMonday) dayoffset--; | 577 | if(bStartOnMonday) dayoffset--; |
579 | 578 | ||
580 | return d.addDays(-dayoffset); | 579 | return d.addDays(-dayoffset); |
581 | } | 580 | } |
582 | 581 | ||
583 | // this used to only be needed by datebook.cpp, but now we need it inside | 582 | // this used to only be needed by datebook.cpp, but now we need it inside |
584 | // week view since | 583 | // week view since |
585 | // we need to be able to figure out our total number of weeks on the fly... | 584 | // we need to be able to figure out our total number of weeks on the fly... |
586 | // this is probably the best place to put it.. | 585 | // this is probably the best place to put it.. |
587 | 586 | ||
588 | // For Weeks that start on Monday... (EASY!) | 587 | // For Weeks that start on Monday... (EASY!) |
589 | // At the moment we will use ISO 8601 method for computing | 588 | // At the moment we will use ISO 8601 method for computing |
590 | // the week. Granted, other countries use other methods, | 589 | // the week. Granted, other countries use other methods, |
591 | // bet we aren't doing any Locale stuff at the moment. So, | 590 | // bet we aren't doing any Locale stuff at the moment. So, |
592 | // this should pass. This Algorithim is public domain and | 591 | // this should pass. This Algorithim is public domain and |
593 | // available at: | 592 | // available at: |
594 | // http://personal.ecu.edu/mccartyr/ISOwdALG.txt | 593 | // http://personal.ecu.edu/mccartyr/ISOwdALG.txt |
595 | // the week number is return, and the year number is returned in year | 594 | // the week number is return, and the year number is returned in year |
596 | // for Instance 2001/12/31 is actually the first week in 2002. | 595 | // for Instance 2001/12/31 is actually the first week in 2002. |
597 | // There is a more mathematical definition, but I will implement it when | 596 | // There is a more mathematical definition, but I will implement it when |
598 | // we are pass our deadline. | 597 | // we are pass our deadline. |
599 | 598 | ||
600 | // For Weeks that start on Sunday... (ahh... home rolled) | 599 | // For Weeks that start on Sunday... (ahh... home rolled) |
601 | // okay, if Jan 1 is on Friday or Saturday, | 600 | // okay, if Jan 1 is on Friday or Saturday, |
602 | // it will go to the pervious | 601 | // it will go to the pervious |
603 | // week... | 602 | // week... |
604 | 603 | ||
605 | bool calcWeek( const QDate &d, int &week, int &year, | 604 | bool calcWeek( const QDate &d, int &week, int &year, |
606 | bool startOnMonday ) | 605 | bool startOnMonday ) |
607 | { | 606 | { |
608 | int weekNumber; | 607 | int weekNumber; |
609 | int yearNumber; | 608 | int yearNumber; |
610 | 609 | ||
611 | // remove a pesky warning, (Optimizations on g++) | 610 | // remove a pesky warning, (Optimizations on g++) |
612 | weekNumber = -1; | 611 | weekNumber = -1; |
613 | int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek(); | 612 | int jan1WeekDay = QDate(d.year(), 1, 1).dayOfWeek(); |
614 | int dayOfWeek = d.dayOfWeek(); | 613 | int dayOfWeek = d.dayOfWeek(); |
615 | 614 | ||
616 | if ( !d.isValid() ) | 615 | if ( !d.isValid() ) |
617 | return false; | 616 | return false; |
618 | 617 | ||
619 | if ( startOnMonday ) { | 618 | if ( startOnMonday ) { |
620 | // find the Jan1Weekday; | 619 | // find the Jan1Weekday; |
621 | if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { | 620 | if ( d.dayOfYear() <= ( 8 - jan1WeekDay) && jan1WeekDay > 4 ) { |
622 | yearNumber = d.year() - 1; | 621 | yearNumber = d.year() - 1; |
623 | if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) | 622 | if ( jan1WeekDay == 5 || ( jan1WeekDay == 6 && QDate::leapYear(yearNumber) ) ) |
624 | weekNumber = 53; | 623 | weekNumber = 53; |
625 | else | 624 | else |
626 | weekNumber = 52; | 625 | weekNumber = 52; |
627 | } else | 626 | } else |
628 | yearNumber = d.year(); | 627 | yearNumber = d.year(); |
629 | if ( yearNumber == d.year() ) { | 628 | if ( yearNumber == d.year() ) { |
630 | int totalDays = 365; | 629 | int totalDays = 365; |
631 | if ( QDate::leapYear(yearNumber) ) | 630 | if ( QDate::leapYear(yearNumber) ) |
632 | totalDays++; | 631 | totalDays++; |
633 | if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) ) | 632 | if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek) ) |
634 | || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) { | 633 | || (jan1WeekDay == 7) && (totalDays - d.dayOfYear()) < 3) { |
635 | yearNumber++; | 634 | yearNumber++; |
636 | weekNumber = 1; | 635 | weekNumber = 1; |
637 | } | 636 | } |
638 | } | 637 | } |
639 | if ( yearNumber == d.year() ) { | 638 | if ( yearNumber == d.year() ) { |
640 | int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 ); | 639 | int j = d.dayOfYear() + (7 - dayOfWeek) + ( jan1WeekDay - 1 ); |
641 | weekNumber = j / 7; | 640 | weekNumber = j / 7; |
642 | if ( jan1WeekDay > 4 ) | 641 | if ( jan1WeekDay > 4 ) |
643 | weekNumber--; | 642 | weekNumber--; |
644 | } | 643 | } |
645 | } else { | 644 | } else { |
646 | // it's better to keep these cases separate... | 645 | // it's better to keep these cases separate... |
647 | if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4 | 646 | if ( d.dayOfYear() <= (7 - jan1WeekDay) && jan1WeekDay > 4 |
648 | && jan1WeekDay != 7 ) { | 647 | && jan1WeekDay != 7 ) { |
649 | yearNumber = d.year() - 1; | 648 | yearNumber = d.year() - 1; |
650 | if ( jan1WeekDay == 6 | 649 | if ( jan1WeekDay == 6 |
651 | || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) { | 650 | || (jan1WeekDay == 7 && QDate::leapYear(yearNumber) ) ) { |
652 | weekNumber = 53; | 651 | weekNumber = 53; |
653 | }else | 652 | }else |
654 | weekNumber = 52; | 653 | weekNumber = 52; |
655 | } else | 654 | } else |
656 | yearNumber = d.year(); | 655 | yearNumber = d.year(); |
657 | if ( yearNumber == d.year() ) { | 656 | if ( yearNumber == d.year() ) { |
658 | int totalDays = 365; | 657 | int totalDays = 365; |
659 | if ( QDate::leapYear( yearNumber ) ) | 658 | if ( QDate::leapYear( yearNumber ) ) |
660 | totalDays++; | 659 | totalDays++; |
661 | if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) { | 660 | if ( ((totalDays - d.dayOfYear()) < (4 - dayOfWeek % 7)) ) { |
662 | yearNumber++; | 661 | yearNumber++; |
663 | weekNumber = 1; | 662 | weekNumber = 1; |
664 | } | 663 | } |
665 | } | 664 | } |
666 | if ( yearNumber == d.year() ) { | 665 | if ( yearNumber == d.year() ) { |
667 | int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 ); | 666 | int j = d.dayOfYear() + (7 - dayOfWeek % 7) + ( jan1WeekDay - 1 ); |