author | zautrix <zautrix> | 2007-06-06 13:14:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2007-06-06 13:14:20 (UTC) |
commit | 623b4d4abe87789dacd4c14de88a63b44ca352b7 (patch) (side-by-side diff) | |
tree | a6bcc1b9359bf904e08b508576c2d2e958cde55c /libkcal | |
parent | d5c53970b9e12bfe774d1fecd603080aded24e09 (diff) | |
download | kdepimpi-623b4d4abe87789dacd4c14de88a63b44ca352b7.zip kdepimpi-623b4d4abe87789dacd4c14de88a63b44ca352b7.tar.gz kdepimpi-623b4d4abe87789dacd4c14de88a63b44ca352b7.tar.bz2 |
display of next alarm of recurring events in event viewer fixed
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 4dfe16a..733b897 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -90,96 +90,104 @@ void KIncidenceFormatter::setEvent(Event *event) } } else { if (event->isMultiDay()) { mText.append(i18n("<p><b>From:</b> %1</p> ") .arg(event->dtStartStr( shortDate))); mText.append(i18n("<p><b>To:</b> %1</p>") .arg(event->dtEndStr(shortDate))); } else { mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") .arg(event->dtStartTimeStr()) .arg(event->dtEndTimeStr())); mText.append(i18n("<p><b>On:</b> %1</p> ") .arg(event->dtStartDateStr( shortDate ))); } } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(deTag(event->location())+"<br>"); } if (event->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); bool ok; QDate start = QDate::currentDate(); QDateTime next; next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); if ( ok ) { addTag("p",i18n("<b>Next recurrence is on:</b>") ); addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); } else { bool last; QDate nextd; nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); if ( last ) { addTag("p",i18n("<b>Last recurrence was on:</b>") ); addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); } } } if (event->isAlarmEnabled()) { Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); + if (event->doesRecur()) { + bool ok = false; + int offset = 0; + QDateTime next = event->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; + if ( ok ) { + t = next; + } + } QString s =i18n("( %1 before )").arg( alarm->offsetText() ); addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p",s); } addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); // mText.append(event->secrecyStr()+"<br>"); formatCategories(event); formatAttendees(event); if ( mCreated ) { #ifdef DESKTOP_VERSION addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); #else addTag("p",i18n("<b>Created: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); #endif } if ( mModified ) { #ifdef DESKTOP_VERSION addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); #else addTag("p",i18n("<b>Last modified: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); #endif } if ( mDetails ) { if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",deTag(event->description())); } } } void KIncidenceFormatter::setTodo(Todo *event ) { int mode = 0; mCurrentIncidence = event; bool shortDate = true; if (mode == 0 ) { addTag("h3",deTag(event->summary())); @@ -199,96 +207,104 @@ void KIncidenceFormatter::setTodo(Todo *event ) } formatReadOnly(event); addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); if ( mColorMode ) mText += "</font>"; } if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { mText +="<font color=\"#B00000\">"; addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); mText += "</font>"; } else { mText.append(i18n("<p><i>%1 % completed</i></p>") .arg(event->percentComplete())); } if (event->cancelled ()) { mText +="<font color=\"#B00000\">"; addTag("i",i18n("This todo has been cancelled!")); mText.append("<br>"); mText += "</font>"; } if (event->doesRecur()) { QString recurText = event->recurrence()->recurrenceText(); addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); } if (event->hasStartDate()) { mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); } if (event->hasDueDate()) { mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); } if (!event->location().isEmpty()) { addTag("b",i18n("Location: ")); mText.append(deTag(event->location())+"<br>"); } mText.append(i18n("<p><b>Priority:</b> %2</p>") .arg(QString::number(event->priority()))); if (event->isAlarmEnabled()) { Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); + if (event->doesRecur()) { + bool ok = false; + int offset = 0; + QDateTime next = event->getNextAlarmDateTime(& ok, &offset, QDateTime::currentDateTime() ) ; + if ( ok ) { + t = next; + } + } QString s =i18n("( %1 before )").arg( alarm->offsetText() ); addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p",s); } addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); formatCategories(event); formatAttendees(event); if ( mCreated ) { #ifdef DESKTOP_VERSION addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); #else addTag("p",i18n("<b>Created: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); #endif } if ( mModified ) { #ifdef DESKTOP_VERSION addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); #else addTag("p",i18n("<b>Last modified: ") +" </b>"); addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); #endif } if ( mDetails ) { if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",deTag(event->description())); } } } void KIncidenceFormatter::setJournal(Journal* ) { } void KIncidenceFormatter::formatCategories(Incidence *event) { if (!event->categoriesStr().isEmpty()) { addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); //mText.append(event->categoriesStr()); } } |