summaryrefslogtreecommitdiffstats
path: root/libkcal/alarm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libkcal/alarm.cpp')
-rw-r--r--libkcal/alarm.cpp60
1 files changed, 44 insertions, 16 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index b5b9b515a..8bc40f001 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -47,6 +47,30 @@ Alarm::~Alarm()
{
}
+Alarm *Alarm::clone()
+{
+ return new Alarm( *this );
+}
+
+Alarm &Alarm::operator=( const Alarm &a )
+{
+ mParent = a.mParent;
+ mType = a.mType;
+ mDescription = a.mDescription;
+ mFile = a.mFile;
+ mMailAttachFiles = a.mMailAttachFiles;
+ mMailAddresses = a.mMailAddresses;
+ mMailSubject = a.mMailSubject;
+ mAlarmSnoozeTime = a.mAlarmSnoozeTime;
+ mAlarmRepeatCount = a.mAlarmRepeatCount;
+ mAlarmTime = a.mAlarmTime;
+ mOffset = a.mOffset;
+ mEndOffset = a.mEndOffset;
+ mHasTime = a.mHasTime;
+ mAlarmEnabled = a.mAlarmEnabled;
+ return *this;
+}
+
bool Alarm::operator==( const Alarm& rhs ) const
{
if ( mType != rhs.mType ||
@@ -304,19 +328,22 @@ void Alarm::setTime(const TQDateTime &alarmTime)
TQDateTime Alarm::time() const
{
- if ( hasTime() )
+ if ( hasTime() ) {
return mAlarmTime;
- else if ( mParent )
- {
- if (mParent->type()=="Todo") {
- Todo *t = static_cast<Todo*>(mParent);
- return mOffset.end( t->dtDue() );
- } else if (mEndOffset) {
- return mOffset.end( mParent->dtEnd() );
+ } else if ( mParent ) {
+ if ( mEndOffset ) {
+ if ( mParent->type() == "Todo" ) {
+ Todo *t = static_cast<Todo*>( mParent );
+ return mOffset.end( t->dtDue() );
+ } else {
+ return mOffset.end( mParent->dtEnd() );
+ }
} else {
return mOffset.end( mParent->dtStart() );
}
- } else return TQDateTime();
+ } else {
+ return TQDateTime();
+ }
}
bool Alarm::hasTime() const
@@ -324,15 +351,15 @@ bool Alarm::hasTime() const
return mHasTime;
}
-void Alarm::setSnoozeTime(int alarmSnoozeTime)
+void Alarm::setSnoozeTime(const Duration &alarmSnoozeTime)
{
- if (alarmSnoozeTime > 0) {
+ if (alarmSnoozeTime.value() > 0) {
mAlarmSnoozeTime = alarmSnoozeTime;
if ( mParent ) mParent->updated();
}
}
-int Alarm::snoozeTime() const
+Duration Alarm::snoozeTime() const
{
return mAlarmSnoozeTime;
}
@@ -348,9 +375,10 @@ int Alarm::repeatCount() const
return mAlarmRepeatCount;
}
-int Alarm::duration() const
+Duration Alarm::duration() const
{
- return mAlarmRepeatCount * mAlarmSnoozeTime * 60;
+ return Duration( mAlarmSnoozeTime.value() * mAlarmRepeatCount,
+ mAlarmSnoozeTime.type() );
}
TQDateTime Alarm::nextRepetition(const TQDateTime& preTime) const
@@ -422,7 +450,7 @@ void Alarm::setStartOffset( const Duration &offset )
Duration Alarm::startOffset() const
{
- return (mHasTime || mEndOffset) ? 0 : mOffset;
+ return (mHasTime || mEndOffset) ? Duration( 0 ) : mOffset;
}
bool Alarm::hasStartOffset() const
@@ -445,7 +473,7 @@ void Alarm::setEndOffset( const Duration &offset )
Duration Alarm::endOffset() const
{
- return (mHasTime || !mEndOffset) ? 0 : mOffset;
+ return (mHasTime || !mEndOffset) ? Duration( 0 ) : mOffset;
}
void Alarm::setParent( Incidence *parent )