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

KDE's Doxygen guidelines are available online.