KCalendarCore

alarm.cpp
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 1998 Preston Brown <[email protected]>
5  SPDX-FileCopyrightText: 2001 Cornelius Schumacher <[email protected]>
6  SPDX-FileCopyrightText: 2003 David Jarvie <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
20 #include "alarm.h"
21 #include "duration.h"
22 #include "incidence.h"
23 #include "utils_p.h"
24 
25 #include <QTime>
26 #include <QTimeZone>
27 
28 using namespace KCalendarCore;
29 
34 //@cond PRIVATE
35 class Q_DECL_HIDDEN KCalendarCore::Alarm::Private
36 {
37 public:
38  Private()
39  : mParent(nullptr),
40  mType(Alarm::Invalid),
41  mAlarmSnoozeTime(5),
42  mAlarmRepeatCount(0),
43  mEndOffset(false),
44  mHasTime(false),
45  mAlarmEnabled(false),
46  mHasLocationRadius(false),
47  mLocationRadius(0)
48  {}
49 
50  Incidence *mParent = nullptr; // the incidence which this alarm belongs to
51 
52  Type mType; // type of alarm
53  QString mDescription;// text to display/email body/procedure arguments
54  QString mFile; // program to run/optional audio file to play
55  QString mMailSubject;// subject of email
56  QStringList mMailAttachFiles; // filenames to attach to email
57  Person::List mMailAddresses; // who to mail for reminder
58 
59  QDateTime mAlarmTime;// time at which to trigger the alarm
60  Duration mAlarmSnoozeTime; // how long after alarm to snooze before
61  // triggering again
62  int mAlarmRepeatCount;// number of times for alarm to repeat
63  // after the initial time
64 
65  Duration mOffset; // time relative to incidence DTSTART
66  // to trigger the alarm
67  bool mEndOffset; // if true, mOffset relates to DTEND, not DTSTART
68  bool mHasTime; // use mAlarmTime, not mOffset
69  bool mAlarmEnabled;
70 
71  bool mHasLocationRadius;
72  int mLocationRadius; // location radius for the alarm
73 };
74 //@endcond
75 
76 Alarm::Alarm(Incidence *parent) : d(new KCalendarCore::Alarm::Private)
77 {
78  d->mParent = parent;
79 }
80 
81 Alarm::Alarm(const Alarm &other) :
82  CustomProperties(other), d(new KCalendarCore::Alarm::Private(*other.d))
83 {
84 }
85 
87 {
88  delete d;
89 }
90 
92 {
93  if (&a != this) {
94  d->mParent = a.d->mParent;
95  d->mType = a.d->mType;
96  d->mDescription = a.d->mDescription;
97  d->mFile = a.d->mFile;
98  d->mMailAttachFiles = a.d->mMailAttachFiles;
99  d->mMailAddresses = a.d->mMailAddresses;
100  d->mMailSubject = a.d->mMailSubject;
101  d->mAlarmSnoozeTime = a.d->mAlarmSnoozeTime;
102  d->mAlarmRepeatCount = a.d->mAlarmRepeatCount;
103  d->mAlarmTime = a.d->mAlarmTime;
104  d->mOffset = a.d->mOffset;
105  d->mEndOffset = a.d->mEndOffset;
106  d->mHasTime = a.d->mHasTime;
107  d->mAlarmEnabled = a.d->mAlarmEnabled;
108  }
109 
110  return *this;
111 }
112 
113 static bool compareMailAddresses(const Person::List &list1, const Person::List &list2)
114 {
115  if (list1.count() == list2.count()) {
116  for (int i = 0; i < list1.count(); ++i) {
117  if (list1.at(i) != list2.at(i)) {
118  return false;
119  }
120  }
121  return true;
122  }
123 
124  return false;
125 }
126 
127 bool Alarm::operator==(const Alarm &rhs) const
128 {
129  if (d->mType != rhs.d->mType ||
130  d->mAlarmSnoozeTime != rhs.d->mAlarmSnoozeTime ||
131  d->mAlarmRepeatCount != rhs.d->mAlarmRepeatCount ||
132  d->mAlarmEnabled != rhs.d->mAlarmEnabled ||
133  d->mHasTime != rhs.d->mHasTime ||
134  d->mHasLocationRadius != rhs.d->mHasLocationRadius ||
135  d->mLocationRadius != rhs.d->mLocationRadius) {
136  return false;
137  }
138 
139  if (d->mHasTime) {
140  if (d->mAlarmTime != rhs.d->mAlarmTime) {
141  return false;
142  }
143  } else {
144  if (d->mOffset != rhs.d->mOffset || d->mEndOffset != rhs.d->mEndOffset) {
145  return false;
146  }
147  }
148 
149  switch (d->mType) {
150  case Display:
151  return d->mDescription == rhs.d->mDescription;
152 
153  case Email:
154  return d->mDescription == rhs.d->mDescription &&
155  d->mMailAttachFiles == rhs.d->mMailAttachFiles &&
156  compareMailAddresses(d->mMailAddresses, rhs.d->mMailAddresses) &&
157  d->mMailSubject == rhs.d->mMailSubject;
158 
159  case Procedure:
160  return d->mFile == rhs.d->mFile &&
161  d->mDescription == rhs.d->mDescription;
162 
163  case Audio:
164  return d->mFile == rhs.d->mFile;
165 
166  case Invalid:
167  break;
168  }
169  return false;
170 }
171 
172 bool Alarm::operator!=(const Alarm &a) const
173 {
174  return !operator==(a);
175 }
176 
178 {
179  if (type == d->mType) {
180  return;
181  }
182 
183  if (d->mParent) {
184  d->mParent->update();
185  }
186  switch (type) {
187  case Display:
188  d->mDescription.clear();
189  break;
190  case Procedure:
191  d->mFile.clear();
192  d->mDescription.clear();
193  break;
194  case Audio:
195  d->mFile.clear();
196  break;
197  case Email:
198  d->mMailSubject.clear();
199  d->mDescription.clear();
200  d->mMailAddresses.clear();
201  d->mMailAttachFiles.clear();
202  break;
203  case Invalid:
204  break;
205  default:
206  if (d->mParent) {
207  d->mParent->updated(); // not really
208  }
209  return;
210  }
211  d->mType = type;
212  if (d->mParent) {
213  d->mParent->updated();
214  }
215 }
216 
218 {
219  return d->mType;
220 }
221 
223 {
224  if (d->mParent) {
225  d->mParent->update();
226  }
227  d->mType = Audio;
228  d->mFile = audioFile;
229  if (d->mParent) {
230  d->mParent->updated();
231  }
232 }
233 
235 {
236  if (d->mType == Audio) {
237  if (d->mParent) {
238  d->mParent->update();
239  }
240  d->mFile = audioFile;
241  if (d->mParent) {
242  d->mParent->updated();
243  }
244  }
245 }
246 
248 {
249  return (d->mType == Audio) ? d->mFile : QString();
250 }
251 
253  const QString &arguments)
254 {
255  if (d->mParent) {
256  d->mParent->update();
257  }
258  d->mType = Procedure;
259  d->mFile = programFile;
260  d->mDescription = arguments;
261  if (d->mParent) {
262  d->mParent->updated();
263  }
264 }
265 
267 {
268  if (d->mType == Procedure) {
269  if (d->mParent) {
270  d->mParent->update();
271  }
272  d->mFile = programFile;
273  if (d->mParent) {
274  d->mParent->updated();
275  }
276  }
277 }
278 
280 {
281  return (d->mType == Procedure) ? d->mFile : QString();
282 }
283 
284 void Alarm::setProgramArguments(const QString &arguments)
285 {
286  if (d->mType == Procedure) {
287  if (d->mParent) {
288  d->mParent->update();
289  }
290  d->mDescription = arguments;
291  if (d->mParent) {
292  d->mParent->updated();
293  }
294  }
295 }
296 
298 {
299  return (d->mType == Procedure) ? d->mDescription : QString();
300 }
301 
302 void Alarm::setEmailAlarm(const QString &subject, const QString &text,
303  const Person::List &addressees,
304  const QStringList &attachments)
305 {
306  if (d->mParent) {
307  d->mParent->update();
308  }
309  d->mType = Email;
310  d->mMailSubject = subject;
311  d->mDescription = text;
312  d->mMailAddresses = addressees;
313  d->mMailAttachFiles = attachments;
314  if (d->mParent) {
315  d->mParent->updated();
316  }
317 }
318 
319 void Alarm::setMailAddress(const Person &mailAddress)
320 {
321  if (d->mType == Email) {
322  if (d->mParent) {
323  d->mParent->update();
324  }
325  d->mMailAddresses.clear();
326  d->mMailAddresses.append(mailAddress);
327  if (d->mParent) {
328  d->mParent->updated();
329  }
330  }
331 }
332 
334 {
335  if (d->mType == Email) {
336  if (d->mParent) {
337  d->mParent->update();
338  }
339  d->mMailAddresses += mailAddresses;
340  if (d->mParent) {
341  d->mParent->updated();
342  }
343  }
344 }
345 
346 void Alarm::addMailAddress(const Person &mailAddress)
347 {
348  if (d->mType == Email) {
349  if (d->mParent) {
350  d->mParent->update();
351  }
352  d->mMailAddresses.append(mailAddress);
353  if (d->mParent) {
354  d->mParent->updated();
355  }
356  }
357 }
358 
360 {
361  return (d->mType == Email) ? d->mMailAddresses : Person::List();
362 }
363 
364 void Alarm::setMailSubject(const QString &mailAlarmSubject)
365 {
366  if (d->mType == Email) {
367  if (d->mParent) {
368  d->mParent->update();
369  }
370  d->mMailSubject = mailAlarmSubject;
371  if (d->mParent) {
372  d->mParent->updated();
373  }
374  }
375 }
376 
378 {
379  return (d->mType == Email) ? d->mMailSubject : QString();
380 }
381 
382 void Alarm::setMailAttachment(const QString &mailAttachFile)
383 {
384  if (d->mType == Email) {
385  if (d->mParent) {
386  d->mParent->update();
387  }
388  d->mMailAttachFiles.clear();
389  d->mMailAttachFiles += mailAttachFile;
390  if (d->mParent) {
391  d->mParent->updated();
392  }
393  }
394 }
395 
396 void Alarm::setMailAttachments(const QStringList &mailAttachFiles)
397 {
398  if (d->mType == Email) {
399  if (d->mParent) {
400  d->mParent->update();
401  }
402  d->mMailAttachFiles = mailAttachFiles;
403  if (d->mParent) {
404  d->mParent->updated();
405  }
406  }
407 }
408 
409 void Alarm::addMailAttachment(const QString &mailAttachFile)
410 {
411  if (d->mType == Email) {
412  if (d->mParent) {
413  d->mParent->update();
414  }
415  d->mMailAttachFiles += mailAttachFile;
416  if (d->mParent) {
417  d->mParent->updated();
418  }
419  }
420 }
421 
423 {
424  return (d->mType == Email) ? d->mMailAttachFiles : QStringList();
425 }
426 
428 {
429  if (d->mType == Email) {
430  if (d->mParent) {
431  d->mParent->update();
432  }
433  d->mDescription = text;
434  if (d->mParent) {
435  d->mParent->updated();
436  }
437  }
438 }
439 
441 {
442  return (d->mType == Email) ? d->mDescription : QString();
443 }
444 
446 {
447  if (d->mParent) {
448  d->mParent->update();
449  }
450  d->mType = Display;
451  if (!text.isNull()) {
452  d->mDescription = text;
453  }
454  if (d->mParent) {
455  d->mParent->updated();
456  }
457 }
458 
460 {
461  if (d->mType == Display) {
462  if (d->mParent) {
463  d->mParent->update();
464  }
465  d->mDescription = text;
466  if (d->mParent) {
467  d->mParent->updated();
468  }
469  }
470 }
471 
473 {
474  return (d->mType == Display) ? d->mDescription : QString();
475 }
476 
477 void Alarm::setTime(const QDateTime &alarmTime)
478 {
479  if (d->mParent) {
480  d->mParent->update();
481  }
482  d->mAlarmTime = alarmTime;
483  d->mHasTime = true;
484 
485  if (d->mParent) {
486  d->mParent->updated();
487  }
488 }
489 
491 {
492  if (hasTime()) {
493  return d->mAlarmTime;
494  } else if (d->mParent) {
495  if (d->mEndOffset) {
496  QDateTime dt = d->mParent->dateTime(Incidence::RoleAlarmEndOffset);
497  return d->mOffset.end(dt);
498  } else {
499  QDateTime dt = d->mParent->dateTime(Incidence::RoleAlarmStartOffset);
500  return d->mOffset.end(dt);
501  }
502  } else {
503  return QDateTime();
504  }
505 }
506 
507 QDateTime Alarm::nextTime(const QDateTime &preTime, bool ignoreRepetitions) const
508 {
509  if (d->mParent && d->mParent->recurs()) {
510  QDateTime dtEnd = d->mParent->dateTime(Incidence::RoleAlarmEndOffset);
511 
512  QDateTime dtStart = d->mParent->dtStart();
513  // Find the incidence's earliest alarm
514  // Alarm time is defined by an offset from the event start or end time.
515  QDateTime alarmStart = d->mOffset.end(d->mEndOffset ? dtEnd : dtStart);
516  // Find the offset from the event start time, which is also used as the
517  // offset from the recurrence time.
518  Duration alarmOffset(dtStart, alarmStart);
519  /*
520  qCDebug(KCALCORE_LOG) << "dtStart " << dtStart;
521  qCDebug(KCALCORE_LOG) << "dtEnd " << dtEnd;
522  qCDebug(KCALCORE_LOG) << "alarmStart " << alarmStart;
523  qCDebug(KCALCORE_LOG) << "alarmOffset " << alarmOffset.value();
524  qCDebug(KCALCORE_LOG) << "preTime " << preTime;
525  */
526  if (alarmStart > preTime) {
527  // No need to go further.
528  return alarmStart;
529  }
530  if (d->mAlarmRepeatCount && !ignoreRepetitions) {
531  // The alarm has repetitions, so check whether repetitions of previous
532  // recurrences happen after given time.
533  QDateTime prevRecurrence = d->mParent->recurrence()->getPreviousDateTime(preTime);
534  if (prevRecurrence.isValid()) {
535  QDateTime prevLastRepeat = alarmOffset.end(duration().end(prevRecurrence));
536  // qCDebug(KCALCORE_LOG) << "prevRecurrence" << prevRecurrence;
537  // qCDebug(KCALCORE_LOG) << "prevLastRepeat" << prevLastRepeat;
538  if (prevLastRepeat > preTime) {
539  // Yes they did, return alarm offset to previous recurrence.
540  QDateTime prevAlarm = alarmOffset.end(prevRecurrence);
541  // qCDebug(KCALCORE_LOG) << "prevAlarm " << prevAlarm;
542  return prevAlarm;
543  }
544  }
545  }
546  // Check the next recurrence now.
547  QDateTime nextRecurrence = d->mParent->recurrence()->getNextDateTime(preTime);
548  if (nextRecurrence.isValid()) {
549  QDateTime nextAlarm = alarmOffset.end(nextRecurrence);
550  /*
551  qCDebug(KCALCORE_LOG) << "nextRecurrence" << nextRecurrence;
552  qCDebug(KCALCORE_LOG) << "nextAlarm " << nextAlarm;
553  */
554  if (nextAlarm > preTime) {
555  // It's first alarm takes place after given time.
556  return nextAlarm;
557  }
558  }
559  } else {
560  // Not recurring.
561  QDateTime alarmTime = time();
562  if (alarmTime > preTime) {
563  return alarmTime;
564  }
565  }
566  return QDateTime();
567 }
568 
569 bool Alarm::hasTime() const
570 {
571  return d->mHasTime;
572 }
573 
574 void Alarm::shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone)
575 {
576  if (d->mParent) {
577  d->mParent->update();
578  }
579  d->mAlarmTime = d->mAlarmTime.toTimeZone(oldZone);
580  d->mAlarmTime.setTimeZone(newZone);
581  if (d->mParent) {
582  d->mParent->updated();
583  }
584 }
585 
586 void Alarm::setSnoozeTime(const Duration &alarmSnoozeTime)
587 {
588  if (alarmSnoozeTime.value() > 0) {
589  if (d->mParent) {
590  d->mParent->update();
591  }
592  d->mAlarmSnoozeTime = alarmSnoozeTime;
593  if (d->mParent) {
594  d->mParent->updated();
595  }
596  }
597 }
598 
600 {
601  return d->mAlarmSnoozeTime;
602 }
603 
604 void Alarm::setRepeatCount(int alarmRepeatCount)
605 {
606  if (d->mParent) {
607  d->mParent->update();
608  }
609  d->mAlarmRepeatCount = alarmRepeatCount;
610  if (d->mParent) {
611  d->mParent->updated();
612  }
613 }
614 
616 {
617  return d->mAlarmRepeatCount;
618 }
619 
621 {
622  return Duration(d->mAlarmSnoozeTime.value() * d->mAlarmRepeatCount,
623  d->mAlarmSnoozeTime.type());
624 }
625 
627 {
628  QDateTime at = nextTime(preTime);
629  if (at > preTime) {
630  return at;
631  }
632  if (!d->mAlarmRepeatCount) {
633  // there isn't an occurrence after the specified time
634  return QDateTime();
635  }
636  qint64 repetition;
637  int interval = d->mAlarmSnoozeTime.value();
638  bool daily = d->mAlarmSnoozeTime.isDaily();
639  if (daily) {
640  qint64 daysTo = at.daysTo(preTime);
641  if (preTime.time() <= at.time()) {
642  --daysTo;
643  }
644  repetition = daysTo / interval + 1;
645  } else {
646  repetition = at.secsTo(preTime) / interval + 1;
647  }
648  if (repetition > d->mAlarmRepeatCount) {
649  // all repetitions have finished before the specified time
650  return QDateTime();
651  }
652  return daily ? at.addDays(int(repetition * interval))
653  : at.addSecs(repetition * interval);
654 }
655 
657 {
658  QDateTime at = time();
659  if (at >= afterTime) {
660  // alarm's first/only time is at/after the specified time
661  return QDateTime();
662  }
663  if (!d->mAlarmRepeatCount) {
664  return at;
665  }
666  qint64 repetition;
667  int interval = d->mAlarmSnoozeTime.value();
668  bool daily = d->mAlarmSnoozeTime.isDaily();
669  if (daily) {
670  qint64 daysTo = at.daysTo(afterTime);
671  if (afterTime.time() <= at.time()) {
672  --daysTo;
673  }
674  repetition = daysTo / interval;
675  } else {
676  repetition = (at.secsTo(afterTime) - 1) / interval;
677  }
678  if (repetition > d->mAlarmRepeatCount) {
679  repetition = d->mAlarmRepeatCount;
680  }
681  return daily ? at.addDays(int(repetition * interval))
682  : at.addSecs(repetition * interval);
683 }
684 
686 {
687  if (!d->mAlarmRepeatCount) {
688  return time();
689  }
690  if (d->mAlarmSnoozeTime.isDaily()) {
691  return time().addDays(d->mAlarmRepeatCount * d->mAlarmSnoozeTime.asDays());
692  } else {
693  return time().addSecs(d->mAlarmRepeatCount * d->mAlarmSnoozeTime.asSeconds());
694  }
695 }
696 
698 {
699  if (d->mParent) {
700  d->mParent->update();
701  }
702  d->mAlarmEnabled = !d->mAlarmEnabled;
703  if (d->mParent) {
704  d->mParent->updated();
705  }
706 }
707 
708 void Alarm::setEnabled(bool enable)
709 {
710  if (d->mParent) {
711  d->mParent->update();
712  }
713  d->mAlarmEnabled = enable;
714  if (d->mParent) {
715  d->mParent->updated();
716  }
717 }
718 
719 bool Alarm::enabled() const
720 {
721  return d->mAlarmEnabled;
722 }
723 
724 void Alarm::setStartOffset(const Duration &offset)
725 {
726  if (d->mParent) {
727  d->mParent->update();
728  }
729  d->mOffset = offset;
730  d->mEndOffset = false;
731  d->mHasTime = false;
732  if (d->mParent) {
733  d->mParent->updated();
734  }
735 }
736 
738 {
739  return (d->mHasTime || d->mEndOffset) ? Duration(0) : d->mOffset;
740 }
741 
743 {
744  return !d->mHasTime && !d->mEndOffset;
745 }
746 
748 {
749  return !d->mHasTime && d->mEndOffset;
750 }
751 
752 void Alarm::setEndOffset(const Duration &offset)
753 {
754  if (d->mParent) {
755  d->mParent->update();
756  }
757  d->mOffset = offset;
758  d->mEndOffset = true;
759  d->mHasTime = false;
760  if (d->mParent) {
761  d->mParent->updated();
762  }
763 }
764 
766 {
767  return (d->mHasTime || !d->mEndOffset) ? Duration(0) : d->mOffset;
768 }
769 
771 {
772  d->mParent = parent;
773 }
774 
776 {
777  return d->mParent ? d->mParent->uid() : QString();
778 }
779 
781 {
782  if (d->mParent) {
783  d->mParent->update();
784  d->mParent->updated();
785  }
786 }
787 
789 {
790  if (d->mParent) {
791  d->mParent->update();
792  }
793  d->mHasLocationRadius = hasLocationRadius;
794  if (hasLocationRadius) {
795  setNonKDECustomProperty("X-LOCATION-RADIUS", QString::number(d->mLocationRadius));
796  } else {
797  removeNonKDECustomProperty("X-LOCATION-RADIUS");
798  }
799  if (d->mParent) {
800  d->mParent->updated();
801  }
802 }
803 
805 {
806  return d->mHasLocationRadius;
807 }
808 
810 {
811  if (d->mParent) {
812  d->mParent->update();
813  }
814  d->mLocationRadius = locationRadius;
815  if (d->mParent) {
816  d->mParent->updated();
817  }
818 }
819 
821 {
822  return d->mLocationRadius;
823 }
824 
826 {
827  if (a) {
828  out << ((quint32)a->d->mType)
829  << a->d->mAlarmSnoozeTime
830  << a->d->mAlarmRepeatCount
831  << a->d->mEndOffset
832  << a->d->mHasTime
833  << a->d->mAlarmEnabled
834  << a->d->mHasLocationRadius
835  << a->d->mLocationRadius
836  << a->d->mOffset;
837 
838  serializeQDateTimeAsKDateTime(out, a->d->mAlarmTime);
839 
840  out << a->d->mFile
841  << a->d->mMailSubject
842  << a->d->mDescription
843  << a->d->mMailAttachFiles
844  << a->d->mMailAddresses;
845  }
846  return out;
847 }
848 
850 {
851  if (a) {
852  quint32 type;
853  in >> type;
854  a->d->mType = static_cast<Alarm::Type>(type);
855  in >> a->d->mAlarmSnoozeTime >> a->d->mAlarmRepeatCount >> a->d->mEndOffset >> a->d->mHasTime
856  >> a->d->mAlarmEnabled >> a->d->mHasLocationRadius >> a->d->mLocationRadius >> a->d->mOffset;
857  deserializeKDateTimeAsQDateTime(in, a->d->mAlarmTime);
858  in >> a->d->mFile >> a->d->mMailSubject >> a->d->mDescription >> a->d->mMailAttachFiles >> a->d->mMailAddresses;
859  }
860  return in;
861 }
862 
863 void Alarm::virtual_hook(int id, void *data)
864 {
865  Q_UNUSED(id);
866  Q_UNUSED(data);
867  Q_ASSERT(false);
868 }
Represents an alarm notification.
Definition: alarm.h:51
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:825
void setNonKDECustomProperty(const QByteArray &name, const QString &value, const QString &parameters=QString())
Create or modify a non-KDE or non-standard custom calendar property.
Play an audio file.
Definition: alarm.h:62
QDateTime endTime() const
Returns the date/time when the last repetition of the alarm goes off.
Definition: alarm.cpp:685
A class to manage custom calendar properties.
bool hasTime() const
Returns true if the alarm has a trigger date/time.
Definition: alarm.cpp:569
bool hasStartOffset() const
Returns whether the alarm is defined in terms of an offset relative to the start of the parent Incide...
Definition: alarm.cpp:742
QDateTime nextTime(const QDateTime &preTime, bool ignoreRepetitions=false) const
Returns the next alarm trigger date/time after given date/time.
Definition: alarm.cpp:507
Represents a person, by name and email address.
Definition: person.h:38
void setMailAttachments(const QStringList &mailAttachFiles)
Sets a list of filenames to attach to a mail message for an Email alarm type.
Definition: alarm.cpp:396
Duration duration() const
Returns the interval between the alarm&#39;s initial occurrence and its final repetition.
Definition: alarm.cpp:620
qint64 daysTo(const QDateTime &other) const const
void setProgramFile(const QString &programFile)
Sets the program file to execute when the alarm is triggered.
Definition: alarm.cpp:266
Person::List mailAddresses() const
Returns the list of addresses for an Email alarm type.
Definition: alarm.cpp:359
QDateTime end(const QDateTime &start) const
Computes a duration end time by adding the number of seconds or days in the duration to the specified...
Definition: duration.cpp:172
Display a dialog box.
Definition: alarm.h:59
void setHasLocationRadius(bool hasLocationRadius)
Set if the location radius for the alarm has been defined.
Definition: alarm.cpp:788
bool hasEndOffset() const
Returns whether the alarm is defined in terms of an offset relative to the end of the event...
Definition: alarm.cpp:747
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:849
virtual void virtual_hook(int id, void *data)
Definition: alarm.cpp:863
void setProcedureAlarm(const QString &programFile, const QString &arguments=QString())
Sets the Procedure type for this alarm and the program (with arguments) to execute when the alarm is ...
Definition: alarm.cpp:252
QDateTime previousRepetition(const QDateTime &afterTime) const
Returns the date/time of the alarm&#39;s latest repetition or, if none, its initial occurrence before a g...
Definition: alarm.cpp:656
void setParent(Incidence *parent)
Sets the parent Incidence of the alarm.
Definition: alarm.cpp:770
QTime time() const const
void customPropertyUpdated() override
Definition: alarm.cpp:780
int value() const
Returns the length of the duration in seconds or days.
Definition: duration.cpp:198
bool hasLocationRadius() const
Returns true if alarm has location radius defined.
Definition: alarm.cpp:804
Alarm & operator=(const Alarm &)
Copy operator.
Definition: alarm.cpp:91
QDateTime time() const
Returns the alarm trigger date/time.
Definition: alarm.cpp:490
QString mailSubject() const
Returns the subject line string for an Email alarm type.
Definition: alarm.cpp:377
void setAudioFile(const QString &audioFile)
Sets the name of the audio file to play when the audio alarm is triggered.
Definition: alarm.cpp:234
void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone)
Shift the times of the alarm so that they appear at the same clock time as before but in a new time z...
Definition: alarm.cpp:574
void toggleAlarm()
Toggles the alarm status, i.e, an enable alarm becomes disabled and a disabled alarm becomes enabled...
Definition: alarm.cpp:697
void setType(Type type)
Sets the Type for this alarm to type.
Definition: alarm.cpp:177
bool isNull() const const
QVector< Person > List
List of persons.
Definition: person.h:50
QString number(int n, int base)
Represents a span of time measured in seconds or days.
Definition: duration.h:44
void removeNonKDECustomProperty(const QByteArray &name)
Delete a non-KDE or non-standard custom calendar property.
void setEmailAlarm(const QString &subject, const QString &text, const Person::List &addressees, const QStringList &attachments=QStringList())
Sets the Email type for this alarm and the email subject, text, addresses, and attachments that make ...
Definition: alarm.cpp:302
void setRepeatCount(int alarmRepeatCount)
Sets how many times an alarm is to repeat itself after its initial occurrence (w/snoozes).
Definition: alarm.cpp:604
void addMailAddress(const Person &mailAlarmAddress)
Adds an address to the list of email addresses to send mail to when the alarm is triggered.
Definition: alarm.cpp:346
QString programArguments() const
Returns the program arguments string for a Procedure alarm type.
Definition: alarm.cpp:297
bool enabled() const
Returns the alarm enabled status: true (enabled) or false (disabled).
Definition: alarm.cpp:719
Type type() const
Returns the Type of the alarm.
Definition: alarm.cpp:217
QString audioFile() const
Returns the audio file name for an Audio alarm type.
Definition: alarm.cpp:247
Role for an incidence alarm&#39;s starting offset date/time.
bool operator!=(const Alarm &a) const
Compares two alarms for inequality.
Definition: alarm.cpp:172
void setProgramArguments(const QString &arguments)
Sets the program arguments string when the alarm is triggered.
Definition: alarm.cpp:284
void setDisplayAlarm(const QString &text=QString())
Sets the Display type for this alarm.
Definition: alarm.cpp:445
QString mailText() const
Returns the body text for an Email alarm type.
Definition: alarm.cpp:440
void setSnoozeTime(const Duration &alarmSnoozeTime)
Sets the snooze time interval for the alarm.
Definition: alarm.cpp:586
void setMailAddress(const Person &mailAlarmAddress)
Sets the email address of an Email type alarm.
Definition: alarm.cpp:319
void setMailAddresses(const Person::List &mailAlarmAddresses)
Sets a list of email addresses of an Email type alarm.
Definition: alarm.cpp:333
void setMailText(const QString &text)
Sets the body text for an Email alarm type.
Definition: alarm.cpp:427
QStringList mailAttachments() const
Returns the list of attachment filenames for an Email alarm type.
Definition: alarm.cpp:422
int locationRadius() const
Returns the location radius in meters.
Definition: alarm.cpp:820
bool isValid() const const
QString text() const
Returns the display text string for a Display alarm type.
Definition: alarm.cpp:472
const T & at(int i) const const
This file is part of the API for handling calendar data and defines the Duration class.
This file is part of the API for handling calendar data and defines the Alarm class.
void setEndOffset(const Duration &offset)
Sets the alarm offset relative to the end of the parent Incidence.
Definition: alarm.cpp:752
Duration snoozeTime() const
Returns the snooze time interval.
Definition: alarm.cpp:599
void setMailSubject(const QString &mailAlarmSubject)
Sets the subject line of a mail message for an Email alarm type.
Definition: alarm.cpp:364
bool operator==(const Alarm &a) const
Compares two alarms for equality.
Definition: alarm.cpp:127
qint64 secsTo(const QDateTime &other) const const
void setStartOffset(const Duration &offset)
Sets the alarm offset relative to the start of the parent Incidence.
Definition: alarm.cpp:724
This file is part of the API for handling calendar data and defines the Incidence class...
QString programFile() const
Returns the program file name for a Procedure alarm type.
Definition: alarm.cpp:279
QDateTime nextRepetition(const QDateTime &preTime) const
Returns the date/time of the alarm&#39;s initial occurrence or its next repetition after a given time...
Definition: alarm.cpp:626
void setEnabled(bool enable)
Sets the enabled status of the alarm.
Definition: alarm.cpp:708
int count(const T &value) const const
Type
The different types of alarms.
Definition: alarm.h:57
Invalid, or no alarm.
Definition: alarm.h:58
void setText(const QString &text)
Sets the description text to be displayed when the alarm is triggered.
Definition: alarm.cpp:459
~Alarm() override
Destroys the alarm.
Definition: alarm.cpp:86
Duration startOffset() const
Returns offset of alarm in time relative to the start of the parent Incidence.
Definition: alarm.cpp:737
void setTime(const QDateTime &alarmTime)
Sets the trigger time of the alarm.
Definition: alarm.cpp:477
void setLocationRadius(int locationRadius)
Set location radius for the alarm.
Definition: alarm.cpp:809
void setMailAttachment(const QString &mailAttachFile)
Sets the filename to attach to a mail message for an Email alarm type.
Definition: alarm.cpp:382
QDateTime addSecs(qint64 s) const const
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:56
void addMailAttachment(const QString &mailAttachFile)
Adds a filename to the list of files to attach to a mail message for an Email alarm type...
Definition: alarm.cpp:409
QDateTime addDays(qint64 ndays) const const
QString parentUid() const
Returns the parent&#39;s incidence UID of the alarm.
Definition: alarm.cpp:775
Alarm(Incidence *parent)
Constructs an alarm belonging to the parent Incidence.
Definition: alarm.cpp:76
void setAudioAlarm(const QString &audioFile=QString())
Sets the Audio type for this alarm and the name of the audio file to play when the alarm is triggered...
Definition: alarm.cpp:222
Namespace for all KCalendarCore types.
Definition: alarm.h:36
Role for an incidence alarm&#39;s ending offset date/time.
int repeatCount() const
Returns how many times an alarm may repeats after its initial occurrence.
Definition: alarm.cpp:615
Duration endOffset() const
Returns offset of alarm in time relative to the end of the event.
Definition: alarm.cpp:765
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Aug 13 2020 22:50:59 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.