summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimevent.h
Unidiff
Diffstat (limited to 'libopie2/opiepim/core/opimevent.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiepim/core/opimevent.h275
1 files changed, 275 insertions, 0 deletions
diff --git a/libopie2/opiepim/core/opimevent.h b/libopie2/opiepim/core/opimevent.h
new file mode 100644
index 0000000..949f263
--- a/dev/null
+++ b/libopie2/opiepim/core/opimevent.h
@@ -0,0 +1,275 @@
1/*
2 This file is part of the Opie Project
3 Copyright (C) Stefan Eilers <Eilers.Stefan@epost.de>
4 =. Copyright (C) The Opie Team <opie-devel@handhelds.org>
5 .=l.
6 .>+-=
7 _;:, .> :=|. This program is free software; you can
8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more
20++= -. .` .: details.
21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA.
28*/
29// CONTAINS GPLed code of TT
30
31#ifndef OEVENT_H
32#define OEVENT_H
33
34/* OPIE */
35#include <opie2/opimtimezone.h>
36#include <opie2/opimrecord.h>
37#include <qpe/recordfields.h>
38#include <qpe/palmtopuidgen.h>
39
40/* QT */
41#include <qstring.h>
42#include <qdatetime.h>
43#include <qvaluelist.h>
44
45namespace Opie
46{
47struct OCalendarHelper
48{
49 /** calculate the week number of the date */
50 static int week( const QDate& );
51 /** calculate the occurence of week days since the start of the month */
52 static int ocurrence( const QDate& );
53
54 // returns the dayOfWeek for the *first* day it finds (ignores
55 // any further days!). Returns 1 (Monday) if there isn't any day found
56 static int dayOfWeek( char day );
57
58 /** returns the diff of month */
59 static int monthDiff( const QDate& first, const QDate& second );
60
61};
62
63class OPimNotifyManager;
64class OPimRecurrence;
65
66/**
67 * This is the container for all Events. It encapsules all
68 * available information for a single Event
69 * @short container for events.
70 */
71class OPimEvent : public OPimRecord
72{
73 public:
74 typedef QValueList<OPimEvent> ValueList;
75 /**
76 * RecordFields contain possible attributes
77 * used in the Results of toMap()..
78 */
79 enum RecordFields {
80 FUid = Qtopia::UID_ID,
81 FCategories = Qtopia::CATEGORY_ID,
82 FDescription = 0,
83 FLocation,
84 FType,
85 FAlarm,
86 FSound,
87 FRType,
88 FRWeekdays,
89 FRPosition,
90 FRFreq,
91 FRHasEndDate,
92 FREndDate,
93 FRCreated,
94 FRExceptions,
95 FStart,
96 FEnd,
97 FNote,
98 FTimeZone,
99 FRecParent,
100 FRecChildren,
101 };
102
103 /**
104 * Start with an Empty OPimEvent. UID == 0 means that it is empty
105 */
106 OPimEvent( int uid = 0 );
107
108 /**
109 * copy c'tor
110 */
111 OPimEvent( const OPimEvent& );
112
113 /**
114 * Create OPimEvent, initialized by map
115 * @see enum RecordFields
116 */
117 OPimEvent( const QMap<int, QString> map );
118 ~OPimEvent();
119 OPimEvent &operator=( const OPimEvent& );
120
121 QString description() const;
122 void setDescription( const QString& description );
123
124 QString location() const;
125 void setLocation( const QString& loc );
126
127 bool hasNotifiers() const;
128 OPimNotifyManager &notifiers() const;
129
130 OPimRecurrence recurrence() const;
131 void setRecurrence( const OPimRecurrence& );
132 bool hasRecurrence() const;
133
134 QString note() const;
135 void setNote( const QString& note );
136
137
138 QDateTime createdDateTime() const;
139 void setCreatedDateTime( const QDateTime& dt );
140
141 /** set the date to dt. dt is the QDateTime in localtime */
142 void setStartDateTime( const QDateTime& );
143 /** returns the datetime in the local timeZone */
144 QDateTime startDateTime() const;
145
146 /** returns the start datetime in the current zone */
147 QDateTime startDateTimeInZone() const;
148
149 /** in current timezone */
150 void setEndDateTime( const QDateTime& );
151 /** in current timezone */
152 QDateTime endDateTime() const;
153 QDateTime endDateTimeInZone() const;
154
155 bool isMultipleDay() const;
156 bool isAllDay() const;
157 void setAllDay( bool isAllDay );
158
159 /* pin this event to a timezone! FIXME */
160 void setTimeZone( const QString& timeZone );
161 QString timeZone() const;
162
163
164 virtual bool match( const QRegExp& ) const;
165
166 /** For exception to recurrence here is a list of children... */
167 QArray<int> children() const;
168 void setChildren( const QArray<int>& );
169 void addChild( int uid );
170 void removeChild( int uid );
171
172 /** return the parent OPimEvent */
173 int parent() const;
174 void setParent( int uid );
175
176
177 /* needed reimp */
178 QString toRichText() const;
179 QString toShortText() const;
180 QString type() const;
181
182 QMap<int, QString> toMap() const;
183 void fromMap( const QMap<int, QString>& map );
184 QString recordField( int ) const;
185
186 static int rtti();
187
188 bool loadFromStream( QDataStream& );
189 bool saveToStream( QDataStream& ) const;
190
191 /* bool operator==( const OPimEvent& );
192 bool operator!=( const OPimEvent& );
193 bool operator<( const OPimEvent& );
194 bool operator<=( const OPimEvent& );
195 bool operator>( const OPimEvent& );
196 bool operator>=(const OPimEvent& );
197 */
198
199 private:
200 inline void changeOrModify();
201 void deref();
202 struct Data;
203 Data* data;
204 class Private;
205 Private* priv;
206
207};
208
209/**
210 * AN Event can span through multiple days. We split up a multiday eve
211 */
212class OEffectiveEvent
213{
214
215 public:
216 typedef QValueList<OEffectiveEvent> ValueList;
217 enum Position { MidWay, Start, End, StartEnd };
218 // If we calculate the effective event of a multi-day event
219 // we have to figure out whether we are at the first day,
220 // at the end, or anywhere else ("middle"). This is important
221 // for the start/end times (00:00/23:59)
222 // MidWay: 00:00 -> 23:59, as we are "in the middle" of a multi-
223 // day event
224 // Start: start time -> 23:59
225 // End: 00:00 -> end time
226 // Start | End == StartEnd: for single-day events (default)
227 // here we draw start time -> end time
228 OEffectiveEvent();
229 OEffectiveEvent( const OPimEvent& event, const QDate& startDate, Position pos = StartEnd );
230 OEffectiveEvent( const OEffectiveEvent& );
231 OEffectiveEvent &operator=( const OEffectiveEvent& );
232 ~OEffectiveEvent();
233
234 void setStartTime( const QTime& );
235 void setEndTime( const QTime& );
236 void setEvent( const OPimEvent& );
237 void setDate( const QDate& );
238
239 void setEffectiveDates( const QDate& from, const QDate& to );
240
241 QString description() const;
242 QString location() const;
243 QString note() const;
244 OPimEvent event() const;
245 QTime startTime() const;
246 QTime endTime() const;
247 QDate date() const;
248
249 /* return the length in hours */
250 int length() const;
251 int size() const;
252
253 QDate startDate() const;
254 QDate endDate() const;
255
256 bool operator<( const OEffectiveEvent &e ) const;
257 bool operator<=( const OEffectiveEvent &e ) const;
258 bool operator==( const OEffectiveEvent &e ) const;
259 bool operator!=( const OEffectiveEvent &e ) const;
260 bool operator>( const OEffectiveEvent &e ) const;
261 bool operator>= ( const OEffectiveEvent &e ) const;
262
263 private:
264 void deref();
265 inline void changeOrModify();
266 class Private;
267 Private* priv;
268 struct Data;
269 Data* data;
270
271};
272
273}
274
275#endif