summaryrefslogtreecommitdiff
path: root/core/pim/datebook/datebookweek.cpp
Unidiff
Diffstat (limited to 'core/pim/datebook/datebookweek.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index dad1c3f..8435132 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -292,52 +292,64 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
292 } 292 }
293 } else { 293 } else {
294 s = QString::number( t ); 294 s = QString::number( t );
295 if ( s.length() == 1 ) 295 if ( s.length() == 1 )
296 s.prepend( "0" ); 296 s.prepend( "0" );
297 } 297 }
298 p->drawText( 1, y+p->fontMetrics().ascent()+1, s ); 298 p->drawText( 1, y+p->fontMetrics().ascent()+1, s );
299 } 299 }
300 } 300 }
301 301
302 QListIterator<DateBookWeekItem> it(items); 302 QListIterator<DateBookWeekItem> it(items);
303 for ( ; it.current(); ++it ) { 303 for ( ; it.current(); ++it ) {
304 DateBookWeekItem *i = it.current(); 304 DateBookWeekItem *i = it.current();
305 if ( i->geometry().intersects( ur ) ) { 305 if ( i->geometry().intersects( ur ) ) {
306 p->setBrush( i->color() ); 306 p->setBrush( i->color() );
307 p->drawRect( i->geometry() ); 307 p->drawRect( i->geometry() );
308 } 308 }
309 } 309 }
310} 310}
311 311
312void DateBookWeekView::resizeEvent( QResizeEvent *e ) 312void DateBookWeekView::resizeEvent( QResizeEvent *e )
313{ 313{
314 const int hourWidth = 20; 314 const int hourWidth = 20;
315 QScrollView::resizeEvent( e ); 315 QScrollView::resizeEvent( e );
316
317#warning check the geometry i have choosen BRANCH_1_0 (waspe)
318
319 //HEAD
320 /*
316 int avail = visibleWidth(); 321 int avail = visibleWidth();
317 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(), 322 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
318 visibleWidth(), header->sizeHint().height() ); 323 visibleWidth(), header->sizeHint().height() );
319 setMargins( 0, header->sizeHint().height(), 0, 0 ); 324 setMargins( 0, header->sizeHint().height(), 0, 0 );
325 */
326 //BRANCH_1_0
327 int avail = width()-qApp->style().scrollBarExtent().width()-1;
328 header->setGeometry( 0, 0, avail, header->sizeHint().height() );
329 setMargins( 0, header->height(), 0, 0 );
330
331
320 header->resizeSection( 0, hourWidth ); 332 header->resizeSection( 0, hourWidth );
321 int sw = (avail - hourWidth) / 7; 333 int sw = (avail - hourWidth) / 7;
322 for ( int i = 1; i < 7; i++ ) 334 for ( int i = 1; i < 7; i++ )
323 header->resizeSection( i, sw ); 335 header->resizeSection( i, sw );
324 header->resizeSection( 7, avail - hourWidth - sw*6 ); 336 header->resizeSection( 7, avail - hourWidth - sw*6 );
325} 337}
326 338
327void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 339void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
328{ 340{
329 bOnMonday = bStartOnMonday; 341 bOnMonday = bStartOnMonday;
330 initNames(); 342 initNames();
331} 343}
332 344
333//------------------------------------------------------------------- 345//-------------------------------------------------------------------
334 346
335DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 347DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
336 QWidget *parent, const char *name ) 348 QWidget *parent, const char *name )
337 : QWidget( parent, name ), 349 : QWidget( parent, name ),
338 db( newDB ), 350 db( newDB ),
339 startTime( 0 ), 351 startTime( 0 ),
340 ampm( ap ), 352 ampm( ap ),
341 bStartOnMonday( startOnMonday ) 353 bStartOnMonday( startOnMonday )
342{ 354{
343 setFocusPolicy(StrongFocus); 355 setFocusPolicy(StrongFocus);
@@ -353,49 +365,49 @@ DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
353 lblDesc->hide(); 365 lblDesc->hide();
354 366
355 tHide = new QTimer( this ); 367 tHide = new QTimer( this );
356 368
357 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); 369 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) );
358 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 370 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
359 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); 371 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
360 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); 372 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) );
361 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); 373 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
362 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 374 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
363 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); 375 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
364 setDate(QDate::currentDate()); 376 setDate(QDate::currentDate());
365} 377}
366 378
367void DateBookWeek::keyPressEvent(QKeyEvent *e) 379void DateBookWeek::keyPressEvent(QKeyEvent *e)
368{ 380{
369 switch(e->key()) { 381 switch(e->key()) {
370 case Key_Up: 382 case Key_Up:
371 view->scrollBy(0, -20); 383 view->scrollBy(0, -20);
372 break; 384 break;
373 case Key_Down: 385 case Key_Down:
374 view->scrollBy(0, 20); 386 view->scrollBy(0, 20);
375 break; 387 break;
376 case Key_Left: 388 case Key_Left:
377 setDate(date().addDays(-7)); 389 setDate(date().addDays(-7));
378 break; 390 break;
379 case Key_Right: 391 case Key_Right:
380 setDate(date().addDays(7)); 392 setDate(date().addDays(7));
381 break; 393 break;
382 default: 394 default:
383 e->ignore(); 395 e->ignore();
384 } 396 }
385} 397}
386 398
387void DateBookWeek::showDay( int day ) 399void DateBookWeek::showDay( int day )
388{ 400{
389 QDate d=bdate; 401 QDate d=bdate;
390 402
391 // Calculate offset to first day of week. 403 // Calculate offset to first day of week.
392 int dayoffset=d.dayOfWeek() % 7; 404 int dayoffset=d.dayOfWeek() % 7;
393 405
394 if(bStartOnMonday) dayoffset--; 406 if(bStartOnMonday) dayoffset--;
395 407
396 day--; 408 day--;
397 d=d.addDays(day-dayoffset); 409 d=d.addDays(day-dayoffset);
398 emit showDate( d.year(), d.month(), d.day() ); 410 emit showDate( d.year(), d.month(), d.day() );
399} 411}
400 412
401void DateBookWeek::setDate( int y, int m, int d ) 413void DateBookWeek::setDate( int y, int m, int d )