-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 @@ -15,16 +15,17 @@ You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <kdebug.h> +#include <klocale.h> #include "incidence.h" #include "todo.h" #include "alarm.h" using namespace KCal; #include <qwidget.h> @@ -344,16 +345,39 @@ int Alarm::offset() return mParent->dtStart().secsTo( mAlarmTime ) ; } else { return mOffset.asSeconds(); } } +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; +} QDateTime Alarm::time() const { if ( hasTime() ) return mAlarmTime; else { diff --git a/libkcal/alarm.h b/libkcal/alarm.h index 682b626..ac6ea0d 100644 --- a/libkcal/alarm.h +++ b/libkcal/alarm.h @@ -54,16 +54,17 @@ class Alarm : public CustomProperties If the specified type is different from the current type of the alarm, the alarm's type-specific properties are initialised to null. @param type type of alarm. */ void setType(Type type); /** Return the type of the alarm */ 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. */ void setDisplayAlarm(const QString &text); /** Set the text to be displayed when the alarm is triggered. Ignored if the alarm is not a display alarm. */ void setText(const QString &text); diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index e506a96..d67ad52 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -126,23 +126,24 @@ void KIncidenceFormatter::setEvent(Event *event) } } } if (event->isAlarmEnabled()) { 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 )); //addTag("p",s); } + + addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); // mText.append(event->secrecyStr()+"<br>"); formatCategories(event); if ( mDetails ) { if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",deTag(event->description())); } @@ -219,16 +220,25 @@ void KIncidenceFormatter::setTodo(Todo *event ) if (event->hasDueDate()) { mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); } 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(); + 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); if ( mDetails ) { if (!event->description().isEmpty()) { addTag("p",i18n("<b>Details: </b>")); addTag("p",deTag(event->description())); } } |