summaryrefslogtreecommitdiffabout
path: root/libkcal/alarm.cpp
Side-by-side diff
Diffstat (limited to 'libkcal/alarm.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/alarm.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 07812c2..29e6205 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -291,24 +291,40 @@ void Alarm::setText(const QString &text)
QString Alarm::text() const
{
return (mType == Display) ? mDescription : QString::null;
}
void Alarm::setTime(const QDateTime &alarmTime)
{
mAlarmTime = alarmTime;
mHasTime = true;
mParent->updated();
}
+int Alarm::offset()
+{
+ if ( hasTime() ) {
+ if (mParent->type()=="Todo") {
+ Todo *t = static_cast<Todo*>(mParent);
+ return t->dtDue().secsTo( mAlarmTime ) ;
+ } else
+ return mParent->dtStart().secsTo( mAlarmTime ) ;
+ }
+ else
+ {
+ return mOffset.asSeconds();
+ }
+
+}
+
QDateTime Alarm::time() const
{
if ( hasTime() )
return mAlarmTime;
else
{
if (mParent->type()=="Todo") {
Todo *t = static_cast<Todo*>(mParent);
return mOffset.end( t->dtDue() );
} else if (mEndOffset) {
return mOffset.end( mParent->dtEnd() );