-rw-r--r-- | libopie2/opiepim/oevent.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/libopie2/opiepim/oevent.cpp b/libopie2/opiepim/oevent.cpp index 28cf873..b731c8a 100644 --- a/libopie2/opiepim/oevent.cpp +++ b/libopie2/opiepim/oevent.cpp | |||
@@ -61,385 +61,397 @@ struct OEvent::Data : public QShared { | |||
61 | QDateTime created; | 61 | QDateTime created; |
62 | QDateTime start; | 62 | QDateTime start; |
63 | QDateTime end; | 63 | QDateTime end; |
64 | bool isAllDay : 1; | 64 | bool isAllDay : 1; |
65 | QString timezone; | 65 | QString timezone; |
66 | QArray<int>* child; | 66 | QArray<int>* child; |
67 | int parent; | 67 | int parent; |
68 | }; | 68 | }; |
69 | 69 | ||
70 | OEvent::OEvent( int uid ) | 70 | OEvent::OEvent( int uid ) |
71 | : OPimRecord( uid ) { | 71 | : OPimRecord( uid ) { |
72 | data = new Data; | 72 | data = new Data; |
73 | } | 73 | } |
74 | OEvent::OEvent( const OEvent& ev) | 74 | OEvent::OEvent( const OEvent& ev) |
75 | : OPimRecord( ev ), data( ev.data ) | 75 | : OPimRecord( ev ), data( ev.data ) |
76 | { | 76 | { |
77 | data->ref(); | 77 | data->ref(); |
78 | } | 78 | } |
79 | OEvent::~OEvent() { | 79 | OEvent::~OEvent() { |
80 | if ( data->deref() ) { | 80 | if ( data->deref() ) { |
81 | delete data; | 81 | delete data; |
82 | data = 0; | 82 | data = 0; |
83 | } | 83 | } |
84 | } | 84 | } |
85 | OEvent& OEvent::operator=( const OEvent& ev) { | 85 | OEvent& OEvent::operator=( const OEvent& ev) { |
86 | if ( this == &ev ) return *this; | 86 | if ( this == &ev ) return *this; |
87 | 87 | ||
88 | OPimRecord::operator=( ev ); | 88 | OPimRecord::operator=( ev ); |
89 | ev.data->ref(); | 89 | ev.data->ref(); |
90 | deref(); | 90 | deref(); |
91 | data = ev.data; | 91 | data = ev.data; |
92 | 92 | ||
93 | 93 | ||
94 | return *this; | 94 | return *this; |
95 | } | 95 | } |
96 | QString OEvent::description()const { | 96 | QString OEvent::description()const { |
97 | return data->description; | 97 | return data->description; |
98 | } | 98 | } |
99 | void OEvent::setDescription( const QString& description ) { | 99 | void OEvent::setDescription( const QString& description ) { |
100 | changeOrModify(); | 100 | changeOrModify(); |
101 | data->description = description; | 101 | data->description = description; |
102 | } | 102 | } |
103 | void OEvent::setLocation( const QString& loc ) { | 103 | void OEvent::setLocation( const QString& loc ) { |
104 | changeOrModify(); | 104 | changeOrModify(); |
105 | data->location = loc; | 105 | data->location = loc; |
106 | } | 106 | } |
107 | QString OEvent::location()const { | 107 | QString OEvent::location()const { |
108 | return data->location; | 108 | return data->location; |
109 | } | 109 | } |
110 | OPimNotifyManager &OEvent::notifiers()const { | 110 | OPimNotifyManager &OEvent::notifiers()const { |
111 | // I hope we can skip the changeOrModify here | 111 | // I hope we can skip the changeOrModify here |
112 | // the notifier should take care of it | 112 | // the notifier should take care of it |
113 | // and OPimNotify is shared too | 113 | // and OPimNotify is shared too |
114 | if (!data->manager ) | 114 | if (!data->manager ) |
115 | data->manager = new OPimNotifyManager; | 115 | data->manager = new OPimNotifyManager; |
116 | 116 | ||
117 | return *data->manager; | 117 | return *data->manager; |
118 | } | 118 | } |
119 | bool OEvent::hasNotifiers()const { | 119 | bool OEvent::hasNotifiers()const { |
120 | if (!data->manager ) | 120 | if (!data->manager ) |
121 | return false; | 121 | return false; |
122 | if (data->manager->reminders().isEmpty() && | 122 | if (data->manager->reminders().isEmpty() && |
123 | data->manager->alarms().isEmpty() ) | 123 | data->manager->alarms().isEmpty() ) |
124 | return false; | 124 | return false; |
125 | 125 | ||
126 | return true; | 126 | return true; |
127 | } | 127 | } |
128 | ORecur OEvent::recurrence()const { | 128 | ORecur OEvent::recurrence()const { |
129 | if (!data->recur) | 129 | if (!data->recur) |
130 | data->recur = new ORecur; | 130 | data->recur = new ORecur; |
131 | 131 | ||
132 | return *data->recur; | 132 | return *data->recur; |
133 | } | 133 | } |
134 | void OEvent::setRecurrence( const ORecur& rec) { | 134 | void OEvent::setRecurrence( const ORecur& rec) { |
135 | changeOrModify(); | 135 | changeOrModify(); |
136 | if (data->recur ) | 136 | if (data->recur ) |
137 | (*data->recur) = rec; | 137 | (*data->recur) = rec; |
138 | else | 138 | else |
139 | data->recur = new ORecur( rec ); | 139 | data->recur = new ORecur( rec ); |
140 | } | 140 | } |
141 | bool OEvent::hasRecurrence()const { | 141 | bool OEvent::hasRecurrence()const { |
142 | if (!data->recur ) return false; | 142 | if (!data->recur ) return false; |
143 | return data->recur->doesRecur(); | 143 | return data->recur->doesRecur(); |
144 | } | 144 | } |
145 | QString OEvent::note()const { | 145 | QString OEvent::note()const { |
146 | return data->note; | 146 | return data->note; |
147 | } | 147 | } |
148 | void OEvent::setNote( const QString& note ) { | 148 | void OEvent::setNote( const QString& note ) { |
149 | changeOrModify(); | 149 | changeOrModify(); |
150 | data->note = note; | 150 | data->note = note; |
151 | } | 151 | } |
152 | QDateTime OEvent::createdDateTime()const { | 152 | QDateTime OEvent::createdDateTime()const { |
153 | return data->created; | 153 | return data->created; |
154 | } | 154 | } |
155 | void OEvent::setCreatedDateTime( const QDateTime& time ) { | 155 | void OEvent::setCreatedDateTime( const QDateTime& time ) { |
156 | changeOrModify(); | 156 | changeOrModify(); |
157 | data->created = time; | 157 | data->created = time; |
158 | } | 158 | } |
159 | QDateTime OEvent::startDateTime()const { | 159 | QDateTime OEvent::startDateTime()const { |
160 | if ( data->isAllDay ) | 160 | if ( data->isAllDay ) |
161 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); | 161 | return QDateTime( data->start.date(), QTime(0, 0, 0 ) ); |
162 | return data->start; | 162 | return data->start; |
163 | } | 163 | } |
164 | QDateTime OEvent::startDateTimeInZone()const { | 164 | QDateTime OEvent::startDateTimeInZone()const { |
165 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 165 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
166 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); | 166 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return startDateTime(); |
167 | 167 | ||
168 | OTimeZone zone(data->timezone ); | 168 | OTimeZone zone(data->timezone ); |
169 | return zone.toDateTime( data->start, OTimeZone::current() ); | 169 | return zone.toDateTime( data->start, OTimeZone::current() ); |
170 | } | 170 | } |
171 | void OEvent::setStartDateTime( const QDateTime& dt ) { | 171 | void OEvent::setStartDateTime( const QDateTime& dt ) { |
172 | changeOrModify(); | 172 | changeOrModify(); |
173 | data->start = dt; | 173 | data->start = dt; |
174 | } | 174 | } |
175 | QDateTime OEvent::endDateTime()const { | 175 | QDateTime OEvent::endDateTime()const { |
176 | /* | 176 | /* |
177 | * if all Day event the end time needs | 177 | * if all Day event the end time needs |
178 | * to be on the same day as the start | 178 | * to be on the same day as the start |
179 | */ | 179 | */ |
180 | if ( data->isAllDay ) | 180 | if ( data->isAllDay ) |
181 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); | 181 | return QDateTime( data->start.date(), QTime(23, 59, 59 ) ); |
182 | return data->end; | 182 | return data->end; |
183 | } | 183 | } |
184 | QDateTime OEvent::endDateTimeInZone()const { | 184 | QDateTime OEvent::endDateTimeInZone()const { |
185 | /* if no timezone, or all day event or if the current and this timeZone match... */ | 185 | /* if no timezone, or all day event or if the current and this timeZone match... */ |
186 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); | 186 | if (data->timezone.isEmpty() || data->isAllDay || data->timezone == OTimeZone::current().timeZone() ) return endDateTime(); |
187 | 187 | ||
188 | OTimeZone zone(data->timezone ); | 188 | OTimeZone zone(data->timezone ); |
189 | return zone.toDateTime( data->end, OTimeZone::current() ); | 189 | return zone.toDateTime( data->end, OTimeZone::current() ); |
190 | } | 190 | } |
191 | void OEvent::setEndDateTime( const QDateTime& dt ) { | 191 | void OEvent::setEndDateTime( const QDateTime& dt ) { |
192 | changeOrModify(); | 192 | changeOrModify(); |
193 | data->end = dt; | 193 | data->end = dt; |
194 | } | 194 | } |
195 | bool OEvent::isMultipleDay()const { | 195 | bool OEvent::isMultipleDay()const { |
196 | return data->end.date().day() - data->start.date().day(); | 196 | return data->end.date().day() - data->start.date().day(); |
197 | } | 197 | } |
198 | bool OEvent::isAllDay()const { | 198 | bool OEvent::isAllDay()const { |
199 | return data->isAllDay; | 199 | return data->isAllDay; |
200 | } | 200 | } |
201 | void OEvent::setAllDay( bool allDay ) { | 201 | void OEvent::setAllDay( bool allDay ) { |
202 | changeOrModify(); | 202 | changeOrModify(); |
203 | data->isAllDay = allDay; | 203 | data->isAllDay = allDay; |
204 | if (allDay ) data->timezone = "UTC"; | 204 | if (allDay ) data->timezone = "UTC"; |
205 | } | 205 | } |
206 | void OEvent::setTimeZone( const QString& tz ) { | 206 | void OEvent::setTimeZone( const QString& tz ) { |
207 | changeOrModify(); | 207 | changeOrModify(); |
208 | data->timezone = tz; | 208 | data->timezone = tz; |
209 | } | 209 | } |
210 | QString OEvent::timeZone()const { | 210 | QString OEvent::timeZone()const { |
211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); | 211 | if (data->isAllDay ) return QString::fromLatin1("UTC"); |
212 | return data->timezone; | 212 | return data->timezone; |
213 | } | 213 | } |
214 | bool OEvent::match( const QRegExp& re )const { | 214 | bool OEvent::match( const QRegExp& re )const { |
215 | if (data->description.contains( re ) ) | 215 | if (data->description.contains( re ) ) |
216 | return true; | 216 | return true; |
217 | if ( data->note.contains( re ) ) | 217 | if ( data->note.contains( re ) ) |
218 | return true; | 218 | return true; |
219 | if ( data->location.contains( re ) ) | 219 | if ( data->location.contains( re ) ) |
220 | return true; | 220 | return true; |
221 | if ( data->start.toString().contains( re ) ) | 221 | if ( data->start.toString().contains( re ) ) |
222 | return true; | 222 | return true; |
223 | if ( data->end.toString().contains( re ) ) | 223 | if ( data->end.toString().contains( re ) ) |
224 | return true; | 224 | return true; |
225 | return false; | 225 | return false; |
226 | } | 226 | } |
227 | QString OEvent::toRichText()const { | 227 | QString OEvent::toRichText()const { |
228 | QString text; | 228 | QString text; |
229 | if ( !description().isEmpty() ) { | 229 | if ( !description().isEmpty() ) { |
230 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; | 230 | text += "<b>" + QObject::tr( "Description:") + "</b><br>"; |
231 | text += Qtopia::escapeString(description() ). | 231 | text += Qtopia::escapeString(description() ). |
232 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 232 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
233 | } | 233 | } |
234 | if ( startDateTime().isValid() ) { | 234 | if ( startDateTime().isValid() ) { |
235 | text += "<b>" + QObject::tr( "Start:") + "</b> "; | 235 | text += "<b>" + QObject::tr( "Start:") + "</b> "; |
236 | text += Qtopia::escapeString(startDateTime().toString() ). | 236 | text += Qtopia::escapeString(startDateTime().toString() ). |
237 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 237 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
238 | } | 238 | } |
239 | if ( endDateTime().isValid() ) { | 239 | if ( endDateTime().isValid() ) { |
240 | text += "<b>" + QObject::tr( "End:") + "</b> "; | 240 | text += "<b>" + QObject::tr( "End:") + "</b> "; |
241 | text += Qtopia::escapeString(endDateTime().toString() ). | 241 | text += Qtopia::escapeString(endDateTime().toString() ). |
242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 242 | replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
243 | } | 243 | } |
244 | if ( !note().isEmpty() ) { | 244 | if ( !note().isEmpty() ) { |
245 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; | 245 | text += "<b>" + QObject::tr( "Note:") + "</b><br>"; |
246 | text += note(); | 246 | text += note(); |
247 | // text += Qtopia::escapeString(note() ). | 247 | // text += Qtopia::escapeString(note() ). |
248 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; | 248 | // replace(QRegExp( "[\n]"), "<br>" ) + "<br>"; |
249 | } | 249 | } |
250 | return text; | 250 | return text; |
251 | } | 251 | } |
252 | QString OEvent::toShortText()const { | 252 | QString OEvent::toShortText()const { |
253 | return description(); | 253 | QString text; |
254 | text += QString::number( startDateTime().date().day() ); | ||
255 | text += "."; | ||
256 | text += QString::number( startDateTime().date().month() ); | ||
257 | text += "."; | ||
258 | text += QString::number( startDateTime().date().year() ); | ||
259 | text += " "; | ||
260 | text += QString::number( startDateTime().time().hour() ); | ||
261 | text += ":"; | ||
262 | text += QString::number( startDateTime().time().minute() ); | ||
263 | text += " - "; | ||
264 | text += description(); | ||
265 | return text; | ||
254 | } | 266 | } |
255 | QString OEvent::type()const { | 267 | QString OEvent::type()const { |
256 | return QString::fromLatin1("OEvent"); | 268 | return QString::fromLatin1("OEvent"); |
257 | } | 269 | } |
258 | QString OEvent::recordField( int /*id */ )const { | 270 | QString OEvent::recordField( int /*id */ )const { |
259 | return QString::null; | 271 | return QString::null; |
260 | } | 272 | } |
261 | int OEvent::rtti() { | 273 | int OEvent::rtti() { |
262 | return OPimResolver::DateBook; | 274 | return OPimResolver::DateBook; |
263 | } | 275 | } |
264 | bool OEvent::loadFromStream( QDataStream& ) { | 276 | bool OEvent::loadFromStream( QDataStream& ) { |
265 | return true; | 277 | return true; |
266 | } | 278 | } |
267 | bool OEvent::saveToStream( QDataStream& )const { | 279 | bool OEvent::saveToStream( QDataStream& )const { |
268 | return true; | 280 | return true; |
269 | } | 281 | } |
270 | void OEvent::changeOrModify() { | 282 | void OEvent::changeOrModify() { |
271 | if ( data->count != 1 ) { | 283 | if ( data->count != 1 ) { |
272 | data->deref(); | 284 | data->deref(); |
273 | Data* d2 = new Data; | 285 | Data* d2 = new Data; |
274 | d2->description = data->description; | 286 | d2->description = data->description; |
275 | d2->location = data->location; | 287 | d2->location = data->location; |
276 | 288 | ||
277 | if (data->manager ) | 289 | if (data->manager ) |
278 | d2->manager = new OPimNotifyManager( *data->manager ); | 290 | d2->manager = new OPimNotifyManager( *data->manager ); |
279 | 291 | ||
280 | if ( data->recur ) | 292 | if ( data->recur ) |
281 | d2->recur = new ORecur( *data->recur ); | 293 | d2->recur = new ORecur( *data->recur ); |
282 | 294 | ||
283 | d2->note = data->note; | 295 | d2->note = data->note; |
284 | d2->created = data->created; | 296 | d2->created = data->created; |
285 | d2->start = data->start; | 297 | d2->start = data->start; |
286 | d2->end = data->end; | 298 | d2->end = data->end; |
287 | d2->isAllDay = data->isAllDay; | 299 | d2->isAllDay = data->isAllDay; |
288 | d2->timezone = data->timezone; | 300 | d2->timezone = data->timezone; |
289 | d2->parent = data->parent; | 301 | d2->parent = data->parent; |
290 | 302 | ||
291 | if ( data->child ) { | 303 | if ( data->child ) { |
292 | d2->child = new QArray<int>( *data->child ); | 304 | d2->child = new QArray<int>( *data->child ); |
293 | d2->child->detach(); | 305 | d2->child->detach(); |
294 | } | 306 | } |
295 | 307 | ||
296 | data = d2; | 308 | data = d2; |
297 | } | 309 | } |
298 | } | 310 | } |
299 | void OEvent::deref() { | 311 | void OEvent::deref() { |
300 | if ( data->deref() ) { | 312 | if ( data->deref() ) { |
301 | delete data; | 313 | delete data; |
302 | data = 0; | 314 | data = 0; |
303 | } | 315 | } |
304 | } | 316 | } |
305 | // FIXME | 317 | // FIXME |
306 | QMap<int, QString> OEvent::toMap()const { | 318 | QMap<int, QString> OEvent::toMap()const { |
307 | return QMap<int, QString>(); | 319 | return QMap<int, QString>(); |
308 | } | 320 | } |
309 | QMap<QString, QString> OEvent::toExtraMap()const { | 321 | QMap<QString, QString> OEvent::toExtraMap()const { |
310 | return QMap<QString, QString>(); | 322 | return QMap<QString, QString>(); |
311 | } | 323 | } |
312 | int OEvent::parent()const { | 324 | int OEvent::parent()const { |
313 | return data->parent; | 325 | return data->parent; |
314 | } | 326 | } |
315 | void OEvent::setParent( int uid ) { | 327 | void OEvent::setParent( int uid ) { |
316 | changeOrModify(); | 328 | changeOrModify(); |
317 | data->parent = uid; | 329 | data->parent = uid; |
318 | } | 330 | } |
319 | QArray<int> OEvent::children() const{ | 331 | QArray<int> OEvent::children() const{ |
320 | if (!data->child) return QArray<int>(); | 332 | if (!data->child) return QArray<int>(); |
321 | else | 333 | else |
322 | return data->child->copy(); | 334 | return data->child->copy(); |
323 | } | 335 | } |
324 | void OEvent::setChildren( const QArray<int>& arr ) { | 336 | void OEvent::setChildren( const QArray<int>& arr ) { |
325 | changeOrModify(); | 337 | changeOrModify(); |
326 | if (data->child) delete data->child; | 338 | if (data->child) delete data->child; |
327 | 339 | ||
328 | data->child = new QArray<int>( arr ); | 340 | data->child = new QArray<int>( arr ); |
329 | data->child->detach(); | 341 | data->child->detach(); |
330 | } | 342 | } |
331 | void OEvent::addChild( int uid ) { | 343 | void OEvent::addChild( int uid ) { |
332 | changeOrModify(); | 344 | changeOrModify(); |
333 | if (!data->child ) { | 345 | if (!data->child ) { |
334 | data->child = new QArray<int>(1); | 346 | data->child = new QArray<int>(1); |
335 | (*data->child)[0] = uid; | 347 | (*data->child)[0] = uid; |
336 | }else{ | 348 | }else{ |
337 | int count = data->child->count(); | 349 | int count = data->child->count(); |
338 | data->child->resize( count + 1 ); | 350 | data->child->resize( count + 1 ); |
339 | (*data->child)[count] = uid; | 351 | (*data->child)[count] = uid; |
340 | } | 352 | } |
341 | } | 353 | } |
342 | void OEvent::removeChild( int uid ) { | 354 | void OEvent::removeChild( int uid ) { |
343 | if (!data->child || !data->child->contains( uid ) ) return; | 355 | if (!data->child || !data->child->contains( uid ) ) return; |
344 | changeOrModify(); | 356 | changeOrModify(); |
345 | QArray<int> newAr( data->child->count() - 1 ); | 357 | QArray<int> newAr( data->child->count() - 1 ); |
346 | int j = 0; | 358 | int j = 0; |
347 | uint count = data->child->count(); | 359 | uint count = data->child->count(); |
348 | for ( uint i = 0; i < count; i++ ) { | 360 | for ( uint i = 0; i < count; i++ ) { |
349 | if ( (*data->child)[i] != uid ) { | 361 | if ( (*data->child)[i] != uid ) { |
350 | newAr[j] = (*data->child)[i]; | 362 | newAr[j] = (*data->child)[i]; |
351 | j++; | 363 | j++; |
352 | } | 364 | } |
353 | } | 365 | } |
354 | (*data->child) = newAr; | 366 | (*data->child) = newAr; |
355 | } | 367 | } |
356 | struct OEffectiveEvent::Data : public QShared { | 368 | struct OEffectiveEvent::Data : public QShared { |
357 | Data() : QShared() { | 369 | Data() : QShared() { |
358 | } | 370 | } |
359 | OEvent event; | 371 | OEvent event; |
360 | QDate date; | 372 | QDate date; |
361 | QTime start, end; | 373 | QTime start, end; |
362 | QDate startDate, endDate; | 374 | QDate startDate, endDate; |
363 | bool dates : 1; | 375 | bool dates : 1; |
364 | }; | 376 | }; |
365 | 377 | ||
366 | OEffectiveEvent::OEffectiveEvent() { | 378 | OEffectiveEvent::OEffectiveEvent() { |
367 | data = new Data; | 379 | data = new Data; |
368 | data->date = QDate::currentDate(); | 380 | data->date = QDate::currentDate(); |
369 | data->start = data->end = QTime::currentTime(); | 381 | data->start = data->end = QTime::currentTime(); |
370 | data->dates = false; | 382 | data->dates = false; |
371 | } | 383 | } |
372 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, | 384 | OEffectiveEvent::OEffectiveEvent( const OEvent& ev, const QDate& startDate, |
373 | Position pos ) { | 385 | Position pos ) { |
374 | data = new Data; | 386 | data = new Data; |
375 | data->event = ev; | 387 | data->event = ev; |
376 | data->date = startDate; | 388 | data->date = startDate; |
377 | if ( pos & Start ) | 389 | if ( pos & Start ) |
378 | data->start = ev.startDateTime().time(); | 390 | data->start = ev.startDateTime().time(); |
379 | else | 391 | else |
380 | data->start = QTime( 0, 0, 0 ); | 392 | data->start = QTime( 0, 0, 0 ); |
381 | 393 | ||
382 | if ( pos & End ) | 394 | if ( pos & End ) |
383 | data->end = ev.endDateTime().time(); | 395 | data->end = ev.endDateTime().time(); |
384 | else | 396 | else |
385 | data->end = QTime( 23, 59, 59 ); | 397 | data->end = QTime( 23, 59, 59 ); |
386 | 398 | ||
387 | data->dates = false; | 399 | data->dates = false; |
388 | } | 400 | } |
389 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { | 401 | OEffectiveEvent::OEffectiveEvent( const OEffectiveEvent& ev) { |
390 | data = ev.data; | 402 | data = ev.data; |
391 | data->ref(); | 403 | data->ref(); |
392 | } | 404 | } |
393 | OEffectiveEvent::~OEffectiveEvent() { | 405 | OEffectiveEvent::~OEffectiveEvent() { |
394 | if ( data->deref() ) { | 406 | if ( data->deref() ) { |
395 | delete data; | 407 | delete data; |
396 | data = 0; | 408 | data = 0; |
397 | } | 409 | } |
398 | } | 410 | } |
399 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { | 411 | OEffectiveEvent& OEffectiveEvent::operator=( const OEffectiveEvent& ev ) { |
400 | if ( *this == ev ) return *this; | 412 | if ( *this == ev ) return *this; |
401 | 413 | ||
402 | ev.data->ref(); | 414 | ev.data->ref(); |
403 | deref(); | 415 | deref(); |
404 | data = ev.data; | 416 | data = ev.data; |
405 | 417 | ||
406 | return *this; | 418 | return *this; |
407 | } | 419 | } |
408 | 420 | ||
409 | void OEffectiveEvent::setStartTime( const QTime& ti) { | 421 | void OEffectiveEvent::setStartTime( const QTime& ti) { |
410 | changeOrModify(); | 422 | changeOrModify(); |
411 | data->start = ti; | 423 | data->start = ti; |
412 | } | 424 | } |
413 | void OEffectiveEvent::setEndTime( const QTime& en) { | 425 | void OEffectiveEvent::setEndTime( const QTime& en) { |
414 | changeOrModify(); | 426 | changeOrModify(); |
415 | data->end = en; | 427 | data->end = en; |
416 | } | 428 | } |
417 | void OEffectiveEvent::setEvent( const OEvent& ev) { | 429 | void OEffectiveEvent::setEvent( const OEvent& ev) { |
418 | changeOrModify(); | 430 | changeOrModify(); |
419 | data->event = ev; | 431 | data->event = ev; |
420 | } | 432 | } |
421 | void OEffectiveEvent::setDate( const QDate& da) { | 433 | void OEffectiveEvent::setDate( const QDate& da) { |
422 | changeOrModify(); | 434 | changeOrModify(); |
423 | data->date = da; | 435 | data->date = da; |
424 | } | 436 | } |
425 | void OEffectiveEvent::setEffectiveDates( const QDate& from, | 437 | void OEffectiveEvent::setEffectiveDates( const QDate& from, |
426 | const QDate& to ) { | 438 | const QDate& to ) { |
427 | if (!from.isValid() ) { | 439 | if (!from.isValid() ) { |
428 | data->dates = false; | 440 | data->dates = false; |
429 | return; | 441 | return; |
430 | } | 442 | } |
431 | 443 | ||
432 | data->startDate = from; | 444 | data->startDate = from; |
433 | data->endDate = to; | 445 | data->endDate = to; |
434 | } | 446 | } |
435 | QString OEffectiveEvent::description()const { | 447 | QString OEffectiveEvent::description()const { |
436 | return data->event.description(); | 448 | return data->event.description(); |
437 | } | 449 | } |
438 | QString OEffectiveEvent::location()const { | 450 | QString OEffectiveEvent::location()const { |
439 | return data->event.location(); | 451 | return data->event.location(); |
440 | } | 452 | } |
441 | QString OEffectiveEvent::note()const { | 453 | QString OEffectiveEvent::note()const { |
442 | return data->event.note(); | 454 | return data->event.note(); |
443 | } | 455 | } |
444 | OEvent OEffectiveEvent::event()const { | 456 | OEvent OEffectiveEvent::event()const { |
445 | return data->event; | 457 | return data->event; |