26#include "identities.h"
29#ifndef KALARMCAL_USE_KRESOURCES
32#include <kcal/calendarlocal.h>
34#include <kholidays/holidays.h>
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
59#ifndef KALARMCAL_USE_KRESOURCES
63typedef KCal::Person EmailAddress;
64class EmailAddressList :
public QList<KCal::Person>
68#ifndef KALARMCAL_USE_KRESOURCES
73 EmailAddressList() : QList<KCal::
Person>() { }
74 EmailAddressList(
const QList<KCal::Person>& list) { operator=(list); }
75 EmailAddressList& operator=(
const QList<KCal::Person>&);
77 operator QStringList()
const;
78 QString join(
const QString& separator)
const;
79 QStringList pureAddresses()
const;
80 QString pureAddresses(
const QString& separator)
const;
82 QString address(
int index)
const;
94 DateTime mNextMainDateTime;
95 Repetition mRepetition;
105class KAEventPrivate :
public QSharedData
115 TIMED_FLAG = 0x400000,
116 DATE_DEFERRAL = DEFERRAL,
117 TIME_DEFERRAL = DEFERRAL | TIMED_FLAG,
118 DISPLAYING_ = 0x800000,
119 READ_ONLY_FLAGS = 0xF00000
140 REMINDER_ALARM = 0x02,
141 DEFERRED_ALARM = 0x04,
142 DEFERRED_REMINDER_ALARM = REMINDER_ALARM | DEFERRED_ALARM,
145 AT_LOGIN_ALARM = 0x10,
146 DISPLAYING_ALARM = 0x20,
149 PRE_ACTION_ALARM = 0x40,
150 POST_ACTION_ALARM = 0x50
155#ifndef KALARMCAL_USE_KRESOURCES
162 QColor bgColour, fgColour;
166 int repeatSoundPause;
169 KAEventPrivate::AlarmType type;
172 KAEvent::ExtraActionOptions extraActionOptions;
180 typedef QMap<AlarmType, AlarmData> AlarmMap;
183 KAEventPrivate(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
185 bool changesPending =
false);
186#ifndef KALARMCAL_USE_KRESOURCES
189 explicit KAEventPrivate(
const KCal::Event*);
191 KAEventPrivate(
const KAEventPrivate&);
192 ~KAEventPrivate() {
delete mRecurrence; }
193 KAEventPrivate& operator=(
const KAEventPrivate& e) {
if (&e !=
this) copy(e);
return *
this; }
194#ifndef KALARMCAL_USE_KRESOURCES
197 void set(
const KCal::Event*);
199 void set(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
201 bool changesPending =
false);
202 void setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile);
204 void setFirstRecurrence();
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
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);
221 void startChanges() { ++mChangeCount; }
225 KAAlarm firstAlarm()
const;
227#ifndef KALARMCAL_USE_KRESOURCES
232 DateTime mainDateTime(
bool withRepeats =
false)
const
233 {
return (withRepeats && mNextRepeat && mRepetition)
235 DateTime mainEndRepeatTime()
const
236 {
return mRepetition ? mRepetition.
duration().
end(mNextMainDateTime.
kDateTime()) : mNextMainDateTime; }
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;
243 KAEvent::OccurType previousOccurrence(
const KDateTime& afterDateTime, DateTime& result,
bool includeRepetitions =
false)
const;
244 void setRecurrence(
const KARecurrence&);
245#ifndef KALARMCAL_USE_KRESOURCES
254 void calcTriggerTimes()
const;
255#ifdef KDE_NO_DEBUG_OUTPUT
256 void dumpDebug()
const { }
258 void dumpDebug()
const;
260#ifndef KALARMCAL_USE_KRESOURCES
265 static void readAlarm(
const KCalCore::Alarm::Ptr&, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
267 static bool convertRepetition(KCal::Event*);
268 static bool convertStartOfDay(KCal::Event*);
269 static DateTime readDateTime(
const KCal::Event*,
bool dateOnly, DateTime& start);
270 static void readAlarms(
const KCal::Event*, AlarmMap*,
bool cmdDisplay =
false);
271 static void readAlarm(
const KCal::Alarm*, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
275 void copy(
const KAEventPrivate&);
276 bool mayOccurDailyDuringWork(
const KDateTime&)
const;
277 int nextWorkRepetition(
const KDateTime& pre)
const;
278 void calcNextWorkingTime(
const DateTime& nextTrigger)
const;
279 DateTime nextWorkingTime()
const;
280 KAEvent::OccurType nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const;
281#ifndef KALARMCAL_USE_KRESOURCES
286 void setAudioAlarm(KCal::Alarm*)
const;
287 KCal::Alarm* initKCalAlarm(KCal::Event*,
const DateTime&,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
288 KCal::Alarm* initKCalAlarm(KCal::Event*,
int startOffsetSecs,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
290 inline void set_deferral(DeferType);
291 inline void activate_reminder(
bool activate);
294#ifdef KALARMCAL_USE_KRESOURCES
295 static QString mCmdErrConfigGroup;
297 static QFont mDefaultFont;
298 static const KHolidays::HolidayRegion* mHolidays;
299 static QBitArray mWorkDays;
300 static QTime mWorkDayStart;
301 static QTime mWorkDayEnd;
302 static int mWorkTimeIndex;
303#ifdef KALARMCAL_USE_KRESOURCES
304 AlarmResource* mResource;
306 mutable DateTime mAllTrigger;
307 mutable DateTime mMainTrigger;
308 mutable DateTime mAllWorkTrigger;
309 mutable DateTime mMainWorkTrigger;
313 QString mTemplateName;
314#ifndef KALARMCAL_USE_KRESOURCES
315 QMap<QByteArray, QString> mCustomProperties;
316 Akonadi::Item::Id mItemId;
320 QString mOriginalResourceId;
326 DateTime mStartDateTime;
327 KDateTime mCreatedDateTime;
328 DateTime mNextMainDateTime;
329 KDateTime mAtLoginDateTime;
330 DateTime mDeferralTime;
331 DateTime mDisplayingTime;
332 int mDisplayingFlags;
333 int mReminderMinutes;
334 DateTime mReminderAfterTime;
335 ReminderType mReminderActive;
336 int mDeferDefaultMinutes;
337 bool mDeferDefaultDateOnly;
339 KARecurrence* mRecurrence;
340 Repetition mRepetition;
344 unsigned long mKMailSerialNumber;
345 int mTemplateAfterTime;
349 uint mEmailFromIdentity;
350 EmailAddressList mEmailAddresses;
351 QString mEmailSubject;
352 QStringList mEmailAttachments;
353 mutable int mChangeCount;
354 mutable bool mTriggerChanged;
359 int mRepeatSoundPause;
361 mutable const KHolidays::HolidayRegion*
363 mutable int mWorkTimeOnly;
366 KAEvent::ExtraActionOptions mExtraActionOptions;
367#ifndef KALARMCAL_USE_KRESOURCES
368 KACalendar::Compat mCompatibility;
372 bool mUseDefaultFont;
375 bool mCommandDisplay;
379 bool mCopyToKOrganizer;
380 bool mReminderOnceOnly;
384 bool mArchiveRepeatAtLogin;
387 bool mDisplayingDefer;
388 bool mDisplayingEdit;
392 static const QByteArray FLAGS_PROPERTY;
393 static const QString DATE_ONLY_FLAG;
394 static const QString EMAIL_BCC_FLAG;
395 static const QString CONFIRM_ACK_FLAG;
396 static const QString KORGANIZER_FLAG;
397 static const QString EXCLUDE_HOLIDAYS_FLAG;
398 static const QString WORK_TIME_ONLY_FLAG;
399 static const QString REMINDER_ONCE_FLAG;
400 static const QString DEFER_FLAG;
401 static const QString LATE_CANCEL_FLAG;
402 static const QString AUTO_CLOSE_FLAG;
403 static const QString TEMPL_AFTER_TIME_FLAG;
404 static const QString KMAIL_SERNUM_FLAG;
405 static const QString ARCHIVE_FLAG;
406 static const QByteArray NEXT_RECUR_PROPERTY;
407 static const QByteArray REPEAT_PROPERTY;
408 static const QByteArray LOG_PROPERTY;
409 static const QString xtermURL;
410 static const QString displayURL;
411 static const QByteArray TYPE_PROPERTY;
412 static const QString FILE_TYPE;
413 static const QString AT_LOGIN_TYPE;
414 static const QString REMINDER_TYPE;
415 static const QString REMINDER_ONCE_TYPE;
416 static const QString TIME_DEFERRAL_TYPE;
417 static const QString DATE_DEFERRAL_TYPE;
418 static const QString DISPLAYING_TYPE;
419 static const QString PRE_ACTION_TYPE;
420 static const QString POST_ACTION_TYPE;
421 static const QString SOUND_REPEAT_TYPE;
422 static const QByteArray NEXT_REPEAT_PROPERTY;
423 static const QString HIDDEN_REMINDER_FLAG;
424 static const QByteArray FONT_COLOUR_PROPERTY;
425 static const QByteArray VOLUME_PROPERTY;
426 static const QString EMAIL_ID_FLAG;
427 static const QString SPEAK_FLAG;
428 static const QString EXEC_ON_DEFERRAL_FLAG;
429 static const QString CANCEL_ON_ERROR_FLAG;
430 static const QString DONT_SHOW_ERROR_FLAG;
431 static const QString DISABLED_STATUS;
432 static const QString DISP_DEFER;
433 static const QString DISP_EDIT;
434 static const QString CMD_ERROR_VALUE;
435 static const QString CMD_ERROR_PRE_VALUE;
436 static const QString CMD_ERROR_POST_VALUE;
437 static const QString SC;
452const QByteArray KAEventPrivate::FLAGS_PROPERTY(
"FLAGS");
453const QString KAEventPrivate::DATE_ONLY_FLAG = QLatin1String(
"DATE");
454const QString KAEventPrivate::EMAIL_BCC_FLAG = QLatin1String(
"BCC");
455const QString KAEventPrivate::CONFIRM_ACK_FLAG = QLatin1String(
"ACKCONF");
456const QString KAEventPrivate::KORGANIZER_FLAG = QLatin1String(
"KORG");
457const QString KAEventPrivate::EXCLUDE_HOLIDAYS_FLAG = QLatin1String(
"EXHOLIDAYS");
458const QString KAEventPrivate::WORK_TIME_ONLY_FLAG = QLatin1String(
"WORKTIME");
459const QString KAEventPrivate::REMINDER_ONCE_FLAG = QLatin1String(
"ONCE");
460const QString KAEventPrivate::DEFER_FLAG = QLatin1String(
"DEFER");
461const QString KAEventPrivate::LATE_CANCEL_FLAG = QLatin1String(
"LATECANCEL");
462const QString KAEventPrivate::AUTO_CLOSE_FLAG = QLatin1String(
"LATECLOSE");
463const QString KAEventPrivate::TEMPL_AFTER_TIME_FLAG = QLatin1String(
"TMPLAFTTIME");
464const QString KAEventPrivate::KMAIL_SERNUM_FLAG = QLatin1String(
"KMAIL");
465const QString KAEventPrivate::ARCHIVE_FLAG = QLatin1String(
"ARCHIVE");
467const QByteArray KAEventPrivate::NEXT_RECUR_PROPERTY(
"NEXTRECUR");
468const QByteArray KAEventPrivate::REPEAT_PROPERTY(
"REPEAT");
469const QByteArray KAEventPrivate::LOG_PROPERTY(
"LOG");
470const QString KAEventPrivate::xtermURL = QLatin1String(
"xterm:");
471const QString KAEventPrivate::displayURL = QLatin1String(
"display:");
474const QByteArray KAEventPrivate::TYPE_PROPERTY(
"TYPE");
475const QString KAEventPrivate::FILE_TYPE = QLatin1String(
"FILE");
476const QString KAEventPrivate::AT_LOGIN_TYPE = QLatin1String(
"LOGIN");
477const QString KAEventPrivate::REMINDER_TYPE = QLatin1String(
"REMINDER");
478const QString KAEventPrivate::TIME_DEFERRAL_TYPE = QLatin1String(
"DEFERRAL");
479const QString KAEventPrivate::DATE_DEFERRAL_TYPE = QLatin1String(
"DATE_DEFERRAL");
480const QString KAEventPrivate::DISPLAYING_TYPE = QLatin1String(
"DISPLAYING");
481const QString KAEventPrivate::PRE_ACTION_TYPE = QLatin1String(
"PRE");
482const QString KAEventPrivate::POST_ACTION_TYPE = QLatin1String(
"POST");
483const QString KAEventPrivate::SOUND_REPEAT_TYPE = QLatin1String(
"SOUNDREPEAT");
484const QByteArray KAEventPrivate::NEXT_REPEAT_PROPERTY(
"NEXTREPEAT");
485const QString KAEventPrivate::HIDDEN_REMINDER_FLAG = QLatin1String(
"HIDE");
487const QByteArray KAEventPrivate::FONT_COLOUR_PROPERTY(
"FONTCOLOR");
489const QString KAEventPrivate::EMAIL_ID_FLAG = QLatin1String(
"EMAILID");
491const QByteArray KAEventPrivate::VOLUME_PROPERTY(
"VOLUME");
492const QString KAEventPrivate::SPEAK_FLAG = QLatin1String(
"SPEAK");
494const QString KAEventPrivate::EXEC_ON_DEFERRAL_FLAG = QLatin1String(
"EXECDEFER");
495const QString KAEventPrivate::CANCEL_ON_ERROR_FLAG = QLatin1String(
"ERRCANCEL");
496const QString KAEventPrivate::DONT_SHOW_ERROR_FLAG = QLatin1String(
"ERRNOSHOW");
499const QString KAEventPrivate::DISABLED_STATUS = QLatin1String(
"DISABLED");
502const QString KAEventPrivate::DISP_DEFER = QLatin1String(
"DEFER");
503const QString KAEventPrivate::DISP_EDIT = QLatin1String(
"EDIT");
506#ifdef KALARMCAL_USE_KRESOURCES
507QString KAEventPrivate::mCmdErrConfigGroup = QLatin1String(
"CommandErrors");
509const QString KAEventPrivate::CMD_ERROR_VALUE = QLatin1String(
"MAIN");
510const QString KAEventPrivate::CMD_ERROR_PRE_VALUE = QLatin1String(
"PRE");
511const QString KAEventPrivate::CMD_ERROR_POST_VALUE = QLatin1String(
"POST");
513const QString KAEventPrivate::SC = QLatin1String(
";");
515QFont KAEventPrivate::mDefaultFont;
516const KHolidays::HolidayRegion* KAEventPrivate::mHolidays = 0;
517QBitArray KAEventPrivate::mWorkDays(7);
518QTime KAEventPrivate::mWorkDayStart(9, 0, 0);
519QTime KAEventPrivate::mWorkDayEnd(17, 0, 0);
520int KAEventPrivate::mWorkTimeIndex = 1;
522#ifndef KALARMCAL_USE_KRESOURCES
523static void setProcedureAlarm(
const Alarm::Ptr&,
const QString& commandLine);
525static void setProcedureAlarm(
Alarm*,
const QString& commandLine);
527static QString reminderToString(
int minutes);
534inline void KAEventPrivate::set_deferral(DeferType type)
538 if (mDeferral == NO_DEFERRAL)
543 if (mDeferral != NO_DEFERRAL)
549inline 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();
565K_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<KAEventPrivate>,
566 emptyKAEventPrivate, (
new KAEventPrivate))
569 : d(*emptyKAEventPrivate)
572KAEventPrivate::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),
607KAEvent::KAEvent(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
608 SubAction action,
int lateCancel, Flags flags,
bool changesPending)
609 : d(new KAEventPrivate(dt, message, bg, fg, f, action, lateCancel, flags, changesPending))
613KAEventPrivate::KAEventPrivate(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
621#ifndef KALARMCAL_USE_KRESOURCES
626 : d(
new KAEventPrivate(e))
630#ifndef KALARMCAL_USE_KRESOURCES
631KAEventPrivate::KAEventPrivate(
const Event::Ptr& e)
633KAEventPrivate::KAEventPrivate(
const Event* e)
640KAEventPrivate::KAEventPrivate(
const KAEventPrivate& e)
654KAEvent& KAEvent::operator=(
const KAEvent& other)
664void 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
769void KAEventPrivate::set(
const Event::Ptr& event)
771void KAEventPrivate::set(
const Event* event)
777#ifdef KALARMCAL_USE_KRESOURCES
780 mEventID =
event->uid();
781 mRevision =
event->revision();
782 mTemplateName.clear();
784#ifndef KALARMCAL_USE_KRESOURCES
788 mOriginalResourceId.clear();
790 mTemplateAfterTime = -1;
794 mCommandXterm =
false;
795 mCommandDisplay =
false;
796 mCopyToKOrganizer =
false;
799 mReminderOnceOnly =
false;
801 mArchiveRepeatAtLogin =
false;
802 mDisplayingDefer =
false;
803 mDisplayingEdit =
false;
804 mDeferDefaultDateOnly =
false;
805 mReminderActive = NO_REMINDER;
806 mReminderMinutes = 0;
807 mDeferDefaultMinutes = 0;
809 mKMailSerialNumber = 0;
810 mExcludeHolidays = 0;
813 mBgColour = QColor(255, 255, 255);
814 mFgColour = QColor(0, 0, 0);
815#ifndef KALARMCAL_USE_KRESOURCES
817 mReadOnly =
event->isReadOnly();
819 mUseDefaultFont =
true;
824 mCategory = CalEvent::status(event, ¶m);
828 const QStringList params = param.split(SC, QString::KeepEmptyParts);
829 int n = params.count();
832#ifndef KALARMCAL_USE_KRESOURCES
833 const qlonglong
id = params[0].toLongLong(&ok);
837 mOriginalResourceId = params[0];
839 for (
int i = 1; i < n; ++i)
841 if (params[i] == DISP_DEFER)
842 mDisplayingDefer =
true;
843 if (params[i] == DISP_EDIT)
844 mDisplayingEdit =
true;
848#ifndef KALARMCAL_USE_KRESOURCES
851 mCustomProperties =
event->customProperties();
852 for (QMap<QByteArray, QString>::Iterator it = mCustomProperties.begin(); it != mCustomProperties.end(); )
854 if (it.key().startsWith(kalarmKey))
855 it = mCustomProperties.erase(it);
861 bool dateOnly =
false;
862 QStringList flags =
event->customProperty(
KACalendar::APPNAME, FLAGS_PROPERTY).split(SC, QString::SkipEmptyParts);
863 flags << QString() << QString();
864 for (
int i = 0, end = flags.count() - 1; i < end; ++i)
866 QString flag = flags.at(i);
867 if (flag == DATE_ONLY_FLAG)
869 else if (flag == CONFIRM_ACK_FLAG)
871 else if (flag == EMAIL_BCC_FLAG)
873 else if (flag == KORGANIZER_FLAG)
874 mCopyToKOrganizer =
true;
875 else if (flag == EXCLUDE_HOLIDAYS_FLAG)
876 mExcludeHolidays = mHolidays;
877 else if (flag == WORK_TIME_ONLY_FLAG)
879 else if (flag == KMAIL_SERNUM_FLAG)
881 const unsigned long n = flags.at(i + 1).toULong(&ok);
884 mKMailSerialNumber = n;
887 else if (flag == KAEventPrivate::ARCHIVE_FLAG)
889 else if (flag == KAEventPrivate::AT_LOGIN_TYPE)
890 mArchiveRepeatAtLogin =
true;
891 else if (flag == KAEventPrivate::REMINDER_TYPE)
893 flag = flags.at(++i);
894 if (flag == KAEventPrivate::REMINDER_ONCE_FLAG)
896 mReminderOnceOnly =
true;
899 const int len = flag.length() - 1;
900 mReminderMinutes = -flag.left(len).toInt();
901 switch (flag.at(len).toLatin1())
904 case 'H': mReminderMinutes *= 60;
break;
905 case 'D': mReminderMinutes *= 1440;
break;
906 default: mReminderMinutes = 0;
break;
909 else if (flag == DEFER_FLAG)
911 QString mins = flags.at(i + 1);
912 if (mins.endsWith(QLatin1Char(
'D')))
914 mDeferDefaultDateOnly =
true;
915 mins.truncate(mins.length() - 1);
917 const int n =
static_cast<int>(mins.toUInt(&ok));
920 mDeferDefaultMinutes = n;
923 else if (flag == TEMPL_AFTER_TIME_FLAG)
925 const int n =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
928 mTemplateAfterTime = n;
931 else if (flag == LATE_CANCEL_FLAG)
933 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
936 if (!ok || !mLateCancel)
939 else if (flag == AUTO_CLOSE_FLAG)
941 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
944 if (!ok || !mLateCancel)
953 if (prop == xtermURL)
954 mCommandXterm =
true;
955 else if (prop == displayURL)
956 mCommandDisplay =
true;
964 const QStringList list = prop.split(QLatin1Char(
':'));
965 if (list.count() >= 2)
967 const int interval =
static_cast<int>(list[0].toUInt());
968 const int count =
static_cast<int>(list[1].toUInt());
969 if (interval && count)
971 if (interval % (24*60))
978 mNextMainDateTime = readDateTime(event, dateOnly, mStartDateTime);
979 mCreatedDateTime =
event->created();
980 if (dateOnly && !mRepetition.isDaily())
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;
1236void KAEvent::set(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
1237 const QFont& f,
SubAction act,
int lateCancel, Flags flags,
bool changesPending)
1245void 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();
1280 mAudioFile = (mActionSubType ==
KAEvent::AUDIO) ? text : QString();
1283 mTemplateAfterTime = -1;
1289 mLateCancel = lateCancel;
1290 mDeferral = NO_DEFERRAL;
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);
1388#ifndef KALARMCAL_USE_KRESOURCES
1389 if (setCustomProperties)
1390 ev->setCustomProperties(mCustomProperties);
1400#ifndef KALARMCAL_USE_KRESOURCES
1401 param = QString::number(mCollectionId);
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)
1439 QString param = QString::number(mDeferDefaultMinutes);
1440 if (mDeferDefaultDateOnly)
1441 param += QLatin1Char(
'D');
1442 (flags += DEFER_FLAG) += param;
1444 if (!mTemplateName.isEmpty() && mTemplateAfterTime >= 0)
1445 (flags += TEMPL_AFTER_TIME_FLAG) += QString::number(mTemplateAfterTime);
1446 if (mKMailSerialNumber)
1447 (flags += KMAIL_SERNUM_FLAG) += QString::number(mKMailSerialNumber);
1448 if (mArchive && !archived)
1450 flags += ARCHIVE_FLAG;
1451 if (mArchiveRepeatAtLogin)
1452 flags += AT_LOGIN_TYPE;
1454 if (!flags.isEmpty())
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();
1499 dt.toString(mNextMainDateTime.isDateOnly() ? QLatin1String(
"yyyyMMdd") : QLatin1String(
"yyyyMMddThhmmss")));
1502 initKCalAlarm(ev, 0, QStringList(), MAIN_ALARM);
1503 ancillaryOffset = 0;
1504 ancillaryType = dtMain.isValid() ? 2 : 0;
1506 else if (mRepetition)
1510 const QString param = QString::fromLatin1(
"%1:%2").arg(mRepetition.intervalMinutes()).arg(mRepetition.count());
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)
1601 QStringList list(DISPLAYING_TYPE);
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
1664Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1666Alarm* 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
1675Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1677Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1680 QStringList alltypes;
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);
1726 QString::number(mNextRepeat));
1728 case REMINDER_ALARM:
1731 if (types == QStringList(REMINDER_TYPE)
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)
1766 alltypes += QString::number(mRepeatSoundPause);
1772 QString::fromLatin1(
"%1;%2;%3").arg(mBgColour.name())
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:
1784 if (!alltypes.isEmpty())
1786 if (!flags.isEmpty())
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;
1843KAEvent::Flags KAEventPrivate::flags()
const
1845 KAEvent::Flags result(0);
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;
1976void KAEvent::setResource(AlarmResource* r)
1981AlarmResource* 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;
2029void KAEvent::setKMailSerialNumber(
unsigned long n)
2031 d->mKMailSerialNumber = n;
2034unsigned long KAEvent::kmailSerialNumber()
const
2036 return d->mKMailSerialNumber;
2046 return (d->mActionSubType ==
MESSAGE
2047 || d->mActionSubType ==
EMAIL) ? d->mText : QString();
2052 return (d->mActionSubType ==
MESSAGE) ? d->mText : QString();
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;
2087 return (d->mActionSubType ==
COMMAND) ? d->mText : QString();
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);
2160void KAEventPrivate::setCommandError(
const QString& configString)
2163 const QStringList errs = configString.split(
',');
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)
2175QString KAEvent::commandErrorConfigGroup()
2177 return KAEventPrivate::mCmdErrConfigGroup;
2183 return d->mCommandError;
2188 d->mLogFile = logfile;
2189 if (!logfile.isEmpty())
2190 d->mCommandDisplay = d->mCommandXterm =
false;
2200 return d->mConfirmAck;
2205 return d->mCopyToKOrganizer;
2208#ifndef KALARMCAL_USE_KRESOURCES
2210 const QStringList& attachments)
2212void KAEvent::setEmail(uint from,
const QList<KCal::Person>& addresses,
const QString& subject,
2213 const QStringList& attachments)
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;
2290void KAEvent::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2295void 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);
2436void 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);
2463void 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);
2527void 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)
2648 mTriggerChanged =
true;
2661void 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)
2726 endTime = mNextMainDateTime;
2730 else if (mReminderMinutes > 0
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);
2845void KAEventPrivate::setRepeatAtLogin(
bool rl)
2847 if (rl && !mRepeatAtLogin)
2849 setRepeatAtLoginTrue(
true);
2852 else if (!rl && mRepeatAtLogin)
2854 mRepeatAtLogin = rl;
2855 mTriggerChanged =
true;
2861void 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);
2921bool 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;
2957void KAEventPrivate::clearRecur()
2959 if (mRecurrence || mRepetition)
2963 mRepetition.
set(0, 0);
2964 mTriggerChanged =
true;
2978void KAEventPrivate::setRecurrence(
const KARecurrence& recurrence)
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)
3033 if (days.testBit(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();
3250void KAEventPrivate::setFirstRecurrence()
3252 switch (checkRecur())
3269 if (mRecurrence->
recursOn(recurStart.date(), recurStart.timeSpec()))
3273 const int frequency = mRecurrence->
frequency();
3277 if (!next.isValid())
3281 mRecurrence->
setStartDateTime(next.effectiveKDateTime(), next.isDateOnly());
3282 mStartDateTime = mNextMainDateTime = next;
3283 mTriggerChanged =
true;
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);
3337bool KAEventPrivate::setRepetition(
const Repetition& repetition)
3342 if (repetition && !mRepeatAtLogin)
3347 mRepetition.
set(0, 0);
3351 if (repetition.
duration() >= longestInterval)
3353 const int count = mStartDateTime.
isDateOnly()
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);
3415bool KAEventPrivate::occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const
3428 QDate pre = preDateTime.date();
3430 pre = pre.addDays(-1);
3431 if (pre < dt.date())
3434 else if (preDateTime < dt)
3437 if (includeRepetitions && mRepetition)
3455 return d->setNextOccurrence(preDateTime);
3462 KDateTime pre = preDateTime;
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)
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;
3547 type = nextRecurrence(pre, result);
3550 result = mNextMainDateTime;
3555 result = DateTime();
3571 const KAEvent::OccurType newType = previousOccurrence(repeatDT.effectiveKDateTime(), dt,
false);
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;
3628 KDateTime after = afterDateTime.toTimeSpec(mStartDateTime.
timeSpec());
3630 after = after.addDays(1);
3636 if (dt == recurStart)
3644 if (includeRepetitions && mRepetition)
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)
3679bool 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
3737void 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();
3882KAAlarm 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;
4025void 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
4052void 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
4185DateTime KAEventPrivate::readDateTime(
const Event::Ptr& event,
bool dateOnly, DateTime& start)
4187DateTime 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;
4207 const QString prop =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::NEXT_RECUR_PROPERTY);
4208 if (prop.length() >= SZ_DATE)
4211 const QDate d(prop.left(SZ_YEAR).toInt(),
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
4241void KAEventPrivate::readAlarms(
const Event::Ptr& event, AlarmMap* alarmMap,
bool cmdDisplay)
4243void 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())
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
4283void KAEventPrivate::readAlarm(
const Alarm::Ptr& alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4285void 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())
4312 data.commandScript = data.cleanText.isEmpty();
4315 if (!data.commandScript)
4316 data.cleanText += QLatin1Char(
' ');
4319 data.extraActionOptions = 0;
4320 if (flags.contains(KAEventPrivate::EXEC_ON_DEFERRAL_FLAG))
4322 if (flags.contains(KAEventPrivate::CANCEL_ON_ERROR_FLAG))
4324 if (flags.contains(KAEventPrivate::DONT_SHOW_ERROR_FLAG))
4337 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
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())
4384 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
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);
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;
4420 const QStringList
types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
4421 for (
int i = 0, end =
types.count(); i < end; ++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)
4505void 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()))
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();
4625void 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;
4646 const QList<RecurrenceRule::WDayPos> pos = rrule->byDays();
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)
4669 const bool weeklyRepeat = mRepetition && !(repeatFreq % 7);
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());
4850 const QList<KTimeZone::Transition> tzTransitions = tz.transitions();
4852 if (recurTimeVaries)
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)
4949 if (!finalDate.isValid())
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)
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();
5069 dayRecur = dateRecur.dayOfWeek() - 1;
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();
5103int 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;
5133bool KAEventPrivate::mayOccurDailyDuringWork(
const KDateTime& kdt)
const
5135 if (!kdt.isDateOnly()
5136 && (kdt.time() < mWorkDayStart || kdt.time() >= mWorkDayEnd))
5140 if (interval && interval.
isDaily() && !(interval.
asDays() % 7))
5147 int day = mRecurrence->
startDateTime().date().dayOfWeek() - 1;
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
5163void KAEventPrivate::setAudioAlarm(
const Alarm::Ptr& alarm)
const
5165void KAEventPrivate::setAudioAlarm(
Alarm* alarm)
const
5169 if (mSoundVolume >= 0)
5171 QString::fromLatin1(
"%1;%2;%3;%4").arg(QString::number(mSoundVolume,
'f', 2))
5172 .arg(QString::number(mFadeVolume,
'f', 2))
5173 .arg(mFadeSeconds));
5181KAEvent::OccurType KAEventPrivate::nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const
5184 KDateTime pre = preDateTime.toTimeSpec(mStartDateTime.
timeSpec());
5187 pre = pre.addDays(-1);
5192 result.setDateOnly(mStartDateTime.
isDateOnly());
5195 if (dt == recurStart)
5224 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5229 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5239#ifndef KALARMCAL_USE_KRESOURCES
5246 static const QChar SEPARATOR = QLatin1Char(
';');
5247 static const QChar LATE_CANCEL_CODE = QLatin1Char(
'C');
5248 static const QChar AT_LOGIN_CODE = QLatin1Char(
'L');
5249 static const QChar DEFERRAL_CODE = QLatin1Char(
'D');
5250 static const QString TEXT_PREFIX = QLatin1String(
"TEXT:");
5251 static const QString FILE_PREFIX = QLatin1String(
"FILE:");
5252 static const QString COMMAND_PREFIX = QLatin1String(
"CMD:");
5255 static const QString BEEP_CATEGORY = QLatin1String(
"BEEP");
5258 static const QString LATE_CANCEL_CAT = QLatin1String(
"LATECANCEL");
5261 static const QString TEMPL_DEF_TIME_CAT = QLatin1String(
"TMPLDEFTIME");
5264 static const QString EXEC_IN_XTERM_CAT = QLatin1String(
"XTERM");
5267 static const QString DATE_ONLY_CATEGORY = QLatin1String(
"DATE");
5268 static const QString EMAIL_BCC_CATEGORY = QLatin1String(
"BCC");
5269 static const QString CONFIRM_ACK_CATEGORY = QLatin1String(
"ACKCONF");
5270 static const QString KORGANIZER_CATEGORY = QLatin1String(
"KORG");
5271 static const QString DEFER_CATEGORY = QLatin1String(
"DEFER;");
5272 static const QString ARCHIVE_CATEGORY = QLatin1String(
"SAVE");
5273 static const QString ARCHIVE_CATEGORIES = QLatin1String(
"SAVE:");
5274 static const QString LATE_CANCEL_CATEGORY = QLatin1String(
"LATECANCEL;");
5275 static const QString AUTO_CLOSE_CATEGORY = QLatin1String(
"LATECLOSE;");
5276 static const QString TEMPL_AFTER_TIME_CATEGORY = QLatin1String(
"TMPLAFTTIME;");
5277 static const QString KMAIL_SERNUM_CATEGORY = QLatin1String(
"KMAIL:");
5278 static const QString LOG_CATEGORY = QLatin1String(
"LOG:");
5281 static const QByteArray KMAIL_ID_PROPERTY(
"KMAILID");
5284 static const QByteArray ARCHIVE_PROPERTY(
"ARCHIVE");
5285 static const QString ARCHIVE_REMINDER_ONCE_TYPE = QLatin1String(
"ONCE");
5286 static const QString REMINDER_ONCE_TYPE = QLatin1String(
"REMINDER_ONCE");
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];
5343 if (alarms.isEmpty())
5345 event->startUpdates();
5346 const bool readOnly =
event->isReadOnly();
5348 event->setReadOnly(
false);
5349 QStringList cats =
event->categories();
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;
5385 const QString txt = alarm->text();
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();
5423 const QString altxt = txt.mid(i);
5429 types += KAEventPrivate::FILE_TYPE;
5432 alarm->setDisplayAlarm(altxt);
5435 setProcedureAlarm(alarm, altxt);
5443 types += KAEventPrivate::AT_LOGIN_TYPE;
5447 types += KAEventPrivate::TIME_DEFERRAL_TYPE;
5449 addLateCancel =
true;
5450 if (types.count() > 0)
5451 alarm->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::TYPE_PROPERTY, types.join(QLatin1String(
",")));
5453 if (pre_0_7 && alarm->repeatCount() > 0 && alarm->snoozeTime().value() > 0)
5458 if (recur && recur->
recurs())
5460 recur->
setMinutely(alarm->snoozeTime().asSeconds() / 60);
5462 alarm->setRepeatCount(0);
5463 alarm->setSnoozeTime(0);
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];
5516 if (!cats.isEmpty())
5518 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5520#ifndef KALARMCAL_USE_KRESOURCES
5523 Alarm* alarm = alarms[ai];
5527 QString::fromLatin1(
"%1;;").arg(cats.at(0)));
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();
5544 alarm->setAudioAlarm();
5545 KDateTime dt =
event->dtStart();
5548 KAEventPrivate::AlarmMap alarmMap;
5549 KAEventPrivate::readAlarms(event, &alarmMap);
5550 KAEventPrivate::AlarmMap::ConstIterator it = alarmMap.constBegin();
5551 if (it != alarmMap.constEnd())
5553 dt = it.value().alarm->time();
5556 alarm->setStartOffset(start.secsTo(dt));
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];
5591 const QString oldtext = alarm->
text();
5593 if (oldtext != newtext)
5594 alarm->setDisplayAlarm(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(); )
5637 const QString cat = cats.at(i);
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;
5646 else if (cat.startsWith(DEFER_CATEGORY))
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)
5658 else if (cat.startsWith(ARCHIVE_CATEGORIES))
5660 else if (cat.startsWith(LOG_CATEGORY))
5677 event->shiftTimes(KDateTime::ClockTime, localZone);
5682 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += QLatin1String(
"1");
5683 if (!flags.isEmpty())
5685 event->setCategories(cats);
5687 if ((pre_1_4_14 || (pre_1_9_7 && !pre_1_9_0))
5697 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
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];
5712 if (!alarm->hasStartOffset())
5721 bool mainAlarm =
true;
5723 const QStringList types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
5724 for (
int t = 0; t < types.count(); ++t)
5726 QString type = types[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();
5751 dt.toString(dateOnly ? QLatin1String(
"yyyyMMdd") : QLatin1String(
"yyyyMMddThhmmss")));
5754 alarm->setStartOffset(0);
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];
5780 if (!alarm->hasStartOffset())
5783 const QStringList types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
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)
5790 alarm->setStartOffset(alarm->startOffset().asSeconds() - adjustment);
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;
5858 if (!prop.isEmpty())
5861 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5862 flags << KAEventPrivate::ARCHIVE_FLAG;
5864 if (prop != QLatin1String(
"0"))
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;
5875 else if (!list[i].isEmpty() && !list[i].startsWith(QChar::fromLatin1(
'-')))
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;
5913 if (!flags.isEmpty())
5914 alarm->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5917 if (!alarm->hasStartOffset())
5920 QStringList types =
property.split(QChar::fromLatin1(
','), QString::SkipEmptyParts);
5921 const int r = types.indexOf(REMINDER_ONCE_TYPE);
5925 types[r] = KAEventPrivate::REMINDER_TYPE;
5926 alarm->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::TYPE_PROPERTY, types.join(QChar::fromLatin1(
',')));
5927 reminderOnce =
true;
5929 if (r >= 0 || types.contains(KAEventPrivate::REMINDER_TYPE))
5932 const int offset = alarm->startOffset().asSeconds();
5935 alarm->setStartOffset(0);
5938 else if (offset < 0)
5939 reminder = reminderToString(offset / 60);
5942 if (!reminder.isEmpty())
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
5969bool KAEventPrivate::convertStartOfDay(
const Event::Ptr& event)
5971bool KAEventPrivate::convertStartOfDay(
Event* event)
5974 bool changed =
false;
5975 const QTime midnight(0, 0);
5976 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
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
6073bool KAEventPrivate::convertRepetition(
const Event::Ptr& event)
6075bool KAEventPrivate::convertRepetition(
Event* event)
6079 if (alarms.isEmpty())
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];
6093 if (alarm->repeatCount() > 0 && alarm->snoozeTime().value() > 0)
6097 event->startUpdates();
6099 event->setReadOnly(
false);
6100 if ((alarm->snoozeTime().asSeconds() % (24*3600)) != 0)
6101 recur->
setMinutely(alarm->snoozeTime().asSeconds() / 60);
6103 recur->
setDaily(alarm->snoozeTime().asDays());
6107 alarm->setRepeatCount(0);
6108 alarm->setSnoozeTime(0);
6114 event->setReadOnly(
true);
6115 event->endUpdates();
6130KAAlarm::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
6244EmailAddressList& EmailAddressList::operator=(
const Person::List& addresses)
6246EmailAddressList& 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]);
6265EmailAddressList::operator QStringList()
const
6268 for (
int p = 0, end = count(); p < end; ++p)
6277QString EmailAddressList::join(
const QString& separator)
const
6281 for (
int p = 0, end = count(); p < end; ++p)
6286 result += separator;
6287 result += address(p);
6295QString 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];
6306 const QString name = person.
name();
6308 if (!name.isEmpty())
6311 for (
int i = 0, len = name.length(); i < len; ++i)
6313 const QChar ch = name[i];
6314 if (!ch.isLetterOrNumber())
6317 result += QLatin1Char(
'\"');
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();
6336 result += QLatin1Char(
'>');
6343QStringList 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();
6358QString 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
6387static void setProcedureAlarm(
const Alarm::Ptr& alarm,
const QString& commandLine)
6389static 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)
6413 switch (ch.toLatin1())
6420 done = !command.isEmpty();
6424 if (command.isEmpty())
6442 for ( ; pos < posMax && commandLine[pos] == QLatin1Char(
' '); ++pos) ;
6443 arguments = commandLine.mid(pos);
6452QString reminderToString(
int minutes)
6455 int count = abs(minutes);
6456 if (count % 1440 == 0)
6461 else if (count % 60 == 0)
6468 return QString::fromLatin1(
"%1%2").arg(count).arg(unit);
static QString fromCalendarText(const QString &text, bool &email)
Translate an alarm calendar text to a display text.
static QString toCalendarText(const QString &text)
Return the text for an alarm message text, in alarm calendar format.
As KDateTime, but with a configurable start-of-day time for date-only values.
DateTime addMins(qint64 n) const
Returns a DateTime value mins minutes later than the value of this object.
KDateTime kDateTime() const
Returns the date and time of the value as a KDateTime.
QString toString(Qt::DateFormat f=Qt::TextDate) const
Returns the value as a string.
static QTime startOfDay()
Returns the start-of-day time.
bool isDateOnly() const
Returns true if it is date-only value.
bool isValid() const
Returns true if the date is valid and, if it is a date-time value, the time is also valid.
void setDateOnly(bool d)
Sets the value to be either date-only or date-time.
void setDate(const QDate &d)
Sets the date component of the value.
KDateTime effectiveKDateTime() const
Returns the date and time of the value.
DateTime addSecs(qint64 n) const
Returns a DateTime value secs seconds later than the value of this object.
static void setStartOfDay(const QTime &sod)
Sets the start-of-day time.
KDateTime::Spec timeSpec() const
Returns the time specification of the value.
QDate date() const
Returns the date part of the value.
KAAlarm represents individual alarms within a KAEvent.
QDate date() const
Return the trigger date for the alarm.
KAAlarm()
Default constructor, which creates an invalid instance.
void setTime(const DateTime &dt)
Set the alarm's trigger time.
Action action() const
Return the action type for the alarm.
static const char * debugType(Type)
Return an alarm type as a string.
DateTime dateTime(bool withRepeats=false) const
Return the trigger time for the alarm.
bool timedDeferral() const
Return whether in the case of a deferred alarm, it is timed (as opposed to date-only).
Action
The basic KAAlarm action types.
@ EMAIL
KCal::Alarm::Email type: send an email.
@ MESSAGE
KCal::Alarm::Display type: display a text message.
@ FILE
KCal::Alarm::Display type: display a file (URL given by the alarm text)
@ AUDIO
KCal::Alarm::Audio type: play a sound file.
@ COMMAND
KCal::Alarm::Procedure type: execute a shell command.
KAAlarm & operator=(const KAAlarm &other)
Assignment operator.
bool deferred() const
Return whether this is a deferred alarm.
bool isReminder() const
Return whether this is a reminder alarm.
QTime time() const
Return the trigger time-of-day for the alarm.
Type type() const
Return the alarm's type (main, reminder, etc.).
bool isValid() const
Return whether the alarm is valid, i.e.
bool repeatAtLogin() const
Return whether this is a repeat-at-login alarm.
@ DEFERRED_ALARM
Deferred alarm.
@ REMINDER_ALARM
Reminder in advance of/after the main alarm.
@ DEFERRED_REMINDER_ALARM
Deferred reminder alarm.
@ INVALID_ALARM
Not an alarm.
@ DISPLAYING_ALARM
Copy of the alarm currently being displayed.
@ MAIN_ALARM
THE real alarm. Must be the first in the enumeration.
@ AT_LOGIN_ALARM
Additional repeat-at-login trigger.
KAEvent represents a KAlarm event.
void reinstateFromDisplaying(const KCalCore::Event::Ptr &event, Akonadi::Collection::Id &colId, bool &showEdit, bool &showDefer)
Reinstate the original event from the 'displaying' event.
int reminderMinutes() const
Return the number of minutes BEFORE the main alarm when a reminder alarm is set.
bool expired() const
Return whether the event has expired.
void setDeferDefaultMinutes(int minutes, bool dateOnly=false)
Set defaults for the deferral dialog.
OccurType
What type of occurrence is due.
@ OCCURRENCE_REPEAT
(bitmask for a sub-repetition of an occurrence)
@ RECURRENCE_DATE_TIME
a recurrence with a date and time
@ RECURRENCE_DATE
a recurrence with only a date, not a time
@ FIRST_OR_ONLY_OCCURRENCE
the first occurrence (takes precedence over LAST_RECURRENCE)
@ LAST_RECURRENCE
the last recurrence
@ NO_OCCURRENCE
no occurrence is due
int repeatSoundPause() const
Return how many seconds to pause between repetitions of the sound file.
void setRepeatAtLogin(bool repeat)
Enable or disable repeat-at-login.
bool deferDefaultDateOnly() const
Return the default date-only setting used in the deferral dialog.
bool setRecurDaily(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur daily.
static void setStartOfDay(const QTime &)
Set the start-of-day time used by all date-only alarms.
void setReminder(int minutes, bool onceOnly)
Set an additional reminder alarm.
bool emailBcc() const
Return whether to send a blind copy of the email to the sender, for an email alarm.
DateTime mainDateTime(bool withRepeats=false) const
Return the next time the main alarm will trigger.
QString audioFile() const
Return the audio file path.
bool autoClose() const
Return whether auto-close is enabled, i.e.
void setCreatedDateTime(const KDateTime &dt)
Set the date/time the event was created, or saved in the archive calendar.
QString logFile() const
Return the log file which command alarm output should be written to.
bool holidaysExcluded() const
Return whether the alarm is disabled on holiday dates.
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.
QString emailSubject() const
Return the email subject line, for an email alarm.
bool repeatSound() const
Return whether the sound file will be repeated indefinitely.
bool mainExpired() const
Return whether the event's main alarm has expired.
void setActions(const QString &pre, const QString &post, ExtraActionOptions options)
Set the pre-alarm and post-alarm actions, and their options.
QVector< KAEvent * > List
A list of pointers to KAEvent objects.
QString recurrenceText(bool brief=false) const
Return the recurrence interval as text suitable for display.
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.
int recurInterval() const
Return the recurrence interval in units of the recurrence period type (minutes, days,...
SubAction
The sub-action type for the event's main alarm.
@ FILE
display the contents of a file
@ COMMAND
execute a command
@ MESSAGE
display a message text
@ AUDIO
play an audio file
void setRecurrence(const KARecurrence &r)
Initialise the event's recurrence from a KARecurrence.
void setCollectionId_const(Akonadi::Collection::Id id) const
Set the ID of the Akonadi Collection which contains the event.
void setLateCancel(int minutes)
Set or clear the late-cancel option.
bool commandXterm() const
Return whether to execute the command in a terminal window, for a command alarm.
bool deferred() const
Return whether there is currently a deferred alarm pending.
static QString joinEmailAddresses(const KCalCore::Person::List &addresses, const QString &sep)
Concatenate a list of email addresses into a string.
bool commandDisplay() const
Return whether the command output is to be displayed in an alarm message window.
QStringList emailAddresses() const
Return a list of the email addresses, including names, for an email alarm.
KACalendar::Compat compatibility() const
Return the event's storage format compatibility compared to the current KAlarm calendar format.
Akonadi::Collection::Id collectionId() const
Return the ID of the Akonadi Collection which contains the event.
QMap< QByteArray, QString > customProperties() const
Return the original KCalCore::Event's custom properties in the source calendar.
bool repeatAtLogin(bool includeArchived=false) const
Return whether the alarm repeats at login.
void setCommandError(CmdErrType error) const
Set or clear the command execution error for the last time the alarm triggered.
void setExcludeHolidays(bool exclude)
Enable or disable the alarm on holiday dates.
int fadeSeconds() const
Return the fade period in seconds, or 0 if no fade is specified.
int deferDefaultMinutes() const
Return the default deferral interval used in the deferral dialog.
QString command() const
Return the command or script to execute, for a command alarm.
QStringList emailAttachments() const
Return the list of file paths of the attachments, for an email alarm.
QString displayMessage() const
Return the message text for a display alarm.
DateTime mainEndRepeatTime() const
Return the time at which the last sub-repetition of the main alarm will occur.
KAAlarm convertDisplayingAlarm() const
Return the original alarm which the displaying alarm refers to.
CalEvent::Type category() const
Return the alarm category (active/archived/template, or displaying).
void setReadOnly(bool ro)
Set the read-only status of the alarm.
KARecurrence * recurrence() const
Return the full recurrence data for the event.
void setCompatibility(KACalendar::Compat c)
Note the event's storage format compatibility compared to the current KAlarm calendar format.
static int currentCalendarVersion()
Return the current KAlarm calendar storage format version.
KAAlarm firstAlarm() const
Return the main alarm for the event.
void setFirstRecurrence()
Adjust the event date/time to the first recurrence of the event, on or after the event start date/tim...
QColor bgColour() const
Return the message window background color, for a display alarm.
DateTime startDateTime() const
Return the start time for the event.
bool copyToKOrganizer() const
Return whether KOrganizer should hold a copy of the event.
QString repetitionText(bool brief=false) const
Return the repetition interval as text suitable for display.
void incrementRevision()
Increment the revision number of the event (SEQUENCE property in iCalendar).
static QByteArray currentCalendarVersionString()
Return the current KAlarm calendar storage format version.
void setTemplate(const QString &name, int afterTime=-1)
Set the event to be an alarm template.
void setEventId(const QString &id)
Set the event's unique identifier.
float soundVolume() const
Return the sound volume (the final volume if fade is specified).
bool confirmAck() const
Return whether alarm acknowledgement must be confirmed by the user, for a display alarm.
void setCollectionId(Akonadi::Collection::Id id)
Set the ID of the Akonadi Collection which contains the event.
bool toBeArchived() const
Return whether the event should be archived when it expires or is deleted.
QString message() const
Return the message text for a display alarm, or the email body for an email alarm.
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...
void set(const KCalCore::Event::Ptr &)
Initialise the instance from a KCalCore::Event.
KAAlarm nextAlarm(const KAAlarm &previousAlarm) const
Return the next alarm for the event, after the specified alarm.
Akonadi::Item::Id itemId() const
Return the ID of the Akonadi Item which contains the event.
void setTime(const KDateTime &dt)
Set the next time to trigger the alarm (excluding sub-repetitions).
KDateTime createdDateTime() const
Return the date/time the event was created, or saved in the archive calendar.
bool isReadOnly() const
Return the read-only status of the alarm.
bool usingDefaultTime() const
Return whether the alarm template does not specify a time.
static void setHolidays(const KHolidays::HolidayRegion ®ion)
Set the holiday region to be used by all KAEvent instances.
QString id() const
Return the event's unique identifier.
Actions
The basic action type(s) for the event's main alarm.
@ ACT_EMAIL
the alarm sends an email
@ ACT_DISPLAY
the alarm displays something
@ ACT_DISPLAY_COMMAND
the alarm displays command output
@ ACT_COMMAND
the alarm executes a command
@ ACT_AUDIO
the alarm plays an audio file (without any display)
int nextRepetition() const
Return the count of the next sub-repetition which is due.
int revision() const
Return the revision number of the event (SEQUENCE property in iCalendar).
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.
OccurOption
How to treat sub-repetitions in nextOccurrence().
@ RETURN_REPETITION
return a sub-repetition if it's the next occurrence
@ IGNORE_REPETITION
check for recurrences only, ignore sub-repetitions
void defer(const DateTime &dt, bool reminder, bool adjustRecurrence=false)
Defer the event to the specified time.
void dumpDebug() const
Output the event's data as debug output.
bool reminderDeferral() const
Return whether there is currently a deferred reminder alarm pending.
int lateCancel() const
Get the late cancellation period.
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...
QFont font() const
Return the font to use for alarm message texts.
UidAction
How to deal with the event UID in updateKCalEvent().
@ UID_SET
set the KCal::Event UID to the KAEvent ID
@ UID_CHECK
verify that the KCal::Event UID is already the same as the KAEvent ID, if the latter is non-empty
QStringList emailPureAddresses() const
Return the list of email addressees, excluding names, for an email alarm.
@ ANY_TIME
only a date is specified for the alarm, not a time
@ DISABLED
the alarm is currently disabled
@ REPEAT_AT_LOGIN
repeat the alarm at every login
@ REPEAT_SOUND
repeat the sound file while the alarm is displayed
@ EXCL_HOLIDAYS
don't trigger the alarm on holidays
@ REMINDER_ONCE
only trigger the reminder on the first recurrence
@ SPEAK
speak the message when the alarm is displayed
@ COPY_KORGANIZER
KOrganizer should hold a copy of the event.
@ DEFAULT_FONT
use the default alarm message font
@ WORK_TIME_ONLY
trigger the alarm only during working hours
@ SCRIPT
the command is a script, not a shell command line
@ BEEP
sound an audible beep when the alarm is displayed
@ CONFIRM_ACK
closing the alarm message window requires a confirmation prompt
@ EMAIL_BCC
blind copy the email to the user
@ EXEC_IN_XTERM
execute the command in a terminal window
@ DISPLAY_COMMAND
display command output in the alarm window
@ AUTO_CLOSE
auto-close the alarm window after the late-cancel period
QString postAction() const
Return the shell command to execute after the display alarm is acknowledged.
bool setRepetition(const Repetition &r)
Initialise the event's sub-repetition.
OccurType setNextOccurrence(const KDateTime &preDateTime)
Set the date/time of the event to the next scheduled occurrence after a specified date/time,...
CmdErrType
Command execution error type for last time the alarm was triggered.
@ CMD_ERROR_PRE
pre-alarm command execution failed
@ CMD_ERROR
command alarm execution failed
@ CMD_ERROR_POST
post-alarm command execution failed
bool commandScript() const
Return whether a command script is specified, for a command alarm.
static void setDefaultFont(const QFont &font)
Set the global default font for alarm message texts.
static List ptrList(QVector< KAEvent > &events)
Return a list of pointers to a list of KAEvent objects.
DateTime deferralLimit(DeferLimitType *limitType=0) const
Return the latest time which the alarm can currently be deferred to.
bool enabled() const
Return the enabled status of the alarm.
QString fileName() const
Return the path of the file whose contents are to be shown, for a display alarm.
void setArchive()
Set the event to be archived when it expires or is deleted.
DateTime nextTrigger(TriggerType type) const
Return the next time the alarm will trigger.
void endChanges()
Call when a group of changes preceded by startChanges() is complete, to allow resultant updates to oc...
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.
bool setRecurMinutely(int freq, int count, const KDateTime &end)
Set the recurrence to recur at a minutes interval.
SubAction actionSubType() const
Return the action sub-type of the event's main alarm.
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.
void setLogFile(const QString &logfile)
Set the log file to write command alarm output to.
bool reminderActive() const
Return whether a reminder is currently due (before the next, or after the last, main alarm/recurrence...
void setEmail(uint from, const KCalCore::Person::List &, const QString &subject, const QStringList &attachments)
Set the email related data for the event.
KCalCore::Duration longestRecurrenceInterval() const
Return the longest interval which can occur between consecutive recurrences.
DateTime deferDateTime() const
Return the time at which the currently pending deferred alarm should trigger.
int templateAfterTime() const
Return the number of minutes (>= 0) after the default alarm time which is specified in the alarm temp...
bool setItemPayload(Akonadi::Item &, const QStringList &collectionMimeTypes) const
Initialise an Akonadi::Item with the event's data.
KARecurrence::Type recurType() const
Return the recurrence period type for the event.
float fadeVolume() const
Return the initial volume which will fade to the final volume.
bool speak() const
Return whether the displayed alarm text should be spoken.
bool setRecurWeekly(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur weekly, on the specified weekdays.
bool displaying() const
Return whether the alarm is currently being displayed, i.e.
static void adjustStartOfDay(const KAEvent::List &events)
Call when the user changes the start-of-day time, to adjust the data for each date-only event in a li...
bool isValid() const
Return whether the instance represents a valid event.
void setItemId(Akonadi::Item::Id id)
Set the ID of the Akonadi Item which contains the event.
ExtraActionOptions extraActionOptions() const
Return the pre- and post-alarm action options.
bool updateKCalEvent(const KCalCore::Event::Ptr &event, UidAction u, bool setCustomProperties=true) const
Update an existing KCalCore::Event with the KAEvent data.
void removeExpiredAlarm(KAAlarm::Type type)
Remove the alarm of the specified type from the event.
Flags flags() const
Return the OR of various Flag enum status values.
DeferLimitType
What type of occurrence currently limits how long the alarm can be deferred.
@ LIMIT_REMINDER
a reminder
@ LIMIT_MAIN
the main alarm
@ LIMIT_RECURRENCE
a recurrence
@ LIMIT_NONE
there is no limit
@ LIMIT_REPETITION
a sub-repetition
bool beep() const
Return whether a beep should sound when the alarm is displayed.
QString cleanText() const
Return the alarm's text.
@ DontShowPreActError
do not notify pre-alarm action errors to user
@ ExecPreActOnDeferral
execute pre-alarm action also for deferred alarms
@ CancelOnPreActError
cancel alarm on pre-alarm action error
KAAlarm alarm(KAAlarm::Type type) const
Return the alarm of a specified type.
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 dontShowPreActionError() const
Return whether the user should not be notified if the pre-alarm action fails.
bool recurs() const
Return whether the event recurs.
Actions actionTypes() const
Return the OR of the basic action types of the event's main alarm (display, command,...
bool isTemplate() const
Return whether the event is an alarm template.
QColor fgColour() const
Return the message window foreground color, for a display alarm.
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.
TriggerType
Alarm trigger type.
@ MAIN_TRIGGER
next trigger, excluding reminders, ignoring working hours & holidays
@ WORK_TRIGGER
next main working time trigger, excluding reminders
@ ALL_TRIGGER
next trigger, including reminders, ignoring working hours & holidays
@ ALL_WORK_TRIGGER
next actual working time trigger, including reminders
@ DISPLAY_TRIGGER
next trigger time for display purposes (i.e. excluding reminders)
bool useDefaultFont() const
Return whether to use the default font (as set by setDefaultFont()) for alarm message texts.
QTime mainTime() const
Return the time at which the main alarm will next trigger.
uint emailFromId() const
Return the email identity to be used as the sender, for an email alarm.
bool occursAfter(const KDateTime &preDateTime, bool includeRepetitions) const
Determine whether the event will occur after the specified date/time.
bool cancelOnPreActionError() const
Return whether the alarm is to be cancelled if the pre-alarm action fails.
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 startChanges()
Call before making a group of changes to the event, to avoid unnecessary calculation intensive recalc...
QString templateName() const
Return the alarm template's name.
void setNoRecur()
Clear the event's recurrence and sub-repetition data.
int alarmCount() const
Return the number of alarms in the event, i.e.
void activateReminderAfter(const DateTime &mainAlarmTime)
If there is a reminder which occurs AFTER the main alarm, activate the event's reminder which occurs ...
QString preAction() const
Return the shell command to execute before the alarm is displayed.
Repetition repetition() const
Return the event's sub-repetition data.
QString emailMessage() const
Return the email message body, for an email alarm.
KAEvent()
Default constructor which creates an invalid event.
bool workTimeOnly() const
Return whether the alarm is disabled on non-working days and outside working hours.
CmdErrType commandError() const
Return the command execution error for the last time the alarm triggered.
void cancelDefer()
Cancel any deferral alarm which is pending.
void setCategory(CalEvent::Type type)
Set the alarm category (active/archived/template, or displaying).
KCalCore::Person::List emailAddressees() const
Return the list of email addressees, including names, for an email alarm.
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.
void setWorkTimeOnly(bool wto)
Enable or disable the alarm on non-working days and outside working hours.
void setEnabled(bool enable)
Enable or disable the alarm.
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.
Represents recurrences for KAlarm.
KDateTime startDateTime() const
Return the start date/time of the recurrence (Time for all-day recurrences will be 0:00).
bool set(const QString &icalRRULE)
Initialise the recurrence from an iCalendar RRULE string.
bool recurs() const
Returns whether the event recurs at all.
void setFrequency(int freq)
Sets the frequency of recurrence, in terms of the recurrence time period type.
KDateTime endDateTime() const
Return the date/time of the last recurrence.
Type
The recurrence's period type.
@ MINUTELY
at an hours/minutes interval
@ ANNUAL_DATE
yearly, on a specified date in each of the specified months
@ ANNUAL_POS
yearly, on specified weekdays in the specified weeks of the specified months
@ WEEKLY
weekly, on specified weekdays
@ MONTHLY_DAY
monthly, on a specified day of the month
@ MONTHLY_POS
monthly, on specified weekdays in a specified week of the month
void setStartDateTime(const KDateTime &dt, bool dateOnly)
Set the recurrence start date/time, and optionally set it to all-day.
Feb29Type
When annual February 29th recurrences should occur in non-leap years.
@ Feb29_None
does not occur in non-leap years
KDateTime getPreviousDateTime(const KDateTime &afterDateTime) const
Get the previous time the recurrence occurred, strictly before a specified time.
bool recursOn(const QDate &, const KDateTime::Spec &) const
Return whether the event will recur on the specified date.
KDateTime getNextDateTime(const KDateTime &preDateTime) const
Get the next time the recurrence occurs, strictly after a specified time.
Type type() const
Return the recurrence's period type.
int frequency() const
Returns frequency of recurrence, in terms of the recurrence time period type.
bool init(KCalCore::RecurrenceRule::PeriodType t, int freq, int count, const KDateTime &start, const KDateTime &end)
Set up a KARecurrence from recurrence parameters.
KCalCore::Duration longestInterval() const
Return the longest interval between recurrences.
QList< int > yearMonths() const
Returns the months within a yearly recurrence.
KCalCore::Duration regularInterval() const
Return the interval between recurrences, if the interval between successive occurrences does not vary...
int duration() const
Returns -1 if the event recurs infinitely, 0 if the end date is set, otherwise the total number of re...
Represents a sub-repetition, defined by interval and repeat count.
void set(const KCalCore::Duration &interval, int count)
Initialises the instance with the specified interval and count.
int nextRepeatCount(const KDateTime &from, const KDateTime &preDateTime) const
Find the repetition count for the next repetition after a specified time.
int previousRepeatCount(const KDateTime &from, const KDateTime &afterDateTime) const
Find the repetition count for the last repetition before a specified time.
KCalCore::Duration interval() const
Return the interval between repetitions.
KCalCore::Duration duration() const
Return the overall duration of the repetition.
int count() const
Return the number of repetitions.
int intervalDays() const
Return the repetition interval in terms of days.
int intervalSeconds() const
Return the repetition interval in terms of seconds.
int intervalMinutes() const
Return the repetition interval in terms of minutes.
bool isDaily() const
Check whether the repetition interval is in terms of days (as opposed to minutes).
QSharedPointer< Alarm > Ptr
QString programFile() const
Duration snoozeTime() const
void setRepeatCount(int alarmRepeatCount)
void setEnabled(bool enable)
void setDisplayAlarm(const QString &text=QString())
QString programArguments() const
void setSnoozeTime(const Duration &alarmSnoozeTime)
QString audioFile() const
void setEmailAlarm(const QString &subject, const QString &text, const Person::List &addressees, const QStringList &attachments=QStringList())
void setAudioAlarm(const QString &audioFile=QString())
void setStartOffset(const Duration &offset)
void setProcedureAlarm(const QString &programFile, const QString &arguments=QString())
QSharedPointer< Calendar > Ptr
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
QString customProperty(const QByteArray &app, const QByteArray &key) const
KDateTime end(const KDateTime &start) const
virtual KDateTime dtEnd() const
QSharedPointer< Event > Ptr
QString customStatus() const
Alarm::List alarms() const
Recurrence * recurrence() const
QSharedPointer< Person > Ptr
void setMinutely(int freq)
void setDuration(int duration)
Type type(const QString &mimeType)
Return the alarm Type for a mime type string.
Type
The category of an event, indicated by the middle part of its UID.
@ DISPLAYING
the event is currently being displayed
@ TEMPLATE
the event is an alarm template
@ ACTIVE
the event is currently active
@ ARCHIVED
the event is archived
@ EMPTY
the event has no alarms
Types types(const QStringList &mimeTypes)
Return the alarm Types for a list of mime type strings.
uint identityUoid(const QString &identityUoidOrName)
Fetch the uoid of an identity name or uoid string.
@ Current
in current KAlarm format
const QByteArray APPNAME
The application name ("KALARM") used in calendar properties.