25 #include "alarmtext.h"
26 #include "identities.h"
29 #ifndef KALARMCAL_USE_KRESOURCES
32 #include <kcal/calendarlocal.h>
34 #include <kholidays/holidays.h>
35 using namespace KHolidays;
37 #include <ksystemtimezone.h>
38 #include <klocalizedstring.h>
39 #ifdef KALARMCAL_USE_KRESOURCES
40 #include <ksharedconfig.h>
42 #include <kconfiggroup.h>
47 #ifndef KALARMCAL_USE_KRESOURCES
48 using namespace KCalCore;
52 using namespace KHolidays;
57 #ifndef KALARMCAL_USE_KRESOURCES
61 typedef KCal::Person EmailAddress;
62 class EmailAddressList :
public QList<KCal::Person>
66 #ifndef KALARMCAL_USE_KRESOURCES
67 EmailAddressList() : KCalCore::
Person::List() { }
71 EmailAddressList() : QList<KCal::
Person>() { }
72 EmailAddressList(
const QList<KCal::Person>& list) { operator=(list); }
73 EmailAddressList& operator=(
const QList<KCal::Person>&);
75 operator QStringList()
const;
76 QString join(
const QString& separator)
const;
77 QStringList pureAddresses()
const;
78 QString pureAddresses(
const QString& separator)
const;
80 QString address(
int index)
const;
84 class KAAlarm::Private
91 DateTime mNextMainDateTime;
92 Repetition mRepetition;
101 class KAEventPrivate :
public QSharedData
111 TIMED_FLAG = 0x400000,
112 DATE_DEFERRAL = DEFERRAL,
113 TIME_DEFERRAL = DEFERRAL | TIMED_FLAG,
114 DISPLAYING_ = 0x800000,
115 READ_ONLY_FLAGS = 0xF00000
136 REMINDER_ALARM = 0x02,
137 DEFERRED_ALARM = 0x04,
138 DEFERRED_REMINDER_ALARM = REMINDER_ALARM | DEFERRED_ALARM,
141 AT_LOGIN_ALARM = 0x10,
142 DISPLAYING_ALARM = 0x20,
145 PRE_ACTION_ALARM = 0x40,
146 POST_ACTION_ALARM = 0x50
151 #ifndef KALARMCAL_USE_KRESOURCES
159 QColor bgColour, fgColour;
163 int repeatSoundPause;
166 KAEventPrivate::AlarmType
type;
167 KAAlarm::Action action;
169 KAEvent::ExtraActionOptions extraActionOptions;
176 typedef QMap<AlarmType, AlarmData> AlarmMap;
179 KAEventPrivate(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
180 const QFont& f, KAEvent::SubAction,
int lateCancel, KAEvent::Flags flags,
181 bool changesPending =
false);
182 #ifndef KALARMCAL_USE_KRESOURCES
185 explicit KAEventPrivate(
const KCal::Event*);
187 KAEventPrivate(
const KAEventPrivate&);
188 ~KAEventPrivate() {
delete mRecurrence; }
189 KAEventPrivate& operator=(
const KAEventPrivate& e) {
if (&e !=
this) copy(e);
return *
this; }
190 #ifndef KALARMCAL_USE_KRESOURCES
193 void set(
const KCal::Event*);
195 void set(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
196 const QFont&, KAEvent::SubAction,
int lateCancel, KAEvent::Flags flags,
197 bool changesPending =
false);
198 void setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile);
199 KAEvent::OccurType setNextOccurrence(
const KDateTime& preDateTime);
200 void setFirstRecurrence();
201 void setCategory(CalEvent::Type);
202 void setRepeatAtLogin(
bool);
203 void setRepeatAtLoginTrue(
bool clearReminder);
204 void setReminder(
int minutes,
bool onceOnly);
205 void activateReminderAfter(
const DateTime& mainAlarmTime);
206 void defer(
const DateTime&,
bool reminder,
bool adjustRecurrence =
false);
208 #ifndef KALARMCAL_USE_KRESOURCES
209 bool setDisplaying(
const KAEventPrivate&, KAAlarm::Type,
Akonadi::Collection::Id,
const KDateTime& dt,
bool showEdit,
bool showDefer);
212 bool setDisplaying(
const KAEventPrivate&, KAAlarm::Type,
const QString& resourceID,
const KDateTime& dt,
bool showEdit,
bool showDefer);
213 void reinstateFromDisplaying(
const KCal::Event*, QString& resourceID,
bool& showEdit,
bool& showDefer);
214 void setCommandError(
const QString& configString);
215 void setCommandError(KAEvent::CmdErrType,
bool writeConfig)
const;
217 void startChanges() { ++mChangeCount; }
219 void removeExpiredAlarm(KAAlarm::Type);
220 KAAlarm alarm(KAAlarm::Type)
const;
221 KAAlarm firstAlarm()
const;
222 KAAlarm nextAlarm(KAAlarm::Type)
const;
223 #ifndef KALARMCAL_USE_KRESOURCES
224 bool updateKCalEvent(
const KCalCore::Event::Ptr&, KAEvent::UidAction,
bool setCustomProperties =
true)
const;
226 bool updateKCalEvent(KCal::Event*, KAEvent::UidAction)
const;
228 DateTime mainDateTime(
bool withRepeats =
false)
const
229 {
return (withRepeats && mNextRepeat && mRepetition)
230 ? mRepetition.duration(mNextRepeat).end(mNextMainDateTime.kDateTime()) : mNextMainDateTime; }
231 DateTime mainEndRepeatTime()
const
232 {
return mRepetition ? mRepetition.duration().end(mNextMainDateTime.kDateTime()) : mNextMainDateTime; }
233 DateTime deferralLimit(KAEvent::DeferLimitType* = 0)
const;
234 KAEvent::Flags flags()
const;
235 bool isWorkingTime(
const KDateTime&)
const;
236 bool setRepetition(
const Repetition&);
237 bool occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const;
238 KAEvent::OccurType nextOccurrence(
const KDateTime& preDateTime, DateTime& result, KAEvent::OccurOption = KAEvent::IGNORE_REPETITION)
const;
239 KAEvent::OccurType previousOccurrence(
const KDateTime& afterDateTime, DateTime& result,
bool includeRepetitions =
false)
const;
240 void setRecurrence(
const KARecurrence&);
241 #ifndef KALARMCAL_USE_KRESOURCES
245 bool setRecur(KCal::RecurrenceRule::PeriodType,
int freq,
int count,
const QDate& end, KARecurrence::Feb29Type = KARecurrence::Feb29_None);
246 bool setRecur(KCal::RecurrenceRule::PeriodType,
int freq,
int count,
const KDateTime& end, KARecurrence::Feb29Type = KARecurrence::Feb29_None);
248 KARecurrence::Type checkRecur()
const;
250 void calcTriggerTimes()
const;
251 #ifdef KDE_NO_DEBUG_OUTPUT
252 void dumpDebug()
const { }
254 void dumpDebug()
const;
256 #ifndef KALARMCAL_USE_KRESOURCES
261 static void readAlarm(
const KCalCore::Alarm::Ptr&, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
263 static bool convertRepetition(KCal::Event*);
264 static bool convertStartOfDay(KCal::Event*);
265 static DateTime readDateTime(
const KCal::Event*,
bool dateOnly, DateTime& start);
266 static void readAlarms(
const KCal::Event*,
void* alarmMap,
bool cmdDisplay =
false);
267 static void readAlarm(
const KCal::Alarm*, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
271 void copy(
const KAEventPrivate&);
272 bool mayOccurDailyDuringWork(
const KDateTime&)
const;
273 int nextWorkRepetition(
const KDateTime& pre)
const;
274 void calcNextWorkingTime(
const DateTime& nextTrigger)
const;
275 DateTime nextWorkingTime()
const;
276 KAEvent::OccurType nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const;
277 #ifndef KALARMCAL_USE_KRESOURCES
282 void setAudioAlarm(KCal::Alarm*)
const;
283 KCal::Alarm* initKCalAlarm(KCal::Event*,
const DateTime&,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
284 KCal::Alarm* initKCalAlarm(KCal::Event*,
int startOffsetSecs,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
286 inline void set_deferral(DeferType);
287 inline void activate_reminder(
bool activate);
290 #ifdef KALARMCAL_USE_KRESOURCES
291 static QString mCmdErrConfigGroup;
293 static QFont mDefaultFont;
294 static const KHolidays::HolidayRegion* mHolidays;
295 static QBitArray mWorkDays;
296 static QTime mWorkDayStart;
297 static QTime mWorkDayEnd;
298 static int mWorkTimeIndex;
299 #ifdef KALARMCAL_USE_KRESOURCES
300 AlarmResource* mResource;
302 mutable DateTime mAllTrigger;
303 mutable DateTime mMainTrigger;
304 mutable DateTime mAllWorkTrigger;
305 mutable DateTime mMainWorkTrigger;
306 mutable KAEvent::CmdErrType mCommandError;
309 QString mTemplateName;
310 #ifndef KALARMCAL_USE_KRESOURCES
311 QMap<QByteArray, QString> mCustomProperties;
312 Akonadi::Item::Id mItemId;
316 QString mOriginalResourceId;
322 DateTime mStartDateTime;
323 KDateTime mCreatedDateTime;
324 DateTime mNextMainDateTime;
325 KDateTime mAtLoginDateTime;
326 DateTime mDeferralTime;
327 DateTime mDisplayingTime;
328 int mDisplayingFlags;
329 int mReminderMinutes;
330 DateTime mReminderAfterTime;
331 ReminderType mReminderActive;
332 int mDeferDefaultMinutes;
333 bool mDeferDefaultDateOnly;
335 KARecurrence* mRecurrence;
336 Repetition mRepetition;
340 unsigned long mKMailSerialNumber;
341 int mTemplateAfterTime;
345 uint mEmailFromIdentity;
346 EmailAddressList mEmailAddresses;
347 QString mEmailSubject;
348 QStringList mEmailAttachments;
349 mutable int mChangeCount;
350 mutable bool mTriggerChanged;
355 int mRepeatSoundPause;
357 mutable const KHolidays::HolidayRegion*
359 mutable int mWorkTimeOnly;
360 KAEvent::SubAction mActionSubType;
361 CalEvent::Type mCategory;
362 KAEvent::ExtraActionOptions mExtraActionOptions;
363 #ifndef KALARMCAL_USE_KRESOURCES
364 KACalendar::Compat mCompatibility;
368 bool mUseDefaultFont;
371 bool mCommandDisplay;
375 bool mCopyToKOrganizer;
376 bool mReminderOnceOnly;
380 bool mArchiveRepeatAtLogin;
383 bool mDisplayingDefer;
384 bool mDisplayingEdit;
388 static const QByteArray FLAGS_PROPERTY;
389 static const QString DATE_ONLY_FLAG;
390 static const QString EMAIL_BCC_FLAG;
391 static const QString CONFIRM_ACK_FLAG;
392 static const QString KORGANIZER_FLAG;
393 static const QString EXCLUDE_HOLIDAYS_FLAG;
394 static const QString WORK_TIME_ONLY_FLAG;
395 static const QString REMINDER_ONCE_FLAG;
396 static const QString DEFER_FLAG;
397 static const QString LATE_CANCEL_FLAG;
398 static const QString AUTO_CLOSE_FLAG;
399 static const QString TEMPL_AFTER_TIME_FLAG;
400 static const QString KMAIL_SERNUM_FLAG;
401 static const QString ARCHIVE_FLAG;
402 static const QByteArray NEXT_RECUR_PROPERTY;
403 static const QByteArray REPEAT_PROPERTY;
404 static const QByteArray LOG_PROPERTY;
405 static const QString xtermURL;
406 static const QString displayURL;
407 static const QByteArray TYPE_PROPERTY;
408 static const QString FILE_TYPE;
409 static const QString AT_LOGIN_TYPE;
410 static const QString REMINDER_TYPE;
411 static const QString REMINDER_ONCE_TYPE;
412 static const QString TIME_DEFERRAL_TYPE;
413 static const QString DATE_DEFERRAL_TYPE;
414 static const QString DISPLAYING_TYPE;
415 static const QString PRE_ACTION_TYPE;
416 static const QString POST_ACTION_TYPE;
417 static const QString SOUND_REPEAT_TYPE;
418 static const QByteArray NEXT_REPEAT_PROPERTY;
419 static const QString HIDDEN_REMINDER_FLAG;
420 static const QByteArray FONT_COLOUR_PROPERTY;
421 static const QByteArray VOLUME_PROPERTY;
422 static const QString EMAIL_ID_FLAG;
423 static const QString SPEAK_FLAG;
424 static const QString EXEC_ON_DEFERRAL_FLAG;
425 static const QString CANCEL_ON_ERROR_FLAG;
426 static const QString DONT_SHOW_ERROR_FLAG;
427 static const QString DISABLED_STATUS;
428 static const QString DISP_DEFER;
429 static const QString DISP_EDIT;
430 static const QString CMD_ERROR_VALUE;
431 static const QString CMD_ERROR_PRE_VALUE;
432 static const QString CMD_ERROR_POST_VALUE;
433 static const QString SC;
440 QByteArray KAEvent::currentCalendarVersionString() {
return QByteArray(
"2.7.0"); }
441 int KAEvent::currentCalendarVersion() {
return Version(2,7,0); }
447 const QByteArray KAEventPrivate::FLAGS_PROPERTY(
"FLAGS");
448 const QString KAEventPrivate::DATE_ONLY_FLAG = QLatin1String(
"DATE");
449 const QString KAEventPrivate::EMAIL_BCC_FLAG = QLatin1String(
"BCC");
450 const QString KAEventPrivate::CONFIRM_ACK_FLAG = QLatin1String(
"ACKCONF");
451 const QString KAEventPrivate::KORGANIZER_FLAG = QLatin1String(
"KORG");
452 const QString KAEventPrivate::EXCLUDE_HOLIDAYS_FLAG = QLatin1String(
"EXHOLIDAYS");
453 const QString KAEventPrivate::WORK_TIME_ONLY_FLAG = QLatin1String(
"WORKTIME");
454 const QString KAEventPrivate::REMINDER_ONCE_FLAG = QLatin1String(
"ONCE");
455 const QString KAEventPrivate::DEFER_FLAG = QLatin1String(
"DEFER");
456 const QString KAEventPrivate::LATE_CANCEL_FLAG = QLatin1String(
"LATECANCEL");
457 const QString KAEventPrivate::AUTO_CLOSE_FLAG = QLatin1String(
"LATECLOSE");
458 const QString KAEventPrivate::TEMPL_AFTER_TIME_FLAG = QLatin1String(
"TMPLAFTTIME");
459 const QString KAEventPrivate::KMAIL_SERNUM_FLAG = QLatin1String(
"KMAIL");
460 const QString KAEventPrivate::ARCHIVE_FLAG = QLatin1String(
"ARCHIVE");
462 const QByteArray KAEventPrivate::NEXT_RECUR_PROPERTY(
"NEXTRECUR");
463 const QByteArray KAEventPrivate::REPEAT_PROPERTY(
"REPEAT");
464 const QByteArray KAEventPrivate::LOG_PROPERTY(
"LOG");
465 const QString KAEventPrivate::xtermURL = QLatin1String(
"xterm:");
466 const QString KAEventPrivate::displayURL = QLatin1String(
"display:");
469 const QByteArray KAEventPrivate::TYPE_PROPERTY(
"TYPE");
470 const QString KAEventPrivate::FILE_TYPE = QLatin1String(
"FILE");
471 const QString KAEventPrivate::AT_LOGIN_TYPE = QLatin1String(
"LOGIN");
472 const QString KAEventPrivate::REMINDER_TYPE = QLatin1String(
"REMINDER");
473 const QString KAEventPrivate::TIME_DEFERRAL_TYPE = QLatin1String(
"DEFERRAL");
474 const QString KAEventPrivate::DATE_DEFERRAL_TYPE = QLatin1String(
"DATE_DEFERRAL");
475 const QString KAEventPrivate::DISPLAYING_TYPE = QLatin1String(
"DISPLAYING");
476 const QString KAEventPrivate::PRE_ACTION_TYPE = QLatin1String(
"PRE");
477 const QString KAEventPrivate::POST_ACTION_TYPE = QLatin1String(
"POST");
478 const QString KAEventPrivate::SOUND_REPEAT_TYPE = QLatin1String(
"SOUNDREPEAT");
479 const QByteArray KAEventPrivate::NEXT_REPEAT_PROPERTY(
"NEXTREPEAT");
480 const QString KAEventPrivate::HIDDEN_REMINDER_FLAG = QLatin1String(
"HIDE");
482 const QByteArray KAEventPrivate::FONT_COLOUR_PROPERTY(
"FONTCOLOR");
484 const QString KAEventPrivate::EMAIL_ID_FLAG = QLatin1String(
"EMAILID");
486 const QByteArray KAEventPrivate::VOLUME_PROPERTY(
"VOLUME");
487 const QString KAEventPrivate::SPEAK_FLAG = QLatin1String(
"SPEAK");
489 const QString KAEventPrivate::EXEC_ON_DEFERRAL_FLAG = QLatin1String(
"EXECDEFER");
490 const QString KAEventPrivate::CANCEL_ON_ERROR_FLAG = QLatin1String(
"ERRCANCEL");
491 const QString KAEventPrivate::DONT_SHOW_ERROR_FLAG = QLatin1String(
"ERRNOSHOW");
494 const QString KAEventPrivate::DISABLED_STATUS = QLatin1String(
"DISABLED");
497 const QString KAEventPrivate::DISP_DEFER = QLatin1String(
"DEFER");
498 const QString KAEventPrivate::DISP_EDIT = QLatin1String(
"EDIT");
501 #ifdef KALARMCAL_USE_KRESOURCES
502 QString KAEventPrivate::mCmdErrConfigGroup = QLatin1String(
"CommandErrors");
504 const QString KAEventPrivate::CMD_ERROR_VALUE = QLatin1String(
"MAIN");
505 const QString KAEventPrivate::CMD_ERROR_PRE_VALUE = QLatin1String(
"PRE");
506 const QString KAEventPrivate::CMD_ERROR_POST_VALUE = QLatin1String(
"POST");
508 const QString KAEventPrivate::SC = QLatin1String(
";");
510 QFont KAEventPrivate::mDefaultFont;
511 const KHolidays::HolidayRegion* KAEventPrivate::mHolidays = 0;
512 QBitArray KAEventPrivate::mWorkDays(7);
513 QTime KAEventPrivate::mWorkDayStart(9, 0, 0);
514 QTime KAEventPrivate::mWorkDayEnd(17, 0, 0);
515 int KAEventPrivate::mWorkTimeIndex = 1;
518 #ifndef KALARMCAL_USE_KRESOURCES
519 static void setProcedureAlarm(
const Alarm::Ptr&,
const QString& commandLine);
521 static void setProcedureAlarm(
Alarm*,
const QString& commandLine);
523 static QString reminderToString(
int minutes);
531 inline void KAEventPrivate::set_deferral(DeferType type)
535 if (mDeferral == NO_DEFERRAL)
540 if (mDeferral != NO_DEFERRAL)
546 inline void KAEventPrivate::activate_reminder(
bool activate)
548 if (activate && mReminderActive != ACTIVE_REMINDER && mReminderMinutes)
550 if (mReminderActive == NO_REMINDER)
552 mReminderActive = ACTIVE_REMINDER;
554 else if (!activate && mReminderActive != NO_REMINDER)
556 mReminderActive = NO_REMINDER;
557 mReminderAfterTime = DateTime();
562 K_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<KAEventPrivate>,
563 emptyKAEventPrivate, (
new KAEventPrivate))
566 : d(*emptyKAEventPrivate)
569 KAEventPrivate::KAEventPrivate()
571 #ifdef KALARMCAL_USE_KRESOURCES
574 mCommandError(KAEvent::CMD_NO_ERROR),
575 #ifndef KALARMCAL_USE_KRESOURCES
580 mReminderActive(NO_REMINDER),
585 mDeferral(NO_DEFERRAL),
587 mTriggerChanged(false),
591 mCategory(CalEvent::
EMPTY),
592 #ifndef KALARMCAL_USE_KRESOURCES
593 mCompatibility(KACalendar::
Current),
600 mRepeatAtLogin(false),
604 KAEvent::KAEvent(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
605 SubAction action,
int lateCancel, Flags flags,
bool changesPending)
606 : d(new KAEventPrivate(dt, message, bg, fg, f, action, lateCancel, flags, changesPending))
610 KAEventPrivate::KAEventPrivate(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
614 set(dt, message, bg, fg, f, action, lateCancel, flags, changesPending);
617 #ifndef KALARMCAL_USE_KRESOURCES
622 : d(
new KAEventPrivate(e))
626 #ifndef KALARMCAL_USE_KRESOURCES
627 KAEventPrivate::KAEventPrivate(
const Event::Ptr& e)
629 KAEventPrivate::KAEventPrivate(
const Event* e)
636 KAEventPrivate::KAEventPrivate(
const KAEventPrivate& e)
650 KAEvent& KAEvent::operator=(
const KAEvent& other)
660 void KAEventPrivate::copy(
const KAEventPrivate& event)
662 #ifdef KALARMCAL_USE_KRESOURCES
663 mResource =
event.mResource;
665 mAllTrigger =
event.mAllTrigger;
666 mMainTrigger =
event.mMainTrigger;
667 mAllWorkTrigger =
event.mAllWorkTrigger;
668 mMainWorkTrigger =
event.mMainWorkTrigger;
669 mCommandError =
event.mCommandError;
670 mEventID =
event.mEventID;
671 mTemplateName =
event.mTemplateName;
672 #ifndef KALARMCAL_USE_KRESOURCES
673 mCustomProperties =
event.mCustomProperties;
674 mItemId =
event.mItemId;
675 mCollectionId =
event.mCollectionId;
677 mOriginalResourceId =
event.mOriginalResourceId;
680 mAudioFile =
event.mAudioFile;
681 mPreAction =
event.mPreAction;
682 mPostAction =
event.mPostAction;
683 mStartDateTime =
event.mStartDateTime;
684 mCreatedDateTime =
event.mCreatedDateTime;
685 mNextMainDateTime =
event.mNextMainDateTime;
686 mAtLoginDateTime =
event.mAtLoginDateTime;
687 mDeferralTime =
event.mDeferralTime;
688 mDisplayingTime =
event.mDisplayingTime;
689 mDisplayingFlags =
event.mDisplayingFlags;
690 mReminderMinutes =
event.mReminderMinutes;
691 mReminderAfterTime =
event.mReminderAfterTime;
692 mReminderActive =
event.mReminderActive;
693 mDeferDefaultMinutes =
event.mDeferDefaultMinutes;
694 mDeferDefaultDateOnly =
event.mDeferDefaultDateOnly;
695 mRevision =
event.mRevision;
696 mRepetition =
event.mRepetition;
697 mNextRepeat =
event.mNextRepeat;
698 mAlarmCount =
event.mAlarmCount;
699 mDeferral =
event.mDeferral;
700 mKMailSerialNumber =
event.mKMailSerialNumber;
701 mTemplateAfterTime =
event.mTemplateAfterTime;
702 mBgColour =
event.mBgColour;
703 mFgColour =
event.mFgColour;
705 mEmailFromIdentity =
event.mEmailFromIdentity;
706 mEmailAddresses =
event.mEmailAddresses;
707 mEmailSubject =
event.mEmailSubject;
708 mEmailAttachments =
event.mEmailAttachments;
709 mLogFile =
event.mLogFile;
710 mSoundVolume =
event.mSoundVolume;
711 mFadeVolume =
event.mFadeVolume;
712 mFadeSeconds =
event.mFadeSeconds;
713 mRepeatSoundPause =
event.mRepeatSoundPause;
714 mLateCancel =
event.mLateCancel;
715 mExcludeHolidays =
event.mExcludeHolidays;
716 mWorkTimeOnly =
event.mWorkTimeOnly;
717 mActionSubType =
event.mActionSubType;
718 mCategory =
event.mCategory;
719 mExtraActionOptions =
event.mExtraActionOptions;
720 #ifndef KALARMCAL_USE_KRESOURCES
721 mCompatibility =
event.mCompatibility;
722 mReadOnly =
event.mReadOnly;
724 mConfirmAck =
event.mConfirmAck;
725 mUseDefaultFont =
event.mUseDefaultFont;
726 mCommandScript =
event.mCommandScript;
727 mCommandXterm =
event.mCommandXterm;
728 mCommandDisplay =
event.mCommandDisplay;
729 mEmailBcc =
event.mEmailBcc;
731 mSpeak =
event.mSpeak;
732 mCopyToKOrganizer =
event.mCopyToKOrganizer;
733 mReminderOnceOnly =
event.mReminderOnceOnly;
734 mAutoClose =
event.mAutoClose;
735 mMainExpired =
event.mMainExpired;
736 mRepeatAtLogin =
event.mRepeatAtLogin;
737 mArchiveRepeatAtLogin =
event.mArchiveRepeatAtLogin;
738 mArchive =
event.mArchive;
739 mDisplaying =
event.mDisplaying;
740 mDisplayingDefer =
event.mDisplayingDefer;
741 mDisplayingEdit =
event.mDisplayingEdit;
742 mEnabled =
event.mEnabled;
744 mTriggerChanged =
event.mTriggerChanged;
746 if (event.mRecurrence)
747 mRecurrence =
new KARecurrence(*event.mRecurrence);
752 #ifndef KALARMCAL_USE_KRESOURCES
764 #ifndef KALARMCAL_USE_KRESOURCES
765 void KAEventPrivate::set(
const Event::Ptr& event)
767 void KAEventPrivate::set(
const Event* event)
773 #ifdef KALARMCAL_USE_KRESOURCES
776 mEventID =
event->uid();
777 mRevision =
event->revision();
778 mTemplateName.clear();
780 #ifndef KALARMCAL_USE_KRESOURCES
784 mOriginalResourceId.clear();
786 mTemplateAfterTime = -1;
790 mCommandXterm =
false;
791 mCommandDisplay =
false;
792 mCopyToKOrganizer =
false;
795 mReminderOnceOnly =
false;
797 mArchiveRepeatAtLogin =
false;
798 mDisplayingDefer =
false;
799 mDisplayingEdit =
false;
800 mDeferDefaultDateOnly =
false;
801 mReminderActive = NO_REMINDER;
802 mReminderMinutes = 0;
803 mDeferDefaultMinutes = 0;
805 mKMailSerialNumber = 0;
806 mExcludeHolidays = 0;
809 mBgColour = QColor(255, 255, 255);
810 mFgColour = QColor(0, 0, 0);
811 #ifndef KALARMCAL_USE_KRESOURCES
813 mReadOnly =
event->isReadOnly();
815 mUseDefaultFont =
true;
820 mCategory = CalEvent::status(event, ¶m);
824 const QStringList params = param.split(SC, QString::KeepEmptyParts);
825 int n = params.count();
828 #ifndef KALARMCAL_USE_KRESOURCES
829 const qlonglong
id = params[0].toLongLong(&ok);
833 mOriginalResourceId = params[0];
835 for (
int i = 1; i < n; ++i)
837 if (params[i] == DISP_DEFER)
838 mDisplayingDefer =
true;
839 if (params[i] == DISP_EDIT)
840 mDisplayingEdit =
true;
844 #ifndef KALARMCAL_USE_KRESOURCES
847 mCustomProperties =
event->customProperties();
848 for (QMap<QByteArray, QString>::Iterator it = mCustomProperties.begin(); it != mCustomProperties.end(); )
850 if (it.key().startsWith(kalarmKey))
851 it = mCustomProperties.erase(it);
857 bool dateOnly =
false;
858 QStringList flags =
event->customProperty(
KACalendar::APPNAME, FLAGS_PROPERTY).split(SC, QString::SkipEmptyParts);
859 flags << QString() << QString();
860 for (
int i = 0, end = flags.count() - 1; i < end; ++i)
862 QString flag = flags.at(i);
863 if (flag == DATE_ONLY_FLAG)
865 else if (flag == CONFIRM_ACK_FLAG)
867 else if (flag == EMAIL_BCC_FLAG)
869 else if (flag == KORGANIZER_FLAG)
870 mCopyToKOrganizer =
true;
871 else if (flag == EXCLUDE_HOLIDAYS_FLAG)
872 mExcludeHolidays = mHolidays;
873 else if (flag == WORK_TIME_ONLY_FLAG)
875 else if (flag == KMAIL_SERNUM_FLAG)
877 const unsigned long n = flags.at(i + 1).toULong(&ok);
880 mKMailSerialNumber = n;
883 else if (flag == KAEventPrivate::ARCHIVE_FLAG)
885 else if (flag == KAEventPrivate::AT_LOGIN_TYPE)
886 mArchiveRepeatAtLogin =
true;
887 else if (flag == KAEventPrivate::REMINDER_TYPE)
889 flag = flags.at(++i);
890 if (flag == KAEventPrivate::REMINDER_ONCE_FLAG)
892 mReminderOnceOnly =
true;
895 const int len = flag.length() - 1;
896 mReminderMinutes = -flag.left(len).toInt();
897 switch (flag.at(len).toLatin1())
900 case 'H': mReminderMinutes *= 60;
break;
901 case 'D': mReminderMinutes *= 1440;
break;
902 default: mReminderMinutes = 0;
break;
905 else if (flag == DEFER_FLAG)
907 QString mins = flags.at(i + 1);
908 if (mins.endsWith(
'D'))
910 mDeferDefaultDateOnly =
true;
911 mins.truncate(mins.length() - 1);
913 const int n =
static_cast<int>(mins.toUInt(&ok));
916 mDeferDefaultMinutes = n;
919 else if (flag == TEMPL_AFTER_TIME_FLAG)
921 const int n =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
924 mTemplateAfterTime = n;
927 else if (flag == LATE_CANCEL_FLAG)
929 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
932 if (!ok || !mLateCancel)
935 else if (flag == AUTO_CLOSE_FLAG)
937 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
940 if (!ok || !mLateCancel)
949 if (prop == xtermURL)
950 mCommandXterm =
true;
951 else if (prop == displayURL)
952 mCommandDisplay =
true;
960 const QStringList list = prop.split(QLatin1Char(
':'));
961 if (list.count() >= 2)
963 const int interval =
static_cast<int>(list[0].toUInt());
964 const int count =
static_cast<int>(list[1].toUInt());
965 if (interval && count)
967 if (interval % (24*60))
968 mRepetition.set(
Duration(interval * 60, Duration::Seconds), count);
970 mRepetition.set(
Duration(interval / (24*60), Duration::Days), count);
974 mNextMainDateTime = readDateTime(event, dateOnly, mStartDateTime);
975 mCreatedDateTime =
event->created();
976 if (dateOnly && !mRepetition.isDaily())
977 mRepetition.set(
Duration(mRepetition.intervalDays(), Duration::Days));
979 mTemplateName =
event->summary();
980 #ifndef KALARMCAL_USE_KRESOURCES
983 if (event->statusStr() == DISABLED_STATUS)
991 mRepeatAtLogin =
false;
993 mCommandScript =
false;
994 mExtraActionOptions = 0;
995 mDeferral = NO_DEFERRAL;
998 mRepeatSoundPause = -1;
1000 mEmailFromIdentity = 0;
1001 mReminderAfterTime = DateTime();
1005 mPostAction.clear();
1006 mEmailSubject.clear();
1007 mEmailAddresses.clear();
1008 mEmailAttachments.clear();
1012 readAlarms(event, &alarmMap, mCommandDisplay);
1018 bool isEmailText =
false;
1019 bool setDeferralTime =
false;
1021 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
1023 const AlarmData& data = it.
value();
1024 const DateTime dateTime = data.alarm->hasStartOffset() ? data.alarm->startOffset().end(mNextMainDateTime.effectiveKDateTime()) : data.alarm->time();
1028 mMainExpired =
false;
1030 alTime.setDateOnly(mStartDateTime.isDateOnly());
1031 if (data.alarm->repeatCount() && data.alarm->snoozeTime())
1033 mRepetition.set(data.alarm->snoozeTime(), data.alarm->repeatCount());
1034 mNextRepeat = data.nextRepeat;
1040 mAudioFile = data.cleanText;
1041 mSpeak = data.speak && mAudioFile.isEmpty();
1042 mBeep = !mSpeak && mAudioFile.isEmpty();
1043 mSoundVolume = (!mBeep && !mSpeak) ? data.soundVolume : -1;
1044 mFadeVolume = (mSoundVolume >= 0 && data.fadeSeconds > 0) ? data.fadeVolume : -1;
1045 mFadeSeconds = (mFadeVolume >= 0) ? data.fadeSeconds : 0;
1046 mRepeatSoundPause = (!mBeep && !mSpeak) ? data.repeatSoundPause : -1;
1048 case AT_LOGIN_ALARM:
1049 mRepeatAtLogin =
true;
1050 mAtLoginDateTime = dateTime.kDateTime();
1051 alTime = mAtLoginDateTime;
1053 case REMINDER_ALARM:
1055 if (data.alarm->startOffset().asSeconds() / 60)
1057 mReminderActive = ACTIVE_REMINDER;
1058 if (mReminderMinutes < 0)
1060 mReminderAfterTime = dateTime;
1061 mReminderAfterTime.setDateOnly(dateOnly);
1062 if (data.hiddenReminder)
1063 mReminderActive = HIDDEN_REMINDER;
1067 case DEFERRED_REMINDER_ALARM:
1068 case DEFERRED_ALARM:
1069 mDeferral = (data.type == DEFERRED_REMINDER_ALARM) ? REMINDER_DEFERRAL : NORMAL_DEFERRAL;
1070 mDeferralTime = dateTime;
1071 if (!data.timedDeferral)
1072 mDeferralTime.setDateOnly(
true);
1073 if (data.alarm->hasStartOffset())
1074 deferralOffset = data.alarm->startOffset();
1076 case DISPLAYING_ALARM:
1079 mDisplayingFlags = data.displayingFlags;
1080 const bool dateOnly = (mDisplayingFlags & DEFERRAL) ? !(mDisplayingFlags & TIMED_FLAG)
1081 : mStartDateTime.isDateOnly();
1082 mDisplayingTime = dateTime;
1083 mDisplayingTime.setDateOnly(dateOnly);
1084 alTime = mDisplayingTime;
1087 case PRE_ACTION_ALARM:
1088 mPreAction = data.cleanText;
1089 mExtraActionOptions = data.extraActionOptions;
1091 case POST_ACTION_ALARM:
1092 mPostAction = data.cleanText;
1099 bool noSetNextTime =
false;
1102 case DEFERRED_REMINDER_ALARM:
1103 case DEFERRED_ALARM:
1108 setDeferralTime =
true;
1109 noSetNextTime =
true;
1112 case REMINDER_ALARM:
1113 case AT_LOGIN_ALARM:
1114 case DISPLAYING_ALARM:
1115 if (!set && !noSetNextTime)
1116 mNextMainDateTime = alTime;
1124 mText = (mActionSubType ==
KAEvent::COMMAND) ? data.cleanText.trimmed() : data.cleanText;
1125 switch (data.action)
1128 mCommandScript = data.commandScript;
1129 if (!mCommandDisplay)
1134 mUseDefaultFont = data.defaultFont;
1135 if (data.isEmailText)
1139 mBgColour = data.bgColour;
1140 mFgColour = data.fgColour;
1143 mEmailFromIdentity = data.emailFromId;
1144 mEmailAddresses = data.alarm->mailAddresses();
1145 mEmailSubject = data.alarm->mailSubject();
1146 mEmailAttachments = data.alarm->mailAttachments();
1150 mRepeatSoundPause = data.repeatSoundPause;
1162 case PRE_ACTION_ALARM:
1163 case POST_ACTION_ALARM:
1170 mKMailSerialNumber = 0;
1173 if (recur && recur->
recurs())
1175 const int nextRepeat = mNextRepeat;
1176 setRecurrence(*recur);
1177 if (nextRepeat <= mRepetition.count())
1178 mNextRepeat = nextRepeat;
1180 else if (mRepetition)
1183 if (mRepetition.isDaily())
1184 recur->
setDaily(mRepetition.intervalDays());
1186 recur->
setMinutely(mRepetition.intervalMinutes());
1188 mRepetition.set(0, 0);
1193 mArchiveRepeatAtLogin =
false;
1194 if (mReminderMinutes > 0)
1196 mReminderMinutes = 0;
1197 mReminderActive = NO_REMINDER;
1199 setRepeatAtLoginTrue(
false);
1206 DateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1207 dt.setDateOnly(mStartDateTime.isDateOnly());
1208 if (mDeferralTime.isDateOnly())
1210 mDeferralTime = deferralOffset.
end(dt.kDateTime());
1211 mDeferralTime.setDateOnly(
true);
1214 mDeferralTime = deferralOffset.
end(dt.effectiveKDateTime());
1216 if (mDeferral != NO_DEFERRAL)
1218 if (setDeferralTime)
1219 mNextMainDateTime = mDeferralTime;
1221 mTriggerChanged =
true;
1225 void KAEvent::set(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
1226 const QFont& f,
SubAction act,
int lateCancel, Flags flags,
bool changesPending)
1228 d->set(dt, message, bg, fg, f, act, lateCancel, flags, changesPending);
1234 void KAEventPrivate::set(
const KDateTime& dateTime,
const QString& text,
const QColor& bg,
const QColor& fg,
1236 bool changesPending)
1239 mStartDateTime = dateTime;
1241 mNextMainDateTime = mStartDateTime;
1256 mTemplateName.clear();
1257 #ifndef KALARMCAL_USE_KRESOURCES
1262 mOriginalResourceId.clear();
1265 mPostAction.clear();
1269 mAudioFile = (mActionSubType ==
KAEvent::AUDIO) ? text : QString();
1272 mTemplateAfterTime = -1;
1278 mLateCancel = lateCancel;
1279 mDeferral = NO_DEFERRAL;
1281 mStartDateTime.setDateOnly(flags & KAEvent::ANY_TIME);
1282 set_deferral((flags & DEFERRAL) ? NORMAL_DEFERRAL : NO_DEFERRAL);
1294 mDisplaying = flags & DISPLAYING_;
1303 setRepeatAtLoginTrue(
false);
1306 mKMailSerialNumber = 0;
1307 mReminderMinutes = 0;
1308 mDeferDefaultMinutes = 0;
1309 mDeferDefaultDateOnly =
false;
1310 mArchiveRepeatAtLogin =
false;
1311 mReminderActive = NO_REMINDER;
1312 mDisplaying =
false;
1313 mMainExpired =
false;
1314 mDisplayingDefer =
false;
1315 mDisplayingEdit =
false;
1317 mReminderAfterTime = DateTime();
1318 mExtraActionOptions = 0;
1319 #ifndef KALARMCAL_USE_KRESOURCES
1324 mChangeCount = changesPending ? 1 : 0;
1325 mTriggerChanged =
true;
1334 #ifndef KALARMCAL_USE_KRESOURCES
1337 return d->updateKCalEvent(e, u, setCustomProperties);
1343 return d->updateKCalEvent(e, u);
1347 #ifndef KALARMCAL_USE_KRESOURCES
1359 || (!mAlarmCount && (!archived || !mMainExpired)))
1364 const bool readOnly = ev->isReadOnly();
1366 ev->setUid(mEventID);
1367 #ifndef KALARMCAL_USE_KRESOURCES
1368 ev->setReadOnly(mReadOnly);
1370 ev->setReadOnly(
false);
1372 ev->setTransparency(Event::Transparent);
1377 #ifndef KALARMCAL_USE_KRESOURCES
1378 if (setCustomProperties)
1379 ev->setCustomProperties(mCustomProperties);
1389 #ifndef KALARMCAL_USE_KRESOURCES
1390 param = QString::number(mCollectionId);
1392 param = mOriginalResourceId;
1394 if (mDisplayingDefer)
1395 param += SC + DISP_DEFER;
1396 if (mDisplayingEdit)
1397 param += SC + DISP_EDIT;
1399 #ifndef KALARMCAL_USE_KRESOURCES
1400 CalEvent::setStatus(ev, mCategory, param);
1402 CalEvent::setStatus(ev, mCategory, param);
1405 if (mStartDateTime.isDateOnly())
1406 flags += DATE_ONLY_FLAG;
1408 flags += CONFIRM_ACK_FLAG;
1410 flags += EMAIL_BCC_FLAG;
1411 if (mCopyToKOrganizer)
1412 flags += KORGANIZER_FLAG;
1413 if (mExcludeHolidays)
1414 flags += EXCLUDE_HOLIDAYS_FLAG;
1416 flags += WORK_TIME_ONLY_FLAG;
1418 (flags += (mAutoClose ? AUTO_CLOSE_FLAG : LATE_CANCEL_FLAG)) += QString::number(mLateCancel);
1419 if (mReminderMinutes)
1421 flags += REMINDER_TYPE;
1422 if (mReminderOnceOnly)
1423 flags += REMINDER_ONCE_FLAG;
1424 flags += reminderToString(-mReminderMinutes);
1426 if (mDeferDefaultMinutes)
1428 QString param = QString::number(mDeferDefaultMinutes);
1429 if (mDeferDefaultDateOnly)
1431 (flags += DEFER_FLAG) += param;
1433 if (!mTemplateName.isEmpty() && mTemplateAfterTime >= 0)
1434 (flags += TEMPL_AFTER_TIME_FLAG) += QString::number(mTemplateAfterTime);
1435 if (mKMailSerialNumber)
1436 (flags += KMAIL_SERNUM_FLAG) += QString::number(mKMailSerialNumber);
1437 if (mArchive && !archived)
1439 flags += ARCHIVE_FLAG;
1440 if (mArchiveRepeatAtLogin)
1441 flags += AT_LOGIN_TYPE;
1443 if (!flags.isEmpty())
1448 else if (mCommandDisplay)
1450 else if (!mLogFile.isEmpty())
1453 ev->setCustomStatus(mEnabled ? QString() : DISABLED_STATUS);
1454 ev->setRevision(mRevision);
1469 ev->setDtStart(mStartDateTime.calendarKDateTime());
1470 ev->setAllDay(
false);
1471 ev->setHasEndDate(
false);
1473 const DateTime dtMain = archived ? mStartDateTime : mNextMainDateTime;
1474 int ancillaryType = 0;
1475 DateTime ancillaryTime;
1476 int ancillaryOffset = 0;
1477 if (!mMainExpired || archived)
1486 QDateTime dt = mNextMainDateTime.kDateTime().toTimeSpec(mStartDateTime.timeSpec()).dateTime();
1488 dt.toString(mNextMainDateTime.isDateOnly() ?
"yyyyMMdd" :
"yyyyMMddThhmmss"));
1491 initKCalAlarm(ev, 0, QStringList(), MAIN_ALARM);
1492 ancillaryOffset = 0;
1493 ancillaryType = dtMain.isValid() ? 2 : 0;
1495 else if (mRepetition)
1499 const QString param = QString(
"%1:%2").arg(mRepetition.intervalMinutes()).arg(mRepetition.count());
1504 if (mRepeatAtLogin || (mArchiveRepeatAtLogin && archived))
1507 if (mArchiveRepeatAtLogin)
1508 dtl = mStartDateTime.calendarKDateTime().addDays(-1);
1509 else if (mAtLoginDateTime.isValid())
1510 dtl = mAtLoginDateTime;
1511 else if (mStartDateTime.isDateOnly())
1512 dtl = DateTime(KDateTime::currentLocalDate().addDays(-1), mStartDateTime.timeSpec());
1514 dtl = KDateTime::currentUtcDateTime();
1515 initKCalAlarm(ev, dtl, QStringList(AT_LOGIN_TYPE));
1516 if (!ancillaryType && dtl.isValid())
1518 ancillaryTime = dtl;
1524 DateTime nextDateTime = mNextMainDateTime;
1528 nextDateTime = mStartDateTime;
1536 KDateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1537 dt.setDateOnly(mStartDateTime.isDateOnly());
1542 if (mReminderMinutes && (mReminderActive != NO_REMINDER || archived))
1545 if (mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
1548 startOffset = nextDateTime.calendarKDateTime().secsTo(mReminderAfterTime.calendarKDateTime());
1553 startOffset = -mReminderMinutes * 60;
1555 initKCalAlarm(ev, startOffset, QStringList(REMINDER_TYPE));
1557 if (!ancillaryType && (mReminderActive == ACTIVE_REMINDER || archived))
1559 ancillaryOffset = startOffset;
1563 if (mDeferral != NO_DEFERRAL)
1567 if (mDeferralTime.isDateOnly())
1569 startOffset = nextDateTime.secsTo(mDeferralTime.calendarKDateTime());
1570 list += DATE_DEFERRAL_TYPE;
1574 startOffset = nextDateTime.calendarKDateTime().secsTo(mDeferralTime.calendarKDateTime());
1575 list += TIME_DEFERRAL_TYPE;
1577 if (mDeferral == REMINDER_DEFERRAL)
1578 list += REMINDER_TYPE;
1579 initKCalAlarm(ev, startOffset, list);
1580 if (!ancillaryType && mDeferralTime.isValid())
1582 ancillaryOffset = startOffset;
1586 if (!mTemplateName.isEmpty())
1587 ev->setSummary(mTemplateName);
1588 else if (mDisplaying)
1590 QStringList list(DISPLAYING_TYPE);
1591 if (mDisplayingFlags & KAEvent::REPEAT_AT_LOGIN)
1592 list += AT_LOGIN_TYPE;
1593 else if (mDisplayingFlags & DEFERRAL)
1595 if (mDisplayingFlags & TIMED_FLAG)
1596 list += TIME_DEFERRAL_TYPE;
1598 list += DATE_DEFERRAL_TYPE;
1600 if (mDisplayingFlags & REMINDER)
1601 list += REMINDER_TYPE;
1602 initKCalAlarm(ev, mDisplayingTime, list);
1603 if (!ancillaryType && mDisplayingTime.isValid())
1605 ancillaryTime = mDisplayingTime;
1609 if ((mBeep || mSpeak || !mAudioFile.isEmpty()) && mActionSubType !=
KAEvent::AUDIO)
1612 if (ancillaryType == 2)
1613 initKCalAlarm(ev, ancillaryOffset, QStringList(), AUDIO_ALARM);
1615 initKCalAlarm(ev, ancillaryTime, QStringList(), AUDIO_ALARM);
1617 if (!mPreAction.isEmpty())
1620 if (ancillaryType == 2)
1621 initKCalAlarm(ev, ancillaryOffset, QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1623 initKCalAlarm(ev, ancillaryTime, QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1625 if (!mPostAction.isEmpty())
1628 if (ancillaryType == 2)
1629 initKCalAlarm(ev, ancillaryOffset, QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1631 initKCalAlarm(ev, ancillaryTime, QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1635 mRecurrence->writeRecurrence(*ev->recurrence());
1637 ev->clearRecurrence();
1638 if (mCreatedDateTime.isValid())
1639 ev->setCreated(mCreatedDateTime);
1640 ev->setReadOnly(readOnly);
1652 #ifndef KALARMCAL_USE_KRESOURCES
1653 Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1655 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1658 const int startOffset = dt.isDateOnly() ? mStartDateTime.secsTo(dt)
1659 : mStartDateTime.calendarKDateTime().secsTo(dt.calendarKDateTime());
1660 return initKCalAlarm(event, startOffset, types, type);
1663 #ifndef KALARMCAL_USE_KRESOURCES
1664 Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1666 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1669 QStringList alltypes;
1671 #ifndef KALARMCAL_USE_KRESOURCES
1674 Alarm* alarm =
event->newAlarm();
1677 if (type != MAIN_ALARM)
1687 setAudioAlarm(alarm);
1689 flags << KAEventPrivate::SPEAK_FLAG;
1690 if (mRepeatSoundPause >= 0)
1698 case PRE_ACTION_ALARM:
1699 setProcedureAlarm(alarm, mPreAction);
1701 flags << KAEventPrivate::EXEC_ON_DEFERRAL_FLAG;
1703 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
1705 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
1707 case POST_ACTION_ALARM:
1708 setProcedureAlarm(alarm, mPostAction);
1715 QString::number(mNextRepeat));
1717 case REMINDER_ALARM:
1720 if (types == QStringList(REMINDER_TYPE)
1721 && mReminderMinutes < 0 && mReminderActive == HIDDEN_REMINDER)
1725 flags << HIDDEN_REMINDER_FLAG;
1727 bool display =
false;
1728 switch (mActionSubType)
1731 alltypes += FILE_TYPE;
1741 setProcedureAlarm(alarm, mText);
1742 display = mCommandDisplay;
1745 alarm->
setEmailAlarm(mEmailSubject, mText, mEmailAddresses, mEmailAttachments);
1746 if (mEmailFromIdentity)
1747 flags << KAEventPrivate::EMAIL_ID_FLAG << QString::number(mEmailFromIdentity);
1750 setAudioAlarm(alarm);
1751 if (mRepeatSoundPause >= 0)
1753 alltypes += SOUND_REPEAT_TYPE;
1754 if (type == MAIN_ALARM)
1755 alltypes += QString::number(mRepeatSoundPause);
1761 QString::fromLatin1(
"%1;%2;%3").arg(mBgColour.name())
1762 .arg(mFgColour.name())
1763 .arg(mUseDefaultFont ? QString() : mFont.toString()));
1766 case DEFERRED_ALARM:
1767 case DEFERRED_REMINDER_ALARM:
1768 case AT_LOGIN_ALARM:
1769 case DISPLAYING_ALARM:
1773 if (!alltypes.isEmpty())
1775 if (!flags.isEmpty())
1782 return d->mAlarmCount && (d->mAlarmCount != 1 || !d->mRepeatAtLogin);
1787 d->mEnabled = enable;
1795 #ifndef KALARMCAL_USE_KRESOURCES
1803 return d->mReadOnly;
1819 return d->mMainExpired;
1832 KAEvent::Flags KAEventPrivate::flags()
const
1834 KAEvent::Flags result(0);
1838 if (mStartDateTime.isDateOnly()) result |= KAEvent::ANY_TIME;
1869 mEventID = CalEvent::uid(mEventID, s);
1871 mTriggerChanged =
true;
1876 return d->mCategory;
1896 return d->mRevision;
1899 #ifndef KALARMCAL_USE_KRESOURCES
1902 d->mCollectionId =
id;
1907 d->mCollectionId =
id;
1913 return d->mDisplaying ? -1 : d->mCollectionId;
1935 switch (d->mCategory)
1940 default: Q_ASSERT(0);
return false;
1942 if (!collectionMimeTypes.contains(mimetype))
1944 item.setMimeType(mimetype);
1945 item.setPayload<
KAEvent>(*this);
1951 d->mCompatibility = c;
1956 return d->mCompatibility;
1961 return d->mCustomProperties;
1965 void KAEvent::setResource(AlarmResource* r)
1970 AlarmResource* KAEvent::resource()
const
1972 return d->mResource;
1978 return d->mActionSubType;
1983 switch (d->mActionSubType)
1996 if (d->mRepeatAtLogin)
1998 d->mLateCancel = minutes;
2000 d->mAutoClose =
false;
2005 return d->mLateCancel;
2015 return d->mAutoClose;
2018 void KAEvent::setKMailSerialNumber(
unsigned long n)
2020 d->mKMailSerialNumber = n;
2023 unsigned long KAEvent::kmailSerialNumber()
const
2025 return d->mKMailSerialNumber;
2035 return (d->mActionSubType ==
MESSAGE
2036 || d->mActionSubType ==
EMAIL) ? d->mText : QString();
2041 return (d->mActionSubType ==
MESSAGE) ? d->mText : QString();
2046 return (d->mActionSubType ==
FILE) ? d->mText : QString();
2051 return d->mBgColour;
2056 return d->mFgColour;
2061 KAEventPrivate::mDefaultFont = f;
2066 return d->mUseDefaultFont;
2071 return d->mUseDefaultFont ? KAEventPrivate::mDefaultFont : d->mFont;
2076 return (d->mActionSubType ==
COMMAND) ? d->mText : QString();
2081 return d->mCommandScript;
2086 return d->mCommandXterm;
2091 return d->mCommandDisplay;
2094 #ifndef KALARMCAL_USE_KRESOURCES
2097 d->mCommandError = t;
2107 d->setCommandError(t, writeConfig);
2112 kDebug() << mEventID <<
"," << error;
2113 if (error == mCommandError)
2115 mCommandError = error;
2118 KConfigGroup config(KGlobal::config(), mCmdErrConfigGroup);
2120 config.deleteEntry(mEventID);
2124 switch (mCommandError)
2129 case KAEvent::CMD_ERROR_PRE_POST:
2130 errtext = CMD_ERROR_PRE_VALUE +
',' + CMD_ERROR_POST_VALUE;
2135 config.writeEntry(mEventID, errtext);
2146 d->setCommandError(configString);
2149 void KAEventPrivate::setCommandError(
const QString& configString)
2152 const QStringList errs = configString.split(
',');
2153 if (errs.indexOf(CMD_ERROR_VALUE) >= 0)
2157 if (errs.indexOf(CMD_ERROR_PRE_VALUE) >= 0)
2159 if (errs.indexOf(CMD_ERROR_POST_VALUE) >= 0)
2164 QString KAEvent::commandErrorConfigGroup()
2166 return KAEventPrivate::mCmdErrConfigGroup;
2172 return d->mCommandError;
2177 d->mLogFile = logfile;
2178 if (!logfile.isEmpty())
2179 d->mCommandDisplay = d->mCommandXterm =
false;
2189 return d->mConfirmAck;
2194 return d->mCopyToKOrganizer;
2197 #ifndef KALARMCAL_USE_KRESOURCES
2199 const QStringList& attachments)
2201 void KAEvent::setEmail(uint from,
const QList<KCal::Person>& addresses,
const QString& subject,
2202 const QStringList& attachments)
2205 d->mEmailFromIdentity = from;
2206 d->mEmailAddresses = addresses;
2207 d->mEmailSubject = subject;
2208 d->mEmailAttachments = attachments;
2213 return (d->mActionSubType ==
EMAIL) ? d->mText : QString();
2218 return d->mEmailFromIdentity;
2221 #ifndef KALARMCAL_USE_KRESOURCES
2227 return d->mEmailAddresses;
2232 return static_cast<QStringList
>(d->mEmailAddresses);
2237 return d->mEmailAddresses.join(sep);
2240 #ifndef KALARMCAL_USE_KRESOURCES
2246 return EmailAddressList(addresses).join(separator);
2251 return d->mEmailAddresses.pureAddresses();
2256 return d->mEmailAddresses.pureAddresses(sep);
2261 return d->mEmailSubject;
2266 return d->mEmailAttachments;
2271 return d->mEmailAttachments.join(sep);
2276 return d->mEmailBcc;
2279 void KAEvent::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2281 d->setAudioFile(filename, volume, fadeVolume, fadeSeconds, repeatPause, allowEmptyFile);
2284 void KAEventPrivate::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2286 mAudioFile = filename;
2287 mSoundVolume = (!allowEmptyFile && filename.isEmpty()) ? -1 : volume;
2288 if (mSoundVolume >= 0)
2290 mFadeVolume = (fadeSeconds > 0) ? fadeVolume : -1;
2291 mFadeSeconds = (mFadeVolume >= 0) ? fadeSeconds : 0;
2298 mRepeatSoundPause = repeatPause;
2303 return d->mAudioFile;
2308 return d->mSoundVolume;
2313 return d->mSoundVolume >= 0 && d->mFadeSeconds ? d->mFadeVolume : -1;
2318 return d->mSoundVolume >= 0 && d->mFadeVolume >= 0 ? d->mFadeSeconds : 0;
2323 return d->mRepeatSoundPause >= 0;
2328 return d->mRepeatSoundPause;
2338 return (d->mActionSubType ==
MESSAGE
2339 || (d->mActionSubType ==
COMMAND && d->mCommandDisplay))
2349 d->mTemplateName = name;
2350 d->mTemplateAfterTime = afterTime;
2351 d->mTriggerChanged =
true;
2356 return !d->mTemplateName.isEmpty();
2361 return d->mTemplateName;
2366 return d->mTemplateAfterTime == 0;
2371 return d->mTemplateAfterTime;
2376 d->mPreAction = pre;
2377 d->mPostAction = post;
2378 d->mExtraActionOptions = options;
2383 ExtraActionOptions opts(0);
2393 return d->mPreAction;
2398 return d->mPostAction;
2403 return d->mExtraActionOptions;
2422 d->setReminder(minutes, onceOnly);
2425 void KAEventPrivate::setReminder(
int minutes,
bool onceOnly)
2427 if (minutes > 0 && mRepeatAtLogin)
2429 if (minutes != mReminderMinutes || (minutes && mReminderActive != ACTIVE_REMINDER))
2431 if (minutes && mReminderActive == NO_REMINDER)
2433 else if (!minutes && mReminderActive != NO_REMINDER)
2435 mReminderMinutes = minutes;
2436 mReminderActive = minutes ? ACTIVE_REMINDER : NO_REMINDER;
2437 mReminderOnceOnly = onceOnly;
2439 mTriggerChanged =
true;
2449 d->activateReminderAfter(mainAlarmTime);
2452 void KAEventPrivate::activateReminderAfter(
const DateTime& mainAlarmTime)
2454 if (mReminderMinutes >= 0 || mReminderActive == ACTIVE_REMINDER || !mainAlarmTime.
isValid())
2464 || mainAlarmTime != next)
2467 else if (!mRepeatAtLogin)
2470 if (mainAlarmTime != mStartDateTime)
2474 const DateTime reminderTime = mainAlarmTime.
addMins(-mReminderMinutes);
2477 && reminderTime >= next)
2481 activate_reminder(
true);
2482 mReminderAfterTime = reminderTime;
2487 return d->mReminderMinutes;
2492 return d->mReminderActive == KAEventPrivate::ACTIVE_REMINDER;
2497 return d->mReminderOnceOnly;
2502 return d->mDeferral == KAEventPrivate::REMINDER_DEFERRAL;
2513 return d->defer(dt, reminder, adjustRecurrence);
2516 void KAEventPrivate::defer(
const DateTime& dateTime,
bool reminder,
bool adjustRecurrence)
2519 bool setNextRepetition =
false;
2520 bool checkRepetition =
false;
2521 bool checkReminderAfter =
false;
2525 if (mReminderMinutes)
2527 bool deferReminder =
false;
2528 if (mReminderMinutes > 0)
2532 deferReminder =
true;
2533 else if (mReminderActive == ACTIVE_REMINDER || mDeferral == REMINDER_DEFERRAL)
2536 set_deferral(NO_DEFERRAL);
2537 mTriggerChanged =
true;
2540 else if (mReminderMinutes < 0 && reminder)
2541 deferReminder =
true;
2544 set_deferral(REMINDER_DEFERRAL);
2545 mDeferralTime = dateTime;
2546 mTriggerChanged =
true;
2548 if (mReminderActive == ACTIVE_REMINDER)
2550 activate_reminder(
false);
2551 mTriggerChanged =
true;
2554 if (mDeferral != REMINDER_DEFERRAL)
2558 mNextMainDateTime = mDeferralTime = dateTime;
2559 set_deferral(NORMAL_DEFERRAL);
2560 mTriggerChanged =
true;
2561 checkReminderAfter =
true;
2565 mMainExpired =
true;
2570 mArchiveRepeatAtLogin =
true;
2571 mRepeatAtLogin =
false;
2584 set_deferral(NO_DEFERRAL);
2588 set_deferral(REMINDER_DEFERRAL);
2589 mDeferralTime = dateTime;
2590 checkRepetition =
true;
2592 mTriggerChanged =
true;
2597 mDeferralTime = dateTime;
2598 if (mDeferral == NO_DEFERRAL)
2599 set_deferral(NORMAL_DEFERRAL);
2600 mTriggerChanged =
true;
2601 checkReminderAfter =
true;
2602 if (adjustRecurrence)
2604 const KDateTime now = KDateTime::currentUtcDateTime();
2605 if (mainEndRepeatTime() < now)
2611 mMainExpired =
true;
2616 setNextRepetition = mRepetition;
2619 checkRepetition =
true;
2621 if (checkReminderAfter && mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
2625 mReminderActive = (mDeferralTime < mReminderAfterTime) ? ACTIVE_REMINDER : HIDDEN_REMINDER;
2627 if (checkRepetition)
2628 setNextRepetition = (mRepetition && mDeferralTime < mainEndRepeatTime());
2629 if (setNextRepetition)
2633 if (mNextMainDateTime >= mDeferralTime)
2636 mNextRepeat = mRepetition.nextRepeatCount(mNextMainDateTime.kDateTime(), mDeferralTime.kDateTime());
2637 mTriggerChanged =
true;
2650 void KAEventPrivate::cancelDefer()
2652 if (mDeferral != NO_DEFERRAL)
2655 set_deferral(NO_DEFERRAL);
2656 mTriggerChanged =
true;
2662 d->mDeferDefaultMinutes = minutes;
2663 d->mDeferDefaultDateOnly = dateOnly;
2668 return d->mDeferral > 0;
2673 return d->mDeferralTime;
2681 return d->deferralLimit(limitType);
2694 const KDateTime now = KDateTime::currentUtcDateTime();
2700 else if (mReminderActive == ACTIVE_REMINDER && mReminderMinutes > 0
2701 && (now < (reminderTime = endTime.
addMins(-mReminderMinutes))))
2703 endTime = reminderTime;
2709 else if (mReminderMinutes < 0)
2713 if (KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2715 endTime = mNextMainDateTime;
2719 else if (mReminderMinutes > 0
2720 && KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2724 endTime = mNextMainDateTime;
2728 endTime = endTime.
addMins(-1);
2736 return d->mDeferDefaultMinutes;
2741 return d->mDeferDefaultDateOnly;
2746 return d->mStartDateTime;
2751 d->mNextMainDateTime = dt;
2752 d->mTriggerChanged =
true;
2757 return d->mainDateTime(withRepeats);
2762 return d->mNextMainDateTime.effectiveTime();
2767 return d->mainEndRepeatTime();
2777 #warning Does this need all trigger times for date-only alarms to be recalculated?
2788 for (
int i = 0, end = events.count(); i < end; ++i)
2790 KAEventPrivate*
const p = events[i]->d;
2792 p->mRecurrence->setStartDateTime(p->mStartDateTime.effectiveKDateTime(),
true);
2798 d->calcTriggerTimes();
2807 const bool reminderAfter = d->mMainExpired && d->mReminderActive && d->mReminderMinutes < 0;
2809 ? (reminderAfter ? d->mAllWorkTrigger : d->mMainWorkTrigger)
2810 : (reminderAfter ? d->mAllTrigger : d->mMainTrigger);
2818 d->mCreatedDateTime = dt;
2823 return d->mCreatedDateTime;
2831 d->setRepeatAtLogin(rl);
2834 void KAEventPrivate::setRepeatAtLogin(
bool rl)
2836 if (rl && !mRepeatAtLogin)
2838 setRepeatAtLoginTrue(
true);
2841 else if (!rl && mRepeatAtLogin)
2843 mRepeatAtLogin = rl;
2844 mTriggerChanged =
true;
2850 void KAEventPrivate::setRepeatAtLoginTrue(
bool clearReminder)
2853 if (mReminderMinutes >= 0 && clearReminder)
2854 setReminder(0,
false);
2857 mCopyToKOrganizer =
false;
2862 return d->mRepeatAtLogin || (includeArchived && d->mArchiveRepeatAtLogin);
2867 d->mExcludeHolidays = ex ? KAEventPrivate::mHolidays : 0;
2874 return d->mExcludeHolidays;
2886 KAEventPrivate::mHolidays = &h;
2891 d->mWorkTimeOnly = wto;
2898 return d->mWorkTimeOnly;
2907 return d->isWorkingTime(dt);
2910 bool KAEventPrivate::isWorkingTime(
const KDateTime& dt)
const
2912 if ((mWorkTimeOnly && !mWorkDays.testBit(dt.date().dayOfWeek() - 1))
2913 || (mExcludeHolidays && mHolidays && mHolidays->isHoliday(dt.date())))
2917 return dt.isDateOnly()
2918 || (dt.time() >= mWorkDayStart && dt.time() < mWorkDayEnd);
2928 if (days != KAEventPrivate::mWorkDays || start != KAEventPrivate::mWorkDayStart || end != KAEventPrivate::mWorkDayEnd)
2930 KAEventPrivate::mWorkDays = days;
2931 KAEventPrivate::mWorkDayStart = start;
2932 KAEventPrivate::mWorkDayEnd = end;
2933 if (!++KAEventPrivate::mWorkTimeIndex)
2934 ++KAEventPrivate::mWorkTimeIndex;
2946 void KAEventPrivate::clearRecur()
2948 if (mRecurrence || mRepetition)
2952 mRepetition.set(0, 0);
2953 mTriggerChanged =
true;
2964 d->setRecurrence(recurrence);
2967 void KAEventPrivate::setRecurrence(
const KARecurrence& recurrence)
2974 mRecurrence->setStartDateTime(mStartDateTime.effectiveKDateTime(), mStartDateTime.isDateOnly());
2975 mTriggerChanged =
true;
2980 mTriggerChanged =
true;
2985 setRepetition(mRepetition);
3002 const bool success = d->setRecur(RecurrenceRule::rMinutely, freq, count, end);
3003 d->mTriggerChanged =
true;
3020 const bool success = d->setRecur(RecurrenceRule::rDaily, freq, count, end);
3024 for (
int i = 0; i < 7; ++i)
3026 if (days.testBit(i))
3030 d->mRecurrence->addWeeklyDays(days);
3032 d->mTriggerChanged =
true;
3049 const bool success = d->setRecur(RecurrenceRule::rWeekly, freq, count, end);
3051 d->mRecurrence->addWeeklyDays(days);
3052 d->mTriggerChanged =
true;
3069 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3072 for (
int i = 0, end = days.count(); i < end; ++i)
3073 d->mRecurrence->addMonthlyDate(days[i]);
3075 d->mTriggerChanged =
true;
3093 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3096 for (
int i = 0, end = posns.count(); i < end; ++i)
3097 d->mRecurrence->addMonthlyPos(posns[i].weeknum, posns[i].days);
3099 d->mTriggerChanged =
true;
3119 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end, feb29);
3122 for (
int i = 0, end = months.count(); i < end; ++i)
3123 d->mRecurrence->addYearlyMonth(months[i]);
3125 d->mRecurrence->addMonthlyDate(day);
3127 d->mTriggerChanged =
true;
3146 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end);
3151 for (iend = months.count(); i < iend; ++i)
3152 d->mRecurrence->addYearlyMonth(months[i]);
3153 for (i = 0, iend = posns.count(); i < iend; ++i)
3154 d->mRecurrence->addYearlyPos(posns[i].weeknum, posns[i].days);
3156 d->mTriggerChanged =
true;
3172 KDateTime edt = mNextMainDateTime.kDateTime();
3174 return setRecur(recurType, freq, count, edt, feb29);
3178 if (count >= -1 && (count || end.date().isValid()))
3181 mRecurrence =
new KARecurrence;
3182 if (mRecurrence->init(recurType, freq, count, mNextMainDateTime.kDateTime(), end, feb29))
3196 return d->checkRecur();
3201 return d->mRecurrence;
3211 switch (d->mRecurrence->type())
3220 return d->mRecurrence->frequency();
3230 return d->mRecurrence ? d->mRecurrence->longestInterval() :
Duration(0);
3240 d->setFirstRecurrence();
3243 void KAEventPrivate::setFirstRecurrence()
3245 switch (checkRecur())
3252 if (mRecurrence->yearMonths().isEmpty())
3261 const KDateTime recurStart = mRecurrence->startDateTime();
3262 if (mRecurrence->recursOn(recurStart.date(), recurStart.timeSpec()))
3266 const int frequency = mRecurrence->frequency();
3267 mRecurrence->setFrequency(1);
3269 nextRecurrence(mNextMainDateTime.effectiveKDateTime(), next);
3270 if (!next.isValid())
3271 mRecurrence->setStartDateTime(recurStart, mStartDateTime.isDateOnly());
3274 mRecurrence->setStartDateTime(next.effectiveKDateTime(), next.isDateOnly());
3275 mStartDateTime = mNextMainDateTime = next;
3276 mTriggerChanged =
true;
3278 mRecurrence->setFrequency(frequency);
3286 if (d->mRepeatAtLogin)
3287 return brief ? i18nc(
"@info/plain Brief form of 'At Login'",
"Login") : i18nc(
"@info/plain",
"At login");
3290 const int frequency = d->mRecurrence->frequency();
3291 switch (d->mRecurrence->defaultRRuleConst()->recurrenceType())
3293 case RecurrenceRule::rMinutely:
3295 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", frequency);
3296 else if (frequency % 60 == 0)
3297 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", frequency/60);
3301 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", frequency/60, mins.sprintf(
"%02d", frequency%60));
3303 case RecurrenceRule::rDaily:
3304 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", frequency);
3305 case RecurrenceRule::rWeekly:
3306 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", frequency);
3307 case RecurrenceRule::rMonthly:
3308 return i18ncp(
"@info/plain",
"1 Month",
"%1 Months", frequency);
3309 case RecurrenceRule::rYearly:
3310 return i18ncp(
"@info/plain",
"1 Year",
"%1 Years", frequency);
3311 case RecurrenceRule::rNone:
3316 return brief ? QString() : i18nc(
"@info/plain No recurrence",
"None");
3327 return d->setRepetition(r);
3330 bool KAEventPrivate::setRepetition(
const Repetition& repetition)
3335 if (repetition && !mRepeatAtLogin)
3338 if (!repetition.
isDaily() && mStartDateTime.isDateOnly())
3340 mRepetition.set(0, 0);
3343 Duration longestInterval = mRecurrence->longestInterval();
3344 if (repetition.
duration() >= longestInterval)
3346 const int count = mStartDateTime.isDateOnly()
3349 mRepetition.set(repetition.
interval(), count);
3352 mRepetition = repetition;
3353 mTriggerChanged =
true;
3355 else if (mRepetition)
3357 mRepetition.
set(0, 0);
3358 mTriggerChanged =
true;
3365 return d->mRepetition;
3370 return d->mNextRepeat;
3380 if (!d->mRepetition.isDaily())
3382 const int minutes = d->mRepetition.intervalMinutes();
3384 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", minutes);
3385 if (minutes % 60 == 0)
3386 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", minutes/60);
3388 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", minutes/60, mins.sprintf(
"%02d", minutes%60));
3390 const int days = d->mRepetition.intervalDays();
3392 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", days);
3393 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", days / 7);
3395 return brief ? QString() : i18nc(
"@info/plain No repetition",
"None");
3405 return d->occursAfter(preDateTime, includeRepetitions);
3408 bool KAEventPrivate::occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const
3413 if (mRecurrence->duration() < 0)
3415 dt = mRecurrence->endDateTime();
3418 dt = mNextMainDateTime.effectiveKDateTime();
3419 if (mStartDateTime.isDateOnly())
3421 QDate pre = preDateTime.date();
3423 pre = pre.addDays(-1);
3424 if (pre < dt.date())
3427 else if (preDateTime < dt)
3430 if (includeRepetitions && mRepetition)
3432 if (preDateTime < mRepetition.duration().end(dt))
3448 return d->setNextOccurrence(preDateTime);
3453 if (preDateTime < mNextMainDateTime.effectiveKDateTime())
3455 KDateTime pre = preDateTime;
3460 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3464 if (pre < mNextMainDateTime.effectiveKDateTime())
3466 afterPre = mNextMainDateTime;
3471 type = nextRecurrence(pre, afterPre);
3477 mNextMainDateTime = afterPre;
3478 if (mReminderMinutes > 0 && (mDeferral == REMINDER_DEFERRAL || mReminderActive != ACTIVE_REMINDER))
3482 activate_reminder(!mReminderOnceOnly);
3484 if (mDeferral == REMINDER_DEFERRAL)
3485 set_deferral(NO_DEFERRAL);
3486 mTriggerChanged =
true;
3494 if (afterPre <= preDateTime)
3498 mNextRepeat = mRepetition.nextRepeatCount(afterPre.
effectiveKDateTime(), preDateTime);
3500 activate_reminder(
false);
3501 if (mDeferral == REMINDER_DEFERRAL)
3502 set_deferral(NO_DEFERRAL);
3503 mTriggerChanged =
true;
3505 else if (mNextRepeat)
3509 mTriggerChanged =
true;
3522 return d->nextOccurrence(preDateTime, result, o);
3528 KDateTime pre = preDateTime;
3534 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3540 type = nextRecurrence(pre, result);
3541 else if (pre < mNextMainDateTime.effectiveKDateTime())
3543 result = mNextMainDateTime;
3548 result = DateTime();
3556 const DateTime repeatDT = mRepetition.duration(repetition).end(result.
kDateTime());
3564 const KAEvent::OccurType newType = previousOccurrence(repeatDT.effectiveKDateTime(), dt,
false);
3572 repetition = mRepetition.nextRepeatCount(result.
kDateTime(), preDateTime);
3573 result = mRepetition.duration(repetition).end(result.
kDateTime());
3598 return d->previousOccurrence(afterDateTime, result, includeRepetitions);
3602 bool includeRepetitions)
const
3604 Q_ASSERT(!afterDateTime.isDateOnly());
3605 if (mStartDateTime >= afterDateTime)
3607 result = KDateTime();
3615 result = mStartDateTime;
3620 const KDateTime recurStart = mRecurrence->startDateTime();
3621 KDateTime after = afterDateTime.toTimeSpec(mStartDateTime.timeSpec());
3623 after = after.addDays(1);
3624 const KDateTime dt = mRecurrence->getPreviousDateTime(after);
3629 if (dt == recurStart)
3631 else if (mRecurrence->getNextDateTime(dt).isValid())
3637 if (includeRepetitions && mRepetition)
3640 const int repetition = mRepetition.previousRepeatCount(result.
effectiveKDateTime(), afterDateTime);
3643 result = mRepetition.duration(qMin(repetition, mRepetition.count())).end(result.
kDateTime());
3659 #ifndef KALARMCAL_USE_KRESOURCES
3665 return d->setDisplaying(*e.d, t,
id, dt, showEdit, showDefer);
3668 #ifndef KALARMCAL_USE_KRESOURCES
3670 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3672 bool KAEventPrivate::setDisplaying(
const KAEventPrivate& event,
KAAlarm::Type alarmType,
const QString& resourceID,
3673 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3684 KAAlarm al =
event.alarm(alarmType);
3690 #ifndef KALARMCAL_USE_KRESOURCES
3692 mCollectionId = collectionId;
3694 mOriginalResourceId = resourceID;
3696 mDisplayingDefer = showDefer;
3697 mDisplayingEdit = showEdit;
3706 default: mDisplayingFlags = 0;
break;
3718 #ifndef KALARMCAL_USE_KRESOURCES
3724 d->reinstateFromDisplaying(e,
id, showEdit, showDefer);
3727 #ifndef KALARMCAL_USE_KRESOURCES
3730 void KAEventPrivate::reinstateFromDisplaying(
const Event* kcalEvent, QString& resourceID,
bool& showEdit,
bool& showDefer)
3738 #ifndef KALARMCAL_USE_KRESOURCES
3739 collectionId = mCollectionId;
3742 resourceID = mOriginalResourceId;
3743 mOriginalResourceId.clear();
3745 showDefer = mDisplayingDefer;
3746 showEdit = mDisplayingEdit;
3747 mDisplaying =
false;
3761 KAAlarm::Private*
const al_d = al.d;
3762 const int displayingFlags = d->mDisplayingFlags;
3765 al_d->mRepeatAtLogin =
true;
3768 else if (displayingFlags & KAEventPrivate::DEFERRAL)
3770 al_d->mDeferred =
true;
3771 al_d->mTimedDeferral = (displayingFlags & KAEventPrivate::TIMED_FLAG);
3774 else if (displayingFlags & KAEventPrivate::REMINDER)
3783 return d->mDisplaying;
3798 KAAlarm::Private*
const al_d = al.d;
3802 al_d->mRepeatAtLogin =
false;
3803 al_d->mDeferred =
false;
3810 al_d->mNextMainDateTime = mNextMainDateTime;
3811 al_d->mRepetition = mRepetition;
3812 al_d->mNextRepeat = mNextRepeat;
3816 if (mReminderActive == ACTIVE_REMINDER)
3819 if (mReminderMinutes < 0)
3820 al_d->mNextMainDateTime = mReminderAfterTime;
3821 else if (mReminderOnceOnly)
3822 al_d->mNextMainDateTime = mStartDateTime.addMins(-mReminderMinutes);
3824 al_d->mNextMainDateTime = mNextMainDateTime.addMins(-mReminderMinutes);
3828 if (mDeferral != REMINDER_DEFERRAL)
3832 if (mDeferral != NO_DEFERRAL)
3835 al_d->mNextMainDateTime = mDeferralTime;
3836 al_d->mDeferred =
true;
3837 al_d->mTimedDeferral = !mDeferralTime.isDateOnly();
3844 al_d->mNextMainDateTime = mAtLoginDateTime;
3845 al_d->mRepeatAtLogin =
true;
3852 al_d->mNextMainDateTime = mDisplayingTime;
3872 return d->firstAlarm();
3875 KAAlarm KAEventPrivate::firstAlarm()
const
3893 return d->nextAlarm(previousAlarm.
type());
3898 return d->nextAlarm(previousType);
3903 switch (previousType)
3906 if (mReminderActive == ACTIVE_REMINDER)
3911 if (mDeferral == REMINDER_DEFERRAL)
3913 if (mDeferral == NORMAL_DEFERRAL)
3936 return d->mAlarmCount;
3946 d->removeExpiredAlarm(type);
3951 const int count = mAlarmCount;
3955 if (!mReminderActive || mReminderMinutes > 0)
3962 mMainExpired =
true;
3964 set_deferral(NO_DEFERRAL);
3967 mDisplaying =
false;
3975 mArchiveRepeatAtLogin =
true;
3976 mRepeatAtLogin =
false;
3983 activate_reminder(
false);
3987 set_deferral(NO_DEFERRAL);
3992 mDisplaying =
false;
4000 if (mAlarmCount != count)
4001 mTriggerChanged =
true;
4018 void KAEventPrivate::endChanges()
4020 if (mChangeCount > 0)
4024 #ifndef KALARMCAL_USE_KRESOURCES
4031 for (
int i = 0, count = objList.count(); i < count; ++i)
4032 ptrs += &objList[i];
4039 #ifndef KDE_NO_DEBUG_OUTPUT
4044 #ifndef KDE_NO_DEBUG_OUTPUT
4045 void KAEventPrivate::dumpDebug()
const
4047 kDebug() <<
"KAEvent dump:";
4048 #ifdef KALARMCAL_USE_KRESOURCES
4049 if (mResource) { kDebug() <<
"-- mResource:" << (
void*)mResource; }
4051 kDebug() <<
"-- mEventID:" << mEventID;
4053 kDebug() <<
"-- mNextMainDateTime:" << mNextMainDateTime.toString();
4054 kDebug() <<
"-- mCommandError:" << mCommandError;
4055 kDebug() <<
"-- mAllTrigger:" << mAllTrigger.toString();
4056 kDebug() <<
"-- mMainTrigger:" << mMainTrigger.toString();
4057 kDebug() <<
"-- mAllWorkTrigger:" << mAllWorkTrigger.toString();
4058 kDebug() <<
"-- mMainWorkTrigger:" << mMainWorkTrigger.toString();
4059 kDebug() <<
"-- mCategory:" << mCategory;
4060 if (!mTemplateName.isEmpty())
4062 kDebug() <<
"-- mTemplateName:" << mTemplateName;
4063 kDebug() <<
"-- mTemplateAfterTime:" << mTemplateAfterTime;
4065 kDebug() <<
"-- mText:" << mText;
4068 kDebug() <<
"-- mBgColour:" << mBgColour.name();
4069 kDebug() <<
"-- mFgColour:" << mFgColour.name();
4070 kDebug() <<
"-- mUseDefaultFont:" << mUseDefaultFont;
4071 if (!mUseDefaultFont)
4072 kDebug() <<
"-- mFont:" << mFont.toString();
4073 kDebug() <<
"-- mSpeak:" << mSpeak;
4074 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4075 kDebug() <<
"-- mPreAction:" << mPreAction;
4079 kDebug() <<
"-- mPostAction:" << mPostAction;
4080 kDebug() <<
"-- mLateCancel:" << mLateCancel;
4081 kDebug() <<
"-- mAutoClose:" << mAutoClose;
4085 kDebug() <<
"-- mCommandScript:" << mCommandScript;
4086 kDebug() <<
"-- mCommandXterm:" << mCommandXterm;
4087 kDebug() <<
"-- mCommandDisplay:" << mCommandDisplay;
4088 kDebug() <<
"-- mLogFile:" << mLogFile;
4092 kDebug() <<
"-- mEmail: FromKMail:" << mEmailFromIdentity;
4093 kDebug() <<
"-- Addresses:" << mEmailAddresses.join(
",");
4094 kDebug() <<
"-- Subject:" << mEmailSubject;
4095 kDebug() <<
"-- Attachments:" << mEmailAttachments.join(
",");
4096 kDebug() <<
"-- Bcc:" << mEmailBcc;
4099 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4100 kDebug() <<
"-- mBeep:" << mBeep;
4103 if (mSoundVolume >= 0)
4105 kDebug() <<
"-- mSoundVolume:" << mSoundVolume;
4106 if (mFadeVolume >= 0)
4108 kDebug() <<
"-- mFadeVolume:" << mFadeVolume;
4109 kDebug() <<
"-- mFadeSeconds:" << mFadeSeconds;
4112 kDebug() <<
"-- mFadeVolume:-:";
4115 kDebug() <<
"-- mSoundVolume:-:";
4116 kDebug() <<
"-- mRepeatSoundPause:" << mRepeatSoundPause;
4118 kDebug() <<
"-- mKMailSerialNumber:" << mKMailSerialNumber;
4119 kDebug() <<
"-- mCopyToKOrganizer:" << mCopyToKOrganizer;
4120 kDebug() <<
"-- mExcludeHolidays:" << (bool)mExcludeHolidays;
4121 kDebug() <<
"-- mWorkTimeOnly:" << mWorkTimeOnly;
4122 kDebug() <<
"-- mStartDateTime:" << mStartDateTime.toString();
4123 kDebug() <<
"-- mCreatedDateTime:" << mCreatedDateTime;
4124 kDebug() <<
"-- mRepeatAtLogin:" << mRepeatAtLogin;
4126 kDebug() <<
"-- mAtLoginDateTime:" << mAtLoginDateTime;
4127 kDebug() <<
"-- mArchiveRepeatAtLogin:" << mArchiveRepeatAtLogin;
4128 kDebug() <<
"-- mConfirmAck:" << mConfirmAck;
4129 kDebug() <<
"-- mEnabled:" << mEnabled;
4130 #ifndef KALARMCAL_USE_KRESOURCES
4131 kDebug() <<
"-- mItemId:" << mItemId;
4132 kDebug() <<
"-- mCollectionId:" << mCollectionId;
4133 kDebug() <<
"-- mCompatibility:" << mCompatibility;
4134 kDebug() <<
"-- mReadOnly:" << mReadOnly;
4136 if (mReminderMinutes)
4138 kDebug() <<
"-- mReminderMinutes:" << mReminderMinutes;
4139 kDebug() <<
"-- mReminderActive:" << (mReminderActive == ACTIVE_REMINDER ?
"active" : mReminderActive == HIDDEN_REMINDER ?
"hidden" :
"no");
4140 kDebug() <<
"-- mReminderOnceOnly:" << mReminderOnceOnly;
4142 else if (mDeferral > 0)
4144 kDebug() <<
"-- mDeferral:" << (mDeferral == NORMAL_DEFERRAL ?
"normal" :
"reminder");
4145 kDebug() <<
"-- mDeferralTime:" << mDeferralTime.toString();
4147 kDebug() <<
"-- mDeferDefaultMinutes:" << mDeferDefaultMinutes;
4148 if (mDeferDefaultMinutes)
4149 kDebug() <<
"-- mDeferDefaultDateOnly:" << mDeferDefaultDateOnly;
4152 kDebug() <<
"-- mDisplayingTime:" << mDisplayingTime.toString();
4153 kDebug() <<
"-- mDisplayingFlags:" << mDisplayingFlags;
4154 kDebug() <<
"-- mDisplayingDefer:" << mDisplayingDefer;
4155 kDebug() <<
"-- mDisplayingEdit:" << mDisplayingEdit;
4157 kDebug() <<
"-- mRevision:" << mRevision;
4158 kDebug() <<
"-- mRecurrence:" << mRecurrence;
4160 kDebug() <<
"-- mRepetition: 0";
4161 else if (mRepetition.isDaily())
4162 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalDays() <<
"days";
4164 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalMinutes() <<
"minutes";
4165 kDebug() <<
"-- mNextRepeat:" << mNextRepeat;
4166 kDebug() <<
"-- mAlarmCount:" << mAlarmCount;
4167 kDebug() <<
"-- mMainExpired:" << mMainExpired;
4168 kDebug() <<
"-- mDisplaying:" << mDisplaying;
4169 kDebug() <<
"KAEvent dump end";
4178 #ifndef KALARMCAL_USE_KRESOURCES
4179 DateTime KAEventPrivate::readDateTime(
const Event::Ptr& event,
bool dateOnly, DateTime& start)
4181 DateTime KAEventPrivate::readDateTime(
const Event* event,
bool dateOnly, DateTime& start)
4184 start =
event->dtStart();
4189 start.setDateOnly(
true);
4191 DateTime next = start;
4192 const QString prop =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::NEXT_RECUR_PROPERTY);
4193 if (prop.length() >= 8)
4196 const QDate d(prop.left(4).toInt(), prop.mid(4,2).toInt(), prop.mid(6,2).toInt());
4199 if (dateOnly && prop.length() == 8)
4201 else if (!dateOnly && prop.length() == 15 && prop[8] == QChar(
'T'))
4203 const QTime t(prop.mid(9,2).toInt(), prop.mid(11,2).toInt(), prop.mid(13,2).toInt());
4221 #ifndef KALARMCAL_USE_KRESOURCES
4222 void KAEventPrivate::readAlarms(
const Event::Ptr& event,
void* almap,
bool cmdDisplay)
4224 void KAEventPrivate::readAlarms(
const Event* event,
void* almap,
bool cmdDisplay)
4227 AlarmMap* alarmMap = (AlarmMap*)almap;
4231 bool audioOnly =
false;
4232 for (
int i = 0, end = alarms.count(); i < end; ++i)
4234 switch (alarms[i]->type())
4236 case Alarm::Display:
4237 case Alarm::Procedure:
4249 for (
int i = 0, end = alarms.count(); i < end; ++i)
4253 readAlarm(alarms[i], data, audioOnly, cmdDisplay);
4254 if (data.type != INVALID_ALARM)
4255 alarmMap->insert(data.type, data);
4264 #ifndef KALARMCAL_USE_KRESOURCES
4265 void KAEventPrivate::readAlarm(
const Alarm::Ptr& alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4267 void KAEventPrivate::readAlarm(
const Alarm* alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4272 data.displayingFlags = 0;
4273 data.isEmailText =
false;
4275 data.hiddenReminder =
false;
4276 data.timedDeferral =
false;
4277 data.nextRepeat = 0;
4278 data.repeatSoundPause = -1;
4283 int n =
static_cast<int>(
property.toUInt(&ok));
4285 data.nextRepeat = n;
4288 const QStringList flags =
property.split(KAEventPrivate::SC, QString::SkipEmptyParts);
4289 switch (alarm->
type())
4291 case Alarm::Procedure:
4294 data.commandScript = data.cleanText.isEmpty();
4297 if (!data.commandScript)
4298 data.cleanText +=
' ';
4301 data.extraActionOptions = 0;
4302 if (flags.contains(KAEventPrivate::EXEC_ON_DEFERRAL_FLAG))
4303 data.extraActionOptions |= KAEvent::ExecPreActOnDeferral;
4304 if (flags.contains(KAEventPrivate::CANCEL_ON_ERROR_FLAG))
4305 data.extraActionOptions |= KAEvent::CancelOnPreActError;
4306 if (flags.contains(KAEventPrivate::DONT_SHOW_ERROR_FLAG))
4307 data.extraActionOptions |= KAEvent::DontShowPreActError;
4311 case Alarm::Display:
4313 if (alarm->
type() == Alarm::Display)
4319 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
4320 data.bgColour = QColor(255, 255, 255);
4321 data.fgColour = QColor(0, 0, 0);
4322 const int n = list.count();
4325 if (!list[0].isEmpty())
4331 if (n > 1 && !list[1].isEmpty())
4338 data.defaultFont = (n <= 2 || list[2].isEmpty());
4339 if (!data.defaultFont)
4340 data.font.fromString(list[2]);
4346 data.cleanText = alarm->
mailText();
4347 const int i = flags.indexOf(KAEventPrivate::EMAIL_ID_FLAG);
4348 data.emailFromId = (i >= 0 && i + 1 < flags.count()) ? flags[i + 1].toUInt() : 0;
4357 data.soundVolume = -1;
4358 data.fadeVolume = -1;
4359 data.fadeSeconds = 0;
4361 if (!property.isEmpty())
4366 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
4367 data.soundVolume = list[0].toFloat(&ok);
4368 if (!ok || data.soundVolume > 1.0f)
4369 data.soundVolume = -1;
4370 if (data.soundVolume >= 0 && list.count() >= 3)
4372 fadeVolume = list[1].toFloat(&ok);
4374 fadeSecs =
static_cast<int>(list[2].toUInt(&ok));
4375 if (ok && fadeVolume >= 0 && fadeVolume <= 1.0f && fadeSecs > 0)
4377 data.fadeVolume = fadeVolume;
4378 data.fadeSeconds = fadeSecs;
4384 data.type = AUDIO_ALARM;
4385 data.speak = flags.contains(KAEventPrivate::SPEAK_FLAG);
4390 case Alarm::Invalid:
4391 data.type = INVALID_ALARM;
4395 bool atLogin =
false;
4396 bool reminder =
false;
4397 bool deferral =
false;
4398 bool dateDeferral =
false;
4399 bool repeatSound =
false;
4400 data.type = MAIN_ALARM;
4402 const QStringList
types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
4403 for (
int i = 0, end = types.count(); i < end; ++i)
4405 const QString type = types[i];
4406 if (type == KAEventPrivate::AT_LOGIN_TYPE)
4408 else if (type == KAEventPrivate::FILE_TYPE && data.action ==
KAAlarm::MESSAGE)
4410 else if (type == KAEventPrivate::REMINDER_TYPE)
4412 else if (type == KAEventPrivate::TIME_DEFERRAL_TYPE)
4414 else if (type == KAEventPrivate::DATE_DEFERRAL_TYPE)
4415 dateDeferral = deferral =
true;
4416 else if (type == KAEventPrivate::DISPLAYING_TYPE)
4417 data.type = DISPLAYING_ALARM;
4418 else if (type == KAEventPrivate::PRE_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4419 data.type = PRE_ACTION_ALARM;
4420 else if (type == KAEventPrivate::POST_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4421 data.type = POST_ACTION_ALARM;
4422 else if (type == KAEventPrivate::SOUND_REPEAT_TYPE && data.action ==
KAAlarm::AUDIO)
4428 uint n = types[i + 1].toUInt(&ok);
4431 data.repeatSoundPause = n;
4437 if (repeatSound && data.repeatSoundPause < 0)
4438 data.repeatSoundPause = 0;
4439 else if (!repeatSound)
4440 data.repeatSoundPause = -1;
4444 if (data.type == MAIN_ALARM)
4446 data.type = deferral ? DEFERRED_REMINDER_ALARM : REMINDER_ALARM;
4447 data.timedDeferral = (deferral && !dateDeferral);
4449 else if (data.type == DISPLAYING_ALARM)
4450 data.displayingFlags = dateDeferral ? REMINDER | DATE_DEFERRAL
4451 : deferral ? REMINDER | TIME_DEFERRAL : REMINDER;
4452 else if (data.type == REMINDER_ALARM
4453 && flags.contains(KAEventPrivate::HIDDEN_REMINDER_FLAG))
4454 data.hiddenReminder =
true;
4458 if (data.type == MAIN_ALARM)
4460 data.type = DEFERRED_ALARM;
4461 data.timedDeferral = !dateDeferral;
4463 else if (data.type == DISPLAYING_ALARM)
4464 data.displayingFlags = dateDeferral ? DATE_DEFERRAL : TIME_DEFERRAL;
4468 if (data.type == MAIN_ALARM)
4469 data.type = AT_LOGIN_ALARM;
4470 else if (data.type == DISPLAYING_ALARM)
4487 void KAEventPrivate::calcTriggerTimes()
const
4492 #warning May need to set date-only alarms to after start-of-day time in working-time checks
4495 if ((recurs && mWorkTimeOnly && mWorkTimeOnly != mWorkTimeIndex)
4496 || (recurs && mExcludeHolidays && mExcludeHolidays != mHolidays))
4500 mTriggerChanged =
true;
4502 else if (!mTriggerChanged)
4504 mTriggerChanged =
false;
4505 if (recurs && mWorkTimeOnly)
4506 mWorkTimeOnly = mWorkTimeIndex;
4507 if (recurs && mExcludeHolidays)
4508 mExcludeHolidays = mHolidays;
4513 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = KDateTime();
4515 else if (mDeferral == NORMAL_DEFERRAL)
4518 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = mDeferralTime;
4522 mMainTrigger = mainDateTime(
true);
4523 mAllTrigger = (mDeferral == REMINDER_DEFERRAL) ? mDeferralTime
4524 : (mReminderActive != ACTIVE_REMINDER) ? mMainTrigger
4525 : (mReminderMinutes < 0) ? mReminderAfterTime
4526 : mMainTrigger.addMins(-mReminderMinutes);
4530 if ((!mWorkTimeOnly && !mExcludeHolidays)
4532 || isWorkingTime(mMainTrigger.kDateTime()))
4536 mMainWorkTrigger = mMainTrigger;
4537 mAllWorkTrigger = mAllTrigger;
4539 else if (mWorkTimeOnly)
4545 if (!mExcludeHolidays)
4548 calcNextWorkingTime(mMainTrigger);
4553 DateTime nextTrigger = mMainTrigger;
4555 for (
int i = 0; i < 20; ++i)
4557 calcNextWorkingTime(nextTrigger);
4558 if (!mHolidays->isHoliday(mMainWorkTrigger.date()))
4560 kdt = mMainWorkTrigger.effectiveKDateTime();
4561 kdt.setTime(QTime(23,59,59));
4563 if (!nextTrigger.isValid())
4565 if (isWorkingTime(nextTrigger.kDateTime()))
4567 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4568 mMainWorkTrigger = nextTrigger;
4573 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4576 else if (mExcludeHolidays && mHolidays)
4579 DateTime nextTrigger = mMainTrigger;
4581 for (
int i = 0; i < 20; ++i)
4583 kdt = nextTrigger.effectiveKDateTime();
4584 kdt.setTime(QTime(23,59,59));
4586 if (!nextTrigger.isValid())
4588 if (!mHolidays->isHoliday(nextTrigger.date()))
4590 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4591 mMainWorkTrigger = nextTrigger;
4596 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4607 void KAEventPrivate::calcNextWorkingTime(
const DateTime& nextTrigger)
const
4609 kDebug() <<
"next=" << nextTrigger.kDateTime().dateTime();
4610 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4612 for (
int i = 0; ; ++i)
4616 if (mWorkDays.testBit(i))
4620 KDateTime kdt = nextTrigger.effectiveKDateTime();
4621 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4626 unsigned allDaysMask = 0x7F;
4627 bool noWorkPos =
false;
4628 const QList<RecurrenceRule::WDayPos> pos = rrule->byDays();
4629 const int nDayPos = pos.count();
4634 for (
int i = 0; i < nDayPos; ++i)
4636 const int day = pos[i].day() - 1;
4637 if (mWorkDays.testBit(day))
4639 allDaysMask |= 1 << day;
4641 if (noWorkPos && !mRepetition)
4646 if (mStartDateTime.isDateOnly())
4650 const int repeatFreq = mRepetition.intervalDays();
4651 const bool weeklyRepeat = mRepetition && !(repeatFreq % 7);
4652 const Duration interval = mRecurrence->regularInterval();
4653 if ((interval && !(interval.
asDays() % 7))
4657 if (!mRepetition || weeklyRepeat)
4663 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4664 dt.setTime(QTime(0,0,0));
4665 previousOccurrence(dt, newdt,
false);
4666 if (!newdt.isValid())
4668 kdt = newdt.effectiveKDateTime();
4669 const int day = kdt.date().dayOfWeek() - 1;
4670 for (
int repeatNum = mNextRepeat + 1; ; ++repeatNum)
4672 if (repeatNum > mRepetition.count())
4674 if (repeatNum == mNextRepeat)
4679 if (mWorkDays.testBit(day))
4681 mMainWorkTrigger = newdt;
4682 mAllWorkTrigger = mMainWorkTrigger.addMins(-reminder);
4685 kdt = newdt.effectiveKDateTime();
4689 const int inc = repeatFreq * repeatNum;
4690 if (mWorkDays.testBit((day + inc) % 7))
4692 kdt = kdt.addDays(inc);
4693 kdt.setDateOnly(
true);
4694 mMainWorkTrigger = mAllWorkTrigger = kdt;
4701 if (!mRepetition || weeklyRepeat)
4709 kdt.setTime(QTime(23,59,59));
4711 if (!newdt.isValid())
4713 kdt = newdt.effectiveKDateTime();
4714 const int day = kdt.date().dayOfWeek() - 1;
4715 if (mWorkDays.testBit(day))
4718 if ((days & allDaysMask) == allDaysMask)
4722 kdt.setDateOnly(
true);
4723 mMainWorkTrigger = kdt;
4724 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4731 unsigned days = 1 << (kdt.date().dayOfWeek() - 1);
4732 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4733 dt.setTime(QTime(0,0,0));
4734 previousOccurrence(dt, newdt,
false);
4735 if (!newdt.isValid())
4737 kdt = newdt.effectiveKDateTime();
4738 int day = kdt.date().dayOfWeek() - 1;
4739 for (
int repeatNum = mNextRepeat; ; repeatNum = 0)
4741 while (++repeatNum <= mRepetition.count())
4743 const int inc = repeatFreq * repeatNum;
4744 if (mWorkDays.testBit((day + inc) % 7))
4746 kdt = kdt.addDays(inc);
4747 kdt.setDateOnly(
true);
4748 mMainWorkTrigger = mAllWorkTrigger = kdt;
4751 if ((days & allDaysMask) == allDaysMask)
4756 if (!newdt.isValid())
4758 kdt = newdt.effectiveKDateTime();
4759 day = kdt.date().dayOfWeek() - 1;
4760 if (mWorkDays.testBit(day))
4762 kdt.setDateOnly(
true);
4763 mMainWorkTrigger = kdt;
4764 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4767 if ((days & allDaysMask) == allDaysMask)
4785 const bool repeatTimeVaries = (mRepetition && !mRepetition.isDaily());
4787 if (!recurTimeVaries && !repeatTimeVaries)
4791 if (!mayOccurDailyDuringWork(kdt))
4795 bool repetition =
false;
4800 if (!newdt.isValid())
4803 kdt = newdt.effectiveKDateTime();
4804 const int day = kdt.date().dayOfWeek() - 1;
4805 if (mWorkDays.testBit(day))
4810 if ((days & allDaysMask) == allDaysMask)
4815 mMainWorkTrigger = nextTrigger;
4816 mMainWorkTrigger.setDate(kdt.date());
4817 mAllWorkTrigger = repetition ? mMainWorkTrigger : mMainWorkTrigger.addMins(-reminder);
4824 KTimeZone tz = kdt.timeZone();
4825 if (tz.isValid() && tz.type() ==
"KSystemTimeZone")
4828 const KTimeZone ktz = KSystemTimeZones::readZone(tz.name());
4832 const QList<KTimeZone::Transition> tzTransitions = tz.transitions();
4834 if (recurTimeVaries)
4853 repeatFreq = mRepetition.intervalSeconds();
4854 previousOccurrence(kdt.addSecs(1), newdt,
false);
4855 if (!newdt.isValid())
4857 kdtRecur = newdt.effectiveKDateTime();
4858 repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4859 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
4873 QTime firstTime = kdtRecur.time();
4874 int firstOffset = kdtRecur.utcOffset();
4875 int currentOffset = firstOffset;
4876 int dayRecur = kdtRecur.date().dayOfWeek() - 1;
4877 int firstDay = dayRecur;
4879 const bool subdaily = (repeatFreq < 24*3600);
4882 int transitionIndex = -1;
4883 for (
int n = 0; n < 7*24*60; ++n)
4891 const int inc = subdaily ? nextWorkRepetition(kdt) : 1;
4893 if (repeatNum > mRepetition.count())
4895 kdt = kdt.addSecs(inc * repeatFreq);
4896 const QTime t = kdt.time();
4897 if (t >= mWorkDayStart && t < mWorkDayEnd)
4899 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
4901 mMainWorkTrigger = mAllWorkTrigger = kdt;
4909 if (!newdt.isValid())
4911 kdtRecur = newdt.effectiveKDateTime();
4912 dayRecur = kdtRecur.date().dayOfWeek() - 1;
4913 const QTime t = kdtRecur.time();
4914 if (t >= mWorkDayStart && t < mWorkDayEnd)
4916 if (mWorkDays.testBit(dayRecur))
4918 mMainWorkTrigger = kdtRecur;
4919 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
4923 if (kdtRecur.utcOffset() != currentOffset)
4924 currentOffset = kdtRecur.utcOffset();
4925 if (t == firstTime && dayRecur == firstDay && currentOffset == firstOffset)
4931 if (!finalDate.isValid())
4932 finalDate = kdtRecur.date();
4933 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
4936 if (i > transitionIndex)
4937 transitionIndex = i;
4938 if (++transitionIndex >= static_cast<int>(tzTransitions.count()))
4941 kdtRecur = newdt.effectiveKDateTime();
4942 if (finalDate.daysTo(kdtRecur.date()) > 365)
4944 firstTime = kdtRecur.time();
4945 firstOffset = kdtRecur.utcOffset();
4946 currentOffset = firstOffset;
4947 firstDay = kdtRecur.date().dayOfWeek() - 1;
4955 if (repeatTimeVaries)
4964 const int repeatFreq = mRepetition.intervalSeconds();
4965 previousOccurrence(kdt.addSecs(1), newdt,
false);
4966 if (!newdt.isValid())
4968 KDateTime kdtRecur = newdt.effectiveKDateTime();
4969 const bool recurDuringWork = (kdtRecur.time() >= mWorkDayStart && kdtRecur.time() < mWorkDayEnd);
4973 const bool subdaily = (repeatFreq < 24*3600);
4975 bool checkTimeChangeOnly =
false;
4976 int transitionIndex = -1;
4977 for (
int limit = 10; --limit >= 0; )
4981 QDate dateRecur = kdtRecur.date();
4982 int dayRecur = dateRecur.dayOfWeek() - 1;
4983 int repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4984 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
4992 KDateTime kdtNextRecur = newdt.effectiveKDateTime();
4994 int repeatsToCheck = mRepetition.count();
4995 int repeatsDuringWork = 0;
4999 if (repeatsDuringWork >= 0)
5004 int inc = subdaily ? nextWorkRepetition(kdt) : 1;
5006 const bool pastEnd = (repeatNum > mRepetition.count());
5008 inc -= repeatNum - mRepetition.count();
5009 repeatsToCheck -= inc;
5010 kdt = kdt.addSecs(inc * repeatFreq);
5011 if (kdtNextRecur.isValid() && kdt >= kdtNextRecur)
5015 repeatsToCheck = mRepetition.count();
5020 const QTime t = kdt.time();
5021 if (t >= mWorkDayStart && t < mWorkDayEnd)
5023 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
5025 mMainWorkTrigger = mAllWorkTrigger = kdt;
5028 repeatsDuringWork = 1;
5030 else if (!repeatsDuringWork && repeatsToCheck <= 0)
5033 repeatsDuringWork = -1;
5039 if (repeatsDuringWork < 0 && !recurDuringWork)
5043 if (!kdtNextRecur.isValid())
5045 if (checkTimeChangeOnly || (days & allDaysMask) == allDaysMask)
5047 kdtRecur = kdtNextRecur;
5049 kdtNextRecur = newdt.effectiveKDateTime();
5050 dateRecur = kdtRecur.date();
5051 dayRecur = dateRecur.dayOfWeek() - 1;
5052 if (recurDuringWork && mWorkDays.testBit(dayRecur))
5054 mMainWorkTrigger = kdtRecur;
5055 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
5058 days |= 1 << dayRecur;
5064 checkTimeChangeOnly =
true;
5065 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
5068 if (i > transitionIndex)
5069 transitionIndex = i;
5070 if (++transitionIndex >= static_cast<int>(tzTransitions.count()))
5072 kdt = KDateTime(tzTransitions[transitionIndex].time(), KDateTime::UTC);
5074 kdtRecur = newdt.effectiveKDateTime();
5085 int KAEventPrivate::nextWorkRepetition(
const KDateTime& pre)
const
5087 KDateTime nextWork(pre);
5088 if (pre.time() < mWorkDayStart)
5089 nextWork.setTime(mWorkDayStart);
5092 const int preDay = pre.date().dayOfWeek() - 1;
5093 for (
int n = 1; ; ++n)
5096 return mRepetition.count() + 1;
5097 if (mWorkDays.testBit((preDay + n) % 7))
5099 nextWork = nextWork.addDays(n);
5100 nextWork.setTime(mWorkDayStart);
5105 return (pre.secsTo(nextWork) - 1) / mRepetition.intervalSeconds() + 1;
5115 bool KAEventPrivate::mayOccurDailyDuringWork(
const KDateTime& kdt)
const
5117 if (!kdt.isDateOnly()
5118 && (kdt.time() < mWorkDayStart || kdt.time() >= mWorkDayEnd))
5121 const Duration interval = mRecurrence->regularInterval();
5122 if (interval && interval.
isDaily() && !(interval.
asDays() % 7))
5125 if (!mRepetition || (mRepetition.isDaily() && !(mRepetition.intervalDays() % 7)))
5129 int day = mRecurrence->startDateTime().date().dayOfWeek() - 1;
5130 const int repeatDays = mRepetition.intervalDays();
5131 const int maxRepeat = (mRepetition.count() < 6) ? mRepetition.count() : 6;
5132 for (
int i = 0; !mWorkDays.testBit(day); ++i, day = (day + repeatDays) % 7)
5144 #ifndef KALARMCAL_USE_KRESOURCES
5145 void KAEventPrivate::setAudioAlarm(
const Alarm::Ptr& alarm)
const
5147 void KAEventPrivate::setAudioAlarm(
Alarm* alarm)
const
5151 if (mSoundVolume >= 0)
5153 QString::fromLatin1(
"%1;%2;%3;%4").arg(QString::number(mSoundVolume,
'f', 2))
5154 .arg(QString::number(mFadeVolume,
'f', 2))
5155 .arg(mFadeSeconds));
5163 KAEvent::OccurType KAEventPrivate::nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const
5165 const KDateTime recurStart = mRecurrence->startDateTime();
5166 KDateTime pre = preDateTime.toTimeSpec(mStartDateTime.timeSpec());
5169 pre = pre.addDays(-1);
5172 const KDateTime dt = mRecurrence->getNextDateTime(pre);
5174 result.setDateOnly(mStartDateTime.isDateOnly());
5177 if (dt == recurStart)
5179 if (mRecurrence->duration() >= 0 && dt == mRecurrence->endDateTime())
5206 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5211 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5221 #ifndef KALARMCAL_USE_KRESOURCES
5228 static const QChar SEPARATOR = QLatin1Char(
';');
5229 static const QChar LATE_CANCEL_CODE = QLatin1Char(
'C');
5230 static const QChar AT_LOGIN_CODE = QLatin1Char(
'L');
5231 static const QChar DEFERRAL_CODE = QLatin1Char(
'D');
5232 static const QString TEXT_PREFIX = QLatin1String(
"TEXT:");
5233 static const QString FILE_PREFIX = QLatin1String(
"FILE:");
5234 static const QString COMMAND_PREFIX = QLatin1String(
"CMD:");
5237 static const QString BEEP_CATEGORY = QLatin1String(
"BEEP");
5240 static const QString LATE_CANCEL_CAT = QLatin1String(
"LATECANCEL");
5243 static const QString TEMPL_DEF_TIME_CAT = QLatin1String(
"TMPLDEFTIME");
5246 static const QString EXEC_IN_XTERM_CAT = QLatin1String(
"XTERM");
5249 static const QString DATE_ONLY_CATEGORY = QLatin1String(
"DATE");
5250 static const QString EMAIL_BCC_CATEGORY = QLatin1String(
"BCC");
5251 static const QString CONFIRM_ACK_CATEGORY = QLatin1String(
"ACKCONF");
5252 static const QString KORGANIZER_CATEGORY = QLatin1String(
"KORG");
5253 static const QString DEFER_CATEGORY = QLatin1String(
"DEFER;");
5254 static const QString ARCHIVE_CATEGORY = QLatin1String(
"SAVE");
5255 static const QString ARCHIVE_CATEGORIES = QLatin1String(
"SAVE:");
5256 static const QString LATE_CANCEL_CATEGORY = QLatin1String(
"LATECANCEL;");
5257 static const QString AUTO_CLOSE_CATEGORY = QLatin1String(
"LATECLOSE;");
5258 static const QString TEMPL_AFTER_TIME_CATEGORY = QLatin1String(
"TMPLAFTTIME;");
5259 static const QString KMAIL_SERNUM_CATEGORY = QLatin1String(
"KMAIL:");
5260 static const QString LOG_CATEGORY = QLatin1String(
"LOG:");
5263 static const QByteArray KMAIL_ID_PROPERTY(
"KMAILID");
5266 static const QByteArray ARCHIVE_PROPERTY(
"ARCHIVE");
5267 static const QString ARCHIVE_REMINDER_ONCE_TYPE = QLatin1String(
"ONCE");
5268 static const QString REMINDER_ONCE_TYPE = QLatin1String(
"REMINDER_ONCE");
5269 static const QByteArray EMAIL_ID_PROPERTY(
"EMAILID");
5270 static const QByteArray SPEAK_PROPERTY(
"SPEAK");
5271 static const QByteArray CANCEL_ON_ERROR_PROPERTY(
"ERRCANCEL");
5272 static const QByteArray DONT_SHOW_ERROR_PROPERTY(
"ERRNOSHOW");
5274 bool adjustSummerTime =
false;
5275 if (calendarVersion == -Version(0,5,7))
5279 calendarVersion = -calendarVersion;
5280 adjustSummerTime =
true;
5283 if (calendarVersion >= currentCalendarVersion())
5286 kDebug() <<
"Adjusting version" << calendarVersion;
5287 const bool pre_0_7 = (calendarVersion < Version(0,7,0));
5288 const bool pre_0_9 = (calendarVersion < Version(0,9,0));
5289 const bool pre_0_9_2 = (calendarVersion < Version(0,9,2));
5290 const bool pre_1_1_1 = (calendarVersion < Version(1,1,1));
5291 const bool pre_1_2_1 = (calendarVersion < Version(1,2,1));
5292 const bool pre_1_3_0 = (calendarVersion < Version(1,3,0));
5293 const bool pre_1_3_1 = (calendarVersion < Version(1,3,1));
5294 const bool pre_1_4_14 = (calendarVersion < Version(1,4,14));
5295 const bool pre_1_5_0 = (calendarVersion < Version(1,5,0));
5296 const bool pre_1_9_0 = (calendarVersion < Version(1,9,0));
5297 const bool pre_1_9_2 = (calendarVersion < Version(1,9,2));
5298 const bool pre_1_9_7 = (calendarVersion < Version(1,9,7));
5299 const bool pre_1_9_9 = (calendarVersion < Version(1,9,9));
5300 const bool pre_1_9_10 = (calendarVersion < Version(1,9,10));
5301 const bool pre_2_2_9 = (calendarVersion < Version(2,2,9));
5302 const bool pre_2_3_0 = (calendarVersion < Version(2,3,0));
5303 const bool pre_2_3_2 = (calendarVersion < Version(2,3,2));
5304 const bool pre_2_7_0 = (calendarVersion < Version(2,7,0));
5305 Q_ASSERT(currentCalendarVersion() == Version(2,7,0));
5307 KTimeZone localZone;
5309 localZone = KSystemTimeZones::local();
5311 bool converted =
false;
5312 #ifndef KALARMCAL_USE_KRESOURCES
5317 for (
int ei = 0, eend = events.count(); ei < eend; ++ei)
5319 #ifndef KALARMCAL_USE_KRESOURCES
5322 Event*
event = events[ei];
5325 if (alarms.isEmpty())
5327 event->startUpdates();
5328 const bool readOnly =
event->isReadOnly();
5330 event->setReadOnly(
false);
5331 QStringList cats =
event->categories();
5332 bool addLateCancel =
false;
5335 if (pre_0_7 && event->
allDay())
5339 event->setAllDay(
false);
5356 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5358 #ifndef KALARMCAL_USE_KRESOURCES
5361 Alarm* alarm = alarms[ai];
5363 bool atLogin =
false;
5364 bool deferral =
false;
5365 bool lateCancel =
false;
5367 const QString txt = alarm->
text();
5368 const int length = txt.length();
5370 if (txt[0].isDigit())
5372 while (++i < length && txt[i].isDigit()) ;
5373 if (i < length && txt[i++] == SEPARATOR)
5377 const QChar ch = txt[i++];
5378 if (ch == SEPARATOR)
5380 if (ch == LATE_CANCEL_CODE)
5382 else if (ch == AT_LOGIN_CODE)
5384 else if (ch == DEFERRAL_CODE)
5391 if (txt.indexOf(TEXT_PREFIX, i) == i)
5392 i += TEXT_PREFIX.length();
5393 else if (txt.indexOf(FILE_PREFIX, i) == i)
5396 i += FILE_PREFIX.length();
5398 else if (txt.indexOf(COMMAND_PREFIX, i) == i)
5401 i += COMMAND_PREFIX.length();
5405 const QString altxt = txt.mid(i);
5411 types += KAEventPrivate::FILE_TYPE;
5417 setProcedureAlarm(alarm, altxt);
5425 types += KAEventPrivate::AT_LOGIN_TYPE;
5429 types += KAEventPrivate::TIME_DEFERRAL_TYPE;
5431 addLateCancel =
true;
5432 if (types.count() > 0)
5440 if (recur && recur->
recurs())
5449 if (adjustSummerTime)
5453 KDateTime dt = alarm->
time();
5454 const time_t t = dt.toTime_t();
5455 const struct tm* dtm = localtime(&t);
5458 dt = dt.addSecs(-3600);
5478 event->setCreated(event->
dtEnd());
5479 KDateTime start =
event->dtStart();
5482 event->setAllDay(
false);
5483 start.setTime(QTime(0, 0));
5484 flags += KAEventPrivate::DATE_ONLY_FLAG;
5486 event->setHasEndDate(
false);
5488 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5490 #ifndef KALARMCAL_USE_KRESOURCES
5493 Alarm* alarm = alarms[ai];
5498 if (!cats.isEmpty())
5500 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5502 #ifndef KALARMCAL_USE_KRESOURCES
5505 Alarm* alarm = alarms[ai];
5507 if (alarm->
type() == Alarm::Display)
5509 QString::fromLatin1(
"%1;;").arg(cats.at(0)));
5514 for (
int i = 0, end = cats.count(); i < end; ++i)
5516 if (cats.at(i) == BEEP_CATEGORY)
5520 #ifndef KALARMCAL_USE_KRESOURCES
5523 Alarm* alarm =
event->newAlarm();
5527 KDateTime dt =
event->dtStart();
5530 KAEventPrivate::AlarmMap alarmMap;
5531 KAEventPrivate::readAlarms(event, &alarmMap);
5532 KAEventPrivate::AlarmMap::ConstIterator it = alarmMap.constBegin();
5533 if (it != alarmMap.constEnd())
5535 dt = it.value().alarm->time();
5551 while ((i = cats.indexOf(LATE_CANCEL_CAT)) >= 0)
5554 addLateCancel =
true;
5564 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5566 #ifndef KALARMCAL_USE_KRESOURCES
5569 Alarm* alarm = alarms[ai];
5571 if (alarm->
type() == Alarm::Display)
5573 const QString oldtext = alarm->
text();
5575 if (oldtext != newtext)
5588 while ((i = cats.indexOf(TEMPL_DEF_TIME_CAT)) >= 0)
5591 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += QLatin1String(
"0");
5602 while ((i = cats.indexOf(EXEC_IN_XTERM_CAT)) >= 0)
5605 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, KAEventPrivate::xtermURL);
5616 CalEvent::setStatus(event, CalEvent::status(event));
5617 for (
int i = 0; i < cats.count(); )
5619 const QString cat = cats.at(i);
5620 if (cat == DATE_ONLY_CATEGORY)
5621 flags += KAEventPrivate::DATE_ONLY_FLAG;
5622 else if (cat == CONFIRM_ACK_CATEGORY)
5623 flags += KAEventPrivate::CONFIRM_ACK_FLAG;
5624 else if (cat == EMAIL_BCC_CATEGORY)
5625 flags += KAEventPrivate::EMAIL_BCC_FLAG;
5626 else if (cat == KORGANIZER_CATEGORY)
5627 flags += KAEventPrivate::KORGANIZER_FLAG;
5628 else if (cat.startsWith(DEFER_CATEGORY))
5629 (flags += KAEventPrivate::DEFER_FLAG) += cat.mid(DEFER_CATEGORY.length());
5630 else if (cat.startsWith(TEMPL_AFTER_TIME_CATEGORY))
5631 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += cat.mid(TEMPL_AFTER_TIME_CATEGORY.length());
5632 else if (cat.startsWith(LATE_CANCEL_CATEGORY))
5633 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += cat.mid(LATE_CANCEL_CATEGORY.length());
5634 else if (cat.startsWith(AUTO_CLOSE_CATEGORY))
5635 (flags += KAEventPrivate::AUTO_CLOSE_FLAG) += cat.mid(AUTO_CLOSE_CATEGORY.length());
5636 else if (cat.startsWith(KMAIL_SERNUM_CATEGORY))
5637 (flags += KAEventPrivate::KMAIL_SERNUM_FLAG) += cat.mid(KMAIL_SERNUM_CATEGORY.length());
5638 else if (cat == ARCHIVE_CATEGORY)
5640 else if (cat.startsWith(ARCHIVE_CATEGORIES))
5641 event->setCustomProperty(
KACalendar::APPNAME, ARCHIVE_PROPERTY, cat.mid(ARCHIVE_CATEGORIES.length()));
5642 else if (cat.startsWith(LOG_CATEGORY))
5643 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, cat.mid(LOG_CATEGORY.length()));
5659 event->
shiftTimes(KDateTime::ClockTime, localZone);
5664 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += QLatin1String(
"1");
5665 if (!flags.isEmpty())
5666 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5670 if ((pre_1_4_14 || (pre_1_9_7 && !pre_1_9_0))
5680 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5681 const bool dateOnly = flags.contains(KAEventPrivate::DATE_ONLY_FLAG);
5682 KDateTime startDateTime =
event->dtStart();
5684 startDateTime.setDateOnly(
true);
5686 KDateTime nextMainDateTime;
5687 bool mainExpired =
true;
5688 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5690 #ifndef KALARMCAL_USE_KRESOURCES
5693 Alarm* alarm = alarms[i];
5704 bool mainAlarm =
true;
5706 const QStringList types =
property.split(QChar(
','), QString::SkipEmptyParts);
5707 for (
int t = 0; t < types.count(); ++t)
5709 QString type = types[t];
5710 if (type == KAEventPrivate::AT_LOGIN_TYPE
5711 || type == KAEventPrivate::TIME_DEFERRAL_TYPE
5712 || type == KAEventPrivate::DATE_DEFERRAL_TYPE
5713 || type == KAEventPrivate::REMINDER_TYPE
5714 || type == REMINDER_ONCE_TYPE)
5726 mainExpired =
false;
5727 nextMainDateTime = alarm->
time();
5728 nextMainDateTime.setDateOnly(dateOnly);
5729 nextMainDateTime = nextMainDateTime.toTimeSpec(startDateTime);
5730 if (nextMainDateTime != startDateTime)
5732 QDateTime dt = nextMainDateTime.dateTime();
5734 dt.toString(dateOnly ?
"yyyyMMdd" :
"yyyyMMddThhmmss"));
5747 KDateTime dt =
event->recurrence()->getNextDateTime(startDateTime.addDays(-1));
5748 dt.setDateOnly(dateOnly);
5749 adjustment = startDateTime.secsTo(dt);
5752 adjustment = startDateTime.secsTo(nextMainDateTime);
5756 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5758 #ifndef KALARMCAL_USE_KRESOURCES
5761 Alarm* alarm = alarms[i];
5766 const QStringList types =
property.split(QChar(
','), QString::SkipEmptyParts);
5767 for (
int t = 0; t < types.count(); ++t)
5769 const QString type = types[t];
5770 if (type == KAEventPrivate::TIME_DEFERRAL_TYPE
5771 || type == KAEventPrivate::DATE_DEFERRAL_TYPE)
5782 if (pre_1_5_0 || (pre_1_9_9 && !pre_1_9_0))
5788 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5790 #ifndef KALARMCAL_USE_KRESOURCES
5793 Alarm* alarm = alarms[i];
5812 if (KAEventPrivate::convertRepetition(event))
5816 if (pre_2_2_9 || (pre_2_3_2 && !pre_2_3_0))
5822 if (KAEventPrivate::convertStartOfDay(event))
5836 bool flagsValid =
false;
5839 bool reminderOnce =
false;
5841 if (!prop.isEmpty())
5844 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5845 flags << KAEventPrivate::ARCHIVE_FLAG;
5847 if (prop != QLatin1String(
"0"))
5851 const QStringList list = prop.split(KAEventPrivate::SC, QString::SkipEmptyParts);
5852 for (
int i = 0; i < list.count(); ++i)
5854 if (list[i] == KAEventPrivate::AT_LOGIN_TYPE)
5855 flags << KAEventPrivate::AT_LOGIN_TYPE;
5856 else if (list[i] == ARCHIVE_REMINDER_ONCE_TYPE)
5857 reminderOnce =
true;
5858 else if (!list[i].isEmpty() && !list[i].startsWith(QChar::fromLatin1(
'-')))
5862 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5866 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5868 #ifndef KALARMCAL_USE_KRESOURCES
5871 Alarm* alarm = alarms[i];
5876 if (!property.isEmpty())
5878 flags << KAEventPrivate::EMAIL_ID_FLAG << property;
5883 flags << KAEventPrivate::SPEAK_FLAG;
5888 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
5893 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
5896 if (!flags.isEmpty())
5903 QStringList types =
property.split(QChar::fromLatin1(
','), QString::SkipEmptyParts);
5904 const int r = types.indexOf(REMINDER_ONCE_TYPE);
5908 types[r] = KAEventPrivate::REMINDER_TYPE;
5910 reminderOnce =
true;
5912 if (r >= 0 || types.contains(KAEventPrivate::REMINDER_TYPE))
5921 else if (offset < 0)
5922 reminder = reminderToString(offset / 60);
5925 if (!reminder.isEmpty())
5929 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5930 if (flags.indexOf(KAEventPrivate::REMINDER_TYPE) < 0)
5932 flags += KAEventPrivate::REMINDER_TYPE;
5934 flags += KAEventPrivate::REMINDER_ONCE_FLAG;
5941 event->setReadOnly(
true);
5942 event->endUpdates();
5951 #ifndef KALARMCAL_USE_KRESOURCES
5952 bool KAEventPrivate::convertStartOfDay(
const Event::Ptr& event)
5954 bool KAEventPrivate::convertStartOfDay(
Event* event)
5957 bool changed =
false;
5958 const QTime midnight(0, 0);
5959 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5960 if (flags.indexOf(KAEventPrivate::DATE_ONLY_FLAG) >= 0)
5963 const KDateTime oldDt =
event->dtStart();
5964 const int adjustment = oldDt.time().secsTo(midnight);
5967 event->setDtStart(KDateTime(oldDt.date(), midnight, oldDt.timeSpec()));
5968 int deferralOffset = 0;
5970 readAlarms(event, &alarmMap);
5971 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
5973 const AlarmData& data = it.value();
5974 if (!data.alarm->hasStartOffset())
5976 if (data.timedDeferral)
5979 deferralOffset = data.alarm->startOffset().asSeconds();
5980 #ifndef KALARMCAL_USE_KRESOURCES
5981 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
5983 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
5986 else if (data.type == AUDIO_ALARM
5987 && data.alarm->startOffset().asSeconds() == deferralOffset)
5990 #ifndef KALARMCAL_USE_KRESOURCES
5991 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
5993 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
6003 bool foundDeferral =
false;
6004 int deferralOffset = 0;
6005 int newDeferralOffset = 0;
6007 const KDateTime nextMainDateTime = readDateTime(event,
false, start).kDateTime();
6009 readAlarms(event, &alarmMap);
6010 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
6012 const AlarmData& data = it.value();
6013 if (!data.alarm->hasStartOffset())
6015 if ((data.type & DEFERRED_ALARM) && !data.timedDeferral)
6018 KDateTime altime = data.alarm->startOffset().end(nextMainDateTime);
6019 altime.setTime(midnight);
6020 deferralOffset = data.alarm->startOffset().asSeconds();
6021 newDeferralOffset =
event->dtStart().secsTo(altime);
6022 #ifndef KALARMCAL_USE_KRESOURCES
6023 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6025 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6027 foundDeferral =
true;
6030 else if (foundDeferral
6031 && data.type == AUDIO_ALARM
6032 && data.alarm->startOffset().asSeconds() == deferralOffset)
6035 #ifndef KALARMCAL_USE_KRESOURCES
6036 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6038 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6055 #ifndef KALARMCAL_USE_KRESOURCES
6056 bool KAEventPrivate::convertRepetition(
const Event::Ptr& event)
6058 bool KAEventPrivate::convertRepetition(
Event* event)
6062 if (alarms.isEmpty())
6067 bool converted =
false;
6068 const bool readOnly =
event->isReadOnly();
6069 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
6071 #ifndef KALARMCAL_USE_KRESOURCES
6074 Alarm* alarm = alarms[ai];
6080 event->startUpdates();
6082 event->setReadOnly(
false);
6097 event->setReadOnly(
true);
6098 event->endUpdates();
6115 KAAlarm::Private::Private()
6116 : mType(INVALID_ALARM),
6118 mRepeatAtLogin(false),
6124 : d(new Private(*other.d))
6142 return d->mActionType;
6157 return (withRepeats && d->mNextRepeat && d->mRepetition)
6158 ? d->mRepetition.duration(d->mNextRepeat).end(d->mNextMainDateTime.kDateTime())
6159 : d->mNextMainDateTime;
6164 return d->mNextMainDateTime.date();
6169 return d->mNextMainDateTime.effectiveTime();
6174 return d->mRepeatAtLogin;
6184 return d->mDeferred;
6189 return d->mDeferred && d->mTimedDeferral;
6194 d->mNextMainDateTime = dt;
6199 d->mNextMainDateTime = dt;
6202 #ifdef KDE_NO_DEBUG_OUTPUT
6215 default:
return "INVALID";
6229 #ifndef KALARMCAL_USE_KRESOURCES
6230 EmailAddressList& EmailAddressList::operator=(
const Person::List& addresses)
6232 EmailAddressList& EmailAddressList::operator=(
const QList<Person>& addresses)
6236 for (
int p = 0, end = addresses.count(); p < end; ++p)
6238 #ifndef KALARMCAL_USE_KRESOURCES
6239 if (!addresses[p]->email().isEmpty())
6241 if (!addresses[p].email().isEmpty())
6243 append(addresses[p]);
6251 EmailAddressList::operator QStringList()
const
6254 for (
int p = 0, end = count(); p < end; ++p)
6263 QString EmailAddressList::join(
const QString& separator)
const
6267 for (
int p = 0, end = count(); p < end; ++p)
6272 result += separator;
6273 result += address(p);
6281 QString EmailAddressList::address(
int index)
const
6283 if (index < 0 || index > count())
6287 #ifndef KALARMCAL_USE_KRESOURCES
6289 const QString name = person->name();
6291 const Person person = (*this)[index];
6292 const QString name = person.
name();
6294 if (!name.isEmpty())
6297 for (
int i = 0, len = name.length(); i < len; ++i)
6299 const QChar ch = name[i];
6300 if (!ch.isLetterOrNumber())
6307 #ifndef KALARMCAL_USE_KRESOURCES
6308 result += (*this)[index]->name();
6310 result += (*this)[index].name();
6312 result += (quote ?
"\" <" :
" <");
6316 #ifndef KALARMCAL_USE_KRESOURCES
6317 result += person->
email();
6319 result += person.
email();
6329 QStringList EmailAddressList::pureAddresses()
const
6332 for (
int p = 0, end = count(); p < end; ++p)
6333 #ifndef KALARMCAL_USE_KRESOURCES
6334 list += at(p)->email();
6336 list += at(p).email();
6344 QString EmailAddressList::pureAddresses(
const QString& separator)
const
6348 for (
int p = 0, end = count(); p < end; ++p)
6353 result += separator;
6354 #ifndef KALARMCAL_USE_KRESOURCES
6355 result += at(p)->email();
6357 result += at(p).email();
6373 #ifndef KALARMCAL_USE_KRESOURCES
6374 static void setProcedureAlarm(
const Alarm::Ptr& alarm,
const QString& commandLine)
6376 static void setProcedureAlarm(
Alarm* alarm,
const QString& commandLine)
6382 bool quoted =
false;
6383 const uint posMax = commandLine.length();
6385 for (pos = 0; pos < posMax; ++pos)
6387 const QChar ch = commandLine[pos];
6390 if (ch == quoteChar)
6400 switch (ch.toLatin1())
6407 done = !command.isEmpty();
6411 if (command.isEmpty())
6429 for ( ; pos < posMax && commandLine[pos] == QLatin1Char(
' '); ++pos) ;
6430 arguments = commandLine.mid(pos);
6439 QString reminderToString(
int minutes)
6442 int count = abs(minutes);
6443 if (count % 1440 == 0)
6448 else if (count % 60 == 0)
6455 return QString(
"%1%2").arg(count).arg(unit);
void setEnabled(bool enable)
the alarm displays something
void cancelDefer()
Cancel any deferral alarm which is pending.
virtual void shiftTimes(const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec)
void setReminder(int minutes, bool onceOnly)
Set an additional reminder alarm.
KCalCore::Person::List emailAddressees() const
Return the list of email addressees, including names, for an email alarm.
the alarm displays command output
bool setRecurMinutely(int freq, int count, const KDateTime &end)
Set the recurrence to recur at a minutes interval.
yearly, on a specified date in each of the specified months
void setRepeatCount(int alarmRepeatCount)
bool repeatSound() const
Return whether the sound file will be repeated indefinitely.
Type type(const QString &mimeType)
Return the alarm Type for a mime type string.
OccurType setNextOccurrence(const KDateTime &preDateTime)
Set the date/time of the event to the next scheduled occurrence after a specified date/time...
KARecurrence * recurrence() const
Return the full recurrence data for the event.
bool recurs() const
Return whether the event recurs.
QTime time() const
Return the trigger time-of-day for the alarm.
void setRecurrence(const KARecurrence &r)
Initialise the event's recurrence from a KARecurrence.
weekly, on specified weekdays
QFont font() const
Return the font to use for alarm message texts.
Flags flags() const
Return the OR of various Flag enum status values.
Duration startOffset() const
QString repetitionText(bool brief=false) const
Return the repetition interval as text suitable for display.
bool cancelOnPreActionError() const
Return whether the alarm is to be cancelled if the pre-alarm action fails.
bool setRecurMonthlyByDate(int freq, const QVector< int > &days, int count, const QDate &end)
Set the recurrence to recur monthly, on the specified days within the month.
Reminder in advance of/after the main alarm.
void setEmailAlarm(const QString &subject, const QString &text, const Person::List &addressees, const QStringList &attachments=QStringList())
void dumpDebug() const
Output the event's data as debug output.
bool confirmAck() const
Return whether alarm acknowledgement must be confirmed by the user, for a display alarm...
THE real alarm. Must be the first in the enumeration.
the event is an alarm template
KCalCore::Duration interval() const
Return the interval between repetitions.
int lateCancel() const
Get the late cancellation period.
void setRepeatAtLogin(bool repeat)
Enable or disable repeat-at-login.
Type
The recurrence's period type.
DateTime addMins(qint64 n) const
Returns a DateTime value mins minutes later than the value of this object.
QSharedPointer< Alarm > Ptr
KAAlarm alarm(KAAlarm::Type type) const
Return the alarm of a specified type.
QString customProperty(const QByteArray &app, const QByteArray &key) const
KAAlarm represents individual alarms within a KAEvent.
DateTime mainEndRepeatTime() const
Return the time at which the last sub-repetition of the main alarm will occur.
int intervalSeconds() const
Return the repetition interval in terms of seconds.
QString customStatus() const
DateTime addSecs(qint64 n) const
Returns a DateTime value secs seconds later than the value of this object.
void setExcludeHolidays(bool exclude)
Enable or disable the alarm on holiday dates.
void setSnoozeTime(const Duration &alarmSnoozeTime)
void setDuration(int duration)
QSharedPointer< Event > Ptr
KCalCore::Duration longestRecurrenceInterval() const
Return the longest interval which can occur between consecutive recurrences.
bool speak() const
Return whether the displayed alarm text should be spoken.
OccurType previousOccurrence(const KDateTime &afterDateTime, DateTime &result, bool includeRepetitions=false) const
Get the date/time of the last previous occurrence of the event, before the specified date/time...
void setCategories(const QStringList &categories)
blind copy the email to the user
bool setRecurDaily(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur daily.
static QTime startOfDay()
Returns the start-of-day time.
Represents a sub-repetition, defined by interval and repeat count.
static void setWorkTime(const QBitArray &days, const QTime &start, const QTime &end)
Set working days and times, to be used by all KAEvent instances.
bool hasStartOffset() const
Recurrence * recurrence() const
auto-close the alarm window after the late-cancel period
int recurInterval() const
Return the recurrence interval in units of the recurrence period type (minutes, days, etc).
static void setStartOfDay(const QTime &sod)
Sets the start-of-day time.
void setLateCancel(int minutes)
Set or clear the late-cancel option.
KCalCore::Duration duration() const
Return the overall duration of the repetition.
bool isValid() const
Return whether the alarm is valid, i.e.
void startChanges()
Call before making a group of changes to the event, to avoid unnecessary calculation intensive recalc...
bool emailBcc() const
Return whether to send a blind copy of the email to the sender, for an email alarm.
post-alarm command execution failed
bool deferred() const
Return whether this is a deferred alarm.
static QString fromCalendarText(const QString &text, bool &email)
Translate an alarm calendar text to a display text.
void setAudioFile(const QString &filename, float volume, float fadeVolume, int fadeSeconds, int repeatPause=-1, bool allowEmptyFile=false)
Set the audio file related data for the event.
void set(const KCalCore::Event::Ptr &)
Initialise the instance from a KCalCore::Event.
static void setDefaultFont(const QFont &font)
Set the global default font for alarm message texts.
static void setHolidays(const KHolidays::HolidayRegion ®ion)
Set the holiday region to be used by all KAEvent instances.
next trigger time for display purposes (i.e. excluding reminders)
KACalendar::Compat compatibility() const
Return the event's storage format compatibility compared to the current KAlarm calendar format...
bool setRecurAnnualByDate(int freq, const QVector< int > &months, int day, KARecurrence::Feb29Type, int count, const QDate &end)
Set the recurrence to recur annually, on the specified day in each of the specified months...
QColor fgColour() const
Return the message window foreground color, for a display alarm.
void setEventId(const QString &id)
Set the event's unique identifier.
bool deferDefaultDateOnly() const
Return the default date-only setting used in the deferral dialog.
Type type() const
Return the alarm's type (main, reminder, etc.).
Actions actionTypes() const
Return the OR of the basic action types of the event's main alarm (display, command, email, audio).
yearly, on specified weekdays in the specified weeks of the specified months
void setProcedureAlarm(const QString &programFile, const QString &arguments=QString())
Feb29Type
When annual February 29th recurrences should occur in non-leap years.
bool setRepetition(const Repetition &r)
Initialise the event's sub-repetition.
int alarmCount() const
Return the number of alarms in the event, i.e.
bool setDisplaying(const KAEvent &event, KAAlarm::Type type, Akonadi::Collection::Id colId, const KDateTime &repeatAtLoginTime, bool showEdit, bool showDefer)
Set the event to be a copy of the specified event, making the specified alarm the 'displaying' alarm...
QString postAction() const
Return the shell command to execute after the display alarm is acknowledged.
int fadeSeconds() const
Return the fade period in seconds, or 0 if no fade is specified.
QStringList emailAttachments() const
Return the list of file paths of the attachments, for an email alarm.
DateTime deferDateTime() const
Return the time at which the currently pending deferred alarm should trigger.
bool holidaysExcluded() const
Return whether the alarm is disabled on holiday dates.
Akonadi::Item::Id itemId() const
Return the ID of the Akonadi Item which contains the event.
bool isTemplate() const
Return whether the event is an alarm template.
bool dontShowPreActionError() const
Return whether the user should not be notified if the pre-alarm action fails.
QVector< KAEvent * > List
A list of pointers to KAEvent objects.
KDateTime end(const KDateTime &start) const
Type
The category of an event, indicated by the middle part of its UID.
repeat the sound file while the alarm is displayed
DateTime mainDateTime(bool withRepeats=false) const
Return the next time the main alarm will trigger.
const QByteArray APPNAME
The application name ("KALARM") used in calendar properties.
check for recurrences only, ignore sub-repetitions
bool isWorkingTime(const KDateTime &dt) const
Check whether a date/time is during working hours and/or holidays, depending on the flags set for the...
DateTime dateTime(bool withRepeats=false) const
Return the trigger time for the alarm.
QString templateName() const
Return the alarm template's name.
Represents recurrences for KAlarm.
static QString toCalendarText(const QString &text)
Return the text for an alarm message text, in alarm calendar format.
Alarm::List alarms() const
void setCreatedDateTime(const KDateTime &dt)
Set the date/time the event was created, or saved in the archive calendar.
Duration snoozeTime() const
void endChanges()
Call when a group of changes preceded by startChanges() is complete, to allow resultant updates to oc...
int revision() const
Return the revision number of the event (SEQUENCE property in iCalendar).
KCal::Alarm::Display type: display a text message.
void setLogFile(const QString &logfile)
Set the log file to write command alarm output to.
bool toBeArchived() const
Return whether the event should be archived when it expires or is deleted.
Action
The basic KAAlarm action types.
QString emailSubject() const
Return the email subject line, for an email alarm.
the event is currently being displayed
bool isReminder() const
Return whether this is a reminder alarm.
QString logFile() const
Return the log file which command alarm output should be written to.
QTime mainTime() const
Return the time at which the main alarm will next trigger.
KAEvent()
Default constructor which creates an invalid event.
the event is currently active
KAAlarm & operator=(const KAAlarm &other)
Assignment operator.
bool isValid() const
Return whether the instance represents a valid event.
virtual KDateTime dtEnd() const
void removeCustomProperty(const QByteArray &app, const QByteArray &key)
KAAlarm firstAlarm() const
Return the main alarm for the event.
trigger the alarm only during working hours
DateTime nextTrigger(TriggerType type) const
Return the next time the alarm will trigger.
the alarm plays an audio file (without any display)
pre-alarm command execution failed
static const char * debugType(Type)
Return an alarm type as a string.
Action action() const
Return the action type for the alarm.
the command is a script, not a shell command line
QString message() const
Return the message text for a display alarm, or the email body for an email alarm.
CmdErrType commandError() const
Return the command execution error for the last time the alarm triggered.
don't trigger the alarm on holidays
bool beep() const
Return whether a beep should sound when the alarm is displayed.
OccurType nextOccurrence(const KDateTime &preDateTime, DateTime &result, OccurOption option=IGNORE_REPETITION) const
Get the date/time of the next occurrence of the event, after the specified date/time.
void setDeferDefaultMinutes(int minutes, bool dateOnly=false)
Set defaults for the deferral dialog.
bool recurs() const
Returns whether the event recurs at all.
the alarm is currently disabled
KAAlarm convertDisplayingAlarm() const
Return the original alarm which the displaying alarm refers to.
void setNoRecur()
Clear the event's recurrence and sub-repetition data.
KDateTime effectiveKDateTime() const
Returns the date and time of the value.
DeferLimitType
What type of occurrence currently limits how long the alarm can be deferred.
void setCommandError(CmdErrType error) const
Set or clear the command execution error for the last time the alarm triggered.
only trigger the reminder on the first recurrence
bool setRecurMonthlyByPos(int freq, const QVector< MonthPos > &pos, int count, const QDate &end)
Set the recurrence to recur monthly, on the specified weekdays in the specified weeks of the month...
void setReadOnly(bool ro)
Set the read-only status of the alarm.
cancel alarm on pre-alarm action error
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
float fadeVolume() const
Return the initial volume which will fade to the final volume.
execute pre-alarm action also for deferred alarms
CmdErrType
Command execution error type for last time the alarm was triggered.
void setFirstRecurrence()
Adjust the event date/time to the first recurrence of the event, on or after the event start date/tim...
next main working time trigger, excluding reminders
void setTime(const DateTime &dt)
Set the alarm's trigger time.
bool isValid() const
Returns true if the date is valid and, if it is a date-time value, the time is also valid...
a recurrence with only a date, not a time
void setAutoClose(bool autoclose)
Enable or disable auto-close for a display alarm, i.e.
bool reminderOnceOnly() const
Return whether the reminder alarm is triggered only for the first recurrence.
bool displaying() const
Return whether the alarm is currently being displayed, i.e.
speak the message when the alarm is displayed
int deferDefaultMinutes() const
Return the default deferral interval used in the deferral dialog.
bool commandScript() const
Return whether a command script is specified, for a command alarm.
KCal::Alarm::Audio type: play a sound file.
the alarm executes a command
bool enabled() const
Return the enabled status of the alarm.
QString id() const
Return the event's unique identifier.
sound an audible beep when the alarm is displayed
bool occursAfter(const KDateTime &preDateTime, bool includeRepetitions) const
Determine whether the event will occur after the specified date/time.
void setArchive()
Set the event to be archived when it expires or is deleted.
bool repeatAtLogin(bool includeArchived=false) const
Return whether the alarm repeats at login.
TriggerType
Alarm trigger type.
only a date is specified for the alarm, not a time
int reminderMinutes() const
Return the number of minutes BEFORE the main alarm when a reminder alarm is set.
a recurrence with a date and time
bool useDefaultFont() const
Return whether to use the default font (as set by setDefaultFont()) for alarm message texts...
void incrementRevision()
Increment the revision number of the event (SEQUENCE property in iCalendar).
DateTime startDateTime() const
Return the start time for the event.
closing the alarm message window requires a confirmation prompt
bool isDateOnly() const
Returns true if it is date-only value.
void setTime(const KDateTime &alarmTime)
void setCompatibility(KACalendar::Compat c)
Note the event's storage format compatibility compared to the current KAlarm calendar format...
bool repeatAtLogin() const
Return whether this is a repeat-at-login alarm.
QString audioFile() const
Return the audio file path.
static bool convertKCalEvents(const KCalCore::Calendar::Ptr &, int calendarVersion)
If a calendar was written by a previous version of KAlarm, do any necessary format conversions on the...
void setStartOffset(const Duration &offset)
bool timedDeferral() const
Return whether in the case of a deferred alarm, it is timed (as opposed to date-only).
ExtraActionOptions extraActionOptions() const
Return the pre- and post-alarm action options.
the first occurrence (takes precedence over LAST_RECURRENCE)
KAAlarm()
Default constructor, which creates an invalid instance.
KCal::Alarm::Display type: display a file (URL given by the alarm text)
verify that the KCal::Event UID is already the same as the KAEvent ID, if the latter is non-empty ...
repeat the alarm at every login
QSharedPointer< Calendar > Ptr
next actual working time trigger, including reminders
float soundVolume() const
Return the sound volume (the final volume if fade is specified).
void removeExpiredAlarm(KAAlarm::Type type)
Remove the alarm of the specified type from the event.
void activateReminderAfter(const DateTime &mainAlarmTime)
If there is a reminder which occurs AFTER the main alarm, activate the event's reminder which occurs ...
void setCollectionId(Akonadi::Collection::Id id)
Set the ID of the Akonadi Collection which contains the event.
QDate date() const
Return the trigger date for the alarm.
void defer(const DateTime &dt, bool reminder, bool adjustRecurrence=false)
Defer the event to the specified time.
static QString joinEmailAddresses(const KCalCore::Person::List &addresses, const QString &sep)
Concatenate a list of email addresses into a string.
void setItemId(Akonadi::Item::Id id)
Set the ID of the Akonadi Item which contains the event.
OccurOption
How to treat sub-repetitions in nextOccurrence().
int nextRepeatCount(const KDateTime &from, const KDateTime &preDateTime) const
Find the repetition count for the next repetition after a specified time.
display the contents of a file
void setTemplate(const QString &name, int afterTime=-1)
Set the event to be an alarm template.
static void setStartOfDay(const QTime &)
Set the start-of-day time used by all date-only alarms.
void setAudioAlarm(const QString &audioFile=QString())
Copy of the alarm currently being displayed.
set the KCal::Event UID to the KAEvent ID
void setMinutely(int freq)
QSharedPointer< Person > Ptr
uint identityUoid(const QString &identityUoidOrName)
Fetch the uoid of an identity name or uoid string.
KCal::Alarm::Email type: send an email.
command alarm execution failed
bool isReadOnly() const
Return the read-only status of the alarm.
QStringList emailPureAddresses() const
Return the list of email addressees, excluding names, for an email alarm.
QString fileName() const
Return the path of the file whose contents are to be shown, for a display alarm.
KAAlarm nextAlarm(const KAAlarm &previousAlarm) const
Return the next alarm for the event, after the specified alarm.
Repetition repetition() const
Return the event's sub-repetition data.
bool commandDisplay() const
Return whether the command output is to be displayed in an alarm message window.
QString emailMessage() const
Return the email message body, for an email alarm.
OccurType
What type of occurrence is due.
KDateTime kDateTime() const
Returns the date and time of the value as a KDateTime.
KAEvent represents a KAlarm event.
static void adjustStartOfDay(const KAEvent::List &events)
Call when the user changes the start-of-day time, to adjust the data for each date-only event in a li...
bool autoClose() const
Return whether auto-close is enabled, i.e.
use the default alarm message font
void setActions(const QString &pre, const QString &post, ExtraActionOptions options)
Set the pre-alarm and post-alarm actions, and their options.
SubAction actionSubType() const
Return the action sub-type of the event's main alarm.
QString recurrenceText(bool brief=false) const
Return the recurrence interval as text suitable for display.
UidAction
How to deal with the event UID in updateKCalEvent().
execute the command in a terminal window
QStringList emailAddresses() const
Return a list of the email addresses, including names, for an email alarm.
void setEmail(uint from, const KCalCore::Person::List &, const QString &subject, const QStringList &attachments)
Set the email related data for the event.
bool setRecurAnnualByPos(int freq, const QVector< MonthPos > &pos, const QVector< int > &months, int count, const QDate &end)
Set the recurrence to recur annually, on the specified weekdays in the specified weeks of the specifi...
bool mainExpired() const
Return whether the event's main alarm has expired.
Actions
The basic action type(s) for the event's main alarm.
display command output in the alarm window
int templateAfterTime() const
Return the number of minutes (>= 0) after the default alarm time which is specified in the alarm temp...
bool isDaily() const
Check whether the repetition interval is in terms of days (as opposed to minutes).
CalEvent::Type category() const
Return the alarm category (active/archived/template, or displaying).
Additional repeat-at-login trigger.
void setEnabled(bool enable)
Enable or disable the alarm.
bool deferred() const
Return whether there is currently a deferred alarm pending.
bool copyToKOrganizer() const
Return whether KOrganizer should hold a copy of the event.
monthly, on specified weekdays in a specified week of the month
bool workTimeOnly() const
Return whether the alarm is disabled on non-working days and outside working hours.
uint emailFromId() const
Return the email identity to be used as the sender, for an email alarm.
QString command() const
Return the command or script to execute, for a command alarm.
void setTime(const KDateTime &dt)
Set the next time to trigger the alarm (excluding sub-repetitions).
bool usingDefaultTime() const
Return whether the alarm template does not specify a time.
bool setItemPayload(Akonadi::Item &, const QStringList &collectionMimeTypes) const
Initialise an Akonadi::Item with the event's data.
KCal::Alarm::Procedure type: execute a shell command.
void setDisplayAlarm(const QString &text=QString())
return a sub-repetition if it's the next occurrence
bool expired() const
Return whether the event has expired.
void setCategory(CalEvent::Type type)
Set the alarm category (active/archived/template, or displaying).
Akonadi::Collection::Id collectionId() const
Return the ID of the Akonadi Collection which contains the event.
void setCollectionId_const(Akonadi::Collection::Id id) const
Set the ID of the Akonadi Collection which contains the event.
bool updateKCalEvent(const KCalCore::Event::Ptr &event, UidAction u, bool setCustomProperties=true) const
Update an existing KCalCore::Event with the KAEvent data.
bool reminderActive() const
Return whether a reminder is currently due (before the next, or after the last, main alarm/recurrence...
(bitmask for a sub-repetition of an occurrence)
void setWorkTimeOnly(bool wto)
Enable or disable the alarm on non-working days and outside working hours.
QMap< QByteArray, QString > customProperties() const
Return the original KCalCore::Event's custom properties in the source calendar.
int nextRepetition() const
Return the count of the next sub-repetition which is due.
at an hours/minutes interval
bool setRecurWeekly(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur weekly, on the specified weekdays.
KDateTime createdDateTime() const
Return the date/time the event was created, or saved in the archive calendar.
void setDateOnly(bool d)
Sets the value to be either date-only or date-time.
QString programArguments() const
do not notify pre-alarm action errors to user
QString displayMessage() const
Return the message text for a display alarm.
bool commandXterm() const
Return whether to execute the command in a terminal window, for a command alarm.
SubAction
The sub-action type for the event's main alarm.
As KDateTime, but with a configurable start-of-day time for date-only values.
next trigger, including reminders, ignoring working hours & holidays
void set(const KCalCore::Duration &interval, int count)
Initialises the instance with the specified interval and count.
monthly, on a specified day of the month
int intervalDays() const
Return the repetition interval in terms of days.
QString cleanText() const
Return the alarm's text.
QString audioFile() const
void reinstateFromDisplaying(const KCalCore::Event::Ptr &event, Akonadi::Collection::Id &colId, bool &showEdit, bool &showDefer)
Reinstate the original event from the 'displaying' event.
QColor bgColour() const
Return the message window background color, for a display alarm.
DateTime deferralLimit(DeferLimitType *limitType=0) const
Return the latest time which the alarm can currently be deferred to.
static List ptrList(QVector< KAEvent > &events)
Return a list of pointers to a list of KAEvent objects.
QString preAction() const
Return the shell command to execute before the alarm is displayed.
KARecurrence::Type recurType() const
Return the recurrence period type for the event.
int repeatSoundPause() const
Return how many seconds to pause between repetitions of the sound file.
Types types(const QStringList &mimeTypes)
Return the alarm Types for a list of mime type strings.
next trigger, excluding reminders, ignoring working hours & holidays
QString programFile() const
KOrganizer should hold a copy of the event.
bool reminderDeferral() const
Return whether there is currently a deferred reminder alarm pending.