author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkcal/alarm.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | libkcal/alarm.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 3157214..3c4a81c 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -1,483 +1,485 @@ | |||
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 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | 24 | ||
25 | #include "incidence.h" | 25 | #include "incidence.h" |
26 | #include "todo.h" | 26 | #include "todo.h" |
27 | 27 | ||
28 | #include "alarm.h" | 28 | #include "alarm.h" |
29 | //Added by qt3to4: | ||
30 | #include <Q3ValueList> | ||
29 | 31 | ||
30 | using namespace KCal; | 32 | using namespace KCal; |
31 | #include <qwidget.h> | 33 | #include <qwidget.h> |
32 | Alarm::Alarm(Incidence *parent) | 34 | Alarm::Alarm(Incidence *parent) |
33 | : mParent(parent), | 35 | : mParent(parent), |
34 | mType(Audio), | 36 | mType(Audio), |
35 | mDescription(""), // to make operator==() not fail | 37 | mDescription(""), // to make operator==() not fail |
36 | mFile(""), // to make operator==() not fail | 38 | mFile(""), // to make operator==() not fail |
37 | mMailSubject(""), // to make operator==() not fail | 39 | mMailSubject(""), // to make operator==() not fail |
38 | mAlarmSnoozeTime(5), | 40 | mAlarmSnoozeTime(5), |
39 | mAlarmRepeatCount(0), | 41 | mAlarmRepeatCount(0), |
40 | mEndOffset(false), | 42 | mEndOffset(false), |
41 | mHasTime(false), | 43 | mHasTime(false), |
42 | mAlarmEnabled(false) | 44 | mAlarmEnabled(false) |
43 | { | 45 | { |
44 | 46 | ||
45 | } | 47 | } |
46 | 48 | ||
47 | Alarm::~Alarm() | 49 | Alarm::~Alarm() |
48 | { | 50 | { |
49 | } | 51 | } |
50 | 52 | ||
51 | bool Alarm::operator==( const Alarm& rhs ) const | 53 | bool Alarm::operator==( const Alarm& rhs ) const |
52 | { | 54 | { |
53 | 55 | ||
54 | if ( mType != rhs.mType || | 56 | if ( mType != rhs.mType || |
55 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || | 57 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || |
56 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || | 58 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || |
57 | mAlarmEnabled != rhs.mAlarmEnabled || | 59 | mAlarmEnabled != rhs.mAlarmEnabled || |
58 | mHasTime != rhs.mHasTime) | 60 | mHasTime != rhs.mHasTime) |
59 | return false; | 61 | return false; |
60 | 62 | ||
61 | #if 0 | 63 | #if 0 |
62 | if ( mType != rhs.mType ) { | 64 | if ( mType != rhs.mType ) { |
63 | 65 | ||
64 | qDebug("aaa1 "); | 66 | qDebug("aaa1 "); |
65 | return false; | 67 | return false; |
66 | } | 68 | } |
67 | 69 | ||
68 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { | 70 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { |
69 | 71 | ||
70 | qDebug("aaa2 "); | 72 | qDebug("aaa2 "); |
71 | return false; | 73 | return false; |
72 | } | 74 | } |
73 | 75 | ||
74 | 76 | ||
75 | if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { | 77 | if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { |
76 | 78 | ||
77 | qDebug("aaa3 "); | 79 | qDebug("aaa3 "); |
78 | return false; | 80 | return false; |
79 | } | 81 | } |
80 | 82 | ||
81 | if ( mAlarmEnabled != rhs.mAlarmEnabled ) { | 83 | if ( mAlarmEnabled != rhs.mAlarmEnabled ) { |
82 | 84 | ||
83 | qDebug("aaa4 "); | 85 | qDebug("aaa4 "); |
84 | return false; | 86 | return false; |
85 | } | 87 | } |
86 | 88 | ||
87 | if ( mHasTime != rhs.mHasTime ) { | 89 | if ( mHasTime != rhs.mHasTime ) { |
88 | 90 | ||
89 | qDebug("aaa5 "); | 91 | qDebug("aaa5 "); |
90 | return false; | 92 | return false; |
91 | } | 93 | } |
92 | #endif | 94 | #endif |
93 | 95 | ||
94 | 96 | ||
95 | if (mHasTime) { | 97 | if (mHasTime) { |
96 | if (mAlarmTime != rhs.mAlarmTime) | 98 | if (mAlarmTime != rhs.mAlarmTime) |
97 | return false; | 99 | return false; |
98 | } else { | 100 | } else { |
99 | if (mOffset != rhs.mOffset || | 101 | if (mOffset != rhs.mOffset || |
100 | mEndOffset != rhs.mEndOffset) | 102 | mEndOffset != rhs.mEndOffset) |
101 | return false; | 103 | return false; |
102 | } | 104 | } |
103 | switch (mType) { | 105 | switch (mType) { |
104 | case Display: | 106 | case Display: |
105 | return mDescription == rhs.mDescription; | 107 | return mDescription == rhs.mDescription; |
106 | 108 | ||
107 | case Email: | 109 | case Email: |
108 | return mDescription == rhs.mDescription && | 110 | return mDescription == rhs.mDescription && |
109 | mMailAttachFiles == rhs.mMailAttachFiles && | 111 | mMailAttachFiles == rhs.mMailAttachFiles && |
110 | mMailAddresses == rhs.mMailAddresses && | 112 | mMailAddresses == rhs.mMailAddresses && |
111 | mMailSubject == rhs.mMailSubject; | 113 | mMailSubject == rhs.mMailSubject; |
112 | 114 | ||
113 | case Procedure: | 115 | case Procedure: |
114 | return mFile == rhs.mFile && | 116 | return mFile == rhs.mFile && |
115 | mDescription == rhs.mDescription; | 117 | mDescription == rhs.mDescription; |
116 | 118 | ||
117 | case Audio: | 119 | case Audio: |
118 | return mFile == rhs.mFile; | 120 | return mFile == rhs.mFile; |
119 | 121 | ||
120 | case Invalid: | 122 | case Invalid: |
121 | break; | 123 | break; |
122 | } | 124 | } |
123 | return false; | 125 | return false; |
124 | } | 126 | } |
125 | 127 | ||
126 | void Alarm::setType(Alarm::Type type) | 128 | void Alarm::setType(Alarm::Type type) |
127 | { | 129 | { |
128 | if (type == mType) | 130 | if (type == mType) |
129 | return; | 131 | return; |
130 | 132 | ||
131 | switch (type) { | 133 | switch (type) { |
132 | case Display: | 134 | case Display: |
133 | mDescription = ""; | 135 | mDescription = ""; |
134 | break; | 136 | break; |
135 | case Procedure: | 137 | case Procedure: |
136 | mFile = mDescription = ""; | 138 | mFile = mDescription = ""; |
137 | break; | 139 | break; |
138 | case Audio: | 140 | case Audio: |
139 | mFile = ""; | 141 | mFile = ""; |
140 | break; | 142 | break; |
141 | case Email: | 143 | case Email: |
142 | mMailSubject = mDescription = ""; | 144 | mMailSubject = mDescription = ""; |
143 | mMailAddresses.clear(); | 145 | mMailAddresses.clear(); |
144 | mMailAttachFiles.clear(); | 146 | mMailAttachFiles.clear(); |
145 | break; | 147 | break; |
146 | case Invalid: | 148 | case Invalid: |
147 | break; | 149 | break; |
148 | default: | 150 | default: |
149 | return; | 151 | return; |
150 | } | 152 | } |
151 | mType = type; | 153 | mType = type; |
152 | mParent->updated(); | 154 | mParent->updated(); |
153 | } | 155 | } |
154 | 156 | ||
155 | Alarm::Type Alarm::type() const | 157 | Alarm::Type Alarm::type() const |
156 | { | 158 | { |
157 | return mType; | 159 | return mType; |
158 | } | 160 | } |
159 | 161 | ||
160 | void Alarm::setAudioAlarm(const QString &audioFile) | 162 | void Alarm::setAudioAlarm(const QString &audioFile) |
161 | { | 163 | { |
162 | mType = Audio; | 164 | mType = Audio; |
163 | mFile = audioFile; | 165 | mFile = audioFile; |
164 | mParent->updated(); | 166 | mParent->updated(); |
165 | } | 167 | } |
166 | 168 | ||
167 | void Alarm::setAudioFile(const QString &audioFile) | 169 | void Alarm::setAudioFile(const QString &audioFile) |
168 | { | 170 | { |
169 | if (mType == Audio) { | 171 | if (mType == Audio) { |
170 | mFile = audioFile; | 172 | mFile = audioFile; |
171 | mParent->updated(); | 173 | mParent->updated(); |
172 | } | 174 | } |
173 | } | 175 | } |
174 | 176 | ||
175 | QString Alarm::audioFile() const | 177 | QString Alarm::audioFile() const |
176 | { | 178 | { |
177 | return (mType == Audio) ? mFile : QString::null; | 179 | return (mType == Audio) ? mFile : QString::null; |
178 | } | 180 | } |
179 | 181 | ||
180 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) | 182 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) |
181 | { | 183 | { |
182 | mType = Procedure; | 184 | mType = Procedure; |
183 | mFile = programFile; | 185 | mFile = programFile; |
184 | mDescription = arguments; | 186 | mDescription = arguments; |
185 | mParent->updated(); | 187 | mParent->updated(); |
186 | } | 188 | } |
187 | 189 | ||
188 | void Alarm::setProgramFile(const QString &programFile) | 190 | void Alarm::setProgramFile(const QString &programFile) |
189 | { | 191 | { |
190 | if (mType == Procedure) { | 192 | if (mType == Procedure) { |
191 | mFile = programFile; | 193 | mFile = programFile; |
192 | mParent->updated(); | 194 | mParent->updated(); |
193 | } | 195 | } |
194 | } | 196 | } |
195 | 197 | ||
196 | QString Alarm::programFile() const | 198 | QString Alarm::programFile() const |
197 | { | 199 | { |
198 | return (mType == Procedure) ? mFile : QString::null; | 200 | return (mType == Procedure) ? mFile : QString::null; |
199 | } | 201 | } |
200 | 202 | ||
201 | void Alarm::setProgramArguments(const QString &arguments) | 203 | void Alarm::setProgramArguments(const QString &arguments) |
202 | { | 204 | { |
203 | if (mType == Procedure) { | 205 | if (mType == Procedure) { |
204 | mDescription = arguments; | 206 | mDescription = arguments; |
205 | mParent->updated(); | 207 | mParent->updated(); |
206 | } | 208 | } |
207 | } | 209 | } |
208 | 210 | ||
209 | QString Alarm::programArguments() const | 211 | QString Alarm::programArguments() const |
210 | { | 212 | { |
211 | return (mType == Procedure) ? mDescription : QString::null; | 213 | return (mType == Procedure) ? mDescription : QString::null; |
212 | } | 214 | } |
213 | 215 | ||
214 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, | 216 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, |
215 | const QValueList<Person> &addressees, const QStringList &attachments) | 217 | const Q3ValueList<Person> &addressees, const QStringList &attachments) |
216 | { | 218 | { |
217 | mType = Email; | 219 | mType = Email; |
218 | mMailSubject = subject; | 220 | mMailSubject = subject; |
219 | mDescription = text; | 221 | mDescription = text; |
220 | mMailAddresses = addressees; | 222 | mMailAddresses = addressees; |
221 | mMailAttachFiles = attachments; | 223 | mMailAttachFiles = attachments; |
222 | mParent->updated(); | 224 | mParent->updated(); |
223 | } | 225 | } |
224 | 226 | ||
225 | void Alarm::setMailAddress(const Person &mailAddress) | 227 | void Alarm::setMailAddress(const Person &mailAddress) |
226 | { | 228 | { |
227 | if (mType == Email) { | 229 | if (mType == Email) { |
228 | mMailAddresses.clear(); | 230 | mMailAddresses.clear(); |
229 | mMailAddresses += mailAddress; | 231 | mMailAddresses += mailAddress; |
230 | mParent->updated(); | 232 | mParent->updated(); |
231 | } | 233 | } |
232 | } | 234 | } |
233 | 235 | ||
234 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) | 236 | void Alarm::setMailAddresses(const Q3ValueList<Person> &mailAddresses) |
235 | { | 237 | { |
236 | if (mType == Email) { | 238 | if (mType == Email) { |
237 | mMailAddresses = mailAddresses; | 239 | mMailAddresses = mailAddresses; |
238 | mParent->updated(); | 240 | mParent->updated(); |
239 | } | 241 | } |
240 | } | 242 | } |
241 | 243 | ||
242 | void Alarm::addMailAddress(const Person &mailAddress) | 244 | void Alarm::addMailAddress(const Person &mailAddress) |
243 | { | 245 | { |
244 | if (mType == Email) { | 246 | if (mType == Email) { |
245 | mMailAddresses += mailAddress; | 247 | mMailAddresses += mailAddress; |
246 | mParent->updated(); | 248 | mParent->updated(); |
247 | } | 249 | } |
248 | } | 250 | } |
249 | 251 | ||
250 | QValueList<Person> Alarm::mailAddresses() const | 252 | Q3ValueList<Person> Alarm::mailAddresses() const |
251 | { | 253 | { |
252 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); | 254 | return (mType == Email) ? mMailAddresses : Q3ValueList<Person>(); |
253 | } | 255 | } |
254 | 256 | ||
255 | void Alarm::setMailSubject(const QString &mailAlarmSubject) | 257 | void Alarm::setMailSubject(const QString &mailAlarmSubject) |
256 | { | 258 | { |
257 | if (mType == Email) { | 259 | if (mType == Email) { |
258 | mMailSubject = mailAlarmSubject; | 260 | mMailSubject = mailAlarmSubject; |
259 | mParent->updated(); | 261 | mParent->updated(); |
260 | } | 262 | } |
261 | } | 263 | } |
262 | 264 | ||
263 | QString Alarm::mailSubject() const | 265 | QString Alarm::mailSubject() const |
264 | { | 266 | { |
265 | return (mType == Email) ? mMailSubject : QString::null; | 267 | return (mType == Email) ? mMailSubject : QString::null; |
266 | } | 268 | } |
267 | 269 | ||
268 | void Alarm::setMailAttachment(const QString &mailAttachFile) | 270 | void Alarm::setMailAttachment(const QString &mailAttachFile) |
269 | { | 271 | { |
270 | if (mType == Email) { | 272 | if (mType == Email) { |
271 | mMailAttachFiles.clear(); | 273 | mMailAttachFiles.clear(); |
272 | mMailAttachFiles += mailAttachFile; | 274 | mMailAttachFiles += mailAttachFile; |
273 | mParent->updated(); | 275 | mParent->updated(); |
274 | } | 276 | } |
275 | } | 277 | } |
276 | 278 | ||
277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) | 279 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) |
278 | { | 280 | { |
279 | if (mType == Email) { | 281 | if (mType == Email) { |
280 | mMailAttachFiles = mailAttachFiles; | 282 | mMailAttachFiles = mailAttachFiles; |
281 | mParent->updated(); | 283 | mParent->updated(); |
282 | } | 284 | } |
283 | } | 285 | } |
284 | 286 | ||
285 | void Alarm::addMailAttachment(const QString &mailAttachFile) | 287 | void Alarm::addMailAttachment(const QString &mailAttachFile) |
286 | { | 288 | { |
287 | if (mType == Email) { | 289 | if (mType == Email) { |
288 | mMailAttachFiles += mailAttachFile; | 290 | mMailAttachFiles += mailAttachFile; |
289 | mParent->updated(); | 291 | mParent->updated(); |
290 | } | 292 | } |
291 | } | 293 | } |
292 | 294 | ||
293 | QStringList Alarm::mailAttachments() const | 295 | QStringList Alarm::mailAttachments() const |
294 | { | 296 | { |
295 | return (mType == Email) ? mMailAttachFiles : QStringList(); | 297 | return (mType == Email) ? mMailAttachFiles : QStringList(); |
296 | } | 298 | } |
297 | 299 | ||
298 | void Alarm::setMailText(const QString &text) | 300 | void Alarm::setMailText(const QString &text) |
299 | { | 301 | { |
300 | if (mType == Email) { | 302 | if (mType == Email) { |
301 | mDescription = text; | 303 | mDescription = text; |
302 | mParent->updated(); | 304 | mParent->updated(); |
303 | } | 305 | } |
304 | } | 306 | } |
305 | 307 | ||
306 | QString Alarm::mailText() const | 308 | QString Alarm::mailText() const |
307 | { | 309 | { |
308 | return (mType == Email) ? mDescription : QString::null; | 310 | return (mType == Email) ? mDescription : QString::null; |
309 | } | 311 | } |
310 | 312 | ||
311 | void Alarm::setDisplayAlarm(const QString &text) | 313 | void Alarm::setDisplayAlarm(const QString &text) |
312 | { | 314 | { |
313 | mType = Display; | 315 | mType = Display; |
314 | mDescription = text; | 316 | mDescription = text; |
315 | mParent->updated(); | 317 | mParent->updated(); |
316 | } | 318 | } |
317 | 319 | ||
318 | void Alarm::setText(const QString &text) | 320 | void Alarm::setText(const QString &text) |
319 | { | 321 | { |
320 | if (mType == Display) { | 322 | if (mType == Display) { |
321 | mDescription = text; | 323 | mDescription = text; |
322 | mParent->updated(); | 324 | mParent->updated(); |
323 | } | 325 | } |
324 | } | 326 | } |
325 | 327 | ||
326 | QString Alarm::text() const | 328 | QString Alarm::text() const |
327 | { | 329 | { |
328 | return (mType == Display) ? mDescription : QString::null; | 330 | return (mType == Display) ? mDescription : QString::null; |
329 | } | 331 | } |
330 | 332 | ||
331 | void Alarm::setTime(const QDateTime &alarmTime) | 333 | void Alarm::setTime(const QDateTime &alarmTime) |
332 | { | 334 | { |
333 | mAlarmTime = alarmTime; | 335 | mAlarmTime = alarmTime; |
334 | mHasTime = true; | 336 | mHasTime = true; |
335 | 337 | ||
336 | mParent->updated(); | 338 | mParent->updated(); |
337 | } | 339 | } |
338 | int Alarm::offset() | 340 | int Alarm::offset() |
339 | { | 341 | { |
340 | if ( hasTime() ) { | 342 | if ( hasTime() ) { |
341 | if (mParent->typeID() == todoID ) { | 343 | if (mParent->typeID() == todoID ) { |
342 | Todo *t = static_cast<Todo*>(mParent); | 344 | Todo *t = static_cast<Todo*>(mParent); |
343 | return t->dtDue().secsTo( mAlarmTime ) ; | 345 | return t->dtDue().secsTo( mAlarmTime ) ; |
344 | } else | 346 | } else |
345 | return mParent->dtStart().secsTo( mAlarmTime ) ; | 347 | return mParent->dtStart().secsTo( mAlarmTime ) ; |
346 | } | 348 | } |
347 | else | 349 | else |
348 | { | 350 | { |
349 | return mOffset.asSeconds(); | 351 | return mOffset.asSeconds(); |
350 | } | 352 | } |
351 | 353 | ||
352 | } | 354 | } |
353 | QString Alarm::offsetText() | 355 | QString Alarm::offsetText() |
354 | { | 356 | { |
355 | int min = -offset()/60; | 357 | int min = -offset()/60; |
356 | int hours = min /60; | 358 | int hours = min /60; |
357 | min = min % 60; | 359 | min = min % 60; |
358 | int days = hours /24; | 360 | int days = hours /24; |
359 | hours = hours % 24; | 361 | hours = hours % 24; |
360 | QString message; | 362 | QString message; |
361 | //qDebug("%d %d %d ", days, hours, min ); | 363 | //qDebug("%d %d %d ", days, hours, min ); |
362 | if ( days > 0 ) | 364 | if ( days > 0 ) |
363 | message += i18n("%1d").arg( days ); | 365 | message += i18n("%1d").arg( days ); |
364 | if ( hours > 0 ) { | 366 | if ( hours > 0 ) { |
365 | if ( !message.isEmpty() ) message += "/"; | 367 | if ( !message.isEmpty() ) message += "/"; |
366 | message += i18n("%1h").arg( hours ); | 368 | message += i18n("%1h").arg( hours ); |
367 | } | 369 | } |
368 | if ( min > 0 ) { | 370 | if ( min > 0 ) { |
369 | if ( !message.isEmpty() ) message += "/"; | 371 | if ( !message.isEmpty() ) message += "/"; |
370 | message += i18n("%1min").arg( min ); | 372 | message += i18n("%1min").arg( min ); |
371 | } | 373 | } |
372 | if ( message.isEmpty() ) | 374 | if ( message.isEmpty() ) |
373 | message = i18n("%1min").arg( 0 ); | 375 | message = i18n("%1min").arg( 0 ); |
374 | if ( !mParent->alarmEnabled() ) | 376 | if ( !mParent->alarmEnabled() ) |
375 | return "!"+message + i18n("(disabled)"); | 377 | return "!"+message + i18n("(disabled)"); |
376 | return message; | 378 | return message; |
377 | } | 379 | } |
378 | 380 | ||
379 | 381 | ||
380 | QDateTime Alarm::time() const | 382 | QDateTime Alarm::time() const |
381 | { | 383 | { |
382 | if ( hasTime() ) | 384 | if ( hasTime() ) |
383 | return mAlarmTime; | 385 | return mAlarmTime; |
384 | else | 386 | else |
385 | { | 387 | { |
386 | if (mParent->typeID() == todoID ) { | 388 | if (mParent->typeID() == todoID ) { |
387 | Todo *t = static_cast<Todo*>(mParent); | 389 | Todo *t = static_cast<Todo*>(mParent); |
388 | return mOffset.end( t->dtDue() ); | 390 | return mOffset.end( t->dtDue() ); |
389 | } else if (mEndOffset) { | 391 | } else if (mEndOffset) { |
390 | return mOffset.end( mParent->dtEnd() ); | 392 | return mOffset.end( mParent->dtEnd() ); |
391 | } else { | 393 | } else { |
392 | return mOffset.end( mParent->dtStart() ); | 394 | return mOffset.end( mParent->dtStart() ); |
393 | } | 395 | } |
394 | } | 396 | } |
395 | } | 397 | } |
396 | 398 | ||
397 | bool Alarm::hasTime() const | 399 | bool Alarm::hasTime() const |
398 | { | 400 | { |
399 | return mHasTime; | 401 | return mHasTime; |
400 | } | 402 | } |
401 | 403 | ||
402 | void Alarm::setSnoozeTime(int alarmSnoozeTime) | 404 | void Alarm::setSnoozeTime(int alarmSnoozeTime) |
403 | { | 405 | { |
404 | mAlarmSnoozeTime = alarmSnoozeTime; | 406 | mAlarmSnoozeTime = alarmSnoozeTime; |
405 | mParent->updated(); | 407 | mParent->updated(); |
406 | } | 408 | } |
407 | 409 | ||
408 | int Alarm::snoozeTime() const | 410 | int Alarm::snoozeTime() const |
409 | { | 411 | { |
410 | return mAlarmSnoozeTime; | 412 | return mAlarmSnoozeTime; |
411 | } | 413 | } |
412 | 414 | ||
413 | void Alarm::setRepeatCount(int alarmRepeatCount) | 415 | void Alarm::setRepeatCount(int alarmRepeatCount) |
414 | { | 416 | { |
415 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; | 417 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; |
416 | 418 | ||
417 | mAlarmRepeatCount = alarmRepeatCount; | 419 | mAlarmRepeatCount = alarmRepeatCount; |
418 | mParent->updated(); | 420 | mParent->updated(); |
419 | } | 421 | } |
420 | 422 | ||
421 | int Alarm::repeatCount() const | 423 | int Alarm::repeatCount() const |
422 | { | 424 | { |
423 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; | 425 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; |
424 | return mAlarmRepeatCount; | 426 | return mAlarmRepeatCount; |
425 | } | 427 | } |
426 | 428 | ||
427 | void Alarm::toggleAlarm() | 429 | void Alarm::toggleAlarm() |
428 | { | 430 | { |
429 | mAlarmEnabled = !mAlarmEnabled; | 431 | mAlarmEnabled = !mAlarmEnabled; |
430 | mParent->updated(); | 432 | mParent->updated(); |
431 | } | 433 | } |
432 | 434 | ||
433 | void Alarm::setEnabled(bool enable) | 435 | void Alarm::setEnabled(bool enable) |
434 | { | 436 | { |
435 | mAlarmEnabled = enable; | 437 | mAlarmEnabled = enable; |
436 | mParent->updated(); | 438 | mParent->updated(); |
437 | } | 439 | } |
438 | 440 | ||
439 | bool Alarm::enabled() const | 441 | bool Alarm::enabled() const |
440 | { | 442 | { |
441 | return mAlarmEnabled; | 443 | return mAlarmEnabled; |
442 | } | 444 | } |
443 | 445 | ||
444 | void Alarm::setStartOffset( const Duration &offset ) | 446 | void Alarm::setStartOffset( const Duration &offset ) |
445 | { | 447 | { |
446 | mOffset = offset; | 448 | mOffset = offset; |
447 | mEndOffset = false; | 449 | mEndOffset = false; |
448 | mHasTime = false; | 450 | mHasTime = false; |
449 | mParent->updated(); | 451 | mParent->updated(); |
450 | } | 452 | } |
451 | 453 | ||
452 | Duration Alarm::startOffset() const | 454 | Duration Alarm::startOffset() const |
453 | { | 455 | { |
454 | return (mHasTime || mEndOffset) ? 0 : mOffset; | 456 | return (mHasTime || mEndOffset) ? 0 : mOffset; |
455 | } | 457 | } |
456 | 458 | ||
457 | bool Alarm::hasStartOffset() const | 459 | bool Alarm::hasStartOffset() const |
458 | { | 460 | { |
459 | return !mHasTime && !mEndOffset; | 461 | return !mHasTime && !mEndOffset; |
460 | } | 462 | } |
461 | 463 | ||
462 | bool Alarm::hasEndOffset() const | 464 | bool Alarm::hasEndOffset() const |
463 | { | 465 | { |
464 | return !mHasTime && mEndOffset; | 466 | return !mHasTime && mEndOffset; |
465 | } | 467 | } |
466 | 468 | ||
467 | void Alarm::setEndOffset( const Duration &offset ) | 469 | void Alarm::setEndOffset( const Duration &offset ) |
468 | { | 470 | { |
469 | mOffset = offset; | 471 | mOffset = offset; |
470 | mEndOffset = true; | 472 | mEndOffset = true; |
471 | mHasTime = false; | 473 | mHasTime = false; |
472 | mParent->updated(); | 474 | mParent->updated(); |
473 | } | 475 | } |
474 | 476 | ||
475 | Duration Alarm::endOffset() const | 477 | Duration Alarm::endOffset() const |
476 | { | 478 | { |
477 | return (mHasTime || !mEndOffset) ? 0 : mOffset; | 479 | return (mHasTime || !mEndOffset) ? 0 : mOffset; |
478 | } | 480 | } |
479 | 481 | ||
480 | void Alarm::setParent( Incidence *parent ) | 482 | void Alarm::setParent( Incidence *parent ) |
481 | { | 483 | { |
482 | mParent = parent; | 484 | mParent = parent; |
483 | } | 485 | } |