-rw-r--r-- | libkcal/alarm.cpp | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 29e6205..1fc7169 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -1,423 +1,457 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <kdebug.h> | 22 | #include <kdebug.h> |
23 | 23 | ||
24 | #include "incidence.h" | 24 | #include "incidence.h" |
25 | #include "todo.h" | 25 | #include "todo.h" |
26 | 26 | ||
27 | #include "alarm.h" | 27 | #include "alarm.h" |
28 | 28 | ||
29 | using namespace KCal; | 29 | using namespace KCal; |
30 | #include <qwidget.h> | 30 | #include <qwidget.h> |
31 | Alarm::Alarm(Incidence *parent) | 31 | Alarm::Alarm(Incidence *parent) |
32 | : mParent(parent), | 32 | : mParent(parent), |
33 | mType(Audio), | 33 | mType(Audio), |
34 | mDescription(""), // to make operator==() not fail | 34 | mDescription(""), // to make operator==() not fail |
35 | mFile(""), // to make operator==() not fail | 35 | mFile(""), // to make operator==() not fail |
36 | mMailSubject(""), // to make operator==() not fail | 36 | mMailSubject(""), // to make operator==() not fail |
37 | mAlarmSnoozeTime(5), | 37 | mAlarmSnoozeTime(5), |
38 | mAlarmRepeatCount(0), | 38 | mAlarmRepeatCount(0), |
39 | mEndOffset(false), | 39 | mEndOffset(false), |
40 | mHasTime(false), | 40 | mHasTime(false), |
41 | mAlarmEnabled(false) | 41 | mAlarmEnabled(false) |
42 | { | 42 | { |
43 | 43 | ||
44 | } | 44 | } |
45 | 45 | ||
46 | Alarm::~Alarm() | 46 | Alarm::~Alarm() |
47 | { | 47 | { |
48 | } | 48 | } |
49 | 49 | ||
50 | bool Alarm::operator==( const Alarm& rhs ) const | 50 | bool Alarm::operator==( const Alarm& rhs ) const |
51 | { | 51 | { |
52 | |||
52 | if ( mType != rhs.mType || | 53 | if ( mType != rhs.mType || |
53 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || | 54 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || |
54 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || | 55 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || |
55 | mAlarmEnabled != rhs.mAlarmEnabled || | 56 | mAlarmEnabled != rhs.mAlarmEnabled || |
56 | mHasTime != rhs.mHasTime) | 57 | mHasTime != rhs.mHasTime) |
57 | return false; | 58 | return false; |
58 | 59 | ||
60 | #if 0 | ||
61 | if ( mType != rhs.mType ) { | ||
62 | |||
63 | qDebug("aaa1 "); | ||
64 | return false; | ||
65 | } | ||
66 | |||
67 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { | ||
68 | |||
69 | qDebug("aaa2 "); | ||
70 | return false; | ||
71 | } | ||
72 | |||
73 | |||
74 | if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { | ||
75 | |||
76 | qDebug("aaa3 "); | ||
77 | return false; | ||
78 | } | ||
79 | |||
80 | if ( mAlarmEnabled != rhs.mAlarmEnabled ) { | ||
81 | |||
82 | qDebug("aaa4 "); | ||
83 | return false; | ||
84 | } | ||
85 | |||
86 | if ( mHasTime != rhs.mHasTime ) { | ||
87 | |||
88 | qDebug("aaa5 "); | ||
89 | return false; | ||
90 | } | ||
91 | #endif | ||
92 | |||
93 | |||
59 | if (mHasTime) { | 94 | if (mHasTime) { |
60 | if (mAlarmTime != rhs.mAlarmTime) | 95 | if (mAlarmTime != rhs.mAlarmTime) |
61 | return false; | 96 | return false; |
62 | } else { | 97 | } else { |
63 | if (mOffset != rhs.mOffset || | 98 | if (mOffset != rhs.mOffset || |
64 | mEndOffset != rhs.mEndOffset) | 99 | mEndOffset != rhs.mEndOffset) |
65 | return false; | 100 | return false; |
66 | } | 101 | } |
67 | |||
68 | switch (mType) { | 102 | switch (mType) { |
69 | case Display: | 103 | case Display: |
70 | return mDescription == rhs.mDescription; | 104 | return mDescription == rhs.mDescription; |
71 | 105 | ||
72 | case Email: | 106 | case Email: |
73 | return mDescription == rhs.mDescription && | 107 | return mDescription == rhs.mDescription && |
74 | mMailAttachFiles == rhs.mMailAttachFiles && | 108 | mMailAttachFiles == rhs.mMailAttachFiles && |
75 | mMailAddresses == rhs.mMailAddresses && | 109 | mMailAddresses == rhs.mMailAddresses && |
76 | mMailSubject == rhs.mMailSubject; | 110 | mMailSubject == rhs.mMailSubject; |
77 | 111 | ||
78 | case Procedure: | 112 | case Procedure: |
79 | return mFile == rhs.mFile && | 113 | return mFile == rhs.mFile && |
80 | mDescription == rhs.mDescription; | 114 | mDescription == rhs.mDescription; |
81 | 115 | ||
82 | case Audio: | 116 | case Audio: |
83 | return mFile == rhs.mFile; | 117 | return mFile == rhs.mFile; |
84 | 118 | ||
85 | case Invalid: | 119 | case Invalid: |
86 | break; | 120 | break; |
87 | } | 121 | } |
88 | return false; | 122 | return false; |
89 | } | 123 | } |
90 | 124 | ||
91 | void Alarm::setType(Alarm::Type type) | 125 | void Alarm::setType(Alarm::Type type) |
92 | { | 126 | { |
93 | if (type == mType) | 127 | if (type == mType) |
94 | return; | 128 | return; |
95 | 129 | ||
96 | switch (type) { | 130 | switch (type) { |
97 | case Display: | 131 | case Display: |
98 | mDescription = ""; | 132 | mDescription = ""; |
99 | break; | 133 | break; |
100 | case Procedure: | 134 | case Procedure: |
101 | mFile = mDescription = ""; | 135 | mFile = mDescription = ""; |
102 | break; | 136 | break; |
103 | case Audio: | 137 | case Audio: |
104 | mFile = ""; | 138 | mFile = ""; |
105 | break; | 139 | break; |
106 | case Email: | 140 | case Email: |
107 | mMailSubject = mDescription = ""; | 141 | mMailSubject = mDescription = ""; |
108 | mMailAddresses.clear(); | 142 | mMailAddresses.clear(); |
109 | mMailAttachFiles.clear(); | 143 | mMailAttachFiles.clear(); |
110 | break; | 144 | break; |
111 | case Invalid: | 145 | case Invalid: |
112 | break; | 146 | break; |
113 | default: | 147 | default: |
114 | return; | 148 | return; |
115 | } | 149 | } |
116 | mType = type; | 150 | mType = type; |
117 | mParent->updated(); | 151 | mParent->updated(); |
118 | } | 152 | } |
119 | 153 | ||
120 | Alarm::Type Alarm::type() const | 154 | Alarm::Type Alarm::type() const |
121 | { | 155 | { |
122 | return mType; | 156 | return mType; |
123 | } | 157 | } |
124 | 158 | ||
125 | void Alarm::setAudioAlarm(const QString &audioFile) | 159 | void Alarm::setAudioAlarm(const QString &audioFile) |
126 | { | 160 | { |
127 | mType = Audio; | 161 | mType = Audio; |
128 | mFile = audioFile; | 162 | mFile = audioFile; |
129 | mParent->updated(); | 163 | mParent->updated(); |
130 | } | 164 | } |
131 | 165 | ||
132 | void Alarm::setAudioFile(const QString &audioFile) | 166 | void Alarm::setAudioFile(const QString &audioFile) |
133 | { | 167 | { |
134 | if (mType == Audio) { | 168 | if (mType == Audio) { |
135 | mFile = audioFile; | 169 | mFile = audioFile; |
136 | mParent->updated(); | 170 | mParent->updated(); |
137 | } | 171 | } |
138 | } | 172 | } |
139 | 173 | ||
140 | QString Alarm::audioFile() const | 174 | QString Alarm::audioFile() const |
141 | { | 175 | { |
142 | return (mType == Audio) ? mFile : QString::null; | 176 | return (mType == Audio) ? mFile : QString::null; |
143 | } | 177 | } |
144 | 178 | ||
145 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) | 179 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) |
146 | { | 180 | { |
147 | mType = Procedure; | 181 | mType = Procedure; |
148 | mFile = programFile; | 182 | mFile = programFile; |
149 | mDescription = arguments; | 183 | mDescription = arguments; |
150 | mParent->updated(); | 184 | mParent->updated(); |
151 | } | 185 | } |
152 | 186 | ||
153 | void Alarm::setProgramFile(const QString &programFile) | 187 | void Alarm::setProgramFile(const QString &programFile) |
154 | { | 188 | { |
155 | if (mType == Procedure) { | 189 | if (mType == Procedure) { |
156 | mFile = programFile; | 190 | mFile = programFile; |
157 | mParent->updated(); | 191 | mParent->updated(); |
158 | } | 192 | } |
159 | } | 193 | } |
160 | 194 | ||
161 | QString Alarm::programFile() const | 195 | QString Alarm::programFile() const |
162 | { | 196 | { |
163 | return (mType == Procedure) ? mFile : QString::null; | 197 | return (mType == Procedure) ? mFile : QString::null; |
164 | } | 198 | } |
165 | 199 | ||
166 | void Alarm::setProgramArguments(const QString &arguments) | 200 | void Alarm::setProgramArguments(const QString &arguments) |
167 | { | 201 | { |
168 | if (mType == Procedure) { | 202 | if (mType == Procedure) { |
169 | mDescription = arguments; | 203 | mDescription = arguments; |
170 | mParent->updated(); | 204 | mParent->updated(); |
171 | } | 205 | } |
172 | } | 206 | } |
173 | 207 | ||
174 | QString Alarm::programArguments() const | 208 | QString Alarm::programArguments() const |
175 | { | 209 | { |
176 | return (mType == Procedure) ? mDescription : QString::null; | 210 | return (mType == Procedure) ? mDescription : QString::null; |
177 | } | 211 | } |
178 | 212 | ||
179 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, | 213 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, |
180 | const QValueList<Person> &addressees, const QStringList &attachments) | 214 | const QValueList<Person> &addressees, const QStringList &attachments) |
181 | { | 215 | { |
182 | mType = Email; | 216 | mType = Email; |
183 | mMailSubject = subject; | 217 | mMailSubject = subject; |
184 | mDescription = text; | 218 | mDescription = text; |
185 | mMailAddresses = addressees; | 219 | mMailAddresses = addressees; |
186 | mMailAttachFiles = attachments; | 220 | mMailAttachFiles = attachments; |
187 | mParent->updated(); | 221 | mParent->updated(); |
188 | } | 222 | } |
189 | 223 | ||
190 | void Alarm::setMailAddress(const Person &mailAddress) | 224 | void Alarm::setMailAddress(const Person &mailAddress) |
191 | { | 225 | { |
192 | if (mType == Email) { | 226 | if (mType == Email) { |
193 | mMailAddresses.clear(); | 227 | mMailAddresses.clear(); |
194 | mMailAddresses += mailAddress; | 228 | mMailAddresses += mailAddress; |
195 | mParent->updated(); | 229 | mParent->updated(); |
196 | } | 230 | } |
197 | } | 231 | } |
198 | 232 | ||
199 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) | 233 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) |
200 | { | 234 | { |
201 | if (mType == Email) { | 235 | if (mType == Email) { |
202 | mMailAddresses = mailAddresses; | 236 | mMailAddresses = mailAddresses; |
203 | mParent->updated(); | 237 | mParent->updated(); |
204 | } | 238 | } |
205 | } | 239 | } |
206 | 240 | ||
207 | void Alarm::addMailAddress(const Person &mailAddress) | 241 | void Alarm::addMailAddress(const Person &mailAddress) |
208 | { | 242 | { |
209 | if (mType == Email) { | 243 | if (mType == Email) { |
210 | mMailAddresses += mailAddress; | 244 | mMailAddresses += mailAddress; |
211 | mParent->updated(); | 245 | mParent->updated(); |
212 | } | 246 | } |
213 | } | 247 | } |
214 | 248 | ||
215 | QValueList<Person> Alarm::mailAddresses() const | 249 | QValueList<Person> Alarm::mailAddresses() const |
216 | { | 250 | { |
217 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); | 251 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); |
218 | } | 252 | } |
219 | 253 | ||
220 | void Alarm::setMailSubject(const QString &mailAlarmSubject) | 254 | void Alarm::setMailSubject(const QString &mailAlarmSubject) |
221 | { | 255 | { |
222 | if (mType == Email) { | 256 | if (mType == Email) { |
223 | mMailSubject = mailAlarmSubject; | 257 | mMailSubject = mailAlarmSubject; |
224 | mParent->updated(); | 258 | mParent->updated(); |
225 | } | 259 | } |
226 | } | 260 | } |
227 | 261 | ||
228 | QString Alarm::mailSubject() const | 262 | QString Alarm::mailSubject() const |
229 | { | 263 | { |
230 | return (mType == Email) ? mMailSubject : QString::null; | 264 | return (mType == Email) ? mMailSubject : QString::null; |
231 | } | 265 | } |
232 | 266 | ||
233 | void Alarm::setMailAttachment(const QString &mailAttachFile) | 267 | void Alarm::setMailAttachment(const QString &mailAttachFile) |
234 | { | 268 | { |
235 | if (mType == Email) { | 269 | if (mType == Email) { |
236 | mMailAttachFiles.clear(); | 270 | mMailAttachFiles.clear(); |
237 | mMailAttachFiles += mailAttachFile; | 271 | mMailAttachFiles += mailAttachFile; |
238 | mParent->updated(); | 272 | mParent->updated(); |
239 | } | 273 | } |
240 | } | 274 | } |
241 | 275 | ||
242 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) | 276 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) |
243 | { | 277 | { |
244 | if (mType == Email) { | 278 | if (mType == Email) { |
245 | mMailAttachFiles = mailAttachFiles; | 279 | mMailAttachFiles = mailAttachFiles; |
246 | mParent->updated(); | 280 | mParent->updated(); |
247 | } | 281 | } |
248 | } | 282 | } |
249 | 283 | ||
250 | void Alarm::addMailAttachment(const QString &mailAttachFile) | 284 | void Alarm::addMailAttachment(const QString &mailAttachFile) |
251 | { | 285 | { |
252 | if (mType == Email) { | 286 | if (mType == Email) { |
253 | mMailAttachFiles += mailAttachFile; | 287 | mMailAttachFiles += mailAttachFile; |
254 | mParent->updated(); | 288 | mParent->updated(); |
255 | } | 289 | } |
256 | } | 290 | } |
257 | 291 | ||
258 | QStringList Alarm::mailAttachments() const | 292 | QStringList Alarm::mailAttachments() const |
259 | { | 293 | { |
260 | return (mType == Email) ? mMailAttachFiles : QStringList(); | 294 | return (mType == Email) ? mMailAttachFiles : QStringList(); |
261 | } | 295 | } |
262 | 296 | ||
263 | void Alarm::setMailText(const QString &text) | 297 | void Alarm::setMailText(const QString &text) |
264 | { | 298 | { |
265 | if (mType == Email) { | 299 | if (mType == Email) { |
266 | mDescription = text; | 300 | mDescription = text; |
267 | mParent->updated(); | 301 | mParent->updated(); |
268 | } | 302 | } |
269 | } | 303 | } |
270 | 304 | ||
271 | QString Alarm::mailText() const | 305 | QString Alarm::mailText() const |
272 | { | 306 | { |
273 | return (mType == Email) ? mDescription : QString::null; | 307 | return (mType == Email) ? mDescription : QString::null; |
274 | } | 308 | } |
275 | 309 | ||
276 | void Alarm::setDisplayAlarm(const QString &text) | 310 | void Alarm::setDisplayAlarm(const QString &text) |
277 | { | 311 | { |
278 | mType = Display; | 312 | mType = Display; |
279 | mDescription = text; | 313 | mDescription = text; |
280 | mParent->updated(); | 314 | mParent->updated(); |
281 | } | 315 | } |
282 | 316 | ||
283 | void Alarm::setText(const QString &text) | 317 | void Alarm::setText(const QString &text) |
284 | { | 318 | { |
285 | if (mType == Display) { | 319 | if (mType == Display) { |
286 | mDescription = text; | 320 | mDescription = text; |
287 | mParent->updated(); | 321 | mParent->updated(); |
288 | } | 322 | } |
289 | } | 323 | } |
290 | 324 | ||
291 | QString Alarm::text() const | 325 | QString Alarm::text() const |
292 | { | 326 | { |
293 | return (mType == Display) ? mDescription : QString::null; | 327 | return (mType == Display) ? mDescription : QString::null; |
294 | } | 328 | } |
295 | 329 | ||
296 | void Alarm::setTime(const QDateTime &alarmTime) | 330 | void Alarm::setTime(const QDateTime &alarmTime) |
297 | { | 331 | { |
298 | mAlarmTime = alarmTime; | 332 | mAlarmTime = alarmTime; |
299 | mHasTime = true; | 333 | mHasTime = true; |
300 | 334 | ||
301 | mParent->updated(); | 335 | mParent->updated(); |
302 | } | 336 | } |
303 | int Alarm::offset() | 337 | int Alarm::offset() |
304 | { | 338 | { |
305 | if ( hasTime() ) { | 339 | if ( hasTime() ) { |
306 | if (mParent->type()=="Todo") { | 340 | if (mParent->type()=="Todo") { |
307 | Todo *t = static_cast<Todo*>(mParent); | 341 | Todo *t = static_cast<Todo*>(mParent); |
308 | return t->dtDue().secsTo( mAlarmTime ) ; | 342 | return t->dtDue().secsTo( mAlarmTime ) ; |
309 | } else | 343 | } else |
310 | return mParent->dtStart().secsTo( mAlarmTime ) ; | 344 | return mParent->dtStart().secsTo( mAlarmTime ) ; |
311 | } | 345 | } |
312 | else | 346 | else |
313 | { | 347 | { |
314 | return mOffset.asSeconds(); | 348 | return mOffset.asSeconds(); |
315 | } | 349 | } |
316 | 350 | ||
317 | } | 351 | } |
318 | 352 | ||
319 | 353 | ||
320 | QDateTime Alarm::time() const | 354 | QDateTime Alarm::time() const |
321 | { | 355 | { |
322 | if ( hasTime() ) | 356 | if ( hasTime() ) |
323 | return mAlarmTime; | 357 | return mAlarmTime; |
324 | else | 358 | else |
325 | { | 359 | { |
326 | if (mParent->type()=="Todo") { | 360 | if (mParent->type()=="Todo") { |
327 | Todo *t = static_cast<Todo*>(mParent); | 361 | Todo *t = static_cast<Todo*>(mParent); |
328 | return mOffset.end( t->dtDue() ); | 362 | return mOffset.end( t->dtDue() ); |
329 | } else if (mEndOffset) { | 363 | } else if (mEndOffset) { |
330 | return mOffset.end( mParent->dtEnd() ); | 364 | return mOffset.end( mParent->dtEnd() ); |
331 | } else { | 365 | } else { |
332 | return mOffset.end( mParent->dtStart() ); | 366 | return mOffset.end( mParent->dtStart() ); |
333 | } | 367 | } |
334 | } | 368 | } |
335 | } | 369 | } |
336 | 370 | ||
337 | bool Alarm::hasTime() const | 371 | bool Alarm::hasTime() const |
338 | { | 372 | { |
339 | return mHasTime; | 373 | return mHasTime; |
340 | } | 374 | } |
341 | 375 | ||
342 | void Alarm::setSnoozeTime(int alarmSnoozeTime) | 376 | void Alarm::setSnoozeTime(int alarmSnoozeTime) |
343 | { | 377 | { |
344 | mAlarmSnoozeTime = alarmSnoozeTime; | 378 | mAlarmSnoozeTime = alarmSnoozeTime; |
345 | mParent->updated(); | 379 | mParent->updated(); |
346 | } | 380 | } |
347 | 381 | ||
348 | int Alarm::snoozeTime() const | 382 | int Alarm::snoozeTime() const |
349 | { | 383 | { |
350 | return mAlarmSnoozeTime; | 384 | return mAlarmSnoozeTime; |
351 | } | 385 | } |
352 | 386 | ||
353 | void Alarm::setRepeatCount(int alarmRepeatCount) | 387 | void Alarm::setRepeatCount(int alarmRepeatCount) |
354 | { | 388 | { |
355 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; | 389 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; |
356 | 390 | ||
357 | mAlarmRepeatCount = alarmRepeatCount; | 391 | mAlarmRepeatCount = alarmRepeatCount; |
358 | mParent->updated(); | 392 | mParent->updated(); |
359 | } | 393 | } |
360 | 394 | ||
361 | int Alarm::repeatCount() const | 395 | int Alarm::repeatCount() const |
362 | { | 396 | { |
363 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; | 397 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; |
364 | return mAlarmRepeatCount; | 398 | return mAlarmRepeatCount; |
365 | } | 399 | } |
366 | 400 | ||
367 | void Alarm::toggleAlarm() | 401 | void Alarm::toggleAlarm() |
368 | { | 402 | { |
369 | mAlarmEnabled = !mAlarmEnabled; | 403 | mAlarmEnabled = !mAlarmEnabled; |
370 | mParent->updated(); | 404 | mParent->updated(); |
371 | } | 405 | } |
372 | 406 | ||
373 | void Alarm::setEnabled(bool enable) | 407 | void Alarm::setEnabled(bool enable) |
374 | { | 408 | { |
375 | mAlarmEnabled = enable; | 409 | mAlarmEnabled = enable; |
376 | mParent->updated(); | 410 | mParent->updated(); |
377 | } | 411 | } |
378 | 412 | ||
379 | bool Alarm::enabled() const | 413 | bool Alarm::enabled() const |
380 | { | 414 | { |
381 | return mAlarmEnabled; | 415 | return mAlarmEnabled; |
382 | } | 416 | } |
383 | 417 | ||
384 | void Alarm::setStartOffset( const Duration &offset ) | 418 | void Alarm::setStartOffset( const Duration &offset ) |
385 | { | 419 | { |
386 | mOffset = offset; | 420 | mOffset = offset; |
387 | mEndOffset = false; | 421 | mEndOffset = false; |
388 | mHasTime = false; | 422 | mHasTime = false; |
389 | mParent->updated(); | 423 | mParent->updated(); |
390 | } | 424 | } |
391 | 425 | ||
392 | Duration Alarm::startOffset() const | 426 | Duration Alarm::startOffset() const |
393 | { | 427 | { |
394 | return (mHasTime || mEndOffset) ? 0 : mOffset; | 428 | return (mHasTime || mEndOffset) ? 0 : mOffset; |
395 | } | 429 | } |
396 | 430 | ||
397 | bool Alarm::hasStartOffset() const | 431 | bool Alarm::hasStartOffset() const |
398 | { | 432 | { |
399 | return !mHasTime && !mEndOffset; | 433 | return !mHasTime && !mEndOffset; |
400 | } | 434 | } |
401 | 435 | ||
402 | bool Alarm::hasEndOffset() const | 436 | bool Alarm::hasEndOffset() const |
403 | { | 437 | { |
404 | return !mHasTime && mEndOffset; | 438 | return !mHasTime && mEndOffset; |
405 | } | 439 | } |
406 | 440 | ||
407 | void Alarm::setEndOffset( const Duration &offset ) | 441 | void Alarm::setEndOffset( const Duration &offset ) |
408 | { | 442 | { |
409 | mOffset = offset; | 443 | mOffset = offset; |
410 | mEndOffset = true; | 444 | mEndOffset = true; |
411 | mHasTime = false; | 445 | mHasTime = false; |
412 | mParent->updated(); | 446 | mParent->updated(); |
413 | } | 447 | } |
414 | 448 | ||
415 | Duration Alarm::endOffset() const | 449 | Duration Alarm::endOffset() const |
416 | { | 450 | { |
417 | return (mHasTime || !mEndOffset) ? 0 : mOffset; | 451 | return (mHasTime || !mEndOffset) ? 0 : mOffset; |
418 | } | 452 | } |
419 | 453 | ||
420 | void Alarm::setParent( Incidence *parent ) | 454 | void Alarm::setParent( Incidence *parent ) |
421 | { | 455 | { |
422 | mParent = parent; | 456 | mParent = parent; |
423 | } | 457 | } |