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-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.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,348 +1,350 @@ | |||
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 | { |