25 #include "alarmtext.h"
26 #include "identities.h"
29 #ifndef KALARMCAL_USE_KRESOURCES
32 #include <kcal/calendarlocal.h>
34 #include <kholidays/holidays.h>
35 using namespace KHolidays;
37 #include <ksystemtimezone.h>
38 #include <klocalizedstring.h>
39 #ifdef KALARMCAL_USE_KRESOURCES
40 #include <ksharedconfig.h>
42 #include <kconfiggroup.h>
47 #ifndef KALARMCAL_USE_KRESOURCES
48 using namespace KCalCore;
52 using namespace KHolidays;
59 #ifndef KALARMCAL_USE_KRESOURCES
63 typedef KCal::Person EmailAddress;
64 class EmailAddressList :
public QList<KCal::Person>
68 #ifndef KALARMCAL_USE_KRESOURCES
69 EmailAddressList() : KCalCore::
Person::List() { }
73 EmailAddressList() : QList<KCal::
Person>() { }
74 EmailAddressList(
const QList<KCal::Person>& list) { operator=(list); }
75 EmailAddressList& operator=(
const QList<KCal::Person>&);
77 operator QStringList()
const;
78 QString join(
const QString& separator)
const;
79 QStringList pureAddresses()
const;
80 QString pureAddresses(
const QString& separator)
const;
82 QString address(
int index)
const;
87 class KAAlarm::Private
94 DateTime mNextMainDateTime;
95 Repetition mRepetition;
105 class KAEventPrivate :
public QSharedData
115 TIMED_FLAG = 0x400000,
116 DATE_DEFERRAL = DEFERRAL,
117 TIME_DEFERRAL = DEFERRAL | TIMED_FLAG,
118 DISPLAYING_ = 0x800000,
119 READ_ONLY_FLAGS = 0xF00000
140 REMINDER_ALARM = 0x02,
141 DEFERRED_ALARM = 0x04,
142 DEFERRED_REMINDER_ALARM = REMINDER_ALARM | DEFERRED_ALARM,
145 AT_LOGIN_ALARM = 0x10,
146 DISPLAYING_ALARM = 0x20,
149 PRE_ACTION_ALARM = 0x40,
150 POST_ACTION_ALARM = 0x50
155 #ifndef KALARMCAL_USE_KRESOURCES
163 QColor bgColour, fgColour;
167 int repeatSoundPause;
170 KAEventPrivate::AlarmType
type;
171 KAAlarm::Action action;
173 KAEvent::ExtraActionOptions extraActionOptions;
180 typedef QMap<AlarmType, AlarmData> AlarmMap;
183 KAEventPrivate(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
184 const QFont& f, KAEvent::SubAction,
int lateCancel, KAEvent::Flags flags,
185 bool changesPending =
false);
186 #ifndef KALARMCAL_USE_KRESOURCES
189 explicit KAEventPrivate(
const KCal::Event*);
191 KAEventPrivate(
const KAEventPrivate&);
192 ~KAEventPrivate() {
delete mRecurrence; }
193 KAEventPrivate& operator=(
const KAEventPrivate& e) {
if (&e !=
this) copy(e);
return *
this; }
194 #ifndef KALARMCAL_USE_KRESOURCES
197 void set(
const KCal::Event*);
199 void set(
const KDateTime&,
const QString& message,
const QColor& bg,
const QColor& fg,
200 const QFont&, KAEvent::SubAction,
int lateCancel, KAEvent::Flags flags,
201 bool changesPending =
false);
202 void setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile);
203 KAEvent::OccurType setNextOccurrence(
const KDateTime& preDateTime);
204 void setFirstRecurrence();
205 void setCategory(CalEvent::Type);
206 void setRepeatAtLogin(
bool);
207 void setRepeatAtLoginTrue(
bool clearReminder);
208 void setReminder(
int minutes,
bool onceOnly);
209 void activateReminderAfter(
const DateTime& mainAlarmTime);
210 void defer(
const DateTime&,
bool reminder,
bool adjustRecurrence =
false);
212 #ifndef KALARMCAL_USE_KRESOURCES
213 bool setDisplaying(
const KAEventPrivate&, KAAlarm::Type,
Akonadi::Collection::Id,
const KDateTime& dt,
bool showEdit,
bool showDefer);
216 bool setDisplaying(
const KAEventPrivate&, KAAlarm::Type,
const QString& resourceID,
const KDateTime& dt,
bool showEdit,
bool showDefer);
217 void reinstateFromDisplaying(
const KCal::Event*, QString& resourceID,
bool& showEdit,
bool& showDefer);
218 void setCommandError(
const QString& configString);
219 void setCommandError(KAEvent::CmdErrType,
bool writeConfig)
const;
221 void startChanges() { ++mChangeCount; }
223 void removeExpiredAlarm(KAAlarm::Type);
224 KAAlarm alarm(KAAlarm::Type)
const;
225 KAAlarm firstAlarm()
const;
226 KAAlarm nextAlarm(KAAlarm::Type)
const;
227 #ifndef KALARMCAL_USE_KRESOURCES
228 bool updateKCalEvent(
const KCalCore::Event::Ptr&, KAEvent::UidAction,
bool setCustomProperties =
true)
const;
230 bool updateKCalEvent(KCal::Event*, KAEvent::UidAction)
const;
232 DateTime mainDateTime(
bool withRepeats =
false)
const
233 {
return (withRepeats && mNextRepeat && mRepetition)
234 ? mRepetition.duration(mNextRepeat).end(mNextMainDateTime.kDateTime()) : mNextMainDateTime; }
235 DateTime mainEndRepeatTime()
const
236 {
return mRepetition ? mRepetition.duration().end(mNextMainDateTime.kDateTime()) : mNextMainDateTime; }
237 DateTime deferralLimit(KAEvent::DeferLimitType* = 0)
const;
238 KAEvent::Flags flags()
const;
239 bool isWorkingTime(
const KDateTime&)
const;
240 bool setRepetition(
const Repetition&);
241 bool occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const;
242 KAEvent::OccurType nextOccurrence(
const KDateTime& preDateTime, DateTime& result, KAEvent::OccurOption = KAEvent::IGNORE_REPETITION)
const;
243 KAEvent::OccurType previousOccurrence(
const KDateTime& afterDateTime, DateTime& result,
bool includeRepetitions =
false)
const;
244 void setRecurrence(
const KARecurrence&);
245 #ifndef KALARMCAL_USE_KRESOURCES
249 bool setRecur(KCal::RecurrenceRule::PeriodType,
int freq,
int count,
const QDate& end, KARecurrence::Feb29Type = KARecurrence::Feb29_None);
250 bool setRecur(KCal::RecurrenceRule::PeriodType,
int freq,
int count,
const KDateTime& end, KARecurrence::Feb29Type = KARecurrence::Feb29_None);
252 KARecurrence::Type checkRecur()
const;
254 void calcTriggerTimes()
const;
255 #ifdef KDE_NO_DEBUG_OUTPUT
256 void dumpDebug()
const { }
258 void dumpDebug()
const;
260 #ifndef KALARMCAL_USE_KRESOURCES
265 static void readAlarm(
const KCalCore::Alarm::Ptr&, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
267 static bool convertRepetition(KCal::Event*);
268 static bool convertStartOfDay(KCal::Event*);
269 static DateTime readDateTime(
const KCal::Event*,
bool dateOnly, DateTime& start);
270 static void readAlarms(
const KCal::Event*,
void* alarmMap,
bool cmdDisplay =
false);
271 static void readAlarm(
const KCal::Alarm*, AlarmData&,
bool audioMain,
bool cmdDisplay =
false);
275 void copy(
const KAEventPrivate&);
276 bool mayOccurDailyDuringWork(
const KDateTime&)
const;
277 int nextWorkRepetition(
const KDateTime& pre)
const;
278 void calcNextWorkingTime(
const DateTime& nextTrigger)
const;
279 DateTime nextWorkingTime()
const;
280 KAEvent::OccurType nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const;
281 #ifndef KALARMCAL_USE_KRESOURCES
286 void setAudioAlarm(KCal::Alarm*)
const;
287 KCal::Alarm* initKCalAlarm(KCal::Event*,
const DateTime&,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
288 KCal::Alarm* initKCalAlarm(KCal::Event*,
int startOffsetSecs,
const QStringList& types, AlarmType = INVALID_ALARM)
const;
290 inline void set_deferral(DeferType);
291 inline void activate_reminder(
bool activate);
294 #ifdef KALARMCAL_USE_KRESOURCES
295 static QString mCmdErrConfigGroup;
297 static QFont mDefaultFont;
298 static const KHolidays::HolidayRegion* mHolidays;
299 static QBitArray mWorkDays;
300 static QTime mWorkDayStart;
301 static QTime mWorkDayEnd;
302 static int mWorkTimeIndex;
303 #ifdef KALARMCAL_USE_KRESOURCES
304 AlarmResource* mResource;
306 mutable DateTime mAllTrigger;
307 mutable DateTime mMainTrigger;
308 mutable DateTime mAllWorkTrigger;
309 mutable DateTime mMainWorkTrigger;
310 mutable KAEvent::CmdErrType mCommandError;
313 QString mTemplateName;
314 #ifndef KALARMCAL_USE_KRESOURCES
315 QMap<QByteArray, QString> mCustomProperties;
316 Akonadi::Item::Id mItemId;
320 QString mOriginalResourceId;
326 DateTime mStartDateTime;
327 KDateTime mCreatedDateTime;
328 DateTime mNextMainDateTime;
329 KDateTime mAtLoginDateTime;
330 DateTime mDeferralTime;
331 DateTime mDisplayingTime;
332 int mDisplayingFlags;
333 int mReminderMinutes;
334 DateTime mReminderAfterTime;
335 ReminderType mReminderActive;
336 int mDeferDefaultMinutes;
337 bool mDeferDefaultDateOnly;
339 KARecurrence* mRecurrence;
340 Repetition mRepetition;
344 unsigned long mKMailSerialNumber;
345 int mTemplateAfterTime;
349 uint mEmailFromIdentity;
350 EmailAddressList mEmailAddresses;
351 QString mEmailSubject;
352 QStringList mEmailAttachments;
353 mutable int mChangeCount;
354 mutable bool mTriggerChanged;
359 int mRepeatSoundPause;
361 mutable const KHolidays::HolidayRegion*
363 mutable int mWorkTimeOnly;
364 KAEvent::SubAction mActionSubType;
365 CalEvent::Type mCategory;
366 KAEvent::ExtraActionOptions mExtraActionOptions;
367 #ifndef KALARMCAL_USE_KRESOURCES
368 KACalendar::Compat mCompatibility;
372 bool mUseDefaultFont;
375 bool mCommandDisplay;
379 bool mCopyToKOrganizer;
380 bool mReminderOnceOnly;
384 bool mArchiveRepeatAtLogin;
387 bool mDisplayingDefer;
388 bool mDisplayingEdit;
392 static const QByteArray FLAGS_PROPERTY;
393 static const QString DATE_ONLY_FLAG;
394 static const QString EMAIL_BCC_FLAG;
395 static const QString CONFIRM_ACK_FLAG;
396 static const QString KORGANIZER_FLAG;
397 static const QString EXCLUDE_HOLIDAYS_FLAG;
398 static const QString WORK_TIME_ONLY_FLAG;
399 static const QString REMINDER_ONCE_FLAG;
400 static const QString DEFER_FLAG;
401 static const QString LATE_CANCEL_FLAG;
402 static const QString AUTO_CLOSE_FLAG;
403 static const QString TEMPL_AFTER_TIME_FLAG;
404 static const QString KMAIL_SERNUM_FLAG;
405 static const QString ARCHIVE_FLAG;
406 static const QByteArray NEXT_RECUR_PROPERTY;
407 static const QByteArray REPEAT_PROPERTY;
408 static const QByteArray LOG_PROPERTY;
409 static const QString xtermURL;
410 static const QString displayURL;
411 static const QByteArray TYPE_PROPERTY;
412 static const QString FILE_TYPE;
413 static const QString AT_LOGIN_TYPE;
414 static const QString REMINDER_TYPE;
415 static const QString REMINDER_ONCE_TYPE;
416 static const QString TIME_DEFERRAL_TYPE;
417 static const QString DATE_DEFERRAL_TYPE;
418 static const QString DISPLAYING_TYPE;
419 static const QString PRE_ACTION_TYPE;
420 static const QString POST_ACTION_TYPE;
421 static const QString SOUND_REPEAT_TYPE;
422 static const QByteArray NEXT_REPEAT_PROPERTY;
423 static const QString HIDDEN_REMINDER_FLAG;
424 static const QByteArray FONT_COLOUR_PROPERTY;
425 static const QByteArray VOLUME_PROPERTY;
426 static const QString EMAIL_ID_FLAG;
427 static const QString SPEAK_FLAG;
428 static const QString EXEC_ON_DEFERRAL_FLAG;
429 static const QString CANCEL_ON_ERROR_FLAG;
430 static const QString DONT_SHOW_ERROR_FLAG;
431 static const QString DISABLED_STATUS;
432 static const QString DISP_DEFER;
433 static const QString DISP_EDIT;
434 static const QString CMD_ERROR_VALUE;
435 static const QString CMD_ERROR_PRE_VALUE;
436 static const QString CMD_ERROR_POST_VALUE;
437 static const QString SC;
445 QByteArray KAEvent::currentCalendarVersionString() {
return QByteArray(
"2.7.0"); }
446 int KAEvent::currentCalendarVersion() {
return Version(2,7,0); }
452 const QByteArray KAEventPrivate::FLAGS_PROPERTY(
"FLAGS");
453 const QString KAEventPrivate::DATE_ONLY_FLAG = QLatin1String(
"DATE");
454 const QString KAEventPrivate::EMAIL_BCC_FLAG = QLatin1String(
"BCC");
455 const QString KAEventPrivate::CONFIRM_ACK_FLAG = QLatin1String(
"ACKCONF");
456 const QString KAEventPrivate::KORGANIZER_FLAG = QLatin1String(
"KORG");
457 const QString KAEventPrivate::EXCLUDE_HOLIDAYS_FLAG = QLatin1String(
"EXHOLIDAYS");
458 const QString KAEventPrivate::WORK_TIME_ONLY_FLAG = QLatin1String(
"WORKTIME");
459 const QString KAEventPrivate::REMINDER_ONCE_FLAG = QLatin1String(
"ONCE");
460 const QString KAEventPrivate::DEFER_FLAG = QLatin1String(
"DEFER");
461 const QString KAEventPrivate::LATE_CANCEL_FLAG = QLatin1String(
"LATECANCEL");
462 const QString KAEventPrivate::AUTO_CLOSE_FLAG = QLatin1String(
"LATECLOSE");
463 const QString KAEventPrivate::TEMPL_AFTER_TIME_FLAG = QLatin1String(
"TMPLAFTTIME");
464 const QString KAEventPrivate::KMAIL_SERNUM_FLAG = QLatin1String(
"KMAIL");
465 const QString KAEventPrivate::ARCHIVE_FLAG = QLatin1String(
"ARCHIVE");
467 const QByteArray KAEventPrivate::NEXT_RECUR_PROPERTY(
"NEXTRECUR");
468 const QByteArray KAEventPrivate::REPEAT_PROPERTY(
"REPEAT");
469 const QByteArray KAEventPrivate::LOG_PROPERTY(
"LOG");
470 const QString KAEventPrivate::xtermURL = QLatin1String(
"xterm:");
471 const QString KAEventPrivate::displayURL = QLatin1String(
"display:");
474 const QByteArray KAEventPrivate::TYPE_PROPERTY(
"TYPE");
475 const QString KAEventPrivate::FILE_TYPE = QLatin1String(
"FILE");
476 const QString KAEventPrivate::AT_LOGIN_TYPE = QLatin1String(
"LOGIN");
477 const QString KAEventPrivate::REMINDER_TYPE = QLatin1String(
"REMINDER");
478 const QString KAEventPrivate::TIME_DEFERRAL_TYPE = QLatin1String(
"DEFERRAL");
479 const QString KAEventPrivate::DATE_DEFERRAL_TYPE = QLatin1String(
"DATE_DEFERRAL");
480 const QString KAEventPrivate::DISPLAYING_TYPE = QLatin1String(
"DISPLAYING");
481 const QString KAEventPrivate::PRE_ACTION_TYPE = QLatin1String(
"PRE");
482 const QString KAEventPrivate::POST_ACTION_TYPE = QLatin1String(
"POST");
483 const QString KAEventPrivate::SOUND_REPEAT_TYPE = QLatin1String(
"SOUNDREPEAT");
484 const QByteArray KAEventPrivate::NEXT_REPEAT_PROPERTY(
"NEXTREPEAT");
485 const QString KAEventPrivate::HIDDEN_REMINDER_FLAG = QLatin1String(
"HIDE");
487 const QByteArray KAEventPrivate::FONT_COLOUR_PROPERTY(
"FONTCOLOR");
489 const QString KAEventPrivate::EMAIL_ID_FLAG = QLatin1String(
"EMAILID");
491 const QByteArray KAEventPrivate::VOLUME_PROPERTY(
"VOLUME");
492 const QString KAEventPrivate::SPEAK_FLAG = QLatin1String(
"SPEAK");
494 const QString KAEventPrivate::EXEC_ON_DEFERRAL_FLAG = QLatin1String(
"EXECDEFER");
495 const QString KAEventPrivate::CANCEL_ON_ERROR_FLAG = QLatin1String(
"ERRCANCEL");
496 const QString KAEventPrivate::DONT_SHOW_ERROR_FLAG = QLatin1String(
"ERRNOSHOW");
499 const QString KAEventPrivate::DISABLED_STATUS = QLatin1String(
"DISABLED");
502 const QString KAEventPrivate::DISP_DEFER = QLatin1String(
"DEFER");
503 const QString KAEventPrivate::DISP_EDIT = QLatin1String(
"EDIT");
506 #ifdef KALARMCAL_USE_KRESOURCES
507 QString KAEventPrivate::mCmdErrConfigGroup = QLatin1String(
"CommandErrors");
509 const QString KAEventPrivate::CMD_ERROR_VALUE = QLatin1String(
"MAIN");
510 const QString KAEventPrivate::CMD_ERROR_PRE_VALUE = QLatin1String(
"PRE");
511 const QString KAEventPrivate::CMD_ERROR_POST_VALUE = QLatin1String(
"POST");
513 const QString KAEventPrivate::SC = QLatin1String(
";");
515 QFont KAEventPrivate::mDefaultFont;
516 const KHolidays::HolidayRegion* KAEventPrivate::mHolidays = 0;
517 QBitArray KAEventPrivate::mWorkDays(7);
518 QTime KAEventPrivate::mWorkDayStart(9, 0, 0);
519 QTime KAEventPrivate::mWorkDayEnd(17, 0, 0);
520 int KAEventPrivate::mWorkTimeIndex = 1;
522 #ifndef KALARMCAL_USE_KRESOURCES
523 static void setProcedureAlarm(
const Alarm::Ptr&,
const QString& commandLine);
525 static void setProcedureAlarm(
Alarm*,
const QString& commandLine);
527 static QString reminderToString(
int minutes);
534 inline void KAEventPrivate::set_deferral(DeferType type)
538 if (mDeferral == NO_DEFERRAL)
543 if (mDeferral != NO_DEFERRAL)
549 inline void KAEventPrivate::activate_reminder(
bool activate)
551 if (activate && mReminderActive != ACTIVE_REMINDER && mReminderMinutes)
553 if (mReminderActive == NO_REMINDER)
555 mReminderActive = ACTIVE_REMINDER;
557 else if (!activate && mReminderActive != NO_REMINDER)
559 mReminderActive = NO_REMINDER;
560 mReminderAfterTime = DateTime();
565 K_GLOBAL_STATIC_WITH_ARGS(QSharedDataPointer<KAEventPrivate>,
566 emptyKAEventPrivate, (
new KAEventPrivate))
569 : d(*emptyKAEventPrivate)
572 KAEventPrivate::KAEventPrivate()
574 #ifdef KALARMCAL_USE_KRESOURCES
577 mCommandError(KAEvent::CMD_NO_ERROR),
578 #ifndef KALARMCAL_USE_KRESOURCES
583 mReminderActive(NO_REMINDER),
588 mDeferral(NO_DEFERRAL),
590 mTriggerChanged(false),
594 mCategory(CalEvent::
EMPTY),
595 #ifndef KALARMCAL_USE_KRESOURCES
596 mCompatibility(KACalendar::
Current),
603 mRepeatAtLogin(false),
607 KAEvent::KAEvent(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
608 SubAction action,
int lateCancel, Flags flags,
bool changesPending)
609 : d(new KAEventPrivate(dt, message, bg, fg, f, action, lateCancel, flags, changesPending))
613 KAEventPrivate::KAEventPrivate(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
const QFont& f,
617 set(dt, message, bg, fg, f, action, lateCancel, flags, changesPending);
620 #ifndef KALARMCAL_USE_KRESOURCES
625 : d(
new KAEventPrivate(e))
629 #ifndef KALARMCAL_USE_KRESOURCES
630 KAEventPrivate::KAEventPrivate(
const Event::Ptr& e)
632 KAEventPrivate::KAEventPrivate(
const Event* e)
639 KAEventPrivate::KAEventPrivate(
const KAEventPrivate& e)
653 KAEvent& KAEvent::operator=(
const KAEvent& other)
663 void KAEventPrivate::copy(
const KAEventPrivate& event)
665 #ifdef KALARMCAL_USE_KRESOURCES
666 mResource =
event.mResource;
668 mAllTrigger =
event.mAllTrigger;
669 mMainTrigger =
event.mMainTrigger;
670 mAllWorkTrigger =
event.mAllWorkTrigger;
671 mMainWorkTrigger =
event.mMainWorkTrigger;
672 mCommandError =
event.mCommandError;
673 mEventID =
event.mEventID;
674 mTemplateName =
event.mTemplateName;
675 #ifndef KALARMCAL_USE_KRESOURCES
676 mCustomProperties =
event.mCustomProperties;
677 mItemId =
event.mItemId;
678 mCollectionId =
event.mCollectionId;
680 mOriginalResourceId =
event.mOriginalResourceId;
683 mAudioFile =
event.mAudioFile;
684 mPreAction =
event.mPreAction;
685 mPostAction =
event.mPostAction;
686 mStartDateTime =
event.mStartDateTime;
687 mCreatedDateTime =
event.mCreatedDateTime;
688 mNextMainDateTime =
event.mNextMainDateTime;
689 mAtLoginDateTime =
event.mAtLoginDateTime;
690 mDeferralTime =
event.mDeferralTime;
691 mDisplayingTime =
event.mDisplayingTime;
692 mDisplayingFlags =
event.mDisplayingFlags;
693 mReminderMinutes =
event.mReminderMinutes;
694 mReminderAfterTime =
event.mReminderAfterTime;
695 mReminderActive =
event.mReminderActive;
696 mDeferDefaultMinutes =
event.mDeferDefaultMinutes;
697 mDeferDefaultDateOnly =
event.mDeferDefaultDateOnly;
698 mRevision =
event.mRevision;
699 mRepetition =
event.mRepetition;
700 mNextRepeat =
event.mNextRepeat;
701 mAlarmCount =
event.mAlarmCount;
702 mDeferral =
event.mDeferral;
703 mKMailSerialNumber =
event.mKMailSerialNumber;
704 mTemplateAfterTime =
event.mTemplateAfterTime;
705 mBgColour =
event.mBgColour;
706 mFgColour =
event.mFgColour;
708 mEmailFromIdentity =
event.mEmailFromIdentity;
709 mEmailAddresses =
event.mEmailAddresses;
710 mEmailSubject =
event.mEmailSubject;
711 mEmailAttachments =
event.mEmailAttachments;
712 mLogFile =
event.mLogFile;
713 mSoundVolume =
event.mSoundVolume;
714 mFadeVolume =
event.mFadeVolume;
715 mFadeSeconds =
event.mFadeSeconds;
716 mRepeatSoundPause =
event.mRepeatSoundPause;
717 mLateCancel =
event.mLateCancel;
718 mExcludeHolidays =
event.mExcludeHolidays;
719 mWorkTimeOnly =
event.mWorkTimeOnly;
720 mActionSubType =
event.mActionSubType;
721 mCategory =
event.mCategory;
722 mExtraActionOptions =
event.mExtraActionOptions;
723 #ifndef KALARMCAL_USE_KRESOURCES
724 mCompatibility =
event.mCompatibility;
725 mReadOnly =
event.mReadOnly;
727 mConfirmAck =
event.mConfirmAck;
728 mUseDefaultFont =
event.mUseDefaultFont;
729 mCommandScript =
event.mCommandScript;
730 mCommandXterm =
event.mCommandXterm;
731 mCommandDisplay =
event.mCommandDisplay;
732 mEmailBcc =
event.mEmailBcc;
734 mSpeak =
event.mSpeak;
735 mCopyToKOrganizer =
event.mCopyToKOrganizer;
736 mReminderOnceOnly =
event.mReminderOnceOnly;
737 mAutoClose =
event.mAutoClose;
738 mMainExpired =
event.mMainExpired;
739 mRepeatAtLogin =
event.mRepeatAtLogin;
740 mArchiveRepeatAtLogin =
event.mArchiveRepeatAtLogin;
741 mArchive =
event.mArchive;
742 mDisplaying =
event.mDisplaying;
743 mDisplayingDefer =
event.mDisplayingDefer;
744 mDisplayingEdit =
event.mDisplayingEdit;
745 mEnabled =
event.mEnabled;
747 mTriggerChanged =
event.mTriggerChanged;
749 if (event.mRecurrence)
750 mRecurrence =
new KARecurrence(*event.mRecurrence);
755 #ifndef KALARMCAL_USE_KRESOURCES
767 #ifndef KALARMCAL_USE_KRESOURCES
768 void KAEventPrivate::set(
const Event::Ptr& event)
770 void KAEventPrivate::set(
const Event* event)
776 #ifdef KALARMCAL_USE_KRESOURCES
779 mEventID =
event->uid();
780 mRevision =
event->revision();
781 mTemplateName.clear();
783 #ifndef KALARMCAL_USE_KRESOURCES
787 mOriginalResourceId.clear();
789 mTemplateAfterTime = -1;
793 mCommandXterm =
false;
794 mCommandDisplay =
false;
795 mCopyToKOrganizer =
false;
798 mReminderOnceOnly =
false;
800 mArchiveRepeatAtLogin =
false;
801 mDisplayingDefer =
false;
802 mDisplayingEdit =
false;
803 mDeferDefaultDateOnly =
false;
804 mReminderActive = NO_REMINDER;
805 mReminderMinutes = 0;
806 mDeferDefaultMinutes = 0;
808 mKMailSerialNumber = 0;
809 mExcludeHolidays = 0;
812 mBgColour = QColor(255, 255, 255);
813 mFgColour = QColor(0, 0, 0);
814 #ifndef KALARMCAL_USE_KRESOURCES
816 mReadOnly =
event->isReadOnly();
818 mUseDefaultFont =
true;
823 mCategory = CalEvent::status(event, ¶m);
827 const QStringList params = param.split(SC, QString::KeepEmptyParts);
828 int n = params.count();
831 #ifndef KALARMCAL_USE_KRESOURCES
832 const qlonglong
id = params[0].toLongLong(&ok);
836 mOriginalResourceId = params[0];
838 for (
int i = 1; i < n; ++i)
840 if (params[i] == DISP_DEFER)
841 mDisplayingDefer =
true;
842 if (params[i] == DISP_EDIT)
843 mDisplayingEdit =
true;
847 #ifndef KALARMCAL_USE_KRESOURCES
850 mCustomProperties =
event->customProperties();
851 for (QMap<QByteArray, QString>::Iterator it = mCustomProperties.begin(); it != mCustomProperties.end(); )
853 if (it.key().startsWith(kalarmKey))
854 it = mCustomProperties.erase(it);
860 bool dateOnly =
false;
861 QStringList flags =
event->customProperty(
KACalendar::APPNAME, FLAGS_PROPERTY).split(SC, QString::SkipEmptyParts);
862 flags << QString() << QString();
863 for (
int i = 0, end = flags.count() - 1; i < end; ++i)
865 QString flag = flags.at(i);
866 if (flag == DATE_ONLY_FLAG)
868 else if (flag == CONFIRM_ACK_FLAG)
870 else if (flag == EMAIL_BCC_FLAG)
872 else if (flag == KORGANIZER_FLAG)
873 mCopyToKOrganizer =
true;
874 else if (flag == EXCLUDE_HOLIDAYS_FLAG)
875 mExcludeHolidays = mHolidays;
876 else if (flag == WORK_TIME_ONLY_FLAG)
878 else if (flag == KMAIL_SERNUM_FLAG)
880 const unsigned long n = flags.at(i + 1).toULong(&ok);
883 mKMailSerialNumber = n;
886 else if (flag == KAEventPrivate::ARCHIVE_FLAG)
888 else if (flag == KAEventPrivate::AT_LOGIN_TYPE)
889 mArchiveRepeatAtLogin =
true;
890 else if (flag == KAEventPrivate::REMINDER_TYPE)
892 flag = flags.at(++i);
893 if (flag == KAEventPrivate::REMINDER_ONCE_FLAG)
895 mReminderOnceOnly =
true;
898 const int len = flag.length() - 1;
899 mReminderMinutes = -flag.left(len).toInt();
900 switch (flag.at(len).toLatin1())
903 case 'H': mReminderMinutes *= 60;
break;
904 case 'D': mReminderMinutes *= 1440;
break;
905 default: mReminderMinutes = 0;
break;
908 else if (flag == DEFER_FLAG)
910 QString mins = flags.at(i + 1);
911 if (mins.endsWith(QLatin1Char(
'D')))
913 mDeferDefaultDateOnly =
true;
914 mins.truncate(mins.length() - 1);
916 const int n =
static_cast<int>(mins.toUInt(&ok));
919 mDeferDefaultMinutes = n;
922 else if (flag == TEMPL_AFTER_TIME_FLAG)
924 const int n =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
927 mTemplateAfterTime = n;
930 else if (flag == LATE_CANCEL_FLAG)
932 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
935 if (!ok || !mLateCancel)
938 else if (flag == AUTO_CLOSE_FLAG)
940 mLateCancel =
static_cast<int>(flags.at(i + 1).toUInt(&ok));
943 if (!ok || !mLateCancel)
952 if (prop == xtermURL)
953 mCommandXterm =
true;
954 else if (prop == displayURL)
955 mCommandDisplay =
true;
963 const QStringList list = prop.split(QLatin1Char(
':'));
964 if (list.count() >= 2)
966 const int interval =
static_cast<int>(list[0].toUInt());
967 const int count =
static_cast<int>(list[1].toUInt());
968 if (interval && count)
970 if (interval % (24*60))
971 mRepetition.set(
Duration(interval * 60, Duration::Seconds), count);
973 mRepetition.set(
Duration(interval / (24*60), Duration::Days), count);
977 mNextMainDateTime = readDateTime(event, dateOnly, mStartDateTime);
978 mCreatedDateTime =
event->created();
979 if (dateOnly && !mRepetition.isDaily())
980 mRepetition.set(
Duration(mRepetition.intervalDays(), Duration::Days));
982 mTemplateName =
event->summary();
983 #ifndef KALARMCAL_USE_KRESOURCES
986 if (event->statusStr() == DISABLED_STATUS)
994 mRepeatAtLogin =
false;
996 mCommandScript =
false;
997 mExtraActionOptions = 0;
998 mDeferral = NO_DEFERRAL;
1001 mRepeatSoundPause = -1;
1003 mEmailFromIdentity = 0;
1004 mReminderAfterTime = DateTime();
1008 mPostAction.clear();
1009 mEmailSubject.clear();
1010 mEmailAddresses.clear();
1011 mEmailAttachments.clear();
1015 readAlarms(event, &alarmMap, mCommandDisplay);
1021 bool isEmailText =
false;
1022 bool setDeferralTime =
false;
1024 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
1026 const AlarmData& data = it.
value();
1027 const DateTime dateTime = data.alarm->hasStartOffset() ? data.alarm->startOffset().end(mNextMainDateTime.effectiveKDateTime()) : data.alarm->time();
1031 mMainExpired =
false;
1033 alTime.setDateOnly(mStartDateTime.isDateOnly());
1034 if (data.alarm->repeatCount() && data.alarm->snoozeTime())
1036 mRepetition.set(data.alarm->snoozeTime(), data.alarm->repeatCount());
1037 mNextRepeat = data.nextRepeat;
1043 mAudioFile = data.cleanText;
1044 mSpeak = data.speak && mAudioFile.isEmpty();
1045 mBeep = !mSpeak && mAudioFile.isEmpty();
1046 mSoundVolume = (!mBeep && !mSpeak) ? data.soundVolume : -1;
1047 mFadeVolume = (mSoundVolume >= 0 && data.fadeSeconds > 0) ? data.fadeVolume : -1;
1048 mFadeSeconds = (mFadeVolume >= 0) ? data.fadeSeconds : 0;
1049 mRepeatSoundPause = (!mBeep && !mSpeak) ? data.repeatSoundPause : -1;
1051 case AT_LOGIN_ALARM:
1052 mRepeatAtLogin =
true;
1053 mAtLoginDateTime = dateTime.kDateTime();
1054 alTime = mAtLoginDateTime;
1056 case REMINDER_ALARM:
1058 if (data.alarm->startOffset().asSeconds() / 60)
1060 mReminderActive = ACTIVE_REMINDER;
1061 if (mReminderMinutes < 0)
1063 mReminderAfterTime = dateTime;
1064 mReminderAfterTime.setDateOnly(dateOnly);
1065 if (data.hiddenReminder)
1066 mReminderActive = HIDDEN_REMINDER;
1070 case DEFERRED_REMINDER_ALARM:
1071 case DEFERRED_ALARM:
1072 mDeferral = (data.type == DEFERRED_REMINDER_ALARM) ? REMINDER_DEFERRAL : NORMAL_DEFERRAL;
1073 mDeferralTime = dateTime;
1074 if (!data.timedDeferral)
1075 mDeferralTime.setDateOnly(
true);
1076 if (data.alarm->hasStartOffset())
1077 deferralOffset = data.alarm->startOffset();
1079 case DISPLAYING_ALARM:
1082 mDisplayingFlags = data.displayingFlags;
1083 const bool dateOnly = (mDisplayingFlags & DEFERRAL) ? !(mDisplayingFlags & TIMED_FLAG)
1084 : mStartDateTime.isDateOnly();
1085 mDisplayingTime = dateTime;
1086 mDisplayingTime.setDateOnly(dateOnly);
1087 alTime = mDisplayingTime;
1090 case PRE_ACTION_ALARM:
1091 mPreAction = data.cleanText;
1092 mExtraActionOptions = data.extraActionOptions;
1094 case POST_ACTION_ALARM:
1095 mPostAction = data.cleanText;
1102 bool noSetNextTime =
false;
1105 case DEFERRED_REMINDER_ALARM:
1106 case DEFERRED_ALARM:
1111 setDeferralTime =
true;
1112 noSetNextTime =
true;
1115 case REMINDER_ALARM:
1116 case AT_LOGIN_ALARM:
1117 case DISPLAYING_ALARM:
1118 if (!set && !noSetNextTime)
1119 mNextMainDateTime = alTime;
1127 mText = (mActionSubType ==
KAEvent::COMMAND) ? data.cleanText.trimmed() : data.cleanText;
1128 switch (data.action)
1131 mCommandScript = data.commandScript;
1132 if (!mCommandDisplay)
1137 mUseDefaultFont = data.defaultFont;
1138 if (data.isEmailText)
1142 mBgColour = data.bgColour;
1143 mFgColour = data.fgColour;
1146 mEmailFromIdentity = data.emailFromId;
1147 mEmailAddresses = data.alarm->mailAddresses();
1148 mEmailSubject = data.alarm->mailSubject();
1149 mEmailAttachments = data.alarm->mailAttachments();
1153 mRepeatSoundPause = data.repeatSoundPause;
1165 case PRE_ACTION_ALARM:
1166 case POST_ACTION_ALARM:
1173 mKMailSerialNumber = 0;
1176 if (recur && recur->
recurs())
1178 const int nextRepeat = mNextRepeat;
1179 setRecurrence(*recur);
1180 if (nextRepeat <= mRepetition.count())
1181 mNextRepeat = nextRepeat;
1183 else if (mRepetition)
1186 if (mRepetition.isDaily())
1187 recur->
setDaily(mRepetition.intervalDays());
1189 recur->
setMinutely(mRepetition.intervalMinutes());
1191 mRepetition.set(0, 0);
1196 mArchiveRepeatAtLogin =
false;
1197 if (mReminderMinutes > 0)
1199 mReminderMinutes = 0;
1200 mReminderActive = NO_REMINDER;
1202 setRepeatAtLoginTrue(
false);
1209 DateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1210 dt.setDateOnly(mStartDateTime.isDateOnly());
1211 if (mDeferralTime.isDateOnly())
1213 mDeferralTime = deferralOffset.
end(dt.kDateTime());
1214 mDeferralTime.setDateOnly(
true);
1217 mDeferralTime = deferralOffset.
end(dt.effectiveKDateTime());
1219 if (mDeferral != NO_DEFERRAL)
1221 if (setDeferralTime)
1222 mNextMainDateTime = mDeferralTime;
1224 mTriggerChanged =
true;
1228 void KAEvent::set(
const KDateTime& dt,
const QString& message,
const QColor& bg,
const QColor& fg,
1229 const QFont& f,
SubAction act,
int lateCancel, Flags flags,
bool changesPending)
1231 d->set(dt, message, bg, fg, f, act, lateCancel, flags, changesPending);
1237 void KAEventPrivate::set(
const KDateTime& dateTime,
const QString& text,
const QColor& bg,
const QColor& fg,
1239 bool changesPending)
1242 mStartDateTime = dateTime;
1244 mNextMainDateTime = mStartDateTime;
1259 mTemplateName.clear();
1260 #ifndef KALARMCAL_USE_KRESOURCES
1265 mOriginalResourceId.clear();
1268 mPostAction.clear();
1272 mAudioFile = (mActionSubType ==
KAEvent::AUDIO) ? text : QString();
1275 mTemplateAfterTime = -1;
1281 mLateCancel = lateCancel;
1282 mDeferral = NO_DEFERRAL;
1284 mStartDateTime.setDateOnly(flags & KAEvent::ANY_TIME);
1285 set_deferral((flags & DEFERRAL) ? NORMAL_DEFERRAL : NO_DEFERRAL);
1297 mDisplaying = flags & DISPLAYING_;
1306 setRepeatAtLoginTrue(
false);
1309 mKMailSerialNumber = 0;
1310 mReminderMinutes = 0;
1311 mDeferDefaultMinutes = 0;
1312 mDeferDefaultDateOnly =
false;
1313 mArchiveRepeatAtLogin =
false;
1314 mReminderActive = NO_REMINDER;
1315 mDisplaying =
false;
1316 mMainExpired =
false;
1317 mDisplayingDefer =
false;
1318 mDisplayingEdit =
false;
1320 mReminderAfterTime = DateTime();
1321 mExtraActionOptions = 0;
1322 #ifndef KALARMCAL_USE_KRESOURCES
1327 mChangeCount = changesPending ? 1 : 0;
1328 mTriggerChanged =
true;
1337 #ifndef KALARMCAL_USE_KRESOURCES
1340 return d->updateKCalEvent(e, u, setCustomProperties);
1346 return d->updateKCalEvent(e, u);
1350 #ifndef KALARMCAL_USE_KRESOURCES
1362 || (!mAlarmCount && (!archived || !mMainExpired)))
1367 const bool readOnly = ev->isReadOnly();
1369 ev->setUid(mEventID);
1370 #ifndef KALARMCAL_USE_KRESOURCES
1371 ev->setReadOnly(mReadOnly);
1373 ev->setReadOnly(
false);
1375 ev->setTransparency(Event::Transparent);
1380 #ifndef KALARMCAL_USE_KRESOURCES
1381 if (setCustomProperties)
1382 ev->setCustomProperties(mCustomProperties);
1392 #ifndef KALARMCAL_USE_KRESOURCES
1393 param = QString::number(mCollectionId);
1395 param = mOriginalResourceId;
1397 if (mDisplayingDefer)
1398 param += SC + DISP_DEFER;
1399 if (mDisplayingEdit)
1400 param += SC + DISP_EDIT;
1402 #ifndef KALARMCAL_USE_KRESOURCES
1403 CalEvent::setStatus(ev, mCategory, param);
1405 CalEvent::setStatus(ev, mCategory, param);
1408 if (mStartDateTime.isDateOnly())
1409 flags += DATE_ONLY_FLAG;
1411 flags += CONFIRM_ACK_FLAG;
1413 flags += EMAIL_BCC_FLAG;
1414 if (mCopyToKOrganizer)
1415 flags += KORGANIZER_FLAG;
1416 if (mExcludeHolidays)
1417 flags += EXCLUDE_HOLIDAYS_FLAG;
1419 flags += WORK_TIME_ONLY_FLAG;
1421 (flags += (mAutoClose ? AUTO_CLOSE_FLAG : LATE_CANCEL_FLAG)) += QString::number(mLateCancel);
1422 if (mReminderMinutes)
1424 flags += REMINDER_TYPE;
1425 if (mReminderOnceOnly)
1426 flags += REMINDER_ONCE_FLAG;
1427 flags += reminderToString(-mReminderMinutes);
1429 if (mDeferDefaultMinutes)
1431 QString param = QString::number(mDeferDefaultMinutes);
1432 if (mDeferDefaultDateOnly)
1433 param += QLatin1Char(
'D');
1434 (flags += DEFER_FLAG) += param;
1436 if (!mTemplateName.isEmpty() && mTemplateAfterTime >= 0)
1437 (flags += TEMPL_AFTER_TIME_FLAG) += QString::number(mTemplateAfterTime);
1438 if (mKMailSerialNumber)
1439 (flags += KMAIL_SERNUM_FLAG) += QString::number(mKMailSerialNumber);
1440 if (mArchive && !archived)
1442 flags += ARCHIVE_FLAG;
1443 if (mArchiveRepeatAtLogin)
1444 flags += AT_LOGIN_TYPE;
1446 if (!flags.isEmpty())
1451 else if (mCommandDisplay)
1453 else if (!mLogFile.isEmpty())
1456 ev->setCustomStatus(mEnabled ? QString() : DISABLED_STATUS);
1457 ev->setRevision(mRevision);
1472 ev->setDtStart(mStartDateTime.calendarKDateTime());
1473 ev->setAllDay(
false);
1474 ev->setHasEndDate(
false);
1476 const DateTime dtMain = archived ? mStartDateTime : mNextMainDateTime;
1477 int ancillaryType = 0;
1478 DateTime ancillaryTime;
1479 int ancillaryOffset = 0;
1480 if (!mMainExpired || archived)
1489 QDateTime dt = mNextMainDateTime.kDateTime().toTimeSpec(mStartDateTime.timeSpec()).dateTime();
1491 dt.toString(mNextMainDateTime.isDateOnly() ? QLatin1String(
"yyyyMMdd") : QLatin1String(
"yyyyMMddThhmmss")));
1494 initKCalAlarm(ev, 0, QStringList(), MAIN_ALARM);
1495 ancillaryOffset = 0;
1496 ancillaryType = dtMain.isValid() ? 2 : 0;
1498 else if (mRepetition)
1502 const QString param = QString::fromLatin1(
"%1:%2").arg(mRepetition.intervalMinutes()).arg(mRepetition.count());
1507 if (mRepeatAtLogin || (mArchiveRepeatAtLogin && archived))
1510 if (mArchiveRepeatAtLogin)
1511 dtl = mStartDateTime.calendarKDateTime().addDays(-1);
1512 else if (mAtLoginDateTime.isValid())
1513 dtl = mAtLoginDateTime;
1514 else if (mStartDateTime.isDateOnly())
1515 dtl = DateTime(KDateTime::currentLocalDate().addDays(-1), mStartDateTime.timeSpec());
1517 dtl = KDateTime::currentUtcDateTime();
1518 initKCalAlarm(ev, dtl, QStringList(AT_LOGIN_TYPE));
1519 if (!ancillaryType && dtl.isValid())
1521 ancillaryTime = dtl;
1527 DateTime nextDateTime = mNextMainDateTime;
1531 nextDateTime = mStartDateTime;
1539 KDateTime dt = mRecurrence->getNextDateTime(mStartDateTime.addDays(-1).kDateTime());
1540 dt.setDateOnly(mStartDateTime.isDateOnly());
1545 if (mReminderMinutes && (mReminderActive != NO_REMINDER || archived))
1548 if (mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
1551 startOffset = nextDateTime.calendarKDateTime().secsTo(mReminderAfterTime.calendarKDateTime());
1556 startOffset = -mReminderMinutes * 60;
1558 initKCalAlarm(ev, startOffset, QStringList(REMINDER_TYPE));
1560 if (!ancillaryType && (mReminderActive == ACTIVE_REMINDER || archived))
1562 ancillaryOffset = startOffset;
1566 if (mDeferral != NO_DEFERRAL)
1570 if (mDeferralTime.isDateOnly())
1572 startOffset = nextDateTime.secsTo(mDeferralTime.calendarKDateTime());
1573 list += DATE_DEFERRAL_TYPE;
1577 startOffset = nextDateTime.calendarKDateTime().secsTo(mDeferralTime.calendarKDateTime());
1578 list += TIME_DEFERRAL_TYPE;
1580 if (mDeferral == REMINDER_DEFERRAL)
1581 list += REMINDER_TYPE;
1582 initKCalAlarm(ev, startOffset, list);
1583 if (!ancillaryType && mDeferralTime.isValid())
1585 ancillaryOffset = startOffset;
1589 if (!mTemplateName.isEmpty())
1590 ev->setSummary(mTemplateName);
1591 else if (mDisplaying)
1593 QStringList list(DISPLAYING_TYPE);
1594 if (mDisplayingFlags & KAEvent::REPEAT_AT_LOGIN)
1595 list += AT_LOGIN_TYPE;
1596 else if (mDisplayingFlags & DEFERRAL)
1598 if (mDisplayingFlags & TIMED_FLAG)
1599 list += TIME_DEFERRAL_TYPE;
1601 list += DATE_DEFERRAL_TYPE;
1603 if (mDisplayingFlags & REMINDER)
1604 list += REMINDER_TYPE;
1605 initKCalAlarm(ev, mDisplayingTime, list);
1606 if (!ancillaryType && mDisplayingTime.isValid())
1608 ancillaryTime = mDisplayingTime;
1612 if ((mBeep || mSpeak || !mAudioFile.isEmpty()) && mActionSubType !=
KAEvent::AUDIO)
1615 if (ancillaryType == 2)
1616 initKCalAlarm(ev, ancillaryOffset, QStringList(), AUDIO_ALARM);
1618 initKCalAlarm(ev, ancillaryTime, QStringList(), AUDIO_ALARM);
1620 if (!mPreAction.isEmpty())
1623 if (ancillaryType == 2)
1624 initKCalAlarm(ev, ancillaryOffset, QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1626 initKCalAlarm(ev, ancillaryTime, QStringList(PRE_ACTION_TYPE), PRE_ACTION_ALARM);
1628 if (!mPostAction.isEmpty())
1631 if (ancillaryType == 2)
1632 initKCalAlarm(ev, ancillaryOffset, QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1634 initKCalAlarm(ev, ancillaryTime, QStringList(POST_ACTION_TYPE), POST_ACTION_ALARM);
1638 mRecurrence->writeRecurrence(*ev->recurrence());
1640 ev->clearRecurrence();
1641 if (mCreatedDateTime.isValid())
1642 ev->setCreated(mCreatedDateTime);
1643 ev->setReadOnly(readOnly);
1655 #ifndef KALARMCAL_USE_KRESOURCES
1656 Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1658 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
const DateTime& dt,
const QStringList& types, AlarmType type)
const
1661 const int startOffset = dt.isDateOnly() ? mStartDateTime.secsTo(dt)
1662 : mStartDateTime.calendarKDateTime().secsTo(dt.calendarKDateTime());
1663 return initKCalAlarm(event, startOffset, types, type);
1666 #ifndef KALARMCAL_USE_KRESOURCES
1667 Alarm::Ptr KAEventPrivate::initKCalAlarm(
const Event::Ptr& event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1669 Alarm* KAEventPrivate::initKCalAlarm(
Event* event,
int startOffsetSecs,
const QStringList& types, AlarmType type)
const
1672 QStringList alltypes;
1674 #ifndef KALARMCAL_USE_KRESOURCES
1677 Alarm* alarm =
event->newAlarm();
1680 if (type != MAIN_ALARM)
1690 setAudioAlarm(alarm);
1692 flags << KAEventPrivate::SPEAK_FLAG;
1693 if (mRepeatSoundPause >= 0)
1701 case PRE_ACTION_ALARM:
1702 setProcedureAlarm(alarm, mPreAction);
1704 flags << KAEventPrivate::EXEC_ON_DEFERRAL_FLAG;
1706 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
1708 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
1710 case POST_ACTION_ALARM:
1711 setProcedureAlarm(alarm, mPostAction);
1718 QString::number(mNextRepeat));
1720 case REMINDER_ALARM:
1723 if (types == QStringList(REMINDER_TYPE)
1724 && mReminderMinutes < 0 && mReminderActive == HIDDEN_REMINDER)
1728 flags << HIDDEN_REMINDER_FLAG;
1730 bool display =
false;
1731 switch (mActionSubType)
1734 alltypes += FILE_TYPE;
1744 setProcedureAlarm(alarm, mText);
1745 display = mCommandDisplay;
1748 alarm->
setEmailAlarm(mEmailSubject, mText, mEmailAddresses, mEmailAttachments);
1749 if (mEmailFromIdentity)
1750 flags << KAEventPrivate::EMAIL_ID_FLAG << QString::number(mEmailFromIdentity);
1753 setAudioAlarm(alarm);
1754 if (mRepeatSoundPause >= 0)
1756 alltypes += SOUND_REPEAT_TYPE;
1757 if (type == MAIN_ALARM)
1758 alltypes += QString::number(mRepeatSoundPause);
1764 QString::fromLatin1(
"%1;%2;%3").arg(mBgColour.name())
1765 .arg(mFgColour.name())
1766 .arg(mUseDefaultFont ? QString() : mFont.toString()));
1769 case DEFERRED_ALARM:
1770 case DEFERRED_REMINDER_ALARM:
1771 case AT_LOGIN_ALARM:
1772 case DISPLAYING_ALARM:
1776 if (!alltypes.isEmpty())
1778 if (!flags.isEmpty())
1785 return d->mAlarmCount && (d->mAlarmCount != 1 || !d->mRepeatAtLogin);
1790 d->mEnabled = enable;
1798 #ifndef KALARMCAL_USE_KRESOURCES
1806 return d->mReadOnly;
1822 return d->mMainExpired;
1835 KAEvent::Flags KAEventPrivate::flags()
const
1837 KAEvent::Flags result(0);
1841 if (mStartDateTime.isDateOnly()) result |= KAEvent::ANY_TIME;
1872 mEventID = CalEvent::uid(mEventID, s);
1874 mTriggerChanged =
true;
1879 return d->mCategory;
1899 return d->mRevision;
1902 #ifndef KALARMCAL_USE_KRESOURCES
1905 d->mCollectionId =
id;
1910 d->mCollectionId =
id;
1916 return d->mDisplaying ? -1 : d->mCollectionId;
1938 switch (d->mCategory)
1943 default: Q_ASSERT(0);
return false;
1945 if (!collectionMimeTypes.contains(mimetype))
1947 item.setMimeType(mimetype);
1948 item.setPayload<
KAEvent>(*this);
1954 d->mCompatibility = c;
1959 return d->mCompatibility;
1964 return d->mCustomProperties;
1968 void KAEvent::setResource(AlarmResource* r)
1973 AlarmResource* KAEvent::resource()
const
1975 return d->mResource;
1981 return d->mActionSubType;
1986 switch (d->mActionSubType)
1999 if (d->mRepeatAtLogin)
2001 d->mLateCancel = minutes;
2003 d->mAutoClose =
false;
2008 return d->mLateCancel;
2018 return d->mAutoClose;
2021 void KAEvent::setKMailSerialNumber(
unsigned long n)
2023 d->mKMailSerialNumber = n;
2026 unsigned long KAEvent::kmailSerialNumber()
const
2028 return d->mKMailSerialNumber;
2038 return (d->mActionSubType ==
MESSAGE
2039 || d->mActionSubType ==
EMAIL) ? d->mText : QString();
2044 return (d->mActionSubType ==
MESSAGE) ? d->mText : QString();
2049 return (d->mActionSubType ==
FILE) ? d->mText : QString();
2054 return d->mBgColour;
2059 return d->mFgColour;
2064 KAEventPrivate::mDefaultFont = f;
2069 return d->mUseDefaultFont;
2074 return d->mUseDefaultFont ? KAEventPrivate::mDefaultFont : d->mFont;
2079 return (d->mActionSubType ==
COMMAND) ? d->mText : QString();
2084 return d->mCommandScript;
2089 return d->mCommandXterm;
2094 return d->mCommandDisplay;
2097 #ifndef KALARMCAL_USE_KRESOURCES
2100 d->mCommandError = t;
2110 d->setCommandError(t, writeConfig);
2115 kDebug() << mEventID <<
"," << error;
2116 if (error == mCommandError)
2118 mCommandError = error;
2121 KConfigGroup config(KGlobal::config(), mCmdErrConfigGroup);
2123 config.deleteEntry(mEventID);
2127 switch (mCommandError)
2132 case KAEvent::CMD_ERROR_PRE_POST:
2133 errtext = CMD_ERROR_PRE_VALUE +
',' + CMD_ERROR_POST_VALUE;
2138 config.writeEntry(mEventID, errtext);
2149 d->setCommandError(configString);
2152 void KAEventPrivate::setCommandError(
const QString& configString)
2155 const QStringList errs = configString.split(
',');
2156 if (errs.indexOf(CMD_ERROR_VALUE) >= 0)
2160 if (errs.indexOf(CMD_ERROR_PRE_VALUE) >= 0)
2162 if (errs.indexOf(CMD_ERROR_POST_VALUE) >= 0)
2167 QString KAEvent::commandErrorConfigGroup()
2169 return KAEventPrivate::mCmdErrConfigGroup;
2175 return d->mCommandError;
2180 d->mLogFile = logfile;
2181 if (!logfile.isEmpty())
2182 d->mCommandDisplay = d->mCommandXterm =
false;
2192 return d->mConfirmAck;
2197 return d->mCopyToKOrganizer;
2200 #ifndef KALARMCAL_USE_KRESOURCES
2202 const QStringList& attachments)
2204 void KAEvent::setEmail(uint from,
const QList<KCal::Person>& addresses,
const QString& subject,
2205 const QStringList& attachments)
2208 d->mEmailFromIdentity = from;
2209 d->mEmailAddresses = addresses;
2210 d->mEmailSubject = subject;
2211 d->mEmailAttachments = attachments;
2216 return (d->mActionSubType ==
EMAIL) ? d->mText : QString();
2221 return d->mEmailFromIdentity;
2224 #ifndef KALARMCAL_USE_KRESOURCES
2230 return d->mEmailAddresses;
2235 return static_cast<QStringList
>(d->mEmailAddresses);
2240 return d->mEmailAddresses.join(sep);
2243 #ifndef KALARMCAL_USE_KRESOURCES
2249 return EmailAddressList(addresses).join(separator);
2254 return d->mEmailAddresses.pureAddresses();
2259 return d->mEmailAddresses.pureAddresses(sep);
2264 return d->mEmailSubject;
2269 return d->mEmailAttachments;
2274 return d->mEmailAttachments.join(sep);
2279 return d->mEmailBcc;
2282 void KAEvent::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2284 d->setAudioFile(filename, volume, fadeVolume, fadeSeconds, repeatPause, allowEmptyFile);
2287 void KAEventPrivate::setAudioFile(
const QString& filename,
float volume,
float fadeVolume,
int fadeSeconds,
int repeatPause,
bool allowEmptyFile)
2289 mAudioFile = filename;
2290 mSoundVolume = (!allowEmptyFile && filename.isEmpty()) ? -1 : volume;
2291 if (mSoundVolume >= 0)
2293 mFadeVolume = (fadeSeconds > 0) ? fadeVolume : -1;
2294 mFadeSeconds = (mFadeVolume >= 0) ? fadeSeconds : 0;
2301 mRepeatSoundPause = repeatPause;
2306 return d->mAudioFile;
2311 return d->mSoundVolume;
2316 return d->mSoundVolume >= 0 && d->mFadeSeconds ? d->mFadeVolume : -1;
2321 return d->mSoundVolume >= 0 && d->mFadeVolume >= 0 ? d->mFadeSeconds : 0;
2326 return d->mRepeatSoundPause >= 0;
2331 return d->mRepeatSoundPause;
2341 return (d->mActionSubType ==
MESSAGE
2342 || (d->mActionSubType ==
COMMAND && d->mCommandDisplay))
2352 d->mTemplateName = name;
2353 d->mTemplateAfterTime = afterTime;
2354 d->mTriggerChanged =
true;
2359 return !d->mTemplateName.isEmpty();
2364 return d->mTemplateName;
2369 return d->mTemplateAfterTime == 0;
2374 return d->mTemplateAfterTime;
2379 d->mPreAction = pre;
2380 d->mPostAction = post;
2381 d->mExtraActionOptions = options;
2386 ExtraActionOptions opts(0);
2396 return d->mPreAction;
2401 return d->mPostAction;
2406 return d->mExtraActionOptions;
2425 d->setReminder(minutes, onceOnly);
2428 void KAEventPrivate::setReminder(
int minutes,
bool onceOnly)
2430 if (minutes > 0 && mRepeatAtLogin)
2432 if (minutes != mReminderMinutes || (minutes && mReminderActive != ACTIVE_REMINDER))
2434 if (minutes && mReminderActive == NO_REMINDER)
2436 else if (!minutes && mReminderActive != NO_REMINDER)
2438 mReminderMinutes = minutes;
2439 mReminderActive = minutes ? ACTIVE_REMINDER : NO_REMINDER;
2440 mReminderOnceOnly = onceOnly;
2442 mTriggerChanged =
true;
2452 d->activateReminderAfter(mainAlarmTime);
2455 void KAEventPrivate::activateReminderAfter(
const DateTime& mainAlarmTime)
2457 if (mReminderMinutes >= 0 || mReminderActive == ACTIVE_REMINDER || !mainAlarmTime.
isValid())
2467 || mainAlarmTime != next)
2470 else if (!mRepeatAtLogin)
2473 if (mainAlarmTime != mStartDateTime)
2477 const DateTime reminderTime = mainAlarmTime.
addMins(-mReminderMinutes);
2480 && reminderTime >= next)
2484 activate_reminder(
true);
2485 mReminderAfterTime = reminderTime;
2490 return d->mReminderMinutes;
2495 return d->mReminderActive == KAEventPrivate::ACTIVE_REMINDER;
2500 return d->mReminderOnceOnly;
2505 return d->mDeferral == KAEventPrivate::REMINDER_DEFERRAL;
2516 return d->defer(dt, reminder, adjustRecurrence);
2519 void KAEventPrivate::defer(
const DateTime& dateTime,
bool reminder,
bool adjustRecurrence)
2522 bool setNextRepetition =
false;
2523 bool checkRepetition =
false;
2524 bool checkReminderAfter =
false;
2528 if (mReminderMinutes)
2530 bool deferReminder =
false;
2531 if (mReminderMinutes > 0)
2535 deferReminder =
true;
2536 else if (mReminderActive == ACTIVE_REMINDER || mDeferral == REMINDER_DEFERRAL)
2539 set_deferral(NO_DEFERRAL);
2540 mTriggerChanged =
true;
2543 else if (mReminderMinutes < 0 && reminder)
2544 deferReminder =
true;
2547 set_deferral(REMINDER_DEFERRAL);
2548 mDeferralTime = dateTime;
2549 mTriggerChanged =
true;
2551 if (mReminderActive == ACTIVE_REMINDER)
2553 activate_reminder(
false);
2554 mTriggerChanged =
true;
2557 if (mDeferral != REMINDER_DEFERRAL)
2561 mNextMainDateTime = mDeferralTime = dateTime;
2562 set_deferral(NORMAL_DEFERRAL);
2563 mTriggerChanged =
true;
2564 checkReminderAfter =
true;
2568 mMainExpired =
true;
2573 mArchiveRepeatAtLogin =
true;
2574 mRepeatAtLogin =
false;
2587 set_deferral(NO_DEFERRAL);
2591 set_deferral(REMINDER_DEFERRAL);
2592 mDeferralTime = dateTime;
2593 checkRepetition =
true;
2595 mTriggerChanged =
true;
2600 mDeferralTime = dateTime;
2601 if (mDeferral == NO_DEFERRAL)
2602 set_deferral(NORMAL_DEFERRAL);
2603 mTriggerChanged =
true;
2604 checkReminderAfter =
true;
2605 if (adjustRecurrence)
2607 const KDateTime now = KDateTime::currentUtcDateTime();
2608 if (mainEndRepeatTime() < now)
2614 mMainExpired =
true;
2619 setNextRepetition = mRepetition;
2622 checkRepetition =
true;
2624 if (checkReminderAfter && mReminderMinutes < 0 && mReminderActive != NO_REMINDER)
2628 mReminderActive = (mDeferralTime < mReminderAfterTime) ? ACTIVE_REMINDER : HIDDEN_REMINDER;
2630 if (checkRepetition)
2631 setNextRepetition = (mRepetition && mDeferralTime < mainEndRepeatTime());
2632 if (setNextRepetition)
2636 if (mNextMainDateTime >= mDeferralTime)
2639 mNextRepeat = mRepetition.nextRepeatCount(mNextMainDateTime.kDateTime(), mDeferralTime.kDateTime());
2640 mTriggerChanged =
true;
2653 void KAEventPrivate::cancelDefer()
2655 if (mDeferral != NO_DEFERRAL)
2658 set_deferral(NO_DEFERRAL);
2659 mTriggerChanged =
true;
2665 d->mDeferDefaultMinutes = minutes;
2666 d->mDeferDefaultDateOnly = dateOnly;
2671 return d->mDeferral > 0;
2676 return d->mDeferralTime;
2684 return d->deferralLimit(limitType);
2697 const KDateTime now = KDateTime::currentUtcDateTime();
2703 else if (mReminderActive == ACTIVE_REMINDER && mReminderMinutes > 0
2704 && (now < (reminderTime = endTime.
addMins(-mReminderMinutes))))
2706 endTime = reminderTime;
2712 else if (mReminderMinutes < 0)
2716 if (KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2718 endTime = mNextMainDateTime;
2722 else if (mReminderMinutes > 0
2723 && KDateTime::currentUtcDateTime() < mNextMainDateTime.effectiveKDateTime())
2727 endTime = mNextMainDateTime;
2731 endTime = endTime.
addMins(-1);
2739 return d->mDeferDefaultMinutes;
2744 return d->mDeferDefaultDateOnly;
2749 return d->mStartDateTime;
2754 d->mNextMainDateTime = dt;
2755 d->mTriggerChanged =
true;
2760 return d->mainDateTime(withRepeats);
2765 return d->mNextMainDateTime.effectiveTime();
2770 return d->mainEndRepeatTime();
2780 #warning Does this need all trigger times for date-only alarms to be recalculated?
2791 for (
int i = 0, end = events.count(); i < end; ++i)
2793 KAEventPrivate*
const p = events[i]->d;
2795 p->mRecurrence->setStartDateTime(p->mStartDateTime.effectiveKDateTime(),
true);
2801 d->calcTriggerTimes();
2810 const bool reminderAfter = d->mMainExpired && d->mReminderActive && d->mReminderMinutes < 0;
2812 ? (reminderAfter ? d->mAllWorkTrigger : d->mMainWorkTrigger)
2813 : (reminderAfter ? d->mAllTrigger : d->mMainTrigger);
2821 d->mCreatedDateTime = dt;
2826 return d->mCreatedDateTime;
2834 d->setRepeatAtLogin(rl);
2837 void KAEventPrivate::setRepeatAtLogin(
bool rl)
2839 if (rl && !mRepeatAtLogin)
2841 setRepeatAtLoginTrue(
true);
2844 else if (!rl && mRepeatAtLogin)
2846 mRepeatAtLogin = rl;
2847 mTriggerChanged =
true;
2853 void KAEventPrivate::setRepeatAtLoginTrue(
bool clearReminder)
2856 if (mReminderMinutes >= 0 && clearReminder)
2857 setReminder(0,
false);
2860 mCopyToKOrganizer =
false;
2865 return d->mRepeatAtLogin || (includeArchived && d->mArchiveRepeatAtLogin);
2870 d->mExcludeHolidays = ex ? KAEventPrivate::mHolidays : 0;
2877 return d->mExcludeHolidays;
2889 KAEventPrivate::mHolidays = &h;
2894 d->mWorkTimeOnly = wto;
2901 return d->mWorkTimeOnly;
2910 return d->isWorkingTime(dt);
2913 bool KAEventPrivate::isWorkingTime(
const KDateTime& dt)
const
2915 if ((mWorkTimeOnly && !mWorkDays.testBit(dt.date().dayOfWeek() - 1))
2916 || (mExcludeHolidays && mHolidays && mHolidays->isHoliday(dt.date())))
2920 return dt.isDateOnly()
2921 || (dt.time() >= mWorkDayStart && dt.time() < mWorkDayEnd);
2931 if (days != KAEventPrivate::mWorkDays || start != KAEventPrivate::mWorkDayStart || end != KAEventPrivate::mWorkDayEnd)
2933 KAEventPrivate::mWorkDays = days;
2934 KAEventPrivate::mWorkDayStart = start;
2935 KAEventPrivate::mWorkDayEnd = end;
2936 if (!++KAEventPrivate::mWorkTimeIndex)
2937 ++KAEventPrivate::mWorkTimeIndex;
2949 void KAEventPrivate::clearRecur()
2951 if (mRecurrence || mRepetition)
2955 mRepetition.set(0, 0);
2956 mTriggerChanged =
true;
2967 d->setRecurrence(recurrence);
2970 void KAEventPrivate::setRecurrence(
const KARecurrence& recurrence)
2977 mRecurrence->setStartDateTime(mStartDateTime.effectiveKDateTime(), mStartDateTime.isDateOnly());
2978 mTriggerChanged =
true;
2983 mTriggerChanged =
true;
2988 setRepetition(mRepetition);
3005 const bool success = d->setRecur(RecurrenceRule::rMinutely, freq, count, end);
3006 d->mTriggerChanged =
true;
3023 const bool success = d->setRecur(RecurrenceRule::rDaily, freq, count, end);
3027 for (
int i = 0; i < 7; ++i)
3029 if (days.testBit(i))
3033 d->mRecurrence->addWeeklyDays(days);
3035 d->mTriggerChanged =
true;
3052 const bool success = d->setRecur(RecurrenceRule::rWeekly, freq, count, end);
3054 d->mRecurrence->addWeeklyDays(days);
3055 d->mTriggerChanged =
true;
3072 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3075 for (
int i = 0, end = days.count(); i < end; ++i)
3076 d->mRecurrence->addMonthlyDate(days[i]);
3078 d->mTriggerChanged =
true;
3096 const bool success = d->setRecur(RecurrenceRule::rMonthly, freq, count, end);
3099 for (
int i = 0, end = posns.count(); i < end; ++i)
3100 d->mRecurrence->addMonthlyPos(posns[i].weeknum, posns[i].days);
3102 d->mTriggerChanged =
true;
3122 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end, feb29);
3125 for (
int i = 0, end = months.count(); i < end; ++i)
3126 d->mRecurrence->addYearlyMonth(months[i]);
3128 d->mRecurrence->addMonthlyDate(day);
3130 d->mTriggerChanged =
true;
3149 const bool success = d->setRecur(RecurrenceRule::rYearly, freq, count, end);
3154 for (iend = months.count(); i < iend; ++i)
3155 d->mRecurrence->addYearlyMonth(months[i]);
3156 for (i = 0, iend = posns.count(); i < iend; ++i)
3157 d->mRecurrence->addYearlyPos(posns[i].weeknum, posns[i].days);
3159 d->mTriggerChanged =
true;
3175 KDateTime edt = mNextMainDateTime.kDateTime();
3177 return setRecur(recurType, freq, count, edt, feb29);
3181 if (count >= -1 && (count || end.date().isValid()))
3184 mRecurrence =
new KARecurrence;
3185 if (mRecurrence->init(recurType, freq, count, mNextMainDateTime.kDateTime(), end, feb29))
3199 return d->checkRecur();
3204 return d->mRecurrence;
3214 switch (d->mRecurrence->type())
3223 return d->mRecurrence->frequency();
3233 return d->mRecurrence ? d->mRecurrence->longestInterval() :
Duration(0);
3243 d->setFirstRecurrence();
3246 void KAEventPrivate::setFirstRecurrence()
3248 switch (checkRecur())
3255 if (mRecurrence->yearMonths().isEmpty())
3264 const KDateTime recurStart = mRecurrence->startDateTime();
3265 if (mRecurrence->recursOn(recurStart.date(), recurStart.timeSpec()))
3269 const int frequency = mRecurrence->frequency();
3270 mRecurrence->setFrequency(1);
3272 nextRecurrence(mNextMainDateTime.effectiveKDateTime(), next);
3273 if (!next.isValid())
3274 mRecurrence->setStartDateTime(recurStart, mStartDateTime.isDateOnly());
3277 mRecurrence->setStartDateTime(next.effectiveKDateTime(), next.isDateOnly());
3278 mStartDateTime = mNextMainDateTime = next;
3279 mTriggerChanged =
true;
3281 mRecurrence->setFrequency(frequency);
3289 if (d->mRepeatAtLogin)
3290 return brief ? i18nc(
"@info/plain Brief form of 'At Login'",
"Login") : i18nc(
"@info/plain",
"At login");
3293 const int frequency = d->mRecurrence->frequency();
3294 switch (d->mRecurrence->defaultRRuleConst()->recurrenceType())
3296 case RecurrenceRule::rMinutely:
3298 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", frequency);
3299 else if (frequency % 60 == 0)
3300 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", frequency/60);
3304 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", frequency/60, mins.sprintf(
"%02d", frequency%60));
3306 case RecurrenceRule::rDaily:
3307 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", frequency);
3308 case RecurrenceRule::rWeekly:
3309 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", frequency);
3310 case RecurrenceRule::rMonthly:
3311 return i18ncp(
"@info/plain",
"1 Month",
"%1 Months", frequency);
3312 case RecurrenceRule::rYearly:
3313 return i18ncp(
"@info/plain",
"1 Year",
"%1 Years", frequency);
3314 case RecurrenceRule::rNone:
3319 return brief ? QString() : i18nc(
"@info/plain No recurrence",
"None");
3330 return d->setRepetition(r);
3333 bool KAEventPrivate::setRepetition(
const Repetition& repetition)
3338 if (repetition && !mRepeatAtLogin)
3341 if (!repetition.
isDaily() && mStartDateTime.isDateOnly())
3343 mRepetition.set(0, 0);
3346 Duration longestInterval = mRecurrence->longestInterval();
3347 if (repetition.
duration() >= longestInterval)
3349 const int count = mStartDateTime.isDateOnly()
3352 mRepetition.set(repetition.
interval(), count);
3355 mRepetition = repetition;
3356 mTriggerChanged =
true;
3358 else if (mRepetition)
3360 mRepetition.
set(0, 0);
3361 mTriggerChanged =
true;
3368 return d->mRepetition;
3373 return d->mNextRepeat;
3383 if (!d->mRepetition.isDaily())
3385 const int minutes = d->mRepetition.intervalMinutes();
3387 return i18ncp(
"@info/plain",
"1 Minute",
"%1 Minutes", minutes);
3388 if (minutes % 60 == 0)
3389 return i18ncp(
"@info/plain",
"1 Hour",
"%1 Hours", minutes/60);
3391 return i18nc(
"@info/plain Hours and minutes",
"%1h %2m", minutes/60, mins.sprintf(
"%02d", minutes%60));
3393 const int days = d->mRepetition.intervalDays();
3395 return i18ncp(
"@info/plain",
"1 Day",
"%1 Days", days);
3396 return i18ncp(
"@info/plain",
"1 Week",
"%1 Weeks", days / 7);
3398 return brief ? QString() : i18nc(
"@info/plain No repetition",
"None");
3408 return d->occursAfter(preDateTime, includeRepetitions);
3411 bool KAEventPrivate::occursAfter(
const KDateTime& preDateTime,
bool includeRepetitions)
const
3416 if (mRecurrence->duration() < 0)
3418 dt = mRecurrence->endDateTime();
3421 dt = mNextMainDateTime.effectiveKDateTime();
3422 if (mStartDateTime.isDateOnly())
3424 QDate pre = preDateTime.date();
3426 pre = pre.addDays(-1);
3427 if (pre < dt.date())
3430 else if (preDateTime < dt)
3433 if (includeRepetitions && mRepetition)
3435 if (preDateTime < mRepetition.duration().end(dt))
3451 return d->setNextOccurrence(preDateTime);
3456 if (preDateTime < mNextMainDateTime.effectiveKDateTime())
3458 KDateTime pre = preDateTime;
3463 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3467 if (pre < mNextMainDateTime.effectiveKDateTime())
3469 afterPre = mNextMainDateTime;
3474 type = nextRecurrence(pre, afterPre);
3480 mNextMainDateTime = afterPre;
3481 if (mReminderMinutes > 0 && (mDeferral == REMINDER_DEFERRAL || mReminderActive != ACTIVE_REMINDER))
3485 activate_reminder(!mReminderOnceOnly);
3487 if (mDeferral == REMINDER_DEFERRAL)
3488 set_deferral(NO_DEFERRAL);
3489 mTriggerChanged =
true;
3497 if (afterPre <= preDateTime)
3501 mNextRepeat = mRepetition.nextRepeatCount(afterPre.
effectiveKDateTime(), preDateTime);
3503 activate_reminder(
false);
3504 if (mDeferral == REMINDER_DEFERRAL)
3505 set_deferral(NO_DEFERRAL);
3506 mTriggerChanged =
true;
3508 else if (mNextRepeat)
3512 mTriggerChanged =
true;
3525 return d->nextOccurrence(preDateTime, result, o);
3531 KDateTime pre = preDateTime;
3537 pre = mRepetition.duration(-mRepetition.count()).end(preDateTime);
3543 type = nextRecurrence(pre, result);
3544 else if (pre < mNextMainDateTime.effectiveKDateTime())
3546 result = mNextMainDateTime;
3551 result = DateTime();
3559 const DateTime repeatDT = mRepetition.duration(repetition).end(result.
kDateTime());
3567 const KAEvent::OccurType newType = previousOccurrence(repeatDT.effectiveKDateTime(), dt,
false);
3575 repetition = mRepetition.nextRepeatCount(result.
kDateTime(), preDateTime);
3576 result = mRepetition.duration(repetition).end(result.
kDateTime());
3601 return d->previousOccurrence(afterDateTime, result, includeRepetitions);
3605 bool includeRepetitions)
const
3607 Q_ASSERT(!afterDateTime.isDateOnly());
3608 if (mStartDateTime >= afterDateTime)
3610 result = KDateTime();
3618 result = mStartDateTime;
3623 const KDateTime recurStart = mRecurrence->startDateTime();
3624 KDateTime after = afterDateTime.toTimeSpec(mStartDateTime.timeSpec());
3626 after = after.addDays(1);
3627 const KDateTime dt = mRecurrence->getPreviousDateTime(after);
3632 if (dt == recurStart)
3634 else if (mRecurrence->getNextDateTime(dt).isValid())
3640 if (includeRepetitions && mRepetition)
3643 const int repetition = mRepetition.previousRepeatCount(result.
effectiveKDateTime(), afterDateTime);
3646 result = mRepetition.duration(qMin(repetition, mRepetition.count())).end(result.
kDateTime());
3662 #ifndef KALARMCAL_USE_KRESOURCES
3668 return d->setDisplaying(*e.d, t,
id, dt, showEdit, showDefer);
3671 #ifndef KALARMCAL_USE_KRESOURCES
3673 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3675 bool KAEventPrivate::setDisplaying(
const KAEventPrivate& event,
KAAlarm::Type alarmType,
const QString& resourceID,
3676 const KDateTime& repeatAtLoginTime,
bool showEdit,
bool showDefer)
3687 KAAlarm al =
event.alarm(alarmType);
3693 #ifndef KALARMCAL_USE_KRESOURCES
3695 mCollectionId = collectionId;
3697 mOriginalResourceId = resourceID;
3699 mDisplayingDefer = showDefer;
3700 mDisplayingEdit = showEdit;
3709 default: mDisplayingFlags = 0;
break;
3721 #ifndef KALARMCAL_USE_KRESOURCES
3727 d->reinstateFromDisplaying(e,
id, showEdit, showDefer);
3730 #ifndef KALARMCAL_USE_KRESOURCES
3733 void KAEventPrivate::reinstateFromDisplaying(
const Event* kcalEvent, QString& resourceID,
bool& showEdit,
bool& showDefer)
3741 #ifndef KALARMCAL_USE_KRESOURCES
3742 collectionId = mCollectionId;
3745 resourceID = mOriginalResourceId;
3746 mOriginalResourceId.clear();
3748 showDefer = mDisplayingDefer;
3749 showEdit = mDisplayingEdit;
3750 mDisplaying =
false;
3764 KAAlarm::Private*
const al_d = al.d;
3765 const int displayingFlags = d->mDisplayingFlags;
3768 al_d->mRepeatAtLogin =
true;
3771 else if (displayingFlags & KAEventPrivate::DEFERRAL)
3773 al_d->mDeferred =
true;
3774 al_d->mTimedDeferral = (displayingFlags & KAEventPrivate::TIMED_FLAG);
3777 else if (displayingFlags & KAEventPrivate::REMINDER)
3786 return d->mDisplaying;
3801 KAAlarm::Private*
const al_d = al.d;
3805 al_d->mRepeatAtLogin =
false;
3806 al_d->mDeferred =
false;
3813 al_d->mNextMainDateTime = mNextMainDateTime;
3814 al_d->mRepetition = mRepetition;
3815 al_d->mNextRepeat = mNextRepeat;
3819 if (mReminderActive == ACTIVE_REMINDER)
3822 if (mReminderMinutes < 0)
3823 al_d->mNextMainDateTime = mReminderAfterTime;
3824 else if (mReminderOnceOnly)
3825 al_d->mNextMainDateTime = mStartDateTime.addMins(-mReminderMinutes);
3827 al_d->mNextMainDateTime = mNextMainDateTime.addMins(-mReminderMinutes);
3831 if (mDeferral != REMINDER_DEFERRAL)
3835 if (mDeferral != NO_DEFERRAL)
3838 al_d->mNextMainDateTime = mDeferralTime;
3839 al_d->mDeferred =
true;
3840 al_d->mTimedDeferral = !mDeferralTime.isDateOnly();
3847 al_d->mNextMainDateTime = mAtLoginDateTime;
3848 al_d->mRepeatAtLogin =
true;
3855 al_d->mNextMainDateTime = mDisplayingTime;
3875 return d->firstAlarm();
3878 KAAlarm KAEventPrivate::firstAlarm()
const
3896 return d->nextAlarm(previousAlarm.
type());
3901 return d->nextAlarm(previousType);
3906 switch (previousType)
3909 if (mReminderActive == ACTIVE_REMINDER)
3914 if (mDeferral == REMINDER_DEFERRAL)
3916 if (mDeferral == NORMAL_DEFERRAL)
3939 return d->mAlarmCount;
3949 d->removeExpiredAlarm(type);
3954 const int count = mAlarmCount;
3958 if (!mReminderActive || mReminderMinutes > 0)
3965 mMainExpired =
true;
3967 set_deferral(NO_DEFERRAL);
3970 mDisplaying =
false;
3978 mArchiveRepeatAtLogin =
true;
3979 mRepeatAtLogin =
false;
3986 activate_reminder(
false);
3990 set_deferral(NO_DEFERRAL);
3995 mDisplaying =
false;
4003 if (mAlarmCount != count)
4004 mTriggerChanged =
true;
4021 void KAEventPrivate::endChanges()
4023 if (mChangeCount > 0)
4027 #ifndef KALARMCAL_USE_KRESOURCES
4034 for (
int i = 0, count = objList.count(); i < count; ++i)
4035 ptrs += &objList[i];
4042 #ifndef KDE_NO_DEBUG_OUTPUT
4047 #ifndef KDE_NO_DEBUG_OUTPUT
4048 void KAEventPrivate::dumpDebug()
const
4050 kDebug() <<
"KAEvent dump:";
4051 #ifdef KALARMCAL_USE_KRESOURCES
4052 if (mResource) { kDebug() <<
"-- mResource:" << (
void*)mResource; }
4054 kDebug() <<
"-- mEventID:" << mEventID;
4056 kDebug() <<
"-- mNextMainDateTime:" << mNextMainDateTime.toString();
4057 kDebug() <<
"-- mCommandError:" << mCommandError;
4058 kDebug() <<
"-- mAllTrigger:" << mAllTrigger.toString();
4059 kDebug() <<
"-- mMainTrigger:" << mMainTrigger.toString();
4060 kDebug() <<
"-- mAllWorkTrigger:" << mAllWorkTrigger.toString();
4061 kDebug() <<
"-- mMainWorkTrigger:" << mMainWorkTrigger.toString();
4062 kDebug() <<
"-- mCategory:" << mCategory;
4063 if (!mTemplateName.isEmpty())
4065 kDebug() <<
"-- mTemplateName:" << mTemplateName;
4066 kDebug() <<
"-- mTemplateAfterTime:" << mTemplateAfterTime;
4068 kDebug() <<
"-- mText:" << mText;
4071 kDebug() <<
"-- mBgColour:" << mBgColour.name();
4072 kDebug() <<
"-- mFgColour:" << mFgColour.name();
4073 kDebug() <<
"-- mUseDefaultFont:" << mUseDefaultFont;
4074 if (!mUseDefaultFont)
4075 kDebug() <<
"-- mFont:" << mFont.toString();
4076 kDebug() <<
"-- mSpeak:" << mSpeak;
4077 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4078 kDebug() <<
"-- mPreAction:" << mPreAction;
4082 kDebug() <<
"-- mPostAction:" << mPostAction;
4083 kDebug() <<
"-- mLateCancel:" << mLateCancel;
4084 kDebug() <<
"-- mAutoClose:" << mAutoClose;
4088 kDebug() <<
"-- mCommandScript:" << mCommandScript;
4089 kDebug() <<
"-- mCommandXterm:" << mCommandXterm;
4090 kDebug() <<
"-- mCommandDisplay:" << mCommandDisplay;
4091 kDebug() <<
"-- mLogFile:" << mLogFile;
4095 kDebug() <<
"-- mEmail: FromKMail:" << mEmailFromIdentity;
4096 kDebug() <<
"-- Addresses:" << mEmailAddresses.join(QLatin1String(
","));
4097 kDebug() <<
"-- Subject:" << mEmailSubject;
4098 kDebug() <<
"-- Attachments:" << mEmailAttachments.join(QLatin1String(
","));
4099 kDebug() <<
"-- Bcc:" << mEmailBcc;
4102 kDebug() <<
"-- mAudioFile:" << mAudioFile;
4103 kDebug() <<
"-- mBeep:" << mBeep;
4106 if (mSoundVolume >= 0)
4108 kDebug() <<
"-- mSoundVolume:" << mSoundVolume;
4109 if (mFadeVolume >= 0)
4111 kDebug() <<
"-- mFadeVolume:" << mFadeVolume;
4112 kDebug() <<
"-- mFadeSeconds:" << mFadeSeconds;
4115 kDebug() <<
"-- mFadeVolume:-:";
4118 kDebug() <<
"-- mSoundVolume:-:";
4119 kDebug() <<
"-- mRepeatSoundPause:" << mRepeatSoundPause;
4121 kDebug() <<
"-- mKMailSerialNumber:" << mKMailSerialNumber;
4122 kDebug() <<
"-- mCopyToKOrganizer:" << mCopyToKOrganizer;
4123 kDebug() <<
"-- mExcludeHolidays:" << (bool)mExcludeHolidays;
4124 kDebug() <<
"-- mWorkTimeOnly:" << mWorkTimeOnly;
4125 kDebug() <<
"-- mStartDateTime:" << mStartDateTime.toString();
4126 kDebug() <<
"-- mCreatedDateTime:" << mCreatedDateTime;
4127 kDebug() <<
"-- mRepeatAtLogin:" << mRepeatAtLogin;
4129 kDebug() <<
"-- mAtLoginDateTime:" << mAtLoginDateTime;
4130 kDebug() <<
"-- mArchiveRepeatAtLogin:" << mArchiveRepeatAtLogin;
4131 kDebug() <<
"-- mConfirmAck:" << mConfirmAck;
4132 kDebug() <<
"-- mEnabled:" << mEnabled;
4133 #ifndef KALARMCAL_USE_KRESOURCES
4134 kDebug() <<
"-- mItemId:" << mItemId;
4135 kDebug() <<
"-- mCollectionId:" << mCollectionId;
4136 kDebug() <<
"-- mCompatibility:" << mCompatibility;
4137 kDebug() <<
"-- mReadOnly:" << mReadOnly;
4139 if (mReminderMinutes)
4141 kDebug() <<
"-- mReminderMinutes:" << mReminderMinutes;
4142 kDebug() <<
"-- mReminderActive:" << (mReminderActive == ACTIVE_REMINDER ?
"active" : mReminderActive == HIDDEN_REMINDER ?
"hidden" :
"no");
4143 kDebug() <<
"-- mReminderOnceOnly:" << mReminderOnceOnly;
4145 else if (mDeferral > 0)
4147 kDebug() <<
"-- mDeferral:" << (mDeferral == NORMAL_DEFERRAL ?
"normal" :
"reminder");
4148 kDebug() <<
"-- mDeferralTime:" << mDeferralTime.toString();
4150 kDebug() <<
"-- mDeferDefaultMinutes:" << mDeferDefaultMinutes;
4151 if (mDeferDefaultMinutes)
4152 kDebug() <<
"-- mDeferDefaultDateOnly:" << mDeferDefaultDateOnly;
4155 kDebug() <<
"-- mDisplayingTime:" << mDisplayingTime.toString();
4156 kDebug() <<
"-- mDisplayingFlags:" << mDisplayingFlags;
4157 kDebug() <<
"-- mDisplayingDefer:" << mDisplayingDefer;
4158 kDebug() <<
"-- mDisplayingEdit:" << mDisplayingEdit;
4160 kDebug() <<
"-- mRevision:" << mRevision;
4161 kDebug() <<
"-- mRecurrence:" << mRecurrence;
4163 kDebug() <<
"-- mRepetition: 0";
4164 else if (mRepetition.isDaily())
4165 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalDays() <<
"days";
4167 kDebug() <<
"-- mRepetition: count:" << mRepetition.count() <<
", interval:" << mRepetition.intervalMinutes() <<
"minutes";
4168 kDebug() <<
"-- mNextRepeat:" << mNextRepeat;
4169 kDebug() <<
"-- mAlarmCount:" << mAlarmCount;
4170 kDebug() <<
"-- mMainExpired:" << mMainExpired;
4171 kDebug() <<
"-- mDisplaying:" << mDisplaying;
4172 kDebug() <<
"KAEvent dump end";
4180 #ifndef KALARMCAL_USE_KRESOURCES
4181 DateTime KAEventPrivate::readDateTime(
const Event::Ptr& event,
bool dateOnly, DateTime& start)
4183 DateTime KAEventPrivate::readDateTime(
const Event* event,
bool dateOnly, DateTime& start)
4186 start =
event->dtStart();
4191 start.setDateOnly(
true);
4193 DateTime next = start;
4194 const QString prop =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::NEXT_RECUR_PROPERTY);
4195 if (prop.length() >= 8)
4198 const QDate d(prop.left(4).toInt(), prop.mid(4,2).toInt(), prop.mid(6,2).toInt());
4201 if (dateOnly && prop.length() == 8)
4203 else if (!dateOnly && prop.length() == 15 && prop[8] == QLatin1Char(
'T'))
4205 const QTime t(prop.mid(9,2).toInt(), prop.mid(11,2).toInt(), prop.mid(13,2).toInt());
4223 #ifndef KALARMCAL_USE_KRESOURCES
4224 void KAEventPrivate::readAlarms(
const Event::Ptr& event,
void* almap,
bool cmdDisplay)
4226 void KAEventPrivate::readAlarms(
const Event* event,
void* almap,
bool cmdDisplay)
4229 AlarmMap* alarmMap = (AlarmMap*)almap;
4233 bool audioOnly =
false;
4234 for (
int i = 0, end = alarms.count(); i < end; ++i)
4236 switch (alarms[i]->type())
4238 case Alarm::Display:
4239 case Alarm::Procedure:
4251 for (
int i = 0, end = alarms.count(); i < end; ++i)
4255 readAlarm(alarms[i], data, audioOnly, cmdDisplay);
4256 if (data.type != INVALID_ALARM)
4257 alarmMap->insert(data.type, data);
4266 #ifndef KALARMCAL_USE_KRESOURCES
4267 void KAEventPrivate::readAlarm(
const Alarm::Ptr& alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4269 void KAEventPrivate::readAlarm(
const Alarm* alarm, AlarmData& data,
bool audioMain,
bool cmdDisplay)
4274 data.displayingFlags = 0;
4275 data.isEmailText =
false;
4277 data.hiddenReminder =
false;
4278 data.timedDeferral =
false;
4279 data.nextRepeat = 0;
4280 data.repeatSoundPause = -1;
4285 int n =
static_cast<int>(
property.toUInt(&ok));
4287 data.nextRepeat = n;
4290 const QStringList flags =
property.split(KAEventPrivate::SC, QString::SkipEmptyParts);
4291 switch (alarm->
type())
4293 case Alarm::Procedure:
4296 data.commandScript = data.cleanText.isEmpty();
4299 if (!data.commandScript)
4300 data.cleanText += QLatin1Char(
' ');
4303 data.extraActionOptions = 0;
4304 if (flags.contains(KAEventPrivate::EXEC_ON_DEFERRAL_FLAG))
4305 data.extraActionOptions |= KAEvent::ExecPreActOnDeferral;
4306 if (flags.contains(KAEventPrivate::CANCEL_ON_ERROR_FLAG))
4307 data.extraActionOptions |= KAEvent::CancelOnPreActError;
4308 if (flags.contains(KAEventPrivate::DONT_SHOW_ERROR_FLAG))
4309 data.extraActionOptions |= KAEvent::DontShowPreActError;
4313 case Alarm::Display:
4315 if (alarm->
type() == Alarm::Display)
4321 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
4322 data.bgColour = QColor(255, 255, 255);
4323 data.fgColour = QColor(0, 0, 0);
4324 const int n = list.count();
4327 if (!list[0].isEmpty())
4333 if (n > 1 && !list[1].isEmpty())
4340 data.defaultFont = (n <= 2 || list[2].isEmpty());
4341 if (!data.defaultFont)
4342 data.font.fromString(list[2]);
4348 data.cleanText = alarm->
mailText();
4349 const int i = flags.indexOf(KAEventPrivate::EMAIL_ID_FLAG);
4350 data.emailFromId = (i >= 0 && i + 1 < flags.count()) ? flags[i + 1].toUInt() : 0;
4359 data.soundVolume = -1;
4360 data.fadeVolume = -1;
4361 data.fadeSeconds = 0;
4363 if (!property.isEmpty())
4368 const QStringList list =
property.split(QLatin1Char(
';'), QString::KeepEmptyParts);
4369 data.soundVolume = list[0].toFloat(&ok);
4370 if (!ok || data.soundVolume > 1.0f)
4371 data.soundVolume = -1;
4372 if (data.soundVolume >= 0 && list.count() >= 3)
4374 fadeVolume = list[1].toFloat(&ok);
4376 fadeSecs =
static_cast<int>(list[2].toUInt(&ok));
4377 if (ok && fadeVolume >= 0 && fadeVolume <= 1.0f && fadeSecs > 0)
4379 data.fadeVolume = fadeVolume;
4380 data.fadeSeconds = fadeSecs;
4386 data.type = AUDIO_ALARM;
4387 data.speak = flags.contains(KAEventPrivate::SPEAK_FLAG);
4392 case Alarm::Invalid:
4393 data.type = INVALID_ALARM;
4397 bool atLogin =
false;
4398 bool reminder =
false;
4399 bool deferral =
false;
4400 bool dateDeferral =
false;
4401 bool repeatSound =
false;
4402 data.type = MAIN_ALARM;
4404 const QStringList
types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
4405 for (
int i = 0, end = types.count(); i < end; ++i)
4407 const QString type = types[i];
4408 if (type == KAEventPrivate::AT_LOGIN_TYPE)
4410 else if (type == KAEventPrivate::FILE_TYPE && data.action ==
KAAlarm::MESSAGE)
4412 else if (type == KAEventPrivate::REMINDER_TYPE)
4414 else if (type == KAEventPrivate::TIME_DEFERRAL_TYPE)
4416 else if (type == KAEventPrivate::DATE_DEFERRAL_TYPE)
4417 dateDeferral = deferral =
true;
4418 else if (type == KAEventPrivate::DISPLAYING_TYPE)
4419 data.type = DISPLAYING_ALARM;
4420 else if (type == KAEventPrivate::PRE_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4421 data.type = PRE_ACTION_ALARM;
4422 else if (type == KAEventPrivate::POST_ACTION_TYPE && data.action ==
KAAlarm::COMMAND)
4423 data.type = POST_ACTION_ALARM;
4424 else if (type == KAEventPrivate::SOUND_REPEAT_TYPE && data.action ==
KAAlarm::AUDIO)
4430 uint n = types[i + 1].toUInt(&ok);
4433 data.repeatSoundPause = n;
4439 if (repeatSound && data.repeatSoundPause < 0)
4440 data.repeatSoundPause = 0;
4441 else if (!repeatSound)
4442 data.repeatSoundPause = -1;
4446 if (data.type == MAIN_ALARM)
4448 data.type = deferral ? DEFERRED_REMINDER_ALARM : REMINDER_ALARM;
4449 data.timedDeferral = (deferral && !dateDeferral);
4451 else if (data.type == DISPLAYING_ALARM)
4452 data.displayingFlags = dateDeferral ? REMINDER | DATE_DEFERRAL
4453 : deferral ? REMINDER | TIME_DEFERRAL : REMINDER;
4454 else if (data.type == REMINDER_ALARM
4455 && flags.contains(KAEventPrivate::HIDDEN_REMINDER_FLAG))
4456 data.hiddenReminder =
true;
4460 if (data.type == MAIN_ALARM)
4462 data.type = DEFERRED_ALARM;
4463 data.timedDeferral = !dateDeferral;
4465 else if (data.type == DISPLAYING_ALARM)
4466 data.displayingFlags = dateDeferral ? DATE_DEFERRAL : TIME_DEFERRAL;
4470 if (data.type == MAIN_ALARM)
4471 data.type = AT_LOGIN_ALARM;
4472 else if (data.type == DISPLAYING_ALARM)
4489 void KAEventPrivate::calcTriggerTimes()
const
4494 #warning May need to set date-only alarms to after start-of-day time in working-time checks
4497 if ((recurs && mWorkTimeOnly && mWorkTimeOnly != mWorkTimeIndex)
4498 || (recurs && mExcludeHolidays && mExcludeHolidays != mHolidays))
4502 mTriggerChanged =
true;
4504 else if (!mTriggerChanged)
4506 mTriggerChanged =
false;
4507 if (recurs && mWorkTimeOnly)
4508 mWorkTimeOnly = mWorkTimeIndex;
4509 if (recurs && mExcludeHolidays)
4510 mExcludeHolidays = mHolidays;
4515 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = KDateTime();
4517 else if (mDeferral == NORMAL_DEFERRAL)
4520 mAllTrigger = mMainTrigger = mAllWorkTrigger = mMainWorkTrigger = mDeferralTime;
4524 mMainTrigger = mainDateTime(
true);
4525 mAllTrigger = (mDeferral == REMINDER_DEFERRAL) ? mDeferralTime
4526 : (mReminderActive != ACTIVE_REMINDER) ? mMainTrigger
4527 : (mReminderMinutes < 0) ? mReminderAfterTime
4528 : mMainTrigger.addMins(-mReminderMinutes);
4532 if ((!mWorkTimeOnly && !mExcludeHolidays)
4534 || isWorkingTime(mMainTrigger.kDateTime()))
4538 mMainWorkTrigger = mMainTrigger;
4539 mAllWorkTrigger = mAllTrigger;
4541 else if (mWorkTimeOnly)
4547 if (!mExcludeHolidays)
4550 calcNextWorkingTime(mMainTrigger);
4555 DateTime nextTrigger = mMainTrigger;
4557 for (
int i = 0; i < 20; ++i)
4559 calcNextWorkingTime(nextTrigger);
4560 if (!mHolidays->isHoliday(mMainWorkTrigger.date()))
4562 kdt = mMainWorkTrigger.effectiveKDateTime();
4563 kdt.setTime(QTime(23,59,59));
4565 if (!nextTrigger.isValid())
4567 if (isWorkingTime(nextTrigger.kDateTime()))
4569 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4570 mMainWorkTrigger = nextTrigger;
4575 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4578 else if (mExcludeHolidays && mHolidays)
4581 DateTime nextTrigger = mMainTrigger;
4583 for (
int i = 0; i < 20; ++i)
4585 kdt = nextTrigger.effectiveKDateTime();
4586 kdt.setTime(QTime(23,59,59));
4588 if (!nextTrigger.isValid())
4590 if (!mHolidays->isHoliday(nextTrigger.date()))
4592 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4593 mMainWorkTrigger = nextTrigger;
4598 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4609 void KAEventPrivate::calcNextWorkingTime(
const DateTime& nextTrigger)
const
4611 kDebug() <<
"next=" << nextTrigger.kDateTime().dateTime();
4612 mMainWorkTrigger = mAllWorkTrigger = DateTime();
4614 for (
int i = 0; ; ++i)
4618 if (mWorkDays.testBit(i))
4622 KDateTime kdt = nextTrigger.effectiveKDateTime();
4623 const int reminder = (mReminderMinutes > 0) ? mReminderMinutes : 0;
4628 unsigned allDaysMask = 0x7F;
4629 bool noWorkPos =
false;
4630 const QList<RecurrenceRule::WDayPos> pos = rrule->byDays();
4631 const int nDayPos = pos.count();
4636 for (
int i = 0; i < nDayPos; ++i)
4638 const int day = pos[i].day() - 1;
4639 if (mWorkDays.testBit(day))
4641 allDaysMask |= 1 << day;
4643 if (noWorkPos && !mRepetition)
4648 if (mStartDateTime.isDateOnly())
4652 const int repeatFreq = mRepetition.intervalDays();
4653 const bool weeklyRepeat = mRepetition && !(repeatFreq % 7);
4654 const Duration interval = mRecurrence->regularInterval();
4655 if ((interval && !(interval.
asDays() % 7))
4659 if (!mRepetition || weeklyRepeat)
4665 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4666 dt.setTime(QTime(0,0,0));
4667 previousOccurrence(dt, newdt,
false);
4668 if (!newdt.isValid())
4670 kdt = newdt.effectiveKDateTime();
4671 const int day = kdt.date().dayOfWeek() - 1;
4672 for (
int repeatNum = mNextRepeat + 1; ; ++repeatNum)
4674 if (repeatNum > mRepetition.count())
4676 if (repeatNum == mNextRepeat)
4681 if (mWorkDays.testBit(day))
4683 mMainWorkTrigger = newdt;
4684 mAllWorkTrigger = mMainWorkTrigger.addMins(-reminder);
4687 kdt = newdt.effectiveKDateTime();
4691 const int inc = repeatFreq * repeatNum;
4692 if (mWorkDays.testBit((day + inc) % 7))
4694 kdt = kdt.addDays(inc);
4695 kdt.setDateOnly(
true);
4696 mMainWorkTrigger = mAllWorkTrigger = kdt;
4703 if (!mRepetition || weeklyRepeat)
4711 kdt.setTime(QTime(23,59,59));
4713 if (!newdt.isValid())
4715 kdt = newdt.effectiveKDateTime();
4716 const int day = kdt.date().dayOfWeek() - 1;
4717 if (mWorkDays.testBit(day))
4720 if ((days & allDaysMask) == allDaysMask)
4724 kdt.setDateOnly(
true);
4725 mMainWorkTrigger = kdt;
4726 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4733 unsigned days = 1 << (kdt.date().dayOfWeek() - 1);
4734 KDateTime dt(nextTrigger.kDateTime().addDays(1));
4735 dt.setTime(QTime(0,0,0));
4736 previousOccurrence(dt, newdt,
false);
4737 if (!newdt.isValid())
4739 kdt = newdt.effectiveKDateTime();
4740 int day = kdt.date().dayOfWeek() - 1;
4741 for (
int repeatNum = mNextRepeat; ; repeatNum = 0)
4743 while (++repeatNum <= mRepetition.count())
4745 const int inc = repeatFreq * repeatNum;
4746 if (mWorkDays.testBit((day + inc) % 7))
4748 kdt = kdt.addDays(inc);
4749 kdt.setDateOnly(
true);
4750 mMainWorkTrigger = mAllWorkTrigger = kdt;
4753 if ((days & allDaysMask) == allDaysMask)
4758 if (!newdt.isValid())
4760 kdt = newdt.effectiveKDateTime();
4761 day = kdt.date().dayOfWeek() - 1;
4762 if (mWorkDays.testBit(day))
4764 kdt.setDateOnly(
true);
4765 mMainWorkTrigger = kdt;
4766 mAllWorkTrigger = kdt.addSecs(-60 * reminder);
4769 if ((days & allDaysMask) == allDaysMask)
4787 const bool repeatTimeVaries = (mRepetition && !mRepetition.isDaily());
4789 if (!recurTimeVaries && !repeatTimeVaries)
4793 if (!mayOccurDailyDuringWork(kdt))
4797 bool repetition =
false;
4802 if (!newdt.isValid())
4805 kdt = newdt.effectiveKDateTime();
4806 const int day = kdt.date().dayOfWeek() - 1;
4807 if (mWorkDays.testBit(day))
4812 if ((days & allDaysMask) == allDaysMask)
4817 mMainWorkTrigger = nextTrigger;
4818 mMainWorkTrigger.setDate(kdt.date());
4819 mAllWorkTrigger = repetition ? mMainWorkTrigger : mMainWorkTrigger.addMins(-reminder);
4826 KTimeZone tz = kdt.timeZone();
4827 if (tz.isValid() && tz.type() ==
"KSystemTimeZone")
4830 const KTimeZone ktz = KSystemTimeZones::readZone(tz.name());
4834 const QList<KTimeZone::Transition> tzTransitions = tz.transitions();
4836 if (recurTimeVaries)
4855 repeatFreq = mRepetition.intervalSeconds();
4856 previousOccurrence(kdt.addSecs(1), newdt,
false);
4857 if (!newdt.isValid())
4859 kdtRecur = newdt.effectiveKDateTime();
4860 repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4861 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
4875 QTime firstTime = kdtRecur.time();
4876 int firstOffset = kdtRecur.utcOffset();
4877 int currentOffset = firstOffset;
4878 int dayRecur = kdtRecur.date().dayOfWeek() - 1;
4879 int firstDay = dayRecur;
4881 const bool subdaily = (repeatFreq < 24*3600);
4884 int transitionIndex = -1;
4885 for (
int n = 0; n < 7*24*60; ++n)
4893 const int inc = subdaily ? nextWorkRepetition(kdt) : 1;
4895 if (repeatNum > mRepetition.count())
4897 kdt = kdt.addSecs(inc * repeatFreq);
4898 const QTime t = kdt.time();
4899 if (t >= mWorkDayStart && t < mWorkDayEnd)
4901 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
4903 mMainWorkTrigger = mAllWorkTrigger = kdt;
4911 if (!newdt.isValid())
4913 kdtRecur = newdt.effectiveKDateTime();
4914 dayRecur = kdtRecur.date().dayOfWeek() - 1;
4915 const QTime t = kdtRecur.time();
4916 if (t >= mWorkDayStart && t < mWorkDayEnd)
4918 if (mWorkDays.testBit(dayRecur))
4920 mMainWorkTrigger = kdtRecur;
4921 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
4925 if (kdtRecur.utcOffset() != currentOffset)
4926 currentOffset = kdtRecur.utcOffset();
4927 if (t == firstTime && dayRecur == firstDay && currentOffset == firstOffset)
4933 if (!finalDate.isValid())
4934 finalDate = kdtRecur.date();
4935 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
4938 if (i > transitionIndex)
4939 transitionIndex = i;
4940 if (++transitionIndex >= static_cast<int>(tzTransitions.count()))
4943 kdtRecur = newdt.effectiveKDateTime();
4944 if (finalDate.daysTo(kdtRecur.date()) > 365)
4946 firstTime = kdtRecur.time();
4947 firstOffset = kdtRecur.utcOffset();
4948 currentOffset = firstOffset;
4949 firstDay = kdtRecur.date().dayOfWeek() - 1;
4957 if (repeatTimeVaries)
4966 const int repeatFreq = mRepetition.intervalSeconds();
4967 previousOccurrence(kdt.addSecs(1), newdt,
false);
4968 if (!newdt.isValid())
4970 KDateTime kdtRecur = newdt.effectiveKDateTime();
4971 const bool recurDuringWork = (kdtRecur.time() >= mWorkDayStart && kdtRecur.time() < mWorkDayEnd);
4975 const bool subdaily = (repeatFreq < 24*3600);
4977 bool checkTimeChangeOnly =
false;
4978 int transitionIndex = -1;
4979 for (
int limit = 10; --limit >= 0; )
4983 QDate dateRecur = kdtRecur.date();
4984 int dayRecur = dateRecur.dayOfWeek() - 1;
4985 int repeatNum = kdtRecur.secsTo(kdt) / repeatFreq;
4986 kdt = kdtRecur.addSecs(repeatNum * repeatFreq);
4994 KDateTime kdtNextRecur = newdt.effectiveKDateTime();
4996 int repeatsToCheck = mRepetition.count();
4997 int repeatsDuringWork = 0;
5001 if (repeatsDuringWork >= 0)
5006 int inc = subdaily ? nextWorkRepetition(kdt) : 1;
5008 const bool pastEnd = (repeatNum > mRepetition.count());
5010 inc -= repeatNum - mRepetition.count();
5011 repeatsToCheck -= inc;
5012 kdt = kdt.addSecs(inc * repeatFreq);
5013 if (kdtNextRecur.isValid() && kdt >= kdtNextRecur)
5017 repeatsToCheck = mRepetition.count();
5022 const QTime t = kdt.time();
5023 if (t >= mWorkDayStart && t < mWorkDayEnd)
5025 if (mWorkDays.testBit(kdt.date().dayOfWeek() - 1))
5027 mMainWorkTrigger = mAllWorkTrigger = kdt;
5030 repeatsDuringWork = 1;
5032 else if (!repeatsDuringWork && repeatsToCheck <= 0)
5035 repeatsDuringWork = -1;
5041 if (repeatsDuringWork < 0 && !recurDuringWork)
5045 if (!kdtNextRecur.isValid())
5047 if (checkTimeChangeOnly || (days & allDaysMask) == allDaysMask)
5049 kdtRecur = kdtNextRecur;
5051 kdtNextRecur = newdt.effectiveKDateTime();
5052 dateRecur = kdtRecur.date();
5053 dayRecur = dateRecur.dayOfWeek() - 1;
5054 if (recurDuringWork && mWorkDays.testBit(dayRecur))
5056 mMainWorkTrigger = kdtRecur;
5057 mAllWorkTrigger = kdtRecur.addSecs(-60 * reminder);
5060 days |= 1 << dayRecur;
5066 checkTimeChangeOnly =
true;
5067 const int i = tz.transitionIndex(kdtRecur.toUtc().dateTime());
5070 if (i > transitionIndex)
5071 transitionIndex = i;
5072 if (++transitionIndex >= static_cast<int>(tzTransitions.count()))
5074 kdt = KDateTime(tzTransitions[transitionIndex].time(), KDateTime::UTC);
5076 kdtRecur = newdt.effectiveKDateTime();
5087 int KAEventPrivate::nextWorkRepetition(
const KDateTime& pre)
const
5089 KDateTime nextWork(pre);
5090 if (pre.time() < mWorkDayStart)
5091 nextWork.setTime(mWorkDayStart);
5094 const int preDay = pre.date().dayOfWeek() - 1;
5095 for (
int n = 1; ; ++n)
5098 return mRepetition.count() + 1;
5099 if (mWorkDays.testBit((preDay + n) % 7))
5101 nextWork = nextWork.addDays(n);
5102 nextWork.setTime(mWorkDayStart);
5107 return (pre.secsTo(nextWork) - 1) / mRepetition.intervalSeconds() + 1;
5117 bool KAEventPrivate::mayOccurDailyDuringWork(
const KDateTime& kdt)
const
5119 if (!kdt.isDateOnly()
5120 && (kdt.time() < mWorkDayStart || kdt.time() >= mWorkDayEnd))
5123 const Duration interval = mRecurrence->regularInterval();
5124 if (interval && interval.
isDaily() && !(interval.
asDays() % 7))
5127 if (!mRepetition || (mRepetition.isDaily() && !(mRepetition.intervalDays() % 7)))
5131 int day = mRecurrence->startDateTime().date().dayOfWeek() - 1;
5132 const int repeatDays = mRepetition.intervalDays();
5133 const int maxRepeat = (mRepetition.count() < 6) ? mRepetition.count() : 6;
5134 for (
int i = 0; !mWorkDays.testBit(day); ++i, day = (day + repeatDays) % 7)
5146 #ifndef KALARMCAL_USE_KRESOURCES
5147 void KAEventPrivate::setAudioAlarm(
const Alarm::Ptr& alarm)
const
5149 void KAEventPrivate::setAudioAlarm(
Alarm* alarm)
const
5153 if (mSoundVolume >= 0)
5155 QString::fromLatin1(
"%1;%2;%3;%4").arg(QString::number(mSoundVolume,
'f', 2))
5156 .arg(QString::number(mFadeVolume,
'f', 2))
5157 .arg(mFadeSeconds));
5165 KAEvent::OccurType KAEventPrivate::nextRecurrence(
const KDateTime& preDateTime, DateTime& result)
const
5167 const KDateTime recurStart = mRecurrence->startDateTime();
5168 KDateTime pre = preDateTime.toTimeSpec(mStartDateTime.timeSpec());
5171 pre = pre.addDays(-1);
5174 const KDateTime dt = mRecurrence->getNextDateTime(pre);
5176 result.setDateOnly(mStartDateTime.isDateOnly());
5179 if (dt == recurStart)
5181 if (mRecurrence->duration() >= 0 && dt == mRecurrence->endDateTime())
5208 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5213 const_cast<KAEventPrivate*
>(
this)->clearRecur();
5223 #ifndef KALARMCAL_USE_KRESOURCES
5230 static const QChar SEPARATOR = QLatin1Char(
';');
5231 static const QChar LATE_CANCEL_CODE = QLatin1Char(
'C');
5232 static const QChar AT_LOGIN_CODE = QLatin1Char(
'L');
5233 static const QChar DEFERRAL_CODE = QLatin1Char(
'D');
5234 static const QString TEXT_PREFIX = QLatin1String(
"TEXT:");
5235 static const QString FILE_PREFIX = QLatin1String(
"FILE:");
5236 static const QString COMMAND_PREFIX = QLatin1String(
"CMD:");
5239 static const QString BEEP_CATEGORY = QLatin1String(
"BEEP");
5242 static const QString LATE_CANCEL_CAT = QLatin1String(
"LATECANCEL");
5245 static const QString TEMPL_DEF_TIME_CAT = QLatin1String(
"TMPLDEFTIME");
5248 static const QString EXEC_IN_XTERM_CAT = QLatin1String(
"XTERM");
5251 static const QString DATE_ONLY_CATEGORY = QLatin1String(
"DATE");
5252 static const QString EMAIL_BCC_CATEGORY = QLatin1String(
"BCC");
5253 static const QString CONFIRM_ACK_CATEGORY = QLatin1String(
"ACKCONF");
5254 static const QString KORGANIZER_CATEGORY = QLatin1String(
"KORG");
5255 static const QString DEFER_CATEGORY = QLatin1String(
"DEFER;");
5256 static const QString ARCHIVE_CATEGORY = QLatin1String(
"SAVE");
5257 static const QString ARCHIVE_CATEGORIES = QLatin1String(
"SAVE:");
5258 static const QString LATE_CANCEL_CATEGORY = QLatin1String(
"LATECANCEL;");
5259 static const QString AUTO_CLOSE_CATEGORY = QLatin1String(
"LATECLOSE;");
5260 static const QString TEMPL_AFTER_TIME_CATEGORY = QLatin1String(
"TMPLAFTTIME;");
5261 static const QString KMAIL_SERNUM_CATEGORY = QLatin1String(
"KMAIL:");
5262 static const QString LOG_CATEGORY = QLatin1String(
"LOG:");
5265 static const QByteArray KMAIL_ID_PROPERTY(
"KMAILID");
5268 static const QByteArray ARCHIVE_PROPERTY(
"ARCHIVE");
5269 static const QString ARCHIVE_REMINDER_ONCE_TYPE = QLatin1String(
"ONCE");
5270 static const QString REMINDER_ONCE_TYPE = QLatin1String(
"REMINDER_ONCE");
5271 static const QByteArray EMAIL_ID_PROPERTY(
"EMAILID");
5272 static const QByteArray SPEAK_PROPERTY(
"SPEAK");
5273 static const QByteArray CANCEL_ON_ERROR_PROPERTY(
"ERRCANCEL");
5274 static const QByteArray DONT_SHOW_ERROR_PROPERTY(
"ERRNOSHOW");
5276 bool adjustSummerTime =
false;
5277 if (calendarVersion == -Version(0,5,7))
5281 calendarVersion = -calendarVersion;
5282 adjustSummerTime =
true;
5285 if (calendarVersion >= currentCalendarVersion())
5288 kDebug() <<
"Adjusting version" << calendarVersion;
5289 const bool pre_0_7 = (calendarVersion < Version(0,7,0));
5290 const bool pre_0_9 = (calendarVersion < Version(0,9,0));
5291 const bool pre_0_9_2 = (calendarVersion < Version(0,9,2));
5292 const bool pre_1_1_1 = (calendarVersion < Version(1,1,1));
5293 const bool pre_1_2_1 = (calendarVersion < Version(1,2,1));
5294 const bool pre_1_3_0 = (calendarVersion < Version(1,3,0));
5295 const bool pre_1_3_1 = (calendarVersion < Version(1,3,1));
5296 const bool pre_1_4_14 = (calendarVersion < Version(1,4,14));
5297 const bool pre_1_5_0 = (calendarVersion < Version(1,5,0));
5298 const bool pre_1_9_0 = (calendarVersion < Version(1,9,0));
5299 const bool pre_1_9_2 = (calendarVersion < Version(1,9,2));
5300 const bool pre_1_9_7 = (calendarVersion < Version(1,9,7));
5301 const bool pre_1_9_9 = (calendarVersion < Version(1,9,9));
5302 const bool pre_1_9_10 = (calendarVersion < Version(1,9,10));
5303 const bool pre_2_2_9 = (calendarVersion < Version(2,2,9));
5304 const bool pre_2_3_0 = (calendarVersion < Version(2,3,0));
5305 const bool pre_2_3_2 = (calendarVersion < Version(2,3,2));
5306 const bool pre_2_7_0 = (calendarVersion < Version(2,7,0));
5307 Q_ASSERT(currentCalendarVersion() == Version(2,7,0));
5309 KTimeZone localZone;
5311 localZone = KSystemTimeZones::local();
5313 bool converted =
false;
5314 #ifndef KALARMCAL_USE_KRESOURCES
5319 for (
int ei = 0, eend = events.count(); ei < eend; ++ei)
5321 #ifndef KALARMCAL_USE_KRESOURCES
5324 Event*
event = events[ei];
5327 if (alarms.isEmpty())
5329 event->startUpdates();
5330 const bool readOnly =
event->isReadOnly();
5332 event->setReadOnly(
false);
5333 QStringList cats =
event->categories();
5334 bool addLateCancel =
false;
5337 if (pre_0_7 && event->
allDay())
5341 event->setAllDay(
false);
5358 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5360 #ifndef KALARMCAL_USE_KRESOURCES
5363 Alarm* alarm = alarms[ai];
5365 bool atLogin =
false;
5366 bool deferral =
false;
5367 bool lateCancel =
false;
5369 const QString txt = alarm->
text();
5370 const int length = txt.length();
5372 if (txt[0].isDigit())
5374 while (++i < length && txt[i].isDigit()) ;
5375 if (i < length && txt[i++] == SEPARATOR)
5379 const QChar ch = txt[i++];
5380 if (ch == SEPARATOR)
5382 if (ch == LATE_CANCEL_CODE)
5384 else if (ch == AT_LOGIN_CODE)
5386 else if (ch == DEFERRAL_CODE)
5393 if (txt.indexOf(TEXT_PREFIX, i) == i)
5394 i += TEXT_PREFIX.length();
5395 else if (txt.indexOf(FILE_PREFIX, i) == i)
5398 i += FILE_PREFIX.length();
5400 else if (txt.indexOf(COMMAND_PREFIX, i) == i)
5403 i += COMMAND_PREFIX.length();
5407 const QString altxt = txt.mid(i);
5413 types += KAEventPrivate::FILE_TYPE;
5419 setProcedureAlarm(alarm, altxt);
5427 types += KAEventPrivate::AT_LOGIN_TYPE;
5431 types += KAEventPrivate::TIME_DEFERRAL_TYPE;
5433 addLateCancel =
true;
5434 if (types.count() > 0)
5442 if (recur && recur->
recurs())
5451 if (adjustSummerTime)
5455 KDateTime dt = alarm->
time();
5456 const time_t t = dt.toTime_t();
5457 const struct tm* dtm = localtime(&t);
5460 dt = dt.addSecs(-3600);
5480 event->setCreated(event->
dtEnd());
5481 KDateTime start =
event->dtStart();
5484 event->setAllDay(
false);
5485 start.setTime(QTime(0, 0));
5486 flags += KAEventPrivate::DATE_ONLY_FLAG;
5488 event->setHasEndDate(
false);
5490 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5492 #ifndef KALARMCAL_USE_KRESOURCES
5495 Alarm* alarm = alarms[ai];
5500 if (!cats.isEmpty())
5502 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5504 #ifndef KALARMCAL_USE_KRESOURCES
5507 Alarm* alarm = alarms[ai];
5509 if (alarm->
type() == Alarm::Display)
5511 QString::fromLatin1(
"%1;;").arg(cats.at(0)));
5516 for (
int i = 0, end = cats.count(); i < end; ++i)
5518 if (cats.at(i) == BEEP_CATEGORY)
5522 #ifndef KALARMCAL_USE_KRESOURCES
5525 Alarm* alarm =
event->newAlarm();
5529 KDateTime dt =
event->dtStart();
5532 KAEventPrivate::AlarmMap alarmMap;
5533 KAEventPrivate::readAlarms(event, &alarmMap);
5534 KAEventPrivate::AlarmMap::ConstIterator it = alarmMap.constBegin();
5535 if (it != alarmMap.constEnd())
5537 dt = it.value().alarm->time();
5553 while ((i = cats.indexOf(LATE_CANCEL_CAT)) >= 0)
5556 addLateCancel =
true;
5566 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
5568 #ifndef KALARMCAL_USE_KRESOURCES
5571 Alarm* alarm = alarms[ai];
5573 if (alarm->
type() == Alarm::Display)
5575 const QString oldtext = alarm->
text();
5577 if (oldtext != newtext)
5590 while ((i = cats.indexOf(TEMPL_DEF_TIME_CAT)) >= 0)
5593 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += QLatin1String(
"0");
5604 while ((i = cats.indexOf(EXEC_IN_XTERM_CAT)) >= 0)
5607 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, KAEventPrivate::xtermURL);
5618 CalEvent::setStatus(event, CalEvent::status(event));
5619 for (
int i = 0; i < cats.count(); )
5621 const QString cat = cats.at(i);
5622 if (cat == DATE_ONLY_CATEGORY)
5623 flags += KAEventPrivate::DATE_ONLY_FLAG;
5624 else if (cat == CONFIRM_ACK_CATEGORY)
5625 flags += KAEventPrivate::CONFIRM_ACK_FLAG;
5626 else if (cat == EMAIL_BCC_CATEGORY)
5627 flags += KAEventPrivate::EMAIL_BCC_FLAG;
5628 else if (cat == KORGANIZER_CATEGORY)
5629 flags += KAEventPrivate::KORGANIZER_FLAG;
5630 else if (cat.startsWith(DEFER_CATEGORY))
5631 (flags += KAEventPrivate::DEFER_FLAG) += cat.mid(DEFER_CATEGORY.length());
5632 else if (cat.startsWith(TEMPL_AFTER_TIME_CATEGORY))
5633 (flags += KAEventPrivate::TEMPL_AFTER_TIME_FLAG) += cat.mid(TEMPL_AFTER_TIME_CATEGORY.length());
5634 else if (cat.startsWith(LATE_CANCEL_CATEGORY))
5635 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += cat.mid(LATE_CANCEL_CATEGORY.length());
5636 else if (cat.startsWith(AUTO_CLOSE_CATEGORY))
5637 (flags += KAEventPrivate::AUTO_CLOSE_FLAG) += cat.mid(AUTO_CLOSE_CATEGORY.length());
5638 else if (cat.startsWith(KMAIL_SERNUM_CATEGORY))
5639 (flags += KAEventPrivate::KMAIL_SERNUM_FLAG) += cat.mid(KMAIL_SERNUM_CATEGORY.length());
5640 else if (cat == ARCHIVE_CATEGORY)
5642 else if (cat.startsWith(ARCHIVE_CATEGORIES))
5643 event->setCustomProperty(
KACalendar::APPNAME, ARCHIVE_PROPERTY, cat.mid(ARCHIVE_CATEGORIES.length()));
5644 else if (cat.startsWith(LOG_CATEGORY))
5645 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::LOG_PROPERTY, cat.mid(LOG_CATEGORY.length()));
5661 event->
shiftTimes(KDateTime::ClockTime, localZone);
5666 (flags += KAEventPrivate::LATE_CANCEL_FLAG) += QLatin1String(
"1");
5667 if (!flags.isEmpty())
5668 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5671 if ((pre_1_4_14 || (pre_1_9_7 && !pre_1_9_0))
5681 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5682 const bool dateOnly = flags.contains(KAEventPrivate::DATE_ONLY_FLAG);
5683 KDateTime startDateTime =
event->dtStart();
5685 startDateTime.setDateOnly(
true);
5687 KDateTime nextMainDateTime;
5688 bool mainExpired =
true;
5689 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5691 #ifndef KALARMCAL_USE_KRESOURCES
5694 Alarm* alarm = alarms[i];
5705 bool mainAlarm =
true;
5707 const QStringList types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
5708 for (
int t = 0; t < types.count(); ++t)
5710 QString type = types[t];
5711 if (type == KAEventPrivate::AT_LOGIN_TYPE
5712 || type == KAEventPrivate::TIME_DEFERRAL_TYPE
5713 || type == KAEventPrivate::DATE_DEFERRAL_TYPE
5714 || type == KAEventPrivate::REMINDER_TYPE
5715 || type == REMINDER_ONCE_TYPE)
5727 mainExpired =
false;
5728 nextMainDateTime = alarm->
time();
5729 nextMainDateTime.setDateOnly(dateOnly);
5730 nextMainDateTime = nextMainDateTime.toTimeSpec(startDateTime);
5731 if (nextMainDateTime != startDateTime)
5733 QDateTime dt = nextMainDateTime.dateTime();
5735 dt.toString(dateOnly ? QLatin1String(
"yyyyMMdd") : QLatin1String(
"yyyyMMddThhmmss")));
5748 KDateTime dt =
event->recurrence()->getNextDateTime(startDateTime.addDays(-1));
5749 dt.setDateOnly(dateOnly);
5750 adjustment = startDateTime.secsTo(dt);
5753 adjustment = startDateTime.secsTo(nextMainDateTime);
5757 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5759 #ifndef KALARMCAL_USE_KRESOURCES
5762 Alarm* alarm = alarms[i];
5767 const QStringList types =
property.split(QLatin1Char(
','), QString::SkipEmptyParts);
5768 for (
int t = 0; t < types.count(); ++t)
5770 const QString type = types[t];
5771 if (type == KAEventPrivate::TIME_DEFERRAL_TYPE
5772 || type == KAEventPrivate::DATE_DEFERRAL_TYPE)
5783 if (pre_1_5_0 || (pre_1_9_9 && !pre_1_9_0))
5789 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5791 #ifndef KALARMCAL_USE_KRESOURCES
5794 Alarm* alarm = alarms[i];
5813 if (KAEventPrivate::convertRepetition(event))
5817 if (pre_2_2_9 || (pre_2_3_2 && !pre_2_3_0))
5823 if (KAEventPrivate::convertStartOfDay(event))
5837 bool flagsValid =
false;
5840 bool reminderOnce =
false;
5842 if (!prop.isEmpty())
5845 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5846 flags << KAEventPrivate::ARCHIVE_FLAG;
5848 if (prop != QLatin1String(
"0"))
5852 const QStringList list = prop.split(KAEventPrivate::SC, QString::SkipEmptyParts);
5853 for (
int i = 0; i < list.count(); ++i)
5855 if (list[i] == KAEventPrivate::AT_LOGIN_TYPE)
5856 flags << KAEventPrivate::AT_LOGIN_TYPE;
5857 else if (list[i] == ARCHIVE_REMINDER_ONCE_TYPE)
5858 reminderOnce =
true;
5859 else if (!list[i].isEmpty() && !list[i].startsWith(QChar::fromLatin1(
'-')))
5863 event->setCustomProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY, flags.join(KAEventPrivate::SC));
5867 for (
int i = 0, alend = alarms.count(); i < alend; ++i)
5869 #ifndef KALARMCAL_USE_KRESOURCES
5872 Alarm* alarm = alarms[i];
5877 if (!property.isEmpty())
5879 flags << KAEventPrivate::EMAIL_ID_FLAG << property;
5884 flags << KAEventPrivate::SPEAK_FLAG;
5889 flags << KAEventPrivate::CANCEL_ON_ERROR_FLAG;
5894 flags << KAEventPrivate::DONT_SHOW_ERROR_FLAG;
5897 if (!flags.isEmpty())
5904 QStringList types =
property.split(QChar::fromLatin1(
','), QString::SkipEmptyParts);
5905 const int r = types.indexOf(REMINDER_ONCE_TYPE);
5909 types[r] = KAEventPrivate::REMINDER_TYPE;
5911 reminderOnce =
true;
5913 if (r >= 0 || types.contains(KAEventPrivate::REMINDER_TYPE))
5922 else if (offset < 0)
5923 reminder = reminderToString(offset / 60);
5926 if (!reminder.isEmpty())
5930 flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5931 if (flags.indexOf(KAEventPrivate::REMINDER_TYPE) < 0)
5933 flags += KAEventPrivate::REMINDER_TYPE;
5935 flags += KAEventPrivate::REMINDER_ONCE_FLAG;
5942 event->setReadOnly(
true);
5943 event->endUpdates();
5952 #ifndef KALARMCAL_USE_KRESOURCES
5953 bool KAEventPrivate::convertStartOfDay(
const Event::Ptr& event)
5955 bool KAEventPrivate::convertStartOfDay(
Event* event)
5958 bool changed =
false;
5959 const QTime midnight(0, 0);
5960 const QStringList flags =
event->customProperty(
KACalendar::APPNAME, KAEventPrivate::FLAGS_PROPERTY).split(KAEventPrivate::SC, QString::SkipEmptyParts);
5961 if (flags.indexOf(KAEventPrivate::DATE_ONLY_FLAG) >= 0)
5964 const KDateTime oldDt =
event->dtStart();
5965 const int adjustment = oldDt.time().secsTo(midnight);
5968 event->setDtStart(KDateTime(oldDt.date(), midnight, oldDt.timeSpec()));
5969 int deferralOffset = 0;
5971 readAlarms(event, &alarmMap);
5972 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
5974 const AlarmData& data = it.value();
5975 if (!data.alarm->hasStartOffset())
5977 if (data.timedDeferral)
5980 deferralOffset = data.alarm->startOffset().asSeconds();
5981 #ifndef KALARMCAL_USE_KRESOURCES
5982 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
5984 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
5987 else if (data.type == AUDIO_ALARM
5988 && data.alarm->startOffset().asSeconds() == deferralOffset)
5991 #ifndef KALARMCAL_USE_KRESOURCES
5992 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(deferralOffset - adjustment);
5994 const_cast<Alarm*
>(data.alarm)->setStartOffset(deferralOffset - adjustment);
6004 bool foundDeferral =
false;
6005 int deferralOffset = 0;
6006 int newDeferralOffset = 0;
6008 const KDateTime nextMainDateTime = readDateTime(event,
false, start).kDateTime();
6010 readAlarms(event, &alarmMap);
6011 for (AlarmMap::ConstIterator it = alarmMap.constBegin(); it != alarmMap.constEnd(); ++it)
6013 const AlarmData& data = it.value();
6014 if (!data.alarm->hasStartOffset())
6016 if ((data.type & DEFERRED_ALARM) && !data.timedDeferral)
6019 KDateTime altime = data.alarm->startOffset().end(nextMainDateTime);
6020 altime.setTime(midnight);
6021 deferralOffset = data.alarm->startOffset().asSeconds();
6022 newDeferralOffset =
event->dtStart().secsTo(altime);
6023 #ifndef KALARMCAL_USE_KRESOURCES
6024 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6026 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6028 foundDeferral =
true;
6031 else if (foundDeferral
6032 && data.type == AUDIO_ALARM
6033 && data.alarm->startOffset().asSeconds() == deferralOffset)
6036 #ifndef KALARMCAL_USE_KRESOURCES
6037 const_cast<Alarm*
>(data.alarm.data())->setStartOffset(newDeferralOffset);
6039 const_cast<Alarm*
>(data.alarm)->setStartOffset(newDeferralOffset);
6056 #ifndef KALARMCAL_USE_KRESOURCES
6057 bool KAEventPrivate::convertRepetition(
const Event::Ptr& event)
6059 bool KAEventPrivate::convertRepetition(
Event* event)
6063 if (alarms.isEmpty())
6068 bool converted =
false;
6069 const bool readOnly =
event->isReadOnly();
6070 for (
int ai = 0, aend = alarms.count(); ai < aend; ++ai)
6072 #ifndef KALARMCAL_USE_KRESOURCES
6075 Alarm* alarm = alarms[ai];
6081 event->startUpdates();
6083 event->setReadOnly(
false);
6098 event->setReadOnly(
true);
6099 event->endUpdates();
6114 KAAlarm::Private::Private()
6115 : mType(INVALID_ALARM),
6117 mRepeatAtLogin(false),
6123 : d(new Private(*other.d))
6141 return d->mActionType;
6156 return (withRepeats && d->mNextRepeat && d->mRepetition)
6157 ? d->mRepetition.duration(d->mNextRepeat).end(d->mNextMainDateTime.kDateTime())
6158 : d->mNextMainDateTime;
6163 return d->mNextMainDateTime.date();
6168 return d->mNextMainDateTime.effectiveTime();
6173 return d->mRepeatAtLogin;
6183 return d->mDeferred;
6188 return d->mDeferred && d->mTimedDeferral;
6193 d->mNextMainDateTime = dt;
6198 d->mNextMainDateTime = dt;
6201 #ifdef KDE_NO_DEBUG_OUTPUT
6214 default:
return "INVALID";
6227 #ifndef KALARMCAL_USE_KRESOURCES
6228 EmailAddressList& EmailAddressList::operator=(
const Person::List& addresses)
6230 EmailAddressList& EmailAddressList::operator=(
const QList<Person>& addresses)
6234 for (
int p = 0, end = addresses.count(); p < end; ++p)
6236 #ifndef KALARMCAL_USE_KRESOURCES
6237 if (!addresses[p]->email().isEmpty())
6239 if (!addresses[p].email().isEmpty())
6241 append(addresses[p]);
6249 EmailAddressList::operator QStringList()
const
6252 for (
int p = 0, end = count(); p < end; ++p)
6261 QString EmailAddressList::join(
const QString& separator)
const
6265 for (
int p = 0, end = count(); p < end; ++p)
6270 result += separator;
6271 result += address(p);
6279 QString EmailAddressList::address(
int index)
const
6281 if (index < 0 || index > count())
6285 #ifndef KALARMCAL_USE_KRESOURCES
6287 const QString name = person->name();
6289 const Person person = (*this)[index];
6290 const QString name = person.
name();
6292 if (!name.isEmpty())
6295 for (
int i = 0, len = name.length(); i < len; ++i)
6297 const QChar ch = name[i];
6298 if (!ch.isLetterOrNumber())
6301 result += QLatin1Char(
'\"');
6305 #ifndef KALARMCAL_USE_KRESOURCES
6306 result += (*this)[index]->name();
6308 result += (*this)[index].name();
6310 result += (quote ? QLatin1String(
"\" <") : QLatin1String(
" <"));
6314 #ifndef KALARMCAL_USE_KRESOURCES
6315 result += person->
email();
6317 result += person.
email();
6320 result += QLatin1Char(
'>');
6327 QStringList EmailAddressList::pureAddresses()
const
6330 for (
int p = 0, end = count(); p < end; ++p)
6331 #ifndef KALARMCAL_USE_KRESOURCES
6332 list += at(p)->email();
6334 list += at(p).email();
6342 QString EmailAddressList::pureAddresses(
const QString& separator)
const
6346 for (
int p = 0, end = count(); p < end; ++p)
6351 result += separator;
6352 #ifndef KALARMCAL_USE_KRESOURCES
6353 result += at(p)->email();
6355 result += at(p).email();
6370 #ifndef KALARMCAL_USE_KRESOURCES
6371 static void setProcedureAlarm(
const Alarm::Ptr& alarm,
const QString& commandLine)
6373 static void setProcedureAlarm(
Alarm* alarm,
const QString& commandLine)
6379 bool quoted =
false;
6380 const uint posMax = commandLine.length();
6382 for (pos = 0; pos < posMax; ++pos)
6384 const QChar ch = commandLine[pos];
6387 if (ch == quoteChar)
6397 switch (ch.toLatin1())
6404 done = !command.isEmpty();
6408 if (command.isEmpty())
6426 for ( ; pos < posMax && commandLine[pos] == QLatin1Char(
' '); ++pos) ;
6427 arguments = commandLine.mid(pos);
6436 QString reminderToString(
int minutes)
6439 int count = abs(minutes);
6440 if (count % 1440 == 0)
6445 else if (count % 60 == 0)
6452 return QString::fromLatin1(
"%1%2").arg(count).arg(unit);
void setEnabled(bool enable)
the alarm displays something
void cancelDefer()
Cancel any deferral alarm which is pending.
virtual void shiftTimes(const KDateTime::Spec &oldSpec, const KDateTime::Spec &newSpec)
void setReminder(int minutes, bool onceOnly)
Set an additional reminder alarm.
KCalCore::Person::List emailAddressees() const
Return the list of email addressees, including names, for an email alarm.
the alarm displays command output
bool setRecurMinutely(int freq, int count, const KDateTime &end)
Set the recurrence to recur at a minutes interval.
yearly, on a specified date in each of the specified months
void setRepeatCount(int alarmRepeatCount)
bool repeatSound() const
Return whether the sound file will be repeated indefinitely.
Type type(const QString &mimeType)
Return the alarm Type for a mime type string.
OccurType setNextOccurrence(const KDateTime &preDateTime)
Set the date/time of the event to the next scheduled occurrence after a specified date/time...
KARecurrence * recurrence() const
Return the full recurrence data for the event.
bool recurs() const
Return whether the event recurs.
QTime time() const
Return the trigger time-of-day for the alarm.
void setRecurrence(const KARecurrence &r)
Initialise the event's recurrence from a KARecurrence.
weekly, on specified weekdays
QFont font() const
Return the font to use for alarm message texts.
Flags flags() const
Return the OR of various Flag enum status values.
Duration startOffset() const
QString repetitionText(bool brief=false) const
Return the repetition interval as text suitable for display.
bool cancelOnPreActionError() const
Return whether the alarm is to be cancelled if the pre-alarm action fails.
bool setRecurMonthlyByDate(int freq, const QVector< int > &days, int count, const QDate &end)
Set the recurrence to recur monthly, on the specified days within the month.
Reminder in advance of/after the main alarm.
void setEmailAlarm(const QString &subject, const QString &text, const Person::List &addressees, const QStringList &attachments=QStringList())
void dumpDebug() const
Output the event's data as debug output.
bool confirmAck() const
Return whether alarm acknowledgement must be confirmed by the user, for a display alarm...
THE real alarm. Must be the first in the enumeration.
the event is an alarm template
KCalCore::Duration interval() const
Return the interval between repetitions.
int lateCancel() const
Get the late cancellation period.
void setRepeatAtLogin(bool repeat)
Enable or disable repeat-at-login.
Type
The recurrence's period type.
DateTime addMins(qint64 n) const
Returns a DateTime value mins minutes later than the value of this object.
QSharedPointer< Alarm > Ptr
KAAlarm alarm(KAAlarm::Type type) const
Return the alarm of a specified type.
QString customProperty(const QByteArray &app, const QByteArray &key) const
KAAlarm represents individual alarms within a KAEvent.
DateTime mainEndRepeatTime() const
Return the time at which the last sub-repetition of the main alarm will occur.
int intervalSeconds() const
Return the repetition interval in terms of seconds.
QString customStatus() const
DateTime addSecs(qint64 n) const
Returns a DateTime value secs seconds later than the value of this object.
void setExcludeHolidays(bool exclude)
Enable or disable the alarm on holiday dates.
void setSnoozeTime(const Duration &alarmSnoozeTime)
void setDuration(int duration)
QSharedPointer< Event > Ptr
KCalCore::Duration longestRecurrenceInterval() const
Return the longest interval which can occur between consecutive recurrences.
bool speak() const
Return whether the displayed alarm text should be spoken.
OccurType previousOccurrence(const KDateTime &afterDateTime, DateTime &result, bool includeRepetitions=false) const
Get the date/time of the last previous occurrence of the event, before the specified date/time...
void setCategories(const QStringList &categories)
blind copy the email to the user
bool setRecurDaily(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur daily.
static QTime startOfDay()
Returns the start-of-day time.
Represents a sub-repetition, defined by interval and repeat count.
static void setWorkTime(const QBitArray &days, const QTime &start, const QTime &end)
Set working days and times, to be used by all KAEvent instances.
bool hasStartOffset() const
Recurrence * recurrence() const
auto-close the alarm window after the late-cancel period
int recurInterval() const
Return the recurrence interval in units of the recurrence period type (minutes, days, etc).
static void setStartOfDay(const QTime &sod)
Sets the start-of-day time.
void setLateCancel(int minutes)
Set or clear the late-cancel option.
KCalCore::Duration duration() const
Return the overall duration of the repetition.
bool isValid() const
Return whether the alarm is valid, i.e.
void startChanges()
Call before making a group of changes to the event, to avoid unnecessary calculation intensive recalc...
bool emailBcc() const
Return whether to send a blind copy of the email to the sender, for an email alarm.
post-alarm command execution failed
bool deferred() const
Return whether this is a deferred alarm.
static QString fromCalendarText(const QString &text, bool &email)
Translate an alarm calendar text to a display text.
void setAudioFile(const QString &filename, float volume, float fadeVolume, int fadeSeconds, int repeatPause=-1, bool allowEmptyFile=false)
Set the audio file related data for the event.
void set(const KCalCore::Event::Ptr &)
Initialise the instance from a KCalCore::Event.
static void setDefaultFont(const QFont &font)
Set the global default font for alarm message texts.
static void setHolidays(const KHolidays::HolidayRegion ®ion)
Set the holiday region to be used by all KAEvent instances.
next trigger time for display purposes (i.e. excluding reminders)
KACalendar::Compat compatibility() const
Return the event's storage format compatibility compared to the current KAlarm calendar format...
bool setRecurAnnualByDate(int freq, const QVector< int > &months, int day, KARecurrence::Feb29Type, int count, const QDate &end)
Set the recurrence to recur annually, on the specified day in each of the specified months...
QColor fgColour() const
Return the message window foreground color, for a display alarm.
void setEventId(const QString &id)
Set the event's unique identifier.
bool deferDefaultDateOnly() const
Return the default date-only setting used in the deferral dialog.
Type type() const
Return the alarm's type (main, reminder, etc.).
Actions actionTypes() const
Return the OR of the basic action types of the event's main alarm (display, command, email, audio).
yearly, on specified weekdays in the specified weeks of the specified months
void setProcedureAlarm(const QString &programFile, const QString &arguments=QString())
Feb29Type
When annual February 29th recurrences should occur in non-leap years.
bool setRepetition(const Repetition &r)
Initialise the event's sub-repetition.
int alarmCount() const
Return the number of alarms in the event, i.e.
bool setDisplaying(const KAEvent &event, KAAlarm::Type type, Akonadi::Collection::Id colId, const KDateTime &repeatAtLoginTime, bool showEdit, bool showDefer)
Set the event to be a copy of the specified event, making the specified alarm the 'displaying' alarm...
QString postAction() const
Return the shell command to execute after the display alarm is acknowledged.
int fadeSeconds() const
Return the fade period in seconds, or 0 if no fade is specified.
QStringList emailAttachments() const
Return the list of file paths of the attachments, for an email alarm.
DateTime deferDateTime() const
Return the time at which the currently pending deferred alarm should trigger.
bool holidaysExcluded() const
Return whether the alarm is disabled on holiday dates.
Akonadi::Item::Id itemId() const
Return the ID of the Akonadi Item which contains the event.
bool isTemplate() const
Return whether the event is an alarm template.
bool dontShowPreActionError() const
Return whether the user should not be notified if the pre-alarm action fails.
QVector< KAEvent * > List
A list of pointers to KAEvent objects.
KDateTime end(const KDateTime &start) const
Type
The category of an event, indicated by the middle part of its UID.
repeat the sound file while the alarm is displayed
DateTime mainDateTime(bool withRepeats=false) const
Return the next time the main alarm will trigger.
const QByteArray APPNAME
The application name ("KALARM") used in calendar properties.
check for recurrences only, ignore sub-repetitions
bool isWorkingTime(const KDateTime &dt) const
Check whether a date/time is during working hours and/or holidays, depending on the flags set for the...
DateTime dateTime(bool withRepeats=false) const
Return the trigger time for the alarm.
QString templateName() const
Return the alarm template's name.
Represents recurrences for KAlarm.
static QString toCalendarText(const QString &text)
Return the text for an alarm message text, in alarm calendar format.
Alarm::List alarms() const
void setCreatedDateTime(const KDateTime &dt)
Set the date/time the event was created, or saved in the archive calendar.
Duration snoozeTime() const
void endChanges()
Call when a group of changes preceded by startChanges() is complete, to allow resultant updates to oc...
int revision() const
Return the revision number of the event (SEQUENCE property in iCalendar).
KCal::Alarm::Display type: display a text message.
void setLogFile(const QString &logfile)
Set the log file to write command alarm output to.
bool toBeArchived() const
Return whether the event should be archived when it expires or is deleted.
Action
The basic KAAlarm action types.
QString emailSubject() const
Return the email subject line, for an email alarm.
the event is currently being displayed
bool isReminder() const
Return whether this is a reminder alarm.
QString logFile() const
Return the log file which command alarm output should be written to.
QTime mainTime() const
Return the time at which the main alarm will next trigger.
KAEvent()
Default constructor which creates an invalid event.
the event is currently active
KAAlarm & operator=(const KAAlarm &other)
Assignment operator.
bool isValid() const
Return whether the instance represents a valid event.
virtual KDateTime dtEnd() const
void removeCustomProperty(const QByteArray &app, const QByteArray &key)
KAAlarm firstAlarm() const
Return the main alarm for the event.
trigger the alarm only during working hours
DateTime nextTrigger(TriggerType type) const
Return the next time the alarm will trigger.
the alarm plays an audio file (without any display)
pre-alarm command execution failed
static const char * debugType(Type)
Return an alarm type as a string.
Action action() const
Return the action type for the alarm.
the command is a script, not a shell command line
QString message() const
Return the message text for a display alarm, or the email body for an email alarm.
CmdErrType commandError() const
Return the command execution error for the last time the alarm triggered.
don't trigger the alarm on holidays
bool beep() const
Return whether a beep should sound when the alarm is displayed.
OccurType nextOccurrence(const KDateTime &preDateTime, DateTime &result, OccurOption option=IGNORE_REPETITION) const
Get the date/time of the next occurrence of the event, after the specified date/time.
void setDeferDefaultMinutes(int minutes, bool dateOnly=false)
Set defaults for the deferral dialog.
bool recurs() const
Returns whether the event recurs at all.
the alarm is currently disabled
KAAlarm convertDisplayingAlarm() const
Return the original alarm which the displaying alarm refers to.
void setNoRecur()
Clear the event's recurrence and sub-repetition data.
KDateTime effectiveKDateTime() const
Returns the date and time of the value.
DeferLimitType
What type of occurrence currently limits how long the alarm can be deferred.
void setCommandError(CmdErrType error) const
Set or clear the command execution error for the last time the alarm triggered.
only trigger the reminder on the first recurrence
bool setRecurMonthlyByPos(int freq, const QVector< MonthPos > &pos, int count, const QDate &end)
Set the recurrence to recur monthly, on the specified weekdays in the specified weeks of the month...
void setReadOnly(bool ro)
Set the read-only status of the alarm.
cancel alarm on pre-alarm action error
void setCustomProperty(const QByteArray &app, const QByteArray &key, const QString &value)
float fadeVolume() const
Return the initial volume which will fade to the final volume.
execute pre-alarm action also for deferred alarms
CmdErrType
Command execution error type for last time the alarm was triggered.
void setFirstRecurrence()
Adjust the event date/time to the first recurrence of the event, on or after the event start date/tim...
next main working time trigger, excluding reminders
void setTime(const DateTime &dt)
Set the alarm's trigger time.
bool isValid() const
Returns true if the date is valid and, if it is a date-time value, the time is also valid...
a recurrence with only a date, not a time
void setAutoClose(bool autoclose)
Enable or disable auto-close for a display alarm, i.e.
bool reminderOnceOnly() const
Return whether the reminder alarm is triggered only for the first recurrence.
bool displaying() const
Return whether the alarm is currently being displayed, i.e.
speak the message when the alarm is displayed
int deferDefaultMinutes() const
Return the default deferral interval used in the deferral dialog.
bool commandScript() const
Return whether a command script is specified, for a command alarm.
KCal::Alarm::Audio type: play a sound file.
the alarm executes a command
bool enabled() const
Return the enabled status of the alarm.
QString id() const
Return the event's unique identifier.
sound an audible beep when the alarm is displayed
bool occursAfter(const KDateTime &preDateTime, bool includeRepetitions) const
Determine whether the event will occur after the specified date/time.
void setArchive()
Set the event to be archived when it expires or is deleted.
bool repeatAtLogin(bool includeArchived=false) const
Return whether the alarm repeats at login.
TriggerType
Alarm trigger type.
only a date is specified for the alarm, not a time
int reminderMinutes() const
Return the number of minutes BEFORE the main alarm when a reminder alarm is set.
a recurrence with a date and time
bool useDefaultFont() const
Return whether to use the default font (as set by setDefaultFont()) for alarm message texts...
void incrementRevision()
Increment the revision number of the event (SEQUENCE property in iCalendar).
DateTime startDateTime() const
Return the start time for the event.
closing the alarm message window requires a confirmation prompt
bool isDateOnly() const
Returns true if it is date-only value.
void setTime(const KDateTime &alarmTime)
void setCompatibility(KACalendar::Compat c)
Note the event's storage format compatibility compared to the current KAlarm calendar format...
bool repeatAtLogin() const
Return whether this is a repeat-at-login alarm.
QString audioFile() const
Return the audio file path.
static bool convertKCalEvents(const KCalCore::Calendar::Ptr &, int calendarVersion)
If a calendar was written by a previous version of KAlarm, do any necessary format conversions on the...
void setStartOffset(const Duration &offset)
bool timedDeferral() const
Return whether in the case of a deferred alarm, it is timed (as opposed to date-only).
ExtraActionOptions extraActionOptions() const
Return the pre- and post-alarm action options.
the first occurrence (takes precedence over LAST_RECURRENCE)
KAAlarm()
Default constructor, which creates an invalid instance.
KCal::Alarm::Display type: display a file (URL given by the alarm text)
verify that the KCal::Event UID is already the same as the KAEvent ID, if the latter is non-empty ...
repeat the alarm at every login
QSharedPointer< Calendar > Ptr
next actual working time trigger, including reminders
float soundVolume() const
Return the sound volume (the final volume if fade is specified).
void removeExpiredAlarm(KAAlarm::Type type)
Remove the alarm of the specified type from the event.
void activateReminderAfter(const DateTime &mainAlarmTime)
If there is a reminder which occurs AFTER the main alarm, activate the event's reminder which occurs ...
void setCollectionId(Akonadi::Collection::Id id)
Set the ID of the Akonadi Collection which contains the event.
QDate date() const
Return the trigger date for the alarm.
void defer(const DateTime &dt, bool reminder, bool adjustRecurrence=false)
Defer the event to the specified time.
static QString joinEmailAddresses(const KCalCore::Person::List &addresses, const QString &sep)
Concatenate a list of email addresses into a string.
void setItemId(Akonadi::Item::Id id)
Set the ID of the Akonadi Item which contains the event.
OccurOption
How to treat sub-repetitions in nextOccurrence().
int nextRepeatCount(const KDateTime &from, const KDateTime &preDateTime) const
Find the repetition count for the next repetition after a specified time.
display the contents of a file
void setTemplate(const QString &name, int afterTime=-1)
Set the event to be an alarm template.
static void setStartOfDay(const QTime &)
Set the start-of-day time used by all date-only alarms.
void setAudioAlarm(const QString &audioFile=QString())
Copy of the alarm currently being displayed.
set the KCal::Event UID to the KAEvent ID
void setMinutely(int freq)
QSharedPointer< Person > Ptr
uint identityUoid(const QString &identityUoidOrName)
Fetch the uoid of an identity name or uoid string.
KCal::Alarm::Email type: send an email.
command alarm execution failed
bool isReadOnly() const
Return the read-only status of the alarm.
QStringList emailPureAddresses() const
Return the list of email addressees, excluding names, for an email alarm.
QString fileName() const
Return the path of the file whose contents are to be shown, for a display alarm.
KAAlarm nextAlarm(const KAAlarm &previousAlarm) const
Return the next alarm for the event, after the specified alarm.
Repetition repetition() const
Return the event's sub-repetition data.
bool commandDisplay() const
Return whether the command output is to be displayed in an alarm message window.
QString emailMessage() const
Return the email message body, for an email alarm.
OccurType
What type of occurrence is due.
KDateTime kDateTime() const
Returns the date and time of the value as a KDateTime.
KAEvent represents a KAlarm event.
static void adjustStartOfDay(const KAEvent::List &events)
Call when the user changes the start-of-day time, to adjust the data for each date-only event in a li...
bool autoClose() const
Return whether auto-close is enabled, i.e.
use the default alarm message font
void setActions(const QString &pre, const QString &post, ExtraActionOptions options)
Set the pre-alarm and post-alarm actions, and their options.
SubAction actionSubType() const
Return the action sub-type of the event's main alarm.
QString recurrenceText(bool brief=false) const
Return the recurrence interval as text suitable for display.
UidAction
How to deal with the event UID in updateKCalEvent().
execute the command in a terminal window
QStringList emailAddresses() const
Return a list of the email addresses, including names, for an email alarm.
void setEmail(uint from, const KCalCore::Person::List &, const QString &subject, const QStringList &attachments)
Set the email related data for the event.
bool setRecurAnnualByPos(int freq, const QVector< MonthPos > &pos, const QVector< int > &months, int count, const QDate &end)
Set the recurrence to recur annually, on the specified weekdays in the specified weeks of the specifi...
bool mainExpired() const
Return whether the event's main alarm has expired.
Actions
The basic action type(s) for the event's main alarm.
display command output in the alarm window
int templateAfterTime() const
Return the number of minutes (>= 0) after the default alarm time which is specified in the alarm temp...
bool isDaily() const
Check whether the repetition interval is in terms of days (as opposed to minutes).
CalEvent::Type category() const
Return the alarm category (active/archived/template, or displaying).
Additional repeat-at-login trigger.
void setEnabled(bool enable)
Enable or disable the alarm.
bool deferred() const
Return whether there is currently a deferred alarm pending.
bool copyToKOrganizer() const
Return whether KOrganizer should hold a copy of the event.
monthly, on specified weekdays in a specified week of the month
bool workTimeOnly() const
Return whether the alarm is disabled on non-working days and outside working hours.
uint emailFromId() const
Return the email identity to be used as the sender, for an email alarm.
QString command() const
Return the command or script to execute, for a command alarm.
void setTime(const KDateTime &dt)
Set the next time to trigger the alarm (excluding sub-repetitions).
bool usingDefaultTime() const
Return whether the alarm template does not specify a time.
bool setItemPayload(Akonadi::Item &, const QStringList &collectionMimeTypes) const
Initialise an Akonadi::Item with the event's data.
KCal::Alarm::Procedure type: execute a shell command.
void setDisplayAlarm(const QString &text=QString())
return a sub-repetition if it's the next occurrence
bool expired() const
Return whether the event has expired.
void setCategory(CalEvent::Type type)
Set the alarm category (active/archived/template, or displaying).
Akonadi::Collection::Id collectionId() const
Return the ID of the Akonadi Collection which contains the event.
void setCollectionId_const(Akonadi::Collection::Id id) const
Set the ID of the Akonadi Collection which contains the event.
bool updateKCalEvent(const KCalCore::Event::Ptr &event, UidAction u, bool setCustomProperties=true) const
Update an existing KCalCore::Event with the KAEvent data.
bool reminderActive() const
Return whether a reminder is currently due (before the next, or after the last, main alarm/recurrence...
(bitmask for a sub-repetition of an occurrence)
void setWorkTimeOnly(bool wto)
Enable or disable the alarm on non-working days and outside working hours.
QMap< QByteArray, QString > customProperties() const
Return the original KCalCore::Event's custom properties in the source calendar.
int nextRepetition() const
Return the count of the next sub-repetition which is due.
at an hours/minutes interval
bool setRecurWeekly(int freq, const QBitArray &days, int count, const QDate &end)
Set the recurrence to recur weekly, on the specified weekdays.
KDateTime createdDateTime() const
Return the date/time the event was created, or saved in the archive calendar.
void setDateOnly(bool d)
Sets the value to be either date-only or date-time.
QString programArguments() const
do not notify pre-alarm action errors to user
QString displayMessage() const
Return the message text for a display alarm.
bool commandXterm() const
Return whether to execute the command in a terminal window, for a command alarm.
SubAction
The sub-action type for the event's main alarm.
As KDateTime, but with a configurable start-of-day time for date-only values.
next trigger, including reminders, ignoring working hours & holidays
void set(const KCalCore::Duration &interval, int count)
Initialises the instance with the specified interval and count.
monthly, on a specified day of the month
int intervalDays() const
Return the repetition interval in terms of days.
QString cleanText() const
Return the alarm's text.
QString audioFile() const
void reinstateFromDisplaying(const KCalCore::Event::Ptr &event, Akonadi::Collection::Id &colId, bool &showEdit, bool &showDefer)
Reinstate the original event from the 'displaying' event.
QColor bgColour() const
Return the message window background color, for a display alarm.
DateTime deferralLimit(DeferLimitType *limitType=0) const
Return the latest time which the alarm can currently be deferred to.
static List ptrList(QVector< KAEvent > &events)
Return a list of pointers to a list of KAEvent objects.
QString preAction() const
Return the shell command to execute before the alarm is displayed.
KARecurrence::Type recurType() const
Return the recurrence period type for the event.
int repeatSoundPause() const
Return how many seconds to pause between repetitions of the sound file.
Types types(const QStringList &mimeTypes)
Return the alarm Types for a list of mime type strings.
next trigger, excluding reminders, ignoring working hours & holidays
QString programFile() const
KOrganizer should hold a copy of the event.
bool reminderDeferral() const
Return whether there is currently a deferred reminder alarm pending.