summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/event.cpp1
-rw-r--r--libkcal/icalformatimpl.cpp10
-rw-r--r--libkcal/incidence.cpp53
-rw-r--r--libkcal/incidence.h5
-rw-r--r--libkcal/kincidenceformatter.cpp4
-rw-r--r--libkcal/vcalformat.cpp4
-rw-r--r--libkcal/vcalformat.h2
7 files changed, 55 insertions, 24 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index ad66639..0766fd9 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -128,96 +128,97 @@ QString Event::dtEndTimeStr() const
128 return KGlobal::locale()->formatTime(mDtEnd.time()); 128 return KGlobal::locale()->formatTime(mDtEnd.time());
129} 129}
130 130
131QString Event::dtEndDateStr(bool shortfmt) const 131QString Event::dtEndDateStr(bool shortfmt) const
132{ 132{
133 return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt); 133 return KGlobal::locale()->formatDate(mDtEnd.date(),shortfmt);
134} 134}
135 135
136QString Event::dtEndStr(bool shortfmt) const 136QString Event::dtEndStr(bool shortfmt) const
137{ 137{
138 return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt); 138 return KGlobal::locale()->formatDateTime(mDtEnd, shortfmt);
139} 139}
140 140
141void Event::setHasEndDate(bool b) 141void Event::setHasEndDate(bool b)
142{ 142{
143 mHasEndDate = b; 143 mHasEndDate = b;
144} 144}
145 145
146bool Event::hasEndDate() const 146bool Event::hasEndDate() const
147{ 147{
148 return mHasEndDate; 148 return mHasEndDate;
149} 149}
150 150
151bool Event::isMultiDay() const 151bool Event::isMultiDay() const
152{ 152{
153 bool multi = !(dtStart().date() == dtEnd().date()); 153 bool multi = !(dtStart().date() == dtEnd().date());
154 return multi; 154 return multi;
155} 155}
156 156
157void Event::setTransparency(Event::Transparency transparency) 157void Event::setTransparency(Event::Transparency transparency)
158{ 158{
159 if (mReadOnly) return; 159 if (mReadOnly) return;
160 mTransparency = transparency; 160 mTransparency = transparency;
161 updated(); 161 updated();
162} 162}
163 163
164Event::Transparency Event::transparency() const 164Event::Transparency Event::transparency() const
165{ 165{
166 return mTransparency; 166 return mTransparency;
167} 167}
168 168
169void Event::setDuration(int seconds) 169void Event::setDuration(int seconds)
170{ 170{
171 setHasEndDate(false); 171 setHasEndDate(false);
172 Incidence::setDuration(seconds); 172 Incidence::setDuration(seconds);
173} 173}
174bool Event::matchTime(QDateTime*startDT, QDateTime* endDT) 174bool Event::matchTime(QDateTime*startDT, QDateTime* endDT)
175{ 175{
176 if ( cancelled() ) return false;
176 if ( ! doesRecur() ) { 177 if ( ! doesRecur() ) {
177 if ( doesFloat() ) { 178 if ( doesFloat() ) {
178 if ( mDtEnd.addDays( 1 ) < *startDT) 179 if ( mDtEnd.addDays( 1 ) < *startDT)
179 return false; 180 return false;
180 if ( endDT && mDtStart > * endDT) 181 if ( endDT && mDtStart > * endDT)
181 return false; 182 return false;
182 } else { 183 } else {
183 if ( mDtEnd < *startDT ) 184 if ( mDtEnd < *startDT )
184 return false; 185 return false;
185 if ( endDT && mDtStart > * endDT) 186 if ( endDT && mDtStart > * endDT)
186 return false; 187 return false;
187 } 188 }
188 } else { 189 } else {
189 if ( endDT && mDtStart > * endDT) 190 if ( endDT && mDtStart > * endDT)
190 return false; 191 return false;
191 } 192 }
192 return true; 193 return true;
193} 194}
194bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) 195bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT )
195{ 196{
196 if ( testEvent == this ) 197 if ( testEvent == this )
197 return false; 198 return false;
198 if ( ! doesRecur() && !testEvent->doesRecur() ) { 199 if ( ! doesRecur() && !testEvent->doesRecur() ) {
199 QDateTime te; 200 QDateTime te;
200 if ( testEvent->doesFloat() ) 201 if ( testEvent->doesFloat() )
201 te = testEvent->mDtEnd.addDays( 1 ); 202 te = testEvent->mDtEnd.addDays( 1 );
202 else 203 else
203 te = testEvent->mDtEnd; 204 te = testEvent->mDtEnd;
204 QDateTime e; 205 QDateTime e;
205 if ( doesFloat() ) 206 if ( doesFloat() )
206 e = mDtEnd.addDays( 1 ); 207 e = mDtEnd.addDays( 1 );
207 else 208 else
208 e = mDtEnd; 209 e = mDtEnd;
209 if ( mDtStart < te && testEvent->mDtStart < e ) { 210 if ( mDtStart < te && testEvent->mDtStart < e ) {
210 if ( mDtStart < testEvent->mDtStart ) 211 if ( mDtStart < testEvent->mDtStart )
211 *overlapDT = testEvent->mDtStart; 212 *overlapDT = testEvent->mDtStart;
212 else 213 else
213 *overlapDT = mDtStart; 214 *overlapDT = mDtStart;
214 if ( startDT ) 215 if ( startDT )
215 return (*overlapDT >= *startDT ); 216 return (*overlapDT >= *startDT );
216 return true; 217 return true;
217 } 218 }
218 return false; 219 return false;
219 } 220 }
220 if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) { 221 if ( !doesFloat() && !testEvent->doesFloat() && !isMultiDay() && !testEvent->isMultiDay() ) {
221 if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) { 222 if ( mDtStart.time() >= testEvent->mDtEnd.time() || testEvent->mDtStart.time() >= mDtEnd.time() ) {
222 // no need to test. times mismatch 223 // no need to test. times mismatch
223 //fprintf(stderr,"timi "); 224 //fprintf(stderr,"timi ");
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 4794bc9..f349681 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -327,109 +327,106 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
327 break; 327 break;
328 } 328 }
329 icalcomponent_add_property(parent,icalproperty_new_class(classInt)); 329 icalcomponent_add_property(parent,icalproperty_new_class(classInt));
330 330
331 // priority 331 // priority
332 icalcomponent_add_property(parent,icalproperty_new_priority( 332 icalcomponent_add_property(parent,icalproperty_new_priority(
333 incidence->priority())); 333 incidence->priority()));
334 334
335 // categories 335 // categories
336 QStringList categories = incidence->categories(); 336 QStringList categories = incidence->categories();
337 QStringList::Iterator it; 337 QStringList::Iterator it;
338 for(it = categories.begin(); it != categories.end(); ++it ) { 338 for(it = categories.begin(); it != categories.end(); ++it ) {
339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8())); 339 icalcomponent_add_property(parent,icalproperty_new_categories((*it).utf8()));
340 } 340 }
341// TODO: Ensure correct concatenation of categories properties. 341// TODO: Ensure correct concatenation of categories properties.
342 342
343/* 343/*
344 // categories 344 // categories
345 tmpStrList = incidence->getCategories(); 345 tmpStrList = incidence->getCategories();
346 tmpStr = ""; 346 tmpStr = "";
347 QString catStr; 347 QString catStr;
348 for ( QStringList::Iterator it = tmpStrList.begin(); 348 for ( QStringList::Iterator it = tmpStrList.begin();
349 it != tmpStrList.end(); 349 it != tmpStrList.end();
350 ++it ) { 350 ++it ) {
351 catStr = *it; 351 catStr = *it;
352 if (catStr[0] == ' ') 352 if (catStr[0] == ' ')
353 tmpStr += catStr.mid(1); 353 tmpStr += catStr.mid(1);
354 else 354 else
355 tmpStr += catStr; 355 tmpStr += catStr;
356 // this must be a ';' character as the vCalendar specification requires! 356 // this must be a ';' character as the vCalendar specification requires!
357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 357 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
358 // read in. 358 // read in.
359 tmpStr += ";"; 359 tmpStr += ";";
360 } 360 }
361 if (!tmpStr.isEmpty()) { 361 if (!tmpStr.isEmpty()) {
362 tmpStr.truncate(tmpStr.length()-1); 362 tmpStr.truncate(tmpStr.length()-1);
363 icalcomponent_add_property(parent,icalproperty_new_categories( 363 icalcomponent_add_property(parent,icalproperty_new_categories(
364 writeText(incidence->getCategories().join(";")))); 364 writeText(incidence->getCategories().join(";"))));
365 } 365 }
366*/ 366*/
367 367
368 // related event 368 // related event
369 if (!incidence->relatedToUid().isEmpty()) { 369 if (!incidence->relatedToUid().isEmpty()) {
370 icalcomponent_add_property(parent,icalproperty_new_relatedto( 370 icalcomponent_add_property(parent,icalproperty_new_relatedto(
371 incidence->relatedToUid().utf8())); 371 incidence->relatedToUid().utf8()));
372 } 372 }
373 373
374 // recurrence rule stuff 374 // recurrence rule stuff
375 Recurrence *recur = incidence->recurrence(); 375 if (incidence->doesRecur()) {
376 if (recur->doesRecur()) { 376 icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence()));
377
378 icalcomponent_add_property(parent,writeRecurrenceRule(recur));
379 }
380
381 // recurrence excpetion dates 377 // recurrence excpetion dates
382 DateList dateList = incidence->exDates(); 378 DateList dateList = incidence->exDates();
383 DateList::ConstIterator exIt; 379 DateList::ConstIterator exIt;
384 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 380 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
385 icalcomponent_add_property(parent,icalproperty_new_exdate( 381 icalcomponent_add_property(parent,icalproperty_new_exdate(
386 writeICalDate(*exIt))); 382 writeICalDate(*exIt)));
387 } 383 }
384 }
388 385
389 // attachments 386 // attachments
390 QPtrList<Attachment> attachments = incidence->attachments(); 387 QPtrList<Attachment> attachments = incidence->attachments();
391 for (Attachment *at = attachments.first(); at; at = attachments.next()) 388 for (Attachment *at = attachments.first(); at; at = attachments.next())
392 icalcomponent_add_property(parent,writeAttachment(at)); 389 icalcomponent_add_property(parent,writeAttachment(at));
393 390
394 // alarms 391 // alarms
395 QPtrList<Alarm> alarms = incidence->alarms(); 392 QPtrList<Alarm> alarms = incidence->alarms();
396 Alarm* alarm; 393 Alarm* alarm;
397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 394 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
398 if (alarm->enabled()) { 395 if (alarm->enabled()) {
399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 396 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
400 icalcomponent_add_component(parent,writeAlarm(alarm)); 397 icalcomponent_add_component(parent,writeAlarm(alarm));
401 } 398 }
402 } 399 }
403 if( incidence->hasRecurrenceID() ) { 400 if( incidence->hasRecurrenceID() ) {
404 icalcomponent_add_property(parent, 401 icalcomponent_add_property(parent,
405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); 402 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID())));
406 } 403 }
407 // duration 404 // duration
408 405
409// turned off as it always is set to PTS0 (and must not occur together with DTEND 406// turned off as it always is set to PTS0 (and must not occur together with DTEND
410 407
411 if (incidence->hasDuration()) { 408 if (incidence->hasDuration()) {
412 icaldurationtype duration; 409 icaldurationtype duration;
413 duration = writeICalDuration(incidence->duration()); 410 duration = writeICalDuration(incidence->duration());
414 icalcomponent_add_property(parent,icalproperty_new_duration(duration)); 411 icalcomponent_add_property(parent,icalproperty_new_duration(duration));
415 } 412 }
416} 413}
417 414
418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 415void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
419{ 416{
420 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 417 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
421 writeICalDateTime(QDateTime::currentDateTime()))); 418 writeICalDateTime(QDateTime::currentDateTime())));
422 419
423 // organizer stuff 420 // organizer stuff
424 icalcomponent_add_property(parent,icalproperty_new_organizer( 421 icalcomponent_add_property(parent,icalproperty_new_organizer(
425 ("MAILTO:" + incidenceBase->organizer()).utf8())); 422 ("MAILTO:" + incidenceBase->organizer()).utf8()));
426 423
427 // attendees 424 // attendees
428 if (incidenceBase->attendeeCount() != 0) { 425 if (incidenceBase->attendeeCount() != 0) {
429 QPtrList<Attendee> al = incidenceBase->attendees(); 426 QPtrList<Attendee> al = incidenceBase->attendees();
430 QPtrListIterator<Attendee> ai(al); 427 QPtrListIterator<Attendee> ai(al);
431 for (; ai.current(); ++ai) { 428 for (; ai.current(); ++ai) {
432 icalcomponent_add_property(parent,writeAttendee(ai.current())); 429 icalcomponent_add_property(parent,writeAttendee(ai.current()));
433 } 430 }
434 } 431 }
435 432
@@ -1250,96 +1247,97 @@ void ICalFormatImpl::readIncidence(icalcomponent *parent,Incidence *incidence)
1250 incidence->addExDate(readICalDate(icaltime)); 1247 incidence->addExDate(readICalDate(icaltime));
1251 break; 1248 break;
1252 1249
1253 case ICAL_CLASS_PROPERTY: { 1250 case ICAL_CLASS_PROPERTY: {
1254 int inttext = icalproperty_get_class(p); 1251 int inttext = icalproperty_get_class(p);
1255 if (inttext == ICAL_CLASS_PUBLIC ) { 1252 if (inttext == ICAL_CLASS_PUBLIC ) {
1256 incidence->setSecrecy(Incidence::SecrecyPublic); 1253 incidence->setSecrecy(Incidence::SecrecyPublic);
1257 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) { 1254 } else if (inttext == ICAL_CLASS_CONFIDENTIAL ) {
1258 incidence->setSecrecy(Incidence::SecrecyConfidential); 1255 incidence->setSecrecy(Incidence::SecrecyConfidential);
1259 } else { 1256 } else {
1260 incidence->setSecrecy(Incidence::SecrecyPrivate); 1257 incidence->setSecrecy(Incidence::SecrecyPrivate);
1261 } 1258 }
1262 } 1259 }
1263 break; 1260 break;
1264 1261
1265 case ICAL_ATTACH_PROPERTY: // attachments 1262 case ICAL_ATTACH_PROPERTY: // attachments
1266 incidence->addAttachment(readAttachment(p)); 1263 incidence->addAttachment(readAttachment(p));
1267 break; 1264 break;
1268 1265
1269 default: 1266 default:
1270// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind 1267// kdDebug(5800) << "ICALFormat::readIncidence(): Unknown property: " << kind
1271// << endl; 1268// << endl;
1272 break; 1269 break;
1273 } 1270 }
1274 1271
1275 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1272 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1276 } 1273 }
1277 if ( readrec ) { 1274 if ( readrec ) {
1278 readRecurrenceRule(rectype,incidence); 1275 readRecurrenceRule(rectype,incidence);
1279 } 1276 }
1280 // kpilot stuff 1277 // kpilot stuff
1281// TODO: move this application-specific code to kpilot 1278// TODO: move this application-specific code to kpilot
1282 QString kp = incidence->nonKDECustomProperty("X-PILOTID"); 1279 QString kp = incidence->nonKDECustomProperty("X-PILOTID");
1283 if (!kp.isNull()) { 1280 if (!kp.isNull()) {
1284 incidence->setPilotId(kp.toInt()); 1281 incidence->setPilotId(kp.toInt());
1285 } 1282 }
1286 kp = incidence->nonKDECustomProperty("X-PILOTSTAT"); 1283 kp = incidence->nonKDECustomProperty("X-PILOTSTAT");
1287 if (!kp.isNull()) { 1284 if (!kp.isNull()) {
1288 incidence->setSyncStatus(kp.toInt()); 1285 incidence->setSyncStatus(kp.toInt());
1289 } 1286 }
1290 1287
1291 1288
1292 kp = incidence->nonKDECustomProperty("X-KOPIEXTID"); 1289 kp = incidence->nonKDECustomProperty("X-KOPIEXTID");
1293 if (!kp.isNull()) { 1290 if (!kp.isNull()) {
1294 incidence->setIDStr(kp); 1291 incidence->setIDStr(kp);
1295 } 1292 }
1296 1293
1297 // Cancel backwards compatibility mode for subsequent changes by the application 1294 // Cancel backwards compatibility mode for subsequent changes by the application
1295 if ( readrec )
1298 incidence->recurrence()->setCompatVersion(); 1296 incidence->recurrence()->setCompatVersion();
1299 1297
1300 // add categories 1298 // add categories
1301 incidence->setCategories(categories); 1299 incidence->setCategories(categories);
1302 1300
1303 // iterate through all alarms 1301 // iterate through all alarms
1304 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT); 1302 for (icalcomponent *alarm = icalcomponent_get_first_component(parent,ICAL_VALARM_COMPONENT);
1305 alarm; 1303 alarm;
1306 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) { 1304 alarm = icalcomponent_get_next_component(parent,ICAL_VALARM_COMPONENT)) {
1307 readAlarm(alarm,incidence); 1305 readAlarm(alarm,incidence);
1308 } 1306 }
1309} 1307}
1310 1308
1311void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 1309void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
1312{ 1310{
1313 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY); 1311 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_ANY_PROPERTY);
1314 1312
1315 while (p) { 1313 while (p) {
1316 icalproperty_kind kind = icalproperty_isa(p); 1314 icalproperty_kind kind = icalproperty_isa(p);
1317 switch (kind) { 1315 switch (kind) {
1318 1316
1319 case ICAL_UID_PROPERTY: // unique id 1317 case ICAL_UID_PROPERTY: // unique id
1320 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p))); 1318 incidenceBase->setUid(QString::fromUtf8(icalproperty_get_uid(p)));
1321 break; 1319 break;
1322 1320
1323 case ICAL_ORGANIZER_PROPERTY: // organizer 1321 case ICAL_ORGANIZER_PROPERTY: // organizer
1324 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p))); 1322 incidenceBase->setOrganizer(QString::fromUtf8(icalproperty_get_organizer(p)));
1325 break; 1323 break;
1326 1324
1327 case ICAL_ATTENDEE_PROPERTY: // attendee 1325 case ICAL_ATTENDEE_PROPERTY: // attendee
1328 incidenceBase->addAttendee(readAttendee(p)); 1326 incidenceBase->addAttendee(readAttendee(p));
1329 break; 1327 break;
1330 1328
1331 default: 1329 default:
1332 break; 1330 break;
1333 } 1331 }
1334 1332
1335 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1333 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1336 } 1334 }
1337 1335
1338 // custom properties 1336 // custom properties
1339 readCustomProperties(parent, incidenceBase); 1337 readCustomProperties(parent, incidenceBase);
1340} 1338}
1341 1339
1342void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1340void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1343{ 1341{
1344 QMap<QCString, QString> customProperties; 1342 QMap<QCString, QString> customProperties;
1345 1343
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index e4bcc5e..4643a3a 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -1,143 +1,147 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#include "incidence.h" 27#include "incidence.h"
28#include "todo.h" 28#include "todo.h"
29 29
30using namespace KCal; 30using namespace KCal;
31 31
32Incidence::Incidence() : 32Incidence::Incidence() :
33 IncidenceBase(), 33 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 35{
36 mRecurrence = new Recurrence(this); 36 mRecurrence = 0;//new Recurrence(this);
37 mCancelled = false; 37 mCancelled = false;
38 recreate(); 38 recreate();
39 mHasStartDate = true; 39 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 40 mAlarms.setAutoDelete(true);
41 mAttachments.setAutoDelete(true); 41 mAttachments.setAutoDelete(true);
42 mHasRecurrenceID = false; 42 mHasRecurrenceID = false;
43 mHoliday = false; 43 mHoliday = false;
44 mBirthday = false; 44 mBirthday = false;
45 mAnniversary = false; 45 mAnniversary = false;
46 46
47} 47}
48 48
49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) 49Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
50{ 50{
51// TODO: reenable attributes currently commented out. 51// TODO: reenable attributes currently commented out.
52 mRevision = i.mRevision; 52 mRevision = i.mRevision;
53 mCreated = i.mCreated; 53 mCreated = i.mCreated;
54 mDescription = i.mDescription; 54 mDescription = i.mDescription;
55 mSummary = i.mSummary; 55 mSummary = i.mSummary;
56 mCategories = i.mCategories; 56 mCategories = i.mCategories;
57// Incidence *mRelatedTo; Incidence *mRelatedTo; 57// Incidence *mRelatedTo; Incidence *mRelatedTo;
58 mRelatedTo = 0; 58 mRelatedTo = 0;
59 mRelatedToUid = i.mRelatedToUid; 59 mRelatedToUid = i.mRelatedToUid;
60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
61 mExDates = i.mExDates; 61 mExDates = i.mExDates;
62 mAttachments = i.mAttachments; 62 mAttachments = i.mAttachments;
63 mResources = i.mResources; 63 mResources = i.mResources;
64 mSecrecy = i.mSecrecy; 64 mSecrecy = i.mSecrecy;
65 mPriority = i.mPriority; 65 mPriority = i.mPriority;
66 mLocation = i.mLocation; 66 mLocation = i.mLocation;
67 mCancelled = i.mCancelled; 67 mCancelled = i.mCancelled;
68 mHasStartDate = i.mHasStartDate; 68 mHasStartDate = i.mHasStartDate;
69 QPtrListIterator<Alarm> it( i.mAlarms ); 69 QPtrListIterator<Alarm> it( i.mAlarms );
70 const Alarm *a; 70 const Alarm *a;
71 while( (a = it.current()) ) { 71 while( (a = it.current()) ) {
72 Alarm *b = new Alarm( *a ); 72 Alarm *b = new Alarm( *a );
73 b->setParent( this ); 73 b->setParent( this );
74 mAlarms.append( b ); 74 mAlarms.append( b );
75 75
76 ++it; 76 ++it;
77 } 77 }
78 mAlarms.setAutoDelete(true); 78 mAlarms.setAutoDelete(true);
79 mHasRecurrenceID = i.mHasRecurrenceID; 79 mHasRecurrenceID = i.mHasRecurrenceID;
80 mRecurrenceID = i.mRecurrenceID; 80 mRecurrenceID = i.mRecurrenceID;
81 if ( i.mRecurrence )
81 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 82 mRecurrence = new Recurrence( *(i.mRecurrence), this );
83 else
84 mRecurrence = 0;
82 mHoliday = i.mHoliday ; 85 mHoliday = i.mHoliday ;
83 mBirthday = i.mBirthday; 86 mBirthday = i.mBirthday;
84 mAnniversary = i.mAnniversary; 87 mAnniversary = i.mAnniversary;
85} 88}
86 89
87Incidence::~Incidence() 90Incidence::~Incidence()
88{ 91{
89 92
90 Incidence *ev; 93 Incidence *ev;
91 QPtrList<Incidence> Relations = relations(); 94 QPtrList<Incidence> Relations = relations();
92 for (ev=Relations.first();ev;ev=Relations.next()) { 95 for (ev=Relations.first();ev;ev=Relations.next()) {
93 if (ev->relatedTo() == this) ev->setRelatedTo(0); 96 if (ev->relatedTo() == this) ev->setRelatedTo(0);
94 } 97 }
95 if (relatedTo()) relatedTo()->removeRelation(this); 98 if (relatedTo()) relatedTo()->removeRelation(this);
99 if ( mRecurrence )
96 delete mRecurrence; 100 delete mRecurrence;
97 101
98} 102}
99 103
100bool Incidence::isHoliday() const 104bool Incidence::isHoliday() const
101{ 105{
102 return mHoliday; 106 return mHoliday;
103} 107}
104bool Incidence::isBirthday() const 108bool Incidence::isBirthday() const
105{ 109{
106 110
107 return mBirthday ; 111 return mBirthday ;
108} 112}
109bool Incidence::isAnniversary() const 113bool Incidence::isAnniversary() const
110{ 114{
111 return mAnniversary ; 115 return mAnniversary ;
112 116
113} 117}
114 118
115bool Incidence::hasRecurrenceID() const 119bool Incidence::hasRecurrenceID() const
116{ 120{
117 return mHasRecurrenceID; 121 return mHasRecurrenceID;
118} 122}
119 123
120void Incidence::setHasRecurrenceID( bool b ) 124void Incidence::setHasRecurrenceID( bool b )
121{ 125{
122 mHasRecurrenceID = b; 126 mHasRecurrenceID = b;
123} 127}
124 128
125void Incidence::setRecurrenceID(QDateTime d) 129void Incidence::setRecurrenceID(QDateTime d)
126{ 130{
127 mRecurrenceID = d; 131 mRecurrenceID = d;
128 mHasRecurrenceID = true; 132 mHasRecurrenceID = true;
129 updated(); 133 updated();
130} 134}
131QDateTime Incidence::recurrenceID () const 135QDateTime Incidence::recurrenceID () const
132{ 136{
133 return mRecurrenceID; 137 return mRecurrenceID;
134} 138}
135 139
136bool Incidence::cancelled() const 140bool Incidence::cancelled() const
137{ 141{
138 return mCancelled; 142 return mCancelled;
139} 143}
140void Incidence::setCancelled( bool b ) 144void Incidence::setCancelled( bool b )
141{ 145{
142 mCancelled = b; 146 mCancelled = b;
143 updated(); 147 updated();
@@ -163,219 +167,236 @@ static bool stringCompare( const QString& s1, const QString& s2 )
163} 167}
164 168
165bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 169bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
166{ 170{
167 171
168 if( i1.alarms().count() != i2.alarms().count() ) { 172 if( i1.alarms().count() != i2.alarms().count() ) {
169 return false; // no need to check further 173 return false; // no need to check further
170 } 174 }
171 if ( i1.alarms().count() > 0 ) { 175 if ( i1.alarms().count() > 0 ) {
172 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 176 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
173 { 177 {
174 qDebug("alarm not equal "); 178 qDebug("alarm not equal ");
175 return false; 179 return false;
176 } 180 }
177 } 181 }
178#if 0 182#if 0
179 QPtrListIterator<Alarm> a1( i1.alarms() ); 183 QPtrListIterator<Alarm> a1( i1.alarms() );
180 QPtrListIterator<Alarm> a2( i2.alarms() ); 184 QPtrListIterator<Alarm> a2( i2.alarms() );
181 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 185 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
182 if( *a1.current() == *a2.current() ) { 186 if( *a1.current() == *a2.current() ) {
183 continue; 187 continue;
184 } 188 }
185 else { 189 else {
186 return false; 190 return false;
187 } 191 }
188 } 192 }
189#endif 193#endif
190 194
191 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 195 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
192 if ( i1.hasRecurrenceID() ) { 196 if ( i1.hasRecurrenceID() ) {
193 if ( i1.recurrenceID() != i2.recurrenceID() ) 197 if ( i1.recurrenceID() != i2.recurrenceID() )
194 return false; 198 return false;
195 } 199 }
196 200
197 } else { 201 } else {
198 return false; 202 return false;
199 } 203 }
200 204
201 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 205 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
202 return false; 206 return false;
203 if ( i1.hasStartDate() == i2.hasStartDate() ) { 207 if ( i1.hasStartDate() == i2.hasStartDate() ) {
204 if ( i1.hasStartDate() ) { 208 if ( i1.hasStartDate() ) {
205 if ( i1.dtStart() != i2.dtStart() ) 209 if ( i1.dtStart() != i2.dtStart() )
206 return false; 210 return false;
207 } 211 }
208 } else { 212 } else {
209 return false; 213 return false;
210 } 214 }
211 if (!( *i1.recurrence() == *i2.recurrence()) ) { 215 if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) {
212 qDebug("recurrence is NOT equal "); 216 if (!( *i1.mRecurrence == *i2.mRecurrence) ) {
217 //qDebug("recurrence is NOT equal ");
218 return false;
219 }
220 } else {
221 // one ( or both ) recurrence is 0
222 if ( i1.mRecurrence == 0 ) {
223 if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone )
224 return false;
225 } else {
226 // i1.mRecurrence != 0
227 // i2.mRecurrence == 0
228 if ( i1.mRecurrence->doesRecur() != Recurrence::rNone )
213 return false; 229 return false;
214 } 230 }
231 }
232
215 return 233 return
216 // i1.created() == i2.created() && 234 // i1.created() == i2.created() &&
217 stringCompare( i1.description(), i2.description() ) && 235 stringCompare( i1.description(), i2.description() ) &&
218 stringCompare( i1.summary(), i2.summary() ) && 236 stringCompare( i1.summary(), i2.summary() ) &&
219 i1.categories() == i2.categories() && 237 i1.categories() == i2.categories() &&
220 // no need to compare mRelatedTo 238 // no need to compare mRelatedTo
221 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 239 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
222 // i1.relations() == i2.relations() && 240 // i1.relations() == i2.relations() &&
223 i1.exDates() == i2.exDates() && 241 i1.exDates() == i2.exDates() &&
224 i1.attachments() == i2.attachments() && 242 i1.attachments() == i2.attachments() &&
225 i1.resources() == i2.resources() && 243 i1.resources() == i2.resources() &&
226 i1.secrecy() == i2.secrecy() && 244 i1.secrecy() == i2.secrecy() &&
227 i1.priority() == i2.priority() && 245 i1.priority() == i2.priority() &&
228 i1.cancelled() == i2.cancelled() && 246 i1.cancelled() == i2.cancelled() &&
229 stringCompare( i1.location(), i2.location() ); 247 stringCompare( i1.location(), i2.location() );
230} 248}
231 249
232Incidence* Incidence::recreateCloneException( QDate d ) 250Incidence* Incidence::recreateCloneException( QDate d )
233{ 251{
234 Incidence* newInc = clone(); 252 Incidence* newInc = clone();
235 newInc->recreate(); 253 newInc->recreate();
236 if ( doesRecur() ) { 254 if ( doesRecur() ) {
237 addExDate( d ); 255 addExDate( d );
238 newInc->recurrence()->unsetRecurs(); 256 newInc->recurrence()->unsetRecurs();
239 if ( typeID() == eventID ) { 257 if ( typeID() == eventID ) {
240 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 258 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
241 QTime tim = dtStart().time(); 259 QTime tim = dtStart().time();
242 newInc->setDtStart( QDateTime(d, tim) ); 260 newInc->setDtStart( QDateTime(d, tim) );
243 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 261 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
244 } else { 262 } else {
245 int len = dtStart().secsTo( ((Todo*)this)->dtDue()); 263 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
246 QTime tim = ((Todo*)this)->dtDue().time(); 264 QTime tim = ((Todo*)this)->dtDue().time();
247 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); 265 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
248 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); 266 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
249 ((Todo*)this)->setRecurDates(); 267 ((Todo*)this)->setRecurDates();
250 } 268 }
251 newInc->setExDates( DateList () ); 269 newInc->setExDates( DateList () );
252 } 270 }
253 return newInc; 271 return newInc;
254} 272}
255 273
256void Incidence::recreate() 274void Incidence::recreate()
257{ 275{
258 setCreated(QDateTime::currentDateTime()); 276 setCreated(QDateTime::currentDateTime());
259 277
260 setUid(CalFormat::createUniqueId()); 278 setUid(CalFormat::createUniqueId());
261 279
262 setRevision(0); 280 setRevision(0);
263 setIDStr( ":" ); 281 setIDStr( ":" );
264 setLastModified(QDateTime::currentDateTime()); 282 setLastModified(QDateTime::currentDateTime());
265} 283}
266void Incidence::cloneRelations( Incidence * newInc ) 284void Incidence::cloneRelations( Incidence * newInc )
267{ 285{
268 // newInc is already a clone of this incidence 286 // newInc is already a clone of this incidence
269 Incidence * inc; 287 Incidence * inc;
270 Incidence * cloneInc; 288 Incidence * cloneInc;
271 QPtrList<Incidence> Relations = relations(); 289 QPtrList<Incidence> Relations = relations();
272 for (inc=Relations.first();inc;inc=Relations.next()) { 290 for (inc=Relations.first();inc;inc=Relations.next()) {
273 cloneInc = inc->clone(); 291 cloneInc = inc->clone();
274 cloneInc->recreate(); 292 cloneInc->recreate();
275 cloneInc->setRelatedTo( newInc ); 293 cloneInc->setRelatedTo( newInc );
276 inc->cloneRelations( cloneInc ); 294 inc->cloneRelations( cloneInc );
277 } 295 }
278} 296}
279void Incidence::setReadOnly( bool readOnly ) 297void Incidence::setReadOnly( bool readOnly )
280{ 298{
281 IncidenceBase::setReadOnly( readOnly ); 299 IncidenceBase::setReadOnly( readOnly );
282 recurrence()->setRecurReadOnly( readOnly); 300 if ( mRecurrence )
301 mRecurrence->setRecurReadOnly( readOnly);
283} 302}
284void Incidence::setLastModifiedSubInvalid() 303void Incidence::setLastModifiedSubInvalid()
285{ 304{
286 mLastModifiedSub = QDateTime(); 305 mLastModifiedSub = QDateTime();
287 if ( mRelatedTo ) 306 if ( mRelatedTo )
288 mRelatedTo->setLastModifiedSubInvalid(); 307 mRelatedTo->setLastModifiedSubInvalid();
289} 308}
290QDateTime Incidence::lastModifiedSub() 309QDateTime Incidence::lastModifiedSub()
291{ 310{
292 if ( !mRelations.count() ) 311 if ( !mRelations.count() )
293 return lastModified(); 312 return lastModified();
294 if ( mLastModifiedSub.isValid() ) 313 if ( mLastModifiedSub.isValid() )
295 return mLastModifiedSub; 314 return mLastModifiedSub;
296 mLastModifiedSub = lastModified(); 315 mLastModifiedSub = lastModified();
297 Incidence * inc; 316 Incidence * inc;
298 QPtrList<Incidence> Relations = relations(); 317 QPtrList<Incidence> Relations = relations();
299 for (inc=Relations.first();inc;inc=Relations.next()) { 318 for (inc=Relations.first();inc;inc=Relations.next()) {
300 if ( inc->lastModifiedSub() > mLastModifiedSub ) 319 if ( inc->lastModifiedSub() > mLastModifiedSub )
301 mLastModifiedSub = inc->lastModifiedSub(); 320 mLastModifiedSub = inc->lastModifiedSub();
302 } 321 }
303 return mLastModifiedSub; 322 return mLastModifiedSub;
304} 323}
305void Incidence::setCreated(QDateTime created) 324void Incidence::setCreated(QDateTime created)
306{ 325{
307 if (mReadOnly) return; 326 if (mReadOnly) return;
308 mCreated = getEvenTime(created); 327 mCreated = getEvenTime(created);
309} 328}
310 329
311QDateTime Incidence::created() const 330QDateTime Incidence::created() const
312{ 331{
313 return mCreated; 332 return mCreated;
314} 333}
315 334
316void Incidence::setRevision(int rev) 335void Incidence::setRevision(int rev)
317{ 336{
318 if (mReadOnly) return; 337 if (mReadOnly) return;
319 mRevision = rev; 338 mRevision = rev;
320 339
321 updated(); 340 updated();
322} 341}
323 342
324int Incidence::revision() const 343int Incidence::revision() const
325{ 344{
326 return mRevision; 345 return mRevision;
327} 346}
328 347
329void Incidence::setDtStart(const QDateTime &dtStart) 348void Incidence::setDtStart(const QDateTime &dtStart)
330{ 349{
331 350
332 QDateTime dt = getEvenTime(dtStart); 351 QDateTime dt = getEvenTime(dtStart);
333 recurrence()->setRecurStart( dt); 352
353 if ( mRecurrence )
354 mRecurrence->setRecurStart( dt);
334 IncidenceBase::setDtStart( dt ); 355 IncidenceBase::setDtStart( dt );
335} 356}
336 357
337void Incidence::setDescription(const QString &description) 358void Incidence::setDescription(const QString &description)
338{ 359{
339 if (mReadOnly) return; 360 if (mReadOnly) return;
340 mDescription = description; 361 mDescription = description;
341 updated(); 362 updated();
342} 363}
343 364
344QString Incidence::description() const 365QString Incidence::description() const
345{ 366{
346 return mDescription; 367 return mDescription;
347} 368}
348 369
349 370
350void Incidence::setSummary(const QString &summary) 371void Incidence::setSummary(const QString &summary)
351{ 372{
352 if (mReadOnly) return; 373 if (mReadOnly) return;
353 mSummary = summary; 374 mSummary = summary;
354 updated(); 375 updated();
355} 376}
356 377
357QString Incidence::summary() const 378QString Incidence::summary() const
358{ 379{
359 return mSummary; 380 return mSummary;
360} 381}
361void Incidence::checkCategories() 382void Incidence::checkCategories()
362{ 383{
363 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); 384 mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday"));
364 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); 385 mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday"));
365 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); 386 mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary"));
366} 387}
367 388
368void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 389void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
369{ 390{
370 if (mReadOnly) return; 391 if (mReadOnly) return;
371 int i; 392 int i;
372 for( i = 0; i < categories.count(); ++i ) { 393 for( i = 0; i < categories.count(); ++i ) {
373 if ( !mCategories.contains (categories[i])) 394 if ( !mCategories.contains (categories[i]))
374 mCategories.append( categories[i] ); 395 mCategories.append( categories[i] );
375 } 396 }
376 checkCategories(); 397 checkCategories();
377 updated(); 398 updated();
378 if ( addToRelations ) { 399 if ( addToRelations ) {
379 Incidence * inc; 400 Incidence * inc;
380 QPtrList<Incidence> Relations = relations(); 401 QPtrList<Incidence> Relations = relations();
381 for (inc=Relations.first();inc;inc=Relations.next()) { 402 for (inc=Relations.first();inc;inc=Relations.next()) {
@@ -459,105 +480,104 @@ void Incidence::setRelatedTo(Incidence *relatedTo)
459 mRelatedTo = relatedTo; 480 mRelatedTo = relatedTo;
460 if (mRelatedTo) { 481 if (mRelatedTo) {
461 mRelatedTo->addRelation(this); 482 mRelatedTo->addRelation(this);
462 mRelatedToUid = mRelatedTo->uid(); 483 mRelatedToUid = mRelatedTo->uid();
463 } else { 484 } else {
464 mRelatedToUid = ""; 485 mRelatedToUid = "";
465 } 486 }
466} 487}
467 488
468Incidence *Incidence::relatedTo() const 489Incidence *Incidence::relatedTo() const
469{ 490{
470 return mRelatedTo; 491 return mRelatedTo;
471} 492}
472 493
473QPtrList<Incidence> Incidence::relations() const 494QPtrList<Incidence> Incidence::relations() const
474{ 495{
475 return mRelations; 496 return mRelations;
476} 497}
477 498
478void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 499void Incidence::addRelationsToList(QPtrList<Incidence> *rel)
479{ 500{
480 Incidence* inc; 501 Incidence* inc;
481 QPtrList<Incidence> Relations = relations(); 502 QPtrList<Incidence> Relations = relations();
482 for (inc=Relations.first();inc;inc=Relations.next()) { 503 for (inc=Relations.first();inc;inc=Relations.next()) {
483 inc->addRelationsToList( rel ); 504 inc->addRelationsToList( rel );
484 } 505 }
485 if ( rel->findRef( this ) == -1 ) 506 if ( rel->findRef( this ) == -1 )
486 rel->append( this ); 507 rel->append( this );
487} 508}
488 509
489void Incidence::addRelation(Incidence *event) 510void Incidence::addRelation(Incidence *event)
490{ 511{
491 setLastModifiedSubInvalid(); 512 setLastModifiedSubInvalid();
492 if( mRelations.findRef( event ) == -1 ) { 513 if( mRelations.findRef( event ) == -1 ) {
493 mRelations.append(event); 514 mRelations.append(event);
494 //updated(); 515 //updated();
495 } 516 }
496} 517}
497 518
498void Incidence::removeRelation(Incidence *event) 519void Incidence::removeRelation(Incidence *event)
499{ 520{
500 setLastModifiedSubInvalid(); 521 setLastModifiedSubInvalid();
501 mRelations.removeRef(event); 522 mRelations.removeRef(event);
502// if (event->getRelatedTo() == this) event->setRelatedTo(0); 523// if (event->getRelatedTo() == this) event->setRelatedTo(0);
503} 524}
504 525
505bool Incidence::recursOn(const QDate &qd) const 526bool Incidence::recursOn(const QDate &qd) const
506{ 527{
507 if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; 528 if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true;
508 else return false; 529 else return false;
509} 530}
510 531
511void Incidence::setExDates(const DateList &exDates) 532void Incidence::setExDates(const DateList &exDates)
512{ 533{
513 if (mReadOnly) return; 534 if (mReadOnly) return;
514 mExDates = exDates; 535 mExDates = exDates;
515
516 recurrence()->setRecurExDatesCount(mExDates.count()); 536 recurrence()->setRecurExDatesCount(mExDates.count());
517 537
518 updated(); 538 updated();
519} 539}
520 540
521void Incidence::addExDate(const QDate &date) 541void Incidence::addExDate(const QDate &date)
522{ 542{
523 if (mReadOnly) return; 543 if (mReadOnly) return;
524 mExDates.append(date); 544 mExDates.append(date);
525 545
526 recurrence()->setRecurExDatesCount(mExDates.count()); 546 recurrence()->setRecurExDatesCount(mExDates.count());
527 547
528 updated(); 548 updated();
529} 549}
530 550
531DateList Incidence::exDates() const 551DateList Incidence::exDates() const
532{ 552{
533 return mExDates; 553 return mExDates;
534} 554}
535 555
536bool Incidence::isException(const QDate &date) const 556bool Incidence::isException(const QDate &date) const
537{ 557{
538 DateList::ConstIterator it; 558 DateList::ConstIterator it;
539 for( it = mExDates.begin(); it != mExDates.end(); ++it ) { 559 for( it = mExDates.begin(); it != mExDates.end(); ++it ) {
540 if ( (*it) == date ) { 560 if ( (*it) == date ) {
541 return true; 561 return true;
542 } 562 }
543 } 563 }
544 564
545 return false; 565 return false;
546} 566}
547 567
548void Incidence::addAttachment(Attachment *attachment) 568void Incidence::addAttachment(Attachment *attachment)
549{ 569{
550 if (mReadOnly || !attachment) return; 570 if (mReadOnly || !attachment) return;
551 mAttachments.append(attachment); 571 mAttachments.append(attachment);
552 updated(); 572 updated();
553} 573}
554 574
555void Incidence::deleteAttachment(Attachment *attachment) 575void Incidence::deleteAttachment(Attachment *attachment)
556{ 576{
557 mAttachments.removeRef(attachment); 577 mAttachments.removeRef(attachment);
558} 578}
559 579
560void Incidence::deleteAttachments(const QString& mime) 580void Incidence::deleteAttachments(const QString& mime)
561{ 581{
562 Attachment *at = mAttachments.first(); 582 Attachment *at = mAttachments.first();
563 while (at) { 583 while (at) {
@@ -653,128 +673,139 @@ QStringList Incidence::secrecyList()
653 list << secrecyName(SecrecyPublic); 673 list << secrecyName(SecrecyPublic);
654 list << secrecyName(SecrecyPrivate); 674 list << secrecyName(SecrecyPrivate);
655 list << secrecyName(SecrecyConfidential); 675 list << secrecyName(SecrecyConfidential);
656 676
657 return list; 677 return list;
658} 678}
659 679
660 680
661QPtrList<Alarm> Incidence::alarms() const 681QPtrList<Alarm> Incidence::alarms() const
662{ 682{
663 return mAlarms; 683 return mAlarms;
664} 684}
665 685
666Alarm* Incidence::newAlarm() 686Alarm* Incidence::newAlarm()
667{ 687{
668 Alarm* alarm = new Alarm(this); 688 Alarm* alarm = new Alarm(this);
669 mAlarms.append(alarm); 689 mAlarms.append(alarm);
670// updated(); 690// updated();
671 return alarm; 691 return alarm;
672} 692}
673 693
674void Incidence::addAlarm(Alarm *alarm) 694void Incidence::addAlarm(Alarm *alarm)
675{ 695{
676 mAlarms.append(alarm); 696 mAlarms.append(alarm);
677 updated(); 697 updated();
678} 698}
679 699
680void Incidence::removeAlarm(Alarm *alarm) 700void Incidence::removeAlarm(Alarm *alarm)
681{ 701{
682 mAlarms.removeRef(alarm); 702 mAlarms.removeRef(alarm);
683 updated(); 703 updated();
684} 704}
685 705
686void Incidence::clearAlarms() 706void Incidence::clearAlarms()
687{ 707{
688 mAlarms.clear(); 708 mAlarms.clear();
689 updated(); 709 updated();
690} 710}
691 711
692bool Incidence::isAlarmEnabled() const 712bool Incidence::isAlarmEnabled() const
693{ 713{
694 Alarm* alarm; 714 Alarm* alarm;
695 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 715 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
696 if (alarm->enabled()) 716 if (alarm->enabled())
697 return true; 717 return true;
698 } 718 }
699 return false; 719 return false;
700} 720}
701 721#include <stdlib.h>
702Recurrence *Incidence::recurrence() const 722Recurrence *Incidence::recurrence()
703{ 723{
724 if ( ! mRecurrence ) {
725 mRecurrence = new Recurrence(this);
726 qDebug("creating new recurence ");
727 //abort();
728 }
704 return mRecurrence; 729 return mRecurrence;
705} 730}
706void Incidence::setRecurrence( Recurrence * r) 731void Incidence::setRecurrence( Recurrence * r)
707{ 732{
733 if ( mRecurrence )
708 delete mRecurrence; 734 delete mRecurrence;
709 mRecurrence = r; 735 mRecurrence = r;
710} 736}
711 737
712void Incidence::setLocation(const QString &location) 738void Incidence::setLocation(const QString &location)
713{ 739{
714 if (mReadOnly) return; 740 if (mReadOnly) return;
715 mLocation = location; 741 mLocation = location;
716 updated(); 742 updated();
717} 743}
718 744
719QString Incidence::location() const 745QString Incidence::location() const
720{ 746{
721 return mLocation; 747 return mLocation;
722} 748}
749QString Incidence::recurrenceText() const
750{
751 if ( mRecurrence ) return mRecurrence->recurrenceText();
752 return i18n("No");
753}
723 754
724ushort Incidence::doesRecur() const 755ushort Incidence::doesRecur() const
725{ 756{
726 if ( mRecurrence ) return mRecurrence->doesRecur(); 757 if ( mRecurrence ) return mRecurrence->doesRecur();
727 else return Recurrence::rNone; 758 else return Recurrence::rNone;
728} 759}
729 760
730QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const 761QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
731{ 762{
732 QDateTime incidenceStart = dt; 763 QDateTime incidenceStart = dt;
733 *ok = false; 764 *ok = false;
734 if ( doesRecur() ) { 765 if ( doesRecur() ) {
735 bool last; 766 bool last;
736 recurrence()->getPreviousDateTime( incidenceStart , &last ); 767 mRecurrence->getPreviousDateTime( incidenceStart , &last );
737 int count = 0; 768 int count = 0;
738 if ( !last ) { 769 if ( !last ) {
739 while ( !last ) { 770 while ( !last ) {
740 ++count; 771 ++count;
741 incidenceStart = recurrence()->getNextDateTime( incidenceStart, &last ); 772 incidenceStart = mRecurrence->getNextDateTime( incidenceStart, &last );
742 if ( recursOn( incidenceStart.date() ) ) { 773 if ( recursOn( incidenceStart.date() ) ) {
743 last = true; // exit while llop 774 last = true; // exit while llop
744 } else { 775 } else {
745 if ( last ) { // no alarm on last recurrence 776 if ( last ) { // no alarm on last recurrence
746 return QDateTime (); 777 return QDateTime ();
747 } 778 }
748 int year = incidenceStart.date().year(); 779 int year = incidenceStart.date().year();
749 // workaround for bug in recurrence 780 // workaround for bug in recurrence
750 if ( count == 100 || year < 1000 || year > 5000 ) { 781 if ( count == 100 || year < 1000 || year > 5000 ) {
751 return QDateTime (); 782 return QDateTime ();
752 } 783 }
753 incidenceStart = incidenceStart.addSecs( 1 ); 784 incidenceStart = incidenceStart.addSecs( 1 );
754 } 785 }
755 } 786 }
756 } else { 787 } else {
757 return QDateTime (); 788 return QDateTime ();
758 } 789 }
759 } else { 790 } else {
760 if ( hasStartDate () ) { 791 if ( hasStartDate () ) {
761 incidenceStart = dtStart(); 792 incidenceStart = dtStart();
762 } 793 }
763 if ( typeID() == todoID ) { 794 if ( typeID() == todoID ) {
764 if ( ((Todo*)this)->hasDueDate() ) 795 if ( ((Todo*)this)->hasDueDate() )
765 incidenceStart = ((Todo*)this)->dtDue(); 796 incidenceStart = ((Todo*)this)->dtDue();
766 } 797 }
767 } 798 }
768 if ( incidenceStart > dt ) 799 if ( incidenceStart > dt )
769 *ok = true; 800 *ok = true;
770 return incidenceStart; 801 return incidenceStart;
771} 802}
772QDateTime Incidence::dtStart() const 803QDateTime Incidence::dtStart() const
773{ 804{
774 if ( doesRecur() ) { 805 if ( doesRecur() ) {
775 if ( typeID() == todoID ) { 806 if ( typeID() == todoID ) {
776 ((Todo*)this)->checkSetCompletedFalse(); 807 ((Todo*)this)->checkSetCompletedFalse();
777 } 808 }
778 } 809 }
779 return mDtStart; 810 return mDtStart;
780} 811}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index d4af9f0..8519f01 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -204,118 +204,119 @@ class Incidence : public IncidenceBase
204 /** find a list of attachments with this mime type */ 204 /** find a list of attachments with this mime type */
205 QPtrList<Attachment> attachments(const QString& mime) const; 205 QPtrList<Attachment> attachments(const QString& mime) const;
206 206
207 /** sets the event's status the value specified. See the enumeration 207 /** sets the event's status the value specified. See the enumeration
208 * above for possible values. */ 208 * above for possible values. */
209 void setSecrecy(int); 209 void setSecrecy(int);
210 /** return the event's secrecy. */ 210 /** return the event's secrecy. */
211 int secrecy() const; 211 int secrecy() const;
212 /** return the event's secrecy in string format. */ 212 /** return the event's secrecy in string format. */
213 QString secrecyStr() const; 213 QString secrecyStr() const;
214 /** return list of all availbale secrecy classes */ 214 /** return list of all availbale secrecy classes */
215 static QStringList secrecyList(); 215 static QStringList secrecyList();
216 /** return human-readable name of secrecy class */ 216 /** return human-readable name of secrecy class */
217 static QString secrecyName(int); 217 static QString secrecyName(int);
218 218
219 /** returns TRUE if the date specified is one on which the event will 219 /** returns TRUE if the date specified is one on which the event will
220 * recur. */ 220 * recur. */
221 bool recursOn(const QDate &qd) const; 221 bool recursOn(const QDate &qd) const;
222 222
223 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?): 223 // VEVENT and VTODO, but not VJOURNAL (move to EventBase class?):
224 224
225 /** set resources used, such as Office, Car, etc. */ 225 /** set resources used, such as Office, Car, etc. */
226 void setResources(const QStringList &resources); 226 void setResources(const QStringList &resources);
227 /** return list of current resources */ 227 /** return list of current resources */
228 QStringList resources() const; 228 QStringList resources() const;
229 229
230 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 230 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
231 void setPriority(int priority); 231 void setPriority(int priority);
232 /** get the event's priority */ 232 /** get the event's priority */
233 int priority() const; 233 int priority() const;
234 234
235 /** All alarms that are associated with this incidence */ 235 /** All alarms that are associated with this incidence */
236 QPtrList<Alarm> alarms() const; 236 QPtrList<Alarm> alarms() const;
237 /** Create a new alarm which is associated with this incidence */ 237 /** Create a new alarm which is associated with this incidence */
238 Alarm* newAlarm(); 238 Alarm* newAlarm();
239 /** Add an alarm which is associated with this incidence */ 239 /** Add an alarm which is associated with this incidence */
240 void addAlarm(Alarm*); 240 void addAlarm(Alarm*);
241 /** Remove an alarm that is associated with this incidence */ 241 /** Remove an alarm that is associated with this incidence */
242 void removeAlarm(Alarm*); 242 void removeAlarm(Alarm*);
243 /** Remove all alarms that are associated with this incidence */ 243 /** Remove all alarms that are associated with this incidence */
244 void clearAlarms(); 244 void clearAlarms();
245 /** return whether any alarm associated with this incidence is enabled */ 245 /** return whether any alarm associated with this incidence is enabled */
246 bool isAlarmEnabled() const; 246 bool isAlarmEnabled() const;
247 247
248 /** 248 /**
249 Return the recurrence rule associated with this incidence. If there is 249 Return the recurrence rule associated with this incidence. If there is
250 none, returns an appropriate (non-0) object. 250 none, returns an appropriate (non-0) object.
251 */ 251 */
252 Recurrence *recurrence() const; 252 Recurrence *recurrence();
253 void setRecurrence(Recurrence * r); 253 void setRecurrence(Recurrence * r);
254 /** 254 /**
255 Forward to Recurrence::doesRecur(). 255 Forward to Recurrence::doesRecur().
256 */ 256 */
257 ushort doesRecur() const; 257 ushort doesRecur() const;
258 258
259 /** set the event's/todo's location. Do _not_ use it with journal */ 259 /** set the event's/todo's location. Do _not_ use it with journal */
260 void setLocation(const QString &location); 260 void setLocation(const QString &location);
261 /** return the event's/todo's location. Do _not_ use it with journal */ 261 /** return the event's/todo's location. Do _not_ use it with journal */
262 QString location() const; 262 QString location() const;
263 /** returns TRUE or FALSE depending on whether the todo has a start date */ 263 /** returns TRUE or FALSE depending on whether the todo has a start date */
264 bool hasStartDate() const; 264 bool hasStartDate() const;
265 /** sets the event's hasStartDate value. */ 265 /** sets the event's hasStartDate value. */
266 void setHasStartDate(bool f); 266 void setHasStartDate(bool f);
267 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const; 267 QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
268 bool cancelled() const; 268 bool cancelled() const;
269 void setCancelled( bool b ); 269 void setCancelled( bool b );
270 270
271 bool hasRecurrenceID() const; 271 bool hasRecurrenceID() const;
272 void setHasRecurrenceID( bool b ); 272 void setHasRecurrenceID( bool b );
273 273
274 void setRecurrenceID(QDateTime); 274 void setRecurrenceID(QDateTime);
275 QDateTime recurrenceID () const; 275 QDateTime recurrenceID () const;
276 QDateTime dtStart() const; 276 QDateTime dtStart() const;
277 bool isHoliday() const; 277 bool isHoliday() const;
278 bool isBirthday() const; 278 bool isBirthday() const;
279 bool isAnniversary() const; 279 bool isAnniversary() const;
280 QDateTime lastModifiedSub(); 280 QDateTime lastModifiedSub();
281 QString recurrenceText() const;
281 void setLastModifiedSubInvalid(); 282 void setLastModifiedSubInvalid();
282 283
283 284
285 Recurrence *mRecurrence;
284protected: 286protected:
285 QPtrList<Alarm> mAlarms; 287 QPtrList<Alarm> mAlarms;
286 QPtrList<Incidence> mRelations; 288 QPtrList<Incidence> mRelations;
287 QDateTime mRecurrenceID; 289 QDateTime mRecurrenceID;
288 bool mHasRecurrenceID; 290 bool mHasRecurrenceID;
289 private: 291 private:
290 void checkCategories(); 292 void checkCategories();
291 bool mHoliday, mBirthday, mAnniversary; 293 bool mHoliday, mBirthday, mAnniversary;
292 int mRevision; 294 int mRevision;
293 bool mCancelled; 295 bool mCancelled;
294 296
295 // base components of jounal, event and todo 297 // base components of jounal, event and todo
296 QDateTime mCreated; 298 QDateTime mCreated;
297 QDateTime mLastModifiedSub; 299 QDateTime mLastModifiedSub;
298 QString mDescription; 300 QString mDescription;
299 QString mSummary; 301 QString mSummary;
300 QStringList mCategories; 302 QStringList mCategories;
301 Incidence *mRelatedTo; 303 Incidence *mRelatedTo;
302 QString mRelatedToUid; 304 QString mRelatedToUid;
303 DateList mExDates; 305 DateList mExDates;
304 QPtrList<Attachment> mAttachments; 306 QPtrList<Attachment> mAttachments;
305 QStringList mResources; 307 QStringList mResources;
306 bool mHasStartDate; // if todo has associated start date 308 bool mHasStartDate; // if todo has associated start date
307 309
308 int mSecrecy; 310 int mSecrecy;
309 int mPriority; // 1 = highest, 2 = less, etc. 311 int mPriority; // 1 = highest, 2 = less, etc.
310 312
311 //QPtrList<Alarm> mAlarms; 313 //QPtrList<Alarm> mAlarms;
312 Recurrence *mRecurrence;
313 314
314 QString mLocation; 315 QString mLocation;
315}; 316};
316 317
317bool operator==( const Incidence&, const Incidence& ); 318bool operator==( const Incidence&, const Incidence& );
318 319
319} 320}
320 321
321#endif 322#endif
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 9359fad..f8f40f1 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -60,97 +60,97 @@ void KIncidenceFormatter::setEvent(Event *event)
60 } 60 }
61 if ( mColorMode == 2 ) { 61 if ( mColorMode == 2 ) {
62 mText +="<font color=\"#C00000\">"; 62 mText +="<font color=\"#C00000\">";
63 } 63 }
64 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>"; 64 // mText +="<font color=\"#F00000\">" + i18n("O-due!") + "</font>";
65 if ( mode == 1 ) { 65 if ( mode == 1 ) {
66 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 66 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
67 } else { 67 } else {
68 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 68 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
69 } 69 }
70 formatReadOnly(event); 70 formatReadOnly(event);
71 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 71 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
72 if ( mColorMode ) 72 if ( mColorMode )
73 mText += "</font>"; 73 mText += "</font>";
74 } 74 }
75 if (event->cancelled ()) { 75 if (event->cancelled ()) {
76 mText +="<font color=\"#B00000\">"; 76 mText +="<font color=\"#B00000\">";
77 addTag("i",i18n("This event has been cancelled!")); 77 addTag("i",i18n("This event has been cancelled!"));
78 mText.append("<br>"); 78 mText.append("<br>");
79 mText += "</font>"; 79 mText += "</font>";
80 } 80 }
81 if (event->doesFloat()) { 81 if (event->doesFloat()) {
82 if (event->isMultiDay()) { 82 if (event->isMultiDay()) {
83 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>") 83 mText.append(i18n("<p><b>From:</b> %1 </p><p><b>To:</b> %2</p>")
84 .arg(event->dtStartDateStr(shortDate)) 84 .arg(event->dtStartDateStr(shortDate))
85 .arg(event->dtEndDateStr(shortDate))); 85 .arg(event->dtEndDateStr(shortDate)));
86 } else { 86 } else {
87 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate ))); 87 mText.append(i18n("<p><b>On:</b> %1</p>").arg(event->dtStartDateStr( shortDate )));
88 } 88 }
89 } else { 89 } else {
90 if (event->isMultiDay()) { 90 if (event->isMultiDay()) {
91 mText.append(i18n("<p><b>From:</b> %1</p> ") 91 mText.append(i18n("<p><b>From:</b> %1</p> ")
92 .arg(event->dtStartStr( shortDate))); 92 .arg(event->dtStartStr( shortDate)));
93 mText.append(i18n("<p><b>To:</b> %1</p>") 93 mText.append(i18n("<p><b>To:</b> %1</p>")
94 .arg(event->dtEndStr(shortDate))); 94 .arg(event->dtEndStr(shortDate)));
95 } else { 95 } else {
96 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>") 96 mText.append(i18n("<p><b>From:</b> %1 <b>To:</b> %2</p>")
97 .arg(event->dtStartTimeStr()) 97 .arg(event->dtStartTimeStr())
98 .arg(event->dtEndTimeStr())); 98 .arg(event->dtEndTimeStr()));
99 mText.append(i18n("<p><b>On:</b> %1</p> ") 99 mText.append(i18n("<p><b>On:</b> %1</p> ")
100 .arg(event->dtStartDateStr( shortDate ))); 100 .arg(event->dtStartDateStr( shortDate )));
101 } 101 }
102 } 102 }
103 if (!event->location().isEmpty()) { 103 if (!event->location().isEmpty()) {
104 addTag("b",i18n("Location: ")); 104 addTag("b",i18n("Location: "));
105 mText.append(deTag(event->location())+"<br>"); 105 mText.append(deTag(event->location())+"<br>");
106 } 106 }
107 107
108 if (event->recurrence()->doesRecur()) { 108 if (event->doesRecur()) {
109 109
110 QString recurText = event->recurrence()->recurrenceText(); 110 QString recurText = event->recurrence()->recurrenceText();
111 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>"); 111 addTag("p","<em>" + i18n("This is a %1 recurring event.").arg(recurText ) + "</em>");
112 112
113 bool ok; 113 bool ok;
114 QDate start = QDate::currentDate(); 114 QDate start = QDate::currentDate();
115 QDateTime next; 115 QDateTime next;
116 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok ); 116 next = event->getNextOccurence( QDateTime::currentDateTime() , &ok );
117 if ( ok ) { 117 if ( ok ) {
118 addTag("p",i18n("<b>Next recurrence is on:</b>") ); 118 addTag("p",i18n("<b>Next recurrence is on:</b>") );
119 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate )); 119 addTag("p", KGlobal::locale()->formatDate( next.date(), shortDate ));
120 120
121 } else { 121 } else {
122 bool last; 122 bool last;
123 QDate nextd; 123 QDate nextd;
124 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last ); 124 nextd = event->recurrence()->getPreviousDate( QDate::currentDate() , &last );
125 if ( last ) { 125 if ( last ) {
126 addTag("p",i18n("<b>Last recurrence was on:</b>") ); 126 addTag("p",i18n("<b>Last recurrence was on:</b>") );
127 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate )); 127 addTag("p", KGlobal::locale()->formatDate( nextd, shortDate ));
128 } 128 }
129 } 129 }
130 } 130 }
131 131
132 132
133 if (event->isAlarmEnabled()) { 133 if (event->isAlarmEnabled()) {
134 Alarm *alarm =event->alarms().first() ; 134 Alarm *alarm =event->alarms().first() ;
135 QDateTime t = alarm->time(); 135 QDateTime t = alarm->time();
136 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 136 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
137 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate )); 137 addTag("p",i18n("<b>Alarm on: </b>") + s + ": "+KGlobal::locale()->formatDateTime( t, shortDate ));
138 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 138 //addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
139 //addTag("p",s); 139 //addTag("p",s);
140 } 140 }
141 141
142 142
143 143
144 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 144 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
145 // mText.append(event->secrecyStr()+"<br>"); 145 // mText.append(event->secrecyStr()+"<br>");
146 formatCategories(event); 146 formatCategories(event);
147 147
148 formatAttendees(event); 148 formatAttendees(event);
149 149
150 if ( mCreated ) { 150 if ( mCreated ) {
151#ifdef DESKTOP_VERSION 151#ifdef DESKTOP_VERSION
152 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 152 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
153#else 153#else
154 addTag("p",i18n("<b>Created: ") +" </b>"); 154 addTag("p",i18n("<b>Created: ") +" </b>");
155 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 155 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
156#endif 156#endif
@@ -171,97 +171,97 @@ void KIncidenceFormatter::setEvent(Event *event)
171 addTag("p",deTag(event->description())); 171 addTag("p",deTag(event->description()));
172 } 172 }
173 } 173 }
174 174
175} 175}
176 176
177void KIncidenceFormatter::setTodo(Todo *event ) 177void KIncidenceFormatter::setTodo(Todo *event )
178{ 178{
179 int mode = 0; 179 int mode = 0;
180 mCurrentIncidence = event; 180 mCurrentIncidence = event;
181 bool shortDate = true; 181 bool shortDate = true;
182 if (mode == 0 ) { 182 if (mode == 0 ) {
183 addTag("h3",deTag(event->summary())); 183 addTag("h3",deTag(event->summary()));
184 formatReadOnly(event); 184 formatReadOnly(event);
185 } 185 }
186 else { 186 else {
187 if ( mColorMode == 1 ) { 187 if ( mColorMode == 1 ) {
188 mText +="<font color=\"#00A000\">"; 188 mText +="<font color=\"#00A000\">";
189 } 189 }
190 if ( mColorMode == 2 ) { 190 if ( mColorMode == 2 ) {
191 mText +="<font color=\"#B00000\">"; 191 mText +="<font color=\"#B00000\">";
192 } 192 }
193 if ( mode == 1 ) { 193 if ( mode == 1 ) {
194 addTag("h2",i18n( "Local: " ) +deTag(event->summary())); 194 addTag("h2",i18n( "Local: " ) +deTag(event->summary()));
195 } else { 195 } else {
196 addTag("h2",i18n( "Remote: " ) +deTag(event->summary())); 196 addTag("h2",i18n( "Remote: " ) +deTag(event->summary()));
197 } 197 }
198 formatReadOnly(event); 198 formatReadOnly(event);
199 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) ); 199 addTag("h3",i18n( "Last modified: " ) + KGlobal::locale()->formatDateTime(event->lastModified(),shortDate, true ) );
200 if ( mColorMode ) 200 if ( mColorMode )
201 mText += "</font>"; 201 mText += "</font>";
202 } 202 }
203 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) { 203 if ( event->percentComplete() == 100 && event->hasCompletedDate() ) {
204 mText +="<font color=\"#B00000\">"; 204 mText +="<font color=\"#B00000\">";
205 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) ); 205 addTag("i", i18n("<p><i>Completed on %1</i></p>").arg( event->completedStr(shortDate) ) );
206 mText += "</font>"; 206 mText += "</font>";
207 } else { 207 } else {
208 mText.append(i18n("<p><i>%1 % completed</i></p>") 208 mText.append(i18n("<p><i>%1 % completed</i></p>")
209 .arg(event->percentComplete())); 209 .arg(event->percentComplete()));
210 } 210 }
211 if (event->cancelled ()) { 211 if (event->cancelled ()) {
212 mText +="<font color=\"#B00000\">"; 212 mText +="<font color=\"#B00000\">";
213 addTag("i",i18n("This todo has been cancelled!")); 213 addTag("i",i18n("This todo has been cancelled!"));
214 mText.append("<br>"); 214 mText.append("<br>");
215 mText += "</font>"; 215 mText += "</font>";
216 } 216 }
217 217
218 218
219 if (event->recurrence()->doesRecur()) { 219 if (event->doesRecur()) {
220 220
221 QString recurText = event->recurrence()->recurrenceText(); 221 QString recurText = event->recurrence()->recurrenceText();
222 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>"); 222 addTag("p","<em>" + i18n("This is a %1 recurring todo.").arg(recurText ) + "</em>");
223 } 223 }
224 224
225 if (event->hasStartDate()) { 225 if (event->hasStartDate()) {
226 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate))); 226 mText.append(i18n("<p><b>Start on:</b> %1</p>").arg(event->dtStartStr(shortDate)));
227 } 227 }
228 228
229 229
230 if (event->hasDueDate()) { 230 if (event->hasDueDate()) {
231 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate))); 231 mText.append(i18n("<p><b>Due on:</b> %1</p>").arg(event->dtDueStr(shortDate)));
232 } 232 }
233 233
234 if (!event->location().isEmpty()) { 234 if (!event->location().isEmpty()) {
235 addTag("b",i18n("Location: ")); 235 addTag("b",i18n("Location: "));
236 mText.append(deTag(event->location())+"<br>"); 236 mText.append(deTag(event->location())+"<br>");
237 } 237 }
238 238
239 mText.append(i18n("<p><b>Priority:</b> %2</p>") 239 mText.append(i18n("<p><b>Priority:</b> %2</p>")
240 .arg(QString::number(event->priority()))); 240 .arg(QString::number(event->priority())));
241 241
242 if (event->isAlarmEnabled()) { 242 if (event->isAlarmEnabled()) {
243 Alarm *alarm =event->alarms().first() ; 243 Alarm *alarm =event->alarms().first() ;
244 QDateTime t = alarm->time(); 244 QDateTime t = alarm->time();
245 QString s =i18n("( %1 before )").arg( alarm->offsetText() ); 245 QString s =i18n("( %1 before )").arg( alarm->offsetText() );
246 addTag("p",i18n("<b>Alarm on: ") + s +" </b>"); 246 addTag("p",i18n("<b>Alarm on: ") + s +" </b>");
247 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate )); 247 addTag("p", KGlobal::locale()->formatDateTime( t, shortDate ));
248 //addTag("p",s); 248 //addTag("p",s);
249 } 249 }
250 250
251 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() ); 251 addTag("p",i18n("<b>Access: </b>") +event->secrecyStr() );
252 formatCategories(event); 252 formatCategories(event);
253 253
254 formatAttendees(event); 254 formatAttendees(event);
255 if ( mCreated ) { 255 if ( mCreated ) {
256#ifdef DESKTOP_VERSION 256#ifdef DESKTOP_VERSION
257 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate )); 257 addTag("p",i18n("<b>Created: ") +" </b>"+KGlobal::locale()->formatDateTime( event->created(), shortDate ));
258#else 258#else
259 addTag("p",i18n("<b>Created: ") +" </b>"); 259 addTag("p",i18n("<b>Created: ") +" </b>");
260 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate )); 260 addTag("p", KGlobal::locale()->formatDateTime( event->created(), shortDate ));
261#endif 261#endif
262 262
263 } 263 }
264 if ( mModified ) { 264 if ( mModified ) {
265#ifdef DESKTOP_VERSION 265#ifdef DESKTOP_VERSION
266 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate )); 266 addTag("p",i18n("<b>Last modified: ") +" </b>"+KGlobal::locale()->formatDateTime( event->lastModified(), shortDate ));
267#else 267#else
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 8efc1ea..2e19740 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -347,164 +347,164 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
348 // read in. 348 // read in.
349 tmpStr += ";"; 349 tmpStr += ";";
350 } 350 }
351 if (!tmpStr.isEmpty()) { 351 if (!tmpStr.isEmpty()) {
352 tmpStr.truncate(tmpStr.length()-1); 352 tmpStr.truncate(tmpStr.length()-1);
353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
354 } 354 }
355 355
356 // alarm stuff 356 // alarm stuff
357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; 357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
358 QPtrList<Alarm> alarms = anEvent->alarms(); 358 QPtrList<Alarm> alarms = anEvent->alarms();
359 Alarm* alarm; 359 Alarm* alarm;
360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
361 if (alarm->enabled()) { 361 if (alarm->enabled()) {
362 VObject *a; 362 VObject *a;
363 tmpStr = qDateTimeToISO(alarm->time()); 363 tmpStr = qDateTimeToISO(alarm->time());
364 if (alarm->type() == Alarm::Audio) { 364 if (alarm->type() == Alarm::Audio) {
365 a = addProp(vtodo, VCAAlarmProp); 365 a = addProp(vtodo, VCAAlarmProp);
366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
367 addPropValue(a, VCRepeatCountProp, "1"); 367 addPropValue(a, VCRepeatCountProp, "1");
368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
369 } 369 }
370 else if (alarm->type() == Alarm::Procedure) { 370 else if (alarm->type() == Alarm::Procedure) {
371 a = addProp(vtodo, VCPAlarmProp); 371 a = addProp(vtodo, VCPAlarmProp);
372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 372 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
373 addPropValue(a, VCRepeatCountProp, "1"); 373 addPropValue(a, VCRepeatCountProp, "1");
374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); 374 addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile()));
375 } else { 375 } else {
376 a = addProp(vtodo, VCDAlarmProp); 376 a = addProp(vtodo, VCDAlarmProp);
377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 377 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
378 addPropValue(a, VCRepeatCountProp, "1"); 378 addPropValue(a, VCRepeatCountProp, "1");
379 addPropValue(a, VCDisplayStringProp, "beep!"); 379 addPropValue(a, VCDisplayStringProp, "beep!");
380 } 380 }
381 } 381 }
382 } 382 }
383 383
384 if (anEvent->pilotId()) { 384 if (anEvent->pilotId()) {
385 // pilot sync stuff 385 // pilot sync stuff
386 tmpStr.sprintf("%i",anEvent->pilotId()); 386 tmpStr.sprintf("%i",anEvent->pilotId());
387 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); 387 addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit());
388 tmpStr.sprintf("%i",anEvent->syncStatus()); 388 tmpStr.sprintf("%i",anEvent->syncStatus());
389 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); 389 addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit());
390 } 390 }
391 391
392 return vtodo; 392 return vtodo;
393} 393}
394 394
395VObject* VCalFormat::eventToVEvent(const Event *anEvent) 395VObject* VCalFormat::eventToVEvent(Event *anEvent)
396{ 396{
397 VObject *vevent; 397 VObject *vevent;
398 QString tmpStr; 398 QString tmpStr;
399 399
400 vevent = newVObject(VCEventProp); 400 vevent = newVObject(VCEventProp);
401 401
402 // start and end time 402 // start and end time
403 tmpStr = qDateTimeToISO(anEvent->dtStart(), 403 tmpStr = qDateTimeToISO(anEvent->dtStart(),
404 !anEvent->doesFloat()); 404 !anEvent->doesFloat());
405 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); 405 addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit());
406 406
407 // events that have time associated but take up no time should 407 // events that have time associated but take up no time should
408 // not have both DTSTART and DTEND. 408 // not have both DTSTART and DTEND.
409 if (anEvent->dtStart() != anEvent->dtEnd()) { 409 if (anEvent->dtStart() != anEvent->dtEnd()) {
410 tmpStr = qDateTimeToISO(anEvent->dtEnd(), 410 tmpStr = qDateTimeToISO(anEvent->dtEnd(),
411 !anEvent->doesFloat()); 411 !anEvent->doesFloat());
412 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); 412 addPropValue(vevent, VCDTendProp, tmpStr.local8Bit());
413 } 413 }
414 414
415 // creation date 415 // creation date
416 tmpStr = qDateTimeToISO(anEvent->created()); 416 tmpStr = qDateTimeToISO(anEvent->created());
417 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); 417 addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit());
418 418
419 // unique id 419 // unique id
420 addPropValue(vevent, VCUniqueStringProp, 420 addPropValue(vevent, VCUniqueStringProp,
421 anEvent->uid().local8Bit()); 421 anEvent->uid().local8Bit());
422 422
423 // revision 423 // revision
424 tmpStr.sprintf("%i", anEvent->revision()); 424 tmpStr.sprintf("%i", anEvent->revision());
425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
426 426
427 // last modification date 427 // last modification date
428 tmpStr = qDateTimeToISO(anEvent->lastModified()); 428 tmpStr = qDateTimeToISO(anEvent->lastModified());
429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
430 430
431 // attendee and organizer stuff 431 // attendee and organizer stuff
432 tmpStr = "MAILTO:" + anEvent->organizer(); 432 tmpStr = "MAILTO:" + anEvent->organizer();
433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
434 434
435 if (anEvent->attendeeCount() != 0) { 435 if (anEvent->attendeeCount() != 0) {
436 QPtrList<Attendee> al = anEvent->attendees(); 436 QPtrList<Attendee> al = anEvent->attendees();
437 QPtrListIterator<Attendee> ai(al); 437 QPtrListIterator<Attendee> ai(al);
438 Attendee *curAttendee; 438 Attendee *curAttendee;
439 439
440 // TODO: Put this functionality into Attendee class 440 // TODO: Put this functionality into Attendee class
441 for (; ai.current(); ++ai) { 441 for (; ai.current(); ++ai) {
442 curAttendee = ai.current(); 442 curAttendee = ai.current();
443 if (!curAttendee->email().isEmpty() && 443 if (!curAttendee->email().isEmpty() &&
444 !curAttendee->name().isEmpty()) 444 !curAttendee->name().isEmpty())
445 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 445 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
446 curAttendee->email() + ">"; 446 curAttendee->email() + ">";
447 else if (curAttendee->name().isEmpty()) 447 else if (curAttendee->name().isEmpty())
448 tmpStr = "MAILTO: " + curAttendee->email(); 448 tmpStr = "MAILTO: " + curAttendee->email();
449 else if (curAttendee->email().isEmpty()) 449 else if (curAttendee->email().isEmpty())
450 tmpStr = "MAILTO: " + curAttendee->name(); 450 tmpStr = "MAILTO: " + curAttendee->name();
451 else if (curAttendee->name().isEmpty() && 451 else if (curAttendee->name().isEmpty() &&
452 curAttendee->email().isEmpty()) 452 curAttendee->email().isEmpty())
453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
458 } 458 }
459 } 459 }
460 460
461 // recurrence rule stuff 461 // recurrence rule stuff
462 if (anEvent->recurrence()->doesRecur()) { 462 if (anEvent->doesRecur()) {
463 // some more variables 463 // some more variables
464 QPtrList<Recurrence::rMonthPos> tmpPositions; 464 QPtrList<Recurrence::rMonthPos> tmpPositions;
465 QPtrList<int> tmpDays; 465 QPtrList<int> tmpDays;
466 int *tmpDay; 466 int *tmpDay;
467 Recurrence::rMonthPos *tmpPos; 467 Recurrence::rMonthPos *tmpPos;
468 QString tmpStr2; 468 QString tmpStr2;
469 int i; 469 int i;
470 470
471 switch(anEvent->recurrence()->doesRecur()) { 471 switch(anEvent->recurrence()->doesRecur()) {
472 case Recurrence::rDaily: 472 case Recurrence::rDaily:
473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
474// if (anEvent->rDuration > 0) 474// if (anEvent->rDuration > 0)
475 //tmpStr += "#"; 475 //tmpStr += "#";
476 break; 476 break;
477 case Recurrence::rWeekly: 477 case Recurrence::rWeekly:
478 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); 478 tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency());
479 for (i = 0; i < 7; i++) { 479 for (i = 0; i < 7; i++) {
480 if (anEvent->recurrence()->days().testBit(i)) 480 if (anEvent->recurrence()->days().testBit(i))
481 tmpStr += dayFromNum(i); 481 tmpStr += dayFromNum(i);
482 } 482 }
483 break; 483 break;
484 case Recurrence::rMonthlyPos: 484 case Recurrence::rMonthlyPos:
485 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); 485 tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency());
486 // write out all rMonthPos's 486 // write out all rMonthPos's
487 tmpPositions = anEvent->recurrence()->monthPositions(); 487 tmpPositions = anEvent->recurrence()->monthPositions();
488 for (tmpPos = tmpPositions.first(); 488 for (tmpPos = tmpPositions.first();
489 tmpPos; 489 tmpPos;
490 tmpPos = tmpPositions.next()) { 490 tmpPos = tmpPositions.next()) {
491 491
492 tmpStr2.sprintf("%i", tmpPos->rPos); 492 tmpStr2.sprintf("%i", tmpPos->rPos);
493 if (tmpPos->negative) 493 if (tmpPos->negative)
494 tmpStr2 += "- "; 494 tmpStr2 += "- ";
495 else 495 else
496 tmpStr2 += "+ "; 496 tmpStr2 += "+ ";
497 tmpStr += tmpStr2; 497 tmpStr += tmpStr2;
498 for (i = 0; i < 7; i++) { 498 for (i = 0; i < 7; i++) {
499 if (tmpPos->rDays.testBit(i)) 499 if (tmpPos->rDays.testBit(i))
500 tmpStr += dayFromNum(i); 500 tmpStr += dayFromNum(i);
501 } 501 }
502 } // loop for all rMonthPos's 502 } // loop for all rMonthPos's
503 break; 503 break;
504 case Recurrence::rMonthlyDay: 504 case Recurrence::rMonthlyDay:
505 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); 505 tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency());
506 // write out all rMonthDays; 506 // write out all rMonthDays;
507 tmpDays = anEvent->recurrence()->monthDays(); 507 tmpDays = anEvent->recurrence()->monthDays();
508 for (tmpDay = tmpDays.first(); 508 for (tmpDay = tmpDays.first();
509 tmpDay; 509 tmpDay;
510 tmpDay = tmpDays.next()) { 510 tmpDay = tmpDays.next()) {
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index c7df017..6dae3d2 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -29,85 +29,85 @@
29class VObject; 29class VObject;
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the vCalendar format. It provides methods for 34 This class implements the vCalendar format. It provides methods for
35 loading/saving/converting vCalendar format data into the internal KOrganizer 35 loading/saving/converting vCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 36 representation as Calendar and Events.
37 37
38 @short vCalendar format implementation 38 @short vCalendar format implementation
39*/ 39*/
40class VCalFormat : public CalFormat { 40class VCalFormat : public CalFormat {
41 public: 41 public:
42 VCalFormat(); 42 VCalFormat();
43 virtual ~VCalFormat(); 43 virtual ~VCalFormat();
44 44
45 /** loads a calendar on disk in vCalendar format into the current calendar. 45 /** loads a calendar on disk in vCalendar format into the current calendar.
46 * any information already present is lost. Returns TRUE if successful, 46 * any information already present is lost. Returns TRUE if successful,
47 * else returns FALSE. 47 * else returns FALSE.
48 * @param fileName the name of the calendar on disk. 48 * @param fileName the name of the calendar on disk.
49 */ 49 */
50 bool load(Calendar *,const QString &fileName ); 50 bool load(Calendar *,const QString &fileName );
51 /** writes out the calendar to disk in vCalendar format. Returns true if 51 /** writes out the calendar to disk in vCalendar format. Returns true if
52 * successful and false on error. 52 * successful and false on error.
53 * @param fileName the name of the file 53 * @param fileName the name of the file
54 */ 54 */
55 bool save(Calendar *,const QString &fileName ); 55 bool save(Calendar *,const QString &fileName );
56 56
57 /** 57 /**
58 Parse string and populate calendar with that information. 58 Parse string and populate calendar with that information.
59 */ 59 */
60 bool fromString( Calendar *, const QString & ); 60 bool fromString( Calendar *, const QString & );
61 /** 61 /**
62 Return calendar information as string. 62 Return calendar information as string.
63 */ 63 */
64 void setLocalTime ( bool ); 64 void setLocalTime ( bool );
65 QString toString( Calendar * ); 65 QString toString( Calendar * );
66 QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); 66 QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true );
67 QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); 67 QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true );
68 68
69 protected: 69 protected:
70 /** translates a VObject of the TODO type into a Event */ 70 /** translates a VObject of the TODO type into a Event */
71 Todo *VTodoToEvent(VObject *vtodo); 71 Todo *VTodoToEvent(VObject *vtodo);
72 /** translates a VObject into a Event and returns a pointer to it. */ 72 /** translates a VObject into a Event and returns a pointer to it. */
73 Event *VEventToEvent(VObject *vevent); 73 Event *VEventToEvent(VObject *vevent);
74 /** translate a Event into a VTodo-type VObject and return pointer */ 74 /** translate a Event into a VTodo-type VObject and return pointer */
75 VObject *eventToVTodo(const Todo *anEvent); 75 VObject *eventToVTodo(const Todo *anEvent);
76 /** translate a Event into a VObject and returns a pointer to it. */ 76 /** translate a Event into a VObject and returns a pointer to it. */
77 VObject* eventToVEvent(const Event *anEvent); 77 VObject* eventToVEvent(Event *anEvent);
78 78
79 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ 79 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
80 QString qDateToISO(const QDate &); 80 QString qDateToISO(const QDate &);
81 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ 81 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */
82 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); 82 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE);
83 /** takes a string in the format YYYYMMDDTHHMMSS and returns a 83 /** takes a string in the format YYYYMMDDTHHMMSS and returns a
84 * valid QDateTime. */ 84 * valid QDateTime. */
85 QDateTime ISOToQDateTime(const QString & dtStr); 85 QDateTime ISOToQDateTime(const QString & dtStr);
86 /** takes a string in the format YYYYMMDD and returns a 86 /** takes a string in the format YYYYMMDD and returns a
87 * valid QDate. */ 87 * valid QDate. */
88 QDate ISOToQDate(const QString & dtStr); 88 QDate ISOToQDate(const QString & dtStr);
89 /** takes a vCalendar tree of VObjects, and puts all of them that have 89 /** takes a vCalendar tree of VObjects, and puts all of them that have
90 * the "event" property into the dictionary, todos in the todo-list, etc. */ 90 * the "event" property into the dictionary, todos in the todo-list, etc. */
91 void populate(VObject *vcal); 91 void populate(VObject *vcal);
92 92
93 /** takes a number 0 - 6 and returns the two letter string of that day, 93 /** takes a number 0 - 6 and returns the two letter string of that day,
94 * i.e. MO, TU, WE, etc. */ 94 * i.e. MO, TU, WE, etc. */
95 const char *dayFromNum(int day); 95 const char *dayFromNum(int day);
96 /** the reverse of the above function. */ 96 /** the reverse of the above function. */
97 int numFromDay(const QString &day); 97 int numFromDay(const QString &day);
98 Attendee::Role VCalFormat::readRole(const char *s) const; 98 Attendee::Role VCalFormat::readRole(const char *s) const;
99 QCString writeRole(Attendee::Role role) const; 99 QCString writeRole(Attendee::Role role) const;
100 Attendee::PartStat readStatus(const char *s) const; 100 Attendee::PartStat readStatus(const char *s) const;
101 QCString writeStatus(Attendee::PartStat status) const; 101 QCString writeStatus(Attendee::PartStat status) const;
102 102
103 private: 103 private:
104 Calendar *mCalendar; 104 Calendar *mCalendar;
105 bool useLocalTime; 105 bool useLocalTime;
106 106
107 QPtrList<Event> mEventsRelate; // events with relations 107 QPtrList<Event> mEventsRelate; // events with relations
108 QPtrList<Todo> mTodosRelate; // todos with relations 108 QPtrList<Todo> mTodosRelate; // todos with relations
109}; 109};
110 110
111} 111}
112 112
113#endif 113#endif