-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 | |||
@@ -11,24 +11,25 @@ | |||
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 |
@@ -340,24 +341,47 @@ int Alarm::offset() | |||
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) { |
diff --git a/libkcal/alarm.h b/libkcal/alarm.h index 682b626..ac6ea0d 100644 --- a/libkcal/alarm.h +++ b/libkcal/alarm.h | |||
@@ -50,24 +50,25 @@ class Alarm : public CustomProperties | |||
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. |
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp index e506a96..d67ad52 100644 --- a/libkcal/kincidenceformatter.cpp +++ b/libkcal/kincidenceformatter.cpp | |||
@@ -122,31 +122,32 @@ void KIncidenceFormatter::setEvent(Event *event) | |||
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); |
@@ -215,24 +216,33 @@ void KIncidenceFormatter::setTodo(Todo *event ) | |||
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>"); |