-rw-r--r-- | libkcal/alarm.cpp | 24 | ||||
-rw-r--r-- | libkcal/alarm.h | 1 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 14 |
3 files changed, 37 insertions, 2 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 1fc7169..d8f15b5 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp @@ -21,4 +21,5 @@ #include <kdebug.h> +#include <klocale.h> #include "incidence.h" @@ -350,4 +351,27 @@ int Alarm::offset() } +QString Alarm::offsetText() +{ + int min = -offset()/60; + int hours = min /60; + min = min % 60; + int days = hours /24; + hours = hours % 24; + QString message; + qDebug("%d %d %d ", days, hours, min ); + if ( days > 0 ) + message += i18n("%1d").arg( days ); + if ( hours > 0 ) { + if ( !message.isEmpty() ) message += "/"; + message += i18n("%1h").arg( hours ); + } + if ( min > 0 ) { + if ( !message.isEmpty() ) message += "/"; + message += i18n("%1min").arg( min ); + } + if ( message.isEmpty() ) + message = i18n("%1min").arg( 0 ); + return message; +} diff --git a/libkcal/alarm.h b/libkcal/alarm.h index 682b626..ac6ea0d 100644 --- a/libkcal/alarm.h +++ b/libkcal/alarm.h @@ -60,4 +60,5 @@ class Alarm : public CustomProperties Type type() const; int offset(); + QString offsetText(); /** Set the alarm to be a display alarm. @param text text to display when the alarm is triggered. diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index e506a96..d67ad52 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -132,6 +132,5 @@ void KIncidenceFormatter::setEvent(Event *event) Alarm *alarm =event->alarms().first() ; QDateTime t = alarm->time(); - int min = t.secsTo( event->dtStart() )/60; - QString s =i18n("(%1 min before)").arg( min ); + 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 )); @@ -139,4 +138,6 @@ void KIncidenceFormatter::setEvent(Event *event) } + + addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); // mText.append(event->secrecyStr()+"<br>"); @@ -225,4 +226,13 @@ void KIncidenceFormatter::setTodo(Todo *event ) .arg(QString::number(event->priority()))); + if (event->isAlarmEnabled()) { + Alarm *alarm =event->alarms().first() ; + QDateTime t = alarm->time(); + 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); |