-rw-r--r-- | libkcal/alarm.cpp | 24 |
1 files changed, 24 insertions, 0 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) { |