-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index 874cf24..8241655 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp @@ -149,110 +149,108 @@ void DateBookWeekView::showEvents( QValueList<EffectiveEvent> &ev ) void DateBookWeekView::moveToHour( int h ) { int offset = h*rowHeight; setContentsPos( 0, offset ); } void DateBookWeekView::keyPressEvent( QKeyEvent *e ) { e->ignore(); } void DateBookWeekView::slotChangeClock( bool c ) { ampm = c; viewport()->update(); } static inline int db_round30min( int m ) { if ( m < 15 ) m = 0; else if ( m < 45 ) m = 1; else m = 2; return m; } void DateBookWeekView::alterDay( int day ) { if ( !bOnMonday ) { day--; } emit showDay( day ); } void DateBookWeekView::positionItem( DateBookWeekItem *i ) { const int Width = 8; const EffectiveEvent ev = i->event(); // 30 minute intervals int y = ev.start().hour() * 2; y += db_round30min( ev.start().minute() ); int y2 = ev.end().hour() * 2; y2 += db_round30min( ev.end().minute() ); - if ( y > 47 ) - y = 47; - if ( y2 > 48 ) - y2 = 48; - y = y * rowHeight / 2; - y2 = y2 * rowHeight / 2; + if ( y > 47 ) y = 47; + if ( y2 > 48 ) y2 = 48; + y = (y * rowHeight) / 2; + y2 = (y2 * rowHeight) / 2; int h; if ( ev.event().type() == Event::AllDay ) { - h = 48 * rowHeight / 2; - y = 0; - } else { - h=y2-y; - if ( h < 1 ) h = 1; + h = (48 * rowHeight) / 2; + y = 0; + } else { + h=y2-y; + if ( h < (1*rowHeight)/2 ) h = (1*rowHeight)/2; } int dow = ev.date().dayOfWeek(); if ( !bOnMonday ) { if ( dow == 7 ) dow = 1; else dow++; } int x = header->sectionPos( dow ) - 1; int xlim = header->sectionPos( dow ) + header->sectionSize( dow ); DateBookWeekItem *isect = 0; do { i->setGeometry( x, y, Width, h ); isect = intersects( i ); x += Width - 1; } while ( isect && x < xlim ); } DateBookWeekItem *DateBookWeekView::intersects( const DateBookWeekItem *item ) { QRect geom = item->geometry(); // We allow the edges to overlap geom.moveBy( 1, 1 ); geom.setSize( geom.size()-QSize(2,2) ); QListIterator<DateBookWeekItem> it(items); for ( ; it.current(); ++it ) { DateBookWeekItem *i = it.current(); if ( i != item ) { if ( i->geometry().intersects( geom ) ) { return i; } } } return 0; } void DateBookWeekView::contentsMousePressEvent( QMouseEvent *e ) { QListIterator<DateBookWeekItem> it(items); for ( ; it.current(); ++it ) { DateBookWeekItem *i = it.current(); if ( i->geometry().contains( e->pos() ) ) { showingEvent = true; emit signalShowEvent( i->event() ); |