KCalendarCore

alarm.h
Go to the documentation of this file.
1 /*
2  This file is part of the kcalcore library.
3 
4  SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <[email protected]>
5  SPDX-FileCopyrightText: 2003 David Jarvie <[email protected]>
6  SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <[email protected]>
7 
8  SPDX-License-Identifier: LGPL-2.0-or-later
9 */
18 #ifndef KCALCORE_ALARM_H
19 #define KCALCORE_ALARM_H
20 
21 #include "kcalendarcore_export.h"
22 #include "customproperties.h"
23 #include "duration.h"
24 #include "person.h"
25 
26 #include <QDateTime>
27 #include <QString>
28 #include <QStringList>
29 #include <QVector>
30 #include <QDataStream>
31 #include <QMetaType>
32 #include <QSharedPointer>
33 
34 class QTimeZone;
35 
36 namespace KCalendarCore
37 {
38 
39 class Incidence;
40 
51 class KCALENDARCORE_EXPORT Alarm : public CustomProperties
52 {
53 public:
57  enum Type {
62  Audio
63  };
64 
69 
73  typedef QVector<Ptr> List;
74 
80  // Can't find a way to use a shared pointer here.
81  // Inside incidence.cpp, it does alarm->setParent( this )
82  explicit Alarm(Incidence *parent);
83 
88  Alarm(const Alarm &other);
89 
93  ~Alarm() override;
94 
98  Alarm &operator=(const Alarm &);
99 
104  bool operator==(const Alarm &a) const;
105 
111  bool operator!=(const Alarm &a) const;
112 
120  // Is there a way to use QSharedPointer here?
121  // although it's safe, Incidence's dtor calls setParent( 0 )
122  // se we don't dereference a deleted pointer here.
123  // Also, I renamed "Incidence *parent()" to "QString parentUid()"
124  // So we don't return raw pointers
125  void setParent(Incidence *parent);
126 
132  // We don't have a share pointer to return, so return the UID.
133  Q_REQUIRED_RESULT QString parentUid() const;
134 
144  void setType(Type type);
145 
151  Q_REQUIRED_RESULT Type type() const;
152 
162  void setDisplayAlarm(const QString &text = QString());
163 
172  void setText(const QString &text);
173 
180  Q_REQUIRED_RESULT QString text() const;
181 
191  void setAudioAlarm(const QString &audioFile = QString());
192 
202  void setAudioFile(const QString &audioFile);
203 
210  Q_REQUIRED_RESULT QString audioFile() const;
211 
223  void setProcedureAlarm(const QString &programFile,
224  const QString &arguments = QString());
225 
236  void setProgramFile(const QString &programFile);
237 
245  Q_REQUIRED_RESULT QString programFile() const;
246 
256  void setProgramArguments(const QString &arguments);
257 
265  Q_REQUIRED_RESULT QString programArguments() const;
266 
281  void setEmailAlarm(const QString &subject, const QString &text,
282  const Person::List &addressees,
283  const QStringList &attachments = QStringList());
284 
295  void setMailAddress(const Person &mailAlarmAddress);
296 
307  void setMailAddresses(const Person::List &mailAlarmAddresses);
308 
319  void addMailAddress(const Person &mailAlarmAddress);
320 
327  Q_REQUIRED_RESULT Person::List mailAddresses() const;
328 
339  void setMailSubject(const QString &mailAlarmSubject);
340 
347  Q_REQUIRED_RESULT QString mailSubject() const;
348 
359  void setMailAttachment(const QString &mailAttachFile);
360 
371  void setMailAttachments(const QStringList &mailAttachFiles);
372 
382  void addMailAttachment(const QString &mailAttachFile);
383 
390  Q_REQUIRED_RESULT QStringList mailAttachments() const;
391 
402  void setMailText(const QString &text);
403 
410  Q_REQUIRED_RESULT QString mailText() const;
411 
419  void setTime(const QDateTime &alarmTime);
420 
426  Q_REQUIRED_RESULT QDateTime time() const;
427 
436  Q_REQUIRED_RESULT QDateTime nextTime(const QDateTime &preTime, bool ignoreRepetitions = false) const;
437 
444  Q_REQUIRED_RESULT QDateTime endTime() const;
445 
449  Q_REQUIRED_RESULT bool hasTime() const;
450 
459  void setStartOffset(const Duration &offset);
460 
468  Q_REQUIRED_RESULT Duration startOffset() const;
469 
476  bool hasStartOffset() const;
477 
486  void setEndOffset(const Duration &offset);
487 
495  Q_REQUIRED_RESULT Duration endOffset() const;
496 
503  bool hasEndOffset() const;
504 
519  void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone);
520 
528  void setSnoozeTime(const Duration &alarmSnoozeTime);
529 
535  Q_REQUIRED_RESULT Duration snoozeTime() const;
536 
546  void setRepeatCount(int alarmRepeatCount);
547 
553  Q_REQUIRED_RESULT int repeatCount() const;
554 
566  Q_REQUIRED_RESULT QDateTime nextRepetition(const QDateTime &preTime) const;
567 
581  Q_REQUIRED_RESULT QDateTime previousRepetition(const QDateTime &afterTime) const;
582 
587  Q_REQUIRED_RESULT Duration duration() const;
588 
595  void toggleAlarm();
596 
603  void setEnabled(bool enable);
604 
610  Q_REQUIRED_RESULT bool enabled() const;
611 
618  void setHasLocationRadius(bool hasLocationRadius);
619 
625  Q_REQUIRED_RESULT bool hasLocationRadius() const;
626 
635  void setLocationRadius(int locationRadius);
636 
642  Q_REQUIRED_RESULT int locationRadius() const;
643 
644 protected:
649  void customPropertyUpdated() override;
650 
655  virtual void virtual_hook(int id, void *data);
656 
657 private:
658  //@cond PRIVATE
659  class Private;
660  Private *const d;
661  //@endcond
662  friend KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &s, const KCalendarCore::Alarm::Ptr &);
663  friend KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &s, const KCalendarCore::Alarm::Ptr &);
664 };
670 KCALENDARCORE_EXPORT QDataStream &operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &);
671 
677 KCALENDARCORE_EXPORT QDataStream &operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &);
678 
679 }
680 
681 //@cond PRIVATE
682 Q_DECLARE_TYPEINFO(KCalendarCore::Alarm::Ptr, Q_MOVABLE_TYPE);
683 Q_DECLARE_METATYPE(KCalendarCore::Alarm::Ptr)
684 //@endcond
685 
686 #endif
Represents an alarm notification.
Definition: alarm.h:51
KCALENDARCORE_EXPORT QDataStream & operator<<(QDataStream &out, const KCalendarCore::Alarm::Ptr &)
Alarm serializer.
Definition: alarm.cpp:825
A class to manage custom calendar properties.
This file is part of the API for handling calendar data and defines the CustomProperties class...
Represents a person, by name and email address.
Definition: person.h:38
Display a dialog box.
Definition: alarm.h:59
KCALENDARCORE_EXPORT QDataStream & operator>>(QDataStream &in, const KCalendarCore::Alarm::Ptr &)
Alarm deserializer.
Definition: alarm.cpp:849
This file is part of the API for handling calendar data and defines the Person class.
Represents a span of time measured in seconds or days.
Definition: duration.h:44
QVector< Ptr > List
List of alarms.
Definition: alarm.h:73
This file is part of the API for handling calendar data and defines the Duration class.
Type
The different types of alarms.
Definition: alarm.h:57
Invalid, or no alarm.
Definition: alarm.h:58
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:57
QSharedPointer< Alarm > Ptr
A shared pointer to an Alarm object.
Definition: alarm.h:68
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Thu Dec 3 2020 22:51:44 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.