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() { }
82 QString address(
int index)
const;
87 class KAAlarm::Private
94 DateTime mNextMainDateTime;
95 Repetition mRepetition;
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;
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*);
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;
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;
314 #ifndef KALARMCAL_USE_KRESOURCES
316 Akonadi::Item::Id mItemId;
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;
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;
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;
410 static const QString displayURL;
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;
423 static const QString HIDDEN_REMINDER_FLAG;
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;
446 int KAEvent::currentCalendarVersion() {
return Version(2,7,0); }
452 const QByteArray KAEventPrivate::FLAGS_PROPERTY(
"FLAGS");
467 const QByteArray KAEventPrivate::NEXT_RECUR_PROPERTY(
"NEXTRECUR");
468 const QByteArray KAEventPrivate::REPEAT_PROPERTY(
"REPEAT");
469 const QByteArray KAEventPrivate::LOG_PROPERTY(
"LOG");
474 const QByteArray KAEventPrivate::TYPE_PROPERTY(
"TYPE");
484 const QByteArray KAEventPrivate::NEXT_REPEAT_PROPERTY(
"NEXTREPEAT");
487 const QByteArray KAEventPrivate::FONT_COLOUR_PROPERTY(
"FONTCOLOR");
491 const QByteArray KAEventPrivate::VOLUME_PROPERTY(
"VOLUME");
506 #ifdef KALARMCAL_USE_KRESOURCES
515 QFont KAEventPrivate::mDefaultFont;
516 const KHolidays::HolidayRegion* KAEventPrivate::mHolidays = 0;
518 QTime KAEventPrivate::mWorkDayStart(9, 0, 0);
519 QTime KAEventPrivate::mWorkDayEnd(17, 0, 0);
520 int KAEventPrivate::mWorkTimeIndex = 1;
522 #ifndef KALARMCAL_USE_KRESOURCES
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();
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),
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);
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();
854 if (it.key().startsWith(kalarmKey))
855 it = mCustomProperties.erase(it);
861 bool dateOnly =
false;
864 for (
int i = 0, end = flags.
count() - 1; i < end; ++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();
904 case 'H': mReminderMinutes *= 60;
break;
905 case 'D': mReminderMinutes *= 1440;
break;
906 default: mReminderMinutes = 0;
break;
909 else if (flag == DEFER_FLAG)
914 mDeferDefaultDateOnly =
true;
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;
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 if (data.timedDeferral)
1077 mDeferralTime = data.alarm->hasStartOffset() ? data.alarm->startOffset().end(mNextMainDateTime.calendarKDateTime()) : data.alarm->time();
1081 mDeferralTime = dateTime;
1082 mDeferralTime.setDateOnly(
true);
1084 if (data.alarm->hasStartOffset())
1085 deferralOffset = data.alarm->startOffset();
1087 case DISPLAYING_ALARM:
1090 mDisplayingFlags = data.displayingFlags;
1091 const bool dateOnly = (mDisplayingFlags & DEFERRAL) ? !(mDisplayingFlags & TIMED_FLAG)
1092 : mStartDateTime.isDateOnly();
1093 mDisplayingTime = dateTime;
1094 mDisplayingTime.setDateOnly(dateOnly);
1095 alTime = mDisplayingTime;
1098 case PRE_ACTION_ALARM:
1099 mPreAction = data.cleanText;
1100 mExtraActionOptions = data.extraActionOptions;
1102 case POST_ACTION_ALARM:
1103 mPostAction = data.cleanText;
1110 bool noSetNextTime =
false;
1113 case DEFERRED_REMINDER_ALARM:
1114 case DEFERRED_ALARM:
1119 setDeferralTime =
true;
1120 noSetNextTime =
true;
1123 case REMINDER_ALARM:
1124 case AT_LOGIN_ALARM:
1125 case DISPLAYING_ALARM:
1126 if (!set && !noSetNextTime)
1127 mNextMainDateTime = alTime;
1135 mText = (mActionSubType ==
KAEvent::COMMAND) ? data.cleanText.trimmed() : data.cleanText;
1136 switch (data.action)
1139 mCommandScript = data.commandScript;
1140 if (!mCommandDisplay)
1145 mUseDefaultFont = data.defaultFont;
1146 if (data.isEmailText)
1150 mBgColour = data.bgColour;
1151 mFgColour = data.fgColour;
1154 mEmailFromIdentity = data.emailFromId;
1155 mEmailAddresses = data.alarm->mailAddresses();
1156 mEmailSubject = data.alarm->mailSubject();
1157 mEmailAttachments = data.alarm->mailAttachments();
1161 mRepeatSoundPause = data.repeatSoundPause;
1173 case PRE_ACTION_ALARM:
1174 case POST_ACTION_ALARM:
1181 mKMailSerialNumber = 0;
1184 if (recur && recur->
recurs())
1186 const int nextRepeat = mNextRepeat;
1187 setRecurrence(*recur);
1188 if (nextRepeat <= mRepetition.count())
1189 mNextRepeat = nextRepeat;
1191 else if (mRepetition)
1194 if (mRepetition.isDaily())
1195 setRecur(RecurrenceRule::rDaily, mRepetition.intervalDays(), mRepetition.count() + 1,
QDate());
1197 setRecur(RecurrenceRule::rMinutely, mRepetition.intervalMinutes(), mRepetition.count() + 1, KDateTime());
1198 mRepetition.set(0, 0);
1199 mTriggerChanged =
true;
1204 mArchiveRepeatAtLogin =
false;
1205 if (mReminderMinutes > 0)
1207 mReminderMinutes = 0;
1208 mReminderActive = NO_REMINDER;
1210 setRepeatAtLoginTrue(
false);
1217 DateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1218 dt.setDateOnly(mStartDateTime.isDateOnly());
1219 if (mDeferralTime.isDateOnly())
1221 mDeferralTime = deferralOffset.
end(dt.kDateTime());
1222 mDeferralTime.setDateOnly(
true);
1225 mDeferralTime = deferralOffset.
end(dt.effectiveKDateTime());
1227 if (mDeferral != NO_DEFERRAL)
1229 if (setDeferralTime)
1230 mNextMainDateTime = mDeferralTime;
1232 mTriggerChanged =
true;
1237 const QFont& f,
SubAction act,
int lateCancel, Flags flags,
bool changesPending)
1239 d->set(dt, message, bg, fg, f, act, lateCancel, flags, changesPending);
1245 void KAEventPrivate::set(
const KDateTime& dateTime,
const QString& text,
const QColor& bg,
const QColor& fg,
1247 bool changesPending)
1250 mStartDateTime = dateTime;
1252 mNextMainDateTime = mStartDateTime;
1267 mTemplateName.clear();
1268 #ifndef KALARMCAL_USE_KRESOURCES
1273 mOriginalResourceId.clear();
1276 mPostAction.clear();
1283 mTemplateAfterTime = -1;
1289 mLateCancel = lateCancel;
1290 mDeferral = NO_DEFERRAL;
1292 mStartDateTime.setDateOnly(flags & KAEvent::ANY_TIME);
1293 set_deferral((flags & DEFERRAL) ? NORMAL_DEFERRAL : NO_DEFERRAL);
1305 mDisplaying = flags & DISPLAYING_;
1314 setRepeatAtLoginTrue(
false);
1317 mKMailSerialNumber = 0;
1318 mReminderMinutes = 0;
1319 mDeferDefaultMinutes = 0;
1320 mDeferDefaultDateOnly =
false;
1321 mArchiveRepeatAtLogin =
false;
1322 mReminderActive = NO_REMINDER;
1323 mDisplaying =
false;
1324 mMainExpired =
false;
1325 mDisplayingDefer =
false;
1326 mDisplayingEdit =
false;
1328 mReminderAfterTime = DateTime();
1329 mExtraActionOptions = 0;
1330 #ifndef KALARMCAL_USE_KRESOURCES
1335 mChangeCount = changesPending ? 1 : 0;
1336 mTriggerChanged =
true;
1345 #ifndef KALARMCAL_USE_KRESOURCES
1348 return d->updateKCalEvent(e, u, setCustomProperties);
1354 return d->updateKCalEvent(e, u);
1358 #ifndef KALARMCAL_USE_KRESOURCES
1370 || (!mAlarmCount && (!archived || !mMainExpired)))
1375 const bool readOnly = ev->isReadOnly();
1377 ev->setUid(mEventID);
1378 #ifndef KALARMCAL_USE_KRESOURCES
1379 ev->setReadOnly(mReadOnly);
1381 ev->setReadOnly(
false);
1383 ev->setTransparency(Event::Transparent);
1388 #ifndef KALARMCAL_USE_KRESOURCES
1389 if (setCustomProperties)
1390 ev->setCustomProperties(mCustomProperties);
1400 #ifndef KALARMCAL_USE_KRESOURCES
1403 param = mOriginalResourceId;
1405 if (mDisplayingDefer)
1406 param += SC + DISP_DEFER;
1407 if (mDisplayingEdit)
1408 param += SC + DISP_EDIT;
1410 #ifndef KALARMCAL_USE_KRESOURCES
1411 CalEvent::setStatus(ev, mCategory, param);
1413 CalEvent::setStatus(ev, mCategory, param);
1416 if (mStartDateTime.isDateOnly())
1417 flags += DATE_ONLY_FLAG;
1419 flags += CONFIRM_ACK_FLAG;
1421 flags += EMAIL_BCC_FLAG;
1422 if (mCopyToKOrganizer)
1423 flags += KORGANIZER_FLAG;
1424 if (mExcludeHolidays)
1425 flags += EXCLUDE_HOLIDAYS_FLAG;
1427 flags += WORK_TIME_ONLY_FLAG;
1429 (flags += (mAutoClose ? AUTO_CLOSE_FLAG : LATE_CANCEL_FLAG)) +=
QString::number(mLateCancel);
1430 if (mReminderMinutes)
1432 flags += REMINDER_TYPE;
1433 if (mReminderOnceOnly)
1434 flags += REMINDER_ONCE_FLAG;
1435 flags += reminderToString(-mReminderMinutes);
1437 if (mDeferDefaultMinutes)
1440 if (mDeferDefaultDateOnly)
1442 (flags += DEFER_FLAG) += param;
1444 if (!mTemplateName.isEmpty() && mTemplateAfterTime >= 0)
1445 (flags += TEMPL_AFTER_TIME_FLAG) +=
QString::number(mTemplateAfterTime);
1446 if (mKMailSerialNumber)
1448 if (mArchive && !archived)
1450 flags += ARCHIVE_FLAG;
1451 if (mArchiveRepeatAtLogin)
1452 flags += AT_LOGIN_TYPE;
1459 else if (mCommandDisplay)
1461 else if (!mLogFile.isEmpty())
1464 ev->setCustomStatus(mEnabled ?
QString() : DISABLED_STATUS);
1465 ev->setRevision(mRevision);
1480 ev->setDtStart(mStartDateTime.calendarKDateTime());
1481 ev->setAllDay(
false);
1482 ev->setDtEnd(KDateTime());
1484 const DateTime dtMain = archived ? mStartDateTime : mNextMainDateTime;
1485 int ancillaryType = 0;
1486 DateTime ancillaryTime;
1487 int ancillaryOffset = 0;
1488 if (!mMainExpired || archived)
1497 QDateTime dt = mNextMainDateTime.kDateTime().
toTimeSpec(mStartDateTime.timeSpec()).dateTime();
1503 ancillaryOffset = 0;
1504 ancillaryType = dtMain.isValid() ? 2 : 0;
1506 else if (mRepetition)
1515 if (mRepeatAtLogin || (mArchiveRepeatAtLogin && archived))
1518 if (mArchiveRepeatAtLogin)
1519 dtl = mStartDateTime.calendarKDateTime().addDays(-1);
1520 else if (mAtLoginDateTime.isValid())
1521 dtl = mAtLoginDateTime;
1522 else if (mStartDateTime.isDateOnly())
1523 dtl = DateTime(KDateTime::currentLocalDate().addDays(-1), mStartDateTime.timeSpec());
1525 dtl = KDateTime::currentUtcDateTime();
1526 initKCalAlarm(ev, dtl,
QStringList(AT_LOGIN_TYPE));
1527 if (!ancillaryType && dtl.isValid())
1529 ancillaryTime = dtl;
1535 DateTime nextDateTime = mNextMainDateTime;
1539 nextDateTime = mStartDateTime;
1547 KDateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1548 dt.setDateOnly(mStartDateTime.isDateOnly());
1553 if (mReminderMinutes && (mReminderActive != NO_REMINDER || archived))
1556 if (mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
1559 startOffset = nextDateTime.calendarKDateTime().
secsTo(mReminderAfterTime.calendarKDateTime());
1564 startOffset = -mReminderMinutes * 60;
1566 initKCalAlarm(ev, startOffset,
QStringList(REMINDER_TYPE));
1568 if (!ancillaryType && (mReminderActive == ACTIVE_REMINDER || archived))
1570 ancillaryOffset = startOffset;
1574 if (mDeferral != NO_DEFERRAL)
1578 if (mDeferralTime.isDateOnly())
1580 startOffset = nextDateTime.secsTo(mDeferralTime.calendarKDateTime());
1581 list += DATE_DEFERRAL_TYPE;
1585 startOffset = nextDateTime.calendarKDateTime().secsTo(mDeferralTime.calendarKDateTime());
1586 list += TIME_DEFERRAL_TYPE;
1588 if (mDeferral == REMINDER_DEFERRAL)
1589 list += REMINDER_TYPE;
1590 initKCalAlarm(ev, startOffset, list);
1591 if (!ancillaryType && mDeferralTime.isValid())
1593 ancillaryOffset = startOffset;
1597 if (!mTemplateName.isEmpty())
1598 ev->setSummary(mTemplateName);
1599 else if (mDisplaying)
1602 if (mDisplayingFlags & KAEvent::REPEAT_AT_LOGIN)
1603 list += AT_LOGIN_TYPE;
1604 else if (mDisplayingFlags & DEFERRAL)
1606 if (mDisplayingFlags & TIMED_FLAG)
1607 list += TIME_DEFERRAL_TYPE;
1609 list += DATE_DEFERRAL_TYPE;
1611 if (mDisplayingFlags & REMINDER)
1612 list += REMINDER_TYPE;
1613 initKCalAlarm(ev, mDisplayingTime, list);
1614 if (!ancillaryType && mDisplayingTime.isValid())
1616 ancillaryTime = mDisplayingTime;
1620 if ((mBeep || mSpeak || !mAudioFile.isEmpty()) && mActionSubType !=
KAEvent::AUDIO)
1623 if (ancillaryType == 2)
1624 initKCalAlarm(ev, ancillaryOffset,
QStringList(), AUDIO_ALARM);
1626 initKCalAlarm(ev, ancillaryTime,
QStringList(), AUDIO_ALARM);
1628 if (!mPreAction.isEmpty())
1631 if (ancillaryType == 2)
1632 initKCalAlarm(ev, ancillaryOffset,
QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1634 initKCalAlarm(ev, ancillaryTime,
QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1636 if (!mPostAction.isEmpty())
1639 if (ancillaryType == 2)
1640 initKCalAlarm(ev, ancillaryOffset,
QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1642 initKCalAlarm(ev, ancillaryTime,
QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1646 mRecurrence->writeRecurrence(*ev->recurrence());
1648 ev->clearRecurrence();
1649 if (mCreatedDateTime.isValid())
1650 ev->setCreated(mCreatedDateTime);
1651 ev->setReadOnly(readOnly);
1663 #ifndef KALARMCAL_USE_KRESOURCES
1666 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1669 const int startOffset = dt.isDateOnly() ? mStartDateTime.secsTo(dt)
1670 : mStartDateTime.calendarKDateTime().secsTo(dt.calendarKDateTime());
1671 return initKCalAlarm(event, startOffset, types, type);
1674 #ifndef KALARMCAL_USE_KRESOURCES
1677 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1682 #ifndef KALARMCAL_USE_KRESOURCES
1685 Alarm* alarm =
event->newAlarm();
1688 if (type != MAIN_ALARM)
1698 setAudioAlarm(alarm);
1700 flags << KAEventPrivate::SPEAK_FLAG;
1701 if (mRepeatSoundPause >= 0)
1709 case PRE_ACTION_ALARM:
1710 setProcedureAlarm(alarm, mPreAction);
1712 flags << KAEventPrivate::EXEC_ON_DEFERRAL_FLAG;
1714 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
1716 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
1718 case POST_ACTION_ALARM:
1719 setProcedureAlarm(alarm, mPostAction);
1728 case REMINDER_ALARM:
1732 && mReminderMinutes < 0 && mReminderActive == HIDDEN_REMINDER)
1736 flags << HIDDEN_REMINDER_FLAG;
1738 bool display =
false;
1739 switch (mActionSubType)
1742 alltypes += FILE_TYPE;
1752 setProcedureAlarm(alarm, mText);
1753 display = mCommandDisplay;
1756 alarm->
setEmailAlarm(mEmailSubject, mText, mEmailAddresses, mEmailAttachments);
1757 if (mEmailFromIdentity)
1758 flags << KAEventPrivate::EMAIL_ID_FLAG <<
QString::number(mEmailFromIdentity);
1761 setAudioAlarm(alarm);
1762 if (mRepeatSoundPause >= 0)
1764 alltypes += SOUND_REPEAT_TYPE;
1765 if (type == MAIN_ALARM)
1773 .arg(mFgColour.name())
1774 .arg(mUseDefaultFont ?
QString() : mFont.toString()));
1777 case DEFERRED_ALARM:
1778 case DEFERRED_REMINDER_ALARM:
1779 case AT_LOGIN_ALARM:
1780 case DISPLAYING_ALARM:
1793 return d->mAlarmCount && (d->mAlarmCount != 1 || !d->mRepeatAtLogin);
1798 d->mEnabled = enable;
1806 #ifndef KALARMCAL_USE_KRESOURCES
1814 return d->mReadOnly;
1830 return d->mMainExpired;
1843 KAEvent::Flags KAEventPrivate::flags()
const
1845 KAEvent::Flags result(0);
1849 if (mStartDateTime.isDateOnly()) result |= KAEvent::ANY_TIME;
1880 mEventID = CalEvent::uid(mEventID, s);
1882 mTriggerChanged =
true;
1887 return d->mCategory;
1907 return d->mRevision;
1910 #ifndef KALARMCAL_USE_KRESOURCES
1913 d->mCollectionId =
id;
1918 d->mCollectionId =
id;
1924 return d->mDisplaying ? -1 : d->mCollectionId;
1946 switch (d->mCategory)
1951 default: Q_ASSERT(0);
return false;
1953 if (!collectionMimeTypes.
contains(mimetype))
1955 item.setMimeType(mimetype);
1956 item.setPayload<
KAEvent>(*this);
1962 d->mCompatibility = c;
1967 return d->mCompatibility;
1972 return d->mCustomProperties;
1976 void KAEvent::setResource(AlarmResource* r)
1981 AlarmResource* KAEvent::resource()
const
1983 return d->mResource;
1989 return d->mActionSubType;
1994 switch (d->mActionSubType)
2007 if (d->mRepeatAtLogin)
2009 d->mLateCancel = minutes;
2011 d->mAutoClose =
false;
2016 return d->mLateCancel;
2026 return d->mAutoClose;
2029 void KAEvent::setKMailSerialNumber(
unsigned long n)
2031 d->mKMailSerialNumber = n;
2034 unsigned long KAEvent::kmailSerialNumber()
const
2036 return d->mKMailSerialNumber;
2046 return (d->mActionSubType ==
MESSAGE
2057 return (d->mActionSubType ==
FILE) ? d->mText :
QString();
2062 return d->mBgColour;
2067 return d->mFgColour;
2072 KAEventPrivate::mDefaultFont = f;
2077 return d->mUseDefaultFont;
2082 return d->mUseDefaultFont ? KAEventPrivate::mDefaultFont : d->mFont;
2092 return d->mCommandScript;
2097 return d->mCommandXterm;
2102 return d->mCommandDisplay;
2105 #ifndef KALARMCAL_USE_KRESOURCES
2108 d->mCommandError = t;
2118 d->setCommandError(t, writeConfig);
2123 kDebug() << mEventID <<
"," << error;
2124 if (error == mCommandError)
2126 mCommandError = error;
2129 KConfigGroup config(KGlobal::config(), mCmdErrConfigGroup);
2131 config.deleteEntry(mEventID);
2135 switch (mCommandError)
2140 case KAEvent::CMD_ERROR_PRE_POST:
2141 errtext = CMD_ERROR_PRE_VALUE +
',' + CMD_ERROR_POST_VALUE;
2146 config.writeEntry(mEventID, errtext);
2157 d->setCommandError(configString);
2160 void KAEventPrivate::setCommandError(
const QString& configString)
2164 if (errs.
indexOf(CMD_ERROR_VALUE) >= 0)
2168 if (errs.
indexOf(CMD_ERROR_PRE_VALUE) >= 0)
2170 if (errs.
indexOf(CMD_ERROR_POST_VALUE) >= 0)
2175 QString KAEvent::commandErrorConfigGroup()
2177 return KAEventPrivate::mCmdErrConfigGroup;
2183 return d->mCommandError;
2188 d->mLogFile = logfile;
2190 d->mCommandDisplay = d->mCommandXterm =
false;
2200 return d->mConfirmAck;
2205 return d->mCopyToKOrganizer;
2208 #ifndef KALARMCAL_USE_KRESOURCES
2216 d->mEmailFromIdentity = from;
2217 d->mEmailAddresses = addresses;
2218 d->mEmailSubject = subject;
2219 d->mEmailAttachments = attachments;
2224 return (d->mActionSubType ==
EMAIL) ? d->mText :
QString();
2229 return d->mEmailFromIdentity;
2232 #ifndef KALARMCAL_USE_KRESOURCES
2238 return d->mEmailAddresses;
2243 return static_cast<QStringList>(d->mEmailAddresses);
2248 return d->mEmailAddresses.join(sep);
2251 #ifndef KALARMCAL_USE_KRESOURCES
2257 return EmailAddressList(addresses).join(separator);
2262 return d->mEmailAddresses.pureAddresses();
2267 return d->mEmailAddresses.pureAddresses(sep);
2272 return d->mEmailSubject;
2277 return d->mEmailAttachments;
2282 return d->mEmailAttachments.join(sep);
2287 return d->mEmailBcc;
2292 d->setAudioFile(filename, volume, fadeVolume, fadeSeconds, repeatPause, allowEmptyFile);
2295 void KAEventPrivate::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2297 mAudioFile = filename;
2298 mSoundVolume = (!allowEmptyFile && filename.
isEmpty()) ? -1 : volume;
2299 if (mSoundVolume >= 0)
2301 mFadeVolume = (fadeSeconds > 0) ? fadeVolume : -1;
2302 mFadeSeconds = (mFadeVolume >= 0) ? fadeSeconds : 0;
2309 mRepeatSoundPause = repeatPause;
2314 return d->mAudioFile;
2319 return d->mSoundVolume;
2324 return d->mSoundVolume >= 0 && d->mFadeSeconds ? d->mFadeVolume : -1;
2329 return d->mSoundVolume >= 0 && d->mFadeVolume >= 0 ? d->mFadeSeconds : 0;
2334 return d->mRepeatSoundPause >= 0;
2339 return d->mRepeatSoundPause;
2349 return (d->mActionSubType ==
MESSAGE
2350 || (d->mActionSubType ==
COMMAND && d->mCommandDisplay))
2360 d->mTemplateName = name;
2361 d->mTemplateAfterTime = afterTime;
2362 d->mTriggerChanged =
true;
2367 return !d->mTemplateName.isEmpty();
2372 return d->mTemplateName;
2377 return d->mTemplateAfterTime == 0;
2382 return d->mTemplateAfterTime;
2387 d->mPreAction = pre;
2388 d->mPostAction = post;
2389 d->mExtraActionOptions = options;
2394 ExtraActionOptions opts(0);
2404 return d->mPreAction;
2409 return d->mPostAction;
2414 return d->mExtraActionOptions;
2433 d->setReminder(minutes, onceOnly);
2436 void KAEventPrivate::setReminder(
int minutes,
bool onceOnly)
2438 if (minutes > 0 && mRepeatAtLogin)
2440 if (minutes != mReminderMinutes || (minutes && mReminderActive != ACTIVE_REMINDER))
2442 if (minutes && mReminderActive == NO_REMINDER)
2444 else if (!minutes && mReminderActive != NO_REMINDER)
2446 mReminderMinutes = minutes;
2447 mReminderActive = minutes ? ACTIVE_REMINDER : NO_REMINDER;
2448 mReminderOnceOnly = onceOnly;
2450 mTriggerChanged =
true;
2460 d->activateReminderAfter(mainAlarmTime);
2463 void KAEventPrivate::activateReminderAfter(
const DateTime& mainAlarmTime)
2465 if (mReminderMinutes >= 0 || mReminderActive == ACTIVE_REMINDER || !mainAlarmTime.
isValid())
2475 || mainAlarmTime != next)
2478 else if (!mRepeatAtLogin)
2481 if (mainAlarmTime != mStartDateTime)
2485 const DateTime reminderTime = mainAlarmTime.
addMins(-mReminderMinutes);
2488 && reminderTime >= next)
2492 activate_reminder(
true);
2493 mReminderAfterTime = reminderTime;
2498 return d->mReminderMinutes;
2503 return d->mReminderActive == KAEventPrivate::ACTIVE_REMINDER;
2508 return d->mReminderOnceOnly;
2513 return d->mDeferral == KAEventPrivate::REMINDER_DEFERRAL;
2524 return d->defer(dt, reminder, adjustRecurrence);
2527 void KAEventPrivate::defer(
const DateTime& dateTime,
bool reminder,
bool adjustRecurrence)
2530 bool setNextRepetition =
false;
2531 bool checkRepetition =
false;
2532 bool checkReminderAfter =
false;
2536 if (mReminderMinutes)
2538 bool deferReminder =
false;
2539 if (mReminderMinutes > 0)
2543 deferReminder =
true;
2544 else if (mReminderActive == ACTIVE_REMINDER || mDeferral == REMINDER_DEFERRAL)
2547 set_deferral(NO_DEFERRAL);
2548 mTriggerChanged =
true;
2551 else if (mReminderMinutes < 0 && reminder)
2552 deferReminder =
true;
2555 set_deferral(REMINDER_DEFERRAL);
2556 mDeferralTime = dateTime;
2557 mTriggerChanged =
true;
2559 if (mReminderActive == ACTIVE_REMINDER)
2561 activate_reminder(
false);
2562 mTriggerChanged =
true;
2565 if (mDeferral != REMINDER_DEFERRAL)
2569 mNextMainDateTime = mDeferralTime = dateTime;
2570 set_deferral(NORMAL_DEFERRAL);
2571 mTriggerChanged =
true;
2572 checkReminderAfter =
true;
2576 mMainExpired =
true;
2581 mArchiveRepeatAtLogin =
true;
2582 mRepeatAtLogin =
false;
2595 set_deferral(NO_DEFERRAL);
2599 set_deferral(REMINDER_DEFERRAL);
2600 mDeferralTime = dateTime;
2601 checkRepetition =
true;
2603 mTriggerChanged =
true;
2608 mDeferralTime = dateTime;
2609 if (mDeferral == NO_DEFERRAL)
2610 set_deferral(NORMAL_DEFERRAL);
2611 mTriggerChanged =
true;
2612 checkReminderAfter =
true;
2613 if (adjustRecurrence)
2615 const KDateTime now = KDateTime::currentUtcDateTime();
2616 if (mainEndRepeatTime() < now)
2622 mMainExpired =
true;
2627 setNextRepetition = mRepetition;
2630 checkRepetition =
true;
2632 if (checkReminderAfter && mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
2636 mReminderActive = (mDeferralTime < mReminderAfterTime) ? ACTIVE_REMINDER : HIDDEN_REMINDER;
2638 if (checkRepetition)
2639 setNextRepetition = (mRepetition && mDeferralTime < mainEndRepeatTime());
2640 if (setNextRepetition)
2644 if (mNextMainDateTime >= mDeferralTime)
2647 mNextRepeat = mRepetition.nextRepeatCount(mNextMainDateTime.kDateTime(), mDeferralTime.kDateTime());
2648 mTriggerChanged =
true;
2661 void KAEventPrivate::cancelDefer()
2663 if (mDeferral != NO_DEFERRAL)
2666 set_deferral(NO_DEFERRAL);
2667 mTriggerChanged =
true;
2673 d->mDeferDefaultMinutes = minutes;
2674 d->mDeferDefaultDateOnly = dateOnly;
2679 return d->mDeferral > 0;
2684 return d->mDeferralTime;
2692 return d->deferralLimit(limitType);
2705 const KDateTime now = KDateTime::currentUtcDateTime();
2711 else if (mReminderActive == ACTIVE_REMINDER && mReminderMinutes > 0
2712 && (now < (reminderTime = endTime.
addMins(-mReminderMinutes))))
2714 endTime = reminderTime;
2720 else if (mReminderMinutes < 0)
2724 if (KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2726 endTime = mNextMainDateTime;
2730 else if (mReminderMinutes > 0
2731 && KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2735 endTime = mNextMainDateTime;
2739 endTime = endTime.
addMins(-1);
2747 return d->mDeferDefaultMinutes;
2752 return d->mDeferDefaultDateOnly;
2757 return d->mStartDateTime;
2762 d->mNextMainDateTime = dt;
2763 d->mTriggerChanged =
true;
2768 return d->mainDateTime(withRepeats);
2773 return d->mNextMainDateTime.effectiveTime();
2778 return d->mainEndRepeatTime();
2788 #warning Does this need all trigger times for date-only alarms to be recalculated?
2799 for (
int i = 0, end = events.
count(); i < end; ++i)
2801 KAEventPrivate*
const p = events[i]->d;
2803 p->mRecurrence->setStartDateTime(p->mStartDateTime.effectiveKDateTime(),
true);
2809 d->calcTriggerTimes();
2818 const bool reminderAfter = d->mMainExpired && d->mReminderActive && d->mReminderMinutes < 0;
2820 ? (reminderAfter ? d->mAllWorkTrigger : d->mMainWorkTrigger)
2821 : (reminderAfter ? d->mAllTrigger : d->mMainTrigger);
2829 d->mCreatedDateTime = dt;
2834 return d->mCreatedDateTime;
2842 d->setRepeatAtLogin(rl);
2845 void KAEventPrivate::setRepeatAtLogin(
bool rl)
2847 if (rl && !mRepeatAtLogin)
2849 setRepeatAtLoginTrue(
true);
2852 else if (!rl && mRepeatAtLogin)
2854 mRepeatAtLogin = rl;
2855 mTriggerChanged =
true;
2861 void KAEventPrivate::setRepeatAtLoginTrue(
bool clearReminder)
2864 if (mReminderMinutes >= 0 && clearReminder)
2865 setReminder(0,
false);
2868 mCopyToKOrganizer =
false;
2873 return d->mRepeatAtLogin || (includeArchived && d->mArchiveRepeatAtLogin);
2878 d->mExcludeHolidays = ex ? KAEventPrivate::mHolidays : 0;
2885 return d->mExcludeHolidays;
2897 KAEventPrivate::mHolidays = &h;
2902 d->mWorkTimeOnly = wto;
2909 return d->mWorkTimeOnly;
2918 return d->isWorkingTime(dt);
2921 bool KAEventPrivate::isWorkingTime(
const KDateTime& dt)
const
2923 if ((mWorkTimeOnly && !mWorkDays.testBit(dt.date().dayOfWeek() - 1))
2924 || (mExcludeHolidays && mHolidays && mHolidays->isHoliday(dt.date())))
2928 return dt.isDateOnly()
2929 || (dt.time() >= mWorkDayStart && dt.time() < mWorkDayEnd);
2939 if (days != KAEventPrivate::mWorkDays || start != KAEventPrivate::mWorkDayStart || end != KAEventPrivate::mWorkDayEnd)
2941 KAEventPrivate::mWorkDays = days;
2942 KAEventPrivate::mWorkDayStart = start;
2943 KAEventPrivate::mWorkDayEnd = end;
2944 if (!++KAEventPrivate::mWorkTimeIndex)
2945 ++KAEventPrivate::mWorkTimeIndex;
2957 void KAEventPrivate::clearRecur()
2959 if (mRecurrence || mRepetition)
2963 mRepetition.set(0, 0);
2964 mTriggerChanged =
true;
2975 d->setRecurrence(recurrence);
2978 void KAEventPrivate::setRecurrence(
const KARecurrence& recurrence)
2985 mRecurrence->setStartDateTime(mStartDateTime.effectiveKDateTime(), mStartDateTime.isDateOnly());
2986 mTriggerChanged =
true;
2989 setRepetition(mRepetition);
3009 const bool success = d->setRecur(RecurrenceRule::rMinutely, freq, count, end);
3010 d->mTriggerChanged =
true;
3027 const bool success = d->setRecur(RecurrenceRule::rDaily, freq, count, end);
3031 for (
int i = 0; i < 7; ++i)
3037 d->mRecurrence->addWeeklyDays(days);
3039 d->mTriggerChanged =
true;
3056 const bool success = d->setRecur(RecurrenceRule::rWeekly, freq, count, end);
3058 d->mRecurrence->addWeeklyDays(days);
3059 d->mTriggerChanged =
true;
3076 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3079 for (
int i = 0, end = days.
count(); i < end; ++i)
3080 d->mRecurrence->addMonthlyDate(days[i]);
3082 d->mTriggerChanged =
true;
3100 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3103 for (
int i = 0, end = posns.
count(); i < end; ++i)
3104 d->mRecurrence->addMonthlyPos(posns[i].weeknum, posns[i].days);
3106 d->mTriggerChanged =
true;
3126 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end, feb29);
3129 for (
int i = 0, end = months.
count(); i < end; ++i)
3130 d->mRecurrence->addYearlyMonth(months[i]);
3132 d->mRecurrence->addMonthlyDate(day);
3134 d->mTriggerChanged =
true;
3153 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end);
3158 for (iend = months.
count(); i < iend; ++i)
3159 d->mRecurrence->addYearlyMonth(months[i]);
3160 for (i = 0, iend = posns.
count(); i < iend; ++i)
3161 d->mRecurrence->addYearlyPos(posns[i].weeknum, posns[i].days);
3163 d->mTriggerChanged =
true;
3179 KDateTime edt = mNextMainDateTime.kDateTime();
3181 return setRecur(recurType, freq, count, edt, feb29);
3185 if (count >= -1 && (count || end.date().isValid()))
3188 mRecurrence =
new KARecurrence;
3189 if (mRecurrence->init(recurType, freq, count, mNextMainDateTime.kDateTime(), end, feb29))
3203 return d->checkRecur();
3208 return d->mRecurrence;
3218 switch (d->mRecurrence->type())
3227 return d->mRecurrence->frequency();
3237 return d->mRecurrence ? d->mRecurrence->longestInterval() :
Duration(0);
3247 d->setFirstRecurrence();
3250 void KAEventPrivate::setFirstRecurrence()
3252 switch (checkRecur())
3259 if (mRecurrence->yearMonths().isEmpty())
3268 const KDateTime recurStart = mRecurrence->startDateTime();
3269 if (mRecurrence->recursOn(recurStart.date(), recurStart.timeSpec()))
3273 const int frequency = mRecurrence->frequency();
3274 mRecurrence->setFrequency(1);
3276 nextRecurrence(mNextMainDateTime.effectiveKDateTime(), next);
3277 if (!next.isValid())
3278 mRecurrence->setStartDateTime(recurStart, mStartDateTime.isDateOnly());
3281 mRecurrence->setStartDateTime(next.effectiveKDateTime(), next.isDateOnly());
3282 mStartDateTime = mNextMainDateTime = next;
3283 mTriggerChanged =
true;
3285 mRecurrence->setFrequency(frequency);
3293 if (d->mRepeatAtLogin)
3294 return brief ? i18nc(
"@info/plain Brief form of 'At Login'",
"Login") : i18nc(
"@info/plain",
"At login");
3297 const int frequency = d->mRecurrence->frequency();
3298 switch (d->mRecurrence->defaultRRuleConst()->recurrenceType())
3300 case RecurrenceRule::rMinutely:
3302 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", frequency);
3303 else if (frequency % 60 == 0)
3304 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", frequency/60);
3308 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", frequency/60, mins.
sprintf(
"%02d", frequency%60));
3310 case RecurrenceRule::rDaily:
3311 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", frequency);
3312 case RecurrenceRule::rWeekly:
3313 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", frequency);
3314 case RecurrenceRule::rMonthly:
3315 return i18ncp(
"@info/plain",
"1 Month",
"%1 Months", frequency);
3316 case RecurrenceRule::rYearly:
3317 return i18ncp(
"@info/plain",
"1 Year",
"%1 Years", frequency);
3318 case RecurrenceRule::rNone:
3323 return brief ?
QString() : i18nc(
"@info/plain No recurrence",
"None");
3334 return d->setRepetition(r);
3337 bool KAEventPrivate::setRepetition(
const Repetition& repetition)
3342 if (repetition && !mRepeatAtLogin)
3345 if (!repetition.
isDaily() && mStartDateTime.isDateOnly())
3347 mRepetition.set(0, 0);
3350 Duration longestInterval = mRecurrence->longestInterval();
3351 if (repetition.
duration() >= longestInterval)
3353 const int count = mStartDateTime.isDateOnly()
3356 mRepetition.set(repetition.
interval(), count);
3359 mRepetition = repetition;
3360 mTriggerChanged =
true;
3362 else if (mRepetition)
3364 mRepetition.
set(0, 0);
3365 mTriggerChanged =
true;
3372 return d->mRepetition;
3377 return d->mNextRepeat;
3387 if (!d->mRepetition.isDaily())
3389 const int minutes = d->mRepetition.intervalMinutes();
3391 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", minutes);
3392 if (minutes % 60 == 0)
3393 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", minutes/60);
3395 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", minutes/60, mins.
sprintf(
"%02d", minutes%60));
3397 const int days = d->mRepetition.intervalDays();
3399 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", days);
3400 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", days / 7);
3402 return brief ?
QString() : i18nc(
"@info/plain No repetition",
"None");
3412 return d->occursAfter(preDateTime, includeRepetitions);
3415 bool KAEventPrivate::occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const
3420 if (mRecurrence->duration() < 0)
3422 dt = mRecurrence->endDateTime();
3425 dt = mNextMainDateTime.effectiveKDateTime();
3426 if (mStartDateTime.isDateOnly())
3428 QDate pre = preDateTime.date();
3431 if (pre < dt.date())
3434 else if (preDateTime < dt)
3437 if (includeRepetitions && mRepetition)
3439 if (preDateTime < mRepetition.duration().end(dt))
3455 return d->setNextOccurrence(preDateTime);
3460 if (preDateTime < mNextMainDateTime.effectiveKDateTime())
3462 KDateTime pre = preDateTime;
3467 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3471 if (pre < mNextMainDateTime.effectiveKDateTime())
3473 afterPre = mNextMainDateTime;
3478 type = nextRecurrence(pre, afterPre);
3484 mNextMainDateTime = afterPre;
3485 if (mReminderMinutes > 0 && (mDeferral == REMINDER_DEFERRAL || mReminderActive != ACTIVE_REMINDER))
3489 activate_reminder(!mReminderOnceOnly);
3491 if (mDeferral == REMINDER_DEFERRAL)
3492 set_deferral(NO_DEFERRAL);
3493 mTriggerChanged =
true;
3501 if (afterPre <= preDateTime)
3505 mNextRepeat = mRepetition.nextRepeatCount(afterPre.
effectiveKDateTime(), preDateTime);
3507 activate_reminder(
false);
3508 if (mDeferral == REMINDER_DEFERRAL)
3509 set_deferral(NO_DEFERRAL);
3510 mTriggerChanged =
true;
3512 else if (mNextRepeat)
3516 mTriggerChanged =
true;
3529 return d->nextOccurrence(preDateTime, result, o);
3535 KDateTime pre = preDateTime;
3541 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3547 type = nextRecurrence(pre, result);
3548 else if (pre < mNextMainDateTime.effectiveKDateTime())
3550 result = mNextMainDateTime;
3555 result = DateTime();
3563 const DateTime repeatDT = mRepetition.duration(repetition).end(result.
kDateTime());
3571 const KAEvent::OccurType newType = previousOccurrence(repeatDT.effectiveKDateTime(), dt,
false);
3579 repetition = mRepetition.nextRepeatCount(result.
kDateTime(), preDateTime);
3580 result = mRepetition.duration(repetition).end(result.
kDateTime());
3605 return d->previousOccurrence(afterDateTime, result, includeRepetitions);
3609 bool includeRepetitions)
const
3611 Q_ASSERT(!afterDateTime.isDateOnly());
3612 if (mStartDateTime >= afterDateTime)
3614 result = KDateTime();
3622 result = mStartDateTime;
3627 const KDateTime recurStart = mRecurrence->startDateTime();
3628 KDateTime after = afterDateTime.toTimeSpec(mStartDateTime.timeSpec());
3630 after = after.addDays(1);
3631 const KDateTime dt = mRecurrence->getPreviousDateTime(after);
3636 if (dt == recurStart)
3638 else if (mRecurrence->getNextDateTime(dt).isValid())
3644 if (includeRepetitions && mRepetition)
3647 const int repetition = mRepetition.previousRepeatCount(result.
effectiveKDateTime(), afterDateTime);
3650 result = mRepetition.duration(qMin(repetition, mRepetition.count())).end(result.
kDateTime());
3666 #ifndef KALARMCAL_USE_KRESOURCES
3672 return d->setDisplaying(*e.d, t,
id, dt, showEdit, showDefer);
3675 #ifndef KALARMCAL_USE_KRESOURCES
3677 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3679 bool KAEventPrivate::setDisplaying(
const KAEventPrivate& event,
KAAlarm::Type alarmType,
const QString& resourceID,
3680 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3691 KAAlarm al =
event.alarm(alarmType);
3697 #ifndef KALARMCAL_USE_KRESOURCES
3699 mCollectionId = collectionId;
3701 mOriginalResourceId = resourceID;
3703 mDisplayingDefer = showDefer;
3704 mDisplayingEdit = showEdit;
3713 default: mDisplayingFlags = 0;
break;
3725 #ifndef KALARMCAL_USE_KRESOURCES
3731 d->reinstateFromDisplaying(e,
id, showEdit, showDefer);
3734 #ifndef KALARMCAL_USE_KRESOURCES
3737 void KAEventPrivate::reinstateFromDisplaying(
const Event* kcalEvent,
QString& resourceID,
bool& showEdit,
bool& showDefer)
3745 #ifndef KALARMCAL_USE_KRESOURCES
3746 collectionId = mCollectionId;
3749 resourceID = mOriginalResourceId;
3750 mOriginalResourceId.
clear();
3752 showDefer = mDisplayingDefer;
3753 showEdit = mDisplayingEdit;
3754 mDisplaying =
false;
3768 KAAlarm::Private*
const al_d = al.d;
3769 const int displayingFlags = d->mDisplayingFlags;
3772 al_d->mRepeatAtLogin =
true;
3775 else if (displayingFlags & KAEventPrivate::DEFERRAL)
3777 al_d->mDeferred =
true;
3778 al_d->mTimedDeferral = (displayingFlags & KAEventPrivate::TIMED_FLAG);
3781 else if (displayingFlags & KAEventPrivate::REMINDER)
3790 return d->mDisplaying;
3805 KAAlarm::Private*
const al_d = al.d;
3809 al_d->mRepeatAtLogin =
false;
3810 al_d->mDeferred =
false;
3817 al_d->mNextMainDateTime = mNextMainDateTime;
3818 al_d->mRepetition = mRepetition;
3819 al_d->mNextRepeat = mNextRepeat;
3823 if (mReminderActive == ACTIVE_REMINDER)
3826 if (mReminderMinutes < 0)
3827 al_d->mNextMainDateTime = mReminderAfterTime;
3828 else if (mReminderOnceOnly)
3829 al_d->mNextMainDateTime = mStartDateTime.addMins(-mReminderMinutes);
3831 al_d->mNextMainDateTime = mNextMainDateTime.addMins(-mReminderMinutes);
3835 if (mDeferral != REMINDER_DEFERRAL)
3839 if (mDeferral != NO_DEFERRAL)
3842 al_d->mNextMainDateTime = mDeferralTime;
3843 al_d->mDeferred =
true;
3844 al_d->mTimedDeferral = !mDeferralTime.isDateOnly();
3851 al_d->mNextMainDateTime = mAtLoginDateTime;
3852 al_d->mRepeatAtLogin =
true;
3859 al_d->mNextMainDateTime = mDisplayingTime;
3879 return d->firstAlarm();
3882 KAAlarm KAEventPrivate::firstAlarm()
const
3900 return d->nextAlarm(previousAlarm.
type());
3905 return d->nextAlarm(previousType);
3910 switch (previousType)
3913 if (mReminderActive == ACTIVE_REMINDER)
3918 if (mDeferral == REMINDER_DEFERRAL)
3920 if (mDeferral == NORMAL_DEFERRAL)
3943 return d->mAlarmCount;
3953 d->removeExpiredAlarm(type);
3958 const int count = mAlarmCount;
3962 if (!mReminderActive || mReminderMinutes > 0)
3969 mMainExpired =
true;
3971 set_deferral(NO_DEFERRAL);
3974 mDisplaying =
false;
3982 mArchiveRepeatAtLogin =
true;
3983 mRepeatAtLogin =
false;
3990 activate_reminder(
false);
3994 set_deferral(NO_DEFERRAL);
3999 mDisplaying =
false;
4007 if (mAlarmCount != count)
4008 mTriggerChanged =
true;
4025 void KAEventPrivate::endChanges()
4027 if (mChangeCount > 0)
4031 #ifndef KALARMCAL_USE_KRESOURCES
4038 for (
int i = 0, count = objList.
count(); i < count; ++i)
4039 ptrs += &objList[i];
4046 #ifndef KDE_NO_DEBUG_OUTPUT
4051 #ifndef KDE_NO_DEBUG_OUTPUT
4052 void KAEventPrivate::dumpDebug()
const
4054 kDebug() <<
"KAEvent dump:";
4055 #ifdef KALARMCAL_USE_KRESOURCES
4056 if (mResource) { kDebug() <<
"-- mResource:" << (
void*)mResource; }
4058 kDebug() <<
"-- mEventID:" << mEventID;
4060 kDebug() <<
"-- mNextMainDateTime:" << mNextMainDateTime.toString();
4061 kDebug() <<
"-- mCommandError:" << mCommandError;
4062 kDebug() <<
"-- mAllTrigger:" << mAllTrigger.toString();
4063 kDebug() <<
"-- mMainTrigger:" << mMainTrigger.toString();
4064 kDebug() <<
"-- mAllWorkTrigger:" << mAllWorkTrigger.toString();
4065 kDebug() <<
"-- mMainWorkTrigger:" << mMainWorkTrigger.toString();
4066 kDebug() <<
"-- mCategory:" << mCategory;
4067 if (!mTemplateName.isEmpty())
4069 kDebug() <<
"-- mTemplateName:" << mTemplateName;
4070 kDebug() <<
"-- mTemplateAfterTime:" << mTemplateAfterTime;
4072 kDebug() <<
"-- mText:" << mText;
4075 kDebug() <<
"-- mBgColour:" << mBgColour.name();
4076 kDebug() <<
"-- mFgColour:" << mFgColour.name();
4077 kDebug() <<
"-- mUseDefaultFont:" << mUseDefaultFont;
4078 if (!mUseDefaultFont)
4079 kDebug() <<
"-- mFont:" << mFont.toString();
4080 kDebug() <<
"-- mSpeak:" << mSpeak;
4081 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4082 kDebug() <<
"-- mPreAction:" << mPreAction;
4086 kDebug() <<
"-- mPostAction:" << mPostAction;
4087 kDebug() <<
"-- mLateCancel:" << mLateCancel;
4088 kDebug() <<
"-- mAutoClose:" << mAutoClose;
4092 kDebug() <<
"-- mCommandScript:" << mCommandScript;
4093 kDebug() <<
"-- mCommandXterm:" << mCommandXterm;
4094 kDebug() <<
"-- mCommandDisplay:" << mCommandDisplay;
4095 kDebug() <<
"-- mLogFile:" << mLogFile;
4099 kDebug() <<
"-- mEmail: FromKMail:" << mEmailFromIdentity;
4100 kDebug() <<
"-- Addresses:" << mEmailAddresses.join(
QLatin1String(
","));
4101 kDebug() <<
"-- Subject:" << mEmailSubject;
4102 kDebug() <<
"-- Attachments:" << mEmailAttachments.join(
QLatin1String(
","));
4103 kDebug() <<
"-- Bcc:" << mEmailBcc;
4106 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4107 kDebug() <<
"-- mBeep:" << mBeep;
4110 if (mSoundVolume >= 0)
4112 kDebug() <<
"-- mSoundVolume:" << mSoundVolume;
4113 if (mFadeVolume >= 0)
4115 kDebug() <<
"-- mFadeVolume:" << mFadeVolume;
4116 kDebug() <<
"-- mFadeSeconds:" << mFadeSeconds;
4119 kDebug() <<
"-- mFadeVolume:-:";
4122 kDebug() <<
"-- mSoundVolume:-:";
4123 kDebug() <<
"-- mRepeatSoundPause:" << mRepeatSoundPause;
4125 kDebug() <<
"-- mKMailSerialNumber:" << mKMailSerialNumber;
4126 kDebug() <<
"-- mCopyToKOrganizer:" << mCopyToKOrganizer;
4127 kDebug() <<
"-- mExcludeHolidays:" << (bool)mExcludeHolidays;
4128 kDebug() <<
"-- mWorkTimeOnly:" << mWorkTimeOnly;
4129 kDebug() <<
"-- mStartDateTime:" << mStartDateTime.toString();
4130 kDebug() <<
"-- mCreatedDateTime:" << mCreatedDateTime;
4131 kDebug() <<
"-- mRepeatAtLogin:" << mRepeatAtLogin;
4133 kDebug() <<
"-- mAtLoginDateTime:" << mAtLoginDateTime;
4134 kDebug() <<
"-- mArchiveRepeatAtLogin:" << mArchiveRepeatAtLogin;
4135 kDebug() <<
"-- mConfirmAck:" << mConfirmAck;
4136 kDebug() <<
"-- mEnabled:" << mEnabled;
4137 #ifndef KALARMCAL_USE_KRESOURCES
4138 kDebug() <<
"-- mItemId:" << mItemId;
4139 kDebug() <<
"-- mCollectionId:" << mCollectionId;
4140 kDebug() <<
"-- mCompatibility:" << mCompatibility;
4141 kDebug() <<
"-- mReadOnly:" << mReadOnly;
4143 if (mReminderMinutes)
4145 kDebug() <<
"-- mReminderMinutes:" << mReminderMinutes;
4146 kDebug() <<
"-- mReminderActive:" << (mReminderActive == ACTIVE_REMINDER ?
"active" : mReminderActive == HIDDEN_REMINDER ?
"hidden" :
"no");
4147 kDebug() <<
"-- mReminderOnceOnly:" << mReminderOnceOnly;
4149 else if (mDeferral > 0)
4151 kDebug() <<
"-- mDeferral:" << (mDeferral == NORMAL_DEFERRAL ?
"normal" :
"reminder");
4152 kDebug() <<
"-- mDeferralTime:" << mDeferralTime.toString();
4154 kDebug() <<
"-- mDeferDefaultMinutes:" << mDeferDefaultMinutes;
4155 if (mDeferDefaultMinutes)
4156 kDebug() <<
"-- mDeferDefaultDateOnly:" << mDeferDefaultDateOnly;
4159 kDebug() <<
"-- mDisplayingTime:" << mDisplayingTime.toString();
4160 kDebug() <<
"-- mDisplayingFlags:" << mDisplayingFlags;
4161 kDebug() <<
"-- mDisplayingDefer:" << mDisplayingDefer;
4162 kDebug() <<
"-- mDisplayingEdit:" << mDisplayingEdit;
4164 kDebug() <<
"-- mRevision:" << mRevision;
4165 kDebug() <<
"-- mRecurrence:" << mRecurrence;
4167 kDebug() <<
"-- mRepetition: 0";
4168 else if (mRepetition.isDaily())
4169 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalDays() <<
"days";
4171 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalMinutes() <<
"minutes";
4172 kDebug() <<
"-- mNextRepeat:" << mNextRepeat;
4173 kDebug() <<
"-- mAlarmCount:" << mAlarmCount;
4174 kDebug() <<
"-- mMainExpired:" << mMainExpired;
4175 kDebug() <<
"-- mDisplaying:" << mDisplaying;
4176 kDebug() <<
"KAEvent dump end";
4184 #ifndef KALARMCAL_USE_KRESOURCES
4185 DateTime KAEventPrivate::readDateTime(
const Event::Ptr& event,
bool dateOnly, DateTime& start)
4187 DateTime KAEventPrivate::readDateTime(
const Event* event,
bool dateOnly, DateTime& start)
4190 start =
event->dtStart();
4195 start.setDateOnly(
true);
4197 DateTime next = start;
4198 const int SZ_YEAR = 4;
4199 const int SZ_MONTH = 2;
4200 const int SZ_DAY = 2;
4201 const int SZ_DATE = SZ_YEAR + SZ_MONTH + SZ_DAY;
4202 const int IX_TIME = SZ_DATE + 1;
4203 const int SZ_HOUR = 2;
4204 const int SZ_MIN = 2;
4205 const int SZ_SEC = 2;
4206 const int SZ_TIME = SZ_HOUR + SZ_MIN + SZ_SEC;
4208 if (prop.
length() >= SZ_DATE)
4212 prop.
mid(SZ_YEAR, SZ_MONTH).
toInt(),
4213 prop.
mid(SZ_YEAR + SZ_MONTH, SZ_DAY).
toInt());
4216 if (dateOnly && prop.
length() == SZ_DATE)
4218 else if (!dateOnly && prop.
length() == IX_TIME + SZ_TIME && prop[SZ_DATE] ==
QLatin1Char(
'T'))
4220 const QTime t(prop.mid(IX_TIME, SZ_HOUR).toInt(),
4221 prop.mid(IX_TIME + SZ_HOUR, SZ_MIN).toInt(),
4222 prop.mid(IX_TIME + SZ_HOUR + SZ_MIN, SZ_SEC).toInt());
4240 #ifndef KALARMCAL_USE_KRESOURCES
4241 void KAEventPrivate::readAlarms(
const Event::Ptr& event, AlarmMap* alarmMap,
bool cmdDisplay)
4243 void KAEventPrivate::readAlarms(
const Event* event, AlarmMap* alarmMap,
bool cmdDisplay)
4249 bool audioOnly =
false;
4250 for (
int i = 0, end = alarms.
count(); i < end; ++i)
4252 switch (alarms[i]->type())
4254 case Alarm::Display:
4255 case Alarm::Procedure:
4267 for (
int i = 0, end = alarms.
count(); i < end; ++i)
4271 readAlarm(alarms[i], data, audioOnly, cmdDisplay);
4272 if (data.type != INVALID_ALARM)
4273 alarmMap->insert(data.type, data);
4282 #ifndef KALARMCAL_USE_KRESOURCES
4283 void KAEventPrivate::readAlarm(
const Alarm::Ptr& alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4285 void KAEventPrivate::readAlarm(
const Alarm* alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4290 data.displayingFlags = 0;
4291 data.isEmailText =
false;
4293 data.hiddenReminder =
false;
4294 data.timedDeferral =
false;
4295 data.nextRepeat = 0;
4296 data.repeatSoundPause = -1;
4301 int n =
static_cast<int>(
property.toUInt(&ok));
4303 data.nextRepeat = n;
4306 const QStringList flags =
property.
split(KAEventPrivate::SC, QString::SkipEmptyParts);
4307 switch (alarm->
type())
4309 case Alarm::Procedure:
4312 data.commandScript = data.cleanText.isEmpty();
4315 if (!data.commandScript)
4319 data.extraActionOptions = 0;
4320 if (flags.
contains(KAEventPrivate::EXEC_ON_DEFERRAL_FLAG))
4321 data.extraActionOptions |= KAEvent::ExecPreActOnDeferral;
4322 if (flags.
contains(KAEventPrivate::CANCEL_ON_ERROR_FLAG))
4323 data.extraActionOptions |= KAEvent::CancelOnPreActError;
4324 if (flags.
contains(KAEventPrivate::DONT_SHOW_ERROR_FLAG))
4325 data.extraActionOptions |= KAEvent::DontShowPreActError;
4329 case Alarm::Display:
4331 if (alarm->
type() == Alarm::Display)
4338 data.bgColour =
QColor(255, 255, 255);
4339 data.fgColour =
QColor(0, 0, 0);
4340 const int n = list.
count();
4343 if (!list[0].isEmpty())
4349 if (n > 1 && !list[1].isEmpty())
4356 data.defaultFont = (n <= 2 || list[2].
isEmpty());
4357 if (!data.defaultFont)
4358 data.font.fromString(list[2]);
4364 data.cleanText = alarm->
mailText();
4365 const int i = flags.
indexOf(KAEventPrivate::EMAIL_ID_FLAG);
4366 data.emailFromId = (i >= 0 && i + 1 < flags.
count()) ? flags[i + 1].toUInt() : 0;
4375 data.soundVolume = -1;
4376 data.fadeVolume = -1;
4377 data.fadeSeconds = 0;
4379 if (!property.isEmpty())
4385 data.soundVolume = list[0].toFloat(&ok);
4386 if (!ok || data.soundVolume > 1.0f)
4387 data.soundVolume = -1;
4388 if (data.soundVolume >= 0 && list.
count() >= 3)
4390 fadeVolume = list[1].toFloat(&ok);
4392 fadeSecs =
static_cast<int>(list[2].toUInt(&ok));
4393 if (ok && fadeVolume >= 0 && fadeVolume <= 1.0f && fadeSecs > 0)
4395 data.fadeVolume = fadeVolume;
4396 data.fadeSeconds = fadeSecs;
4402 data.type = AUDIO_ALARM;
4403 data.speak = flags.
contains(KAEventPrivate::SPEAK_FLAG);
4408 case Alarm::Invalid:
4409 data.type = INVALID_ALARM;
4413 bool atLogin =
false;
4414 bool reminder =
false;
4415 bool deferral =
false;
4416 bool dateDeferral =
false;
4417 bool repeatSound =
false;
4418 data.type = MAIN_ALARM;
4421 for (
int i = 0, end = types.
count(); i < end; ++i)
4423 const QString type = types[i];
4424 if (type == KAEventPrivate::AT_LOGIN_TYPE)
4426 else if (type == KAEventPrivate::FILE_TYPE && data.action ==
KAAlarm::MESSAGE)
4428 else if (type == KAEventPrivate::REMINDER_TYPE)
4430 else if (type == KAEventPrivate::TIME_DEFERRAL_TYPE)
4432 else if (type == KAEventPrivate::DATE_DEFERRAL_TYPE)
4433 dateDeferral = deferral =
true;
4434 else if (type == KAEventPrivate::DISPLAYING_TYPE)
4435 data.type = DISPLAYING_ALARM;
4436 else if (type == KAEventPrivate::PRE_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4437 data.type = PRE_ACTION_ALARM;
4438 else if (type == KAEventPrivate::POST_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4439 data.type = POST_ACTION_ALARM;
4440 else if (type == KAEventPrivate::SOUND_REPEAT_TYPE && data.action ==
KAAlarm::AUDIO)
4446 uint n = types[i + 1].toUInt(&ok);
4449 data.repeatSoundPause = n;
4455 if (repeatSound && data.repeatSoundPause < 0)
4456 data.repeatSoundPause = 0;
4457 else if (!repeatSound)
4458 data.repeatSoundPause = -1;
4462 if (data.type == MAIN_ALARM)
4464 data.type = deferral ? DEFERRED_REMINDER_ALARM : REMINDER_ALARM;
4465 data.timedDeferral = (deferral && !dateDeferral);
4467 else if (data.type == DISPLAYING_ALARM)
4468 data.displayingFlags = dateDeferral ? REMINDER | DATE_DEFERRAL
4469 : deferral ? REMINDER | TIME_DEFERRAL : REMINDER;
4470 else if (data.type == REMINDER_ALARM
4471 && flags.
contains(KAEventPrivate::HIDDEN_REMINDER_FLAG))
4472 data.hiddenReminder =
true;
4476 if (data.type == MAIN_ALARM)
4478 data.type = DEFERRED_ALARM;
4479 data.timedDeferral = !dateDeferral;
4481 else if (data.type == DISPLAYING_ALARM)
4482 data.displayingFlags = dateDeferral ? DATE_DEFERRAL : TIME_DEFERRAL;
4486 if (data.type == MAIN_ALARM)
4487 data.type = AT_LOGIN_ALARM;
4488 else if (data.type == DISPLAYING_ALARM)
4505 void KAEventPrivate::calcTriggerTimes()
const
4510 #warning May need to set date-only alarms to after start-of-day time in working-time checks
4513 if ((recurs && mWorkTimeOnly && mWorkTimeOnly != mWorkTimeIndex)
4514 || (recurs && mExcludeHolidays && mExcludeHolidays != mHolidays))
4518 mTriggerChanged =
true;
4520 else if (!mTriggerChanged)
4522 mTriggerChanged =
false;
4523 if (recurs && mWorkTimeOnly)
4524 mWorkTimeOnly = mWorkTimeIndex;
4525 if (recurs && mExcludeHolidays)
4526 mExcludeHolidays = mHolidays;
4531 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = KDateTime();
4533 else if (mDeferral == NORMAL_DEFERRAL)
4536 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = mDeferralTime;
4540 mMainTrigger = mainDateTime(
true);
4541 mAllTrigger = (mDeferral == REMINDER_DEFERRAL) ? mDeferralTime
4542 : (mReminderActive != ACTIVE_REMINDER) ? mMainTrigger
4543 : (mReminderMinutes < 0) ? mReminderAfterTime
4544 : mMainTrigger.addMins(-mReminderMinutes);
4548 if ((!mWorkTimeOnly && !mExcludeHolidays)
4550 || isWorkingTime(mMainTrigger.kDateTime()))
4554 mMainWorkTrigger = mMainTrigger;
4555 mAllWorkTrigger = mAllTrigger;
4557 else if (mWorkTimeOnly)
4563 if (!mExcludeHolidays)
4566 calcNextWorkingTime(mMainTrigger);
4571 DateTime nextTrigger = mMainTrigger;
4573 for (
int i = 0; i < 20; ++i)
4575 calcNextWorkingTime(nextTrigger);
4576 if (!mHolidays->isHoliday(mMainWorkTrigger.date()))
4578 kdt = mMainWorkTrigger.effectiveKDateTime();
4579 kdt.setTime(
QTime(23,59,59));
4581 if (!nextTrigger.isValid())
4583 if (isWorkingTime(nextTrigger.kDateTime()))
4585 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4586 mMainWorkTrigger = nextTrigger;
4591 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4594 else if (mExcludeHolidays && mHolidays)
4597 DateTime nextTrigger = mMainTrigger;
4599 for (
int i = 0; i < 20; ++i)
4601 kdt = nextTrigger.effectiveKDateTime();
4602 kdt.setTime(
QTime(23,59,59));
4604 if (!nextTrigger.isValid())
4606 if (!mHolidays->isHoliday(nextTrigger.date()))
4608 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4609 mMainWorkTrigger = nextTrigger;
4614 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4625 void KAEventPrivate::calcNextWorkingTime(
const DateTime& nextTrigger)
const
4627 kDebug() <<
"next=" << nextTrigger.kDateTime().dateTime();
4628 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4630 for (
int i = 0; ; ++i)
4634 if (mWorkDays.testBit(i))
4638 KDateTime kdt = nextTrigger.effectiveKDateTime();
4639 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4644 unsigned allDaysMask = 0x7F;
4645 bool noWorkPos =
false;
4647 const int nDayPos = pos.
count();
4652 for (
int i = 0; i < nDayPos; ++i)
4654 const int day = pos[i].day() - 1;
4655 if (mWorkDays.testBit(day))
4657 allDaysMask |= 1 << day;
4659 if (noWorkPos && !mRepetition)
4664 if (mStartDateTime.isDateOnly())
4668 const int repeatFreq = mRepetition.intervalDays();
4669 const bool weeklyRepeat = mRepetition && !(repeatFreq % 7);
4670 const Duration interval = mRecurrence->regularInterval();
4671 if ((interval && !(interval.
asDays() % 7))
4675 if (!mRepetition || weeklyRepeat)
4681 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4682 dt.setTime(
QTime(0,0,0));
4683 previousOccurrence(dt, newdt,
false);
4684 if (!newdt.isValid())
4686 kdt = newdt.effectiveKDateTime();
4687 const int day = kdt.date().dayOfWeek() - 1;
4688 for (
int repeatNum = mNextRepeat + 1; ; ++repeatNum)
4690 if (repeatNum > mRepetition.count())
4692 if (repeatNum == mNextRepeat)
4697 if (mWorkDays.testBit(day))
4699 mMainWorkTrigger = newdt;
4700 mAllWorkTrigger = mMainWorkTrigger.addMins(-reminder);
4703 kdt = newdt.effectiveKDateTime();
4707 const int inc = repeatFreq * repeatNum;
4708 if (mWorkDays.testBit((day + inc) % 7))
4710 kdt = kdt.addDays(inc);
4711 kdt.setDateOnly(
true);
4712 mMainWorkTrigger = mAllWorkTrigger = kdt;
4719 if (!mRepetition || weeklyRepeat)
4727 kdt.setTime(
QTime(23,59,59));
4729 if (!newdt.isValid())
4731 kdt = newdt.effectiveKDateTime();
4732 const int day = kdt.date().dayOfWeek() - 1;
4733 if (mWorkDays.testBit(day))
4736 if ((days & allDaysMask) == allDaysMask)
4740 kdt.setDateOnly(
true);
4741 mMainWorkTrigger = kdt;
4742 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4749 unsigned days = 1 << (kdt.date().dayOfWeek() - 1);
4750 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4751 dt.setTime(
QTime(0,0,0));
4752 previousOccurrence(dt, newdt,
false);
4753 if (!newdt.isValid())
4755 kdt = newdt.effectiveKDateTime();
4756 int day = kdt.date().dayOfWeek() - 1;
4757 for (
int repeatNum = mNextRepeat; ; repeatNum = 0)
4759 while (++repeatNum <= mRepetition.count())
4761 const int inc = repeatFreq * repeatNum;
4762 if (mWorkDays.testBit((day + inc) % 7))
4764 kdt = kdt.addDays(inc);
4765 kdt.setDateOnly(
true);
4766 mMainWorkTrigger = mAllWorkTrigger = kdt;
4769 if ((days & allDaysMask) == allDaysMask)
4774 if (!newdt.isValid())
4776 kdt = newdt.effectiveKDateTime();
4777 day = kdt.date().dayOfWeek() - 1;
4778 if (mWorkDays.testBit(day))
4780 kdt.setDateOnly(
true);
4781 mMainWorkTrigger = kdt;
4782 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4785 if ((days & allDaysMask) == allDaysMask)
4803 const bool repeatTimeVaries = (mRepetition && !mRepetition.isDaily());
4805 if (!recurTimeVaries && !repeatTimeVaries)
4809 if (!mayOccurDailyDuringWork(kdt))
4813 bool repetition =
false;
4818 if (!newdt.isValid())
4821 kdt = newdt.effectiveKDateTime();
4822 const int day = kdt.date().dayOfWeek() - 1;
4823 if (mWorkDays.testBit(day))
4828 if ((days & allDaysMask) == allDaysMask)
4833 mMainWorkTrigger = nextTrigger;
4834 mMainWorkTrigger.setDate(kdt.date());
4835 mAllWorkTrigger = repetition ? mMainWorkTrigger : mMainWorkTrigger.addMins(-reminder);
4842 KTimeZone tz = kdt.timeZone();
4843 if (tz.isValid() && tz.type() ==
"KSystemTimeZone")
4846 const KTimeZone ktz = KSystemTimeZones::readZone(tz.name());
4852 if (recurTimeVaries)
4871 repeatFreq = mRepetition.intervalSeconds();
4872 previousOccurrence(kdt.addSecs(1), newdt,
false);
4873 if (!newdt.isValid())
4875 kdtRecur = newdt.effectiveKDateTime();
4876 repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4877 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
4891 QTime firstTime = kdtRecur.time();
4892 int firstOffset = kdtRecur.utcOffset();
4893 int currentOffset = firstOffset;
4894 int dayRecur = kdtRecur.date().dayOfWeek() - 1;
4895 int firstDay = dayRecur;
4897 const bool subdaily = (repeatFreq < 24*3600);
4900 int transitionIndex = -1;
4901 for (
int n = 0; n < 7*24*60; ++n)
4909 const int inc = subdaily ? nextWorkRepetition(kdt) : 1;
4911 if (repeatNum > mRepetition.count())
4913 kdt = kdt.addSecs(inc * repeatFreq);
4914 const QTime t = kdt.time();
4915 if (t >= mWorkDayStart && t < mWorkDayEnd)
4917 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
4919 mMainWorkTrigger = mAllWorkTrigger = kdt;
4927 if (!newdt.isValid())
4929 kdtRecur = newdt.effectiveKDateTime();
4930 dayRecur = kdtRecur.date().dayOfWeek() - 1;
4931 const QTime t = kdtRecur.time();
4932 if (t >= mWorkDayStart && t < mWorkDayEnd)
4934 if (mWorkDays.testBit(dayRecur))
4936 mMainWorkTrigger = kdtRecur;
4937 mAllWorkTrigger = kdtRecur.
addSecs(-60 * reminder);
4941 if (kdtRecur.utcOffset() != currentOffset)
4942 currentOffset = kdtRecur.utcOffset();
4943 if (t == firstTime && dayRecur == firstDay && currentOffset == firstOffset)
4950 finalDate = kdtRecur.date();
4951 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
4954 if (i > transitionIndex)
4955 transitionIndex = i;
4956 if (++transitionIndex >= static_cast<int>(tzTransitions.
count()))
4959 kdtRecur = newdt.effectiveKDateTime();
4960 if (finalDate.
daysTo(kdtRecur.date()) > 365)
4962 firstTime = kdtRecur.time();
4963 firstOffset = kdtRecur.utcOffset();
4964 currentOffset = firstOffset;
4965 firstDay = kdtRecur.date().dayOfWeek() - 1;
4973 if (repeatTimeVaries)
4982 const int repeatFreq = mRepetition.intervalSeconds();
4983 previousOccurrence(kdt.addSecs(1), newdt,
false);
4984 if (!newdt.isValid())
4986 KDateTime kdtRecur = newdt.effectiveKDateTime();
4987 const bool recurDuringWork = (kdtRecur.time() >= mWorkDayStart && kdtRecur.time() < mWorkDayEnd);
4991 const bool subdaily = (repeatFreq < 24*3600);
4993 bool checkTimeChangeOnly =
false;
4994 int transitionIndex = -1;
4995 for (
int limit = 10; --limit >= 0; )
4999 QDate dateRecur = kdtRecur.date();
5000 int dayRecur = dateRecur.
dayOfWeek() - 1;
5001 int repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
5002 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
5010 KDateTime kdtNextRecur = newdt.effectiveKDateTime();
5012 int repeatsToCheck = mRepetition.count();
5013 int repeatsDuringWork = 0;
5017 if (repeatsDuringWork >= 0)
5022 int inc = subdaily ? nextWorkRepetition(kdt) : 1;
5024 const bool pastEnd = (repeatNum > mRepetition.count());
5026 inc -= repeatNum - mRepetition.count();
5027 repeatsToCheck -= inc;
5028 kdt = kdt.addSecs(inc * repeatFreq);
5029 if (kdtNextRecur.isValid() && kdt >= kdtNextRecur)
5033 repeatsToCheck = mRepetition.count();
5038 const QTime t = kdt.time();
5039 if (t >= mWorkDayStart && t < mWorkDayEnd)
5041 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
5043 mMainWorkTrigger = mAllWorkTrigger = kdt;
5046 repeatsDuringWork = 1;
5048 else if (!repeatsDuringWork && repeatsToCheck <= 0)
5051 repeatsDuringWork = -1;
5057 if (repeatsDuringWork < 0 && !recurDuringWork)
5061 if (!kdtNextRecur.isValid())
5063 if (checkTimeChangeOnly || (days & allDaysMask) == allDaysMask)
5065 kdtRecur = kdtNextRecur;
5067 kdtNextRecur = newdt.effectiveKDateTime();
5068 dateRecur = kdtRecur.date();
5070 if (recurDuringWork && mWorkDays.testBit(dayRecur))
5072 mMainWorkTrigger = kdtRecur;
5073 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
5076 days |= 1 << dayRecur;
5082 checkTimeChangeOnly =
true;
5083 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
5086 if (i > transitionIndex)
5087 transitionIndex = i;
5088 if (++transitionIndex >= static_cast<int>(tzTransitions.
count()))
5090 kdt = KDateTime(tzTransitions[transitionIndex].time(), KDateTime::UTC);
5092 kdtRecur = newdt.effectiveKDateTime();
5103 int KAEventPrivate::nextWorkRepetition(
const KDateTime& pre)
const
5105 KDateTime nextWork(pre);
5106 if (pre.time() < mWorkDayStart)
5107 nextWork.setTime(mWorkDayStart);
5110 const int preDay = pre.date().dayOfWeek() - 1;
5111 for (
int n = 1; ; ++n)
5114 return mRepetition.count() + 1;
5115 if (mWorkDays.testBit((preDay + n) % 7))
5117 nextWork = nextWork.addDays(n);
5118 nextWork.setTime(mWorkDayStart);
5123 return (pre.secsTo(nextWork) - 1) / mRepetition.intervalSeconds() + 1;
5133 bool KAEventPrivate::mayOccurDailyDuringWork(
const KDateTime& kdt)
const
5135 if (!kdt.isDateOnly()
5136 && (kdt.time() < mWorkDayStart || kdt.time() >= mWorkDayEnd))
5139 const Duration interval = mRecurrence->regularInterval();
5140 if (interval && interval.
isDaily() && !(interval.
asDays() % 7))
5143 if (!mRepetition || (mRepetition.isDaily() && !(mRepetition.intervalDays() % 7)))
5147 int day = mRecurrence->startDateTime().date().dayOfWeek() - 1;
5148 const int repeatDays = mRepetition.intervalDays();
5149 const int maxRepeat = (mRepetition.count() < 6) ? mRepetition.count() : 6;
5150 for (
int i = 0; !mWorkDays.testBit(day); ++i, day = (day + repeatDays) % 7)
5162 #ifndef KALARMCAL_USE_KRESOURCES
5163 void KAEventPrivate::setAudioAlarm(
const Alarm::Ptr& alarm)
const
5165 void KAEventPrivate::setAudioAlarm(
Alarm* alarm)
const
5169 if (mSoundVolume >= 0)
5173 .arg(mFadeSeconds));
5181 KAEvent::OccurType KAEventPrivate::nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const
5183 const KDateTime recurStart = mRecurrence->startDateTime();
5184 KDateTime pre = preDateTime.toTimeSpec(mStartDateTime.timeSpec());
5187 pre = pre.addDays(-1);
5190 const KDateTime dt = mRecurrence->getNextDateTime(pre);
5192 result.setDateOnly(mStartDateTime.isDateOnly());
5195 if (dt == recurStart)
5197 if (mRecurrence->duration() >= 0 && dt == mRecurrence->endDateTime())
5224 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5229 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5239 #ifndef KALARMCAL_USE_KRESOURCES
5281 static const QByteArray KMAIL_ID_PROPERTY(
"KMAILID");
5284 static const QByteArray ARCHIVE_PROPERTY(
"ARCHIVE");
5287 static const QByteArray EMAIL_ID_PROPERTY(
"EMAILID");
5288 static const QByteArray SPEAK_PROPERTY(
"SPEAK");
5289 static const QByteArray CANCEL_ON_ERROR_PROPERTY(
"ERRCANCEL");
5290 static const QByteArray DONT_SHOW_ERROR_PROPERTY(
"ERRNOSHOW");
5292 bool adjustSummerTime =
false;
5293 if (calendarVersion == -Version(0,5,7))
5297 calendarVersion = -calendarVersion;
5298 adjustSummerTime =
true;
5301 if (calendarVersion >= currentCalendarVersion())
5304 kDebug() <<
"Adjusting version" << calendarVersion;
5305 const bool pre_0_7 = (calendarVersion < Version(0,7,0));
5306 const bool pre_0_9 = (calendarVersion < Version(0,9,0));
5307 const bool pre_0_9_2 = (calendarVersion < Version(0,9,2));
5308 const bool pre_1_1_1 = (calendarVersion < Version(1,1,1));
5309 const bool pre_1_2_1 = (calendarVersion < Version(1,2,1));
5310 const bool pre_1_3_0 = (calendarVersion < Version(1,3,0));
5311 const bool pre_1_3_1 = (calendarVersion < Version(1,3,1));
5312 const bool pre_1_4_14 = (calendarVersion < Version(1,4,14));
5313 const bool pre_1_5_0 = (calendarVersion < Version(1,5,0));
5314 const bool pre_1_9_0 = (calendarVersion < Version(1,9,0));
5315 const bool pre_1_9_2 = (calendarVersion < Version(1,9,2));
5316 const bool pre_1_9_7 = (calendarVersion < Version(1,9,7));
5317 const bool pre_1_9_9 = (calendarVersion < Version(1,9,9));
5318 const bool pre_1_9_10 = (calendarVersion < Version(1,9,10));
5319 const bool pre_2_2_9 = (calendarVersion < Version(2,2,9));
5320 const bool pre_2_3_0 = (calendarVersion < Version(2,3,0));
5321 const bool pre_2_3_2 = (calendarVersion < Version(2,3,2));
5322 const bool pre_2_7_0 = (calendarVersion < Version(2,7,0));
5323 Q_ASSERT(currentCalendarVersion() == Version(2,7,0));
5325 KTimeZone localZone;
5327 localZone = KSystemTimeZones::local();
5329 bool converted =
false;
5330 #ifndef KALARMCAL_USE_KRESOURCES
5335 for (
int ei = 0, eend = events.
count(); ei < eend; ++ei)
5337 #ifndef KALARMCAL_USE_KRESOURCES
5340 Event*
event = events[ei];
5345 event->startUpdates();
5346 const bool readOnly =
event->isReadOnly();
5348 event->setReadOnly(
false);
5350 bool addLateCancel =
false;
5353 if (pre_0_7 && event->
allDay())
5357 event->setAllDay(
false);
5374 for (
int ai = 0, aend = alarms.
count(); ai < aend; ++ai)
5376 #ifndef KALARMCAL_USE_KRESOURCES
5379 Alarm* alarm = alarms[ai];
5381 bool atLogin =
false;
5382 bool deferral =
false;
5383 bool lateCancel =
false;
5386 const int length = txt.
length();
5388 if (txt[0].isDigit())
5390 while (++i < length && txt[i].isDigit()) ;
5391 if (i < length && txt[i++] == SEPARATOR)
5395 const QChar ch = txt[i++];
5396 if (ch == SEPARATOR)
5398 if (ch == LATE_CANCEL_CODE)
5400 else if (ch == AT_LOGIN_CODE)
5402 else if (ch == DEFERRAL_CODE)
5409 if (txt.
indexOf(TEXT_PREFIX, i) == i)
5410 i += TEXT_PREFIX.
length();
5411 else if (txt.
indexOf(FILE_PREFIX, i) == i)
5414 i += FILE_PREFIX.
length();
5416 else if (txt.
indexOf(COMMAND_PREFIX, i) == i)
5419 i += COMMAND_PREFIX.
length();
5429 types += KAEventPrivate::FILE_TYPE;
5435 setProcedureAlarm(alarm, altxt);
5443 types += KAEventPrivate::AT_LOGIN_TYPE;
5447 types += KAEventPrivate::TIME_DEFERRAL_TYPE;
5449 addLateCancel =
true;
5450 if (types.
count() > 0)
5458 if (recur && recur->
recurs())
5467 if (adjustSummerTime)
5471 KDateTime dt = alarm->
time();
5472 const time_t t = dt.toTime_t();
5473 const struct tm* dtm = localtime(&t);
5476 dt = dt.addSecs(-3600);
5496 event->setCreated(event->
dtEnd());
5497 KDateTime start =
event->dtStart();
5500 event->setAllDay(
false);
5501 start.setTime(
QTime(0, 0));
5502 flags += KAEventPrivate::DATE_ONLY_FLAG;
5504 event->setDtEnd(KDateTime());
5506 for (
int ai = 0, aend = alarms.
count(); ai < aend; ++ai)
5508 #ifndef KALARMCAL_USE_KRESOURCES
5511 Alarm* alarm = alarms[ai];
5518 for (
int ai = 0, aend = alarms.
count(); ai < aend; ++ai)
5520 #ifndef KALARMCAL_USE_KRESOURCES
5523 Alarm* alarm = alarms[ai];
5525 if (alarm->
type() == Alarm::Display)
5532 for (
int i = 0, end = cats.
count(); i < end; ++i)
5534 if (cats.
at(i) == BEEP_CATEGORY)
5538 #ifndef KALARMCAL_USE_KRESOURCES
5541 Alarm* alarm =
event->newAlarm();
5545 KDateTime dt =
event->dtStart();
5549 KAEventPrivate::readAlarms(event, &alarmMap);
5553 dt = it.value().alarm->time();
5569 while ((i = cats.
indexOf(LATE_CANCEL_CAT)) >= 0)
5572 addLateCancel =
true;
5582 for (
int ai = 0, aend = alarms.
count(); ai < aend; ++ai)
5584 #ifndef KALARMCAL_USE_KRESOURCES
5587 Alarm* alarm = alarms[ai];
5589 if (alarm->
type() == Alarm::Display)
5593 if (oldtext != newtext)
5606 while ((i = cats.
indexOf(TEMPL_DEF_TIME_CAT)) >= 0)
5609 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) +=
QLatin1String(
"0");
5620 while ((i = cats.
indexOf(EXEC_IN_XTERM_CAT)) >= 0)
5623 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, KAEventPrivate::xtermURL);
5634 CalEvent::setStatus(event, CalEvent::status(event));
5635 for (
int i = 0; i < cats.
count(); )
5638 if (cat == DATE_ONLY_CATEGORY)
5639 flags += KAEventPrivate::DATE_ONLY_FLAG;
5640 else if (cat == CONFIRM_ACK_CATEGORY)
5641 flags += KAEventPrivate::CONFIRM_ACK_FLAG;
5642 else if (cat == EMAIL_BCC_CATEGORY)
5643 flags += KAEventPrivate::EMAIL_BCC_FLAG;
5644 else if (cat == KORGANIZER_CATEGORY)
5645 flags += KAEventPrivate::KORGANIZER_FLAG;
5647 (flags += KAEventPrivate::DEFER_FLAG) += cat.
mid(DEFER_CATEGORY.
length());
5648 else if (cat.
startsWith(TEMPL_AFTER_TIME_CATEGORY))
5649 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += cat.
mid(TEMPL_AFTER_TIME_CATEGORY.
length());
5650 else if (cat.
startsWith(LATE_CANCEL_CATEGORY))
5651 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += cat.
mid(LATE_CANCEL_CATEGORY.
length());
5652 else if (cat.
startsWith(AUTO_CLOSE_CATEGORY))
5653 (flags += KAEventPrivate::AUTO_CLOSE_FLAG) += cat.
mid(AUTO_CLOSE_CATEGORY.
length());
5654 else if (cat.
startsWith(KMAIL_SERNUM_CATEGORY))
5655 (flags += KAEventPrivate::KMAIL_SERNUM_FLAG) += cat.
mid(KMAIL_SERNUM_CATEGORY.
length());
5656 else if (cat == ARCHIVE_CATEGORY)
5677 event->shiftTimes(KDateTime::ClockTime, localZone);
5682 (flags += KAEventPrivate::LATE_CANCEL_FLAG) +=
QLatin1String(
"1");
5684 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.
join(KAEventPrivate::SC));
5687 if ((pre_1_4_14 || (pre_1_9_7 && !pre_1_9_0))
5698 const bool dateOnly = flags.
contains(KAEventPrivate::DATE_ONLY_FLAG);
5699 KDateTime startDateTime =
event->dtStart();
5701 startDateTime.setDateOnly(
true);
5703 KDateTime nextMainDateTime;
5704 bool mainExpired =
true;
5705 for (
int i = 0, alend = alarms.
count(); i < alend; ++i)
5707 #ifndef KALARMCAL_USE_KRESOURCES
5710 Alarm* alarm = alarms[i];
5721 bool mainAlarm =
true;
5724 for (
int t = 0; t < types.
count(); ++t)
5727 if (type == KAEventPrivate::AT_LOGIN_TYPE
5728 || type == KAEventPrivate::TIME_DEFERRAL_TYPE
5729 || type == KAEventPrivate::DATE_DEFERRAL_TYPE
5730 || type == KAEventPrivate::REMINDER_TYPE
5731 || type == REMINDER_ONCE_TYPE)
5743 mainExpired =
false;
5744 nextMainDateTime = alarm->
time();
5745 nextMainDateTime.setDateOnly(dateOnly);
5746 nextMainDateTime = nextMainDateTime.toTimeSpec(startDateTime);
5747 if (nextMainDateTime != startDateTime)
5749 QDateTime dt = nextMainDateTime.dateTime();
5764 KDateTime dt =
event->recurrence()->getNextDateTime(startDateTime.addDays(-1));
5765 dt.setDateOnly(dateOnly);
5766 adjustment = startDateTime.secsTo(dt);
5769 adjustment = startDateTime.secsTo(nextMainDateTime);
5773 for (
int i = 0, alend = alarms.
count(); i < alend; ++i)
5775 #ifndef KALARMCAL_USE_KRESOURCES
5778 Alarm* alarm = alarms[i];
5784 for (
int t = 0; t < types.
count(); ++t)
5786 const QString type = types[t];
5787 if (type == KAEventPrivate::TIME_DEFERRAL_TYPE
5788 || type == KAEventPrivate::DATE_DEFERRAL_TYPE)
5799 if (pre_1_5_0 || (pre_1_9_9 && !pre_1_9_0))
5805 for (
int i = 0, alend = alarms.
count(); i < alend; ++i)
5807 #ifndef KALARMCAL_USE_KRESOURCES
5810 Alarm* alarm = alarms[i];
5829 if (KAEventPrivate::convertRepetition(event))
5833 if (pre_2_2_9 || (pre_2_3_2 && !pre_2_3_0))
5839 if (KAEventPrivate::convertStartOfDay(event))
5853 bool flagsValid =
false;
5856 bool reminderOnce =
false;
5861 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).
split(KAEventPrivate::SC, QString::SkipEmptyParts);
5862 flags << KAEventPrivate::ARCHIVE_FLAG;
5868 const QStringList list = prop.
split(KAEventPrivate::SC, QString::SkipEmptyParts);
5869 for (
int i = 0; i < list.
count(); ++i)
5871 if (list[i] == KAEventPrivate::AT_LOGIN_TYPE)
5872 flags << KAEventPrivate::AT_LOGIN_TYPE;
5873 else if (list[i] == ARCHIVE_REMINDER_ONCE_TYPE)
5874 reminderOnce =
true;
5879 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.
join(KAEventPrivate::SC));
5883 for (
int i = 0, alend = alarms.
count(); i < alend; ++i)
5885 #ifndef KALARMCAL_USE_KRESOURCES
5888 Alarm* alarm = alarms[i];
5893 if (!property.isEmpty())
5895 flags << KAEventPrivate::EMAIL_ID_FLAG << property;
5900 flags << KAEventPrivate::SPEAK_FLAG;
5905 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
5910 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
5921 const int r = types.
indexOf(REMINDER_ONCE_TYPE);
5925 types[r] = KAEventPrivate::REMINDER_TYPE;
5927 reminderOnce =
true;
5929 if (r >= 0 || types.
contains(KAEventPrivate::REMINDER_TYPE))
5938 else if (offset < 0)
5939 reminder = reminderToString(offset / 60);
5946 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).
split(KAEventPrivate::SC, QString::SkipEmptyParts);
5947 if (flags.
indexOf(KAEventPrivate::REMINDER_TYPE) < 0)
5949 flags += KAEventPrivate::REMINDER_TYPE;
5951 flags += KAEventPrivate::REMINDER_ONCE_FLAG;
5958 event->setReadOnly(
true);
5959 event->endUpdates();
5968 #ifndef KALARMCAL_USE_KRESOURCES
5969 bool KAEventPrivate::convertStartOfDay(
const Event::Ptr& event)
5971 bool KAEventPrivate::convertStartOfDay(
Event* event)
5974 bool changed =
false;
5975 const QTime midnight(0, 0);
5977 if (flags.
indexOf(KAEventPrivate::DATE_ONLY_FLAG) >= 0)
5980 const KDateTime oldDt =
event->dtStart();
5981 const int adjustment = oldDt.time().secsTo(midnight);
5984 event->setDtStart(KDateTime(oldDt.date(), midnight, oldDt.timeSpec()));
5985 int deferralOffset = 0;
5987 readAlarms(event, &alarmMap);
5988 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
5990 const AlarmData& data = it.value();
5991 if (!data.alarm->hasStartOffset())
5993 if (data.timedDeferral)
5996 deferralOffset = data.alarm->startOffset().asSeconds();
5997 #ifndef KALARMCAL_USE_KRESOURCES
5998 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
6000 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
6003 else if (data.type == AUDIO_ALARM
6004 && data.alarm->startOffset().asSeconds() == deferralOffset)
6007 #ifndef KALARMCAL_USE_KRESOURCES
6008 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
6010 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
6020 bool foundDeferral =
false;
6021 int deferralOffset = 0;
6022 int newDeferralOffset = 0;
6024 const KDateTime nextMainDateTime = readDateTime(event,
false, start).kDateTime();
6026 readAlarms(event, &alarmMap);
6027 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
6029 const AlarmData& data = it.value();
6030 if (!data.alarm->hasStartOffset())
6032 if ((data.type & DEFERRED_ALARM) && !data.timedDeferral)
6035 KDateTime altime = data.alarm->startOffset().end(nextMainDateTime);
6036 altime.setTime(midnight);
6037 deferralOffset = data.alarm->startOffset().asSeconds();
6038 newDeferralOffset =
event->dtStart().secsTo(altime);
6039 #ifndef KALARMCAL_USE_KRESOURCES
6040 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6042 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6044 foundDeferral =
true;
6047 else if (foundDeferral
6048 && data.type == AUDIO_ALARM
6049 && data.alarm->startOffset().asSeconds() == deferralOffset)
6052 #ifndef KALARMCAL_USE_KRESOURCES
6053 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6055 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6072 #ifndef KALARMCAL_USE_KRESOURCES
6073 bool KAEventPrivate::convertRepetition(
const Event::Ptr& event)
6075 bool KAEventPrivate::convertRepetition(
Event* event)
6084 bool converted =
false;
6085 const bool readOnly =
event->isReadOnly();
6086 for (
int ai = 0, aend = alarms.
count(); ai < aend; ++ai)
6088 #ifndef KALARMCAL_USE_KRESOURCES
6091 Alarm* alarm = alarms[ai];
6097 event->startUpdates();
6099 event->setReadOnly(
false);
6114 event->setReadOnly(
true);
6115 event->endUpdates();
6130 KAAlarm::Private::Private()
6131 : mType(INVALID_ALARM),
6133 mRepeatAtLogin(false),
6139 : d(new Private(*other.d))
6157 return d->mActionType;
6172 return (withRepeats && d->mNextRepeat && d->mRepetition)
6173 ? d->mRepetition.duration(d->mNextRepeat).end(d->mNextMainDateTime.kDateTime())
6174 : d->mNextMainDateTime;
6179 return d->mNextMainDateTime.date();
6184 return d->mNextMainDateTime.effectiveTime();
6189 return d->mRepeatAtLogin;
6199 return d->mDeferred;
6204 return d->mDeferred && d->mTimedDeferral;
6209 d->mNextMainDateTime = dt;
6214 d->mNextMainDateTime = dt;
6217 #ifdef KDE_NO_DEBUG_OUTPUT
6230 default:
return "INVALID";
6243 #ifndef KALARMCAL_USE_KRESOURCES
6244 EmailAddressList& EmailAddressList::operator=(
const Person::List& addresses)
6246 EmailAddressList& EmailAddressList::operator=(
const QList<Person>& addresses)
6250 for (
int p = 0, end = addresses.
count(); p < end; ++p)
6252 #ifndef KALARMCAL_USE_KRESOURCES
6253 if (!addresses[p]->email().
isEmpty())
6255 if (!addresses[p].email().
isEmpty())
6257 append(addresses[p]);
6268 for (
int p = 0, end = count(); p < end; ++p)
6281 for (
int p = 0, end = count(); p < end; ++p)
6286 result += separator;
6287 result += address(p);
6295 QString EmailAddressList::address(
int index)
const
6297 if (index < 0 || index > count())
6301 #ifndef KALARMCAL_USE_KRESOURCES
6303 const QString name = person->name();
6305 const Person person = (*this)[index];
6311 for (
int i = 0, len = name.
length(); i < len; ++i)
6313 const QChar ch = name[i];
6321 #ifndef KALARMCAL_USE_KRESOURCES
6322 result += (*this)[index]->name();
6324 result += (*this)[index].name();
6326 result += (quote ?
QLatin1String(
"\" <") : QLatin1String(
" <"));
6330 #ifndef KALARMCAL_USE_KRESOURCES
6331 result += person->
email();
6333 result += person.
email();
6343 QStringList EmailAddressList::pureAddresses()
const
6346 for (
int p = 0, end = count(); p < end; ++p)
6347 #ifndef KALARMCAL_USE_KRESOURCES
6348 list += at(p)->email();
6350 list += at(p).email();
6358 QString EmailAddressList::pureAddresses(
const QString& separator)
const
6362 for (
int p = 0, end = count(); p < end; ++p)
6367 result += separator;
6368 #ifndef KALARMCAL_USE_KRESOURCES
6369 result += at(p)->email();
6371 result += at(p).email();
6386 #ifndef KALARMCAL_USE_KRESOURCES
6387 static void setProcedureAlarm(
const Alarm::Ptr& alarm,
const QString& commandLine)
6389 static void setProcedureAlarm(
Alarm* alarm,
const QString& commandLine)
6395 bool quoted =
false;
6396 const uint posMax = commandLine.
length();
6398 for (pos = 0; pos < posMax; ++pos)
6400 const QChar ch = commandLine[pos];
6403 if (ch == quoteChar)
6442 for ( ; pos < posMax && commandLine[pos] ==
QLatin1Char(
' '); ++pos) ;
6443 arguments = commandLine.
mid(pos);
6452 QString reminderToString(
int minutes)
6455 int count = abs(minutes);
6456 if (count % 1440 == 0)
6461 else if (count % 60 == 0)
void setEnabled(bool enable)
the alarm displays something
void cancelDefer()
Cancel any deferral alarm which is pending.
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
int daysTo(const QDate &d) const
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)
QString toString(Qt::DateFormat format) const
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.
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
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.
void truncate(int position)
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.
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)
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
void setDuration(int duration)
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)
const_iterator constBegin() const
blind copy the email to the user
const T & at(int i) const
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
bool contains(const QString &str, Qt::CaseSensitivity cs) 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.
QString join(const QString &separator) const
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.
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.
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.
const QByteArray APPNAME("KALARM")
The application name ("KALARM") used in calendar properties.
QString templateName() const
Return the alarm template's name.
QString number(int n, int base)
Represents recurrences for KAlarm.
int count(const T &value) const
static QString toCalendarText(const QString &text)
Return the text for an alarm message text, in alarm calendar format.
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
int toInt(bool *ok, int base) 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)
const_iterator constEnd() const
pre-alarm command execution failed
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const
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.
QTime addSecs(int s) const
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
bool endsWith(const QString &s, Qt::CaseSensitivity cs) const
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).
bool startsWith(const T &value) const
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
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.
bool setDate(int year, int month, int day)
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
QString mid(int position, int n) const
void setMinutely(int freq)
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.
int secsTo(const QDateTime &other) const
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...
QString & sprintf(const char *cformat,...)
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.
const QChar at(int position) const
QString recurrenceText(bool brief=false) const
Return the recurrence interval as text suitable for display.
QDateTime toTimeSpec(Qt::TimeSpec specification) const
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.
int count(const T &value) const
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.
QStringList split(const QString &sep, const QString &str, bool allowEmptyEntries)
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.
QString left(int n) const
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.
QString fromLatin1(const char *str, int size)
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
int indexOf(const QRegExp &rx, int from) const
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.
QDate addDays(int ndays) const
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
bool testBit(int i) const
QString displayMessage() const
Return the message text for a display alarm.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
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.
bool isLetterOrNumber() const
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
uint toUInt(bool *ok, int base) const
KOrganizer should hold a copy of the event.
bool reminderDeferral() const
Return whether there is currently a deferred reminder alarm pending.