25 #include "alarmtext.h"
26 #include "identities.h"
29 #ifndef KALARMCAL_USE_KRESOURCES
32 #include <kcal/calendarlocal.h>
34 #include <kholidays/holidays.h>
35 using namespace KHolidays;
37 #include <ksystemtimezone.h>
38 #include <klocalizedstring.h>
39 #ifdef KALARMCAL_USE_KRESOURCES
40 #include <ksharedconfig.h>
42 #include <kconfiggroup.h>
47 #ifndef KALARMCAL_USE_KRESOURCES
48 using namespace KCalCore;
52 using namespace KHolidays;
59 #ifndef KALARMCAL_USE_KRESOURCES
63 typedef KCal::Person EmailAddress;
64 class EmailAddressList :
public QList<KCal::Person>
68 #ifndef KALARMCAL_USE_KRESOURCES
69 EmailAddressList() : KCalCore::
Person::List() { }
73 EmailAddressList() : QList<KCal::
Person>() { }
74 EmailAddressList(
const QList<KCal::Person>& list) { operator=(list); }
75 EmailAddressList& operator=(
const QList<KCal::Person>&);
77 operator QStringList()
const;
78 QString join(
const QString& separator)
const;
79 QStringList pureAddresses()
const;
80 QString pureAddresses(
const QString& separator)
const;
82 QString address(
int index)
const;
87 class KAAlarm::Private
94 DateTime mNextMainDateTime;
95 Repetition mRepetition;
105 class KAEventPrivate :
public QSharedData
115 TIMED_FLAG = 0x400000,
116 DATE_DEFERRAL = DEFERRAL,
117 TIME_DEFERRAL = DEFERRAL | TIMED_FLAG,
118 DISPLAYING_ = 0x800000,
119 READ_ONLY_FLAGS = 0xF00000
140 REMINDER_ALARM = 0x02,
141 DEFERRED_ALARM = 0x04,
142 DEFERRED_REMINDER_ALARM = REMINDER_ALARM | DEFERRED_ALARM,
145 AT_LOGIN_ALARM = 0x10,
146 DISPLAYING_ALARM = 0x20,
149 PRE_ACTION_ALARM = 0x40,
150 POST_ACTION_ALARM = 0x50
155 #ifndef KALARMCAL_USE_KRESOURCES
162 QColor bgColour, fgColour;
166 int repeatSoundPause;
169 KAEventPrivate::AlarmType
type;
170 KAAlarm::Action action;
172 KAEvent::ExtraActionOptions extraActionOptions;
180 typedef QMap<AlarmType, AlarmData> AlarmMap;
183 KAEventPrivate(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
184 const QFont& f, KAEvent::SubAction,
int lateCancel, KAEvent::Flags flags,
185 bool changesPending =
false);
186 #ifndef KALARMCAL_USE_KRESOURCES
189 explicit KAEventPrivate(
const KCal::Event*);
191 KAEventPrivate(
const KAEventPrivate&);
192 ~KAEventPrivate() {
delete mRecurrence; }
193 KAEventPrivate& operator=(
const KAEventPrivate& e) {
if (&e !=
this) copy(e);
return *
this; }
194 #ifndef KALARMCAL_USE_KRESOURCES
197 void set(
const KCal::Event*);
199 void set(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
200 const QFont&, KAEvent::SubAction,
int lateCancel, KAEvent::Flags flags,
201 bool changesPending =
false);
202 void setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile);
203 KAEvent::OccurType setNextOccurrence(
const KDateTime& preDateTime);
204 void setFirstRecurrence();
205 void setCategory(CalEvent::Type);
206 void setRepeatAtLogin(
bool);
207 void setRepeatAtLoginTrue(
bool clearReminder);
208 void setReminder(
int minutes,
bool onceOnly);
209 void activateReminderAfter(
const DateTime& mainAlarmTime);
210 void defer(
const DateTime&,
bool reminder,
bool adjustRecurrence =
false);
212 #ifndef KALARMCAL_USE_KRESOURCES
213 bool setDisplaying(
const KAEventPrivate&, KAAlarm::Type,
Akonadi::Collection::Id,
const KDateTime& dt,
bool showEdit,
bool showDefer);
216 bool setDisplaying(
const KAEventPrivate&, KAAlarm::Type,
const QString& resourceID,
const KDateTime& dt,
bool showEdit,
bool showDefer);
217 void reinstateFromDisplaying(
const KCal::Event*, QString& resourceID,
bool& showEdit,
bool& showDefer);
218 void setCommandError(
const QString& configString);
219 void setCommandError(KAEvent::CmdErrType,
bool writeConfig)
const;
221 void startChanges() { ++mChangeCount; }
223 void removeExpiredAlarm(KAAlarm::Type);
224 KAAlarm alarm(KAAlarm::Type)
const;
225 KAAlarm firstAlarm()
const;
226 KAAlarm nextAlarm(KAAlarm::Type)
const;
227 #ifndef KALARMCAL_USE_KRESOURCES
228 bool updateKCalEvent(
const KCalCore::Event::Ptr&, KAEvent::UidAction,
bool setCustomProperties =
true)
const;
230 bool updateKCalEvent(KCal::Event*, KAEvent::UidAction)
const;
232 DateTime mainDateTime(
bool withRepeats =
false)
const
233 {
return (withRepeats && mNextRepeat && mRepetition)
234 ? mRepetition.duration(mNextRepeat).end(mNextMainDateTime.kDateTime()) : mNextMainDateTime; }
235 DateTime mainEndRepeatTime()
const
236 {
return mRepetition ? mRepetition.duration().end(mNextMainDateTime.kDateTime()) : mNextMainDateTime; }
237 DateTime deferralLimit(KAEvent::DeferLimitType* = 0)
const;
238 KAEvent::Flags flags()
const;
239 bool isWorkingTime(
const KDateTime&)
const;
240 bool setRepetition(
const Repetition&);
241 bool occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const;
242 KAEvent::OccurType nextOccurrence(
const KDateTime& preDateTime, DateTime& result, KAEvent::OccurOption = KAEvent::IGNORE_REPETITION)
const;
243 KAEvent::OccurType previousOccurrence(
const KDateTime& afterDateTime, DateTime& result,
bool includeRepetitions =
false)
const;
244 void setRecurrence(
const KARecurrence&);
245 #ifndef KALARMCAL_USE_KRESOURCES
249 bool setRecur(KCal::RecurrenceRule::PeriodType,
int freq,
int count,
const QDate& end, KARecurrence::Feb29Type = KARecurrence::Feb29_None);
250 bool setRecur(KCal::RecurrenceRule::PeriodType,
int freq,
int count,
const KDateTime& end, KARecurrence::Feb29Type = KARecurrence::Feb29_None);
252 KARecurrence::Type checkRecur()
const;
254 void calcTriggerTimes()
const;
255 #ifdef KDE_NO_DEBUG_OUTPUT
256 void dumpDebug()
const { }
258 void dumpDebug()
const;
260 #ifndef KALARMCAL_USE_KRESOURCES
265 static void readAlarm(
const KCalCore::Alarm::Ptr&, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
267 static bool convertRepetition(KCal::Event*);
268 static bool convertStartOfDay(KCal::Event*);
269 static DateTime readDateTime(
const KCal::Event*,
bool dateOnly, DateTime& start);
270 static void readAlarms(
const KCal::Event*, AlarmMap*,
bool cmdDisplay =
false);
271 static void readAlarm(
const KCal::Alarm*, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
275 void copy(
const KAEventPrivate&);
276 bool mayOccurDailyDuringWork(
const KDateTime&)
const;
277 int nextWorkRepetition(
const KDateTime& pre)
const;
278 void calcNextWorkingTime(
const DateTime& nextTrigger)
const;
279 DateTime nextWorkingTime()
const;
280 KAEvent::OccurType nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const;
281 #ifndef KALARMCAL_USE_KRESOURCES
286 void setAudioAlarm(KCal::Alarm*)
const;
287 KCal::Alarm* initKCalAlarm(KCal::Event*,
const DateTime&,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
288 KCal::Alarm* initKCalAlarm(KCal::Event*,
int startOffsetSecs,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
290 inline void set_deferral(DeferType);
291 inline void activate_reminder(
bool activate);
294 #ifdef KALARMCAL_USE_KRESOURCES
295 static QString mCmdErrConfigGroup;
297 static QFont mDefaultFont;
298 static const KHolidays::HolidayRegion* mHolidays;
299 static QBitArray mWorkDays;
300 static QTime mWorkDayStart;
301 static QTime mWorkDayEnd;
302 static int mWorkTimeIndex;
303 #ifdef KALARMCAL_USE_KRESOURCES
304 AlarmResource* mResource;
306 mutable DateTime mAllTrigger;
307 mutable DateTime mMainTrigger;
308 mutable DateTime mAllWorkTrigger;
309 mutable DateTime mMainWorkTrigger;
310 mutable KAEvent::CmdErrType mCommandError;
313 QString mTemplateName;
314 #ifndef KALARMCAL_USE_KRESOURCES
315 QMap<QByteArray, QString> mCustomProperties;
316 Akonadi::Item::Id mItemId;
320 QString mOriginalResourceId;
326 DateTime mStartDateTime;
327 KDateTime mCreatedDateTime;
328 DateTime mNextMainDateTime;
329 KDateTime mAtLoginDateTime;
330 DateTime mDeferralTime;
331 DateTime mDisplayingTime;
332 int mDisplayingFlags;
333 int mReminderMinutes;
334 DateTime mReminderAfterTime;
335 ReminderType mReminderActive;
336 int mDeferDefaultMinutes;
337 bool mDeferDefaultDateOnly;
339 KARecurrence* mRecurrence;
340 Repetition mRepetition;
344 unsigned long mKMailSerialNumber;
345 int mTemplateAfterTime;
349 uint mEmailFromIdentity;
350 EmailAddressList mEmailAddresses;
351 QString mEmailSubject;
352 QStringList mEmailAttachments;
353 mutable int mChangeCount;
354 mutable bool mTriggerChanged;
359 int mRepeatSoundPause;
361 mutable const KHolidays::HolidayRegion*
363 mutable int mWorkTimeOnly;
364 KAEvent::SubAction mActionSubType;
365 CalEvent::Type mCategory;
366 KAEvent::ExtraActionOptions mExtraActionOptions;
367 #ifndef KALARMCAL_USE_KRESOURCES
368 KACalendar::Compat mCompatibility;
372 bool mUseDefaultFont;
375 bool mCommandDisplay;
379 bool mCopyToKOrganizer;
380 bool mReminderOnceOnly;
384 bool mArchiveRepeatAtLogin;
387 bool mDisplayingDefer;
388 bool mDisplayingEdit;
392 static const QByteArray FLAGS_PROPERTY;
393 static const QString DATE_ONLY_FLAG;
394 static const QString EMAIL_BCC_FLAG;
395 static const QString CONFIRM_ACK_FLAG;
396 static const QString KORGANIZER_FLAG;
397 static const QString EXCLUDE_HOLIDAYS_FLAG;
398 static const QString WORK_TIME_ONLY_FLAG;
399 static const QString REMINDER_ONCE_FLAG;
400 static const QString DEFER_FLAG;
401 static const QString LATE_CANCEL_FLAG;
402 static const QString AUTO_CLOSE_FLAG;
403 static const QString TEMPL_AFTER_TIME_FLAG;
404 static const QString KMAIL_SERNUM_FLAG;
405 static const QString ARCHIVE_FLAG;
406 static const QByteArray NEXT_RECUR_PROPERTY;
407 static const QByteArray REPEAT_PROPERTY;
408 static const QByteArray LOG_PROPERTY;
409 static const QString xtermURL;
410 static const QString displayURL;
411 static const QByteArray TYPE_PROPERTY;
412 static const QString FILE_TYPE;
413 static const QString AT_LOGIN_TYPE;
414 static const QString REMINDER_TYPE;
415 static const QString REMINDER_ONCE_TYPE;
416 static const QString TIME_DEFERRAL_TYPE;
417 static const QString DATE_DEFERRAL_TYPE;
418 static const QString DISPLAYING_TYPE;
419 static const QString PRE_ACTION_TYPE;
420 static const QString POST_ACTION_TYPE;
421 static const QString SOUND_REPEAT_TYPE;
422 static const QByteArray NEXT_REPEAT_PROPERTY;
423 static const QString HIDDEN_REMINDER_FLAG;
424 static const QByteArray FONT_COLOUR_PROPERTY;
425 static const QByteArray VOLUME_PROPERTY;
426 static const QString EMAIL_ID_FLAG;
427 static const QString SPEAK_FLAG;
428 static const QString EXEC_ON_DEFERRAL_FLAG;
429 static const QString CANCEL_ON_ERROR_FLAG;
430 static const QString DONT_SHOW_ERROR_FLAG;
431 static const QString DISABLED_STATUS;
432 static const QString DISP_DEFER;
433 static const QString DISP_EDIT;
434 static const QString CMD_ERROR_VALUE;
435 static const QString CMD_ERROR_PRE_VALUE;
436 static const QString CMD_ERROR_POST_VALUE;
437 static const QString SC;
445 QByteArray KAEvent::currentCalendarVersionString() {
return QByteArray(
"2.7.0"); }
446 int KAEvent::currentCalendarVersion() {
return Version(2,7,0); }
452 const QByteArray KAEventPrivate::FLAGS_PROPERTY(
"FLAGS");
453 const QString KAEventPrivate::DATE_ONLY_FLAG = QLatin1String(
"DATE");
454 const QString KAEventPrivate::EMAIL_BCC_FLAG = QLatin1String(
"BCC");
455 const QString KAEventPrivate::CONFIRM_ACK_FLAG = QLatin1String(
"ACKCONF");
456 const QString KAEventPrivate::KORGANIZER_FLAG = QLatin1String(
"KORG");
457 const QString KAEventPrivate::EXCLUDE_HOLIDAYS_FLAG = QLatin1String(
"EXHOLIDAYS");
458 const QString KAEventPrivate::WORK_TIME_ONLY_FLAG = QLatin1String(
"WORKTIME");
459 const QString KAEventPrivate::REMINDER_ONCE_FLAG = QLatin1String(
"ONCE");
460 const QString KAEventPrivate::DEFER_FLAG = QLatin1String(
"DEFER");
461 const QString KAEventPrivate::LATE_CANCEL_FLAG = QLatin1String(
"LATECANCEL");
462 const QString KAEventPrivate::AUTO_CLOSE_FLAG = QLatin1String(
"LATECLOSE");
463 const QString KAEventPrivate::TEMPL_AFTER_TIME_FLAG = QLatin1String(
"TMPLAFTTIME");
464 const QString KAEventPrivate::KMAIL_SERNUM_FLAG = QLatin1String(
"KMAIL");
465 const QString KAEventPrivate::ARCHIVE_FLAG = QLatin1String(
"ARCHIVE");
467 const QByteArray KAEventPrivate::NEXT_RECUR_PROPERTY(
"NEXTRECUR");
468 const QByteArray KAEventPrivate::REPEAT_PROPERTY(
"REPEAT");
469 const QByteArray KAEventPrivate::LOG_PROPERTY(
"LOG");
470 const QString KAEventPrivate::xtermURL = QLatin1String(
"xterm:");
471 const QString KAEventPrivate::displayURL = QLatin1String(
"display:");
474 const QByteArray KAEventPrivate::TYPE_PROPERTY(
"TYPE");
475 const QString KAEventPrivate::FILE_TYPE = QLatin1String(
"FILE");
476 const QString KAEventPrivate::AT_LOGIN_TYPE = QLatin1String(
"LOGIN");
477 const QString KAEventPrivate::REMINDER_TYPE = QLatin1String(
"REMINDER");
478 const QString KAEventPrivate::TIME_DEFERRAL_TYPE = QLatin1String(
"DEFERRAL");
479 const QString KAEventPrivate::DATE_DEFERRAL_TYPE = QLatin1String(
"DATE_DEFERRAL");
480 const QString KAEventPrivate::DISPLAYING_TYPE = QLatin1String(
"DISPLAYING");
481 const QString KAEventPrivate::PRE_ACTION_TYPE = QLatin1String(
"PRE");
482 const QString KAEventPrivate::POST_ACTION_TYPE = QLatin1String(
"POST");
483 const QString KAEventPrivate::SOUND_REPEAT_TYPE = QLatin1String(
"SOUNDREPEAT");
484 const QByteArray KAEventPrivate::NEXT_REPEAT_PROPERTY(
"NEXTREPEAT");
485 const QString KAEventPrivate::HIDDEN_REMINDER_FLAG = QLatin1String(
"HIDE");
487 const QByteArray KAEventPrivate::FONT_COLOUR_PROPERTY(
"FONTCOLOR");
489 const QString KAEventPrivate::EMAIL_ID_FLAG = QLatin1String(
"EMAILID");
491 const QByteArray KAEventPrivate::VOLUME_PROPERTY(
"VOLUME");
492 const QString KAEventPrivate::SPEAK_FLAG = QLatin1String(
"SPEAK");
494 const QString KAEventPrivate::EXEC_ON_DEFERRAL_FLAG = QLatin1String(
"EXECDEFER");
495 const QString KAEventPrivate::CANCEL_ON_ERROR_FLAG = QLatin1String(
"ERRCANCEL");
496 const QString KAEventPrivate::DONT_SHOW_ERROR_FLAG = QLatin1String(
"ERRNOSHOW");
499 const QString KAEventPrivate::DISABLED_STATUS = QLatin1String(
"DISABLED");
502 const QString KAEventPrivate::DISP_DEFER = QLatin1String(
"DEFER");
503 const QString KAEventPrivate::DISP_EDIT = QLatin1String(
"EDIT");
506 #ifdef KALARMCAL_USE_KRESOURCES
507 QString KAEventPrivate::mCmdErrConfigGroup = QLatin1String(
"CommandErrors");
509 const QString KAEventPrivate::CMD_ERROR_VALUE = QLatin1String(
"MAIN");
510 const QString KAEventPrivate::CMD_ERROR_PRE_VALUE = QLatin1String(
"PRE");
511 const QString KAEventPrivate::CMD_ERROR_POST_VALUE = QLatin1String(
"POST");
513 const QString KAEventPrivate::SC = QLatin1String(
";");
515 QFont KAEventPrivate::mDefaultFont;
516 const KHolidays::HolidayRegion* KAEventPrivate::mHolidays = 0;
517 QBitArray KAEventPrivate::mWorkDays(7);
518 QTime KAEventPrivate::mWorkDayStart(9, 0, 0);
519 QTime KAEventPrivate::mWorkDayEnd(17, 0, 0);
520 int KAEventPrivate::mWorkTimeIndex = 1;
522 #ifndef KALARMCAL_USE_KRESOURCES
523 static void setProcedureAlarm(
const Alarm::Ptr&,
const QString& commandLine);
525 static void setProcedureAlarm(
Alarm*,
const QString& commandLine);
527 static QString reminderToString(
int minutes);
534 inline void KAEventPrivate::set_deferral(DeferType type)
538 if (mDeferral == NO_DEFERRAL)
543 if (mDeferral != NO_DEFERRAL)
549 inline void KAEventPrivate::activate_reminder(
bool activate)
551 if (activate && mReminderActive != ACTIVE_REMINDER && mReminderMinutes)
553 if (mReminderActive == NO_REMINDER)
555 mReminderActive = ACTIVE_REMINDER;
557 else if (!activate && mReminderActive != NO_REMINDER)
559 mReminderActive = NO_REMINDER;
560 mReminderAfterTime = DateTime();
565 K_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<KAEventPrivate>,
566 emptyKAEventPrivate, (
new KAEventPrivate))
569 : d(*emptyKAEventPrivate)
572 KAEventPrivate::KAEventPrivate()
574 #ifdef KALARMCAL_USE_KRESOURCES
577 mCommandError(KAEvent::CMD_NO_ERROR),
578 #ifndef KALARMCAL_USE_KRESOURCES
583 mReminderActive(NO_REMINDER),
588 mDeferral(NO_DEFERRAL),
590 mTriggerChanged(false),
594 mCategory(CalEvent::
EMPTY),
595 #ifndef KALARMCAL_USE_KRESOURCES
596 mCompatibility(KACalendar::
Current),
603 mRepeatAtLogin(false),
607 KAEvent::KAEvent(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
608 SubAction action,
int lateCancel, Flags flags,
bool changesPending)
609 : d(new KAEventPrivate(dt, message, bg, fg, f, action, lateCancel, flags, changesPending))
613 KAEventPrivate::KAEventPrivate(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
618 set(dt, message, bg, fg, f, action, lateCancel, flags, changesPending);
621 #ifndef KALARMCAL_USE_KRESOURCES
626 : d(
new KAEventPrivate(e))
630 #ifndef KALARMCAL_USE_KRESOURCES
631 KAEventPrivate::KAEventPrivate(
const Event::Ptr& e)
633 KAEventPrivate::KAEventPrivate(
const Event* e)
640 KAEventPrivate::KAEventPrivate(
const KAEventPrivate& e)
654 KAEvent& KAEvent::operator=(
const KAEvent& other)
664 void KAEventPrivate::copy(
const KAEventPrivate& event)
666 #ifdef KALARMCAL_USE_KRESOURCES
667 mResource =
event.mResource;
669 mAllTrigger =
event.mAllTrigger;
670 mMainTrigger =
event.mMainTrigger;
671 mAllWorkTrigger =
event.mAllWorkTrigger;
672 mMainWorkTrigger =
event.mMainWorkTrigger;
673 mCommandError =
event.mCommandError;
674 mEventID =
event.mEventID;
675 mTemplateName =
event.mTemplateName;
676 #ifndef KALARMCAL_USE_KRESOURCES
677 mCustomProperties =
event.mCustomProperties;
678 mItemId =
event.mItemId;
679 mCollectionId =
event.mCollectionId;
681 mOriginalResourceId =
event.mOriginalResourceId;
684 mAudioFile =
event.mAudioFile;
685 mPreAction =
event.mPreAction;
686 mPostAction =
event.mPostAction;
687 mStartDateTime =
event.mStartDateTime;
688 mCreatedDateTime =
event.mCreatedDateTime;
689 mNextMainDateTime =
event.mNextMainDateTime;
690 mAtLoginDateTime =
event.mAtLoginDateTime;
691 mDeferralTime =
event.mDeferralTime;
692 mDisplayingTime =
event.mDisplayingTime;
693 mDisplayingFlags =
event.mDisplayingFlags;
694 mReminderMinutes =
event.mReminderMinutes;
695 mReminderAfterTime =
event.mReminderAfterTime;
696 mReminderActive =
event.mReminderActive;
697 mDeferDefaultMinutes =
event.mDeferDefaultMinutes;
698 mDeferDefaultDateOnly =
event.mDeferDefaultDateOnly;
699 mRevision =
event.mRevision;
700 mRepetition =
event.mRepetition;
701 mNextRepeat =
event.mNextRepeat;
702 mAlarmCount =
event.mAlarmCount;
703 mDeferral =
event.mDeferral;
704 mKMailSerialNumber =
event.mKMailSerialNumber;
705 mTemplateAfterTime =
event.mTemplateAfterTime;
706 mBgColour =
event.mBgColour;
707 mFgColour =
event.mFgColour;
709 mEmailFromIdentity =
event.mEmailFromIdentity;
710 mEmailAddresses =
event.mEmailAddresses;
711 mEmailSubject =
event.mEmailSubject;
712 mEmailAttachments =
event.mEmailAttachments;
713 mLogFile =
event.mLogFile;
714 mSoundVolume =
event.mSoundVolume;
715 mFadeVolume =
event.mFadeVolume;
716 mFadeSeconds =
event.mFadeSeconds;
717 mRepeatSoundPause =
event.mRepeatSoundPause;
718 mLateCancel =
event.mLateCancel;
719 mExcludeHolidays =
event.mExcludeHolidays;
720 mWorkTimeOnly =
event.mWorkTimeOnly;
721 mActionSubType =
event.mActionSubType;
722 mCategory =
event.mCategory;
723 mExtraActionOptions =
event.mExtraActionOptions;
724 #ifndef KALARMCAL_USE_KRESOURCES
725 mCompatibility =
event.mCompatibility;
726 mReadOnly =
event.mReadOnly;
728 mConfirmAck =
event.mConfirmAck;
729 mUseDefaultFont =
event.mUseDefaultFont;
730 mCommandScript =
event.mCommandScript;
731 mCommandXterm =
event.mCommandXterm;
732 mCommandDisplay =
event.mCommandDisplay;
733 mEmailBcc =
event.mEmailBcc;
735 mSpeak =
event.mSpeak;
736 mCopyToKOrganizer =
event.mCopyToKOrganizer;
737 mReminderOnceOnly =
event.mReminderOnceOnly;
738 mAutoClose =
event.mAutoClose;
739 mMainExpired =
event.mMainExpired;
740 mRepeatAtLogin =
event.mRepeatAtLogin;
741 mArchiveRepeatAtLogin =
event.mArchiveRepeatAtLogin;
742 mArchive =
event.mArchive;
743 mDisplaying =
event.mDisplaying;
744 mDisplayingDefer =
event.mDisplayingDefer;
745 mDisplayingEdit =
event.mDisplayingEdit;
746 mEnabled =
event.mEnabled;
748 mTriggerChanged =
event.mTriggerChanged;
750 if (event.mRecurrence)
751 mRecurrence =
new KARecurrence(*event.mRecurrence);
756 #ifndef KALARMCAL_USE_KRESOURCES
768 #ifndef KALARMCAL_USE_KRESOURCES
769 void KAEventPrivate::set(
const Event::Ptr& event)
771 void KAEventPrivate::set(
const Event* event)
777 #ifdef KALARMCAL_USE_KRESOURCES
780 mEventID =
event->uid();
781 mRevision =
event->revision();
782 mTemplateName.clear();
784 #ifndef KALARMCAL_USE_KRESOURCES
788 mOriginalResourceId.clear();
790 mTemplateAfterTime = -1;
794 mCommandXterm =
false;
795 mCommandDisplay =
false;
796 mCopyToKOrganizer =
false;
799 mReminderOnceOnly =
false;
801 mArchiveRepeatAtLogin =
false;
802 mDisplayingDefer =
false;
803 mDisplayingEdit =
false;
804 mDeferDefaultDateOnly =
false;
805 mReminderActive = NO_REMINDER;
806 mReminderMinutes = 0;
807 mDeferDefaultMinutes = 0;
809 mKMailSerialNumber = 0;
810 mExcludeHolidays = 0;
813 mBgColour = QColor(255, 255, 255);
814 mFgColour = QColor(0, 0, 0);
815 #ifndef KALARMCAL_USE_KRESOURCES
817 mReadOnly =
event->isReadOnly();
819 mUseDefaultFont =
true;
824 mCategory = CalEvent::status(event, ¶m);
828 const QStringList params = param.split(SC, QString::KeepEmptyParts);
829 int n = params.count();
832 #ifndef KALARMCAL_USE_KRESOURCES
833 const qlonglong
id = params[0].toLongLong(&ok);
837 mOriginalResourceId = params[0];
839 for (
int i = 1; i < n; ++i)
841 if (params[i] == DISP_DEFER)
842 mDisplayingDefer =
true;
843 if (params[i] == DISP_EDIT)
844 mDisplayingEdit =
true;
848 #ifndef KALARMCAL_USE_KRESOURCES
851 mCustomProperties =
event->customProperties();
852 for (QMap<QByteArray, QString>::Iterator it = mCustomProperties.begin(); it != mCustomProperties.end(); )
854 if (it.key().startsWith(kalarmKey))
855 it = mCustomProperties.erase(it);
861 bool dateOnly =
false;
862 QStringList flags =
event->customProperty(
KACalendar::APPNAME, FLAGS_PROPERTY).split(SC, QString::SkipEmptyParts);
863 flags << QString() << QString();
864 for (
int i = 0, end = flags.count() - 1; i < end; ++i)
866 QString flag = flags.at(i);
867 if (flag == DATE_ONLY_FLAG)
869 else if (flag == CONFIRM_ACK_FLAG)
871 else if (flag == EMAIL_BCC_FLAG)
873 else if (flag == KORGANIZER_FLAG)
874 mCopyToKOrganizer =
true;
875 else if (flag == EXCLUDE_HOLIDAYS_FLAG)
876 mExcludeHolidays = mHolidays;
877 else if (flag == WORK_TIME_ONLY_FLAG)
879 else if (flag == KMAIL_SERNUM_FLAG)
881 const unsigned long n = flags.at(i + 1).toULong(&ok);
884 mKMailSerialNumber = n;
887 else if (flag == KAEventPrivate::ARCHIVE_FLAG)
889 else if (flag == KAEventPrivate::AT_LOGIN_TYPE)
890 mArchiveRepeatAtLogin =
true;
891 else if (flag == KAEventPrivate::REMINDER_TYPE)
893 flag = flags.at(++i);
894 if (flag == KAEventPrivate::REMINDER_ONCE_FLAG)
896 mReminderOnceOnly =
true;
899 const int len = flag.length() - 1;
900 mReminderMinutes = -flag.left(len).toInt();
901 switch (flag.at(len).toLatin1())
904 case 'H': mReminderMinutes *= 60;
break;
905 case 'D': mReminderMinutes *= 1440;
break;
906 default: mReminderMinutes = 0;
break;
909 else if (flag == DEFER_FLAG)
911 QString mins = flags.at(i + 1);
912 if (mins.endsWith(QLatin1Char(
'D')))
914 mDeferDefaultDateOnly =
true;
915 mins.truncate(mins.length() - 1);
917 const int n =
static_cast<int>(mins.toUInt(&ok));
920 mDeferDefaultMinutes = n;
923 else if (flag == TEMPL_AFTER_TIME_FLAG)
925 const int n =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
928 mTemplateAfterTime = n;
931 else if (flag == LATE_CANCEL_FLAG)
933 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
936 if (!ok || !mLateCancel)
939 else if (flag == AUTO_CLOSE_FLAG)
941 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
944 if (!ok || !mLateCancel)
953 if (prop == xtermURL)
954 mCommandXterm =
true;
955 else if (prop == displayURL)
956 mCommandDisplay =
true;
964 const QStringList list = prop.split(QLatin1Char(
':'));
965 if (list.count() >= 2)
967 const int interval =
static_cast<int>(list[0].toUInt());
968 const int count =
static_cast<int>(list[1].toUInt());
969 if (interval && count)
971 if (interval % (24*60))
972 mRepetition.set(
Duration(interval * 60, Duration::Seconds), count);
974 mRepetition.set(
Duration(interval / (24*60), Duration::Days), count);
978 mNextMainDateTime = readDateTime(event, dateOnly, mStartDateTime);
979 mCreatedDateTime =
event->created();
980 if (dateOnly && !mRepetition.isDaily())
981 mRepetition.set(
Duration(mRepetition.intervalDays(), Duration::Days));
983 mTemplateName =
event->summary();
984 #ifndef KALARMCAL_USE_KRESOURCES
987 if (event->statusStr() == DISABLED_STATUS)
995 mRepeatAtLogin =
false;
997 mCommandScript =
false;
998 mExtraActionOptions = 0;
999 mDeferral = NO_DEFERRAL;
1002 mRepeatSoundPause = -1;
1004 mEmailFromIdentity = 0;
1005 mReminderAfterTime = DateTime();
1009 mPostAction.clear();
1010 mEmailSubject.clear();
1011 mEmailAddresses.clear();
1012 mEmailAttachments.clear();
1016 readAlarms(event, &alarmMap, mCommandDisplay);
1022 bool isEmailText =
false;
1023 bool setDeferralTime =
false;
1025 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
1027 const AlarmData& data = it.
value();
1028 const DateTime dateTime = data.alarm->hasStartOffset() ? data.alarm->startOffset().end(mNextMainDateTime.effectiveKDateTime()) : data.alarm->time();
1032 mMainExpired =
false;
1034 alTime.setDateOnly(mStartDateTime.isDateOnly());
1035 if (data.alarm->repeatCount() && data.alarm->snoozeTime())
1037 mRepetition.set(data.alarm->snoozeTime(), data.alarm->repeatCount());
1038 mNextRepeat = data.nextRepeat;
1044 mAudioFile = data.cleanText;
1045 mSpeak = data.speak && mAudioFile.isEmpty();
1046 mBeep = !mSpeak && mAudioFile.isEmpty();
1047 mSoundVolume = (!mBeep && !mSpeak) ? data.soundVolume : -1;
1048 mFadeVolume = (mSoundVolume >= 0 && data.fadeSeconds > 0) ? data.fadeVolume : -1;
1049 mFadeSeconds = (mFadeVolume >= 0) ? data.fadeSeconds : 0;
1050 mRepeatSoundPause = (!mBeep && !mSpeak) ? data.repeatSoundPause : -1;
1052 case AT_LOGIN_ALARM:
1053 mRepeatAtLogin =
true;
1054 mAtLoginDateTime = dateTime.kDateTime();
1055 alTime = mAtLoginDateTime;
1057 case REMINDER_ALARM:
1059 if (data.alarm->startOffset().asSeconds() / 60)
1061 mReminderActive = ACTIVE_REMINDER;
1062 if (mReminderMinutes < 0)
1064 mReminderAfterTime = dateTime;
1065 mReminderAfterTime.setDateOnly(dateOnly);
1066 if (data.hiddenReminder)
1067 mReminderActive = HIDDEN_REMINDER;
1071 case DEFERRED_REMINDER_ALARM:
1072 case DEFERRED_ALARM:
1073 mDeferral = (data.type == DEFERRED_REMINDER_ALARM) ? REMINDER_DEFERRAL : NORMAL_DEFERRAL;
1074 mDeferralTime = dateTime;
1075 if (!data.timedDeferral)
1076 mDeferralTime.setDateOnly(
true);
1077 if (data.alarm->hasStartOffset())
1078 deferralOffset = data.alarm->startOffset();
1080 case DISPLAYING_ALARM:
1083 mDisplayingFlags = data.displayingFlags;
1084 const bool dateOnly = (mDisplayingFlags & DEFERRAL) ? !(mDisplayingFlags & TIMED_FLAG)
1085 : mStartDateTime.isDateOnly();
1086 mDisplayingTime = dateTime;
1087 mDisplayingTime.setDateOnly(dateOnly);
1088 alTime = mDisplayingTime;
1091 case PRE_ACTION_ALARM:
1092 mPreAction = data.cleanText;
1093 mExtraActionOptions = data.extraActionOptions;
1095 case POST_ACTION_ALARM:
1096 mPostAction = data.cleanText;
1103 bool noSetNextTime =
false;
1106 case DEFERRED_REMINDER_ALARM:
1107 case DEFERRED_ALARM:
1112 setDeferralTime =
true;
1113 noSetNextTime =
true;
1116 case REMINDER_ALARM:
1117 case AT_LOGIN_ALARM:
1118 case DISPLAYING_ALARM:
1119 if (!set && !noSetNextTime)
1120 mNextMainDateTime = alTime;
1128 mText = (mActionSubType ==
KAEvent::COMMAND) ? data.cleanText.trimmed() : data.cleanText;
1129 switch (data.action)
1132 mCommandScript = data.commandScript;
1133 if (!mCommandDisplay)
1138 mUseDefaultFont = data.defaultFont;
1139 if (data.isEmailText)
1143 mBgColour = data.bgColour;
1144 mFgColour = data.fgColour;
1147 mEmailFromIdentity = data.emailFromId;
1148 mEmailAddresses = data.alarm->mailAddresses();
1149 mEmailSubject = data.alarm->mailSubject();
1150 mEmailAttachments = data.alarm->mailAttachments();
1154 mRepeatSoundPause = data.repeatSoundPause;
1166 case PRE_ACTION_ALARM:
1167 case POST_ACTION_ALARM:
1174 mKMailSerialNumber = 0;
1177 if (recur && recur->
recurs())
1179 const int nextRepeat = mNextRepeat;
1180 setRecurrence(*recur);
1181 if (nextRepeat <= mRepetition.count())
1182 mNextRepeat = nextRepeat;
1184 else if (mRepetition)
1187 if (mRepetition.isDaily())
1188 setRecur(RecurrenceRule::rDaily, mRepetition.intervalDays(), mRepetition.count() + 1, QDate());
1190 setRecur(RecurrenceRule::rMinutely, mRepetition.intervalMinutes(), mRepetition.count() + 1, KDateTime());
1191 mRepetition.set(0, 0);
1192 mTriggerChanged =
true;
1197 mArchiveRepeatAtLogin =
false;
1198 if (mReminderMinutes > 0)
1200 mReminderMinutes = 0;
1201 mReminderActive = NO_REMINDER;
1203 setRepeatAtLoginTrue(
false);
1210 DateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1211 dt.setDateOnly(mStartDateTime.isDateOnly());
1212 if (mDeferralTime.isDateOnly())
1214 mDeferralTime = deferralOffset.
end(dt.kDateTime());
1215 mDeferralTime.setDateOnly(
true);
1218 mDeferralTime = deferralOffset.
end(dt.effectiveKDateTime());
1220 if (mDeferral != NO_DEFERRAL)
1222 if (setDeferralTime)
1223 mNextMainDateTime = mDeferralTime;
1225 mTriggerChanged =
true;
1229 void KAEvent::set(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
1230 const QFont& f,
SubAction act,
int lateCancel, Flags flags,
bool changesPending)
1232 d->set(dt, message, bg, fg, f, act, lateCancel, flags, changesPending);
1238 void KAEventPrivate::set(
const KDateTime& dateTime,
const QString& text,
const QColor& bg,
const QColor& fg,
1240 bool changesPending)
1243 mStartDateTime = dateTime;
1245 mNextMainDateTime = mStartDateTime;
1260 mTemplateName.clear();
1261 #ifndef KALARMCAL_USE_KRESOURCES
1266 mOriginalResourceId.clear();
1269 mPostAction.clear();
1273 mAudioFile = (mActionSubType ==
KAEvent::AUDIO) ? text : QString();
1276 mTemplateAfterTime = -1;
1282 mLateCancel = lateCancel;
1283 mDeferral = NO_DEFERRAL;
1285 mStartDateTime.setDateOnly(flags & KAEvent::ANY_TIME);
1286 set_deferral((flags & DEFERRAL) ? NORMAL_DEFERRAL : NO_DEFERRAL);
1298 mDisplaying = flags & DISPLAYING_;
1307 setRepeatAtLoginTrue(
false);
1310 mKMailSerialNumber = 0;
1311 mReminderMinutes = 0;
1312 mDeferDefaultMinutes = 0;
1313 mDeferDefaultDateOnly =
false;
1314 mArchiveRepeatAtLogin =
false;
1315 mReminderActive = NO_REMINDER;
1316 mDisplaying =
false;
1317 mMainExpired =
false;
1318 mDisplayingDefer =
false;
1319 mDisplayingEdit =
false;
1321 mReminderAfterTime = DateTime();
1322 mExtraActionOptions = 0;
1323 #ifndef KALARMCAL_USE_KRESOURCES
1328 mChangeCount = changesPending ? 1 : 0;
1329 mTriggerChanged =
true;
1338 #ifndef KALARMCAL_USE_KRESOURCES
1341 return d->updateKCalEvent(e, u, setCustomProperties);
1347 return d->updateKCalEvent(e, u);
1351 #ifndef KALARMCAL_USE_KRESOURCES
1363 || (!mAlarmCount && (!archived || !mMainExpired)))
1368 const bool readOnly = ev->isReadOnly();
1370 ev->setUid(mEventID);
1371 #ifndef KALARMCAL_USE_KRESOURCES
1372 ev->setReadOnly(mReadOnly);
1374 ev->setReadOnly(
false);
1376 ev->setTransparency(Event::Transparent);
1381 #ifndef KALARMCAL_USE_KRESOURCES
1382 if (setCustomProperties)
1383 ev->setCustomProperties(mCustomProperties);
1393 #ifndef KALARMCAL_USE_KRESOURCES
1394 param = QString::number(mCollectionId);
1396 param = mOriginalResourceId;
1398 if (mDisplayingDefer)
1399 param += SC + DISP_DEFER;
1400 if (mDisplayingEdit)
1401 param += SC + DISP_EDIT;
1403 #ifndef KALARMCAL_USE_KRESOURCES
1404 CalEvent::setStatus(ev, mCategory, param);
1406 CalEvent::setStatus(ev, mCategory, param);
1409 if (mStartDateTime.isDateOnly())
1410 flags += DATE_ONLY_FLAG;
1412 flags += CONFIRM_ACK_FLAG;
1414 flags += EMAIL_BCC_FLAG;
1415 if (mCopyToKOrganizer)
1416 flags += KORGANIZER_FLAG;
1417 if (mExcludeHolidays)
1418 flags += EXCLUDE_HOLIDAYS_FLAG;
1420 flags += WORK_TIME_ONLY_FLAG;
1422 (flags += (mAutoClose ? AUTO_CLOSE_FLAG : LATE_CANCEL_FLAG)) += QString::number(mLateCancel);
1423 if (mReminderMinutes)
1425 flags += REMINDER_TYPE;
1426 if (mReminderOnceOnly)
1427 flags += REMINDER_ONCE_FLAG;
1428 flags += reminderToString(-mReminderMinutes);
1430 if (mDeferDefaultMinutes)
1432 QString param = QString::number(mDeferDefaultMinutes);
1433 if (mDeferDefaultDateOnly)
1434 param += QLatin1Char(
'D');
1435 (flags += DEFER_FLAG) += param;
1437 if (!mTemplateName.isEmpty() && mTemplateAfterTime >= 0)
1438 (flags += TEMPL_AFTER_TIME_FLAG) += QString::number(mTemplateAfterTime);
1439 if (mKMailSerialNumber)
1440 (flags += KMAIL_SERNUM_FLAG) += QString::number(mKMailSerialNumber);
1441 if (mArchive && !archived)
1443 flags += ARCHIVE_FLAG;
1444 if (mArchiveRepeatAtLogin)
1445 flags += AT_LOGIN_TYPE;
1447 if (!flags.isEmpty())
1452 else if (mCommandDisplay)
1454 else if (!mLogFile.isEmpty())
1457 ev->setCustomStatus(mEnabled ? QString() : DISABLED_STATUS);
1458 ev->setRevision(mRevision);
1473 ev->setDtStart(mStartDateTime.calendarKDateTime());
1474 ev->setAllDay(
false);
1475 ev->setDtEnd(KDateTime());
1477 const DateTime dtMain = archived ? mStartDateTime : mNextMainDateTime;
1478 int ancillaryType = 0;
1479 DateTime ancillaryTime;
1480 int ancillaryOffset = 0;
1481 if (!mMainExpired || archived)
1490 QDateTime dt = mNextMainDateTime.kDateTime().toTimeSpec(mStartDateTime.timeSpec()).dateTime();
1492 dt.toString(mNextMainDateTime.isDateOnly() ? QLatin1String(
"yyyyMMdd") : QLatin1String(
"yyyyMMddThhmmss")));
1495 initKCalAlarm(ev, 0, QStringList(), MAIN_ALARM);
1496 ancillaryOffset = 0;
1497 ancillaryType = dtMain.isValid() ? 2 : 0;
1499 else if (mRepetition)
1503 const QString param = QString::fromLatin1(
"%1:%2").arg(mRepetition.intervalMinutes()).arg(mRepetition.count());
1508 if (mRepeatAtLogin || (mArchiveRepeatAtLogin && archived))
1511 if (mArchiveRepeatAtLogin)
1512 dtl = mStartDateTime.calendarKDateTime().addDays(-1);
1513 else if (mAtLoginDateTime.isValid())
1514 dtl = mAtLoginDateTime;
1515 else if (mStartDateTime.isDateOnly())
1516 dtl = DateTime(KDateTime::currentLocalDate().addDays(-1), mStartDateTime.timeSpec());
1518 dtl = KDateTime::currentUtcDateTime();
1519 initKCalAlarm(ev, dtl, QStringList(AT_LOGIN_TYPE));
1520 if (!ancillaryType && dtl.isValid())
1522 ancillaryTime = dtl;
1528 DateTime nextDateTime = mNextMainDateTime;
1532 nextDateTime = mStartDateTime;
1540 KDateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1541 dt.setDateOnly(mStartDateTime.isDateOnly());
1546 if (mReminderMinutes && (mReminderActive != NO_REMINDER || archived))
1549 if (mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
1552 startOffset = nextDateTime.calendarKDateTime().secsTo(mReminderAfterTime.calendarKDateTime());
1557 startOffset = -mReminderMinutes * 60;
1559 initKCalAlarm(ev, startOffset, QStringList(REMINDER_TYPE));
1561 if (!ancillaryType && (mReminderActive == ACTIVE_REMINDER || archived))
1563 ancillaryOffset = startOffset;
1567 if (mDeferral != NO_DEFERRAL)
1571 if (mDeferralTime.isDateOnly())
1573 startOffset = nextDateTime.secsTo(mDeferralTime.calendarKDateTime());
1574 list += DATE_DEFERRAL_TYPE;
1578 startOffset = nextDateTime.calendarKDateTime().secsTo(mDeferralTime.calendarKDateTime());
1579 list += TIME_DEFERRAL_TYPE;
1581 if (mDeferral == REMINDER_DEFERRAL)
1582 list += REMINDER_TYPE;
1583 initKCalAlarm(ev, startOffset, list);
1584 if (!ancillaryType && mDeferralTime.isValid())
1586 ancillaryOffset = startOffset;
1590 if (!mTemplateName.isEmpty())
1591 ev->setSummary(mTemplateName);
1592 else if (mDisplaying)
1594 QStringList list(DISPLAYING_TYPE);
1595 if (mDisplayingFlags & KAEvent::REPEAT_AT_LOGIN)
1596 list += AT_LOGIN_TYPE;
1597 else if (mDisplayingFlags & DEFERRAL)
1599 if (mDisplayingFlags & TIMED_FLAG)
1600 list += TIME_DEFERRAL_TYPE;
1602 list += DATE_DEFERRAL_TYPE;
1604 if (mDisplayingFlags & REMINDER)
1605 list += REMINDER_TYPE;
1606 initKCalAlarm(ev, mDisplayingTime, list);
1607 if (!ancillaryType && mDisplayingTime.isValid())
1609 ancillaryTime = mDisplayingTime;
1613 if ((mBeep || mSpeak || !mAudioFile.isEmpty()) && mActionSubType !=
KAEvent::AUDIO)
1616 if (ancillaryType == 2)
1617 initKCalAlarm(ev, ancillaryOffset, QStringList(), AUDIO_ALARM);
1619 initKCalAlarm(ev, ancillaryTime, QStringList(), AUDIO_ALARM);
1621 if (!mPreAction.isEmpty())
1624 if (ancillaryType == 2)
1625 initKCalAlarm(ev, ancillaryOffset, QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1627 initKCalAlarm(ev, ancillaryTime, QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1629 if (!mPostAction.isEmpty())
1632 if (ancillaryType == 2)
1633 initKCalAlarm(ev, ancillaryOffset, QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1635 initKCalAlarm(ev, ancillaryTime, QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1639 mRecurrence->writeRecurrence(*ev->recurrence());
1641 ev->clearRecurrence();
1642 if (mCreatedDateTime.isValid())
1643 ev->setCreated(mCreatedDateTime);
1644 ev->setReadOnly(readOnly);
1656 #ifndef KALARMCAL_USE_KRESOURCES
1657 Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1659 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1662 const int startOffset = dt.isDateOnly() ? mStartDateTime.secsTo(dt)
1663 : mStartDateTime.calendarKDateTime().secsTo(dt.calendarKDateTime());
1664 return initKCalAlarm(event, startOffset, types, type);
1667 #ifndef KALARMCAL_USE_KRESOURCES
1668 Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1670 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1673 QStringList alltypes;
1675 #ifndef KALARMCAL_USE_KRESOURCES
1678 Alarm* alarm =
event->newAlarm();
1681 if (type != MAIN_ALARM)
1691 setAudioAlarm(alarm);
1693 flags << KAEventPrivate::SPEAK_FLAG;
1694 if (mRepeatSoundPause >= 0)
1702 case PRE_ACTION_ALARM:
1703 setProcedureAlarm(alarm, mPreAction);
1705 flags << KAEventPrivate::EXEC_ON_DEFERRAL_FLAG;
1707 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
1709 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
1711 case POST_ACTION_ALARM:
1712 setProcedureAlarm(alarm, mPostAction);
1719 QString::number(mNextRepeat));
1721 case REMINDER_ALARM:
1724 if (types == QStringList(REMINDER_TYPE)
1725 && mReminderMinutes < 0 && mReminderActive == HIDDEN_REMINDER)
1729 flags << HIDDEN_REMINDER_FLAG;
1731 bool display =
false;
1732 switch (mActionSubType)
1735 alltypes += FILE_TYPE;
1745 setProcedureAlarm(alarm, mText);
1746 display = mCommandDisplay;
1749 alarm->
setEmailAlarm(mEmailSubject, mText, mEmailAddresses, mEmailAttachments);
1750 if (mEmailFromIdentity)
1751 flags << KAEventPrivate::EMAIL_ID_FLAG << QString::number(mEmailFromIdentity);
1754 setAudioAlarm(alarm);
1755 if (mRepeatSoundPause >= 0)
1757 alltypes += SOUND_REPEAT_TYPE;
1758 if (type == MAIN_ALARM)
1759 alltypes += QString::number(mRepeatSoundPause);
1765 QString::fromLatin1(
"%1;%2;%3").arg(mBgColour.name())
1766 .arg(mFgColour.name())
1767 .arg(mUseDefaultFont ? QString() : mFont.toString()));
1770 case DEFERRED_ALARM:
1771 case DEFERRED_REMINDER_ALARM:
1772 case AT_LOGIN_ALARM:
1773 case DISPLAYING_ALARM:
1777 if (!alltypes.isEmpty())
1779 if (!flags.isEmpty())
1786 return d->mAlarmCount && (d->mAlarmCount != 1 || !d->mRepeatAtLogin);
1791 d->mEnabled = enable;
1799 #ifndef KALARMCAL_USE_KRESOURCES
1807 return d->mReadOnly;
1823 return d->mMainExpired;
1836 KAEvent::Flags KAEventPrivate::flags()
const
1838 KAEvent::Flags result(0);
1842 if (mStartDateTime.isDateOnly()) result |= KAEvent::ANY_TIME;
1873 mEventID = CalEvent::uid(mEventID, s);
1875 mTriggerChanged =
true;
1880 return d->mCategory;
1900 return d->mRevision;
1903 #ifndef KALARMCAL_USE_KRESOURCES
1906 d->mCollectionId =
id;
1911 d->mCollectionId =
id;
1917 return d->mDisplaying ? -1 : d->mCollectionId;
1939 switch (d->mCategory)
1944 default: Q_ASSERT(0);
return false;
1946 if (!collectionMimeTypes.contains(mimetype))
1948 item.setMimeType(mimetype);
1949 item.setPayload<
KAEvent>(*this);
1955 d->mCompatibility = c;
1960 return d->mCompatibility;
1965 return d->mCustomProperties;
1969 void KAEvent::setResource(AlarmResource* r)
1974 AlarmResource* KAEvent::resource()
const
1976 return d->mResource;
1982 return d->mActionSubType;
1987 switch (d->mActionSubType)
2000 if (d->mRepeatAtLogin)
2002 d->mLateCancel = minutes;
2004 d->mAutoClose =
false;
2009 return d->mLateCancel;
2019 return d->mAutoClose;
2022 void KAEvent::setKMailSerialNumber(
unsigned long n)
2024 d->mKMailSerialNumber = n;
2027 unsigned long KAEvent::kmailSerialNumber()
const
2029 return d->mKMailSerialNumber;
2039 return (d->mActionSubType ==
MESSAGE
2040 || d->mActionSubType ==
EMAIL) ? d->mText : QString();
2045 return (d->mActionSubType ==
MESSAGE) ? d->mText : QString();
2050 return (d->mActionSubType ==
FILE) ? d->mText : QString();
2055 return d->mBgColour;
2060 return d->mFgColour;
2065 KAEventPrivate::mDefaultFont = f;
2070 return d->mUseDefaultFont;
2075 return d->mUseDefaultFont ? KAEventPrivate::mDefaultFont : d->mFont;
2080 return (d->mActionSubType ==
COMMAND) ? d->mText : QString();
2085 return d->mCommandScript;
2090 return d->mCommandXterm;
2095 return d->mCommandDisplay;
2098 #ifndef KALARMCAL_USE_KRESOURCES
2101 d->mCommandError = t;
2111 d->setCommandError(t, writeConfig);
2116 kDebug() << mEventID <<
"," << error;
2117 if (error == mCommandError)
2119 mCommandError = error;
2122 KConfigGroup config(KGlobal::config(), mCmdErrConfigGroup);
2124 config.deleteEntry(mEventID);
2128 switch (mCommandError)
2133 case KAEvent::CMD_ERROR_PRE_POST:
2134 errtext = CMD_ERROR_PRE_VALUE +
',' + CMD_ERROR_POST_VALUE;
2139 config.writeEntry(mEventID, errtext);
2150 d->setCommandError(configString);
2153 void KAEventPrivate::setCommandError(
const QString& configString)
2156 const QStringList errs = configString.split(
',');
2157 if (errs.indexOf(CMD_ERROR_VALUE) >= 0)
2161 if (errs.indexOf(CMD_ERROR_PRE_VALUE) >= 0)
2163 if (errs.indexOf(CMD_ERROR_POST_VALUE) >= 0)
2168 QString KAEvent::commandErrorConfigGroup()
2170 return KAEventPrivate::mCmdErrConfigGroup;
2176 return d->mCommandError;
2181 d->mLogFile = logfile;
2182 if (!logfile.isEmpty())
2183 d->mCommandDisplay = d->mCommandXterm =
false;
2193 return d->mConfirmAck;
2198 return d->mCopyToKOrganizer;
2201 #ifndef KALARMCAL_USE_KRESOURCES
2203 const QStringList& attachments)
2205 void KAEvent::setEmail(uint from,
const QList<KCal::Person>& addresses,
const QString& subject,
2206 const QStringList& attachments)
2209 d->mEmailFromIdentity = from;
2210 d->mEmailAddresses = addresses;
2211 d->mEmailSubject = subject;
2212 d->mEmailAttachments = attachments;
2217 return (d->mActionSubType ==
EMAIL) ? d->mText : QString();
2222 return d->mEmailFromIdentity;
2225 #ifndef KALARMCAL_USE_KRESOURCES
2231 return d->mEmailAddresses;
2236 return static_cast<QStringList
>(d->mEmailAddresses);
2241 return d->mEmailAddresses.join(sep);
2244 #ifndef KALARMCAL_USE_KRESOURCES
2250 return EmailAddressList(addresses).join(separator);
2255 return d->mEmailAddresses.pureAddresses();
2260 return d->mEmailAddresses.pureAddresses(sep);
2265 return d->mEmailSubject;
2270 return d->mEmailAttachments;
2275 return d->mEmailAttachments.join(sep);
2280 return d->mEmailBcc;
2283 void KAEvent::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2285 d->setAudioFile(filename, volume, fadeVolume, fadeSeconds, repeatPause, allowEmptyFile);
2288 void KAEventPrivate::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2290 mAudioFile = filename;
2291 mSoundVolume = (!allowEmptyFile && filename.isEmpty()) ? -1 : volume;
2292 if (mSoundVolume >= 0)
2294 mFadeVolume = (fadeSeconds > 0) ? fadeVolume : -1;
2295 mFadeSeconds = (mFadeVolume >= 0) ? fadeSeconds : 0;
2302 mRepeatSoundPause = repeatPause;
2307 return d->mAudioFile;
2312 return d->mSoundVolume;
2317 return d->mSoundVolume >= 0 && d->mFadeSeconds ? d->mFadeVolume : -1;
2322 return d->mSoundVolume >= 0 && d->mFadeVolume >= 0 ? d->mFadeSeconds : 0;
2327 return d->mRepeatSoundPause >= 0;
2332 return d->mRepeatSoundPause;
2342 return (d->mActionSubType ==
MESSAGE
2343 || (d->mActionSubType ==
COMMAND && d->mCommandDisplay))
2353 d->mTemplateName = name;
2354 d->mTemplateAfterTime = afterTime;
2355 d->mTriggerChanged =
true;
2360 return !d->mTemplateName.isEmpty();
2365 return d->mTemplateName;
2370 return d->mTemplateAfterTime == 0;
2375 return d->mTemplateAfterTime;
2380 d->mPreAction = pre;
2381 d->mPostAction = post;
2382 d->mExtraActionOptions = options;
2387 ExtraActionOptions opts(0);
2397 return d->mPreAction;
2402 return d->mPostAction;
2407 return d->mExtraActionOptions;
2426 d->setReminder(minutes, onceOnly);
2429 void KAEventPrivate::setReminder(
int minutes,
bool onceOnly)
2431 if (minutes > 0 && mRepeatAtLogin)
2433 if (minutes != mReminderMinutes || (minutes && mReminderActive != ACTIVE_REMINDER))
2435 if (minutes && mReminderActive == NO_REMINDER)
2437 else if (!minutes && mReminderActive != NO_REMINDER)
2439 mReminderMinutes = minutes;
2440 mReminderActive = minutes ? ACTIVE_REMINDER : NO_REMINDER;
2441 mReminderOnceOnly = onceOnly;
2443 mTriggerChanged =
true;
2453 d->activateReminderAfter(mainAlarmTime);
2456 void KAEventPrivate::activateReminderAfter(
const DateTime& mainAlarmTime)
2458 if (mReminderMinutes >= 0 || mReminderActive == ACTIVE_REMINDER || !mainAlarmTime.
isValid())
2468 || mainAlarmTime != next)
2471 else if (!mRepeatAtLogin)
2474 if (mainAlarmTime != mStartDateTime)
2478 const DateTime reminderTime = mainAlarmTime.
addMins(-mReminderMinutes);
2481 && reminderTime >= next)
2485 activate_reminder(
true);
2486 mReminderAfterTime = reminderTime;
2491 return d->mReminderMinutes;
2496 return d->mReminderActive == KAEventPrivate::ACTIVE_REMINDER;
2501 return d->mReminderOnceOnly;
2506 return d->mDeferral == KAEventPrivate::REMINDER_DEFERRAL;
2517 return d->defer(dt, reminder, adjustRecurrence);
2520 void KAEventPrivate::defer(
const DateTime& dateTime,
bool reminder,
bool adjustRecurrence)
2523 bool setNextRepetition =
false;
2524 bool checkRepetition =
false;
2525 bool checkReminderAfter =
false;
2529 if (mReminderMinutes)
2531 bool deferReminder =
false;
2532 if (mReminderMinutes > 0)
2536 deferReminder =
true;
2537 else if (mReminderActive == ACTIVE_REMINDER || mDeferral == REMINDER_DEFERRAL)
2540 set_deferral(NO_DEFERRAL);
2541 mTriggerChanged =
true;
2544 else if (mReminderMinutes < 0 && reminder)
2545 deferReminder =
true;
2548 set_deferral(REMINDER_DEFERRAL);
2549 mDeferralTime = dateTime;
2550 mTriggerChanged =
true;
2552 if (mReminderActive == ACTIVE_REMINDER)
2554 activate_reminder(
false);
2555 mTriggerChanged =
true;
2558 if (mDeferral != REMINDER_DEFERRAL)
2562 mNextMainDateTime = mDeferralTime = dateTime;
2563 set_deferral(NORMAL_DEFERRAL);
2564 mTriggerChanged =
true;
2565 checkReminderAfter =
true;
2569 mMainExpired =
true;
2574 mArchiveRepeatAtLogin =
true;
2575 mRepeatAtLogin =
false;
2588 set_deferral(NO_DEFERRAL);
2592 set_deferral(REMINDER_DEFERRAL);
2593 mDeferralTime = dateTime;
2594 checkRepetition =
true;
2596 mTriggerChanged =
true;
2601 mDeferralTime = dateTime;
2602 if (mDeferral == NO_DEFERRAL)
2603 set_deferral(NORMAL_DEFERRAL);
2604 mTriggerChanged =
true;
2605 checkReminderAfter =
true;
2606 if (adjustRecurrence)
2608 const KDateTime now = KDateTime::currentUtcDateTime();
2609 if (mainEndRepeatTime() < now)
2615 mMainExpired =
true;
2620 setNextRepetition = mRepetition;
2623 checkRepetition =
true;
2625 if (checkReminderAfter && mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
2629 mReminderActive = (mDeferralTime < mReminderAfterTime) ? ACTIVE_REMINDER : HIDDEN_REMINDER;
2631 if (checkRepetition)
2632 setNextRepetition = (mRepetition && mDeferralTime < mainEndRepeatTime());
2633 if (setNextRepetition)
2637 if (mNextMainDateTime >= mDeferralTime)
2640 mNextRepeat = mRepetition.nextRepeatCount(mNextMainDateTime.kDateTime(), mDeferralTime.kDateTime());
2641 mTriggerChanged =
true;
2654 void KAEventPrivate::cancelDefer()
2656 if (mDeferral != NO_DEFERRAL)
2659 set_deferral(NO_DEFERRAL);
2660 mTriggerChanged =
true;
2666 d->mDeferDefaultMinutes = minutes;
2667 d->mDeferDefaultDateOnly = dateOnly;
2672 return d->mDeferral > 0;
2677 return d->mDeferralTime;
2685 return d->deferralLimit(limitType);
2698 const KDateTime now = KDateTime::currentUtcDateTime();
2704 else if (mReminderActive == ACTIVE_REMINDER && mReminderMinutes > 0
2705 && (now < (reminderTime = endTime.
addMins(-mReminderMinutes))))
2707 endTime = reminderTime;
2713 else if (mReminderMinutes < 0)
2717 if (KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2719 endTime = mNextMainDateTime;
2723 else if (mReminderMinutes > 0
2724 && KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2728 endTime = mNextMainDateTime;
2732 endTime = endTime.
addMins(-1);
2740 return d->mDeferDefaultMinutes;
2745 return d->mDeferDefaultDateOnly;
2750 return d->mStartDateTime;
2755 d->mNextMainDateTime = dt;
2756 d->mTriggerChanged =
true;
2761 return d->mainDateTime(withRepeats);
2766 return d->mNextMainDateTime.effectiveTime();
2771 return d->mainEndRepeatTime();
2781 #warning Does this need all trigger times for date-only alarms to be recalculated?
2792 for (
int i = 0, end = events.count(); i < end; ++i)
2794 KAEventPrivate*
const p = events[i]->d;
2796 p->mRecurrence->setStartDateTime(p->mStartDateTime.effectiveKDateTime(),
true);
2802 d->calcTriggerTimes();
2811 const bool reminderAfter = d->mMainExpired && d->mReminderActive && d->mReminderMinutes < 0;
2813 ? (reminderAfter ? d->mAllWorkTrigger : d->mMainWorkTrigger)
2814 : (reminderAfter ? d->mAllTrigger : d->mMainTrigger);
2822 d->mCreatedDateTime = dt;
2827 return d->mCreatedDateTime;
2835 d->setRepeatAtLogin(rl);
2838 void KAEventPrivate::setRepeatAtLogin(
bool rl)
2840 if (rl && !mRepeatAtLogin)
2842 setRepeatAtLoginTrue(
true);
2845 else if (!rl && mRepeatAtLogin)
2847 mRepeatAtLogin = rl;
2848 mTriggerChanged =
true;
2854 void KAEventPrivate::setRepeatAtLoginTrue(
bool clearReminder)
2857 if (mReminderMinutes >= 0 && clearReminder)
2858 setReminder(0,
false);
2861 mCopyToKOrganizer =
false;
2866 return d->mRepeatAtLogin || (includeArchived && d->mArchiveRepeatAtLogin);
2871 d->mExcludeHolidays = ex ? KAEventPrivate::mHolidays : 0;
2878 return d->mExcludeHolidays;
2890 KAEventPrivate::mHolidays = &h;
2895 d->mWorkTimeOnly = wto;
2902 return d->mWorkTimeOnly;
2911 return d->isWorkingTime(dt);
2914 bool KAEventPrivate::isWorkingTime(
const KDateTime& dt)
const
2916 if ((mWorkTimeOnly && !mWorkDays.testBit(dt.date().dayOfWeek() - 1))
2917 || (mExcludeHolidays && mHolidays && mHolidays->isHoliday(dt.date())))
2921 return dt.isDateOnly()
2922 || (dt.time() >= mWorkDayStart && dt.time() < mWorkDayEnd);
2932 if (days != KAEventPrivate::mWorkDays || start != KAEventPrivate::mWorkDayStart || end != KAEventPrivate::mWorkDayEnd)
2934 KAEventPrivate::mWorkDays = days;
2935 KAEventPrivate::mWorkDayStart = start;
2936 KAEventPrivate::mWorkDayEnd = end;
2937 if (!++KAEventPrivate::mWorkTimeIndex)
2938 ++KAEventPrivate::mWorkTimeIndex;
2950 void KAEventPrivate::clearRecur()
2952 if (mRecurrence || mRepetition)
2956 mRepetition.set(0, 0);
2957 mTriggerChanged =
true;
2968 d->setRecurrence(recurrence);
2971 void KAEventPrivate::setRecurrence(
const KARecurrence& recurrence)
2978 mRecurrence->setStartDateTime(mStartDateTime.effectiveKDateTime(), mStartDateTime.isDateOnly());
2979 mTriggerChanged =
true;
2982 setRepetition(mRepetition);
3002 const bool success = d->setRecur(RecurrenceRule::rMinutely, freq, count, end);
3003 d->mTriggerChanged =
true;
3020 const bool success = d->setRecur(RecurrenceRule::rDaily, freq, count, end);
3024 for (
int i = 0; i < 7; ++i)
3026 if (days.testBit(i))
3030 d->mRecurrence->addWeeklyDays(days);
3032 d->mTriggerChanged =
true;
3049 const bool success = d->setRecur(RecurrenceRule::rWeekly, freq, count, end);
3051 d->mRecurrence->addWeeklyDays(days);
3052 d->mTriggerChanged =
true;
3069 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3072 for (
int i = 0, end = days.count(); i < end; ++i)
3073 d->mRecurrence->addMonthlyDate(days[i]);
3075 d->mTriggerChanged =
true;
3093 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3096 for (
int i = 0, end = posns.count(); i < end; ++i)
3097 d->mRecurrence->addMonthlyPos(posns[i].weeknum, posns[i].days);
3099 d->mTriggerChanged =
true;
3119 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end, feb29);
3122 for (
int i = 0, end = months.count(); i < end; ++i)
3123 d->mRecurrence->addYearlyMonth(months[i]);
3125 d->mRecurrence->addMonthlyDate(day);
3127 d->mTriggerChanged =
true;
3146 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end);
3151 for (iend = months.count(); i < iend; ++i)
3152 d->mRecurrence->addYearlyMonth(months[i]);
3153 for (i = 0, iend = posns.count(); i < iend; ++i)
3154 d->mRecurrence->addYearlyPos(posns[i].weeknum, posns[i].days);
3156 d->mTriggerChanged =
true;
3172 KDateTime edt = mNextMainDateTime.kDateTime();
3174 return setRecur(recurType, freq, count, edt, feb29);
3178 if (count >= -1 && (count || end.date().isValid()))
3181 mRecurrence =
new KARecurrence;
3182 if (mRecurrence->init(recurType, freq, count, mNextMainDateTime.kDateTime(), end, feb29))
3196 return d->checkRecur();
3201 return d->mRecurrence;
3211 switch (d->mRecurrence->type())
3220 return d->mRecurrence->frequency();
3230 return d->mRecurrence ? d->mRecurrence->longestInterval() :
Duration(0);
3240 d->setFirstRecurrence();
3243 void KAEventPrivate::setFirstRecurrence()
3245 switch (checkRecur())
3252 if (mRecurrence->yearMonths().isEmpty())
3261 const KDateTime recurStart = mRecurrence->startDateTime();
3262 if (mRecurrence->recursOn(recurStart.date(), recurStart.timeSpec()))
3266 const int frequency = mRecurrence->frequency();
3267 mRecurrence->setFrequency(1);
3269 nextRecurrence(mNextMainDateTime.effectiveKDateTime(), next);
3270 if (!next.isValid())
3271 mRecurrence->setStartDateTime(recurStart, mStartDateTime.isDateOnly());
3274 mRecurrence->setStartDateTime(next.effectiveKDateTime(), next.isDateOnly());
3275 mStartDateTime = mNextMainDateTime = next;
3276 mTriggerChanged =
true;
3278 mRecurrence->setFrequency(frequency);
3286 if (d->mRepeatAtLogin)
3287 return brief ? i18nc(
"@info/plain Brief form of 'At Login'",
"Login") : i18nc(
"@info/plain",
"At login");
3290 const int frequency = d->mRecurrence->frequency();
3291 switch (d->mRecurrence->defaultRRuleConst()->recurrenceType())
3293 case RecurrenceRule::rMinutely:
3295 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", frequency);
3296 else if (frequency % 60 == 0)
3297 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", frequency/60);
3301 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", frequency/60, mins.sprintf(
"%02d", frequency%60));
3303 case RecurrenceRule::rDaily:
3304 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", frequency);
3305 case RecurrenceRule::rWeekly:
3306 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", frequency);
3307 case RecurrenceRule::rMonthly:
3308 return i18ncp(
"@info/plain",
"1 Month",
"%1 Months", frequency);
3309 case RecurrenceRule::rYearly:
3310 return i18ncp(
"@info/plain",
"1 Year",
"%1 Years", frequency);
3311 case RecurrenceRule::rNone:
3316 return brief ? QString() : i18nc(
"@info/plain No recurrence",
"None");
3327 return d->setRepetition(r);
3330 bool KAEventPrivate::setRepetition(
const Repetition& repetition)
3335 if (repetition && !mRepeatAtLogin)
3338 if (!repetition.
isDaily() && mStartDateTime.isDateOnly())
3340 mRepetition.set(0, 0);
3343 Duration longestInterval = mRecurrence->longestInterval();
3344 if (repetition.
duration() >= longestInterval)
3346 const int count = mStartDateTime.isDateOnly()
3349 mRepetition.set(repetition.
interval(), count);
3352 mRepetition = repetition;
3353 mTriggerChanged =
true;
3355 else if (mRepetition)
3357 mRepetition.
set(0, 0);
3358 mTriggerChanged =
true;
3365 return d->mRepetition;
3370 return d->mNextRepeat;
3380 if (!d->mRepetition.isDaily())
3382 const int minutes = d->mRepetition.intervalMinutes();
3384 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", minutes);
3385 if (minutes % 60 == 0)
3386 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", minutes/60);
3388 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", minutes/60, mins.sprintf(
"%02d", minutes%60));
3390 const int days = d->mRepetition.intervalDays();
3392 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", days);
3393 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", days / 7);
3395 return brief ? QString() : i18nc(
"@info/plain No repetition",
"None");
3405 return d->occursAfter(preDateTime, includeRepetitions);
3408 bool KAEventPrivate::occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const
3413 if (mRecurrence->duration() < 0)
3415 dt = mRecurrence->endDateTime();
3418 dt = mNextMainDateTime.effectiveKDateTime();
3419 if (mStartDateTime.isDateOnly())
3421 QDate pre = preDateTime.date();
3423 pre = pre.addDays(-1);
3424 if (pre < dt.date())
3427 else if (preDateTime < dt)
3430 if (includeRepetitions && mRepetition)
3432 if (preDateTime < mRepetition.duration().end(dt))
3448 return d->setNextOccurrence(preDateTime);
3453 if (preDateTime < mNextMainDateTime.effectiveKDateTime())
3455 KDateTime pre = preDateTime;
3460 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3464 if (pre < mNextMainDateTime.effectiveKDateTime())
3466 afterPre = mNextMainDateTime;
3471 type = nextRecurrence(pre, afterPre);
3477 mNextMainDateTime = afterPre;
3478 if (mReminderMinutes > 0 && (mDeferral == REMINDER_DEFERRAL || mReminderActive != ACTIVE_REMINDER))
3482 activate_reminder(!mReminderOnceOnly);
3484 if (mDeferral == REMINDER_DEFERRAL)
3485 set_deferral(NO_DEFERRAL);
3486 mTriggerChanged =
true;
3494 if (afterPre <= preDateTime)
3498 mNextRepeat = mRepetition.nextRepeatCount(afterPre.
effectiveKDateTime(), preDateTime);
3500 activate_reminder(
false);
3501 if (mDeferral == REMINDER_DEFERRAL)
3502 set_deferral(NO_DEFERRAL);
3503 mTriggerChanged =
true;
3505 else if (mNextRepeat)
3509 mTriggerChanged =
true;
3522 return d->nextOccurrence(preDateTime, result, o);
3528 KDateTime pre = preDateTime;
3534 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3540 type = nextRecurrence(pre, result);
3541 else if (pre < mNextMainDateTime.effectiveKDateTime())
3543 result = mNextMainDateTime;
3548 result = DateTime();
3556 const DateTime repeatDT = mRepetition.duration(repetition).end(result.
kDateTime());
3564 const KAEvent::OccurType newType = previousOccurrence(repeatDT.effectiveKDateTime(), dt,
false);
3572 repetition = mRepetition.nextRepeatCount(result.
kDateTime(), preDateTime);
3573 result = mRepetition.duration(repetition).end(result.
kDateTime());
3598 return d->previousOccurrence(afterDateTime, result, includeRepetitions);
3602 bool includeRepetitions)
const
3604 Q_ASSERT(!afterDateTime.isDateOnly());
3605 if (mStartDateTime >= afterDateTime)
3607 result = KDateTime();
3615 result = mStartDateTime;
3620 const KDateTime recurStart = mRecurrence->startDateTime();
3621 KDateTime after = afterDateTime.toTimeSpec(mStartDateTime.timeSpec());
3623 after = after.addDays(1);
3624 const KDateTime dt = mRecurrence->getPreviousDateTime(after);
3629 if (dt == recurStart)
3631 else if (mRecurrence->getNextDateTime(dt).isValid())
3637 if (includeRepetitions && mRepetition)
3640 const int repetition = mRepetition.previousRepeatCount(result.
effectiveKDateTime(), afterDateTime);
3643 result = mRepetition.duration(qMin(repetition, mRepetition.count())).end(result.
kDateTime());
3659 #ifndef KALARMCAL_USE_KRESOURCES
3665 return d->setDisplaying(*e.d, t,
id, dt, showEdit, showDefer);
3668 #ifndef KALARMCAL_USE_KRESOURCES
3670 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3672 bool KAEventPrivate::setDisplaying(
const KAEventPrivate& event,
KAAlarm::Type alarmType,
const QString& resourceID,
3673 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3684 KAAlarm al =
event.alarm(alarmType);
3690 #ifndef KALARMCAL_USE_KRESOURCES
3692 mCollectionId = collectionId;
3694 mOriginalResourceId = resourceID;
3696 mDisplayingDefer = showDefer;
3697 mDisplayingEdit = showEdit;
3706 default: mDisplayingFlags = 0;
break;
3718 #ifndef KALARMCAL_USE_KRESOURCES
3724 d->reinstateFromDisplaying(e,
id, showEdit, showDefer);
3727 #ifndef KALARMCAL_USE_KRESOURCES
3730 void KAEventPrivate::reinstateFromDisplaying(
const Event* kcalEvent, QString& resourceID,
bool& showEdit,
bool& showDefer)
3738 #ifndef KALARMCAL_USE_KRESOURCES
3739 collectionId = mCollectionId;
3742 resourceID = mOriginalResourceId;
3743 mOriginalResourceId.clear();
3745 showDefer = mDisplayingDefer;
3746 showEdit = mDisplayingEdit;
3747 mDisplaying =
false;
3761 KAAlarm::Private*
const al_d = al.d;
3762 const int displayingFlags = d->mDisplayingFlags;
3765 al_d->mRepeatAtLogin =
true;
3768 else if (displayingFlags & KAEventPrivate::DEFERRAL)
3770 al_d->mDeferred =
true;
3771 al_d->mTimedDeferral = (displayingFlags & KAEventPrivate::TIMED_FLAG);
3774 else if (displayingFlags & KAEventPrivate::REMINDER)
3783 return d->mDisplaying;
3798 KAAlarm::Private*
const al_d = al.d;
3802 al_d->mRepeatAtLogin =
false;
3803 al_d->mDeferred =
false;
3810 al_d->mNextMainDateTime = mNextMainDateTime;
3811 al_d->mRepetition = mRepetition;
3812 al_d->mNextRepeat = mNextRepeat;
3816 if (mReminderActive == ACTIVE_REMINDER)
3819 if (mReminderMinutes < 0)
3820 al_d->mNextMainDateTime = mReminderAfterTime;
3821 else if (mReminderOnceOnly)
3822 al_d->mNextMainDateTime = mStartDateTime.addMins(-mReminderMinutes);
3824 al_d->mNextMainDateTime = mNextMainDateTime.addMins(-mReminderMinutes);
3828 if (mDeferral != REMINDER_DEFERRAL)
3832 if (mDeferral != NO_DEFERRAL)
3835 al_d->mNextMainDateTime = mDeferralTime;
3836 al_d->mDeferred =
true;
3837 al_d->mTimedDeferral = !mDeferralTime.isDateOnly();
3844 al_d->mNextMainDateTime = mAtLoginDateTime;
3845 al_d->mRepeatAtLogin =
true;
3852 al_d->mNextMainDateTime = mDisplayingTime;
3872 return d->firstAlarm();
3875 KAAlarm KAEventPrivate::firstAlarm()
const
3893 return d->nextAlarm(previousAlarm.
type());
3898 return d->nextAlarm(previousType);
3903 switch (previousType)
3906 if (mReminderActive == ACTIVE_REMINDER)
3911 if (mDeferral == REMINDER_DEFERRAL)
3913 if (mDeferral == NORMAL_DEFERRAL)
3936 return d->mAlarmCount;
3946 d->removeExpiredAlarm(type);
3951 const int count = mAlarmCount;
3955 if (!mReminderActive || mReminderMinutes > 0)
3962 mMainExpired =
true;
3964 set_deferral(NO_DEFERRAL);
3967 mDisplaying =
false;
3975 mArchiveRepeatAtLogin =
true;
3976 mRepeatAtLogin =
false;
3983 activate_reminder(
false);
3987 set_deferral(NO_DEFERRAL);
3992 mDisplaying =
false;
4000 if (mAlarmCount != count)
4001 mTriggerChanged =
true;
4018 void KAEventPrivate::endChanges()
4020 if (mChangeCount > 0)
4024 #ifndef KALARMCAL_USE_KRESOURCES
4031 for (
int i = 0, count = objList.count(); i < count; ++i)
4032 ptrs += &objList[i];
4039 #ifndef KDE_NO_DEBUG_OUTPUT
4044 #ifndef KDE_NO_DEBUG_OUTPUT
4045 void KAEventPrivate::dumpDebug()
const
4047 kDebug() <<
"KAEvent dump:";
4048 #ifdef KALARMCAL_USE_KRESOURCES
4049 if (mResource) { kDebug() <<
"-- mResource:" << (
void*)mResource; }
4051 kDebug() <<
"-- mEventID:" << mEventID;
4053 kDebug() <<
"-- mNextMainDateTime:" << mNextMainDateTime.toString();
4054 kDebug() <<
"-- mCommandError:" << mCommandError;
4055 kDebug() <<
"-- mAllTrigger:" << mAllTrigger.toString();
4056 kDebug() <<
"-- mMainTrigger:" << mMainTrigger.toString();
4057 kDebug() <<
"-- mAllWorkTrigger:" << mAllWorkTrigger.toString();
4058 kDebug() <<
"-- mMainWorkTrigger:" << mMainWorkTrigger.toString();
4059 kDebug() <<
"-- mCategory:" << mCategory;
4060 if (!mTemplateName.isEmpty())
4062 kDebug() <<
"-- mTemplateName:" << mTemplateName;
4063 kDebug() <<
"-- mTemplateAfterTime:" << mTemplateAfterTime;
4065 kDebug() <<
"-- mText:" << mText;
4068 kDebug() <<
"-- mBgColour:" << mBgColour.name();
4069 kDebug() <<
"-- mFgColour:" << mFgColour.name();
4070 kDebug() <<
"-- mUseDefaultFont:" << mUseDefaultFont;
4071 if (!mUseDefaultFont)
4072 kDebug() <<
"-- mFont:" << mFont.toString();
4073 kDebug() <<
"-- mSpeak:" << mSpeak;
4074 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4075 kDebug() <<
"-- mPreAction:" << mPreAction;
4079 kDebug() <<
"-- mPostAction:" << mPostAction;
4080 kDebug() <<
"-- mLateCancel:" << mLateCancel;
4081 kDebug() <<
"-- mAutoClose:" << mAutoClose;
4085 kDebug() <<
"-- mCommandScript:" << mCommandScript;
4086 kDebug() <<
"-- mCommandXterm:" << mCommandXterm;
4087 kDebug() <<
"-- mCommandDisplay:" << mCommandDisplay;
4088 kDebug() <<
"-- mLogFile:" << mLogFile;
4092 kDebug() <<
"-- mEmail: FromKMail:" << mEmailFromIdentity;
4093 kDebug() <<
"-- Addresses:" << mEmailAddresses.join(QLatin1String(
","));
4094 kDebug() <<
"-- Subject:" << mEmailSubject;
4095 kDebug() <<
"-- Attachments:" << mEmailAttachments.join(QLatin1String(
","));
4096 kDebug() <<
"-- Bcc:" << mEmailBcc;
4099 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4100 kDebug() <<
"-- mBeep:" << mBeep;
4103 if (mSoundVolume >= 0)
4105 kDebug() <<
"-- mSoundVolume:" << mSoundVolume;
4106 if (mFadeVolume >= 0)
4108 kDebug() <<
"-- mFadeVolume:" << mFadeVolume;
4109 kDebug() <<
"-- mFadeSeconds:" << mFadeSeconds;
4112 kDebug() <<
"-- mFadeVolume:-:";
4115 kDebug() <<
"-- mSoundVolume:-:";
4116 kDebug() <<
"-- mRepeatSoundPause:" << mRepeatSoundPause;
4118 kDebug() <<
"-- mKMailSerialNumber:" << mKMailSerialNumber;
4119 kDebug() <<
"-- mCopyToKOrganizer:" << mCopyToKOrganizer;
4120 kDebug() <<
"-- mExcludeHolidays:" << (bool)mExcludeHolidays;
4121 kDebug() <<
"-- mWorkTimeOnly:" << mWorkTimeOnly;
4122 kDebug() <<
"-- mStartDateTime:" << mStartDateTime.toString();
4123 kDebug() <<
"-- mCreatedDateTime:" << mCreatedDateTime;
4124 kDebug() <<
"-- mRepeatAtLogin:" << mRepeatAtLogin;
4126 kDebug() <<
"-- mAtLoginDateTime:" << mAtLoginDateTime;
4127 kDebug() <<
"-- mArchiveRepeatAtLogin:" << mArchiveRepeatAtLogin;
4128 kDebug() <<
"-- mConfirmAck:" << mConfirmAck;
4129 kDebug() <<
"-- mEnabled:" << mEnabled;
4130 #ifndef KALARMCAL_USE_KRESOURCES
4131 kDebug() <<
"-- mItemId:" << mItemId;
4132 kDebug() <<
"-- mCollectionId:" << mCollectionId;
4133 kDebug() <<
"-- mCompatibility:" << mCompatibility;
4134 kDebug() <<
"-- mReadOnly:" << mReadOnly;
4136 if (mReminderMinutes)
4138 kDebug() <<
"-- mReminderMinutes:" << mReminderMinutes;
4139 kDebug() <<
"-- mReminderActive:" << (mReminderActive == ACTIVE_REMINDER ?
"active" : mReminderActive == HIDDEN_REMINDER ?
"hidden" :
"no");
4140 kDebug() <<
"-- mReminderOnceOnly:" << mReminderOnceOnly;
4142 else if (mDeferral > 0)
4144 kDebug() <<
"-- mDeferral:" << (mDeferral == NORMAL_DEFERRAL ?
"normal" :
"reminder");
4145 kDebug() <<
"-- mDeferralTime:" << mDeferralTime.toString();
4147 kDebug() <<
"-- mDeferDefaultMinutes:" << mDeferDefaultMinutes;
4148 if (mDeferDefaultMinutes)
4149 kDebug() <<
"-- mDeferDefaultDateOnly:" << mDeferDefaultDateOnly;
4152 kDebug() <<
"-- mDisplayingTime:" << mDisplayingTime.toString();
4153 kDebug() <<
"-- mDisplayingFlags:" << mDisplayingFlags;
4154 kDebug() <<
"-- mDisplayingDefer:" << mDisplayingDefer;
4155 kDebug() <<
"-- mDisplayingEdit:" << mDisplayingEdit;
4157 kDebug() <<
"-- mRevision:" << mRevision;
4158 kDebug() <<
"-- mRecurrence:" << mRecurrence;
4160 kDebug() <<
"-- mRepetition: 0";
4161 else if (mRepetition.isDaily())
4162 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalDays() <<
"days";
4164 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalMinutes() <<
"minutes";
4165 kDebug() <<
"-- mNextRepeat:" << mNextRepeat;
4166 kDebug() <<
"-- mAlarmCount:" << mAlarmCount;
4167 kDebug() <<
"-- mMainExpired:" << mMainExpired;
4168 kDebug() <<
"-- mDisplaying:" << mDisplaying;
4169 kDebug() <<
"KAEvent dump end";
4177 #ifndef KALARMCAL_USE_KRESOURCES
4178 DateTime KAEventPrivate::readDateTime(
const Event::Ptr& event,
bool dateOnly, DateTime& start)
4180 DateTime KAEventPrivate::readDateTime(
const Event* event,
bool dateOnly, DateTime& start)
4183 start =
event->dtStart();
4188 start.setDateOnly(
true);
4190 DateTime next = start;
4191 const int SZ_YEAR = 4;
4192 const int SZ_MONTH = 2;
4193 const int SZ_DAY = 2;
4194 const int SZ_DATE = SZ_YEAR + SZ_MONTH + SZ_DAY;
4195 const int IX_TIME = SZ_DATE + 1;
4196 const int SZ_HOUR = 2;
4197 const int SZ_MIN = 2;
4198 const int SZ_SEC = 2;
4199 const int SZ_TIME = SZ_HOUR + SZ_MIN + SZ_SEC;
4200 const QString prop =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::NEXT_RECUR_PROPERTY);
4201 if (prop.length() >= SZ_DATE)
4204 const QDate d(prop.left(SZ_YEAR).toInt(),
4205 prop.mid(SZ_YEAR, SZ_MONTH).toInt(),
4206 prop.mid(SZ_YEAR + SZ_MONTH, SZ_DAY).toInt());
4209 if (dateOnly && prop.length() == SZ_DATE)
4211 else if (!dateOnly && prop.length() == IX_TIME + SZ_TIME && prop[SZ_DATE] == QLatin1Char(
'T'))
4213 const QTime t(prop.mid(IX_TIME, SZ_HOUR).toInt(),
4214 prop.mid(IX_TIME + SZ_HOUR, SZ_MIN).toInt(),
4215 prop.mid(IX_TIME + SZ_HOUR + SZ_MIN, SZ_SEC).toInt());
4233 #ifndef KALARMCAL_USE_KRESOURCES
4234 void KAEventPrivate::readAlarms(
const Event::Ptr& event, AlarmMap* alarmMap,
bool cmdDisplay)
4236 void KAEventPrivate::readAlarms(
const Event* event, AlarmMap* alarmMap,
bool cmdDisplay)
4242 bool audioOnly =
false;
4243 for (
int i = 0, end = alarms.count(); i < end; ++i)
4245 switch (alarms[i]->type())
4247 case Alarm::Display:
4248 case Alarm::Procedure:
4260 for (
int i = 0, end = alarms.count(); i < end; ++i)
4264 readAlarm(alarms[i], data, audioOnly, cmdDisplay);
4265 if (data.type != INVALID_ALARM)
4266 alarmMap->insert(data.type, data);
4275 #ifndef KALARMCAL_USE_KRESOURCES
4276 void KAEventPrivate::readAlarm(
const Alarm::Ptr& alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4278 void KAEventPrivate::readAlarm(
const Alarm* alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4283 data.displayingFlags = 0;
4284 data.isEmailText =
false;
4286 data.hiddenReminder =
false;
4287 data.timedDeferral =
false;
4288 data.nextRepeat = 0;
4289 data.repeatSoundPause = -1;
4294 int n =
static_cast<int>(
property.toUInt(&ok));
4296 data.nextRepeat = n;
4299 const QStringList flags =
property.split(KAEventPrivate::SC, QString::SkipEmptyParts);
4300 switch (alarm->
type())
4302 case Alarm::Procedure:
4305 data.commandScript = data.cleanText.isEmpty();
4308 if (!data.commandScript)
4309 data.cleanText += QLatin1Char(
' ');
4312 data.extraActionOptions = 0;
4313 if (flags.contains(KAEventPrivate::EXEC_ON_DEFERRAL_FLAG))
4314 data.extraActionOptions |= KAEvent::ExecPreActOnDeferral;
4315 if (flags.contains(KAEventPrivate::CANCEL_ON_ERROR_FLAG))
4316 data.extraActionOptions |= KAEvent::CancelOnPreActError;
4317 if (flags.contains(KAEventPrivate::DONT_SHOW_ERROR_FLAG))
4318 data.extraActionOptions |= KAEvent::DontShowPreActError;
4322 case Alarm::Display:
4324 if (alarm->
type() == Alarm::Display)
4330 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
4331 data.bgColour = QColor(255, 255, 255);
4332 data.fgColour = QColor(0, 0, 0);
4333 const int n = list.count();
4336 if (!list[0].isEmpty())
4342 if (n > 1 && !list[1].isEmpty())
4349 data.defaultFont = (n <= 2 || list[2].isEmpty());
4350 if (!data.defaultFont)
4351 data.font.fromString(list[2]);
4357 data.cleanText = alarm->
mailText();
4358 const int i = flags.indexOf(KAEventPrivate::EMAIL_ID_FLAG);
4359 data.emailFromId = (i >= 0 && i + 1 < flags.count()) ? flags[i + 1].toUInt() : 0;
4368 data.soundVolume = -1;
4369 data.fadeVolume = -1;
4370 data.fadeSeconds = 0;
4372 if (!property.isEmpty())
4377 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
4378 data.soundVolume = list[0].toFloat(&ok);
4379 if (!ok || data.soundVolume > 1.0f)
4380 data.soundVolume = -1;
4381 if (data.soundVolume >= 0 && list.count() >= 3)
4383 fadeVolume = list[1].toFloat(&ok);
4385 fadeSecs =
static_cast<int>(list[2].toUInt(&ok));
4386 if (ok && fadeVolume >= 0 && fadeVolume <= 1.0f && fadeSecs > 0)
4388 data.fadeVolume = fadeVolume;
4389 data.fadeSeconds = fadeSecs;
4395 data.type = AUDIO_ALARM;
4396 data.speak = flags.contains(KAEventPrivate::SPEAK_FLAG);
4401 case Alarm::Invalid:
4402 data.type = INVALID_ALARM;
4406 bool atLogin =
false;
4407 bool reminder =
false;
4408 bool deferral =
false;
4409 bool dateDeferral =
false;
4410 bool repeatSound =
false;
4411 data.type = MAIN_ALARM;
4413 const QStringList
types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
4414 for (
int i = 0, end = types.count(); i < end; ++i)
4416 const QString type = types[i];
4417 if (type == KAEventPrivate::AT_LOGIN_TYPE)
4419 else if (type == KAEventPrivate::FILE_TYPE && data.action ==
KAAlarm::MESSAGE)
4421 else if (type == KAEventPrivate::REMINDER_TYPE)
4423 else if (type == KAEventPrivate::TIME_DEFERRAL_TYPE)
4425 else if (type == KAEventPrivate::DATE_DEFERRAL_TYPE)
4426 dateDeferral = deferral =
true;
4427 else if (type == KAEventPrivate::DISPLAYING_TYPE)
4428 data.type = DISPLAYING_ALARM;
4429 else if (type == KAEventPrivate::PRE_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4430 data.type = PRE_ACTION_ALARM;
4431 else if (type == KAEventPrivate::POST_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4432 data.type = POST_ACTION_ALARM;
4433 else if (type == KAEventPrivate::SOUND_REPEAT_TYPE && data.action ==
KAAlarm::AUDIO)
4439 uint n = types[i + 1].toUInt(&ok);
4442 data.repeatSoundPause = n;
4448 if (repeatSound && data.repeatSoundPause < 0)
4449 data.repeatSoundPause = 0;
4450 else if (!repeatSound)
4451 data.repeatSoundPause = -1;
4455 if (data.type == MAIN_ALARM)
4457 data.type = deferral ? DEFERRED_REMINDER_ALARM : REMINDER_ALARM;
4458 data.timedDeferral = (deferral && !dateDeferral);
4460 else if (data.type == DISPLAYING_ALARM)
4461 data.displayingFlags = dateDeferral ? REMINDER | DATE_DEFERRAL
4462 : deferral ? REMINDER | TIME_DEFERRAL : REMINDER;
4463 else if (data.type == REMINDER_ALARM
4464 && flags.contains(KAEventPrivate::HIDDEN_REMINDER_FLAG))
4465 data.hiddenReminder =
true;
4469 if (data.type == MAIN_ALARM)
4471 data.type = DEFERRED_ALARM;
4472 data.timedDeferral = !dateDeferral;
4474 else if (data.type == DISPLAYING_ALARM)
4475 data.displayingFlags = dateDeferral ? DATE_DEFERRAL : TIME_DEFERRAL;
4479 if (data.type == MAIN_ALARM)
4480 data.type = AT_LOGIN_ALARM;
4481 else if (data.type == DISPLAYING_ALARM)
4498 void KAEventPrivate::calcTriggerTimes()
const
4503 #warning May need to set date-only alarms to after start-of-day time in working-time checks
4506 if ((recurs && mWorkTimeOnly && mWorkTimeOnly != mWorkTimeIndex)
4507 || (recurs && mExcludeHolidays && mExcludeHolidays != mHolidays))
4511 mTriggerChanged =
true;
4513 else if (!mTriggerChanged)
4515 mTriggerChanged =
false;
4516 if (recurs && mWorkTimeOnly)
4517 mWorkTimeOnly = mWorkTimeIndex;
4518 if (recurs && mExcludeHolidays)
4519 mExcludeHolidays = mHolidays;
4524 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = KDateTime();
4526 else if (mDeferral == NORMAL_DEFERRAL)
4529 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = mDeferralTime;
4533 mMainTrigger = mainDateTime(
true);
4534 mAllTrigger = (mDeferral == REMINDER_DEFERRAL) ? mDeferralTime
4535 : (mReminderActive != ACTIVE_REMINDER) ? mMainTrigger
4536 : (mReminderMinutes < 0) ? mReminderAfterTime
4537 : mMainTrigger.addMins(-mReminderMinutes);
4541 if ((!mWorkTimeOnly && !mExcludeHolidays)
4543 || isWorkingTime(mMainTrigger.kDateTime()))
4547 mMainWorkTrigger = mMainTrigger;
4548 mAllWorkTrigger = mAllTrigger;
4550 else if (mWorkTimeOnly)
4556 if (!mExcludeHolidays)
4559 calcNextWorkingTime(mMainTrigger);
4564 DateTime nextTrigger = mMainTrigger;
4566 for (
int i = 0; i < 20; ++i)
4568 calcNextWorkingTime(nextTrigger);
4569 if (!mHolidays->isHoliday(mMainWorkTrigger.date()))
4571 kdt = mMainWorkTrigger.effectiveKDateTime();
4572 kdt.setTime(QTime(23,59,59));
4574 if (!nextTrigger.isValid())
4576 if (isWorkingTime(nextTrigger.kDateTime()))
4578 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4579 mMainWorkTrigger = nextTrigger;
4584 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4587 else if (mExcludeHolidays && mHolidays)
4590 DateTime nextTrigger = mMainTrigger;
4592 for (
int i = 0; i < 20; ++i)
4594 kdt = nextTrigger.effectiveKDateTime();
4595 kdt.setTime(QTime(23,59,59));
4597 if (!nextTrigger.isValid())
4599 if (!mHolidays->isHoliday(nextTrigger.date()))
4601 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4602 mMainWorkTrigger = nextTrigger;
4607 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4618 void KAEventPrivate::calcNextWorkingTime(
const DateTime& nextTrigger)
const
4620 kDebug() <<
"next=" << nextTrigger.kDateTime().dateTime();
4621 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4623 for (
int i = 0; ; ++i)
4627 if (mWorkDays.testBit(i))
4631 KDateTime kdt = nextTrigger.effectiveKDateTime();
4632 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4637 unsigned allDaysMask = 0x7F;
4638 bool noWorkPos =
false;
4639 const QList<RecurrenceRule::WDayPos> pos = rrule->byDays();
4640 const int nDayPos = pos.count();
4645 for (
int i = 0; i < nDayPos; ++i)
4647 const int day = pos[i].day() - 1;
4648 if (mWorkDays.testBit(day))
4650 allDaysMask |= 1 << day;
4652 if (noWorkPos && !mRepetition)
4657 if (mStartDateTime.isDateOnly())
4661 const int repeatFreq = mRepetition.intervalDays();
4662 const bool weeklyRepeat = mRepetition && !(repeatFreq % 7);
4663 const Duration interval = mRecurrence->regularInterval();
4664 if ((interval && !(interval.
asDays() % 7))
4668 if (!mRepetition || weeklyRepeat)
4674 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4675 dt.setTime(QTime(0,0,0));
4676 previousOccurrence(dt, newdt,
false);
4677 if (!newdt.isValid())
4679 kdt = newdt.effectiveKDateTime();
4680 const int day = kdt.date().dayOfWeek() - 1;
4681 for (
int repeatNum = mNextRepeat + 1; ; ++repeatNum)
4683 if (repeatNum > mRepetition.count())
4685 if (repeatNum == mNextRepeat)
4690 if (mWorkDays.testBit(day))
4692 mMainWorkTrigger = newdt;
4693 mAllWorkTrigger = mMainWorkTrigger.addMins(-reminder);
4696 kdt = newdt.effectiveKDateTime();
4700 const int inc = repeatFreq * repeatNum;
4701 if (mWorkDays.testBit((day + inc) % 7))
4703 kdt = kdt.addDays(inc);
4704 kdt.setDateOnly(
true);
4705 mMainWorkTrigger = mAllWorkTrigger = kdt;
4712 if (!mRepetition || weeklyRepeat)
4720 kdt.setTime(QTime(23,59,59));
4722 if (!newdt.isValid())
4724 kdt = newdt.effectiveKDateTime();
4725 const int day = kdt.date().dayOfWeek() - 1;
4726 if (mWorkDays.testBit(day))
4729 if ((days & allDaysMask) == allDaysMask)
4733 kdt.setDateOnly(
true);
4734 mMainWorkTrigger = kdt;
4735 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4742 unsigned days = 1 << (kdt.date().dayOfWeek() - 1);
4743 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4744 dt.setTime(QTime(0,0,0));
4745 previousOccurrence(dt, newdt,
false);
4746 if (!newdt.isValid())
4748 kdt = newdt.effectiveKDateTime();
4749 int day = kdt.date().dayOfWeek() - 1;
4750 for (
int repeatNum = mNextRepeat; ; repeatNum = 0)
4752 while (++repeatNum <= mRepetition.count())
4754 const int inc = repeatFreq * repeatNum;
4755 if (mWorkDays.testBit((day + inc) % 7))
4757 kdt = kdt.addDays(inc);
4758 kdt.setDateOnly(
true);
4759 mMainWorkTrigger = mAllWorkTrigger = kdt;
4762 if ((days & allDaysMask) == allDaysMask)
4767 if (!newdt.isValid())
4769 kdt = newdt.effectiveKDateTime();
4770 day = kdt.date().dayOfWeek() - 1;
4771 if (mWorkDays.testBit(day))
4773 kdt.setDateOnly(
true);
4774 mMainWorkTrigger = kdt;
4775 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4778 if ((days & allDaysMask) == allDaysMask)
4796 const bool repeatTimeVaries = (mRepetition && !mRepetition.isDaily());
4798 if (!recurTimeVaries && !repeatTimeVaries)
4802 if (!mayOccurDailyDuringWork(kdt))
4806 bool repetition =
false;
4811 if (!newdt.isValid())
4814 kdt = newdt.effectiveKDateTime();
4815 const int day = kdt.date().dayOfWeek() - 1;
4816 if (mWorkDays.testBit(day))
4821 if ((days & allDaysMask) == allDaysMask)
4826 mMainWorkTrigger = nextTrigger;
4827 mMainWorkTrigger.setDate(kdt.date());
4828 mAllWorkTrigger = repetition ? mMainWorkTrigger : mMainWorkTrigger.addMins(-reminder);
4835 KTimeZone tz = kdt.timeZone();
4836 if (tz.isValid() && tz.type() ==
"KSystemTimeZone")
4839 const KTimeZone ktz = KSystemTimeZones::readZone(tz.name());
4843 const QList<KTimeZone::Transition> tzTransitions = tz.transitions();
4845 if (recurTimeVaries)
4864 repeatFreq = mRepetition.intervalSeconds();
4865 previousOccurrence(kdt.addSecs(1), newdt,
false);
4866 if (!newdt.isValid())
4868 kdtRecur = newdt.effectiveKDateTime();
4869 repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4870 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
4884 QTime firstTime = kdtRecur.time();
4885 int firstOffset = kdtRecur.utcOffset();
4886 int currentOffset = firstOffset;
4887 int dayRecur = kdtRecur.date().dayOfWeek() - 1;
4888 int firstDay = dayRecur;
4890 const bool subdaily = (repeatFreq < 24*3600);
4893 int transitionIndex = -1;
4894 for (
int n = 0; n < 7*24*60; ++n)
4902 const int inc = subdaily ? nextWorkRepetition(kdt) : 1;
4904 if (repeatNum > mRepetition.count())
4906 kdt = kdt.addSecs(inc * repeatFreq);
4907 const QTime t = kdt.time();
4908 if (t >= mWorkDayStart && t < mWorkDayEnd)
4910 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
4912 mMainWorkTrigger = mAllWorkTrigger = kdt;
4920 if (!newdt.isValid())
4922 kdtRecur = newdt.effectiveKDateTime();
4923 dayRecur = kdtRecur.date().dayOfWeek() - 1;
4924 const QTime t = kdtRecur.time();
4925 if (t >= mWorkDayStart && t < mWorkDayEnd)
4927 if (mWorkDays.testBit(dayRecur))
4929 mMainWorkTrigger = kdtRecur;
4930 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
4934 if (kdtRecur.utcOffset() != currentOffset)
4935 currentOffset = kdtRecur.utcOffset();
4936 if (t == firstTime && dayRecur == firstDay && currentOffset == firstOffset)
4942 if (!finalDate.isValid())
4943 finalDate = kdtRecur.date();
4944 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
4947 if (i > transitionIndex)
4948 transitionIndex = i;
4949 if (++transitionIndex >= static_cast<int>(tzTransitions.count()))
4952 kdtRecur = newdt.effectiveKDateTime();
4953 if (finalDate.daysTo(kdtRecur.date()) > 365)
4955 firstTime = kdtRecur.time();
4956 firstOffset = kdtRecur.utcOffset();
4957 currentOffset = firstOffset;
4958 firstDay = kdtRecur.date().dayOfWeek() - 1;
4966 if (repeatTimeVaries)
4975 const int repeatFreq = mRepetition.intervalSeconds();
4976 previousOccurrence(kdt.addSecs(1), newdt,
false);
4977 if (!newdt.isValid())
4979 KDateTime kdtRecur = newdt.effectiveKDateTime();
4980 const bool recurDuringWork = (kdtRecur.time() >= mWorkDayStart && kdtRecur.time() < mWorkDayEnd);
4984 const bool subdaily = (repeatFreq < 24*3600);
4986 bool checkTimeChangeOnly =
false;
4987 int transitionIndex = -1;
4988 for (
int limit = 10; --limit >= 0; )
4992 QDate dateRecur = kdtRecur.date();
4993 int dayRecur = dateRecur.dayOfWeek() - 1;
4994 int repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4995 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
5003 KDateTime kdtNextRecur = newdt.effectiveKDateTime();
5005 int repeatsToCheck = mRepetition.count();
5006 int repeatsDuringWork = 0;
5010 if (repeatsDuringWork >= 0)
5015 int inc = subdaily ? nextWorkRepetition(kdt) : 1;
5017 const bool pastEnd = (repeatNum > mRepetition.count());
5019 inc -= repeatNum - mRepetition.count();
5020 repeatsToCheck -= inc;
5021 kdt = kdt.addSecs(inc * repeatFreq);
5022 if (kdtNextRecur.isValid() && kdt >= kdtNextRecur)
5026 repeatsToCheck = mRepetition.count();
5031 const QTime t = kdt.time();
5032 if (t >= mWorkDayStart && t < mWorkDayEnd)
5034 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
5036 mMainWorkTrigger = mAllWorkTrigger = kdt;
5039 repeatsDuringWork = 1;
5041 else if (!repeatsDuringWork && repeatsToCheck <= 0)
5044 repeatsDuringWork = -1;
5050 if (repeatsDuringWork < 0 && !recurDuringWork)
5054 if (!kdtNextRecur.isValid())
5056 if (checkTimeChangeOnly || (days & allDaysMask) == allDaysMask)
5058 kdtRecur = kdtNextRecur;
5060 kdtNextRecur = newdt.effectiveKDateTime();
5061 dateRecur = kdtRecur.date();
5062 dayRecur = dateRecur.dayOfWeek() - 1;
5063 if (recurDuringWork && mWorkDays.testBit(dayRecur))
5065 mMainWorkTrigger = kdtRecur;
5066 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
5069 days |= 1 << dayRecur;
5075 checkTimeChangeOnly =
true;
5076 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
5079 if (i > transitionIndex)
5080 transitionIndex = i;
5081 if (++transitionIndex >= static_cast<int>(tzTransitions.count()))
5083 kdt = KDateTime(tzTransitions[transitionIndex].time(), KDateTime::UTC);
5085 kdtRecur = newdt.effectiveKDateTime();
5096 int KAEventPrivate::nextWorkRepetition(
const KDateTime& pre)
const
5098 KDateTime nextWork(pre);
5099 if (pre.time() < mWorkDayStart)
5100 nextWork.setTime(mWorkDayStart);
5103 const int preDay = pre.date().dayOfWeek() - 1;
5104 for (
int n = 1; ; ++n)
5107 return mRepetition.count() + 1;
5108 if (mWorkDays.testBit((preDay + n) % 7))
5110 nextWork = nextWork.addDays(n);
5111 nextWork.setTime(mWorkDayStart);
5116 return (pre.secsTo(nextWork) - 1) / mRepetition.intervalSeconds() + 1;
5126 bool KAEventPrivate::mayOccurDailyDuringWork(
const KDateTime& kdt)
const
5128 if (!kdt.isDateOnly()
5129 && (kdt.time() < mWorkDayStart || kdt.time() >= mWorkDayEnd))
5132 const Duration interval = mRecurrence->regularInterval();
5133 if (interval && interval.
isDaily() && !(interval.
asDays() % 7))
5136 if (!mRepetition || (mRepetition.isDaily() && !(mRepetition.intervalDays() % 7)))
5140 int day = mRecurrence->startDateTime().date().dayOfWeek() - 1;
5141 const int repeatDays = mRepetition.intervalDays();
5142 const int maxRepeat = (mRepetition.count() < 6) ? mRepetition.count() : 6;
5143 for (
int i = 0; !mWorkDays.testBit(day); ++i, day = (day + repeatDays) % 7)
5155 #ifndef KALARMCAL_USE_KRESOURCES
5156 void KAEventPrivate::setAudioAlarm(
const Alarm::Ptr& alarm)
const
5158 void KAEventPrivate::setAudioAlarm(
Alarm* alarm)
const
5162 if (mSoundVolume >= 0)
5164 QString::fromLatin1(
"%1;%2;%3;%4").arg(QString::number(mSoundVolume,
'f', 2))
5165 .arg(QString::number(mFadeVolume,
'f', 2))
5166 .arg(mFadeSeconds));
5174 KAEvent::OccurType KAEventPrivate::nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const
5176 const KDateTime recurStart = mRecurrence->startDateTime();
5177 KDateTime pre = preDateTime.toTimeSpec(mStartDateTime.timeSpec());
5180 pre = pre.addDays(-1);
5183 const KDateTime dt = mRecurrence->getNextDateTime(pre);
5185 result.setDateOnly(mStartDateTime.isDateOnly());
5188 if (dt == recurStart)
5190 if (mRecurrence->duration() >= 0 && dt == mRecurrence->endDateTime())
5217 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5222 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5232 #ifndef KALARMCAL_USE_KRESOURCES
5239 static const QChar SEPARATOR = QLatin1Char(
';');
5240 static const QChar LATE_CANCEL_CODE = QLatin1Char(
'C');
5241 static const QChar AT_LOGIN_CODE = QLatin1Char(
'L');
5242 static const QChar DEFERRAL_CODE = QLatin1Char(
'D');
5243 static const QString TEXT_PREFIX = QLatin1String(
"TEXT:");
5244 static const QString FILE_PREFIX = QLatin1String(
"FILE:");
5245 static const QString COMMAND_PREFIX = QLatin1String(
"CMD:");
5248 static const QString BEEP_CATEGORY = QLatin1String(
"BEEP");
5251 static const QString LATE_CANCEL_CAT = QLatin1String(
"LATECANCEL");
5254 static const QString TEMPL_DEF_TIME_CAT = QLatin1String(
"TMPLDEFTIME");
5257 static const QString EXEC_IN_XTERM_CAT = QLatin1String(
"XTERM");
5260 static const QString DATE_ONLY_CATEGORY = QLatin1String(
"DATE");
5261 static const QString EMAIL_BCC_CATEGORY = QLatin1String(
"BCC");
5262 static const QString CONFIRM_ACK_CATEGORY = QLatin1String(
"ACKCONF");
5263 static const QString KORGANIZER_CATEGORY = QLatin1String(
"KORG");
5264 static const QString DEFER_CATEGORY = QLatin1String(
"DEFER;");
5265 static const QString ARCHIVE_CATEGORY = QLatin1String(
"SAVE");
5266 static const QString ARCHIVE_CATEGORIES = QLatin1String(
"SAVE:");
5267 static const QString LATE_CANCEL_CATEGORY = QLatin1String(
"LATECANCEL;");
5268 static const QString AUTO_CLOSE_CATEGORY = QLatin1String(
"LATECLOSE;");
5269 static const QString TEMPL_AFTER_TIME_CATEGORY = QLatin1String(
"TMPLAFTTIME;");
5270 static const QString KMAIL_SERNUM_CATEGORY = QLatin1String(
"KMAIL:");
5271 static const QString LOG_CATEGORY = QLatin1String(
"LOG:");
5274 static const QByteArray KMAIL_ID_PROPERTY(
"KMAILID");
5277 static const QByteArray ARCHIVE_PROPERTY(
"ARCHIVE");
5278 static const QString ARCHIVE_REMINDER_ONCE_TYPE = QLatin1String(
"ONCE");
5279 static const QString REMINDER_ONCE_TYPE = QLatin1String(
"REMINDER_ONCE");
5280 static const QByteArray EMAIL_ID_PROPERTY(
"EMAILID");
5281 static const QByteArray SPEAK_PROPERTY(
"SPEAK");
5282 static const QByteArray CANCEL_ON_ERROR_PROPERTY(
"ERRCANCEL");
5283 static const QByteArray DONT_SHOW_ERROR_PROPERTY(
"ERRNOSHOW");
5285 bool adjustSummerTime =
false;
5286 if (calendarVersion == -Version(0,5,7))
5290 calendarVersion = -calendarVersion;
5291 adjustSummerTime =
true;
5294 if (calendarVersion >= currentCalendarVersion())
5297 kDebug() <<
"Adjusting version" << calendarVersion;
5298 const bool pre_0_7 = (calendarVersion < Version(0,7,0));
5299 const bool pre_0_9 = (calendarVersion < Version(0,9,0));
5300 const bool pre_0_9_2 = (calendarVersion < Version(0,9,2));
5301 const bool pre_1_1_1 = (calendarVersion < Version(1,1,1));
5302 const bool pre_1_2_1 = (calendarVersion < Version(1,2,1));
5303 const bool pre_1_3_0 = (calendarVersion < Version(1,3,0));
5304 const bool pre_1_3_1 = (calendarVersion < Version(1,3,1));
5305 const bool pre_1_4_14 = (calendarVersion < Version(1,4,14));
5306 const bool pre_1_5_0 = (calendarVersion < Version(1,5,0));
5307 const bool pre_1_9_0 = (calendarVersion < Version(1,9,0));
5308 const bool pre_1_9_2 = (calendarVersion < Version(1,9,2));
5309 const bool pre_1_9_7 = (calendarVersion < Version(1,9,7));
5310 const bool pre_1_9_9 = (calendarVersion < Version(1,9,9));
5311 const bool pre_1_9_10 = (calendarVersion < Version(1,9,10));
5312 const bool pre_2_2_9 = (calendarVersion < Version(2,2,9));
5313 const bool pre_2_3_0 = (calendarVersion < Version(2,3,0));
5314 const bool pre_2_3_2 = (calendarVersion < Version(2,3,2));
5315 const bool pre_2_7_0 = (calendarVersion < Version(2,7,0));
5316 Q_ASSERT(currentCalendarVersion() == Version(2,7,0));
5318 KTimeZone localZone;
5320 localZone = KSystemTimeZones::local();
5322 bool converted =
false;
5323 #ifndef KALARMCAL_USE_KRESOURCES
5328 for (
int ei = 0, eend = events.count(); ei < eend; ++ei)
5330 #ifndef KALARMCAL_USE_KRESOURCES
5333 Event*
event = events[ei];
5336 if (alarms.isEmpty())
5338 event->startUpdates();
5339 const bool readOnly =
event->isReadOnly();
5341 event->setReadOnly(
false);
5342 QStringList cats =
event->categories();
5343 bool addLateCancel =
false;
5346 if (pre_0_7 && event->
allDay())
5350 event->setAllDay(
false);
5367 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5369 #ifndef KALARMCAL_USE_KRESOURCES
5372 Alarm* alarm = alarms[ai];
5374 bool atLogin =
false;
5375 bool deferral =
false;
5376 bool lateCancel =
false;
5378 const QString txt = alarm->
text();
5379 const int length = txt.length();
5381 if (txt[0].isDigit())
5383 while (++i < length && txt[i].isDigit()) ;
5384 if (i < length && txt[i++] == SEPARATOR)
5388 const QChar ch = txt[i++];
5389 if (ch == SEPARATOR)
5391 if (ch == LATE_CANCEL_CODE)
5393 else if (ch == AT_LOGIN_CODE)
5395 else if (ch == DEFERRAL_CODE)
5402 if (txt.indexOf(TEXT_PREFIX, i) == i)
5403 i += TEXT_PREFIX.length();
5404 else if (txt.indexOf(FILE_PREFIX, i) == i)
5407 i += FILE_PREFIX.length();
5409 else if (txt.indexOf(COMMAND_PREFIX, i) == i)
5412 i += COMMAND_PREFIX.length();
5416 const QString altxt = txt.mid(i);
5422 types += KAEventPrivate::FILE_TYPE;
5428 setProcedureAlarm(alarm, altxt);
5436 types += KAEventPrivate::AT_LOGIN_TYPE;
5440 types += KAEventPrivate::TIME_DEFERRAL_TYPE;
5442 addLateCancel =
true;
5443 if (types.count() > 0)
5451 if (recur && recur->
recurs())
5460 if (adjustSummerTime)
5464 KDateTime dt = alarm->
time();
5465 const time_t t = dt.toTime_t();
5466 const struct tm* dtm = localtime(&t);
5469 dt = dt.addSecs(-3600);
5489 event->setCreated(event->
dtEnd());
5490 KDateTime start =
event->dtStart();
5493 event->setAllDay(
false);
5494 start.setTime(QTime(0, 0));
5495 flags += KAEventPrivate::DATE_ONLY_FLAG;
5497 event->setDtEnd(KDateTime());
5499 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5501 #ifndef KALARMCAL_USE_KRESOURCES
5504 Alarm* alarm = alarms[ai];
5509 if (!cats.isEmpty())
5511 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5513 #ifndef KALARMCAL_USE_KRESOURCES
5516 Alarm* alarm = alarms[ai];
5518 if (alarm->
type() == Alarm::Display)
5520 QString::fromLatin1(
"%1;;").arg(cats.at(0)));
5525 for (
int i = 0, end = cats.count(); i < end; ++i)
5527 if (cats.at(i) == BEEP_CATEGORY)
5531 #ifndef KALARMCAL_USE_KRESOURCES
5534 Alarm* alarm =
event->newAlarm();
5538 KDateTime dt =
event->dtStart();
5541 KAEventPrivate::AlarmMap alarmMap;
5542 KAEventPrivate::readAlarms(event, &alarmMap);
5543 KAEventPrivate::AlarmMap::ConstIterator it = alarmMap.constBegin();
5544 if (it != alarmMap.constEnd())
5546 dt = it.value().alarm->time();
5562 while ((i = cats.indexOf(LATE_CANCEL_CAT)) >= 0)
5565 addLateCancel =
true;
5575 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5577 #ifndef KALARMCAL_USE_KRESOURCES
5580 Alarm* alarm = alarms[ai];
5582 if (alarm->
type() == Alarm::Display)
5584 const QString oldtext = alarm->
text();
5586 if (oldtext != newtext)
5599 while ((i = cats.indexOf(TEMPL_DEF_TIME_CAT)) >= 0)
5602 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += QLatin1String(
"0");
5613 while ((i = cats.indexOf(EXEC_IN_XTERM_CAT)) >= 0)
5616 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, KAEventPrivate::xtermURL);
5627 CalEvent::setStatus(event, CalEvent::status(event));
5628 for (
int i = 0; i < cats.count(); )
5630 const QString cat = cats.at(i);
5631 if (cat == DATE_ONLY_CATEGORY)
5632 flags += KAEventPrivate::DATE_ONLY_FLAG;
5633 else if (cat == CONFIRM_ACK_CATEGORY)
5634 flags += KAEventPrivate::CONFIRM_ACK_FLAG;
5635 else if (cat == EMAIL_BCC_CATEGORY)
5636 flags += KAEventPrivate::EMAIL_BCC_FLAG;
5637 else if (cat == KORGANIZER_CATEGORY)
5638 flags += KAEventPrivate::KORGANIZER_FLAG;
5639 else if (cat.startsWith(DEFER_CATEGORY))
5640 (flags += KAEventPrivate::DEFER_FLAG) += cat.mid(DEFER_CATEGORY.length());
5641 else if (cat.startsWith(TEMPL_AFTER_TIME_CATEGORY))
5642 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += cat.mid(TEMPL_AFTER_TIME_CATEGORY.length());
5643 else if (cat.startsWith(LATE_CANCEL_CATEGORY))
5644 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += cat.mid(LATE_CANCEL_CATEGORY.length());
5645 else if (cat.startsWith(AUTO_CLOSE_CATEGORY))
5646 (flags += KAEventPrivate::AUTO_CLOSE_FLAG) += cat.mid(AUTO_CLOSE_CATEGORY.length());
5647 else if (cat.startsWith(KMAIL_SERNUM_CATEGORY))
5648 (flags += KAEventPrivate::KMAIL_SERNUM_FLAG) += cat.mid(KMAIL_SERNUM_CATEGORY.length());
5649 else if (cat == ARCHIVE_CATEGORY)
5651 else if (cat.startsWith(ARCHIVE_CATEGORIES))
5652 event->setCustomProperty(
KACalendar::APPNAME, ARCHIVE_PROPERTY, cat.mid(ARCHIVE_CATEGORIES.length()));
5653 else if (cat.startsWith(LOG_CATEGORY))
5654 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, cat.mid(LOG_CATEGORY.length()));
5670 event->
shiftTimes(KDateTime::ClockTime, localZone);
5675 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += QLatin1String(
"1");
5676 if (!flags.isEmpty())
5677 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5680 if ((pre_1_4_14 || (pre_1_9_7 && !pre_1_9_0))
5690 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5691 const bool dateOnly = flags.contains(KAEventPrivate::DATE_ONLY_FLAG);
5692 KDateTime startDateTime =
event->dtStart();
5694 startDateTime.setDateOnly(
true);
5696 KDateTime nextMainDateTime;
5697 bool mainExpired =
true;
5698 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5700 #ifndef KALARMCAL_USE_KRESOURCES
5703 Alarm* alarm = alarms[i];
5714 bool mainAlarm =
true;
5716 const QStringList types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
5717 for (
int t = 0; t < types.count(); ++t)
5719 QString type = types[t];
5720 if (type == KAEventPrivate::AT_LOGIN_TYPE
5721 || type == KAEventPrivate::TIME_DEFERRAL_TYPE
5722 || type == KAEventPrivate::DATE_DEFERRAL_TYPE
5723 || type == KAEventPrivate::REMINDER_TYPE
5724 || type == REMINDER_ONCE_TYPE)
5736 mainExpired =
false;
5737 nextMainDateTime = alarm->
time();
5738 nextMainDateTime.setDateOnly(dateOnly);
5739 nextMainDateTime = nextMainDateTime.toTimeSpec(startDateTime);
5740 if (nextMainDateTime != startDateTime)
5742 QDateTime dt = nextMainDateTime.dateTime();
5744 dt.toString(dateOnly ? QLatin1String(
"yyyyMMdd") : QLatin1String(
"yyyyMMddThhmmss")));
5757 KDateTime dt =
event->recurrence()->getNextDateTime(startDateTime.addDays(-1));
5758 dt.setDateOnly(dateOnly);
5759 adjustment = startDateTime.secsTo(dt);
5762 adjustment = startDateTime.secsTo(nextMainDateTime);
5766 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5768 #ifndef KALARMCAL_USE_KRESOURCES
5771 Alarm* alarm = alarms[i];
5776 const QStringList types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
5777 for (
int t = 0; t < types.count(); ++t)
5779 const QString type = types[t];
5780 if (type == KAEventPrivate::TIME_DEFERRAL_TYPE
5781 || type == KAEventPrivate::DATE_DEFERRAL_TYPE)
5792 if (pre_1_5_0 || (pre_1_9_9 && !pre_1_9_0))
5798 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5800 #ifndef KALARMCAL_USE_KRESOURCES
5803 Alarm* alarm = alarms[i];
5822 if (KAEventPrivate::convertRepetition(event))
5826 if (pre_2_2_9 || (pre_2_3_2 && !pre_2_3_0))
5832 if (KAEventPrivate::convertStartOfDay(event))
5846 bool flagsValid =
false;
5849 bool reminderOnce =
false;
5851 if (!prop.isEmpty())
5854 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5855 flags << KAEventPrivate::ARCHIVE_FLAG;
5857 if (prop != QLatin1String(
"0"))
5861 const QStringList list = prop.split(KAEventPrivate::SC, QString::SkipEmptyParts);
5862 for (
int i = 0; i < list.count(); ++i)
5864 if (list[i] == KAEventPrivate::AT_LOGIN_TYPE)
5865 flags << KAEventPrivate::AT_LOGIN_TYPE;
5866 else if (list[i] == ARCHIVE_REMINDER_ONCE_TYPE)
5867 reminderOnce =
true;
5868 else if (!list[i].isEmpty() && !list[i].startsWith(QChar::fromLatin1(
'-')))
5872 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5876 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5878 #ifndef KALARMCAL_USE_KRESOURCES
5881 Alarm* alarm = alarms[i];
5886 if (!property.isEmpty())
5888 flags << KAEventPrivate::EMAIL_ID_FLAG << property;
5893 flags << KAEventPrivate::SPEAK_FLAG;
5898 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
5903 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
5906 if (!flags.isEmpty())
5913 QStringList types =
property.split(QChar::fromLatin1(
','), QString::SkipEmptyParts);
5914 const int r = types.indexOf(REMINDER_ONCE_TYPE);
5918 types[r] = KAEventPrivate::REMINDER_TYPE;
5920 reminderOnce =
true;
5922 if (r >= 0 || types.contains(KAEventPrivate::REMINDER_TYPE))
5931 else if (offset < 0)
5932 reminder = reminderToString(offset / 60);
5935 if (!reminder.isEmpty())
5939 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5940 if (flags.indexOf(KAEventPrivate::REMINDER_TYPE) < 0)
5942 flags += KAEventPrivate::REMINDER_TYPE;
5944 flags += KAEventPrivate::REMINDER_ONCE_FLAG;
5951 event->setReadOnly(
true);
5952 event->endUpdates();
5961 #ifndef KALARMCAL_USE_KRESOURCES
5962 bool KAEventPrivate::convertStartOfDay(
const Event::Ptr& event)
5964 bool KAEventPrivate::convertStartOfDay(
Event* event)
5967 bool changed =
false;
5968 const QTime midnight(0, 0);
5969 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5970 if (flags.indexOf(KAEventPrivate::DATE_ONLY_FLAG) >= 0)
5973 const KDateTime oldDt =
event->dtStart();
5974 const int adjustment = oldDt.time().secsTo(midnight);
5977 event->setDtStart(KDateTime(oldDt.date(), midnight, oldDt.timeSpec()));
5978 int deferralOffset = 0;
5980 readAlarms(event, &alarmMap);
5981 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
5983 const AlarmData& data = it.value();
5984 if (!data.alarm->hasStartOffset())
5986 if (data.timedDeferral)
5989 deferralOffset = data.alarm->startOffset().asSeconds();
5990 #ifndef KALARMCAL_USE_KRESOURCES
5991 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
5993 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
5996 else if (data.type == AUDIO_ALARM
5997 && data.alarm->startOffset().asSeconds() == deferralOffset)
6000 #ifndef KALARMCAL_USE_KRESOURCES
6001 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
6003 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
6013 bool foundDeferral =
false;
6014 int deferralOffset = 0;
6015 int newDeferralOffset = 0;
6017 const KDateTime nextMainDateTime = readDateTime(event,
false, start).kDateTime();
6019 readAlarms(event, &alarmMap);
6020 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
6022 const AlarmData& data = it.value();
6023 if (!data.alarm->hasStartOffset())
6025 if ((data.type & DEFERRED_ALARM) && !data.timedDeferral)
6028 KDateTime altime = data.alarm->startOffset().end(nextMainDateTime);
6029 altime.setTime(midnight);
6030 deferralOffset = data.alarm->startOffset().asSeconds();
6031 newDeferralOffset =
event->dtStart().secsTo(altime);
6032 #ifndef KALARMCAL_USE_KRESOURCES
6033 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6035 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6037 foundDeferral =
true;
6040 else if (foundDeferral
6041 && data.type == AUDIO_ALARM
6042 && data.alarm->startOffset().asSeconds() == deferralOffset)
6045 #ifndef KALARMCAL_USE_KRESOURCES
6046 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6048 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6065 #ifndef KALARMCAL_USE_KRESOURCES
6066 bool KAEventPrivate::convertRepetition(
const Event::Ptr& event)
6068 bool KAEventPrivate::convertRepetition(
Event* event)
6072 if (alarms.isEmpty())
6077 bool converted =
false;
6078 const bool readOnly =
event->isReadOnly();
6079 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
6081 #ifndef KALARMCAL_USE_KRESOURCES
6084 Alarm* alarm = alarms[ai];
6090 event->startUpdates();
6092 event->setReadOnly(
false);
6107 event->setReadOnly(
true);
6108 event->endUpdates();
6123 KAAlarm::Private::Private()
6124 : mType(INVALID_ALARM),
6126 mRepeatAtLogin(false),
6132 : d(new Private(*other.d))
6150 return d->mActionType;
6165 return (withRepeats && d->mNextRepeat && d->mRepetition)
6166 ? d->mRepetition.duration(d->mNextRepeat).end(d->mNextMainDateTime.kDateTime())
6167 : d->mNextMainDateTime;
6172 return d->mNextMainDateTime.date();
6177 return d->mNextMainDateTime.effectiveTime();
6182 return d->mRepeatAtLogin;
6192 return d->mDeferred;
6197 return d->mDeferred && d->mTimedDeferral;
6202 d->mNextMainDateTime = dt;
6207 d->mNextMainDateTime = dt;
6210 #ifdef KDE_NO_DEBUG_OUTPUT
6223 default:
return "INVALID";
6236 #ifndef KALARMCAL_USE_KRESOURCES
6237 EmailAddressList& EmailAddressList::operator=(
const Person::List& addresses)
6239 EmailAddressList& EmailAddressList::operator=(
const QList<Person>& addresses)
6243 for (
int p = 0, end = addresses.count(); p < end; ++p)
6245 #ifndef KALARMCAL_USE_KRESOURCES
6246 if (!addresses[p]->email().isEmpty())
6248 if (!addresses[p].email().isEmpty())
6250 append(addresses[p]);
6258 EmailAddressList::operator QStringList()
const
6261 for (
int p = 0, end = count(); p < end; ++p)
6270 QString EmailAddressList::join(
const QString& separator)
const
6274 for (
int p = 0, end = count(); p < end; ++p)
6279 result += separator;
6280 result += address(p);
6288 QString EmailAddressList::address(
int index)
const
6290 if (index < 0 || index > count())
6294 #ifndef KALARMCAL_USE_KRESOURCES
6296 const QString name = person->name();
6298 const Person person = (*this)[index];
6299 const QString name = person.
name();
6301 if (!name.isEmpty())
6304 for (
int i = 0, len = name.length(); i < len; ++i)
6306 const QChar ch = name[i];
6307 if (!ch.isLetterOrNumber())
6310 result += QLatin1Char(
'\"');
6314 #ifndef KALARMCAL_USE_KRESOURCES
6315 result += (*this)[index]->name();
6317 result += (*this)[index].name();
6319 result += (quote ? QLatin1String(
"\" <") : QLatin1String(
" <"));
6323 #ifndef KALARMCAL_USE_KRESOURCES
6324 result += person->
email();
6326 result += person.
email();
6329 result += QLatin1Char(
'>');
6336 QStringList EmailAddressList::pureAddresses()
const
6339 for (
int p = 0, end = count(); p < end; ++p)
6340 #ifndef KALARMCAL_USE_KRESOURCES
6341 list += at(p)->email();
6343 list += at(p).email();
6351 QString EmailAddressList::pureAddresses(
const QString& separator)
const
6355 for (
int p = 0, end = count(); p < end; ++p)
6360 result += separator;
6361 #ifndef KALARMCAL_USE_KRESOURCES
6362 result += at(p)->email();
6364 result += at(p).email();
6379 #ifndef KALARMCAL_USE_KRESOURCES
6380 static void setProcedureAlarm(
const Alarm::Ptr& alarm,
const QString& commandLine)
6382 static void setProcedureAlarm(
Alarm* alarm,
const QString& commandLine)
6388 bool quoted =
false;
6389 const uint posMax = commandLine.length();
6391 for (pos = 0; pos < posMax; ++pos)
6393 const QChar ch = commandLine[pos];
6396 if (ch == quoteChar)
6406 switch (ch.toLatin1())
6413 done = !command.isEmpty();
6417 if (command.isEmpty())
6435 for ( ; pos < posMax && commandLine[pos] == QLatin1Char(
' '); ++pos) ;
6436 arguments = commandLine.mid(pos);
6445 QString reminderToString(
int minutes)
6448 int count = abs(minutes);
6449 if (count % 1440 == 0)
6454 else if (count % 60 == 0)
6461 return QString::fromLatin1(
"%1%2").arg(count).arg(unit);
void setEnabled(bool enable)
the alarm displays something
void cancelDefer()
Cancel any deferral alarm which is pending.
virtual void shiftTimes(const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec)
void setReminder(int minutes, bool onceOnly)
Set an additional reminder alarm.
KCalCore::Person::List emailAddressees() const
Return the list of email addressees, including names, for an email alarm.
the alarm displays command output
bool setRecurMinutely(int freq, int count, const KDateTime &end)
Set the recurrence to recur at a minutes interval.
yearly, on a specified date in each of the specified months
void setRepeatCount(int alarmRepeatCount)
bool repeatSound() const
Return whether the sound file will be repeated indefinitely.
Type type(const QString &mimeType)
Return the alarm Type for a mime type string.
OccurType setNextOccurrence(const KDateTime &preDateTime)
Set the date/time of the event to the next scheduled occurrence after a specified date/time...
KARecurrence * recurrence() const
Return the full recurrence data for the event.
bool recurs() const
Return whether the event recurs.
QTime time() const
Return the trigger time-of-day for the alarm.
void setRecurrence(const KARecurrence &r)
Initialise the event's recurrence from a KARecurrence.
weekly, on specified weekdays
QFont font() const
Return the font to use for alarm message texts.
Flags flags() const
Return the OR of various Flag enum status values.
Duration startOffset() const
QString repetitionText(bool brief=false) const
Return the repetition interval as text suitable for display.
bool cancelOnPreActionError() const
Return whether the alarm is to be cancelled if the pre-alarm action fails.
bool setRecurMonthlyByDate(int freq, const QVector< int > &days, int count, const QDate &end)
Set the recurrence to recur monthly, on the specified days within the month.
Reminder in advance of/after the main alarm.
void setEmailAlarm(const QString &subject, const QString &text, const Person::List &addressees, const QStringList &attachments=QStringList())
void dumpDebug() const
Output the event's data as debug output.
bool confirmAck() const
Return whether alarm acknowledgement must be confirmed by the user, for a display alarm...
THE real alarm. Must be the first in the enumeration.
the event is an alarm template
KCalCore::Duration interval() const
Return the interval between repetitions.
int lateCancel() const
Get the late cancellation period.
void setRepeatAtLogin(bool repeat)
Enable or disable repeat-at-login.
Type
The recurrence's period type.
DateTime addMins(qint64 n) const
Returns a DateTime value mins minutes later than the value of this object.
QSharedPointer< Alarm > Ptr
KAAlarm alarm(KAAlarm::Type type) const
Return the alarm of a specified type.
QString customProperty(const QByteArray &app, const QByteArray &key) const
KAAlarm represents individual alarms within a KAEvent.
DateTime mainEndRepeatTime() const
Return the time at which the last sub-repetition of the main alarm will occur.
int intervalSeconds() const
Return the repetition interval in terms of seconds.
QString customStatus() const
DateTime addSecs(qint64 n) const
Returns a DateTime value secs seconds later than the value of this object.
void setExcludeHolidays(bool exclude)
Enable or disable the alarm on holiday dates.
void setSnoozeTime(const Duration &alarmSnoozeTime)
void setDuration(int duration)
QSharedPointer< Event > Ptr
KCalCore::Duration longestRecurrenceInterval() const
Return the longest interval which can occur between consecutive recurrences.
bool speak() const
Return whether the displayed alarm text should be spoken.
OccurType previousOccurrence(const KDateTime &afterDateTime, DateTime &result, bool includeRepetitions=false) const
Get the date/time of the last previous occurrence of the event, before the specified date/time...
void setCategories(const QStringList &categories)
blind copy the email to the user
bool setRecurDaily(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur daily.
static QTime startOfDay()
Returns the start-of-day time.
Represents a sub-repetition, defined by interval and repeat count.
static void setWorkTime(const QBitArray &days, const QTime &start, const QTime &end)
Set working days and times, to be used by all KAEvent instances.
bool hasStartOffset() const
Recurrence * recurrence() const
auto-close the alarm window after the late-cancel period
int recurInterval() const
Return the recurrence interval in units of the recurrence period type (minutes, days, etc).
static void setStartOfDay(const QTime &sod)
Sets the start-of-day time.
void setLateCancel(int minutes)
Set or clear the late-cancel option.
KCalCore::Duration duration() const
Return the overall duration of the repetition.
bool isValid() const
Return whether the alarm is valid, i.e.
void startChanges()
Call before making a group of changes to the event, to avoid unnecessary calculation intensive recalc...
bool emailBcc() const
Return whether to send a blind copy of the email to the sender, for an email alarm.
post-alarm command execution failed
bool deferred() const
Return whether this is a deferred alarm.
static QString fromCalendarText(const QString &text, bool &email)
Translate an alarm calendar text to a display text.
void setAudioFile(const QString &filename, float volume, float fadeVolume, int fadeSeconds, int repeatPause=-1, bool allowEmptyFile=false)
Set the audio file related data for the event.
void set(const KCalCore::Event::Ptr &)
Initialise the instance from a KCalCore::Event.
static void setDefaultFont(const QFont &font)
Set the global default font for alarm message texts.
static void setHolidays(const KHolidays::HolidayRegion ®ion)
Set the holiday region to be used by all KAEvent instances.
next trigger time for display purposes (i.e. excluding reminders)
KACalendar::Compat compatibility() const
Return the event's storage format compatibility compared to the current KAlarm calendar format...
bool setRecurAnnualByDate(int freq, const QVector< int > &months, int day, KARecurrence::Feb29Type, int count, const QDate &end)
Set the recurrence to recur annually, on the specified day in each of the specified months...
QColor fgColour() const
Return the message window foreground color, for a display alarm.
void setEventId(const QString &id)
Set the event's unique identifier.
bool deferDefaultDateOnly() const
Return the default date-only setting used in the deferral dialog.
Type type() const
Return the alarm's type (main, reminder, etc.).
Actions actionTypes() const
Return the OR of the basic action types of the event's main alarm (display, command, email, audio).
yearly, on specified weekdays in the specified weeks of the specified months
void setProcedureAlarm(const QString &programFile, const QString &arguments=QString())
Feb29Type
When annual February 29th recurrences should occur in non-leap years.
bool setRepetition(const Repetition &r)
Initialise the event's sub-repetition.
int alarmCount() const
Return the number of alarms in the event, i.e.
bool setDisplaying(const KAEvent &event, KAAlarm::Type type, Akonadi::Collection::Id colId, const KDateTime &repeatAtLoginTime, bool showEdit, bool showDefer)
Set the event to be a copy of the specified event, making the specified alarm the 'displaying' alarm...
QString postAction() const
Return the shell command to execute after the display alarm is acknowledged.
int fadeSeconds() const
Return the fade period in seconds, or 0 if no fade is specified.
QStringList emailAttachments() const
Return the list of file paths of the attachments, for an email alarm.
DateTime deferDateTime() const
Return the time at which the currently pending deferred alarm should trigger.
bool holidaysExcluded() const
Return whether the alarm is disabled on holiday dates.
Akonadi::Item::Id itemId() const
Return the ID of the Akonadi Item which contains the event.
bool isTemplate() const
Return whether the event is an alarm template.
bool dontShowPreActionError() const
Return whether the user should not be notified if the pre-alarm action fails.
QVector< KAEvent * > List
A list of pointers to KAEvent objects.
KDateTime end(const KDateTime &start) const
Type
The category of an event, indicated by the middle part of its UID.
repeat the sound file while the alarm is displayed
DateTime mainDateTime(bool withRepeats=false) const
Return the next time the main alarm will trigger.
const QByteArray APPNAME
The application name ("KALARM") used in calendar properties.
check for recurrences only, ignore sub-repetitions
bool isWorkingTime(const KDateTime &dt) const
Check whether a date/time is during working hours and/or holidays, depending on the flags set for the...
DateTime dateTime(bool withRepeats=false) const
Return the trigger time for the alarm.
QString templateName() const
Return the alarm template's name.
Represents recurrences for KAlarm.
static QString toCalendarText(const QString &text)
Return the text for an alarm message text, in alarm calendar format.
Alarm::List alarms() const
void setCreatedDateTime(const KDateTime &dt)
Set the date/time the event was created, or saved in the archive calendar.
Duration snoozeTime() const
void endChanges()
Call when a group of changes preceded by startChanges() is complete, to allow resultant updates to oc...
int revision() const
Return the revision number of the event (SEQUENCE property in iCalendar).
KCal::Alarm::Display type: display a text message.
void setLogFile(const QString &logfile)
Set the log file to write command alarm output to.
bool toBeArchived() const
Return whether the event should be archived when it expires or is deleted.
Action
The basic KAAlarm action types.
QString emailSubject() const
Return the email subject line, for an email alarm.
the event is currently being displayed
bool isReminder() const
Return whether this is a reminder alarm.
QString logFile() const
Return the log file which command alarm output should be written to.
QTime mainTime() const
Return the time at which the main alarm will next trigger.
KAEvent()
Default constructor which creates an invalid event.
the event is currently active
KAAlarm & operator=(const KAAlarm &other)
Assignment operator.
bool isValid() const
Return whether the instance represents a valid event.
virtual KDateTime dtEnd() const
void removeCustomProperty(const QByteArray &app, const QByteArray &key)
KAAlarm firstAlarm() const
Return the main alarm for the event.
trigger the alarm only during working hours
DateTime nextTrigger(TriggerType type) const
Return the next time the alarm will trigger.
the alarm plays an audio file (without any display)
pre-alarm command execution failed
static const char * debugType(Type)
Return an alarm type as a string.
Action action() const
Return the action type for the alarm.
the command is a script, not a shell command line
QString message() const
Return the message text for a display alarm, or the email body for an email alarm.
CmdErrType commandError() const
Return the command execution error for the last time the alarm triggered.
don't trigger the alarm on holidays
bool beep() const
Return whether a beep should sound when the alarm is displayed.
OccurType nextOccurrence(const KDateTime &preDateTime, DateTime &result, OccurOption option=IGNORE_REPETITION) const
Get the date/time of the next occurrence of the event, after the specified date/time.
void setDeferDefaultMinutes(int minutes, bool dateOnly=false)
Set defaults for the deferral dialog.
bool recurs() const
Returns whether the event recurs at all.
the alarm is currently disabled
KAAlarm convertDisplayingAlarm() const
Return the original alarm which the displaying alarm refers to.
void setNoRecur()
Clear the event's recurrence and sub-repetition data.
KDateTime effectiveKDateTime() const
Returns the date and time of the value.
DeferLimitType
What type of occurrence currently limits how long the alarm can be deferred.
void setCommandError(CmdErrType error) const
Set or clear the command execution error for the last time the alarm triggered.
only trigger the reminder on the first recurrence
bool setRecurMonthlyByPos(int freq, const QVector< MonthPos > &pos, int count, const QDate &end)
Set the recurrence to recur monthly, on the specified weekdays in the specified weeks of the month...
void setReadOnly(bool ro)
Set the read-only status of the alarm.
cancel alarm on pre-alarm action error
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
float fadeVolume() const
Return the initial volume which will fade to the final volume.
execute pre-alarm action also for deferred alarms
CmdErrType
Command execution error type for last time the alarm was triggered.
void setFirstRecurrence()
Adjust the event date/time to the first recurrence of the event, on or after the event start date/tim...
next main working time trigger, excluding reminders
void setTime(const DateTime &dt)
Set the alarm's trigger time.
bool isValid() const
Returns true if the date is valid and, if it is a date-time value, the time is also valid...
a recurrence with only a date, not a time
void setAutoClose(bool autoclose)
Enable or disable auto-close for a display alarm, i.e.
bool reminderOnceOnly() const
Return whether the reminder alarm is triggered only for the first recurrence.
bool displaying() const
Return whether the alarm is currently being displayed, i.e.
speak the message when the alarm is displayed
int deferDefaultMinutes() const
Return the default deferral interval used in the deferral dialog.
bool commandScript() const
Return whether a command script is specified, for a command alarm.
KCal::Alarm::Audio type: play a sound file.
the alarm executes a command
bool enabled() const
Return the enabled status of the alarm.
QString id() const
Return the event's unique identifier.
sound an audible beep when the alarm is displayed
bool occursAfter(const KDateTime &preDateTime, bool includeRepetitions) const
Determine whether the event will occur after the specified date/time.
void setArchive()
Set the event to be archived when it expires or is deleted.
bool repeatAtLogin(bool includeArchived=false) const
Return whether the alarm repeats at login.
TriggerType
Alarm trigger type.
only a date is specified for the alarm, not a time
int reminderMinutes() const
Return the number of minutes BEFORE the main alarm when a reminder alarm is set.
a recurrence with a date and time
bool useDefaultFont() const
Return whether to use the default font (as set by setDefaultFont()) for alarm message texts...
void incrementRevision()
Increment the revision number of the event (SEQUENCE property in iCalendar).
DateTime startDateTime() const
Return the start time for the event.
closing the alarm message window requires a confirmation prompt
bool isDateOnly() const
Returns true if it is date-only value.
void setTime(const KDateTime &alarmTime)
void setCompatibility(KACalendar::Compat c)
Note the event's storage format compatibility compared to the current KAlarm calendar format...
bool repeatAtLogin() const
Return whether this is a repeat-at-login alarm.
QString audioFile() const
Return the audio file path.
static bool convertKCalEvents(const KCalCore::Calendar::Ptr &, int calendarVersion)
If a calendar was written by a previous version of KAlarm, do any necessary format conversions on the...
void setStartOffset(const Duration &offset)
bool timedDeferral() const
Return whether in the case of a deferred alarm, it is timed (as opposed to date-only).
ExtraActionOptions extraActionOptions() const
Return the pre- and post-alarm action options.
the first occurrence (takes precedence over LAST_RECURRENCE)
KAAlarm()
Default constructor, which creates an invalid instance.
KCal::Alarm::Display type: display a file (URL given by the alarm text)
verify that the KCal::Event UID is already the same as the KAEvent ID, if the latter is non-empty ...
repeat the alarm at every login
QSharedPointer< Calendar > Ptr
next actual working time trigger, including reminders
float soundVolume() const
Return the sound volume (the final volume if fade is specified).
void removeExpiredAlarm(KAAlarm::Type type)
Remove the alarm of the specified type from the event.
void activateReminderAfter(const DateTime &mainAlarmTime)
If there is a reminder which occurs AFTER the main alarm, activate the event's reminder which occurs ...
void setCollectionId(Akonadi::Collection::Id id)
Set the ID of the Akonadi Collection which contains the event.
QDate date() const
Return the trigger date for the alarm.
void defer(const DateTime &dt, bool reminder, bool adjustRecurrence=false)
Defer the event to the specified time.
static QString joinEmailAddresses(const KCalCore::Person::List &addresses, const QString &sep)
Concatenate a list of email addresses into a string.
void setItemId(Akonadi::Item::Id id)
Set the ID of the Akonadi Item which contains the event.
OccurOption
How to treat sub-repetitions in nextOccurrence().
int nextRepeatCount(const KDateTime &from, const KDateTime &preDateTime) const
Find the repetition count for the next repetition after a specified time.
display the contents of a file
void setTemplate(const QString &name, int afterTime=-1)
Set the event to be an alarm template.
static void setStartOfDay(const QTime &)
Set the start-of-day time used by all date-only alarms.
void setAudioAlarm(const QString &audioFile=QString())
Copy of the alarm currently being displayed.
set the KCal::Event UID to the KAEvent ID
void setMinutely(int freq)
QSharedPointer< Person > Ptr
uint identityUoid(const QString &identityUoidOrName)
Fetch the uoid of an identity name or uoid string.
KCal::Alarm::Email type: send an email.
command alarm execution failed
bool isReadOnly() const
Return the read-only status of the alarm.
QStringList emailPureAddresses() const
Return the list of email addressees, excluding names, for an email alarm.
QString fileName() const
Return the path of the file whose contents are to be shown, for a display alarm.
KAAlarm nextAlarm(const KAAlarm &previousAlarm) const
Return the next alarm for the event, after the specified alarm.
Repetition repetition() const
Return the event's sub-repetition data.
bool commandDisplay() const
Return whether the command output is to be displayed in an alarm message window.
QString emailMessage() const
Return the email message body, for an email alarm.
OccurType
What type of occurrence is due.
KDateTime kDateTime() const
Returns the date and time of the value as a KDateTime.
KAEvent represents a KAlarm event.
static void adjustStartOfDay(const KAEvent::List &events)
Call when the user changes the start-of-day time, to adjust the data for each date-only event in a li...
bool autoClose() const
Return whether auto-close is enabled, i.e.
use the default alarm message font
void setActions(const QString &pre, const QString &post, ExtraActionOptions options)
Set the pre-alarm and post-alarm actions, and their options.
SubAction actionSubType() const
Return the action sub-type of the event's main alarm.
QString recurrenceText(bool brief=false) const
Return the recurrence interval as text suitable for display.
UidAction
How to deal with the event UID in updateKCalEvent().
execute the command in a terminal window
QStringList emailAddresses() const
Return a list of the email addresses, including names, for an email alarm.
void setEmail(uint from, const KCalCore::Person::List &, const QString &subject, const QStringList &attachments)
Set the email related data for the event.
bool setRecurAnnualByPos(int freq, const QVector< MonthPos > &pos, const QVector< int > &months, int count, const QDate &end)
Set the recurrence to recur annually, on the specified weekdays in the specified weeks of the specifi...
bool mainExpired() const
Return whether the event's main alarm has expired.
Actions
The basic action type(s) for the event's main alarm.
display command output in the alarm window
int templateAfterTime() const
Return the number of minutes (>= 0) after the default alarm time which is specified in the alarm temp...
bool isDaily() const
Check whether the repetition interval is in terms of days (as opposed to minutes).
CalEvent::Type category() const
Return the alarm category (active/archived/template, or displaying).
Additional repeat-at-login trigger.
void setEnabled(bool enable)
Enable or disable the alarm.
bool deferred() const
Return whether there is currently a deferred alarm pending.
bool copyToKOrganizer() const
Return whether KOrganizer should hold a copy of the event.
monthly, on specified weekdays in a specified week of the month
bool workTimeOnly() const
Return whether the alarm is disabled on non-working days and outside working hours.
uint emailFromId() const
Return the email identity to be used as the sender, for an email alarm.
QString command() const
Return the command or script to execute, for a command alarm.
void setTime(const KDateTime &dt)
Set the next time to trigger the alarm (excluding sub-repetitions).
bool usingDefaultTime() const
Return whether the alarm template does not specify a time.
bool setItemPayload(Akonadi::Item &, const QStringList &collectionMimeTypes) const
Initialise an Akonadi::Item with the event's data.
KCal::Alarm::Procedure type: execute a shell command.
void setDisplayAlarm(const QString &text=QString())
return a sub-repetition if it's the next occurrence
bool expired() const
Return whether the event has expired.
void setCategory(CalEvent::Type type)
Set the alarm category (active/archived/template, or displaying).
Akonadi::Collection::Id collectionId() const
Return the ID of the Akonadi Collection which contains the event.
void setCollectionId_const(Akonadi::Collection::Id id) const
Set the ID of the Akonadi Collection which contains the event.
bool updateKCalEvent(const KCalCore::Event::Ptr &event, UidAction u, bool setCustomProperties=true) const
Update an existing KCalCore::Event with the KAEvent data.
bool reminderActive() const
Return whether a reminder is currently due (before the next, or after the last, main alarm/recurrence...
(bitmask for a sub-repetition of an occurrence)
void setWorkTimeOnly(bool wto)
Enable or disable the alarm on non-working days and outside working hours.
QMap< QByteArray, QString > customProperties() const
Return the original KCalCore::Event's custom properties in the source calendar.
int nextRepetition() const
Return the count of the next sub-repetition which is due.
at an hours/minutes interval
bool setRecurWeekly(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur weekly, on the specified weekdays.
KDateTime createdDateTime() const
Return the date/time the event was created, or saved in the archive calendar.
void setDateOnly(bool d)
Sets the value to be either date-only or date-time.
QString programArguments() const
do not notify pre-alarm action errors to user
QString displayMessage() const
Return the message text for a display alarm.
bool commandXterm() const
Return whether to execute the command in a terminal window, for a command alarm.
SubAction
The sub-action type for the event's main alarm.
As KDateTime, but with a configurable start-of-day time for date-only values.
next trigger, including reminders, ignoring working hours & holidays
void set(const KCalCore::Duration &interval, int count)
Initialises the instance with the specified interval and count.
monthly, on a specified day of the month
int intervalDays() const
Return the repetition interval in terms of days.
QString cleanText() const
Return the alarm's text.
QString audioFile() const
void reinstateFromDisplaying(const KCalCore::Event::Ptr &event, Akonadi::Collection::Id &colId, bool &showEdit, bool &showDefer)
Reinstate the original event from the 'displaying' event.
QColor bgColour() const
Return the message window background color, for a display alarm.
DateTime deferralLimit(DeferLimitType *limitType=0) const
Return the latest time which the alarm can currently be deferred to.
static List ptrList(QVector< KAEvent > &events)
Return a list of pointers to a list of KAEvent objects.
QString preAction() const
Return the shell command to execute before the alarm is displayed.
KARecurrence::Type recurType() const
Return the recurrence period type for the event.
int repeatSoundPause() const
Return how many seconds to pause between repetitions of the sound file.
Types types(const QStringList &mimeTypes)
Return the alarm Types for a list of mime type strings.
next trigger, excluding reminders, ignoring working hours & holidays
QString programFile() const
KOrganizer should hold a copy of the event.
bool reminderDeferral() const
Return whether there is currently a deferred reminder alarm pending.