-rw-r--r-- | core/pim/datebook/datebookweek.cpp | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/core/pim/datebook/datebookweek.cpp b/core/pim/datebook/datebookweek.cpp index ddd41af..e30c776 100644 --- a/core/pim/datebook/datebookweek.cpp +++ b/core/pim/datebook/datebookweek.cpp @@ -169,62 +169,65 @@ static inline int db_round30min( int m ) 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; int h; if ( ev.event().type() == Event::AllDay ) { - h = 48; + h = 48 * rowHeight / 2; y = 0; } else { - h = ( ev.end().hour() - ev.start().hour() ) * 2; - h += db_round30min( ev.end().minute() - ev.start().minute() ); + h=y2-y; if ( h < 1 ) h = 1; } - h = h * 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 ); @@ -447,65 +450,57 @@ QDate DateBookWeek::date() const else d = d.addDays( 7 + dow ); } return d; } void DateBookWeek::getEvents() { QDate startWeek = weekDate(); QDate endWeek = startWeek.addDays( 6 ); QValueList<EffectiveEvent> eventList = db->getEffectiveEvents(startWeek, endWeek); view->showEvents( eventList ); view->moveToHour( startTime ); } void DateBookWeek::generateAllDayTooltext( QString& text ) { text += "<b>" + tr("This is an all day event.") + "</b><br>"; } void DateBookWeek::generateNormalTooltext( QString& str, const EffectiveEvent &ev ) { str += "<b>" + QObject::tr("Start") + "</b>: "; - - if ( ev.startDate() != ev.date() ) { - // multi-day event. Show start date - str += TimeString::longDateString( ev.startDate() ); - } else { - // Show start time. - str += TimeString::timeString(ev.start(), ampm, FALSE ); + str += TimeString::timeString( ev.event().start().time(), ampm, FALSE ); + if( ev.startDate()!=ev.endDate() ) { + str += " <i>" + TimeString::longDateString( ev.startDate() )+"</i>"; } - - - str += "<br><b>" + QObject::tr("End") + "</b>: "; - if ( ev.endDate() != ev.date() ) { - // multi-day event. Show end date - str += TimeString::longDateString( ev.endDate() ); - } else { - // Show end time. - str += TimeString::timeString( ev.end(), ampm, FALSE ); + str += "<br>"; + str += "<b>" + QObject::tr("End") + "</b>: "; + str += TimeString::timeString( ev.event().end().time(), ampm, FALSE ); + if( ev.startDate()!=ev.endDate() ) { + str += " <i>" + TimeString::longDateString( ev.endDate() ) + "</i>"; } } void DateBookWeek::slotShowEvent( const EffectiveEvent &ev ) { if ( tHide->isActive() ) tHide->stop(); // why would someone use "<"? Oh well, fix it up... // I wonder what other things may be messed up... QString strDesc = ev.description(); int where = strDesc.find( "<" ); while ( where != -1 ) { strDesc.remove( where, 1 ); strDesc.insert( where, "<" ); where = strDesc.find( "<", where ); } QString strCat; // ### FIX later... // QString strCat = ev.category(); // where = strCat.find( "<" ); // while ( where != -1 ) { // strCat.remove( where, 1 ); |