-rw-r--r-- | libkcal/alarm.cpp | 2 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index d8f15b5..6de1566 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -1,481 +1,481 @@ | |||
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 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | #include <qwidget.h> | 31 | #include <qwidget.h> |
32 | Alarm::Alarm(Incidence *parent) | 32 | Alarm::Alarm(Incidence *parent) |
33 | : mParent(parent), | 33 | : mParent(parent), |
34 | mType(Audio), | 34 | mType(Audio), |
35 | mDescription(""), // to make operator==() not fail | 35 | mDescription(""), // to make operator==() not fail |
36 | mFile(""), // to make operator==() not fail | 36 | mFile(""), // to make operator==() not fail |
37 | mMailSubject(""), // to make operator==() not fail | 37 | mMailSubject(""), // to make operator==() not fail |
38 | mAlarmSnoozeTime(5), | 38 | mAlarmSnoozeTime(5), |
39 | mAlarmRepeatCount(0), | 39 | mAlarmRepeatCount(0), |
40 | mEndOffset(false), | 40 | mEndOffset(false), |
41 | mHasTime(false), | 41 | mHasTime(false), |
42 | mAlarmEnabled(false) | 42 | mAlarmEnabled(false) |
43 | { | 43 | { |
44 | 44 | ||
45 | } | 45 | } |
46 | 46 | ||
47 | Alarm::~Alarm() | 47 | Alarm::~Alarm() |
48 | { | 48 | { |
49 | } | 49 | } |
50 | 50 | ||
51 | bool Alarm::operator==( const Alarm& rhs ) const | 51 | bool Alarm::operator==( const Alarm& rhs ) const |
52 | { | 52 | { |
53 | 53 | ||
54 | if ( mType != rhs.mType || | 54 | if ( mType != rhs.mType || |
55 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || | 55 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || |
56 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || | 56 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || |
57 | mAlarmEnabled != rhs.mAlarmEnabled || | 57 | mAlarmEnabled != rhs.mAlarmEnabled || |
58 | mHasTime != rhs.mHasTime) | 58 | mHasTime != rhs.mHasTime) |
59 | return false; | 59 | return false; |
60 | 60 | ||
61 | #if 0 | 61 | #if 0 |
62 | if ( mType != rhs.mType ) { | 62 | if ( mType != rhs.mType ) { |
63 | 63 | ||
64 | qDebug("aaa1 "); | 64 | qDebug("aaa1 "); |
65 | return false; | 65 | return false; |
66 | } | 66 | } |
67 | 67 | ||
68 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { | 68 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { |
69 | 69 | ||
70 | qDebug("aaa2 "); | 70 | qDebug("aaa2 "); |
71 | return false; | 71 | return false; |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { | 75 | if ( mAlarmRepeatCount != rhs.mAlarmRepeatCount ) { |
76 | 76 | ||
77 | qDebug("aaa3 "); | 77 | qDebug("aaa3 "); |
78 | return false; | 78 | return false; |
79 | } | 79 | } |
80 | 80 | ||
81 | if ( mAlarmEnabled != rhs.mAlarmEnabled ) { | 81 | if ( mAlarmEnabled != rhs.mAlarmEnabled ) { |
82 | 82 | ||
83 | qDebug("aaa4 "); | 83 | qDebug("aaa4 "); |
84 | return false; | 84 | return false; |
85 | } | 85 | } |
86 | 86 | ||
87 | if ( mHasTime != rhs.mHasTime ) { | 87 | if ( mHasTime != rhs.mHasTime ) { |
88 | 88 | ||
89 | qDebug("aaa5 "); | 89 | qDebug("aaa5 "); |
90 | return false; | 90 | return false; |
91 | } | 91 | } |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | 94 | ||
95 | if (mHasTime) { | 95 | if (mHasTime) { |
96 | if (mAlarmTime != rhs.mAlarmTime) | 96 | if (mAlarmTime != rhs.mAlarmTime) |
97 | return false; | 97 | return false; |
98 | } else { | 98 | } else { |
99 | if (mOffset != rhs.mOffset || | 99 | if (mOffset != rhs.mOffset || |
100 | mEndOffset != rhs.mEndOffset) | 100 | mEndOffset != rhs.mEndOffset) |
101 | return false; | 101 | return false; |
102 | } | 102 | } |
103 | switch (mType) { | 103 | switch (mType) { |
104 | case Display: | 104 | case Display: |
105 | return mDescription == rhs.mDescription; | 105 | return mDescription == rhs.mDescription; |
106 | 106 | ||
107 | case Email: | 107 | case Email: |
108 | return mDescription == rhs.mDescription && | 108 | return mDescription == rhs.mDescription && |
109 | mMailAttachFiles == rhs.mMailAttachFiles && | 109 | mMailAttachFiles == rhs.mMailAttachFiles && |
110 | mMailAddresses == rhs.mMailAddresses && | 110 | mMailAddresses == rhs.mMailAddresses && |
111 | mMailSubject == rhs.mMailSubject; | 111 | mMailSubject == rhs.mMailSubject; |
112 | 112 | ||
113 | case Procedure: | 113 | case Procedure: |
114 | return mFile == rhs.mFile && | 114 | return mFile == rhs.mFile && |
115 | mDescription == rhs.mDescription; | 115 | mDescription == rhs.mDescription; |
116 | 116 | ||
117 | case Audio: | 117 | case Audio: |
118 | return mFile == rhs.mFile; | 118 | return mFile == rhs.mFile; |
119 | 119 | ||
120 | case Invalid: | 120 | case Invalid: |
121 | break; | 121 | break; |
122 | } | 122 | } |
123 | return false; | 123 | return false; |
124 | } | 124 | } |
125 | 125 | ||
126 | void Alarm::setType(Alarm::Type type) | 126 | void Alarm::setType(Alarm::Type type) |
127 | { | 127 | { |
128 | if (type == mType) | 128 | if (type == mType) |
129 | return; | 129 | return; |
130 | 130 | ||
131 | switch (type) { | 131 | switch (type) { |
132 | case Display: | 132 | case Display: |
133 | mDescription = ""; | 133 | mDescription = ""; |
134 | break; | 134 | break; |
135 | case Procedure: | 135 | case Procedure: |
136 | mFile = mDescription = ""; | 136 | mFile = mDescription = ""; |
137 | break; | 137 | break; |
138 | case Audio: | 138 | case Audio: |
139 | mFile = ""; | 139 | mFile = ""; |
140 | break; | 140 | break; |
141 | case Email: | 141 | case Email: |
142 | mMailSubject = mDescription = ""; | 142 | mMailSubject = mDescription = ""; |
143 | mMailAddresses.clear(); | 143 | mMailAddresses.clear(); |
144 | mMailAttachFiles.clear(); | 144 | mMailAttachFiles.clear(); |
145 | break; | 145 | break; |
146 | case Invalid: | 146 | case Invalid: |
147 | break; | 147 | break; |
148 | default: | 148 | default: |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | mType = type; | 151 | mType = type; |
152 | mParent->updated(); | 152 | mParent->updated(); |
153 | } | 153 | } |
154 | 154 | ||
155 | Alarm::Type Alarm::type() const | 155 | Alarm::Type Alarm::type() const |
156 | { | 156 | { |
157 | return mType; | 157 | return mType; |
158 | } | 158 | } |
159 | 159 | ||
160 | void Alarm::setAudioAlarm(const QString &audioFile) | 160 | void Alarm::setAudioAlarm(const QString &audioFile) |
161 | { | 161 | { |
162 | mType = Audio; | 162 | mType = Audio; |
163 | mFile = audioFile; | 163 | mFile = audioFile; |
164 | mParent->updated(); | 164 | mParent->updated(); |
165 | } | 165 | } |
166 | 166 | ||
167 | void Alarm::setAudioFile(const QString &audioFile) | 167 | void Alarm::setAudioFile(const QString &audioFile) |
168 | { | 168 | { |
169 | if (mType == Audio) { | 169 | if (mType == Audio) { |
170 | mFile = audioFile; | 170 | mFile = audioFile; |
171 | mParent->updated(); | 171 | mParent->updated(); |
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | QString Alarm::audioFile() const | 175 | QString Alarm::audioFile() const |
176 | { | 176 | { |
177 | return (mType == Audio) ? mFile : QString::null; | 177 | return (mType == Audio) ? mFile : QString::null; |
178 | } | 178 | } |
179 | 179 | ||
180 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) | 180 | void Alarm::setProcedureAlarm(const QString &programFile, const QString &arguments) |
181 | { | 181 | { |
182 | mType = Procedure; | 182 | mType = Procedure; |
183 | mFile = programFile; | 183 | mFile = programFile; |
184 | mDescription = arguments; | 184 | mDescription = arguments; |
185 | mParent->updated(); | 185 | mParent->updated(); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Alarm::setProgramFile(const QString &programFile) | 188 | void Alarm::setProgramFile(const QString &programFile) |
189 | { | 189 | { |
190 | if (mType == Procedure) { | 190 | if (mType == Procedure) { |
191 | mFile = programFile; | 191 | mFile = programFile; |
192 | mParent->updated(); | 192 | mParent->updated(); |
193 | } | 193 | } |
194 | } | 194 | } |
195 | 195 | ||
196 | QString Alarm::programFile() const | 196 | QString Alarm::programFile() const |
197 | { | 197 | { |
198 | return (mType == Procedure) ? mFile : QString::null; | 198 | return (mType == Procedure) ? mFile : QString::null; |
199 | } | 199 | } |
200 | 200 | ||
201 | void Alarm::setProgramArguments(const QString &arguments) | 201 | void Alarm::setProgramArguments(const QString &arguments) |
202 | { | 202 | { |
203 | if (mType == Procedure) { | 203 | if (mType == Procedure) { |
204 | mDescription = arguments; | 204 | mDescription = arguments; |
205 | mParent->updated(); | 205 | mParent->updated(); |
206 | } | 206 | } |
207 | } | 207 | } |
208 | 208 | ||
209 | QString Alarm::programArguments() const | 209 | QString Alarm::programArguments() const |
210 | { | 210 | { |
211 | return (mType == Procedure) ? mDescription : QString::null; | 211 | return (mType == Procedure) ? mDescription : QString::null; |
212 | } | 212 | } |
213 | 213 | ||
214 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, | 214 | void Alarm::setEmailAlarm(const QString &subject, const QString &text, |
215 | const QValueList<Person> &addressees, const QStringList &attachments) | 215 | const QValueList<Person> &addressees, const QStringList &attachments) |
216 | { | 216 | { |
217 | mType = Email; | 217 | mType = Email; |
218 | mMailSubject = subject; | 218 | mMailSubject = subject; |
219 | mDescription = text; | 219 | mDescription = text; |
220 | mMailAddresses = addressees; | 220 | mMailAddresses = addressees; |
221 | mMailAttachFiles = attachments; | 221 | mMailAttachFiles = attachments; |
222 | mParent->updated(); | 222 | mParent->updated(); |
223 | } | 223 | } |
224 | 224 | ||
225 | void Alarm::setMailAddress(const Person &mailAddress) | 225 | void Alarm::setMailAddress(const Person &mailAddress) |
226 | { | 226 | { |
227 | if (mType == Email) { | 227 | if (mType == Email) { |
228 | mMailAddresses.clear(); | 228 | mMailAddresses.clear(); |
229 | mMailAddresses += mailAddress; | 229 | mMailAddresses += mailAddress; |
230 | mParent->updated(); | 230 | mParent->updated(); |
231 | } | 231 | } |
232 | } | 232 | } |
233 | 233 | ||
234 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) | 234 | void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) |
235 | { | 235 | { |
236 | if (mType == Email) { | 236 | if (mType == Email) { |
237 | mMailAddresses = mailAddresses; | 237 | mMailAddresses = mailAddresses; |
238 | mParent->updated(); | 238 | mParent->updated(); |
239 | } | 239 | } |
240 | } | 240 | } |
241 | 241 | ||
242 | void Alarm::addMailAddress(const Person &mailAddress) | 242 | void Alarm::addMailAddress(const Person &mailAddress) |
243 | { | 243 | { |
244 | if (mType == Email) { | 244 | if (mType == Email) { |
245 | mMailAddresses += mailAddress; | 245 | mMailAddresses += mailAddress; |
246 | mParent->updated(); | 246 | mParent->updated(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | QValueList<Person> Alarm::mailAddresses() const | 250 | QValueList<Person> Alarm::mailAddresses() const |
251 | { | 251 | { |
252 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); | 252 | return (mType == Email) ? mMailAddresses : QValueList<Person>(); |
253 | } | 253 | } |
254 | 254 | ||
255 | void Alarm::setMailSubject(const QString &mailAlarmSubject) | 255 | void Alarm::setMailSubject(const QString &mailAlarmSubject) |
256 | { | 256 | { |
257 | if (mType == Email) { | 257 | if (mType == Email) { |
258 | mMailSubject = mailAlarmSubject; | 258 | mMailSubject = mailAlarmSubject; |
259 | mParent->updated(); | 259 | mParent->updated(); |
260 | } | 260 | } |
261 | } | 261 | } |
262 | 262 | ||
263 | QString Alarm::mailSubject() const | 263 | QString Alarm::mailSubject() const |
264 | { | 264 | { |
265 | return (mType == Email) ? mMailSubject : QString::null; | 265 | return (mType == Email) ? mMailSubject : QString::null; |
266 | } | 266 | } |
267 | 267 | ||
268 | void Alarm::setMailAttachment(const QString &mailAttachFile) | 268 | void Alarm::setMailAttachment(const QString &mailAttachFile) |
269 | { | 269 | { |
270 | if (mType == Email) { | 270 | if (mType == Email) { |
271 | mMailAttachFiles.clear(); | 271 | mMailAttachFiles.clear(); |
272 | mMailAttachFiles += mailAttachFile; | 272 | mMailAttachFiles += mailAttachFile; |
273 | mParent->updated(); | 273 | mParent->updated(); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | 276 | ||
277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) | 277 | void Alarm::setMailAttachments(const QStringList &mailAttachFiles) |
278 | { | 278 | { |
279 | if (mType == Email) { | 279 | if (mType == Email) { |
280 | mMailAttachFiles = mailAttachFiles; | 280 | mMailAttachFiles = mailAttachFiles; |
281 | mParent->updated(); | 281 | mParent->updated(); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | 284 | ||
285 | void Alarm::addMailAttachment(const QString &mailAttachFile) | 285 | void Alarm::addMailAttachment(const QString &mailAttachFile) |
286 | { | 286 | { |
287 | if (mType == Email) { | 287 | if (mType == Email) { |
288 | mMailAttachFiles += mailAttachFile; | 288 | mMailAttachFiles += mailAttachFile; |
289 | mParent->updated(); | 289 | mParent->updated(); |
290 | } | 290 | } |
291 | } | 291 | } |
292 | 292 | ||
293 | QStringList Alarm::mailAttachments() const | 293 | QStringList Alarm::mailAttachments() const |
294 | { | 294 | { |
295 | return (mType == Email) ? mMailAttachFiles : QStringList(); | 295 | return (mType == Email) ? mMailAttachFiles : QStringList(); |
296 | } | 296 | } |
297 | 297 | ||
298 | void Alarm::setMailText(const QString &text) | 298 | void Alarm::setMailText(const QString &text) |
299 | { | 299 | { |
300 | if (mType == Email) { | 300 | if (mType == Email) { |
301 | mDescription = text; | 301 | mDescription = text; |
302 | mParent->updated(); | 302 | mParent->updated(); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | QString Alarm::mailText() const | 306 | QString Alarm::mailText() const |
307 | { | 307 | { |
308 | return (mType == Email) ? mDescription : QString::null; | 308 | return (mType == Email) ? mDescription : QString::null; |
309 | } | 309 | } |
310 | 310 | ||
311 | void Alarm::setDisplayAlarm(const QString &text) | 311 | void Alarm::setDisplayAlarm(const QString &text) |
312 | { | 312 | { |
313 | mType = Display; | 313 | mType = Display; |
314 | mDescription = text; | 314 | mDescription = text; |
315 | mParent->updated(); | 315 | mParent->updated(); |
316 | } | 316 | } |
317 | 317 | ||
318 | void Alarm::setText(const QString &text) | 318 | void Alarm::setText(const QString &text) |
319 | { | 319 | { |
320 | if (mType == Display) { | 320 | if (mType == Display) { |
321 | mDescription = text; | 321 | mDescription = text; |
322 | mParent->updated(); | 322 | mParent->updated(); |
323 | } | 323 | } |
324 | } | 324 | } |
325 | 325 | ||
326 | QString Alarm::text() const | 326 | QString Alarm::text() const |
327 | { | 327 | { |
328 | return (mType == Display) ? mDescription : QString::null; | 328 | return (mType == Display) ? mDescription : QString::null; |
329 | } | 329 | } |
330 | 330 | ||
331 | void Alarm::setTime(const QDateTime &alarmTime) | 331 | void Alarm::setTime(const QDateTime &alarmTime) |
332 | { | 332 | { |
333 | mAlarmTime = alarmTime; | 333 | mAlarmTime = alarmTime; |
334 | mHasTime = true; | 334 | mHasTime = true; |
335 | 335 | ||
336 | mParent->updated(); | 336 | mParent->updated(); |
337 | } | 337 | } |
338 | int Alarm::offset() | 338 | int Alarm::offset() |
339 | { | 339 | { |
340 | if ( hasTime() ) { | 340 | if ( hasTime() ) { |
341 | if (mParent->type()=="Todo") { | 341 | if (mParent->type()=="Todo") { |
342 | Todo *t = static_cast<Todo*>(mParent); | 342 | Todo *t = static_cast<Todo*>(mParent); |
343 | return t->dtDue().secsTo( mAlarmTime ) ; | 343 | return t->dtDue().secsTo( mAlarmTime ) ; |
344 | } else | 344 | } else |
345 | return mParent->dtStart().secsTo( mAlarmTime ) ; | 345 | return mParent->dtStart().secsTo( mAlarmTime ) ; |
346 | } | 346 | } |
347 | else | 347 | else |
348 | { | 348 | { |
349 | return mOffset.asSeconds(); | 349 | return mOffset.asSeconds(); |
350 | } | 350 | } |
351 | 351 | ||
352 | } | 352 | } |
353 | QString Alarm::offsetText() | 353 | QString Alarm::offsetText() |
354 | { | 354 | { |
355 | int min = -offset()/60; | 355 | int min = -offset()/60; |
356 | int hours = min /60; | 356 | int hours = min /60; |
357 | min = min % 60; | 357 | min = min % 60; |
358 | int days = hours /24; | 358 | int days = hours /24; |
359 | hours = hours % 24; | 359 | hours = hours % 24; |
360 | QString message; | 360 | QString message; |
361 | qDebug("%d %d %d ", days, hours, min ); | 361 | //qDebug("%d %d %d ", days, hours, min ); |
362 | if ( days > 0 ) | 362 | if ( days > 0 ) |
363 | message += i18n("%1d").arg( days ); | 363 | message += i18n("%1d").arg( days ); |
364 | if ( hours > 0 ) { | 364 | if ( hours > 0 ) { |
365 | if ( !message.isEmpty() ) message += "/"; | 365 | if ( !message.isEmpty() ) message += "/"; |
366 | message += i18n("%1h").arg( hours ); | 366 | message += i18n("%1h").arg( hours ); |
367 | } | 367 | } |
368 | if ( min > 0 ) { | 368 | if ( min > 0 ) { |
369 | if ( !message.isEmpty() ) message += "/"; | 369 | if ( !message.isEmpty() ) message += "/"; |
370 | message += i18n("%1min").arg( min ); | 370 | message += i18n("%1min").arg( min ); |
371 | } | 371 | } |
372 | if ( message.isEmpty() ) | 372 | if ( message.isEmpty() ) |
373 | message = i18n("%1min").arg( 0 ); | 373 | message = i18n("%1min").arg( 0 ); |
374 | return message; | 374 | return message; |
375 | } | 375 | } |
376 | 376 | ||
377 | 377 | ||
378 | QDateTime Alarm::time() const | 378 | QDateTime Alarm::time() const |
379 | { | 379 | { |
380 | if ( hasTime() ) | 380 | if ( hasTime() ) |
381 | return mAlarmTime; | 381 | return mAlarmTime; |
382 | else | 382 | else |
383 | { | 383 | { |
384 | if (mParent->type()=="Todo") { | 384 | if (mParent->type()=="Todo") { |
385 | Todo *t = static_cast<Todo*>(mParent); | 385 | Todo *t = static_cast<Todo*>(mParent); |
386 | return mOffset.end( t->dtDue() ); | 386 | return mOffset.end( t->dtDue() ); |
387 | } else if (mEndOffset) { | 387 | } else if (mEndOffset) { |
388 | return mOffset.end( mParent->dtEnd() ); | 388 | return mOffset.end( mParent->dtEnd() ); |
389 | } else { | 389 | } else { |
390 | return mOffset.end( mParent->dtStart() ); | 390 | return mOffset.end( mParent->dtStart() ); |
391 | } | 391 | } |
392 | } | 392 | } |
393 | } | 393 | } |
394 | 394 | ||
395 | bool Alarm::hasTime() const | 395 | bool Alarm::hasTime() const |
396 | { | 396 | { |
397 | return mHasTime; | 397 | return mHasTime; |
398 | } | 398 | } |
399 | 399 | ||
400 | void Alarm::setSnoozeTime(int alarmSnoozeTime) | 400 | void Alarm::setSnoozeTime(int alarmSnoozeTime) |
401 | { | 401 | { |
402 | mAlarmSnoozeTime = alarmSnoozeTime; | 402 | mAlarmSnoozeTime = alarmSnoozeTime; |
403 | mParent->updated(); | 403 | mParent->updated(); |
404 | } | 404 | } |
405 | 405 | ||
406 | int Alarm::snoozeTime() const | 406 | int Alarm::snoozeTime() const |
407 | { | 407 | { |
408 | return mAlarmSnoozeTime; | 408 | return mAlarmSnoozeTime; |
409 | } | 409 | } |
410 | 410 | ||
411 | void Alarm::setRepeatCount(int alarmRepeatCount) | 411 | void Alarm::setRepeatCount(int alarmRepeatCount) |
412 | { | 412 | { |
413 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; | 413 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; |
414 | 414 | ||
415 | mAlarmRepeatCount = alarmRepeatCount; | 415 | mAlarmRepeatCount = alarmRepeatCount; |
416 | mParent->updated(); | 416 | mParent->updated(); |
417 | } | 417 | } |
418 | 418 | ||
419 | int Alarm::repeatCount() const | 419 | int Alarm::repeatCount() const |
420 | { | 420 | { |
421 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; | 421 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; |
422 | return mAlarmRepeatCount; | 422 | return mAlarmRepeatCount; |
423 | } | 423 | } |
424 | 424 | ||
425 | void Alarm::toggleAlarm() | 425 | void Alarm::toggleAlarm() |
426 | { | 426 | { |
427 | mAlarmEnabled = !mAlarmEnabled; | 427 | mAlarmEnabled = !mAlarmEnabled; |
428 | mParent->updated(); | 428 | mParent->updated(); |
429 | } | 429 | } |
430 | 430 | ||
431 | void Alarm::setEnabled(bool enable) | 431 | void Alarm::setEnabled(bool enable) |
432 | { | 432 | { |
433 | mAlarmEnabled = enable; | 433 | mAlarmEnabled = enable; |
434 | mParent->updated(); | 434 | mParent->updated(); |
435 | } | 435 | } |
436 | 436 | ||
437 | bool Alarm::enabled() const | 437 | bool Alarm::enabled() const |
438 | { | 438 | { |
439 | return mAlarmEnabled; | 439 | return mAlarmEnabled; |
440 | } | 440 | } |
441 | 441 | ||
442 | void Alarm::setStartOffset( const Duration &offset ) | 442 | void Alarm::setStartOffset( const Duration &offset ) |
443 | { | 443 | { |
444 | mOffset = offset; | 444 | mOffset = offset; |
445 | mEndOffset = false; | 445 | mEndOffset = false; |
446 | mHasTime = false; | 446 | mHasTime = false; |
447 | mParent->updated(); | 447 | mParent->updated(); |
448 | } | 448 | } |
449 | 449 | ||
450 | Duration Alarm::startOffset() const | 450 | Duration Alarm::startOffset() const |
451 | { | 451 | { |
452 | return (mHasTime || mEndOffset) ? 0 : mOffset; | 452 | return (mHasTime || mEndOffset) ? 0 : mOffset; |
453 | } | 453 | } |
454 | 454 | ||
455 | bool Alarm::hasStartOffset() const | 455 | bool Alarm::hasStartOffset() const |
456 | { | 456 | { |
457 | return !mHasTime && !mEndOffset; | 457 | return !mHasTime && !mEndOffset; |
458 | } | 458 | } |
459 | 459 | ||
460 | bool Alarm::hasEndOffset() const | 460 | bool Alarm::hasEndOffset() const |
461 | { | 461 | { |
462 | return !mHasTime && mEndOffset; | 462 | return !mHasTime && mEndOffset; |
463 | } | 463 | } |
464 | 464 | ||
465 | void Alarm::setEndOffset( const Duration &offset ) | 465 | void Alarm::setEndOffset( const Duration &offset ) |
466 | { | 466 | { |
467 | mOffset = offset; | 467 | mOffset = offset; |
468 | mEndOffset = true; | 468 | mEndOffset = true; |
469 | mHasTime = false; | 469 | mHasTime = false; |
470 | mParent->updated(); | 470 | mParent->updated(); |
471 | } | 471 | } |
472 | 472 | ||
473 | Duration Alarm::endOffset() const | 473 | Duration Alarm::endOffset() const |
474 | { | 474 | { |
475 | return (mHasTime || !mEndOffset) ? 0 : mOffset; | 475 | return (mHasTime || !mEndOffset) ? 0 : mOffset; |
476 | } | 476 | } |
477 | 477 | ||
478 | void Alarm::setParent( Incidence *parent ) | 478 | void Alarm::setParent( Incidence *parent ) |
479 | { | 479 | { |
480 | mParent = parent; | 480 | mParent = parent; |
481 | } | 481 | } |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index 8ae5b46..7d61b7f 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -1,422 +1,422 @@ | |||
1 | #include "kincidenceformatter.h" | 1 | #include "kincidenceformatter.h" |
2 | #include <kstaticdeleter.h> | 2 | #include <kstaticdeleter.h> |
3 | #include <kglobal.h> | 3 | #include <kglobal.h> |
4 | #include <klocale.h> | 4 | #include <klocale.h> |
5 | #ifdef DEKTOP_VERSION | 5 | #ifdef DEKTOP_VERSION |
6 | #include <kabc/stdaddressbook.h> | 6 | #include <kabc/stdaddressbook.h> |
7 | #define size count | 7 | #define size count |
8 | #endif | 8 | #endif |
9 | 9 | ||
10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; | 10 | KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; |
11 | static KStaticDeleter<KIncidenceFormatter> insd; | 11 | static KStaticDeleter<KIncidenceFormatter> insd; |
12 | 12 | ||
13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) | 13 | QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) |
14 | { | 14 | { |
15 | // #ifndef QT_NO_INPUTDIALOG | 15 | // #ifndef QT_NO_INPUTDIALOG |
16 | // return QInputDialog::getItem( caption, label, items, current, editable ); | 16 | // return QInputDialog::getItem( caption, label, items, current, editable ); |
17 | // #else | 17 | // #else |
18 | // return QString::null; | 18 | // return QString::null; |
19 | // #endif | 19 | // #endif |
20 | mDetails = details; | 20 | mDetails = details; |
21 | mCreated = created ; | 21 | mCreated = created ; |
22 | mModified = modified; | 22 | mModified = modified; |
23 | mText = ""; | 23 | mText = ""; |
24 | if ( inc->type() == "Event" ) | 24 | if ( inc->type() == "Event" ) |
25 | setEvent((Event *) inc ); | 25 | setEvent((Event *) inc ); |
26 | else if ( inc->type() == "Todo" ) | 26 | else if ( inc->type() == "Todo" ) |
27 | setTodo((Todo *) inc ); | 27 | setTodo((Todo *) inc ); |
28 | return mText; | 28 | return mText; |
29 | } | 29 | } |
30 | 30 | ||
31 | KIncidenceFormatter* KIncidenceFormatter::instance() | 31 | KIncidenceFormatter* KIncidenceFormatter::instance() |
32 | { | 32 | { |
33 | if (!mInstance) { | 33 | if (!mInstance) { |
34 | mInstance = insd.setObject(new KIncidenceFormatter()); | 34 | mInstance = insd.setObject(new KIncidenceFormatter()); |
35 | } | 35 | } |
36 | return mInstance; | 36 | return mInstance; |
37 | } | 37 | } |
38 | KIncidenceFormatter::~KIncidenceFormatter() | 38 | KIncidenceFormatter::~KIncidenceFormatter() |
39 | { | 39 | { |
40 | if (mInstance == this) | 40 | if (mInstance == this) |
41 | mInstance = insd.setObject(0); | 41 | mInstance = insd.setObject(0); |
42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); | 42 | //qDebug("KIncidenceFormatter::~KIncidenceFormatter "); |
43 | } | 43 | } |
44 | KIncidenceFormatter::KIncidenceFormatter() | 44 | KIncidenceFormatter::KIncidenceFormatter() |
45 | { | 45 | { |
46 | mColorMode = 0; | 46 | mColorMode = 0; |
47 | } | 47 | } |
48 | void KIncidenceFormatter::setEvent(Event *event) | 48 | void KIncidenceFormatter::setEvent(Event *event) |
49 | { | 49 | { |
50 | int mode = 0; | 50 | int mode = 0; |
51 | mCurrentIncidence = event; | 51 | mCurrentIncidence = event; |
52 | bool shortDate = true; | 52 | bool shortDate = true; |
53 | if ( mode == 0 ) { | 53 | if ( mode == 0 ) { |
54 | addTag("h3",deTag(event->summary())); | 54 | addTag("h3",deTag(event->summary())); |
55 | } | 55 | } |
56 | else { | 56 | else { |
57 | if ( mColorMode == 1 ) { | 57 | if ( mColorMode == 1 ) { |
58 | mText +="<font color=\"#00A000\">"; | 58 | mText +="<font color=\"#00A000\">"; |
59 | } | 59 | } |
60 | if ( mColorMode == 2 ) { | 60 | if ( mColorMode == 2 ) { |
61 | mText +="<font color=\"#C00000\">"; | 61 | mText +="<font color=\"#C00000\">"; |
62 | } | 62 | } |
63 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; | 63 | // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; |
64 | if ( mode == 1 ) { | 64 | if ( mode == 1 ) { |
65 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 65 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
66 | } else { | 66 | } else { |
67 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 67 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
68 | } | 68 | } |
69 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 69 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
70 | if ( mColorMode ) | 70 | if ( mColorMode ) |
71 | mText += "</font>"; | 71 | mText += "</font>"; |
72 | } | 72 | } |
73 | if (event->cancelled ()) { | 73 | if (event->cancelled ()) { |
74 | mText +="<font color=\"#B00000\">"; | 74 | mText +="<font color=\"#B00000\">"; |
75 | addTag("i",i18n("This event has been cancelled!")); | 75 | addTag("i",i18n("This event has been cancelled!")); |
76 | mText.append("<br>"); | 76 | mText.append("<br>"); |
77 | mText += "</font>"; | 77 | mText += "</font>"; |
78 | } | 78 | } |
79 | if (event->doesFloat()) { | 79 | if (event->doesFloat()) { |
80 | if (event->isMultiDay()) { | 80 | if (event->isMultiDay()) { |
81 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") | 81 | mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") |
82 | .arg(event->dtStartDateStr(shortDate)) | 82 | .arg(event->dtStartDateStr(shortDate)) |
83 | .arg(event->dtEndDateStr(shortDate))); | 83 | .arg(event->dtEndDateStr(shortDate))); |
84 | } else { | 84 | } else { |
85 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 85 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
86 | } | 86 | } |
87 | } else { | 87 | } else { |
88 | if (event->isMultiDay()) { | 88 | if (event->isMultiDay()) { |
89 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 89 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
90 | .arg(event->dtStartStr( shortDate))); | 90 | .arg(event->dtStartStr( shortDate))); |
91 | mText.append(i18n("<p><b>To:</b> %1</p>") | 91 | mText.append(i18n("<p><b>To:</b> %1</p>") |
92 | .arg(event->dtEndStr(shortDate))); | 92 | .arg(event->dtEndStr(shortDate))); |
93 | } else { | 93 | } else { |
94 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 94 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
95 | .arg(event->dtStartTimeStr()) | 95 | .arg(event->dtStartTimeStr()) |
96 | .arg(event->dtEndTimeStr())); | 96 | .arg(event->dtEndTimeStr())); |
97 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 97 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
98 | .arg(event->dtStartDateStr( shortDate ))); | 98 | .arg(event->dtStartDateStr( shortDate ))); |
99 | } | 99 | } |
100 | } | 100 | } |
101 | if (!event->location().isEmpty()) { | 101 | if (!event->location().isEmpty()) { |
102 | addTag("b",i18n("Location: ")); | 102 | addTag("b",i18n("Location: ")); |
103 | mText.append(deTag(event->location())+"<br>"); | 103 | mText.append(deTag(event->location())+"<br>"); |
104 | } | 104 | } |
105 | 105 | ||
106 | if (event->recurrence()->doesRecur()) { | 106 | if (event->recurrence()->doesRecur()) { |
107 | 107 | ||
108 | QString recurText = event->recurrence()->recurrenceText(); | 108 | QString recurText = event->recurrence()->recurrenceText(); |
109 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); | 109 | addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); |
110 | 110 | ||
111 | bool ok; | 111 | bool ok; |
112 | QDate start = QDate::currentDate(); | 112 | QDate start = QDate::currentDate(); |
113 | QDateTime next; | 113 | QDateTime next; |
114 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); | 114 | next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); |
115 | if ( ok ) { | 115 | if ( ok ) { |
116 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); | 116 | addTag("p",i18n("<b>Next recurrence is on:</b>") ); |
117 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); | 117 | addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); |
118 | 118 | ||
119 | } else { | 119 | } else { |
120 | bool last; | 120 | bool last; |
121 | QDate nextd; | 121 | QDate nextd; |
122 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); | 122 | nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); |
123 | if ( last ) { | 123 | if ( last ) { |
124 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); | 124 | addTag("p",i18n("<b>Last recurrence was on:</b>") ); |
125 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); | 125 | addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); |
126 | } | 126 | } |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | 130 | ||
131 | if (event->isAlarmEnabled()) { | 131 | if (event->isAlarmEnabled()) { |
132 | Alarm *alarm =event->alarms().first() ; | 132 | Alarm *alarm =event->alarms().first() ; |
133 | QDateTime t = alarm->time(); | 133 | QDateTime t = alarm->time(); |
134 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 134 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
135 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); | 135 | addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); |
136 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 136 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
137 | //addTag("p",s); | 137 | //addTag("p",s); |
138 | } | 138 | } |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 142 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
143 | // mText.append(event->secrecyStr()+"<br>"); | 143 | // mText.append(event->secrecyStr()+"<br>"); |
144 | formatCategories(event); | 144 | formatCategories(event); |
145 | 145 | ||
146 | formatReadOnly(event); | 146 | formatReadOnly(event); |
147 | formatAttendees(event); | 147 | formatAttendees(event); |
148 | 148 | ||
149 | if ( mCreated ) { | 149 | if ( mCreated ) { |
150 | #ifdef DESKTOP_VERSION | 150 | #ifdef DESKTOP_VERSION |
151 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 151 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
152 | #else | 152 | #else |
153 | addTag("p",i18n("<b>Created: ") +" </b>"); | 153 | addTag("p",i18n("<b>Created: ") +" </b>"); |
154 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 154 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
155 | #endif | 155 | #endif |
156 | 156 | ||
157 | } | 157 | } |
158 | if ( mModified ) { | 158 | if ( mModified ) { |
159 | #ifdef DESKTOP_VERSION | 159 | #ifdef DESKTOP_VERSION |
160 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 160 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
161 | #else | 161 | #else |
162 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 162 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
163 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 163 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
164 | #endif | 164 | #endif |
165 | 165 | ||
166 | } | 166 | } |
167 | if ( mDetails ) { | 167 | if ( mDetails ) { |
168 | if (!event->description().isEmpty()) { | 168 | if (!event->description().isEmpty()) { |
169 | addTag("p",i18n("<b>Details: </b>")); | 169 | addTag("p",i18n("<b>Details: </b>")); |
170 | addTag("p",deTag(event->description())); | 170 | addTag("p",deTag(event->description())); |
171 | } | 171 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | } | 174 | } |
175 | 175 | ||
176 | void KIncidenceFormatter::setTodo(Todo *event ) | 176 | void KIncidenceFormatter::setTodo(Todo *event ) |
177 | { | 177 | { |
178 | int mode = 0; | 178 | int mode = 0; |
179 | mCurrentIncidence = event; | 179 | mCurrentIncidence = event; |
180 | bool shortDate = true; | 180 | bool shortDate = true; |
181 | if (mode == 0 ) | 181 | if (mode == 0 ) |
182 | addTag("h3",deTag(event->summary())); | 182 | addTag("h3",deTag(event->summary())); |
183 | else { | 183 | else { |
184 | if ( mColorMode == 1 ) { | 184 | if ( mColorMode == 1 ) { |
185 | mText +="<font color=\"#00A000\">"; | 185 | mText +="<font color=\"#00A000\">"; |
186 | } | 186 | } |
187 | if ( mColorMode == 2 ) { | 187 | if ( mColorMode == 2 ) { |
188 | mText +="<font color=\"#B00000\">"; | 188 | mText +="<font color=\"#B00000\">"; |
189 | } | 189 | } |
190 | if ( mode == 1 ) { | 190 | if ( mode == 1 ) { |
191 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 191 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
192 | } else { | 192 | } else { |
193 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 193 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
194 | } | 194 | } |
195 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 195 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
196 | if ( mColorMode ) | 196 | if ( mColorMode ) |
197 | mText += "</font>"; | 197 | mText += "</font>"; |
198 | } | 198 | } |
199 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 199 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
200 | mText +="<font color=\"#B00000\">"; | 200 | mText +="<font color=\"#B00000\">"; |
201 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 201 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
202 | mText += "</font>"; | 202 | mText += "</font>"; |
203 | } else { | 203 | } else { |
204 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 204 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
205 | .arg(event->percentComplete())); | 205 | .arg(event->percentComplete())); |
206 | } | 206 | } |
207 | if (event->cancelled ()) { | 207 | if (event->cancelled ()) { |
208 | mText +="<font color=\"#B00000\">"; | 208 | mText +="<font color=\"#B00000\">"; |
209 | addTag("i",i18n("This todo has been cancelled!")); | 209 | addTag("i",i18n("This todo has been cancelled!")); |
210 | mText.append("<br>"); | 210 | mText.append("<br>"); |
211 | mText += "</font>"; | 211 | mText += "</font>"; |
212 | } | 212 | } |
213 | 213 | ||
214 | 214 | ||
215 | if (event->recurrence()->doesRecur()) { | 215 | if (event->recurrence()->doesRecur()) { |
216 | 216 | ||
217 | QString recurText = event->recurrence()->recurrenceText(); | 217 | QString recurText = event->recurrence()->recurrenceText(); |
218 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 218 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
219 | } | 219 | } |
220 | 220 | ||
221 | if (event->hasStartDate()) { | 221 | if (event->hasStartDate()) { |
222 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | 222 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); |
223 | } | 223 | } |
224 | 224 | ||
225 | 225 | ||
226 | if (event->hasDueDate()) { | 226 | if (event->hasDueDate()) { |
227 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 227 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
228 | } | 228 | } |
229 | 229 | ||
230 | if (!event->location().isEmpty()) { | 230 | if (!event->location().isEmpty()) { |
231 | addTag("b",i18n("Location: ")); | 231 | addTag("b",i18n("Location: ")); |
232 | mText.append(deTag(event->location())+"<br>"); | 232 | mText.append(deTag(event->location())+"<br>"); |
233 | } | 233 | } |
234 | 234 | ||
235 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 235 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
236 | .arg(QString::number(event->priority()))); | 236 | .arg(QString::number(event->priority()))); |
237 | 237 | ||
238 | if (event->isAlarmEnabled()) { | 238 | if (event->isAlarmEnabled()) { |
239 | Alarm *alarm =event->alarms().first() ; | 239 | Alarm *alarm =event->alarms().first() ; |
240 | QDateTime t = alarm->time(); | 240 | QDateTime t = alarm->time(); |
241 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | 241 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
242 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | 242 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); |
243 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 243 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
244 | //addTag("p",s); | 244 | //addTag("p",s); |
245 | } | 245 | } |
246 | 246 | ||
247 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 247 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
248 | formatCategories(event); | 248 | formatCategories(event); |
249 | 249 | ||
250 | formatReadOnly(event); | 250 | formatReadOnly(event); |
251 | formatAttendees(event); | 251 | formatAttendees(event); |
252 | if ( mCreated ) { | 252 | if ( mCreated ) { |
253 | #ifdef DESKTOP_VERSION | 253 | #ifdef DESKTOP_VERSION |
254 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 254 | addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
255 | #else | 255 | #else |
256 | addTag("p",i18n("<b>Created: ") +" </b>"); | 256 | addTag("p",i18n("<b>Created: ") +" </b>"); |
257 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 257 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
258 | #endif | 258 | #endif |
259 | 259 | ||
260 | } | 260 | } |
261 | if ( mModified ) { | 261 | if ( mModified ) { |
262 | #ifdef DESKTOP_VERSION | 262 | #ifdef DESKTOP_VERSION |
263 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 263 | addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
264 | #else | 264 | #else |
265 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 265 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
266 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 266 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
267 | #endif | 267 | #endif |
268 | 268 | ||
269 | } | 269 | } |
270 | if ( mDetails ) { | 270 | if ( mDetails ) { |
271 | if (!event->description().isEmpty()) { | 271 | if (!event->description().isEmpty()) { |
272 | addTag("p",i18n("<b>Details: </b>")); | 272 | addTag("p",i18n("<b>Details: </b>")); |
273 | addTag("p",deTag(event->description())); | 273 | addTag("p",deTag(event->description())); |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | void KIncidenceFormatter::setJournal(Journal* ) | 278 | void KIncidenceFormatter::setJournal(Journal* ) |
279 | { | 279 | { |
280 | 280 | ||
281 | } | 281 | } |
282 | 282 | ||
283 | void KIncidenceFormatter::formatCategories(Incidence *event) | 283 | void KIncidenceFormatter::formatCategories(Incidence *event) |
284 | { | 284 | { |
285 | if (!event->categoriesStr().isEmpty()) { | 285 | if (!event->categoriesStr().isEmpty()) { |
286 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 286 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); |
287 | //mText.append(event->categoriesStr()); | 287 | //mText.append(event->categoriesStr()); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 290 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
291 | { | 291 | { |
292 | int number=text.contains("\n"); | 292 | int number=text.contains("\n"); |
293 | QString str = "<" + tag + ">"; | 293 | QString str = "<" + tag + ">"; |
294 | QString tmpText=text; | 294 | QString tmpText=text; |
295 | QString tmpStr=str; | 295 | QString tmpStr=str; |
296 | if(number !=-1) | 296 | if(number !=-1) |
297 | { | 297 | { |
298 | if (number > 0) { | 298 | if (number > 0) { |
299 | int pos=0; | 299 | int pos=0; |
300 | QString tmp; | 300 | QString tmp; |
301 | for(int i=0;i<=number;i++) { | 301 | for(int i=0;i<=number;i++) { |
302 | pos=tmpText.find("\n"); | 302 | pos=tmpText.find("\n"); |
303 | tmp=tmpText.left(pos); | 303 | tmp=tmpText.left(pos); |
304 | tmpText=tmpText.right(tmpText.length()-pos-1); | 304 | tmpText=tmpText.right(tmpText.length()-pos-1); |
305 | tmpStr+=tmp+"<br>"; | 305 | tmpStr+=tmp+"<br>"; |
306 | } | 306 | } |
307 | } | 307 | } |
308 | else tmpStr += tmpText; | 308 | else tmpStr += tmpText; |
309 | tmpStr+="</" + tag + ">"; | 309 | tmpStr+="</" + tag + ">"; |
310 | mText.append(tmpStr); | 310 | mText.append(tmpStr); |
311 | } | 311 | } |
312 | else | 312 | else |
313 | { | 313 | { |
314 | str += text + "</" + tag + ">"; | 314 | str += text + "</" + tag + ">"; |
315 | mText.append(str); | 315 | mText.append(str); |
316 | } | 316 | } |
317 | } | 317 | } |
318 | 318 | ||
319 | void KIncidenceFormatter::formatAttendees(Incidence *event) | 319 | void KIncidenceFormatter::formatAttendees(Incidence *event) |
320 | { | 320 | { |
321 | QPtrList<Attendee> attendees = event->attendees(); | 321 | QPtrList<Attendee> attendees = event->attendees(); |
322 | if (attendees.count()) { | 322 | if (attendees.count()) { |
323 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); | 323 | QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); |
324 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); | 324 | QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); |
325 | addTag("h3",i18n("Organizer")); | 325 | addTag("h3",i18n("Organizer")); |
326 | mText.append("<ul><li>"); | 326 | mText.append("<ul><li>"); |
327 | #if 0 | 327 | #if 0 |
328 | //ndef KORG_NOKABC | 328 | //ndef KORG_NOKABC |
329 | 329 | ||
330 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); | 330 | KABC::AddressBook *add_book = KABC::StdAddressBook::self(); |
331 | KABC::Addressee::List addressList; | 331 | KABC::Addressee::List addressList; |
332 | addressList = add_book->findByEmail(event->organizer()); | 332 | addressList = add_book->findByEmail(event->organizer()); |
333 | KABC::Addressee o = addressList.first(); | 333 | KABC::Addressee o = addressList.first(); |
334 | if (!o.isEmpty() && addressList.size()<2) { | 334 | if (!o.isEmpty() && addressList.size()<2) { |
335 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 335 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
336 | mText += o.formattedName(); | 336 | mText += o.formattedName(); |
337 | mText += "</a>\n"; | 337 | mText += "</a>\n"; |
338 | } else { | 338 | } else { |
339 | mText.append(event->organizer()); | 339 | mText.append(event->organizer()); |
340 | } | 340 | } |
341 | #else | 341 | #else |
342 | mText.append(event->organizer()); | 342 | mText.append(event->organizer()); |
343 | #endif | 343 | #endif |
344 | if (iconPath) { | 344 | if (iconPath) { |
345 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; | 345 | mText += " <a href=\"mailto:" + event->organizer() + "\">"; |
346 | mText += "<IMG src=\"" + iconPath + "\">"; | 346 | mText += "<IMG src=\"" + iconPath + "\">"; |
347 | mText += "</a>\n"; | 347 | mText += "</a>\n"; |
348 | } | 348 | } |
349 | mText.append("</li></ul>"); | 349 | mText.append("</li></ul>"); |
350 | 350 | ||
351 | addTag("h3",i18n("Attendees")); | 351 | addTag("h3",i18n("Attendees")); |
352 | Attendee *a; | 352 | Attendee *a; |
353 | mText.append("<ul>"); | 353 | mText.append("<ul>"); |
354 | for(a=attendees.first();a;a=attendees.next()) { | 354 | for(a=attendees.first();a;a=attendees.next()) { |
355 | #if 0 | 355 | #if 0 |
356 | //ndef KORG_NOKABC | 356 | //ndef KORG_NOKABC |
357 | if (a->name().isEmpty()) { | 357 | if (a->name().isEmpty()) { |
358 | addressList = add_book->findByEmail(a->email()); | 358 | addressList = add_book->findByEmail(a->email()); |
359 | KABC::Addressee o = addressList.first(); | 359 | KABC::Addressee o = addressList.first(); |
360 | if (!o.isEmpty() && addressList.size()<2) { | 360 | if (!o.isEmpty() && addressList.size()<2) { |
361 | mText += "<a href=\"uid:" + o.uid() + "\">"; | 361 | mText += "<a href=\"uid:" + o.uid() + "\">"; |
362 | mText += o.formattedName(); | 362 | mText += o.formattedName(); |
363 | mText += "</a>\n"; | 363 | mText += "</a>\n"; |
364 | } else { | 364 | } else { |
365 | mText += "<li>"; | 365 | mText += "<li>"; |
366 | mText.append(a->email()); | 366 | mText.append(a->email()); |
367 | mText += "\n"; | 367 | mText += "\n"; |
368 | } | 368 | } |
369 | } else { | 369 | } else { |
370 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 370 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
371 | if (!a->name().isEmpty()) mText += a->name(); | 371 | if (!a->name().isEmpty()) mText += a->name(); |
372 | else mText += a->email(); | 372 | else mText += a->email(); |
373 | mText += "</a>\n"; | 373 | mText += "</a>\n"; |
374 | } | 374 | } |
375 | #else | 375 | #else |
376 | //qDebug("nokabc "); | 376 | //qDebug("nokabc "); |
377 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; | 377 | mText += "<li><a href=\"uid:" + a->uid() + "\">"; |
378 | if (!a->name().isEmpty()) mText += a->name(); | 378 | if (!a->name().isEmpty()) mText += a->name(); |
379 | else mText += a->email(); | 379 | else mText += a->email(); |
380 | mText += "</a>\n"; | 380 | mText += "</a>\n"; |
381 | #endif | 381 | #endif |
382 | 382 | ||
383 | if (!a->email().isEmpty()) { | 383 | if (!a->email().isEmpty()) { |
384 | if (iconPath) { | 384 | if (iconPath) { |
385 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; | 385 | mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; |
386 | if ( a->RSVP() ) | 386 | if ( a->RSVP() ) |
387 | mText += "<IMG src=\"" + iconPath + "\">"; | 387 | mText += "<IMG src=\"" + iconPath + "\">"; |
388 | else | 388 | else |
389 | mText += "<IMG src=\"" + NOiconPath + "\">"; | 389 | mText += "<IMG src=\"" + NOiconPath + "\">"; |
390 | mText += "</a>\n"; | 390 | mText += "</a>\n"; |
391 | } | 391 | } |
392 | } | 392 | } |
393 | if (a->status() != Attendee::NeedsAction ) | 393 | if (a->status() != Attendee::NeedsAction ) |
394 | mText +="[" + a->statusStr() + "] "; | 394 | mText +="[" + a->statusStr() + "] "; |
395 | if (a->role() == Attendee::Chair ) | 395 | if (a->role() == Attendee::Chair ) |
396 | mText +="(" + a->roleStr().left(1) + ".)"; | 396 | mText +="(" + a->roleStr().left(1) + ".)"; |
397 | } | 397 | } |
398 | mText.append("</li></ul>"); | 398 | mText.append("</li></ul>"); |
399 | } | 399 | } |
400 | } | 400 | } |
401 | 401 | ||
402 | void KIncidenceFormatter::formatReadOnly(Incidence *event) | 402 | void KIncidenceFormatter::formatReadOnly(Incidence *event) |
403 | { | 403 | { |
404 | if (event->isReadOnly()) { | 404 | if (event->isReadOnly()) { |
405 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); | 405 | addTag("p","<em>(" + i18n("read-only") + ")</em>"); |
406 | } | 406 | } |
407 | } | 407 | } |
408 | QString KIncidenceFormatter::deTag(QString text) | 408 | QString KIncidenceFormatter::deTag(QString text) |
409 | { | 409 | { |
410 | #if QT_VERSION >= 0x030000 | 410 | #if QT_VERSION >= 0x030000 |
411 | text.replace( '<' , "<" ); | 411 | text.replace( '<' , "<" ); |
412 | text.replace( '>' , ">" ); | 412 | text.replace( '>' , ">" ); |
413 | #else | 413 | #else |
414 | if ( text.find ('<') >= 0 ) { | 414 | if ( text.find ('<') >= 0 ) { |
415 | text.replace( QRegExp("<") , "<" ); | 415 | text.replace( QRegExp("<") , "<" ); |
416 | } | 416 | } |
417 | if ( text.find ('>') >= 0 ) { | 417 | if ( text.find ('>') >= 0 ) { |
418 | text.replace( QRegExp(">") , ">" ); | 418 | text.replace( QRegExp(">") , ">" ); |
419 | } | 419 | } |
420 | #endif | 420 | #endif |
421 | return text; | 421 | return text; |
422 | } | 422 | } |