summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweek.cpp
authorumopapisdn <umopapisdn>2003-05-13 23:05:33 (UTC)
committer umopapisdn <umopapisdn>2003-05-13 23:05:33 (UTC)
commit81a58bae78d693b67679d94d2f7fcdb300e12d4f (patch) (unidiff)
treee34959f08d7f7d2f3a5c5d86d7115f805d9eed88 /core/pim/datebook/datebookweek.cpp
parent3cd39cd981c4691c559042075c5223d09c87007e (diff)
downloadopie-81a58bae78d693b67679d94d2f7fcdb300e12d4f.zip
opie-81a58bae78d693b67679d94d2f7fcdb300e12d4f.tar.gz
opie-81a58bae78d693b67679d94d2f7fcdb300e12d4f.tar.bz2
Just a removal of a debug message.
Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp1
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
@@ -315,193 +315,192 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
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
326void DateBookWeekView::resizeEvent( QResizeEvent *e ) 326void 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
340void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 340void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
341{ 341{
342 bOnMonday = bStartOnMonday; 342 bOnMonday = bStartOnMonday;
343 initNames(); 343 initNames();
344} 344}
345 345
346//------------------------------------------------------------------- 346//-------------------------------------------------------------------
347 347
348DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 348DateBookWeek::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
380void DateBookWeek::keyPressEvent(QKeyEvent *e) 380void 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
400void DateBookWeek::showDay( int day ) 400void 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
414void DateBookWeek::setDate( int y, int m, int d ) 413void 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
419void DateBookWeek::setDate(QDate newdate) 418void 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
426void DateBookWeek::dateChanged( QDate &newdate ) 425void DateBookWeek::dateChanged( QDate &newdate )
427{ 426{
428 bdate=newdate; 427 bdate=newdate;
429 getEvents(); 428 getEvents();
430} 429}
431 430
432QDate DateBookWeek::date() const 431QDate DateBookWeek::date() const
433{ 432{
434 return bdate; 433 return bdate;
435} 434}
436 435
437void DateBookWeek::getEvents() 436void 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
447void DateBookWeek::generateAllDayTooltext( QString& text ) { 446void 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
451void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { 450void 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
465void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) 464void 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, "&#60;" ); 475 strDesc.insert( where, "&#60;" );
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, "&#60;" ); 485 // strCat.insert( where, "&#60;" );
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, "&#60;" ); 492 strLocation.insert( where, "&#60;" );
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, "&#60;" ); 500 strNote.insert( where, "&#60;" );
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>"