Build, if that was not necessary blame cartman who told me "sure" :-D
[kdepim.git] / libkcal / vcalformat.h
bloba7bb2c0c4924954eab73b426af6d9e97b35f53aa
1 /*
2 This file is part of libkcal.
4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001-2003 Cornelius Schumacher <schumacher@kde.org>
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA.
22 #ifndef KCAL_VCALFORMAT_H
23 #define KCAL_VCALFORMAT_H
25 #include "calformat.h"
27 #include "todo.h"
28 #include "event.h"
30 #define _VCAL_VERSION "1.0"
32 class VObject;
34 namespace KCal {
36 /**
37 This class implements the vCalendar format. It provides methods for
38 loading/saving/converting vCalendar format data into the internal KOrganizer
39 representation as Calendar and Events.
41 @short vCalendar format implementation
43 class VCalFormat : public CalFormat
45 public:
46 VCalFormat();
47 virtual ~VCalFormat();
49 /**
50 Loads a calendar on disk in vCalendar format into the given calendar.
52 @param calendar Calendar object the loaded data is stored into.
53 @param fileName Name of the vCalendar file on disk.
54 @return true on success, otherwise false
56 bool load( Calendar *calendar, const QString &fileName );
57 /**
58 Writes out the given calendar to disk in vCalendar format.
60 @param calendar Calendar object holding data to be written
61 @param fileName the name of the file
62 @return true on success, otherwise false
64 bool save(Calendar *calendar, const QString &fileName);
66 /**
67 Parse string and populate calendar with that information.
69 bool fromString( Calendar *, const QString & );
70 /**
71 Return calendar information as string.
73 QString toString( Calendar * );
75 protected:
76 /** translates a VObject of the TODO type into a Event */
77 Todo *VTodoToEvent(VObject *vtodo);
78 /** translates a VObject into a Event and returns a pointer to it. */
79 Event *VEventToEvent(VObject *vevent);
80 /** translate a Event into a VTodo-type VObject and return pointer */
81 VObject *eventToVTodo(const Todo *anEvent);
82 /** translate a Event into a VObject and returns a pointer to it. */
83 VObject* eventToVEvent(const Event *anEvent);
85 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
86 QString qDateToISO(const QDate &);
87 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */
88 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE);
89 /** takes a string in the format YYYYMMDDTHHMMSS and returns a
90 * valid QDateTime. */
91 QDateTime ISOToQDateTime(const QString & dtStr);
92 /** takes a string in the format YYYYMMDD and returns a
93 * valid QDate. */
94 QDate ISOToQDate(const QString & dtStr);
95 /** takes a vCalendar tree of VObjects, and puts all of them that have
96 * the "event" property into the dictionary, todos in the todo-list, etc. */
97 void populate(VObject *vcal);
99 /** takes a number 0 - 6 and returns the two letter string of that day,
100 * i.e. MO, TU, WE, etc. */
101 const char *dayFromNum(int day);
102 /** the reverse of the above function. */
103 int numFromDay(const QString &day);
105 Attendee::PartStat readStatus(const char *s) const;
106 QCString writeStatus(Attendee::PartStat status) const;
108 private:
109 Calendar *mCalendar;
111 Event::List mEventsRelate; // events with relations
112 Todo::List mTodosRelate; // todos with relations
114 class Private;
115 Private *d;
120 #endif