From b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 02 Apr 2005 14:07:31 +0000 Subject: fixes --- (limited to 'libkcal') diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 1fc7169..d8f15b5 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp @@ -20,6 +20,7 @@ */ #include +#include #include "incidence.h" #include "todo.h" @@ -349,6 +350,29 @@ 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; +} QDateTime Alarm::time() const diff --git a/libkcal/alarm.h b/libkcal/alarm.h index 682b626..ac6ea0d 100644 --- a/libkcal/alarm.h +++ b/libkcal/alarm.h @@ -59,6 +59,7 @@ class Alarm : public CustomProperties /** 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. */ diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index e506a96..d67ad52 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp @@ -131,13 +131,14 @@ 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("Alarm on: ") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); //addTag("p",s); } + + addTag("p",i18n("Access: ") +event->secrecyStr() ); // mText.append(event->secrecyStr()+"
"); formatCategories(event); @@ -224,6 +225,15 @@ void KIncidenceFormatter::setTodo(Todo *event ) mText.append(i18n("

Priority: %2

") .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("Alarm on: ") + s +" "); + addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); + //addTag("p",s); + } + addTag("p",i18n("Access: ") +event->secrecyStr() ); formatCategories(event); if ( mDetails ) { -- cgit v0.9.0.2