KCalendarCore

vcalformat.h
Go to the documentation of this file.
1/*
2 This file is part of the kcalcore library.
3
4 SPDX-FileCopyrightText: 1998 Preston Brown <pbrown@kde.org>
5 SPDX-FileCopyrightText: 2001-2003 Cornelius Schumacher <schumacher@kde.org>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9/**
10 @file
11 This file is part of the API for handling calendar data and
12 defines the VCalFormat base class.
13
14 This class implements the vCalendar format. It provides methods for
15 loading/saving/converting vCalendar format data into the internal
16 representation as Calendar and Incidences.
17
18 @brief
19 vCalendar format implementation.
20
21 @author Preston Brown <pbrown@kde.org>
22 @author Cornelius Schumacher <schumacher@kde.org>
23*/
24
25#ifndef KCALCORE_VCALFORMAT_H
26#define KCALCORE_VCALFORMAT_H
27
28#include "attendee.h"
29#include "calformat.h"
30#include "event.h"
31#include "journal.h"
32#include "kcalendarcore_export.h"
33#include "todo.h"
34
35struct VObject;
36
37class QDate;
38
39#define _VCAL_VERSION "1.0"
40
41/* extensions for iMIP / iTIP */
42#define ICOrganizerProp "X-ORGANIZER"
43#define ICMethodProp "X-METHOD"
44#define ICRequestStatusProp "X-REQUEST-STATUS"
45
46namespace KCalendarCore
47{
48class Event;
49class Todo;
50class VCalFormatPrivate;
51
52/**
53 @brief
54 vCalendar format implementation.
55
56 This class implements the vCalendar format. It provides methods for
57 loading/saving/converting vCalendar format data into the internal
58 representation as Calendar and Incidences.
59*/
60class KCALENDARCORE_EXPORT VCalFormat : public CalFormat
61{
62public:
63 /**
64 Constructor a new vCalendar Format object.
65 */
66 VCalFormat();
67
68 /**
69 Destructor.
70 */
71 ~VCalFormat() override;
72
73 /**
74 @copydoc
75 CalFormat::load()
76 */
77 bool load(const Calendar::Ptr &calendar, const QString &fileName) override;
78
79 /**
80 @copydoc
81 CalFormat::save()
82 */
83 bool save(const Calendar::Ptr &calendar, const QString &fileName) override;
84
85 /**
86 @copydoc
87 CalFormat::toString()
88 */
89 Q_REQUIRED_RESULT QString toString(const Calendar::Ptr &calendar) override;
90
91 /**
92 @copydoc
93 CalFormat::fromRawString()
94 */
95 Q_REQUIRED_RESULT bool fromRawString(const Calendar::Ptr &calendar, const QByteArray &string) override;
96
97protected:
98 /**
99 Translates a VObject of the TODO type into an Event.
100 @param vtodo is a pointer to a valid VObject object.
101 */
102 Todo::Ptr VTodoToEvent(VObject *vtodo);
103
104 /**
105 Translates a VObject into a Event and returns a pointer to it.
106 @param vevent is a pointer to a valid VObject object.
107 */
108 Event::Ptr VEventToEvent(VObject *vevent);
109
110 /**
111 Parse TZ tag from vtimezone.
112 */
113 QString parseTZ(const QByteArray &timezone) const;
114
115 /**
116 Parse DAYLIGHT tag from vtimezone.
117 */
118 QString parseDst(QByteArray &timezone) const;
119
120 /**
121 Takes a QDate and returns a string in the format YYYYMMDDTHHMMSS.
122 @param date is the date to format.
123 */
124 QString qDateToISO(const QDate &date);
125
126 /**
127 Takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS.
128 @param date is the date to format.
129 @param zulu if true, then shift the date to UTC.
130 */
131 QString qDateTimeToISO(const QDateTime &date, bool zulu = true);
132
133 /**
134 Takes a string in YYYYMMDDTHHMMSS format and returns a valid QDateTime.
135 @param dtStr is a QString containing the date to convert. If this value
136 is invalid, then QDateTime() is returned.
137 */
138 QDateTime ISOToQDateTime(const QString &dtStr);
139
140 /**
141 Takes a string in the YYYYMMDD format and returns a valid QDate.
142 @param dtStr is a QString containing the date to convert. If this value
143 is invalid, then QDateTime() is returned.
144 */
145 QDate ISOToQDate(const QString &dtStr);
146
147 /**
148 Parse one of the myriad of ISO8601 timezone offset formats, e.g.
149 +- hh : mm
150 +- hh mm
151 +- hh
152
153 @param s string to be parsed.
154 @param result timezone offset in seconds, if parse succeeded.
155 @return Whether the parse succeeded or not.
156 */
157 bool parseTZOffsetISO8601(const QString &s, int &result);
158
159 /**
160 Takes a vCalendar tree of VObjects, and puts all of them that have the
161 "event" property into the dictionary, todos in the todo-list, etc.
162 */
163 void populate(VObject *vcal);
164
165 /**
166 Converts a two letter representation of the day (i.e. MO, TU, WE, etc) and
167 returns a number 0-6 corresponding to that ordinal day of the week.
168 @param day is the QString containing the two letter day representation.
169 */
170 int numFromDay(const QString &day);
171
172 /**
173 Converts a status string into an Attendee::PartStat.
174 @param s is a null-terminated character string containing the status to convert.
175
176 @return a valid Attendee::PartStat. If the string provided is empty, null,
177 or the contents are unrecognized, then Attendee::NeedsAction is returned.
178 */
179 Attendee::PartStat readStatus(const char *s) const;
180
181 /**
182 Converts an Attendee::PartStat into a QByteArray string.
183 @param status is the Attendee::PartStat to convert.
184
185 @return a QByteArray containing the status string.
186 */
187 QByteArray writeStatus(Attendee::PartStat status) const;
188
189 void readCustomProperties(VObject *o, const Incidence::Ptr &i);
190 void writeCustomProperties(VObject *o, const Incidence::Ptr &i);
191
192private:
193 //@cond PRIVATE
194 Q_DISABLE_COPY(VCalFormat)
195 Q_DECLARE_PRIVATE(VCalFormat)
196 //@endcond
197};
198
199}
200
201#endif
This file is part of the API for handling calendar data and defines the Attendee class.
This file is part of the API for handling calendar data and defines the CalFormat abstract base class...
PartStat
The different types of participant status.
Definition attendee.h:64
An abstract base class that provides an interface to various calendar formats.
Definition calformat.h:39
vCalendar format implementation.
Definition vcalformat.h:61
This file is part of the API for handling calendar data and defines the Event class.
Q_SCRIPTABLE CaptureState status()
This file is part of the API for handling calendar data and defines the Journal class.
Namespace for all KCalendarCore types.
Definition alarm.h:37
This file is part of the API for handling calendar data and defines the Todo class.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:05 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.