summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/pim/datebook/datebookweek.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp
index ab7e963..dad1c3f 100644
--- a/core/pim/datebook/datebookweek.cpp
+++ b/core/pim/datebook/datebookweek.cpp
@@ -268,99 +268,100 @@ void DateBookWeekView::drawContents( QPainter *p, int cx, int cy, int cw, int ch
268 p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch ); 268 p->drawLine( header->sectionPos(i)-2, cy, header->sectionPos(i)-2, cy+ch );
269 269
270 p->setPen( black ); 270 p->setPen( black );
271 for ( int t = 0; t < 24; t++ ) { 271 for ( int t = 0; t < 24; t++ ) {
272 int y = t*rowHeight; 272 int y = t*rowHeight;
273 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) { 273 if ( QRect( 1, y, 20, rowHeight ).intersects( ur ) ) {
274 QString s; 274 QString s;
275 if ( ampm ) { 275 if ( ampm ) {
276 if ( t == 0 ) 276 if ( t == 0 )
277 s = QString::number( 12 ); 277 s = QString::number( 12 );
278 else if ( t == 12 ) 278 else if ( t == 12 )
279 s = QString::number(12) + tr( "p" ); 279 s = QString::number(12) + tr( "p" );
280 else if ( t > 12 ) { 280 else if ( t > 12 ) {
281 if ( t - 12 < 10 ) 281 if ( t - 12 < 10 )
282 s = " "; 282 s = " ";
283 else 283 else
284 s = ""; 284 s = "";
285 s += QString::number( t - 12 ) + tr("p"); 285 s += QString::number( t - 12 ) + tr("p");
286 } else { 286 } else {
287 if ( 12 - t < 3 ) 287 if ( 12 - t < 3 )
288 s = ""; 288 s = "";
289 else 289 else
290 s = " "; 290 s = " ";
291 s += QString::number( t ); 291 s += QString::number( t );
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 int avail = width()-qApp->style().scrollBarExtent().width()-1; 316 int avail = visibleWidth();
317 header->setGeometry( 0, 0, avail, header->sizeHint().height() ); 317 header->setGeometry( leftMargin()+frameWidth()+frameRect().left() , frameWidth(),
318 setMargins( 0, header->height(), 0, 0 ); 318 visibleWidth(), header->sizeHint().height() );
319 setMargins( 0, header->sizeHint().height(), 0, 0 );
319 header->resizeSection( 0, hourWidth ); 320 header->resizeSection( 0, hourWidth );
320 int sw = (avail - hourWidth) / 7; 321 int sw = (avail - hourWidth) / 7;
321 for ( int i = 1; i < 7; i++ ) 322 for ( int i = 1; i < 7; i++ )
322 header->resizeSection( i, sw ); 323 header->resizeSection( i, sw );
323 header->resizeSection( 7, avail - hourWidth - sw*6 ); 324 header->resizeSection( 7, avail - hourWidth - sw*6 );
324} 325}
325 326
326void DateBookWeekView::setStartOfWeek( bool bStartOnMonday ) 327void DateBookWeekView::setStartOfWeek( bool bStartOnMonday )
327{ 328{
328 bOnMonday = bStartOnMonday; 329 bOnMonday = bStartOnMonday;
329 initNames(); 330 initNames();
330} 331}
331 332
332//------------------------------------------------------------------- 333//-------------------------------------------------------------------
333 334
334DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB, 335DateBookWeek::DateBookWeek( bool ap, bool startOnMonday, DateBookDB *newDB,
335 QWidget *parent, const char *name ) 336 QWidget *parent, const char *name )
336 : QWidget( parent, name ), 337 : QWidget( parent, name ),
337 db( newDB ), 338 db( newDB ),
338 startTime( 0 ), 339 startTime( 0 ),
339 ampm( ap ), 340 ampm( ap ),
340 bStartOnMonday( startOnMonday ) 341 bStartOnMonday( startOnMonday )
341{ 342{
342 setFocusPolicy(StrongFocus); 343 setFocusPolicy(StrongFocus);
343 QVBoxLayout *vb = new QVBoxLayout( this ); 344 QVBoxLayout *vb = new QVBoxLayout( this );
344 header = new DateBookWeekHeader( bStartOnMonday, this ); 345 header = new DateBookWeekHeader( bStartOnMonday, this );
345 view = new DateBookWeekView( ampm, startOnMonday, this ); 346 view = new DateBookWeekView( ampm, startOnMonday, this );
346 vb->addWidget( header ); 347 vb->addWidget( header );
347 vb->addWidget( view ); 348 vb->addWidget( view );
348 349
349 lblDesc = new QLabel( this, "event label" ); 350 lblDesc = new QLabel( this, "event label" );
350 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box ); 351 lblDesc->setFrameStyle( QFrame::Plain | QFrame::Box );
351 lblDesc->setBackgroundColor( yellow ); 352 lblDesc->setBackgroundColor( yellow );
352 lblDesc->hide(); 353 lblDesc->hide();
353 354
354 tHide = new QTimer( this ); 355 tHide = new QTimer( this );
355 356
356 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) ); 357 connect( view, SIGNAL( showDay( int ) ), this, SLOT( showDay( int ) ) );
357 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) ); 358 connect( view, SIGNAL(signalShowEvent(const EffectiveEvent&)), this, SLOT(slotShowEvent(const EffectiveEvent&)) );
358 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) ); 359 connect( view, SIGNAL(signalHideEvent()), this, SLOT(slotHideEvent()) );
359 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) ); 360 connect( header, SIGNAL( dateChanged( QDate &) ), this, SLOT( dateChanged( QDate &) ) );
360 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) ); 361 connect( tHide, SIGNAL( timeout() ), lblDesc, SLOT( hide() ) );
361 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) ); 362 connect( qApp, SIGNAL(weekChanged(bool)), this, SLOT(slotWeekChanged(bool)) );
362 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool))); 363 connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(slotClockChanged(bool)));
363 setDate(QDate::currentDate()); 364 setDate(QDate::currentDate());
364} 365}
365 366
366void DateBookWeek::keyPressEvent(QKeyEvent *e) 367void DateBookWeek::keyPressEvent(QKeyEvent *e)