author | zautrix <zautrix> | 2005-04-02 14:07:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-02 14:07:31 (UTC) |
commit | b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd (patch) (unidiff) | |
tree | 942bcf89b35cf165e9147c1e4a5efa817c48007f /libkcal | |
parent | 997e7660a81baa2b8aeb1b66a3cc3ebe54e00ebe (diff) | |
download | kdepimpi-b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd.zip kdepimpi-b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd.tar.gz kdepimpi-b0d17f8f2ef9b09b7d8b8aa0f6cc34f400f8fddd.tar.bz2 |
fixes
-rw-r--r-- | libkcal/alarm.cpp | 24 | ||||
-rw-r--r-- | libkcal/alarm.h | 1 | ||||
-rw-r--r-- | libkcal/kincidenceformatter.cpp | 14 |
3 files changed, 37 insertions, 2 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 1fc7169..d8f15b5 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp | |||
@@ -1,70 +1,71 @@ | |||
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 | 24 | ||
24 | #include "incidence.h" | 25 | #include "incidence.h" |
25 | #include "todo.h" | 26 | #include "todo.h" |
26 | 27 | ||
27 | #include "alarm.h" | 28 | #include "alarm.h" |
28 | 29 | ||
29 | using namespace KCal; | 30 | using namespace KCal; |
30 | #include <qwidget.h> | 31 | #include <qwidget.h> |
31 | Alarm::Alarm(Incidence *parent) | 32 | Alarm::Alarm(Incidence *parent) |
32 | : mParent(parent), | 33 | : mParent(parent), |
33 | mType(Audio), | 34 | mType(Audio), |
34 | mDescription(""), // to make operator==() not fail | 35 | mDescription(""), // to make operator==() not fail |
35 | mFile(""), // to make operator==() not fail | 36 | mFile(""), // to make operator==() not fail |
36 | mMailSubject(""), // to make operator==() not fail | 37 | mMailSubject(""), // to make operator==() not fail |
37 | mAlarmSnoozeTime(5), | 38 | mAlarmSnoozeTime(5), |
38 | mAlarmRepeatCount(0), | 39 | mAlarmRepeatCount(0), |
39 | mEndOffset(false), | 40 | mEndOffset(false), |
40 | mHasTime(false), | 41 | mHasTime(false), |
41 | mAlarmEnabled(false) | 42 | mAlarmEnabled(false) |
42 | { | 43 | { |
43 | 44 | ||
44 | } | 45 | } |
45 | 46 | ||
46 | Alarm::~Alarm() | 47 | Alarm::~Alarm() |
47 | { | 48 | { |
48 | } | 49 | } |
49 | 50 | ||
50 | bool Alarm::operator==( const Alarm& rhs ) const | 51 | bool Alarm::operator==( const Alarm& rhs ) const |
51 | { | 52 | { |
52 | 53 | ||
53 | if ( mType != rhs.mType || | 54 | if ( mType != rhs.mType || |
54 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || | 55 | mAlarmSnoozeTime != rhs.mAlarmSnoozeTime || |
55 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || | 56 | mAlarmRepeatCount != rhs.mAlarmRepeatCount || |
56 | mAlarmEnabled != rhs.mAlarmEnabled || | 57 | mAlarmEnabled != rhs.mAlarmEnabled || |
57 | mHasTime != rhs.mHasTime) | 58 | mHasTime != rhs.mHasTime) |
58 | return false; | 59 | return false; |
59 | 60 | ||
60 | #if 0 | 61 | #if 0 |
61 | if ( mType != rhs.mType ) { | 62 | if ( mType != rhs.mType ) { |
62 | 63 | ||
63 | qDebug("aaa1 "); | 64 | qDebug("aaa1 "); |
64 | return false; | 65 | return false; |
65 | } | 66 | } |
66 | 67 | ||
67 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { | 68 | if ( mAlarmSnoozeTime != rhs.mAlarmSnoozeTime ) { |
68 | 69 | ||
69 | qDebug("aaa2 "); | 70 | qDebug("aaa2 "); |
70 | return false; | 71 | return false; |
@@ -304,96 +305,119 @@ void Alarm::setMailText(const QString &text) | |||
304 | 305 | ||
305 | QString Alarm::mailText() const | 306 | QString Alarm::mailText() const |
306 | { | 307 | { |
307 | return (mType == Email) ? mDescription : QString::null; | 308 | return (mType == Email) ? mDescription : QString::null; |
308 | } | 309 | } |
309 | 310 | ||
310 | void Alarm::setDisplayAlarm(const QString &text) | 311 | void Alarm::setDisplayAlarm(const QString &text) |
311 | { | 312 | { |
312 | mType = Display; | 313 | mType = Display; |
313 | mDescription = text; | 314 | mDescription = text; |
314 | mParent->updated(); | 315 | mParent->updated(); |
315 | } | 316 | } |
316 | 317 | ||
317 | void Alarm::setText(const QString &text) | 318 | void Alarm::setText(const QString &text) |
318 | { | 319 | { |
319 | if (mType == Display) { | 320 | if (mType == Display) { |
320 | mDescription = text; | 321 | mDescription = text; |
321 | mParent->updated(); | 322 | mParent->updated(); |
322 | } | 323 | } |
323 | } | 324 | } |
324 | 325 | ||
325 | QString Alarm::text() const | 326 | QString Alarm::text() const |
326 | { | 327 | { |
327 | return (mType == Display) ? mDescription : QString::null; | 328 | return (mType == Display) ? mDescription : QString::null; |
328 | } | 329 | } |
329 | 330 | ||
330 | void Alarm::setTime(const QDateTime &alarmTime) | 331 | void Alarm::setTime(const QDateTime &alarmTime) |
331 | { | 332 | { |
332 | mAlarmTime = alarmTime; | 333 | mAlarmTime = alarmTime; |
333 | mHasTime = true; | 334 | mHasTime = true; |
334 | 335 | ||
335 | mParent->updated(); | 336 | mParent->updated(); |
336 | } | 337 | } |
337 | int Alarm::offset() | 338 | int Alarm::offset() |
338 | { | 339 | { |
339 | if ( hasTime() ) { | 340 | if ( hasTime() ) { |
340 | if (mParent->type()=="Todo") { | 341 | if (mParent->type()=="Todo") { |
341 | Todo *t = static_cast<Todo*>(mParent); | 342 | Todo *t = static_cast<Todo*>(mParent); |
342 | return t->dtDue().secsTo( mAlarmTime ) ; | 343 | return t->dtDue().secsTo( mAlarmTime ) ; |
343 | } else | 344 | } else |
344 | return mParent->dtStart().secsTo( mAlarmTime ) ; | 345 | return mParent->dtStart().secsTo( mAlarmTime ) ; |
345 | } | 346 | } |
346 | else | 347 | else |
347 | { | 348 | { |
348 | return mOffset.asSeconds(); | 349 | return mOffset.asSeconds(); |
349 | } | 350 | } |
350 | 351 | ||
351 | } | 352 | } |
353 | QString Alarm::offsetText() | ||
354 | { | ||
355 | int min = -offset()/60; | ||
356 | int hours = min /60; | ||
357 | min = min % 60; | ||
358 | int days = hours /24; | ||
359 | hours = hours % 24; | ||
360 | QString message; | ||
361 | qDebug("%d %d %d ", days, hours, min ); | ||
362 | if ( days > 0 ) | ||
363 | message += i18n("%1d").arg( days ); | ||
364 | if ( hours > 0 ) { | ||
365 | if ( !message.isEmpty() ) message += "/"; | ||
366 | message += i18n("%1h").arg( hours ); | ||
367 | } | ||
368 | if ( min > 0 ) { | ||
369 | if ( !message.isEmpty() ) message += "/"; | ||
370 | message += i18n("%1min").arg( min ); | ||
371 | } | ||
372 | if ( message.isEmpty() ) | ||
373 | message = i18n("%1min").arg( 0 ); | ||
374 | return message; | ||
375 | } | ||
352 | 376 | ||
353 | 377 | ||
354 | QDateTime Alarm::time() const | 378 | QDateTime Alarm::time() const |
355 | { | 379 | { |
356 | if ( hasTime() ) | 380 | if ( hasTime() ) |
357 | return mAlarmTime; | 381 | return mAlarmTime; |
358 | else | 382 | else |
359 | { | 383 | { |
360 | if (mParent->type()=="Todo") { | 384 | if (mParent->type()=="Todo") { |
361 | Todo *t = static_cast<Todo*>(mParent); | 385 | Todo *t = static_cast<Todo*>(mParent); |
362 | return mOffset.end( t->dtDue() ); | 386 | return mOffset.end( t->dtDue() ); |
363 | } else if (mEndOffset) { | 387 | } else if (mEndOffset) { |
364 | return mOffset.end( mParent->dtEnd() ); | 388 | return mOffset.end( mParent->dtEnd() ); |
365 | } else { | 389 | } else { |
366 | return mOffset.end( mParent->dtStart() ); | 390 | return mOffset.end( mParent->dtStart() ); |
367 | } | 391 | } |
368 | } | 392 | } |
369 | } | 393 | } |
370 | 394 | ||
371 | bool Alarm::hasTime() const | 395 | bool Alarm::hasTime() const |
372 | { | 396 | { |
373 | return mHasTime; | 397 | return mHasTime; |
374 | } | 398 | } |
375 | 399 | ||
376 | void Alarm::setSnoozeTime(int alarmSnoozeTime) | 400 | void Alarm::setSnoozeTime(int alarmSnoozeTime) |
377 | { | 401 | { |
378 | mAlarmSnoozeTime = alarmSnoozeTime; | 402 | mAlarmSnoozeTime = alarmSnoozeTime; |
379 | mParent->updated(); | 403 | mParent->updated(); |
380 | } | 404 | } |
381 | 405 | ||
382 | int Alarm::snoozeTime() const | 406 | int Alarm::snoozeTime() const |
383 | { | 407 | { |
384 | return mAlarmSnoozeTime; | 408 | return mAlarmSnoozeTime; |
385 | } | 409 | } |
386 | 410 | ||
387 | void Alarm::setRepeatCount(int alarmRepeatCount) | 411 | void Alarm::setRepeatCount(int alarmRepeatCount) |
388 | { | 412 | { |
389 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; | 413 | kdDebug(5800) << "Alarm::setRepeatCount(): " << alarmRepeatCount << endl; |
390 | 414 | ||
391 | mAlarmRepeatCount = alarmRepeatCount; | 415 | mAlarmRepeatCount = alarmRepeatCount; |
392 | mParent->updated(); | 416 | mParent->updated(); |
393 | } | 417 | } |
394 | 418 | ||
395 | int Alarm::repeatCount() const | 419 | int Alarm::repeatCount() const |
396 | { | 420 | { |
397 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; | 421 | kdDebug(5800) << "Alarm::repeatCount(): " << mAlarmRepeatCount << endl; |
398 | return mAlarmRepeatCount; | 422 | return mAlarmRepeatCount; |
399 | } | 423 | } |
diff --git a/libkcal/alarm.h b/libkcal/alarm.h index 682b626..ac6ea0d 100644 --- a/libkcal/alarm.h +++ b/libkcal/alarm.h | |||
@@ -14,96 +14,97 @@ | |||
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #ifndef KCAL_ALARM_H | 21 | #ifndef KCAL_ALARM_H |
22 | #define KCAL_ALARM_H | 22 | #define KCAL_ALARM_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qvaluelist.h> | 25 | #include <qvaluelist.h> |
26 | 26 | ||
27 | #include "customproperties.h" | 27 | #include "customproperties.h" |
28 | #include "duration.h" | 28 | #include "duration.h" |
29 | #include "person.h" | 29 | #include "person.h" |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace KCal { |
32 | 32 | ||
33 | class Incidence; | 33 | class Incidence; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | This class represents an alarm notification. | 36 | This class represents an alarm notification. |
37 | */ | 37 | */ |
38 | class Alarm : public CustomProperties | 38 | class Alarm : public CustomProperties |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | enum Type { Invalid, Display, Procedure, Email, Audio }; | 41 | enum Type { Invalid, Display, Procedure, Email, Audio }; |
42 | typedef QValueList<Alarm *> List; | 42 | typedef QValueList<Alarm *> List; |
43 | 43 | ||
44 | /** Construct a new alarm with variables initialized to "sane" values. */ | 44 | /** Construct a new alarm with variables initialized to "sane" values. */ |
45 | explicit Alarm(Incidence *parent); | 45 | explicit Alarm(Incidence *parent); |
46 | /** Destruct Alarm object. */ | 46 | /** Destruct Alarm object. */ |
47 | ~Alarm(); | 47 | ~Alarm(); |
48 | 48 | ||
49 | /** Compare this alarm with another one. */ | 49 | /** Compare this alarm with another one. */ |
50 | bool operator==(const Alarm &) const; | 50 | bool operator==(const Alarm &) const; |
51 | bool operator!=(const Alarm &a) const { return !operator==(a); } | 51 | bool operator!=(const Alarm &a) const { return !operator==(a); } |
52 | 52 | ||
53 | /** Set the type of the alarm. | 53 | /** Set the type of the alarm. |
54 | If the specified type is different from the current type of the alarm, | 54 | If the specified type is different from the current type of the alarm, |
55 | the alarm's type-specific properties are initialised to null. | 55 | the alarm's type-specific properties are initialised to null. |
56 | @param type type of alarm. | 56 | @param type type of alarm. |
57 | */ | 57 | */ |
58 | void setType(Type type); | 58 | void setType(Type type); |
59 | /** Return the type of the alarm */ | 59 | /** Return the type of the alarm */ |
60 | Type type() const; | 60 | Type type() const; |
61 | int offset(); | 61 | int offset(); |
62 | QString offsetText(); | ||
62 | /** Set the alarm to be a display alarm. | 63 | /** Set the alarm to be a display alarm. |
63 | @param text text to display when the alarm is triggered. | 64 | @param text text to display when the alarm is triggered. |
64 | */ | 65 | */ |
65 | void setDisplayAlarm(const QString &text); | 66 | void setDisplayAlarm(const QString &text); |
66 | /** Set the text to be displayed when the alarm is triggered. | 67 | /** Set the text to be displayed when the alarm is triggered. |
67 | Ignored if the alarm is not a display alarm. | 68 | Ignored if the alarm is not a display alarm. |
68 | */ | 69 | */ |
69 | void setText(const QString &text); | 70 | void setText(const QString &text); |
70 | /** Return the text string that displays when the alarm is triggered. */ | 71 | /** Return the text string that displays when the alarm is triggered. */ |
71 | QString text() const; | 72 | QString text() const; |
72 | 73 | ||
73 | /** Set the alarm to be an audio alarm. | 74 | /** Set the alarm to be an audio alarm. |
74 | @param audioFile optional file to play when the alarm is triggered. | 75 | @param audioFile optional file to play when the alarm is triggered. |
75 | */ | 76 | */ |
76 | void setAudioAlarm(const QString &audioFile = QString::null); | 77 | void setAudioAlarm(const QString &audioFile = QString::null); |
77 | /** Set the file to play when the audio alarm is triggered. | 78 | /** Set the file to play when the audio alarm is triggered. |
78 | Ignored if the alarm is not an audio alarm. | 79 | Ignored if the alarm is not an audio alarm. |
79 | */ | 80 | */ |
80 | void setAudioFile(const QString &audioFile); | 81 | void setAudioFile(const QString &audioFile); |
81 | /** Return the name of the audio file for the alarm. | 82 | /** Return the name of the audio file for the alarm. |
82 | @return The audio file for the alarm, or QString::null if not an audio alarm. | 83 | @return The audio file for the alarm, or QString::null if not an audio alarm. |
83 | */ | 84 | */ |
84 | QString audioFile() const; | 85 | QString audioFile() const; |
85 | 86 | ||
86 | /** Set the alarm to be a procedure alarm. | 87 | /** Set the alarm to be a procedure alarm. |
87 | @param programFile program to execute when the alarm is triggered. | 88 | @param programFile program to execute when the alarm is triggered. |
88 | @param arguments arguments to supply to programFile. | 89 | @param arguments arguments to supply to programFile. |
89 | */ | 90 | */ |
90 | void setProcedureAlarm(const QString &programFile, const QString &arguments = QString::null); | 91 | void setProcedureAlarm(const QString &programFile, const QString &arguments = QString::null); |
91 | /** Set the program file to execute when the alarm is triggered. | 92 | /** Set the program file to execute when the alarm is triggered. |
92 | Ignored if the alarm is not a procedure alarm. | 93 | Ignored if the alarm is not a procedure alarm. |
93 | */ | 94 | */ |
94 | void setProgramFile(const QString &programFile); | 95 | void setProgramFile(const QString &programFile); |
95 | /** Return the name of the program file to execute when the alarm is triggered. | 96 | /** Return the name of the program file to execute when the alarm is triggered. |
96 | @return the program file name, or QString::null if not a procedure alarm. | 97 | @return the program file name, or QString::null if not a procedure alarm. |
97 | */ | 98 | */ |
98 | QString programFile() const; | 99 | QString programFile() const; |
99 | /** Set the arguments to the program to execute when the alarm is triggered. | 100 | /** Set the arguments to the program to execute when the alarm is triggered. |
100 | Ignored if the alarm is not a procedure alarm. | 101 | Ignored if the alarm is not a procedure alarm. |
101 | */ | 102 | */ |
102 | void setProgramArguments(const QString &arguments); | 103 | void setProgramArguments(const QString &arguments); |
103 | /** Return the arguments to the program to run when the alarm is triggered. | 104 | /** Return the arguments to the program to run when the alarm is triggered. |
104 | @return the program arguments, or QString::null if not a procedure alarm. | 105 | @return the program arguments, or QString::null if not a procedure alarm. |
105 | */ | 106 | */ |
106 | QString programArguments() const; | 107 | QString programArguments() const; |
107 | 108 | ||
108 | /** Set the alarm to be an email alarm. | 109 | /** Set the alarm to be an email alarm. |
109 | @param subject subject line of email. | 110 | @param subject subject line of email. |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index e506a96..d67ad52 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -86,189 +86,199 @@ void KIncidenceFormatter::setEvent(Event *event) | |||
86 | .arg(event->dtStartDateStr(shortDate)) | 86 | .arg(event->dtStartDateStr(shortDate)) |
87 | .arg(event->dtEndDateStr(shortDate))); | 87 | .arg(event->dtEndDateStr(shortDate))); |
88 | } else { | 88 | } else { |
89 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); | 89 | mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); |
90 | } | 90 | } |
91 | } else { | 91 | } else { |
92 | if (event->isMultiDay()) { | 92 | if (event->isMultiDay()) { |
93 | mText.append(i18n("<p><b>From:</b> %1</p> ") | 93 | mText.append(i18n("<p><b>From:</b> %1</p> ") |
94 | .arg(event->dtStartStr( shortDate))); | 94 | .arg(event->dtStartStr( shortDate))); |
95 | mText.append(i18n("<p><b>To:</b> %1</p>") | 95 | mText.append(i18n("<p><b>To:</b> %1</p>") |
96 | .arg(event->dtEndStr(shortDate))); | 96 | .arg(event->dtEndStr(shortDate))); |
97 | } else { | 97 | } else { |
98 | mText.append(i18n("<p><b>On:</b> %1</p> ") | 98 | mText.append(i18n("<p><b>On:</b> %1</p> ") |
99 | .arg(event->dtStartDateStr( shortDate ))); | 99 | .arg(event->dtStartDateStr( shortDate ))); |
100 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") | 100 | mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") |
101 | .arg(event->dtStartTimeStr()) | 101 | .arg(event->dtStartTimeStr()) |
102 | .arg(event->dtEndTimeStr())); | 102 | .arg(event->dtEndTimeStr())); |
103 | } | 103 | } |
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 | int min = t.secsTo( event->dtStart() )/60; | 134 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); |
135 | QString s =i18n("(%1 min before)").arg( min ); | ||
136 | 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 )); |
137 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | 136 | //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); |
138 | //addTag("p",s); | 137 | //addTag("p",s); |
139 | } | 138 | } |
140 | 139 | ||
140 | |||
141 | |||
141 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 142 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
142 | // mText.append(event->secrecyStr()+"<br>"); | 143 | // mText.append(event->secrecyStr()+"<br>"); |
143 | formatCategories(event); | 144 | formatCategories(event); |
144 | if ( mDetails ) { | 145 | if ( mDetails ) { |
145 | if (!event->description().isEmpty()) { | 146 | if (!event->description().isEmpty()) { |
146 | addTag("p",i18n("<b>Details: </b>")); | 147 | addTag("p",i18n("<b>Details: </b>")); |
147 | addTag("p",deTag(event->description())); | 148 | addTag("p",deTag(event->description())); |
148 | } | 149 | } |
149 | } | 150 | } |
150 | 151 | ||
151 | formatReadOnly(event); | 152 | formatReadOnly(event); |
152 | formatAttendees(event); | 153 | formatAttendees(event); |
153 | 154 | ||
154 | if ( mCreated ) { | 155 | if ( mCreated ) { |
155 | addTag("p",i18n("<b>Created: ") +" </b>"); | 156 | addTag("p",i18n("<b>Created: ") +" </b>"); |
156 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 157 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
157 | 158 | ||
158 | } | 159 | } |
159 | if ( mModified ) { | 160 | if ( mModified ) { |
160 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 161 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
161 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 162 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | } | 166 | } |
166 | 167 | ||
167 | void KIncidenceFormatter::setTodo(Todo *event ) | 168 | void KIncidenceFormatter::setTodo(Todo *event ) |
168 | { | 169 | { |
169 | int mode = 0; | 170 | int mode = 0; |
170 | mCurrentIncidence = event; | 171 | mCurrentIncidence = event; |
171 | bool shortDate = true; | 172 | bool shortDate = true; |
172 | if (mode == 0 ) | 173 | if (mode == 0 ) |
173 | addTag("h3",deTag(event->summary())); | 174 | addTag("h3",deTag(event->summary())); |
174 | else { | 175 | else { |
175 | if ( mColorMode == 1 ) { | 176 | if ( mColorMode == 1 ) { |
176 | mText +="<font color=\"#00A000\">"; | 177 | mText +="<font color=\"#00A000\">"; |
177 | } | 178 | } |
178 | if ( mColorMode == 2 ) { | 179 | if ( mColorMode == 2 ) { |
179 | mText +="<font color=\"#B00000\">"; | 180 | mText +="<font color=\"#B00000\">"; |
180 | } | 181 | } |
181 | if ( mode == 1 ) { | 182 | if ( mode == 1 ) { |
182 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); | 183 | addTag("h2",i18n( "Local: " ) +deTag(event->summary())); |
183 | } else { | 184 | } else { |
184 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); | 185 | addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); |
185 | } | 186 | } |
186 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); | 187 | addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); |
187 | if ( mColorMode ) | 188 | if ( mColorMode ) |
188 | mText += "</font>"; | 189 | mText += "</font>"; |
189 | } | 190 | } |
190 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { | 191 | if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { |
191 | mText +="<font color=\"#B00000\">"; | 192 | mText +="<font color=\"#B00000\">"; |
192 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); | 193 | addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); |
193 | mText += "</font>"; | 194 | mText += "</font>"; |
194 | } else { | 195 | } else { |
195 | mText.append(i18n("<p><i>%1 % completed</i></p>") | 196 | mText.append(i18n("<p><i>%1 % completed</i></p>") |
196 | .arg(event->percentComplete())); | 197 | .arg(event->percentComplete())); |
197 | } | 198 | } |
198 | if (event->cancelled ()) { | 199 | if (event->cancelled ()) { |
199 | mText +="<font color=\"#B00000\">"; | 200 | mText +="<font color=\"#B00000\">"; |
200 | addTag("i",i18n("This todo has been cancelled!")); | 201 | addTag("i",i18n("This todo has been cancelled!")); |
201 | mText.append("<br>"); | 202 | mText.append("<br>"); |
202 | mText += "</font>"; | 203 | mText += "</font>"; |
203 | } | 204 | } |
204 | 205 | ||
205 | if (!event->location().isEmpty()) { | 206 | if (!event->location().isEmpty()) { |
206 | addTag("b",i18n("Location: ")); | 207 | addTag("b",i18n("Location: ")); |
207 | mText.append(deTag(event->location())+"<br>"); | 208 | mText.append(deTag(event->location())+"<br>"); |
208 | } | 209 | } |
209 | 210 | ||
210 | if (event->recurrence()->doesRecur()) { | 211 | if (event->recurrence()->doesRecur()) { |
211 | 212 | ||
212 | QString recurText = event->recurrence()->recurrenceText(); | 213 | QString recurText = event->recurrence()->recurrenceText(); |
213 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); | 214 | addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); |
214 | } | 215 | } |
215 | 216 | ||
216 | if (event->hasStartDate()) { | 217 | if (event->hasStartDate()) { |
217 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); | 218 | mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); |
218 | } | 219 | } |
219 | 220 | ||
220 | 221 | ||
221 | if (event->hasDueDate()) { | 222 | if (event->hasDueDate()) { |
222 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); | 223 | mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); |
223 | } | 224 | } |
224 | mText.append(i18n("<p><b>Priority:</b> %2</p>") | 225 | mText.append(i18n("<p><b>Priority:</b> %2</p>") |
225 | .arg(QString::number(event->priority()))); | 226 | .arg(QString::number(event->priority()))); |
226 | 227 | ||
228 | if (event->isAlarmEnabled()) { | ||
229 | Alarm *alarm =event->alarms().first() ; | ||
230 | QDateTime t = alarm->time(); | ||
231 | QString s =i18n("( %1 before )").arg( alarm->offsetText() ); | ||
232 | addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); | ||
233 | addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); | ||
234 | //addTag("p",s); | ||
235 | } | ||
236 | |||
227 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); | 237 | addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); |
228 | formatCategories(event); | 238 | formatCategories(event); |
229 | if ( mDetails ) { | 239 | if ( mDetails ) { |
230 | if (!event->description().isEmpty()) { | 240 | if (!event->description().isEmpty()) { |
231 | addTag("p",i18n("<b>Details: </b>")); | 241 | addTag("p",i18n("<b>Details: </b>")); |
232 | addTag("p",deTag(event->description())); | 242 | addTag("p",deTag(event->description())); |
233 | } | 243 | } |
234 | } | 244 | } |
235 | formatReadOnly(event); | 245 | formatReadOnly(event); |
236 | formatAttendees(event); | 246 | formatAttendees(event); |
237 | if ( mCreated ) { | 247 | if ( mCreated ) { |
238 | addTag("p",i18n("<b>Created: ") +" </b>"); | 248 | addTag("p",i18n("<b>Created: ") +" </b>"); |
239 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); | 249 | addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); |
240 | 250 | ||
241 | } | 251 | } |
242 | if ( mModified ) { | 252 | if ( mModified ) { |
243 | addTag("p",i18n("<b>Last modified: ") +" </b>"); | 253 | addTag("p",i18n("<b>Last modified: ") +" </b>"); |
244 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); | 254 | addTag("p", KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); |
245 | 255 | ||
246 | } | 256 | } |
247 | } | 257 | } |
248 | 258 | ||
249 | void KIncidenceFormatter::setJournal(Journal* ) | 259 | void KIncidenceFormatter::setJournal(Journal* ) |
250 | { | 260 | { |
251 | 261 | ||
252 | } | 262 | } |
253 | 263 | ||
254 | void KIncidenceFormatter::formatCategories(Incidence *event) | 264 | void KIncidenceFormatter::formatCategories(Incidence *event) |
255 | { | 265 | { |
256 | if (!event->categoriesStr().isEmpty()) { | 266 | if (!event->categoriesStr().isEmpty()) { |
257 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); | 267 | addTag("p",i18n("<b>Categories: </b>")+event->categoriesStr() ); |
258 | //mText.append(event->categoriesStr()); | 268 | //mText.append(event->categoriesStr()); |
259 | } | 269 | } |
260 | } | 270 | } |
261 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) | 271 | void KIncidenceFormatter::addTag(const QString & tag,const QString & text) |
262 | { | 272 | { |
263 | int number=text.contains("\n"); | 273 | int number=text.contains("\n"); |
264 | QString str = "<" + tag + ">"; | 274 | QString str = "<" + tag + ">"; |
265 | QString tmpText=text; | 275 | QString tmpText=text; |
266 | QString tmpStr=str; | 276 | QString tmpStr=str; |
267 | if(number !=-1) | 277 | if(number !=-1) |
268 | { | 278 | { |
269 | if (number > 0) { | 279 | if (number > 0) { |
270 | int pos=0; | 280 | int pos=0; |
271 | QString tmp; | 281 | QString tmp; |
272 | for(int i=0;i<=number;i++) { | 282 | for(int i=0;i<=number;i++) { |
273 | pos=tmpText.find("\n"); | 283 | pos=tmpText.find("\n"); |
274 | tmp=tmpText.left(pos); | 284 | tmp=tmpText.left(pos); |