summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-04-02 14:07:31 (UTC)
committer zautrix <zautrix>2005-04-02 14:07:31 (UTC)
commitb0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd (patch) (side-by-side diff)
tree942bcf89b35cf165e9147c1e4a5efa817c48007f /libkcal
parent997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (diff)
downloadkdepimpi-b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd.zip
kdepimpi-b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd.tar.gz
kdepimpi-b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd.tar.bz2
fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/alarm.cpp24
-rw-r--r--libkcal/alarm.h1
-rw-r--r--libkcal/kincidenceformatter.cpp14
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
@@ -20,6 +20,7 @@
*/
#include <kdebug.h>
+#include <klocale.h>
#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("<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);
@@ -224,6 +225,15 @@ void KIncidenceFormatter::setTodo(Todo *event )
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 ) {