KCalendarCore

event.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 
6  SPDX-License-Identifier: LGPL-2.0-or-later
7 */
8 /**
9  @file
10  This file is part of the API for handling calendar data and
11  defines the Event class.
12 
13  @author Cornelius Schumacher <[email protected]>
14 */
15 #ifndef KCALCORE_EVENT_H
16 #define KCALCORE_EVENT_H
17 
18 #include "incidence.h"
19 #include "kcalendarcore_export.h"
20 
21 #include <QTimeZone>
22 
23 namespace KCalendarCore
24 {
25 /**
26  @brief
27  This class provides an Event in the sense of RFC2445.
28 */
29 class KCALENDARCORE_EXPORT Event : public Incidence
30 {
31  Q_GADGET
32  Q_PROPERTY(QDateTime dtEnd READ dtEnd WRITE setDtEnd)
33  Q_PROPERTY(KCalendarCore::Event::Transparency transparency READ transparency WRITE setTransparency)
34 public:
35  /**
36  The different Event transparency types.
37  */
38  enum Transparency {
39  Opaque, /**< Event appears in free/busy time */
40  Transparent, /**< Event does @b not appear in free/busy time */
41  };
42  Q_ENUM(Transparency)
43 
44  /**
45  A shared pointer to an Event object.
46  */
48 
49  /**
50  List of events.
51  */
52  typedef QVector<Ptr> List;
53 
54  ///@cond PRIVATE
55  // needed for Akonadi polymorphic payload support
56  typedef Incidence SuperClass;
57  ///@endcond
58 
59  /**
60  Constructs an event.
61  */
62  Event();
63 
64  /**
65  Copy constructor.
66  @param other is the event to copy.
67  */
68  Event(const Event &other);
69 
70  /**
71  Costructs an event out of an incidence
72  This constructs allows to make it easy to create an event from a todo.
73  @param other is the incidence to copy.
74  @since 4.14
75  */
76  Event(const Incidence &other); // krazy:exclude=explicit (copy ctor)
77 
78  /**
79  Destroys the event.
80  */
81  ~Event() override;
82 
83  /**
84  @copydoc
85  IncidenceBase::type()
86  */
87  Q_REQUIRED_RESULT IncidenceType type() const override;
88 
89  /**
90  @copydoc
91  IncidenceBase::typeStr()
92  */
93  Q_REQUIRED_RESULT QByteArray typeStr() const override;
94 
95  /**
96  Returns an exact copy of this Event. The caller owns the returned object.
97  */
98  Event *clone() const override;
99 
100  /**
101  Sets the incidence starting date/time.
102 
103  @param dt is the starting date/time.
104  @see IncidenceBase::dtStart().
105  */
106  void setDtStart(const QDateTime &dt) override;
107 
108  /**
109  Sets the event end date and time.
110  Important note for all day events: the end date is inclusive,
111  the event will still occur during dtEnd(). When serializing to iCalendar
112  DTEND will be dtEnd()+1, because the RFC states that DTEND is exclusive.
113  @param dtEnd is a QDateTime specifying when the event ends.
114  @see dtEnd(), dateEnd().
115  */
116  void setDtEnd(const QDateTime &dtEnd);
117 
118  /**
119  Returns the event end date and time.
120  Important note for all day events: the returned end date is inclusive,
121  the event will still occur during dtEnd(). When serializing to iCalendar
122  DTEND will be dtEnd()+1, because the RFC states that DTEND is exclusive.
123  @see setDtEnd().
124  */
125  virtual QDateTime dtEnd() const;
126 
127  /**
128  Returns the date when the event ends. This might be different from
129  dtEnd().date, since the end date/time is non-inclusive. So timed events
130  ending at 0:00 have their end date on the day before.
131  */
132  Q_REQUIRED_RESULT QDate dateEnd() const;
133 
134  /**
135  Returns whether the event has an end date/time.
136  */
137  Q_REQUIRED_RESULT bool hasEndDate() const;
138 
139  /**
140  Returns true if the event spans multiple days, otherwise return false.
141 
142  For recurring events, it returns true if the first occurrence spans multiple days,
143  otherwise returns false. Other occurrences might have a different span due to day light
144  savings changes.
145 
146  @param zone If set, looks if the event is multiday for the given zone.
147  If not set, looks if event this multiday for its zone.
148  */
149  Q_REQUIRED_RESULT bool isMultiDay(const QTimeZone &zone = {}) const;
150 
151  /**
152  @copydoc
153  IncidenceBase::shiftTimes()
154  */
155  void shiftTimes(const QTimeZone &oldZone, const QTimeZone &newZone) override;
156 
157  /**
158  Sets the event's time transparency level.
159  @param transparency is the event Transparency level.
160  */
161  void setTransparency(Transparency transparency);
162 
163  /**
164  Returns the event's time transparency level.
165  */
166  Q_REQUIRED_RESULT Transparency transparency() const;
167 
168  /**
169  Sets the duration of this event.
170  @param duration is the event Duration.
171  */
172  void setDuration(const Duration &duration) override;
173 
174  /**
175  @copydoc
176  IncidenceBase::setAllDay().
177  */
178  void setAllDay(bool allDay) override;
179 
180  /**
181  @copydoc
182  IncidenceBase::dateTime()
183  */
184  Q_REQUIRED_RESULT QDateTime dateTime(DateTimeRole role) const override;
185 
186  /**
187  @copydoc
188  IncidenceBase::setDateTime()
189  */
190  void setDateTime(const QDateTime &dateTime, DateTimeRole role) override;
191 
192  /**
193  @copydoc
194  IncidenceBase::mimeType()
195  */
196  Q_REQUIRED_RESULT QLatin1String mimeType() const override;
197 
198  /**
199  @copydoc
200  Incidence::iconName()
201  */
202  Q_REQUIRED_RESULT QLatin1String iconName(const QDateTime &recurrenceId = {}) const override;
203 
204  /**
205  @copydoc
206  Incidence::supportsGroupwareCommunication()
207  */
208  Q_REQUIRED_RESULT bool supportsGroupwareCommunication() const override;
209 
210  /**
211  Returns the Akonadi specific sub MIME type of a KCalendarCore::Event.
212  */
213  Q_REQUIRED_RESULT static QLatin1String eventMimeType();
214 
215 protected:
216  /**
217  Compares two events for equality.
218  @param event is the event to compare.
219  */
220  bool equals(const IncidenceBase &event) const override;
221 
222  /**
223  @copydoc
224  IncidenceBase::assign()
225  */
226  IncidenceBase &assign(const IncidenceBase &other) override;
227 
228  /**
229  @copydoc
230  IncidenceBase::virtual_hook()
231  */
232  void virtual_hook(VirtualHook id, void *data) override;
233 
234 private:
235  /**
236  @copydoc
237  IncidenceBase::accept()
238  */
239  bool accept(Visitor &v, const IncidenceBase::Ptr &incidence) override;
240 
241  /**
242  Disabled, otherwise could be dangerous if you subclass Event.
243  Use IncidenceBase::operator= which is safe because it calls
244  virtual function assign().
245  @param other is another Event object to assign to this one.
246  */
247  Event &operator=(const Event &other);
248 
249  // For polymorfic serialization
250  void serialize(QDataStream &out) const override;
251  void deserialize(QDataStream &in) override;
252 
253  //@cond PRIVATE
254  class Private;
255  Private *const d;
256  //@endcond
257 };
258 
259 } // namespace KCalendarCore
260 
261 //@cond PRIVATE
262 Q_DECLARE_TYPEINFO(KCalendarCore::Event::Ptr, Q_MOVABLE_TYPE);
263 Q_DECLARE_METATYPE(KCalendarCore::Event::Ptr)
264 Q_DECLARE_METATYPE(KCalendarCore::Event *)
265 //@endcond
266 
267 #endif
This class provides the interface for a visitor of calendar components.
Definition: visitor.h:30
Event does not appear in free/busy time.
Definition: event.h:40
DateTimeRole
The different types of incidence date/times roles.
An abstract class that provides a common base for all calendar incidence classes. ...
Definition: incidencebase.h:97
Represents a span of time measured in seconds or days.
Definition: duration.h:43
This class provides an Event in the sense of RFC2445.
Definition: event.h:29
Event appears in free/busy time.
Definition: event.h:39
IncidenceType
The different types of incidences, per RFC2445.
Transparency
The different Event transparency types.
Definition: event.h:38
This file is part of the API for handling calendar data and defines the Incidence class...
Provides the abstract base class common to non-FreeBusy (Events, To-dos, Journals) calendar component...
Definition: incidence.h:56
Namespace for all KCalendarCore types.
Definition: alarm.h:36
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Sep 24 2021 22:51:50 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.