summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/alarm.cpp10
-rw-r--r--libkcal/alarm.h12
-rw-r--r--libkcal/calendar.cpp66
-rw-r--r--libkcal/calendar.h40
-rw-r--r--libkcal/calendarlocal.cpp66
-rw-r--r--libkcal/calendarlocal.h28
-rw-r--r--libkcal/calfilter.cpp6
-rw-r--r--libkcal/calfilter.h10
-rw-r--r--libkcal/customproperties.cpp32
-rw-r--r--libkcal/customproperties.h22
-rw-r--r--libkcal/dndfactory.cpp9
-rw-r--r--libkcal/dndfactory.h2
-rw-r--r--libkcal/dndfactory_dummy.h2
-rw-r--r--libkcal/dummyscheduler.cpp16
-rw-r--r--libkcal/dummyscheduler.h4
-rw-r--r--libkcal/event.cpp2
-rw-r--r--libkcal/event.h4
-rw-r--r--libkcal/filestorage.cpp2
-rw-r--r--libkcal/freebusy.cpp11
-rw-r--r--libkcal/freebusy.h14
-rw-r--r--libkcal/icaldrag.cpp2
-rw-r--r--libkcal/icaldrag.h4
-rw-r--r--libkcal/icalformat.cpp32
-rw-r--r--libkcal/icalformat.h4
-rw-r--r--libkcal/icalformatimpl.cpp35
-rw-r--r--libkcal/icalformatimpl.h6
-rw-r--r--libkcal/imipscheduler.cpp6
-rw-r--r--libkcal/imipscheduler.h4
-rw-r--r--libkcal/incidence.cpp38
-rw-r--r--libkcal/incidence.h20
-rw-r--r--libkcal/incidencebase.cpp14
-rw-r--r--libkcal/incidencebase.h16
-rw-r--r--libkcal/journal.h4
-rw-r--r--libkcal/kincidenceformatter.cpp10
-rw-r--r--libkcal/libkcal.pro6
-rw-r--r--libkcal/libkcalE.pro2
-rw-r--r--libkcal/listbase.h24
-rw-r--r--libkcal/phoneformat.cpp23
-rw-r--r--libkcal/qtopiaformat.cpp8
-rw-r--r--libkcal/recurrence.cpp187
-rw-r--r--libkcal/recurrence.h26
-rw-r--r--libkcal/scheduler.cpp12
-rw-r--r--libkcal/scheduler.h4
-rw-r--r--libkcal/sharpformat.cpp48
-rw-r--r--libkcal/todo.cpp2
-rw-r--r--libkcal/todo.h4
-rw-r--r--libkcal/vcaldrag.cpp2
-rw-r--r--libkcal/vcaldrag.h4
-rw-r--r--libkcal/vcalformat.cpp52
-rw-r--r--libkcal/vcalformat.h13
50 files changed, 521 insertions, 449 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 3157214..3c4a81c 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -17,24 +17,26 @@
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <kdebug.h> 22#include <kdebug.h>
23#include <klocale.h> 23#include <klocale.h>
24 24
25#include "incidence.h" 25#include "incidence.h"
26#include "todo.h" 26#include "todo.h"
27 27
28#include "alarm.h" 28#include "alarm.h"
29//Added by qt3to4:
30#include <Q3ValueList>
29 31
30using namespace KCal; 32using namespace KCal;
31#include <qwidget.h> 33#include <qwidget.h>
32Alarm::Alarm(Incidence *parent) 34Alarm::Alarm(Incidence *parent)
33 : mParent(parent), 35 : mParent(parent),
34 mType(Audio), 36 mType(Audio),
35 mDescription(""), // to make operator==() not fail 37 mDescription(""), // to make operator==() not fail
36 mFile(""), // to make operator==() not fail 38 mFile(""), // to make operator==() not fail
37 mMailSubject(""), // to make operator==() not fail 39 mMailSubject(""), // to make operator==() not fail
38 mAlarmSnoozeTime(5), 40 mAlarmSnoozeTime(5),
39 mAlarmRepeatCount(0), 41 mAlarmRepeatCount(0),
40 mEndOffset(false), 42 mEndOffset(false),
@@ -203,62 +205,62 @@ void Alarm::setProgramArguments(const QString &arguments)
203 if (mType == Procedure) { 205 if (mType == Procedure) {
204 mDescription = arguments; 206 mDescription = arguments;
205 mParent->updated(); 207 mParent->updated();
206 } 208 }
207} 209}
208 210
209QString Alarm::programArguments() const 211QString Alarm::programArguments() const
210{ 212{
211 return (mType == Procedure) ? mDescription : QString::null; 213 return (mType == Procedure) ? mDescription : QString::null;
212} 214}
213 215
214void Alarm::setEmailAlarm(const QString &subject, const QString &text, 216void Alarm::setEmailAlarm(const QString &subject, const QString &text,
215 const QValueList<Person> &addressees, const QStringList &attachments) 217 const Q3ValueList<Person> &addressees, const QStringList &attachments)
216{ 218{
217 mType = Email; 219 mType = Email;
218 mMailSubject = subject; 220 mMailSubject = subject;
219 mDescription = text; 221 mDescription = text;
220 mMailAddresses = addressees; 222 mMailAddresses = addressees;
221 mMailAttachFiles = attachments; 223 mMailAttachFiles = attachments;
222 mParent->updated(); 224 mParent->updated();
223} 225}
224 226
225void Alarm::setMailAddress(const Person &mailAddress) 227void Alarm::setMailAddress(const Person &mailAddress)
226{ 228{
227 if (mType == Email) { 229 if (mType == Email) {
228 mMailAddresses.clear(); 230 mMailAddresses.clear();
229 mMailAddresses += mailAddress; 231 mMailAddresses += mailAddress;
230 mParent->updated(); 232 mParent->updated();
231 } 233 }
232} 234}
233 235
234void Alarm::setMailAddresses(const QValueList<Person> &mailAddresses) 236void Alarm::setMailAddresses(const Q3ValueList<Person> &mailAddresses)
235{ 237{
236 if (mType == Email) { 238 if (mType == Email) {
237 mMailAddresses = mailAddresses; 239 mMailAddresses = mailAddresses;
238 mParent->updated(); 240 mParent->updated();
239 } 241 }
240} 242}
241 243
242void Alarm::addMailAddress(const Person &mailAddress) 244void Alarm::addMailAddress(const Person &mailAddress)
243{ 245{
244 if (mType == Email) { 246 if (mType == Email) {
245 mMailAddresses += mailAddress; 247 mMailAddresses += mailAddress;
246 mParent->updated(); 248 mParent->updated();
247 } 249 }
248} 250}
249 251
250QValueList<Person> Alarm::mailAddresses() const 252Q3ValueList<Person> Alarm::mailAddresses() const
251{ 253{
252 return (mType == Email) ? mMailAddresses : QValueList<Person>(); 254 return (mType == Email) ? mMailAddresses : Q3ValueList<Person>();
253} 255}
254 256
255void Alarm::setMailSubject(const QString &mailAlarmSubject) 257void Alarm::setMailSubject(const QString &mailAlarmSubject)
256{ 258{
257 if (mType == Email) { 259 if (mType == Email) {
258 mMailSubject = mailAlarmSubject; 260 mMailSubject = mailAlarmSubject;
259 mParent->updated(); 261 mParent->updated();
260 } 262 }
261} 263}
262 264
263QString Alarm::mailSubject() const 265QString Alarm::mailSubject() const
264{ 266{
diff --git a/libkcal/alarm.h b/libkcal/alarm.h
index ac6ea0d..b24f0f7 100644
--- a/libkcal/alarm.h
+++ b/libkcal/alarm.h
@@ -13,42 +13,42 @@
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#ifndef KCAL_ALARM_H 21#ifndef KCAL_ALARM_H
22#define KCAL_ALARM_H 22#define KCAL_ALARM_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qvaluelist.h> 25#include <q3valuelist.h>
26 26
27#include "customproperties.h" 27#include "customproperties.h"
28#include "duration.h" 28#include "duration.h"
29#include "person.h" 29#include "person.h"
30 30
31namespace KCal { 31namespace KCal {
32 32
33class Incidence; 33class Incidence;
34 34
35/** 35/**
36 This class represents an alarm notification. 36 This class represents an alarm notification.
37*/ 37*/
38class Alarm : public CustomProperties 38class Alarm : public CustomProperties
39{ 39{
40 public: 40 public:
41 enum Type { Invalid, Display, Procedure, Email, Audio }; 41 enum Type { Invalid, Display, Procedure, Email, Audio };
42 typedef QValueList<Alarm *> List; 42 typedef Q3ValueList<Alarm *> List;
43 43
44 /** Construct a new alarm with variables initialized to "sane" values. */ 44 /** Construct a new alarm with variables initialized to "sane" values. */
45 explicit Alarm(Incidence *parent); 45 explicit Alarm(Incidence *parent);
46 /** Destruct Alarm object. */ 46 /** Destruct Alarm object. */
47 ~Alarm(); 47 ~Alarm();
48 48
49 /** Compare this alarm with another one. */ 49 /** Compare this alarm with another one. */
50 bool operator==(const Alarm &) const; 50 bool operator==(const Alarm &) const;
51 bool operator!=(const Alarm &a) const { return !operator==(a); } 51 bool operator!=(const Alarm &a) const { return !operator==(a); }
52 52
53 /** Set the type of the alarm. 53 /** Set the type of the alarm.
54 If the specified type is different from the current type of the alarm, 54 If the specified type is different from the current type of the alarm,
@@ -103,41 +103,41 @@ class Alarm : public CustomProperties
103 void setProgramArguments(const QString &arguments); 103 void setProgramArguments(const QString &arguments);
104 /** Return the arguments to the program to run when the alarm is triggered. 104 /** Return the arguments to the program to run when the alarm is triggered.
105 @return the program arguments, or QString::null if not a procedure alarm. 105 @return the program arguments, or QString::null if not a procedure alarm.
106 */ 106 */
107 QString programArguments() const; 107 QString programArguments() const;
108 108
109 /** Set the alarm to be an email alarm. 109 /** Set the alarm to be an email alarm.
110 @param subject subject line of email. 110 @param subject subject line of email.
111 @param text body of email. 111 @param text body of email.
112 @param addressees email addresses of recipient(s). 112 @param addressees email addresses of recipient(s).
113 @param attachments optional names of files to attach to the email. 113 @param attachments optional names of files to attach to the email.
114 */ 114 */
115 void setEmailAlarm(const QString &subject, const QString &text, const QValueList<Person> &addressees, 115 void setEmailAlarm(const QString &subject, const QString &text, const Q3ValueList<Person> &addressees,
116 const QStringList &attachments = QStringList()); 116 const QStringList &attachments = QStringList());
117 117
118 /** Send mail to this address when the alarm is triggered. 118 /** Send mail to this address when the alarm is triggered.
119 Ignored if the alarm is not an email alarm. 119 Ignored if the alarm is not an email alarm.
120 */ 120 */
121 void setMailAddress(const Person &mailAlarmAddress); 121 void setMailAddress(const Person &mailAlarmAddress);
122 /** Send mail to these addresses when the alarm is triggered. 122 /** Send mail to these addresses when the alarm is triggered.
123 Ignored if the alarm is not an email alarm. 123 Ignored if the alarm is not an email alarm.
124 */ 124 */
125 void setMailAddresses(const QValueList<Person> &mailAlarmAddresses); 125 void setMailAddresses(const Q3ValueList<Person> &mailAlarmAddresses);
126 /** Add this address to the list of addresses to send mail to when the alarm is triggered. 126 /** Add this address to the list of addresses to send mail to when the alarm is triggered.
127 Ignored if the alarm is not an email alarm. 127 Ignored if the alarm is not an email alarm.
128 */ 128 */
129 void addMailAddress(const Person &mailAlarmAddress); 129 void addMailAddress(const Person &mailAlarmAddress);
130 /** return the addresses to send mail to when an alarm goes off */ 130 /** return the addresses to send mail to when an alarm goes off */
131 QValueList<Person> mailAddresses() const; 131 Q3ValueList<Person> mailAddresses() const;
132 132
133 /** Set the subject line of the mail. 133 /** Set the subject line of the mail.
134 Ignored if the alarm is not an email alarm. 134 Ignored if the alarm is not an email alarm.
135 */ 135 */
136 void setMailSubject(const QString &mailAlarmSubject); 136 void setMailSubject(const QString &mailAlarmSubject);
137 /** return the subject line of the mail */ 137 /** return the subject line of the mail */
138 QString mailSubject() const; 138 QString mailSubject() const;
139 139
140 /** Attach this filename to the email. 140 /** Attach this filename to the email.
141 Ignored if the alarm is not an email alarm. 141 Ignored if the alarm is not an email alarm.
142 */ 142 */
143 void setMailAttachment(const QString &mailAttachFile); 143 void setMailAttachment(const QString &mailAttachFile);
@@ -217,25 +217,25 @@ class Alarm : public CustomProperties
217 217
218 /** Set the alarm's parent incidence */ 218 /** Set the alarm's parent incidence */
219 void setParent( Incidence * ); 219 void setParent( Incidence * );
220 /** get the alarm's parent incidence */ 220 /** get the alarm's parent incidence */
221 Incidence *parent() const { return mParent; } 221 Incidence *parent() const { return mParent; }
222 222
223 private: 223 private:
224 Incidence *mParent; // the incidence which this alarm belongs to 224 Incidence *mParent; // the incidence which this alarm belongs to
225 Type mType; // type of alarm 225 Type mType; // type of alarm
226 QString mDescription; // text to display/email body/procedure arguments 226 QString mDescription; // text to display/email body/procedure arguments
227 QString mFile; // procedure program to run/optional audio file to play 227 QString mFile; // procedure program to run/optional audio file to play
228 QStringList mMailAttachFiles; // filenames to attach to email 228 QStringList mMailAttachFiles; // filenames to attach to email
229 QValueList<Person> mMailAddresses; // who to mail for reminder 229 Q3ValueList<Person> mMailAddresses; // who to mail for reminder
230 QString mMailSubject; // subject of email 230 QString mMailSubject; // subject of email
231 231
232 int mAlarmSnoozeTime; // number of minutes after alarm to 232 int mAlarmSnoozeTime; // number of minutes after alarm to
233 // snooze before ringing again 233 // snooze before ringing again
234 int mAlarmRepeatCount; // number of times for alarm to repeat 234 int mAlarmRepeatCount; // number of times for alarm to repeat
235 // after the initial time 235 // after the initial time
236 236
237 QDateTime mAlarmTime; // time at which to trigger the alarm 237 QDateTime mAlarmTime; // time at which to trigger the alarm
238 Duration mOffset; // time relative to incidence DTSTART to trigger the alarm 238 Duration mOffset; // time relative to incidence DTSTART to trigger the alarm
239 bool mEndOffset; // if true, mOffset relates to DTEND, not DTSTART 239 bool mEndOffset; // if true, mOffset relates to DTEND, not DTSTART
240 bool mHasTime; // use mAlarmTime, not mOffset 240 bool mHasTime; // use mAlarmTime, not mOffset
241 bool mAlarmEnabled; 241 bool mAlarmEnabled;
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 9b38d3f..bf095cf 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -21,24 +21,26 @@
21#include <stdlib.h> 21#include <stdlib.h>
22#include <time.h> 22#include <time.h>
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <klocale.h> 26#include <klocale.h>
27 27
28#include "exceptions.h" 28#include "exceptions.h"
29#include "calfilter.h" 29#include "calfilter.h"
30 30
31#include "calendar.h" 31#include "calendar.h"
32#include "syncdefines.h" 32#include "syncdefines.h"
33//Added by qt3to4:
34#include <Q3PtrList>
33 35
34using namespace KCal; 36using namespace KCal;
35 37
36Calendar::Calendar() 38Calendar::Calendar()
37{ 39{
38 40
39 init(); 41 init();
40 setTimeZoneId( " 00:00 Europe/London(UTC)" ); 42 setTimeZoneId( " 00:00 Europe/London(UTC)" );
41} 43}
42 44
43Calendar::Calendar( const QString &timeZoneId ) 45Calendar::Calendar( const QString &timeZoneId )
44{ 46{
@@ -262,123 +264,123 @@ void Calendar::setEmail(const QString &e)
262} 264}
263 265
264void Calendar::setFilter(CalFilter *filter) 266void Calendar::setFilter(CalFilter *filter)
265{ 267{
266 mFilter = filter; 268 mFilter = filter;
267} 269}
268 270
269CalFilter *Calendar::filter() 271CalFilter *Calendar::filter()
270{ 272{
271 return mFilter; 273 return mFilter;
272} 274}
273 275
274QPtrList<Incidence> Calendar::incidences() 276Q3PtrList<Incidence> Calendar::incidences()
275{ 277{
276 QPtrList<Incidence> incidences; 278 Q3PtrList<Incidence> incidences;
277 279
278 Incidence *i; 280 Incidence *i;
279 281
280 QPtrList<Event> e = events(); 282 Q3PtrList<Event> e = events();
281 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 283 for( i = e.first(); i; i = e.next() ) incidences.append( i );
282 284
283 QPtrList<Todo> t = todos(); 285 Q3PtrList<Todo> t = todos();
284 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 286 for( i = t.first(); i; i = t.next() ) incidences.append( i );
285 287
286 QPtrList<Journal> j = journals(); 288 Q3PtrList<Journal> j = journals();
287 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 289 for( i = j.first(); i; i = j.next() ) incidences.append( i );
288 290
289 return incidences; 291 return incidences;
290} 292}
291 293
292void Calendar::resetPilotStat(int id ) 294void Calendar::resetPilotStat(int id )
293{ 295{
294 QPtrList<Incidence> incidences; 296 Q3PtrList<Incidence> incidences;
295 297
296 Incidence *i; 298 Incidence *i;
297 299
298 QPtrList<Event> e = rawEvents(); 300 Q3PtrList<Event> e = rawEvents();
299 for( i = e.first(); i; i = e.next() ) i->setPilotId( id ); 301 for( i = e.first(); i; i = e.next() ) i->setPilotId( id );
300 302
301 QPtrList<Todo> t = rawTodos(); 303 Q3PtrList<Todo> t = rawTodos();
302 for( i = t.first(); i; i = t.next() ) i->setPilotId( id ); 304 for( i = t.first(); i; i = t.next() ) i->setPilotId( id );
303 305
304 QPtrList<Journal> j = journals(); 306 Q3PtrList<Journal> j = journals();
305 for( i = j.first(); i; i = j.next() ) i->setPilotId( id ); 307 for( i = j.first(); i; i = j.next() ) i->setPilotId( id );
306} 308}
307void Calendar::resetTempSyncStat() 309void Calendar::resetTempSyncStat()
308{ 310{
309 QPtrList<Incidence> incidences; 311 Q3PtrList<Incidence> incidences;
310 312
311 Incidence *i; 313 Incidence *i;
312 314
313 QPtrList<Event> e = rawEvents(); 315 Q3PtrList<Event> e = rawEvents();
314 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 316 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
315 317
316 QPtrList<Todo> t = rawTodos(); 318 Q3PtrList<Todo> t = rawTodos();
317 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 319 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
318 320
319 QPtrList<Journal> j = journals(); 321 Q3PtrList<Journal> j = journals();
320 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 322 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
321} 323}
322QPtrList<Incidence> Calendar::rawIncidences() 324Q3PtrList<Incidence> Calendar::rawIncidences()
323{ 325{
324 QPtrList<Incidence> incidences; 326 Q3PtrList<Incidence> incidences;
325 327
326 Incidence *i; 328 Incidence *i;
327 329
328 QPtrList<Event> e = rawEvents(); 330 Q3PtrList<Event> e = rawEvents();
329 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 331 for( i = e.first(); i; i = e.next() ) incidences.append( i );
330 332
331 QPtrList<Todo> t = rawTodos(); 333 Q3PtrList<Todo> t = rawTodos();
332 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 334 for( i = t.first(); i; i = t.next() ) incidences.append( i );
333 335
334 QPtrList<Journal> j = journals(); 336 Q3PtrList<Journal> j = journals();
335 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 337 for( i = j.first(); i; i = j.next() ) incidences.append( i );
336 338
337 return incidences; 339 return incidences;
338} 340}
339 341
340QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 342Q3PtrList<Event> Calendar::events( const QDate &date, bool sorted )
341{ 343{
342 QPtrList<Event> el = rawEventsForDate(date,sorted); 344 Q3PtrList<Event> el = rawEventsForDate(date,sorted);
343 mFilter->apply(&el); 345 mFilter->apply(&el);
344 return el; 346 return el;
345} 347}
346 348
347QPtrList<Event> Calendar::events( const QDateTime &qdt ) 349Q3PtrList<Event> Calendar::events( const QDateTime &qdt )
348{ 350{
349 QPtrList<Event> el = rawEventsForDate(qdt); 351 Q3PtrList<Event> el = rawEventsForDate(qdt);
350 mFilter->apply(&el); 352 mFilter->apply(&el);
351 return el; 353 return el;
352} 354}
353 355
354QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 356Q3PtrList<Event> Calendar::events( const QDate &start, const QDate &end,
355 bool inclusive) 357 bool inclusive)
356{ 358{
357 QPtrList<Event> el = rawEvents(start,end,inclusive); 359 Q3PtrList<Event> el = rawEvents(start,end,inclusive);
358 mFilter->apply(&el); 360 mFilter->apply(&el);
359 return el; 361 return el;
360} 362}
361 363
362QPtrList<Event> Calendar::events() 364Q3PtrList<Event> Calendar::events()
363{ 365{
364 QPtrList<Event> el = rawEvents(); 366 Q3PtrList<Event> el = rawEvents();
365 mFilter->apply(&el); 367 mFilter->apply(&el);
366 return el; 368 return el;
367} 369}
368void Calendar::addIncidenceBranch(Incidence *i) 370void Calendar::addIncidenceBranch(Incidence *i)
369{ 371{
370 addIncidence( i ); 372 addIncidence( i );
371 Incidence * inc; 373 Incidence * inc;
372 QPtrList<Incidence> Relations = i->relations(); 374 Q3PtrList<Incidence> Relations = i->relations();
373 for (inc=Relations.first();inc;inc=Relations.next()) { 375 for (inc=Relations.first();inc;inc=Relations.next()) {
374 addIncidenceBranch( inc ); 376 addIncidenceBranch( inc );
375 } 377 }
376} 378}
377 379
378bool Calendar::addIncidence(Incidence *i) 380bool Calendar::addIncidence(Incidence *i)
379{ 381{
380 Incidence::AddVisitor<Calendar> v(this); 382 Incidence::AddVisitor<Calendar> v(this);
381 if ( i->calID() == 0 ) 383 if ( i->calID() == 0 )
382 i->setCalID_block( mDefaultCalendar ); 384 i->setCalID_block( mDefaultCalendar );
383 i->setCalEnabled( true ); 385 i->setCalEnabled( true );
384 return i->accept(v); 386 return i->accept(v);
@@ -398,27 +400,27 @@ Incidence* Calendar::incidence( const QString& uid )
398 Incidence* i; 400 Incidence* i;
399 401
400 if( (i = todo( uid )) != 0 ) 402 if( (i = todo( uid )) != 0 )
401 return i; 403 return i;
402 if( (i = event( uid )) != 0 ) 404 if( (i = event( uid )) != 0 )
403 return i; 405 return i;
404 if( (i = journal( uid )) != 0 ) 406 if( (i = journal( uid )) != 0 )
405 return i; 407 return i;
406 408
407 return 0; 409 return 0;
408} 410}
409 411
410QPtrList<Todo> Calendar::todos() 412Q3PtrList<Todo> Calendar::todos()
411{ 413{
412 QPtrList<Todo> tl = rawTodos(); 414 Q3PtrList<Todo> tl = rawTodos();
413 mFilter->apply( &tl ); 415 mFilter->apply( &tl );
414 return tl; 416 return tl;
415} 417}
416 418
417// When this is called, the todo have already been added to the calendar. 419// When this is called, the todo have already been added to the calendar.
418// This method is only about linking related todos 420// This method is only about linking related todos
419void Calendar::setupRelations( Incidence *incidence ) 421void Calendar::setupRelations( Incidence *incidence )
420{ 422{
421 QString uid = incidence->uid(); 423 QString uid = incidence->uid();
422 qDebug("Calendar::setupRelations %s", incidence->summary().latin1()); 424 qDebug("Calendar::setupRelations %s", incidence->summary().latin1());
423 // First, go over the list of orphans and see if this is their parent 425 // First, go over the list of orphans and see if this is their parent
424 while( Incidence* i = mOrphans[ uid ] ) { 426 while( Incidence* i = mOrphans[ uid ] ) {
@@ -446,57 +448,57 @@ void Calendar::setupRelations( Incidence *incidence )
446 mOrphans.insert( incidence->relatedToUid(), incidence ); 448 mOrphans.insert( incidence->relatedToUid(), incidence );
447 mOrphanUids.insert( incidence->uid(), incidence ); 449 mOrphanUids.insert( incidence->uid(), incidence );
448 } 450 }
449 } 451 }
450} 452}
451 453
452// If a task with subtasks is deleted, move it's subtasks to the orphans list 454// If a task with subtasks is deleted, move it's subtasks to the orphans list
453void Calendar::removeRelations( Incidence *incidence ) 455void Calendar::removeRelations( Incidence *incidence )
454{ 456{
455 // qDebug("Calendar::removeRelations "); 457 // qDebug("Calendar::removeRelations ");
456 QString uid = incidence->uid(); 458 QString uid = incidence->uid();
457 459
458 QPtrList<Incidence> relations = incidence->relations(); 460 Q3PtrList<Incidence> relations = incidence->relations();
459 for( Incidence* i = relations.first(); i; i = relations.next() ) 461 for( Incidence* i = relations.first(); i; i = relations.next() )
460 if( !mOrphanUids.find( i->uid() ) ) { 462 if( !mOrphanUids.find( i->uid() ) ) {
461 mOrphans.insert( uid, i ); 463 mOrphans.insert( uid, i );
462 mOrphanUids.insert( i->uid(), i ); 464 mOrphanUids.insert( i->uid(), i );
463 i->setRelatedTo( 0 ); 465 i->setRelatedTo( 0 );
464 i->setRelatedToUid( uid ); 466 i->setRelatedToUid( uid );
465 } 467 }
466 468
467 // If this incidence is related to something else, tell that about it 469 // If this incidence is related to something else, tell that about it
468 if( incidence->relatedTo() ) 470 if( incidence->relatedTo() )
469 incidence->relatedTo()->removeRelation( incidence ); 471 incidence->relatedTo()->removeRelation( incidence );
470 472
471 // Remove this one from the orphans list 473 // Remove this one from the orphans list
472 if( mOrphanUids.remove( uid ) ) { 474 if( mOrphanUids.remove( uid ) ) {
473 QString r2uid = incidence->relatedToUid(); 475 QString r2uid = incidence->relatedToUid();
474 QPtrList<Incidence> tempList; 476 Q3PtrList<Incidence> tempList;
475 while( Incidence* i = mOrphans[ r2uid ] ) { 477 while( Incidence* i = mOrphans[ r2uid ] ) {
476 mOrphans.remove( r2uid ); 478 mOrphans.remove( r2uid );
477 if ( i != incidence ) tempList.append( i ); 479 if ( i != incidence ) tempList.append( i );
478 } 480 }
479 Incidence* inc = tempList.first(); 481 Incidence* inc = tempList.first();
480 while ( inc ) { 482 while ( inc ) {
481 mOrphans.insert( r2uid, inc ); 483 mOrphans.insert( r2uid, inc );
482 inc = tempList.next(); 484 inc = tempList.next();
483 } 485 }
484 } 486 }
485 // LR: and another big bad bug found 487 // LR: and another big bad bug found
486#if 0 488#if 0
487 // This incidence is located in the orphans list - it should be removed 489 // This incidence is located in the orphans list - it should be removed
488 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) { 490 if( !( incidence->relatedTo() != 0 && mOrphans.remove( incidence->relatedTo()->uid() ) ) ) {
489 // Removing wasn't that easy 491 // Removing wasn't that easy
490 for( QDictIterator<Incidence> it( mOrphans ); it.current(); ++it ) { 492 for( Q3DictIterator<Incidence> it( mOrphans ); it.current(); ++it ) {
491 if( it.current()->uid() == uid ) { 493 if( it.current()->uid() == uid ) {
492 mOrphans.remove( it.currentKey() ); 494 mOrphans.remove( it.currentKey() );
493 break; 495 break;
494 } 496 }
495 } 497 }
496 } 498 }
497#endif 499#endif
498} 500}
499 501
500void Calendar::registerObserver( Observer *observer ) 502void Calendar::registerObserver( Observer *observer )
501{ 503{
502 mObserver = observer; 504 mObserver = observer;
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index fbc40ad..5845f44 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -16,26 +16,26 @@
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29#include <qdict.h> 29#include <q3dict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35#include "calfilter.h" 35#include "calfilter.h"
36 36
37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 37//#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
38 38
39class KConfig; 39class KConfig;
40 40
41namespace KCal { 41namespace KCal {
@@ -79,25 +79,25 @@ public:
79 virtual bool mergeCalendarFile( QString name ) = 0; 79 virtual bool mergeCalendarFile( QString name ) = 0;
80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ,int * isDup = 0 ) = 0; 80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ,int * isDup = 0 ) = 0;
81 virtual Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0) = 0; 81 virtual Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0) = 0;
82 virtual void setSyncEventsReadOnly() = 0; 82 virtual void setSyncEventsReadOnly() = 0;
83 virtual void setSyncEventsEnabled() = 0; 83 virtual void setSyncEventsEnabled() = 0;
84 virtual void stopAllTodos() = 0; 84 virtual void stopAllTodos() = 0;
85 virtual void clearUndo( Incidence * newUndo ); 85 virtual void clearUndo( Incidence * newUndo );
86 86
87 /** 87 /**
88 Sync changes in memory to persistant storage. 88 Sync changes in memory to persistant storage.
89 */ 89 */
90 virtual void save() = 0; 90 virtual void save() = 0;
91 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 91 virtual Q3PtrList<Event> getExternLastSyncEvents() = 0;
92 virtual void removeSyncInfo( QString syncProfile) = 0; 92 virtual void removeSyncInfo( QString syncProfile) = 0;
93 virtual bool isSaving() { return false; } 93 virtual bool isSaving() { return false; }
94 94
95 /** 95 /**
96 Return the owner of the calendar's full name. 96 Return the owner of the calendar's full name.
97 */ 97 */
98 const QString &getOwner() const; 98 const QString &getOwner() const;
99 /** 99 /**
100 Set the owner of the calendar. Should be owner's full name. 100 Set the owner of the calendar. Should be owner's full name.
101 */ 101 */
102 void setOwner( const QString &os ); 102 void setOwner( const QString &os );
103 /** 103 /**
@@ -146,126 +146,126 @@ public:
146 /** 146 /**
147 Add an incidence to calendar. 147 Add an incidence to calendar.
148 148
149 @return true on success, false on error. 149 @return true on success, false on error.
150 */ 150 */
151 virtual bool addIncidence( Incidence * ); 151 virtual bool addIncidence( Incidence * );
152 152
153 // Adds an incidence and all relatedto incidences to the cal 153 // Adds an incidence and all relatedto incidences to the cal
154 void addIncidenceBranch( Incidence * ); 154 void addIncidenceBranch( Incidence * );
155 /** 155 /**
156 Return filtered list of all incidences of this calendar. 156 Return filtered list of all incidences of this calendar.
157 */ 157 */
158 virtual QPtrList<Incidence> incidences(); 158 virtual Q3PtrList<Incidence> incidences();
159 159
160 /** 160 /**
161 Return unfiltered list of all incidences of this calendar. 161 Return unfiltered list of all incidences of this calendar.
162 */ 162 */
163 virtual QPtrList<Incidence> rawIncidences(); 163 virtual Q3PtrList<Incidence> rawIncidences();
164 164
165 /** 165 /**
166 Adds a Event to this calendar object. 166 Adds a Event to this calendar object.
167 @param anEvent a pointer to the event to add 167 @param anEvent a pointer to the event to add
168 168
169 @return true on success, false on error. 169 @return true on success, false on error.
170 */ 170 */
171 virtual bool addEventNoDup( Event *event ) = 0; 171 virtual bool addEventNoDup( Event *event ) = 0;
172 virtual bool addAnniversaryNoDup( Event *event ) = 0; 172 virtual bool addAnniversaryNoDup( Event *event ) = 0;
173 virtual bool addEvent( Event *anEvent ) = 0; 173 virtual bool addEvent( Event *anEvent ) = 0;
174 /** 174 /**
175 Delete event from calendar. 175 Delete event from calendar.
176 */ 176 */
177 virtual void deleteEvent( Event * ) = 0; 177 virtual void deleteEvent( Event * ) = 0;
178 /** 178 /**
179 Retrieves an event on the basis of the unique string ID. 179 Retrieves an event on the basis of the unique string ID.
180 */ 180 */
181 virtual Event *event( const QString &UniqueStr ) = 0; 181 virtual Event *event( const QString &UniqueStr ) = 0;
182 virtual Event *event( QString, QString ) = 0; 182 virtual Event *event( QString, QString ) = 0;
183 /** 183 /**
184 Builds and then returns a list of all events that match for the 184 Builds and then returns a list of all events that match for the
185 date specified. useful for dayView, etc. etc. 185 date specified. useful for dayView, etc. etc.
186 The calendar filter is applied. 186 The calendar filter is applied.
187 */ 187 */
188 QPtrList<Event> events( const QDate &date, bool sorted = false); 188 Q3PtrList<Event> events( const QDate &date, bool sorted = false);
189 /** 189 /**
190 Get events, which occur on the given date. 190 Get events, which occur on the given date.
191 The calendar filter is applied. 191 The calendar filter is applied.
192 */ 192 */
193 QPtrList<Event> events( const QDateTime &qdt ); 193 Q3PtrList<Event> events( const QDateTime &qdt );
194 /** 194 /**
195 Get events in a range of dates. If inclusive is set to true, only events 195 Get events in a range of dates. If inclusive is set to true, only events
196 are returned, which are completely included in the range. 196 are returned, which are completely included in the range.
197 The calendar filter is applied. 197 The calendar filter is applied.
198 */ 198 */
199 QPtrList<Event> events( const QDate &start, const QDate &end, 199 Q3PtrList<Event> events( const QDate &start, const QDate &end,
200 bool inclusive = false); 200 bool inclusive = false);
201 /** 201 /**
202 Return filtered list of all events in calendar. 202 Return filtered list of all events in calendar.
203 */ 203 */
204 virtual QPtrList<Event> events(); 204 virtual Q3PtrList<Event> events();
205 /** 205 /**
206 Return unfiltered list of all events in calendar. 206 Return unfiltered list of all events in calendar.
207 */ 207 */
208 virtual QPtrList<Event> rawEvents() = 0; 208 virtual Q3PtrList<Event> rawEvents() = 0;
209 209
210 /** 210 /**
211 Add a todo to the todolist. 211 Add a todo to the todolist.
212 212
213 @return true on success, false on error. 213 @return true on success, false on error.
214 */ 214 */
215 virtual bool addTodo( Todo *todo ) = 0; 215 virtual bool addTodo( Todo *todo ) = 0;
216 virtual bool addTodoNoDup( Todo *todo ) = 0; 216 virtual bool addTodoNoDup( Todo *todo ) = 0;
217 /** 217 /**
218 Remove a todo from the todolist. 218 Remove a todo from the todolist.
219 */ 219 */
220 virtual void deleteTodo( Todo * ) = 0; 220 virtual void deleteTodo( Todo * ) = 0;
221 virtual void deleteJournal( Journal * ) = 0; 221 virtual void deleteJournal( Journal * ) = 0;
222 /** 222 /**
223 Return filterd list of todos. 223 Return filterd list of todos.
224 */ 224 */
225 virtual QPtrList<Todo> todos(); 225 virtual Q3PtrList<Todo> todos();
226 /** 226 /**
227 Searches todolist for an event with this unique string identifier, 227 Searches todolist for an event with this unique string identifier,
228 returns a pointer or null. 228 returns a pointer or null.
229 */ 229 */
230 virtual Todo *todo( const QString &uid ) = 0; 230 virtual Todo *todo( const QString &uid ) = 0;
231 virtual Todo *todo( QString, QString ) = 0; 231 virtual Todo *todo( QString, QString ) = 0;
232 /** 232 /**
233 Returns list of todos due on the specified date. 233 Returns list of todos due on the specified date.
234 */ 234 */
235 virtual QPtrList<Todo> todos( const QDate &date ) = 0; 235 virtual Q3PtrList<Todo> todos( const QDate &date ) = 0;
236 /** 236 /**
237 Return unfiltered list of todos. 237 Return unfiltered list of todos.
238 */ 238 */
239 virtual QPtrList<Todo> rawTodos() = 0; 239 virtual Q3PtrList<Todo> rawTodos() = 0;
240 240
241 /** 241 /**
242 Add a Journal entry to calendar. 242 Add a Journal entry to calendar.
243 243
244 @return true on success, false on error. 244 @return true on success, false on error.
245 */ 245 */
246 virtual bool addJournal( Journal * ) = 0; 246 virtual bool addJournal( Journal * ) = 0;
247 /** 247 /**
248 Return Journal for given date. 248 Return Journal for given date.
249 */ 249 */
250 virtual Journal *journal( const QDate & ) = 0; 250 virtual Journal *journal( const QDate & ) = 0;
251 virtual QPtrList<Journal> journals4Date( const QDate & ) = 0; 251 virtual Q3PtrList<Journal> journals4Date( const QDate & ) = 0;
252 /** 252 /**
253 Return Journal with given UID. 253 Return Journal with given UID.
254 */ 254 */
255 virtual Journal *journal( const QString &UID ) = 0; 255 virtual Journal *journal( const QString &UID ) = 0;
256 /** 256 /**
257 Return list of all Journal entries. 257 Return list of all Journal entries.
258 */ 258 */
259 virtual QPtrList<Journal> journals() = 0; 259 virtual Q3PtrList<Journal> journals() = 0;
260 260
261 /** 261 /**
262 Searches all incidence types for an incidence with this unique 262 Searches all incidence types for an incidence with this unique
263 string identifier, returns a pointer or null. 263 string identifier, returns a pointer or null.
264 */ 264 */
265 Incidence* incidence( const QString&UID ); 265 Incidence* incidence( const QString&UID );
266 266
267 /** 267 /**
268 Setup relations for an incidence. 268 Setup relations for an incidence.
269 */ 269 */
270 virtual void setupRelations( Incidence * ); 270 virtual void setupRelations( Incidence * );
271 /** 271 /**
@@ -326,35 +326,35 @@ public:
326 326
327 signals: 327 signals:
328 void calendarChanged(); 328 void calendarChanged();
329 void calendarSaved(); 329 void calendarSaved();
330 void calendarLoaded(); 330 void calendarLoaded();
331 void addAlarm(const QDateTime &qdt, const QString &noti ); 331 void addAlarm(const QDateTime &qdt, const QString &noti );
332 void removeAlarm(const QDateTime &qdt, const QString &noti ); 332 void removeAlarm(const QDateTime &qdt, const QString &noti );
333 333
334 protected: 334 protected:
335 /** 335 /**
336 Get unfiltered events, which occur on the given date. 336 Get unfiltered events, which occur on the given date.
337 */ 337 */
338 virtual QPtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0; 338 virtual Q3PtrList<Event> rawEventsForDate( const QDateTime &qdt ) = 0;
339 /** 339 /**
340 Get unfiltered events, which occur on the given date. 340 Get unfiltered events, which occur on the given date.
341 */ 341 */
342 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 342 virtual Q3PtrList<Event> rawEventsForDate( const QDate &date,
343 bool sorted = false ) = 0; 343 bool sorted = false ) = 0;
344 /** 344 /**
345 Get events in a range of dates. If inclusive is set to true, only events 345 Get events in a range of dates. If inclusive is set to true, only events
346 are returned, which are completely included in the range. 346 are returned, which are completely included in the range.
347 */ 347 */
348 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 348 virtual Q3PtrList<Event> rawEvents( const QDate &start, const QDate &end,
349 bool inclusive = false ) = 0; 349 bool inclusive = false ) = 0;
350 350
351 Incidence *mNextAlarmIncidence; 351 Incidence *mNextAlarmIncidence;
352 Incidence *mUndoIncidence; 352 Incidence *mUndoIncidence;
353 int mDefaultCalendar; 353 int mDefaultCalendar;
354 bool mDeleteIncidencesOnClose; 354 bool mDeleteIncidencesOnClose;
355 355
356private: 356private:
357 void init(); 357 void init();
358 358
359 QString mOwner; // who the calendar belongs to 359 QString mOwner; // who the calendar belongs to
360 QString mOwnerEmail; // email address of the owner 360 QString mOwnerEmail; // email address of the owner
@@ -367,19 +367,19 @@ private:
367 367
368 368
369 QString mTimeZoneId; 369 QString mTimeZoneId;
370 370
371 Observer *mObserver; 371 Observer *mObserver;
372 bool mNewObserver; 372 bool mNewObserver;
373 373
374 bool mModified; 374 bool mModified;
375 375
376 QString mLoadedProductId; 376 QString mLoadedProductId;
377 377
378 // This list is used to put together related todos 378 // This list is used to put together related todos
379 QDict<Incidence> mOrphans; 379 Q3Dict<Incidence> mOrphans;
380 QDict<Incidence> mOrphanUids; 380 Q3Dict<Incidence> mOrphanUids;
381}; 381};
382 382
383} 383}
384 384
385#endif 385#endif
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index ce3cd09..cb52b7c 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -13,25 +13,25 @@
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kconfig.h> 28#include <kconfig.h>
29#include <kglobal.h> 29#include <kglobal.h>
30#include <klocale.h> 30#include <klocale.h>
31 31
32#include "vcaldrag.h" 32#include "vcaldrag.h"
33#include "vcalformat.h" 33#include "vcalformat.h"
34#include "icalformat.h" 34#include "icalformat.h"
35#include "exceptions.h" 35#include "exceptions.h"
36#include "incidence.h" 36#include "incidence.h"
37#include "journal.h" 37#include "journal.h"
@@ -183,33 +183,33 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
183 } 183 }
184 } 184 }
185 return retVal; 185 return retVal;
186} 186}
187 187
188bool CalendarLocal::mergeCalendar( Calendar* remote ) 188bool CalendarLocal::mergeCalendar( Calendar* remote )
189{ 189{
190 // 1 look for raw inc in local 190 // 1 look for raw inc in local
191 // if inc not in remote, delete in local 191 // if inc not in remote, delete in local
192 // 2 look for raw inc in remote 192 // 2 look for raw inc in remote
193 // if inc in local, replace it 193 // if inc in local, replace it
194 // if not in local, add it to default calendar 194 // if not in local, add it to default calendar
195 QPtrList<Incidence> localInc = rawIncidences(); 195 Q3PtrList<Incidence> localInc = rawIncidences();
196 Incidence* inL = localInc.first(); 196 Incidence* inL = localInc.first();
197 while ( inL ) { 197 while ( inL ) {
198 if ( ! inL->isReadOnly () ) 198 if ( ! inL->isReadOnly () )
199 if ( !remote->incidenceForUid( inL->uid(), true )) 199 if ( !remote->incidenceForUid( inL->uid(), true ))
200 deleteIncidence( inL ); 200 deleteIncidence( inL );
201 inL = localInc.next(); 201 inL = localInc.next();
202 } 202 }
203 QPtrList<Incidence> er = remote->rawIncidences(); 203 Q3PtrList<Incidence> er = remote->rawIncidences();
204 Incidence* inR = er.first(); 204 Incidence* inR = er.first();
205 while ( inR ) { 205 while ( inR ) {
206 inL = incidenceForUid( inR->uid(),false ); 206 inL = incidenceForUid( inR->uid(),false );
207 if ( inL ) { 207 if ( inL ) {
208 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) { 208 if ( ! inL->isReadOnly () || inL->uid().left(15) == QString("last-syncEvent-") ) {
209 int calID = inL->calID(); 209 int calID = inL->calID();
210 deleteIncidence( inL ); 210 deleteIncidence( inL );
211 inL = inR->clone(); 211 inL = inR->clone();
212 inL->setCalID_block( calID ); 212 inL->setCalID_block( calID );
213 addIncidence( inL ); 213 addIncidence( inL );
214 } 214 }
215 } else { 215 } else {
@@ -250,65 +250,65 @@ void CalendarLocal::setSyncEventsReadOnly()
250 while ( ev ) { 250 while ( ev ) {
251 if ( ev->uid().left(15) == QString("last-syncEvent-") ) { 251 if ( ev->uid().left(15) == QString("last-syncEvent-") ) {
252 ev->setReadOnly( true ); 252 ev->setReadOnly( true );
253 } 253 }
254 ev = mEventList.next(); 254 ev = mEventList.next();
255 } 255 }
256} 256}
257 257
258void CalendarLocal::addCalendar( Calendar* cal ) 258void CalendarLocal::addCalendar( Calendar* cal )
259{ 259{
260 cal->setDontDeleteIncidencesOnClose(); 260 cal->setDontDeleteIncidencesOnClose();
261 setSyncEventsEnabled(); 261 setSyncEventsEnabled();
262 QPtrList<Incidence> incList; 262 Q3PtrList<Incidence> incList;
263 { 263 {
264 QPtrList<Event> EventList = cal->rawEvents(); 264 Q3PtrList<Event> EventList = cal->rawEvents();
265 Event * ev = EventList.first(); 265 Event * ev = EventList.first();
266 while ( ev ) { 266 while ( ev ) {
267 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) { 267 if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
268 ev->setCalID_block( 1 ); 268 ev->setCalID_block( 1 );
269 } 269 }
270 Event * se = event( ev->uid() ); 270 Event * se = event( ev->uid() );
271 if ( se ) 271 if ( se )
272 incList.append( se ); 272 incList.append( se );
273 ev->unRegisterObserver( cal ); 273 ev->unRegisterObserver( cal );
274 ev->registerObserver( this ); 274 ev->registerObserver( this );
275 mEventList.append( ev ); 275 mEventList.append( ev );
276 ev = EventList.next(); 276 ev = EventList.next();
277 } 277 }
278 278
279 } 279 }
280 { 280 {
281 281
282 QPtrList<Todo> TodoList = cal->rawTodos(); 282 Q3PtrList<Todo> TodoList = cal->rawTodos();
283 Todo * ev = TodoList.first(); 283 Todo * ev = TodoList.first();
284 while ( ev ) { 284 while ( ev ) {
285 ev->resetRelatedTo(); 285 ev->resetRelatedTo();
286 Todo * se = todo( ev->uid() ); 286 Todo * se = todo( ev->uid() );
287 if ( se ) 287 if ( se )
288 deleteTodo( se ); 288 deleteTodo( se );
289 ev = TodoList.next(); 289 ev = TodoList.next();
290 } 290 }
291 //TodoList = cal->rawTodos(); 291 //TodoList = cal->rawTodos();
292 ev = TodoList.first(); 292 ev = TodoList.first();
293 while ( ev ) { 293 while ( ev ) {
294 ev->unRegisterObserver( cal ); 294 ev->unRegisterObserver( cal );
295 ev->registerObserver( this ); 295 ev->registerObserver( this );
296 mTodoList.append( ev ); 296 mTodoList.append( ev );
297 setupRelations( ev ); 297 setupRelations( ev );
298 ev = TodoList.next(); 298 ev = TodoList.next();
299 } 299 }
300 } 300 }
301 { 301 {
302 QPtrList<Journal> JournalList = cal->journals(); 302 Q3PtrList<Journal> JournalList = cal->journals();
303 Journal * ev = JournalList.first(); 303 Journal * ev = JournalList.first();
304 while ( ev ) { 304 while ( ev ) {
305 Journal * se = journal( ev->uid() ); 305 Journal * se = journal( ev->uid() );
306 if ( se ) 306 if ( se )
307 incList.append( se ); 307 incList.append( se );
308 ev->unRegisterObserver( cal ); 308 ev->unRegisterObserver( cal );
309 ev->registerObserver( this ); 309 ev->registerObserver( this );
310 mJournalList.append( ev ); 310 mJournalList.append( ev );
311 ev = JournalList.next(); 311 ev = JournalList.next();
312 } 312 }
313 } 313 }
314 { 314 {
@@ -472,66 +472,66 @@ void CalendarLocal::deleteTodo( Todo *todo )
472 // Handle orphaned children 472 // Handle orphaned children
473 removeRelations( todo ); 473 removeRelations( todo );
474 clearUndo(todo); 474 clearUndo(todo);
475 475
476 if ( mTodoList.removeRef( todo ) ) { 476 if ( mTodoList.removeRef( todo ) ) {
477 setModified( true ); 477 setModified( true );
478 } 478 }
479 Todo* dup = todoForUid( uid ); 479 Todo* dup = todoForUid( uid );
480 if ( dup ) 480 if ( dup )
481 setupRelations( dup ); 481 setupRelations( dup );
482} 482}
483 483
484QPtrList<Todo> CalendarLocal::rawTodos() 484Q3PtrList<Todo> CalendarLocal::rawTodos()
485{ 485{
486 QPtrList<Todo> el; 486 Q3PtrList<Todo> el;
487 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() ) 487 for ( Todo *it = mTodoList.first(); it; it = mTodoList.next() )
488 if ( it->calEnabled() ) el.append( it ); 488 if ( it->calEnabled() ) el.append( it );
489 return el; 489 return el;
490} 490}
491Todo *CalendarLocal::todo( QString syncProf, QString id ) 491Todo *CalendarLocal::todo( QString syncProf, QString id )
492{ 492{
493 Todo *todo; 493 Todo *todo;
494 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 494 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
495 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo; 495 if ( todo->calEnabled() && todo->getID( syncProf ) == id ) return todo;
496 } 496 }
497 497
498 return 0; 498 return 0;
499} 499}
500void CalendarLocal::removeSyncInfo( QString syncProfile) 500void CalendarLocal::removeSyncInfo( QString syncProfile)
501{ 501{
502 QPtrList<Incidence> all = rawIncidences() ; 502 Q3PtrList<Incidence> all = rawIncidences() ;
503 Incidence *inc; 503 Incidence *inc;
504 for ( inc = all.first(); inc; inc = all.next() ) { 504 for ( inc = all.first(); inc; inc = all.next() ) {
505 inc->removeID( syncProfile ); 505 inc->removeID( syncProfile );
506 } 506 }
507 if ( syncProfile.isEmpty() ) { 507 if ( syncProfile.isEmpty() ) {
508 QPtrList<Event> el; 508 Q3PtrList<Event> el;
509 Event *todo; 509 Event *todo;
510 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 510 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
511 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 511 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
512 el.append( todo ); 512 el.append( todo );
513 } 513 }
514 for ( todo = el.first(); todo; todo = el.next() ) { 514 for ( todo = el.first(); todo; todo = el.next() ) {
515 deleteIncidence ( todo ); 515 deleteIncidence ( todo );
516 } 516 }
517 } else { 517 } else {
518 Event *lse = event( "last-syncEvent-"+ syncProfile); 518 Event *lse = event( "last-syncEvent-"+ syncProfile);
519 if ( lse ) 519 if ( lse )
520 deleteIncidence ( lse ); 520 deleteIncidence ( lse );
521 } 521 }
522} 522}
523QPtrList<Event> CalendarLocal::getExternLastSyncEvents() 523Q3PtrList<Event> CalendarLocal::getExternLastSyncEvents()
524{ 524{
525 QPtrList<Event> el; 525 Q3PtrList<Event> el;
526 Event *todo; 526 Event *todo;
527 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { 527 for ( todo = mEventList.first(); todo; todo = mEventList.next() ) {
528 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) 528 if ( todo->uid().left( 15 ) == QString("last-syncEvent-") )
529 if ( todo->summary().left(3) == "E: " ) 529 if ( todo->summary().left(3) == "E: " )
530 el.append( todo ); 530 el.append( todo );
531 } 531 }
532 532
533 return el; 533 return el;
534 534
535} 535}
536Event *CalendarLocal::event( QString syncProf, QString id ) 536Event *CalendarLocal::event( QString syncProf, QString id )
537{ 537{
@@ -676,27 +676,27 @@ void CalendarLocal::deRegisterAlarm()
676{ 676{
677 if ( mLastAlarmNotificationString.isNull() ) 677 if ( mLastAlarmNotificationString.isNull() )
678 return; 678 return;
679 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() ); 679 //qDebug("-- deregister Alarm %s ", mLastAlarmNotificationString.latin1() );
680 680
681 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); 681 emit removeAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString );
682 mNextAlarmEventDateTime = QDateTime(); 682 mNextAlarmEventDateTime = QDateTime();
683// #ifndef DESKTOP_VERSION 683// #ifndef DESKTOP_VERSION
684// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() ); 684// AlarmServer::deleteAlarm (mNextAlarmDateTime ,"koalarm" ,mLastAlarmNotificationString.latin1() );
685// #endif 685// #endif
686} 686}
687 687
688QPtrList<Todo> CalendarLocal::todos( const QDate &date ) 688Q3PtrList<Todo> CalendarLocal::todos( const QDate &date )
689{ 689{
690 QPtrList<Todo> todos; 690 Q3PtrList<Todo> todos;
691 691
692 Todo *todo; 692 Todo *todo;
693 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 693 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
694 if ( !todo->calEnabled() ) continue; 694 if ( !todo->calEnabled() ) continue;
695 if ( todo->hasDueDate() && todo->dtDue().date() == date ) { 695 if ( todo->hasDueDate() && todo->dtDue().date() == date ) {
696 todos.append( todo ); 696 todos.append( todo );
697 } 697 }
698 } 698 }
699 699
700 filter()->apply( &todos ); 700 filter()->apply( &todos );
701 return todos; 701 return todos;
702} 702}
@@ -777,44 +777,44 @@ Alarm::List CalendarLocal::alarms( const QDateTime &from, const QDateTime &to )
777 Todo *t; 777 Todo *t;
778 for( t = mTodoList.first(); t; t = mTodoList.next() ) { 778 for( t = mTodoList.first(); t; t = mTodoList.next() ) {
779 if ( !t->calEnabled() ) continue; 779 if ( !t->calEnabled() ) continue;
780 appendAlarms( alarms, t, from, to ); 780 appendAlarms( alarms, t, from, to );
781 } 781 }
782 782
783 return alarms; 783 return alarms;
784} 784}
785 785
786void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence, 786void CalendarLocal::appendAlarms( Alarm::List &alarms, Incidence *incidence,
787 const QDateTime &from, const QDateTime &to ) 787 const QDateTime &from, const QDateTime &to )
788{ 788{
789 QPtrList<Alarm> alarmList = incidence->alarms(); 789 Q3PtrList<Alarm> alarmList = incidence->alarms();
790 Alarm *alarm; 790 Alarm *alarm;
791 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 791 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
792// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text() 792// kdDebug(5800) << "CalendarLocal::appendAlarms() '" << alarm->text()
793// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl; 793// << "': " << alarm->time().toString() << " - " << alarm->enabled() << endl;
794 if ( alarm->enabled() ) { 794 if ( alarm->enabled() ) {
795 if ( alarm->time() >= from && alarm->time() <= to ) { 795 if ( alarm->time() >= from && alarm->time() <= to ) {
796 alarms.append( alarm ); 796 alarms.append( alarm );
797 } 797 }
798 } 798 }
799 } 799 }
800} 800}
801 801
802void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms, 802void CalendarLocal::appendRecurringAlarms( Alarm::List &alarms,
803 Incidence *incidence, 803 Incidence *incidence,
804 const QDateTime &from, 804 const QDateTime &from,
805 const QDateTime &to ) 805 const QDateTime &to )
806{ 806{
807 807
808 QPtrList<Alarm> alarmList = incidence->alarms(); 808 Q3PtrList<Alarm> alarmList = incidence->alarms();
809 Alarm *alarm; 809 Alarm *alarm;
810 QDateTime qdt; 810 QDateTime qdt;
811 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) { 811 for( alarm = alarmList.first(); alarm; alarm = alarmList.next() ) {
812 if (incidence->recursOn(from.date())) { 812 if (incidence->recursOn(from.date())) {
813 qdt.setTime(alarm->time().time()); 813 qdt.setTime(alarm->time().time());
814 qdt.setDate(from.date()); 814 qdt.setDate(from.date());
815 } 815 }
816 else qdt = alarm->time(); 816 else qdt = alarm->time();
817 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1()); 817 // qDebug("1 %s %s %s", qdt.toString().latin1(), from.toString().latin1(), to.toString().latin1());
818 if ( alarm->enabled() ) { 818 if ( alarm->enabled() ) {
819 if ( qdt >= from && qdt <= to ) { 819 if ( qdt >= from && qdt <= to ) {
820 alarms.append( alarm ); 820 alarms.append( alarm );
@@ -835,27 +835,27 @@ void CalendarLocal::update( IncidenceBase *incidence )
835 // or internally in the Event itself when certain things change. 835 // or internally in the Event itself when certain things change.
836 // need to verify with ical documentation. 836 // need to verify with ical documentation.
837 837
838 setModified( true ); 838 setModified( true );
839} 839}
840 840
841void CalendarLocal::insertEvent( Event *event ) 841void CalendarLocal::insertEvent( Event *event )
842{ 842{
843 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event ); 843 if ( mEventList.findRef( event ) < 0 ) mEventList.append( event );
844} 844}
845 845
846 846
847QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted ) 847Q3PtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
848{ 848{
849 QPtrList<Event> eventList; 849 Q3PtrList<Event> eventList;
850 850
851 Event *event; 851 Event *event;
852 for( event = mEventList.first(); event; event = mEventList.next() ) { 852 for( event = mEventList.first(); event; event = mEventList.next() ) {
853 if ( !event->calEnabled() ) continue; 853 if ( !event->calEnabled() ) continue;
854 if ( event->doesRecur() ) { 854 if ( event->doesRecur() ) {
855 if ( event->isMultiDay() ) { 855 if ( event->isMultiDay() ) {
856 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() ); 856 int extraDays = event->dtStart().date().daysTo( event->dtEnd().date() );
857 int i; 857 int i;
858 for ( i = 0; i <= extraDays; i++ ) { 858 for ( i = 0; i <= extraDays; i++ ) {
859 if ( event->recursOn( qd.addDays( -i ) ) ) { 859 if ( event->recursOn( qd.addDays( -i ) ) ) {
860 eventList.append( event ); 860 eventList.append( event );
861 break; 861 break;
@@ -869,70 +869,70 @@ QPtrList<Event> CalendarLocal::rawEventsForDate( const QDate &qd, bool sorted )
869 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) { 869 if ( event->dtStart().date() <= qd && event->dtEnd().date() >= qd ) {
870 eventList.append( event ); 870 eventList.append( event );
871 } 871 }
872 } 872 }
873 } 873 }
874 874
875 if ( !sorted ) { 875 if ( !sorted ) {
876 return eventList; 876 return eventList;
877 } 877 }
878 878
879 // kdDebug(5800) << "Sorting events for date\n" << endl; 879 // kdDebug(5800) << "Sorting events for date\n" << endl;
880 // now, we have to sort it based on dtStart.time() 880 // now, we have to sort it based on dtStart.time()
881 QPtrList<Event> eventListSorted; 881 Q3PtrList<Event> eventListSorted;
882 Event *sortEvent; 882 Event *sortEvent;
883 for ( event = eventList.first(); event; event = eventList.next() ) { 883 for ( event = eventList.first(); event; event = eventList.next() ) {
884 sortEvent = eventListSorted.first(); 884 sortEvent = eventListSorted.first();
885 int i = 0; 885 int i = 0;
886 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() ) 886 while ( sortEvent && event->dtStart().time()>=sortEvent->dtStart().time() )
887 { 887 {
888 i++; 888 i++;
889 sortEvent = eventListSorted.next(); 889 sortEvent = eventListSorted.next();
890 } 890 }
891 eventListSorted.insert( i, event ); 891 eventListSorted.insert( i, event );
892 } 892 }
893 return eventListSorted; 893 return eventListSorted;
894} 894}
895 895
896 896
897QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end, 897Q3PtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
898 bool inclusive ) 898 bool inclusive )
899{ 899{
900 Event *event = 0; 900 Event *event = 0;
901 901
902 QPtrList<Event> eventList; 902 Q3PtrList<Event> eventList;
903 903
904 // Get non-recurring events 904 // Get non-recurring events
905 for( event = mEventList.first(); event; event = mEventList.next() ) { 905 for( event = mEventList.first(); event; event = mEventList.next() ) {
906 if ( !event->calEnabled() ) continue; 906 if ( !event->calEnabled() ) continue;
907 if ( event->doesRecur() ) { 907 if ( event->doesRecur() ) {
908 QDate rStart = event->dtStart().date(); 908 QDate rStart = event->dtStart().date();
909 bool found = false; 909 bool found = false;
910 if ( inclusive ) { 910 if ( inclusive ) {
911 if ( rStart >= start && rStart <= end ) { 911 if ( rStart >= start && rStart <= end ) {
912 // Start date of event is in range. Now check for end date. 912 // Start date of event is in range. Now check for end date.
913 // if duration is negative, event recurs forever, so do not include it. 913 // if duration is negative, event recurs forever, so do not include it.
914 if ( event->recurrence()->duration() == 0 ) { // End date set 914 if ( event->recurrence()->duration() == 0 ) { // End date set
915 QDate rEnd = event->recurrence()->endDate(); 915 QDate rEnd = event->recurrence()->endDate();
916 if ( rEnd >= start && rEnd <= end ) { // End date within range 916 if ( rEnd >= start && rEnd <= end ) { // End date within range
917 found = true; 917 found = true;
918 } 918 }
919 } else if ( event->recurrence()->duration() > 0 ) { // Duration set 919 } else if ( event->recurrence()->duration() > 0 ) { // Duration set
920 // TODO: Calculate end date from duration. Should be done in Event 920 // TODO: Calculate end date from duration. Should be done in Event
921 // For now exclude all events with a duration. 921 // For now exclude all events with a duration.
922 } 922 }
923 } 923 }
924 } else { 924 } else {
925 bool founOne; 925 bool founOne;
926 QDate next = event->getNextOccurence( start, &founOne ).date(); 926 QDate next = event->getNextOccurence( (QDateTime)start, &founOne ).date();
927 if ( founOne ) { 927 if ( founOne ) {
928 if ( next <= end ) { 928 if ( next <= end ) {
929 found = true; 929 found = true;
930 } 930 }
931 } 931 }
932 932
933 /* 933 /*
934 // crap !!! 934 // crap !!!
935 if ( rStart <= end ) { // Start date not after range 935 if ( rStart <= end ) { // Start date not after range
936 if ( rStart >= start ) { // Start date within range 936 if ( rStart >= start ) { // Start date within range
937 found = true; 937 found = true;
938 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever 938 } else if ( event->recurrence()->duration() == -1 ) { // Recurs forever
@@ -963,32 +963,32 @@ QPtrList<Event> CalendarLocal::rawEvents( const QDate &start, const QDate &end,
963 } 963 }
964 } else { 964 } else {
965 if ( ( e >= start && s <= end ) ) { 965 if ( ( e >= start && s <= end ) ) {
966 eventList.append( event ); 966 eventList.append( event );
967 } 967 }
968 } 968 }
969 } 969 }
970 } 970 }
971 971
972 return eventList; 972 return eventList;
973} 973}
974 974
975QPtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt ) 975Q3PtrList<Event> CalendarLocal::rawEventsForDate( const QDateTime &qdt )
976{ 976{
977 return rawEventsForDate( qdt.date() ); 977 return rawEventsForDate( qdt.date() );
978} 978}
979 979
980QPtrList<Event> CalendarLocal::rawEvents() 980Q3PtrList<Event> CalendarLocal::rawEvents()
981{ 981{
982 QPtrList<Event> el; 982 Q3PtrList<Event> el;
983 for ( Event *it = mEventList.first(); it; it = mEventList.next() ) 983 for ( Event *it = mEventList.first(); it; it = mEventList.next() )
984 if ( it->calEnabled() ) el.append( it ); 984 if ( it->calEnabled() ) el.append( it );
985 return el; 985 return el;
986} 986}
987 987
988bool CalendarLocal::addJournal(Journal *journal) 988bool CalendarLocal::addJournal(Journal *journal)
989{ 989{
990 mJournalList.append(journal); 990 mJournalList.append(journal);
991 991
992 journal->registerObserver( this ); 992 journal->registerObserver( this );
993 993
994 setModified( true ); 994 setModified( true );
@@ -997,27 +997,27 @@ bool CalendarLocal::addJournal(Journal *journal)
997 journal->setCalEnabled( true ); 997 journal->setCalEnabled( true );
998 return true; 998 return true;
999} 999}
1000 1000
1001void CalendarLocal::deleteJournal( Journal *journal ) 1001void CalendarLocal::deleteJournal( Journal *journal )
1002{ 1002{
1003 clearUndo(journal); 1003 clearUndo(journal);
1004 if ( mJournalList.removeRef(journal) ) { 1004 if ( mJournalList.removeRef(journal) ) {
1005 setModified( true ); 1005 setModified( true );
1006 } 1006 }
1007} 1007}
1008 1008
1009QPtrList<Journal> CalendarLocal::journals4Date( const QDate & date ) 1009Q3PtrList<Journal> CalendarLocal::journals4Date( const QDate & date )
1010{ 1010{
1011 QPtrList<Journal> el; 1011 Q3PtrList<Journal> el;
1012 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1012 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1013 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it ); 1013 if ( it->calEnabled() && it->dtStart().date() == date) el.append( it );
1014 return el; 1014 return el;
1015} 1015}
1016Journal *CalendarLocal::journal( const QDate &date ) 1016Journal *CalendarLocal::journal( const QDate &date )
1017{ 1017{
1018// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 1018// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
1019 1019
1020 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1020 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1021 if ( it->calEnabled() && it->dtStart().date() == date ) 1021 if ( it->calEnabled() && it->dtStart().date() == date )
1022 return it; 1022 return it;
1023 1023
@@ -1031,55 +1031,55 @@ Journal *CalendarLocal::journal( const QString &uid )
1031 if ( it->calEnabled() && it->uid() == uid ) { 1031 if ( it->calEnabled() && it->uid() == uid ) {
1032 if ( retVal ) { 1032 if ( retVal ) {
1033 if ( retVal->calID() > it->calID() ) { 1033 if ( retVal->calID() > it->calID() ) {
1034 retVal = it; 1034 retVal = it;
1035 } 1035 }
1036 } else { 1036 } else {
1037 retVal = it; 1037 retVal = it;
1038 } 1038 }
1039 } 1039 }
1040 return retVal; 1040 return retVal;
1041} 1041}
1042 1042
1043QPtrList<Journal> CalendarLocal::journals() 1043Q3PtrList<Journal> CalendarLocal::journals()
1044{ 1044{
1045 QPtrList<Journal> el; 1045 Q3PtrList<Journal> el;
1046 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 1046 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
1047 if ( it->calEnabled() ) el.append( it ); 1047 if ( it->calEnabled() ) el.append( it );
1048 return el; 1048 return el;
1049} 1049}
1050void CalendarLocal::setCalendarRemove( int id ) 1050void CalendarLocal::setCalendarRemove( int id )
1051{ 1051{
1052 1052
1053 { 1053 {
1054 QPtrList<Event> EventList = mEventList; 1054 Q3PtrList<Event> EventList = mEventList;
1055 Event * ev = EventList.first(); 1055 Event * ev = EventList.first();
1056 while ( ev ) { 1056 while ( ev ) {
1057 if ( ev->calID() == id && ev->uid().left( 15 ) != QString("last-syncEvent-") ) 1057 if ( ev->calID() == id && ev->uid().left( 15 ) != QString("last-syncEvent-") )
1058 deleteEvent( ev ); 1058 deleteEvent( ev );
1059 ev = EventList.next(); 1059 ev = EventList.next();
1060 } 1060 }
1061 } 1061 }
1062 { 1062 {
1063 1063
1064 QPtrList<Todo> TodoList = mTodoList; 1064 Q3PtrList<Todo> TodoList = mTodoList;
1065 Todo * ev = TodoList.first(); 1065 Todo * ev = TodoList.first();
1066 while ( ev ) { 1066 while ( ev ) {
1067 if ( ev->calID() == id ) 1067 if ( ev->calID() == id )
1068 deleteTodo( ev ); 1068 deleteTodo( ev );
1069 ev = TodoList.next(); 1069 ev = TodoList.next();
1070 } 1070 }
1071 } 1071 }
1072 { 1072 {
1073 QPtrList<Journal> JournalList = mJournalList; 1073 Q3PtrList<Journal> JournalList = mJournalList;
1074 Journal * ev = JournalList.first(); 1074 Journal * ev = JournalList.first();
1075 while ( ev ) { 1075 while ( ev ) {
1076 if ( ev->calID() == id ) 1076 if ( ev->calID() == id )
1077 deleteJournal( ev ); 1077 deleteJournal( ev );
1078 ev = JournalList.next(); 1078 ev = JournalList.next();
1079 } 1079 }
1080 } 1080 }
1081 1081
1082 clearUndo(0); 1082 clearUndo(0);
1083 1083
1084} 1084}
1085 1085
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 1ceabce..1df65c7 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -14,24 +14,26 @@
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_CALENDARLOCAL_H 22#ifndef KCAL_CALENDARLOCAL_H
23#define KCAL_CALENDARLOCAL_H 23#define KCAL_CALENDARLOCAL_H
24 24
25#include "calendar.h" 25#include "calendar.h"
26//Added by qt3to4:
27#include <Q3PtrList>
26 28
27namespace KCal { 29namespace KCal {
28 30
29class CalFormat; 31class CalFormat;
30 32
31/** 33/**
32 This class provides a calendar stored as a local file. 34 This class provides a calendar stored as a local file.
33*/ 35*/
34class CalendarLocal : public Calendar 36class CalendarLocal : public Calendar
35{ 37{
36 public: 38 public:
37 /** 39 /**
@@ -84,76 +86,76 @@ class CalendarLocal : public Calendar
84 /** 86 /**
85 Deletes an event from this calendar. 87 Deletes an event from this calendar.
86 */ 88 */
87 void deleteEvent( Event *event ); 89 void deleteEvent( Event *event );
88 90
89 /** 91 /**
90 Retrieves an event on the basis of the unique string ID. 92 Retrieves an event on the basis of the unique string ID.
91 */ 93 */
92 Event *event( const QString &uid ); 94 Event *event( const QString &uid );
93 /** 95 /**
94 Return unfiltered list of all events in calendar. 96 Return unfiltered list of all events in calendar.
95 */ 97 */
96 QPtrList<Event> rawEvents(); 98 Q3PtrList<Event> rawEvents();
97 QPtrList<Event> getExternLastSyncEvents(); 99 Q3PtrList<Event> getExternLastSyncEvents();
98 /** 100 /**
99 Add a todo to the todolist. 101 Add a todo to the todolist.
100 */ 102 */
101 bool addTodo( Todo *todo ); 103 bool addTodo( Todo *todo );
102 bool addTodoNoDup( Todo *todo ); 104 bool addTodoNoDup( Todo *todo );
103 /** 105 /**
104 Remove a todo from the todolist. 106 Remove a todo from the todolist.
105 */ 107 */
106 void deleteTodo( Todo * ); 108 void deleteTodo( Todo * );
107 /** 109 /**
108 Searches todolist for an event with this unique string identifier, 110 Searches todolist for an event with this unique string identifier,
109 returns a pointer or null. 111 returns a pointer or null.
110 */ 112 */
111 Todo *todo( const QString &uid ); 113 Todo *todo( const QString &uid );
112 /** 114 /**
113 Return list of all todos. 115 Return list of all todos.
114 */ 116 */
115 QPtrList<Todo> rawTodos(); 117 Q3PtrList<Todo> rawTodos();
116 /** 118 /**
117 Returns list of todos due on the specified date. 119 Returns list of todos due on the specified date.
118 */ 120 */
119 QPtrList<Todo> todos( const QDate &date ); 121 Q3PtrList<Todo> todos( const QDate &date );
120 /** 122 /**
121 Return list of all todos. 123 Return list of all todos.
122 124
123 Workaround because compiler does not recognize function of base class. 125 Workaround because compiler does not recognize function of base class.
124 */ 126 */
125 QPtrList<Todo> todos() { return Calendar::todos(); } 127 Q3PtrList<Todo> todos() { return Calendar::todos(); }
126 128
127 /** 129 /**
128 Add a Journal entry to calendar. 130 Add a Journal entry to calendar.
129 */ 131 */
130 bool addJournal( Journal * ); 132 bool addJournal( Journal * );
131 /** 133 /**
132 Remove a Journal from the calendar. 134 Remove a Journal from the calendar.
133 */ 135 */
134 void deleteJournal( Journal * ); 136 void deleteJournal( Journal * );
135 /** 137 /**
136 Return Journal for given date. 138 Return Journal for given date.
137 */ 139 */
138 Journal *journal( const QDate & ); 140 Journal *journal( const QDate & );
139 QPtrList<Journal> journals4Date( const QDate & ); 141 Q3PtrList<Journal> journals4Date( const QDate & );
140 /** 142 /**
141 Return Journal with given UID. 143 Return Journal with given UID.
142 */ 144 */
143 Journal *journal( const QString &uid ); 145 Journal *journal( const QString &uid );
144 /** 146 /**
145 Return list of all Journals stored in calendar. 147 Return list of all Journals stored in calendar.
146 */ 148 */
147 QPtrList<Journal> journals(); 149 Q3PtrList<Journal> journals();
148 150
149 /** 151 /**
150 Return all alarms, which ocur in the given time interval. 152 Return all alarms, which ocur in the given time interval.
151 */ 153 */
152 Alarm::List alarms( const QDateTime &from, const QDateTime &to ); 154 Alarm::List alarms( const QDateTime &from, const QDateTime &to );
153 155
154 /** 156 /**
155 Return all alarms, which ocur before given date. 157 Return all alarms, which ocur before given date.
156 */ 158 */
157 Alarm::List alarmsTo( const QDateTime &to ); 159 Alarm::List alarmsTo( const QDateTime &to );
158 160
159 QDateTime nextAlarm( int daysTo ) ; 161 QDateTime nextAlarm( int daysTo ) ;
@@ -165,34 +167,34 @@ class CalendarLocal : public Calendar
165 QString nextSummary() const ; 167 QString nextSummary() const ;
166 /** 168 /**
167 This method should be called whenever a Event is modified directly 169 This method should be called whenever a Event is modified directly
168 via it's pointer. It makes sure that the calendar is internally 170 via it's pointer. It makes sure that the calendar is internally
169 consistent. 171 consistent.
170 */ 172 */
171 void update( IncidenceBase *incidence ); 173 void update( IncidenceBase *incidence );
172 174
173 /** 175 /**
174 Builds and then returns a list of all events that match for the 176 Builds and then returns a list of all events that match for the
175 date specified. useful for dayView, etc. etc. 177 date specified. useful for dayView, etc. etc.
176 */ 178 */
177 QPtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false ); 179 Q3PtrList<Event> rawEventsForDate( const QDate &date, bool sorted = false );
178 /** 180 /**
179 Get unfiltered events for date \a qdt. 181 Get unfiltered events for date \a qdt.
180 */ 182 */
181 QPtrList<Event> rawEventsForDate( const QDateTime &qdt ); 183 Q3PtrList<Event> rawEventsForDate( const QDateTime &qdt );
182 /** 184 /**
183 Get unfiltered events in a range of dates. If inclusive is set to true, 185 Get unfiltered events in a range of dates. If inclusive is set to true,
184 only events are returned, which are completely included in the range. 186 only events are returned, which are completely included in the range.
185 */ 187 */
186 QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 188 Q3PtrList<Event> rawEvents( const QDate &start, const QDate &end,
187 bool inclusive = false ); 189 bool inclusive = false );
188 Todo *todo( QString, QString ); 190 Todo *todo( QString, QString );
189 Event *event( QString, QString ); 191 Event *event( QString, QString );
190 void getIncidenceCount( int calId, int& events, int & todos, int & journals); 192 void getIncidenceCount( int calId, int& events, int & todos, int & journals);
191 193
192public slots: 194public slots:
193 void setCalendarEnabled( int id, bool enable ); 195 void setCalendarEnabled( int id, bool enable );
194 void setAlarmEnabled( int id, bool enable ); 196 void setAlarmEnabled( int id, bool enable );
195 void setReadOnly( int id, bool enable ); 197 void setReadOnly( int id, bool enable );
196 void setDefaultCalendarEnabledOnly(); 198 void setDefaultCalendarEnabledOnly();
197 void setCalendarRemove( int id ); 199 void setCalendarRemove( int id );
198 void setAllCalendarEnabled( bool enable ); 200 void setAllCalendarEnabled( bool enable );
@@ -215,20 +217,20 @@ public slots:
215 217
216 /** Append alarms of incidence in interval to list of alarms. */ 218 /** Append alarms of incidence in interval to list of alarms. */
217 void appendAlarms( Alarm::List &alarms, Incidence *incidence, 219 void appendAlarms( Alarm::List &alarms, Incidence *incidence,
218 const QDateTime &from, const QDateTime &to ); 220 const QDateTime &from, const QDateTime &to );
219 221
220 /** Append alarms of recurring events in interval to list of alarms. */ 222 /** Append alarms of recurring events in interval to list of alarms. */
221 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence, 223 void appendRecurringAlarms( Alarm::List &alarms, Incidence *incidence,
222 const QDateTime &from, const QDateTime &to ); 224 const QDateTime &from, const QDateTime &to );
223 225
224 private: 226 private:
225 void init(); 227 void init();
226 228
227 QPtrList<Event> mEventList; 229 Q3PtrList<Event> mEventList;
228 QPtrList<Todo> mTodoList; 230 Q3PtrList<Todo> mTodoList;
229 QPtrList<Journal> mJournalList; 231 Q3PtrList<Journal> mJournalList;
230}; 232};
231 233
232} 234}
233 235
234#endif 236#endif
diff --git a/libkcal/calfilter.cpp b/libkcal/calfilter.cpp
index 72f70c2..fa1dbd5 100644
--- a/libkcal/calfilter.cpp
+++ b/libkcal/calfilter.cpp
@@ -12,65 +12,67 @@
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 <kdebug.h> 21#include <kdebug.h>
22 22
23#include "calfilter.h" 23#include "calfilter.h"
24//Added by qt3to4:
25#include <Q3PtrList>
24 26
25using namespace KCal; 27using namespace KCal;
26 28
27CalFilter::CalFilter() 29CalFilter::CalFilter()
28{ 30{
29 mEnabled = true; 31 mEnabled = true;
30 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 32 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
31} 33}
32 34
33CalFilter::CalFilter(const QString &name) 35CalFilter::CalFilter(const QString &name)
34{ 36{
35 mName = name; 37 mName = name;
36 mEnabled = true; 38 mEnabled = true;
37 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; 39 mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
38} 40}
39 41
40CalFilter::~CalFilter() 42CalFilter::~CalFilter()
41{ 43{
42} 44}
43 45
44void CalFilter::apply(QPtrList<Event> *eventlist) 46void CalFilter::apply(Q3PtrList<Event> *eventlist)
45{ 47{
46 if (!mEnabled) return; 48 if (!mEnabled) return;
47 49
48// kdDebug(5800) << "CalFilter::apply()" << endl; 50// kdDebug(5800) << "CalFilter::apply()" << endl;
49 51
50 Event *event = eventlist->first(); 52 Event *event = eventlist->first();
51 while(event) { 53 while(event) {
52 if (!filterEvent(event)) { 54 if (!filterEvent(event)) {
53 eventlist->remove(); 55 eventlist->remove();
54 event = eventlist->current(); 56 event = eventlist->current();
55 } else { 57 } else {
56 event = eventlist->next(); 58 event = eventlist->next();
57 } 59 }
58 } 60 }
59 61
60// kdDebug(5800) << "CalFilter::apply() done" << endl; 62// kdDebug(5800) << "CalFilter::apply() done" << endl;
61} 63}
62 64
63// TODO: avoid duplicating apply() code 65// TODO: avoid duplicating apply() code
64void CalFilter::apply(QPtrList<Todo> *eventlist) 66void CalFilter::apply(Q3PtrList<Todo> *eventlist)
65{ 67{
66 if (!mEnabled) return; 68 if (!mEnabled) return;
67 Todo *event = eventlist->first(); 69 Todo *event = eventlist->first();
68 while(event) { 70 while(event) {
69 if (!filterTodo(event)) { 71 if (!filterTodo(event)) {
70 eventlist->remove(); 72 eventlist->remove();
71 event = eventlist->current(); 73 event = eventlist->current();
72 } else { 74 } else {
73 event = eventlist->next(); 75 event = eventlist->next();
74 } 76 }
75 } 77 }
76 78
diff --git a/libkcal/calfilter.h b/libkcal/calfilter.h
index e349770..821149f 100644
--- a/libkcal/calfilter.h
+++ b/libkcal/calfilter.h
@@ -13,25 +13,25 @@
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#ifndef _CALFILTER_H 21#ifndef _CALFILTER_H
22#define _CALFILTER_H 22#define _CALFILTER_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26 26
27#include "event.h" 27#include "event.h"
28#include "todo.h" 28#include "todo.h"
29#include "journal.h" 29#include "journal.h"
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 Filter for calendar objects. 34 Filter for calendar objects.
35*/ 35*/
36class CalFilter { 36class CalFilter {
37 public: 37 public:
@@ -46,33 +46,33 @@ class CalFilter {
46 Set name of filter. 46 Set name of filter.
47 */ 47 */
48 void setName(const QString &name) { mName = name; } 48 void setName(const QString &name) { mName = name; }
49 /** 49 /**
50 Return name of filter. 50 Return name of filter.
51 */ 51 */
52 QString name() const { return mName; } 52 QString name() const { return mName; }
53 53
54 /** 54 /**
55 Apply filter to eventlist, all events not matching filter criterias are 55 Apply filter to eventlist, all events not matching filter criterias are
56 removed from the list. 56 removed from the list.
57 */ 57 */
58 void apply(QPtrList<Event> *eventlist); 58 void apply(Q3PtrList<Event> *eventlist);
59 59
60 /** 60 /**
61 Apply filter to todolist, all todos not matching filter criterias are 61 Apply filter to todolist, all todos not matching filter criterias are
62 removed from the list. 62 removed from the list.
63 */ 63 */
64 void apply(QPtrList<Todo> *todolist); 64 void apply(Q3PtrList<Todo> *todolist);
65 bool CalFilter::filterCalendarItem(Incidence *in); 65 bool filterCalendarItem(Incidence *in);
66 bool CalFilter::filterJournal(Journal *in); 66 bool filterJournal(Journal *in);
67 /** 67 /**
68 Apply filter criteria on the specified event. Return true, if event passes 68 Apply filter criteria on the specified event. Return true, if event passes
69 criteria, otherwise return false. 69 criteria, otherwise return false.
70 */ 70 */
71 bool filterEvent(Event *); 71 bool filterEvent(Event *);
72 72
73 /** 73 /**
74 Apply filter criteria on the specified todo. Return true, if event passes 74 Apply filter criteria on the specified todo. Return true, if event passes
75 criteria, otherwise return false. 75 criteria, otherwise return false.
76 */ 76 */
77 bool filterTodo(Todo *); 77 bool filterTodo(Todo *);
78 78
diff --git a/libkcal/customproperties.cpp b/libkcal/customproperties.cpp
index adc1710..16f4a28 100644
--- a/libkcal/customproperties.cpp
+++ b/libkcal/customproperties.cpp
@@ -10,99 +10,101 @@
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 "customproperties.h" 21#include "customproperties.h"
22//Added by qt3to4:
23#include <Q3CString>
22 24
23using namespace KCal; 25using namespace KCal;
24 26
25CustomProperties::CustomProperties() 27CustomProperties::CustomProperties()
26{ 28{
27} 29}
28 30
29CustomProperties::CustomProperties(const CustomProperties &cp) 31CustomProperties::CustomProperties(const CustomProperties &cp)
30 : mProperties(cp.mProperties) 32 : mProperties(cp.mProperties)
31{ 33{
32} 34}
33 35
34CustomProperties::~CustomProperties() 36CustomProperties::~CustomProperties()
35{ 37{
36} 38}
37 39
38void CustomProperties::setCustomProperty(const QCString &app, const QCString &key, 40void CustomProperties::setCustomProperty(const Q3CString &app, const Q3CString &key,
39 const QString &value) 41 const QString &value)
40{ 42{
41 if (value.isNull() || key.isEmpty() || app.isEmpty()) 43 if (value.isNull() || key.isEmpty() || app.isEmpty())
42 return; 44 return;
43 QCString property = "X-KDE-" + app + "-" + key; 45 Q3CString property = "X-KDE-" + app + "-" + key;
44 if (!checkName(property)) 46 if (!checkName(property))
45 return; 47 return;
46 mProperties[property] = value; 48 mProperties[property] = value;
47} 49}
48 50
49void CustomProperties::removeCustomProperty(const QCString &app, const QCString &key) 51void CustomProperties::removeCustomProperty(const Q3CString &app, const Q3CString &key)
50{ 52{
51 removeNonKDECustomProperty(QCString("X-KDE-" + app + "-" + key)); 53 removeNonKDECustomProperty(Q3CString("X-KDE-" + app + "-" + key));
52} 54}
53 55
54QString CustomProperties::customProperty(const QCString &app, const QCString &key) const 56QString CustomProperties::customProperty(const Q3CString &app, const Q3CString &key) const
55{ 57{
56 return nonKDECustomProperty(QCString("X-KDE-" + app + "-" + key)); 58 return nonKDECustomProperty(Q3CString("X-KDE-" + app + "-" + key));
57} 59}
58 60
59void CustomProperties::setNonKDECustomProperty(const QCString &name, const QString &value) 61void CustomProperties::setNonKDECustomProperty(const Q3CString &name, const QString &value)
60{ 62{
61 if (value.isNull() || !checkName(name)) 63 if (value.isNull() || !checkName(name))
62 return; 64 return;
63 mProperties[name] = value; 65 mProperties[name] = value;
64} 66}
65 67
66void CustomProperties::removeNonKDECustomProperty(const QCString &name) 68void CustomProperties::removeNonKDECustomProperty(const Q3CString &name)
67{ 69{
68 QMap<QCString, QString>::Iterator it = mProperties.find(name); 70 QMap<Q3CString, QString>::Iterator it = mProperties.find(name);
69 if (it != mProperties.end()) 71 if (it != mProperties.end())
70 mProperties.remove(it); 72 mProperties.remove(it);
71} 73}
72 74
73QString CustomProperties::nonKDECustomProperty(const QCString &name) const 75QString CustomProperties::nonKDECustomProperty(const Q3CString &name) const
74{ 76{
75 QMap<QCString, QString>::ConstIterator it = mProperties.find(name); 77 QMap<Q3CString, QString>::ConstIterator it = mProperties.find(name);
76 if (it == mProperties.end()) 78 if (it == mProperties.end())
77 return QString::null; 79 return QString::null;
78 return it.data(); 80 return it.data();
79} 81}
80 82
81void CustomProperties::setCustomProperties(const QMap<QCString, QString> &properties) 83void CustomProperties::setCustomProperties(const QMap<Q3CString, QString> &properties)
82{ 84{
83 for (QMap<QCString, QString>::ConstIterator it = properties.begin(); it != properties.end(); ++it) { 85 for (QMap<Q3CString, QString>::ConstIterator it = properties.begin(); it != properties.end(); ++it) {
84 // Validate the property name and convert any null string to empty string 86 // Validate the property name and convert any null string to empty string
85 if (checkName(it.key())) { 87 if (checkName(it.key())) {
86 mProperties[it.key()] = it.data().isNull() ? QString("") : it.data(); 88 mProperties[it.key()] = it.data().isNull() ? QString("") : it.data();
87 } 89 }
88 } 90 }
89} 91}
90 92
91QMap<QCString, QString> CustomProperties::customProperties() const 93QMap<Q3CString, QString> CustomProperties::customProperties() const
92{ 94{
93 return mProperties; 95 return mProperties;
94} 96}
95 97
96bool CustomProperties::checkName(const QCString &name) 98bool CustomProperties::checkName(const Q3CString &name)
97{ 99{
98 // Check that the property name starts with 'X-' and contains 100 // Check that the property name starts with 'X-' and contains
99 // only the permitted characters 101 // only the permitted characters
100 const char* n = name; 102 const char* n = name;
101 int len = name.length(); 103 int len = name.length();
102 if (len < 2 || n[0] != 'X' || n[1] != '-') 104 if (len < 2 || n[0] != 'X' || n[1] != '-')
103 return false; 105 return false;
104 for (int i = 2; i < len; ++i) { 106 for (int i = 2; i < len; ++i) {
105 char ch = n[i]; 107 char ch = n[i];
106 if (ch >= 'A' && ch <= 'Z' 108 if (ch >= 'A' && ch <= 'Z'
107 || ch >= 'a' && ch <= 'z' 109 || ch >= 'a' && ch <= 'z'
108 || ch >= '0' && ch <= '9' 110 || ch >= '0' && ch <= '9'
diff --git a/libkcal/customproperties.h b/libkcal/customproperties.h
index 0cbfdcd..75eb3ad 100644
--- a/libkcal/customproperties.h
+++ b/libkcal/customproperties.h
@@ -14,24 +14,26 @@
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#ifndef KCAL_CUSTOM_PROPERTIES_H 21#ifndef KCAL_CUSTOM_PROPERTIES_H
22#define KCAL_CUSTOM_PROPERTIES_H 22#define KCAL_CUSTOM_PROPERTIES_H
23 23
24#include <qstring.h> 24#include <qstring.h>
25#include <qmap.h> 25#include <qmap.h>
26//Added by qt3to4:
27#include <Q3CString>
26 28
27namespace KCal { 29namespace KCal {
28 30
29/** 31/**
30 This class represents custom calendar properties. 32 This class represents custom calendar properties.
31 It is used as a base class for classes which represent calendar components. 33 It is used as a base class for classes which represent calendar components.
32 A custom property name written by libkcal has the form X-KDE-APP-KEY where 34 A custom property name written by libkcal has the form X-KDE-APP-KEY where
33 APP represents the application name, and KEY distinguishes individual 35 APP represents the application name, and KEY distinguishes individual
34 properties for the application. 36 properties for the application.
35 In keeping with RFC2445, property names must be composed only of the 37 In keeping with RFC2445, property names must be composed only of the
36 characters A-Z, a-z, 0-9 and '-'. 38 characters A-Z, a-z, 0-9 and '-'.
37*/ 39*/
@@ -40,58 +42,58 @@ class CustomProperties
40 public: 42 public:
41 /** Construct a new empty custom properties instance */ 43 /** Construct a new empty custom properties instance */
42 CustomProperties(); 44 CustomProperties();
43 CustomProperties(const CustomProperties &); 45 CustomProperties(const CustomProperties &);
44 ~CustomProperties(); 46 ~CustomProperties();
45 47
46 /** Create or modify a custom calendar property. 48 /** Create or modify a custom calendar property.
47 @param app Application name as it appears in the custom property name. 49 @param app Application name as it appears in the custom property name.
48 @param key Property identifier specific to the application. 50 @param key Property identifier specific to the application.
49 @param value The property's value. A call with a value of QString::null 51 @param value The property's value. A call with a value of QString::null
50 will be ignored. 52 will be ignored.
51 */ 53 */
52 void setCustomProperty(const QCString &app, const QCString &key, 54 void setCustomProperty(const Q3CString &app, const Q3CString &key,
53 const QString &value); 55 const QString &value);
54 /** Delete a custom calendar property. 56 /** Delete a custom calendar property.
55 @param app Application name as it appears in the custom property name. 57 @param app Application name as it appears in the custom property name.
56 @param key Property identifier specific to the application. 58 @param key Property identifier specific to the application.
57 */ 59 */
58 void removeCustomProperty(const QCString &app, const QCString &key); 60 void removeCustomProperty(const Q3CString &app, const Q3CString &key);
59 /** Return the value of a custom calendar property. 61 /** Return the value of a custom calendar property.
60 @param app Application name as it appears in the custom property name. 62 @param app Application name as it appears in the custom property name.
61 @param key Property identifier specific to the application. 63 @param key Property identifier specific to the application.
62 @return Property value, or QString::null if (and only if) the property does not exist. 64 @return Property value, or QString::null if (and only if) the property does not exist.
63 */ 65 */
64 QString customProperty(const QCString &app, const QCString &key) const; 66 QString customProperty(const Q3CString &app, const Q3CString &key) const;
65 67
66 /** Create or modify a non-KDE or non-standard custom calendar property. 68 /** Create or modify a non-KDE or non-standard custom calendar property.
67 @param name Full property name 69 @param name Full property name
68 @param value The property's value. A call with a value of QString::null 70 @param value The property's value. A call with a value of QString::null
69 will be ignored. 71 will be ignored.
70 */ 72 */
71 void setNonKDECustomProperty(const QCString &name, const QString &value); 73 void setNonKDECustomProperty(const Q3CString &name, const QString &value);
72 /** Delete a non-KDE or non-standard custom calendar property. 74 /** Delete a non-KDE or non-standard custom calendar property.
73 @param name Full property name 75 @param name Full property name
74 */ 76 */
75 void removeNonKDECustomProperty(const QCString &name); 77 void removeNonKDECustomProperty(const Q3CString &name);
76 /** Return the value of a non-KDE or non-standard custom calendar property. 78 /** Return the value of a non-KDE or non-standard custom calendar property.
77 @param name Full property name 79 @param name Full property name
78 @return Property value, or QString::null if (and only if) the property does not exist. 80 @return Property value, or QString::null if (and only if) the property does not exist.
79 */ 81 */
80 QString nonKDECustomProperty(const QCString& name) const; 82 QString nonKDECustomProperty(const Q3CString& name) const;
81 83
82 /** Initialise the alarm's custom calendar properties to the specified 84 /** Initialise the alarm's custom calendar properties to the specified
83 key/value pairs. 85 key/value pairs.
84 */ 86 */
85 void setCustomProperties(const QMap<QCString, QString> &properties); 87 void setCustomProperties(const QMap<Q3CString, QString> &properties);
86 /** Return all custom calendar property key/value pairs. */ 88 /** Return all custom calendar property key/value pairs. */
87 QMap<QCString, QString> customProperties() const; 89 QMap<Q3CString, QString> customProperties() const;
88 90
89 private: 91 private:
90 static bool checkName(const QCString& name); 92 static bool checkName(const Q3CString& name);
91 93
92 QMap<QCString, QString> mProperties; // custom calendar properties 94 QMap<Q3CString, QString> mProperties; // custom calendar properties
93}; 95};
94 96
95} 97}
96 98
97#endif 99#endif
diff --git a/libkcal/dndfactory.cpp b/libkcal/dndfactory.cpp
index cdcfae4..ca7e212 100644
--- a/libkcal/dndfactory.cpp
+++ b/libkcal/dndfactory.cpp
@@ -13,24 +13,27 @@
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <qapplication.h> 23#include <qapplication.h>
24#include <qclipboard.h> 24#include <qclipboard.h>
25//Added by qt3to4:
26#include <QDropEvent>
27#include <Q3PtrList>
25 28
26#include <kiconloader.h> 29#include <kiconloader.h>
27#include <kdebug.h> 30#include <kdebug.h>
28#include <kmessagebox.h> 31#include <kmessagebox.h>
29#include <klocale.h> 32#include <klocale.h>
30 33
31#include "vcaldrag.h" 34#include "vcaldrag.h"
32#include "icaldrag.h" 35#include "icaldrag.h"
33#include "calendar.h" 36#include "calendar.h"
34#include "vcalformat.h" 37#include "vcalformat.h"
35#include "icalformat.h" 38#include "icalformat.h"
36#include "calendarlocal.h" 39#include "calendarlocal.h"
@@ -59,44 +62,44 @@ ICalDrag *DndFactory::createDrag( Incidence *incidence, QWidget *owner )
59 return icd; 62 return icd;
60} 63}
61 64
62Event *DndFactory::createDrop(QDropEvent *de) 65Event *DndFactory::createDrop(QDropEvent *de)
63{ 66{
64 kdDebug(5800) << "DndFactory::createDrop()" << endl; 67 kdDebug(5800) << "DndFactory::createDrop()" << endl;
65 68
66 CalendarLocal cal( mCalendar->timeZoneId() ); 69 CalendarLocal cal( mCalendar->timeZoneId() );
67 70
68 if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) { 71 if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) {
69 de->accept(); 72 de->accept();
70 73
71 QPtrList<Event> events = cal.events(); 74 Q3PtrList<Event> events = cal.events();
72 if ( !events.isEmpty() ) { 75 if ( !events.isEmpty() ) {
73 Event *event = new Event( *events.first() ); 76 Event *event = new Event( *events.first() );
74 return event; 77 return event;
75 } 78 }
76 } 79 }
77 80
78 return 0; 81 return 0;
79} 82}
80 83
81Todo *DndFactory::createDropTodo(QDropEvent *de) 84Todo *DndFactory::createDropTodo(QDropEvent *de)
82{ 85{
83 kdDebug(5800) << "VCalFormat::createDropTodo()" << endl; 86 kdDebug(5800) << "VCalFormat::createDropTodo()" << endl;
84 87
85 CalendarLocal cal( mCalendar->timeZoneId() ); 88 CalendarLocal cal( mCalendar->timeZoneId() );
86 89
87 if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) { 90 if ( ICalDrag::decode( de, &cal ) || VCalDrag::decode( de, &cal ) ) {
88 de->accept(); 91 de->accept();
89 92
90 QPtrList<Todo> todos = cal.todos(); 93 Q3PtrList<Todo> todos = cal.todos();
91 if ( !todos.isEmpty() ) { 94 if ( !todos.isEmpty() ) {
92 Todo *todo = new Todo( *todos.first() ); 95 Todo *todo = new Todo( *todos.first() );
93 return todo; 96 return todo;
94 } 97 }
95 } 98 }
96 99
97 return 0; 100 return 0;
98} 101}
99 102
100 103
101void DndFactory::cutIncidence( Incidence *selectedInc ) 104void DndFactory::cutIncidence( Incidence *selectedInc )
102{ 105{
@@ -124,25 +127,25 @@ Incidence *DndFactory::pasteIncidence(const QDate &newDate, const QTime *newTime
124// kdDebug(5800) << "DnDFactory::pasteEvent()" << endl; 127// kdDebug(5800) << "DnDFactory::pasteEvent()" << endl;
125 128
126 CalendarLocal cal( mCalendar->timeZoneId() ); 129 CalendarLocal cal( mCalendar->timeZoneId() );
127 130
128 QClipboard *cb = QApplication::clipboard(); 131 QClipboard *cb = QApplication::clipboard();
129 132
130 if ( !ICalDrag::decode( cb->data(), &cal ) && 133 if ( !ICalDrag::decode( cb->data(), &cal ) &&
131 !VCalDrag::decode( cb->data(), &cal ) ) { 134 !VCalDrag::decode( cb->data(), &cal ) ) {
132 kdDebug(5800) << "Can't parse clipboard" << endl; 135 kdDebug(5800) << "Can't parse clipboard" << endl;
133 return 0; 136 return 0;
134 } 137 }
135 138
136 QPtrList<Incidence> incList = cal.incidences(); 139 Q3PtrList<Incidence> incList = cal.incidences();
137 Incidence *inc = incList.first(); 140 Incidence *inc = incList.first();
138 141
139 if ( !incList.isEmpty() && inc ) { 142 if ( !incList.isEmpty() && inc ) {
140 inc = inc->clone(); 143 inc = inc->clone();
141 144
142 inc->recreate(); 145 inc->recreate();
143 146
144 if ( inc->type() == "Event" ) { 147 if ( inc->type() == "Event" ) {
145 148
146 Event *anEvent = static_cast<Event*>( inc ); 149 Event *anEvent = static_cast<Event*>( inc );
147 // Calculate length of event 150 // Calculate length of event
148 int daysOffset = anEvent->dtStart().date().daysTo( 151 int daysOffset = anEvent->dtStart().date().daysTo(
diff --git a/libkcal/dndfactory.h b/libkcal/dndfactory.h
index 2df5259..a873c37 100644
--- a/libkcal/dndfactory.h
+++ b/libkcal/dndfactory.h
@@ -1,12 +1,14 @@
1//Added by qt3to4:
2#include <QDropEvent>
1/* 3/*
2 This file is part of libkcal. 4 This file is part of libkcal.
3 5
4 Copyright (c) 1998 Preston Brown 6 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org> 7 Copyright (c) 2001,2002,2003 Cornelius Schumacher <schumacher@kde.org>
6 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com> 8 Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
7 9
8 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 12 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 13 version 2 of the License, or (at your option) any later version.
12 14
diff --git a/libkcal/dndfactory_dummy.h b/libkcal/dndfactory_dummy.h
index 44cc114..3ab6adf 100644
--- a/libkcal/dndfactory_dummy.h
+++ b/libkcal/dndfactory_dummy.h
@@ -16,24 +16,26 @@
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22// $Id$ 22// $Id$
23 23
24#ifndef KCAL_DNDFACTORY_H 24#ifndef KCAL_DNDFACTORY_H
25#define KCAL_DNDFACTORY_H 25#define KCAL_DNDFACTORY_H
26 26
27#include "vcalformat.h" 27#include "vcalformat.h"
28//Added by qt3to4:
29#include <QDropEvent>
28 30
29class QDropEvent; 31class QDropEvent;
30 32
31namespace KCal { 33namespace KCal {
32 34
33/** 35/**
34 This class implements functions to create Drag and Drop objects used for 36 This class implements functions to create Drag and Drop objects used for
35 Drag-and-Drop and Copy-and-Paste. 37 Drag-and-Drop and Copy-and-Paste.
36 38
37 @short vCalendar Drag-and-Drop object factory. 39 @short vCalendar Drag-and-Drop object factory.
38*/ 40*/
39class DndFactory { 41class DndFactory {
diff --git a/libkcal/dummyscheduler.cpp b/libkcal/dummyscheduler.cpp
index ae40e6d..73eb3d0 100644
--- a/libkcal/dummyscheduler.cpp
+++ b/libkcal/dummyscheduler.cpp
@@ -14,25 +14,27 @@
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// 21//
22// DummyScheduler - iMIP implementation of iTIP methods 22// DummyScheduler - iMIP implementation of iTIP methods
23// 23//
24 24
25#include <qfile.h> 25#include <qfile.h>
26#include <qtextstream.h> 26#include <q3textstream.h>
27//Added by qt3to4:
28#include <Q3PtrList>
27 29
28#include <kdebug.h> 30#include <kdebug.h>
29 31
30#include "event.h" 32#include "event.h"
31#include "icalformat.h" 33#include "icalformat.h"
32 34
33#include "dummyscheduler.h" 35#include "dummyscheduler.h"
34 36
35using namespace KCal; 37using namespace KCal;
36 38
37DummyScheduler::DummyScheduler(Calendar *calendar) 39DummyScheduler::DummyScheduler(Calendar *calendar)
38 : Scheduler(calendar) 40 : Scheduler(calendar)
@@ -59,44 +61,44 @@ bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method,c
59} 61}
60 62
61bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method) 63bool DummyScheduler::performTransaction(IncidenceBase *incidence,Method method)
62{ 64{
63 QString messageText = mFormat->createScheduleMessage(incidence,method); 65 QString messageText = mFormat->createScheduleMessage(incidence,method);
64 66
65 return saveMessage(messageText); 67 return saveMessage(messageText);
66} 68}
67 69
68bool DummyScheduler::saveMessage(const QString &message) 70bool DummyScheduler::saveMessage(const QString &message)
69{ 71{
70 QFile f("dummyscheduler.store"); 72 QFile f("dummyscheduler.store");
71 if (f.open(IO_WriteOnly | IO_Append)) { 73 if (f.open(QIODevice::WriteOnly | QIODevice::Append)) {
72 QTextStream t(&f); 74 Q3TextStream t(&f);
73 t << message << endl; 75 t << message << endl;
74 f.close(); 76 f.close();
75 return true; 77 return true;
76 } else { 78 } else {
77 return false; 79 return false;
78 } 80 }
79} 81}
80 82
81QPtrList<ScheduleMessage> DummyScheduler::retrieveTransactions() 83Q3PtrList<ScheduleMessage> DummyScheduler::retrieveTransactions()
82{ 84{
83 QPtrList<ScheduleMessage> messageList; 85 Q3PtrList<ScheduleMessage> messageList;
84 86
85 QFile f("dummyscheduler.store"); 87 QFile f("dummyscheduler.store");
86 if (!f.open(IO_ReadOnly)) { 88 if (!f.open(QIODevice::ReadOnly)) {
87 kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file" 89 kdDebug(5800) << "DummyScheduler::retrieveTransactions(): Can't open file"
88 << endl; 90 << endl;
89 } else { 91 } else {
90 QTextStream t(&f); 92 Q3TextStream t(&f);
91 QString messageString; 93 QString messageString;
92 QString messageLine = t.readLine(); 94 QString messageLine = t.readLine();
93 while (!messageLine.isNull()) { 95 while (!messageLine.isNull()) {
94// kdDebug(5800) << "++++++++" << messageLine << endl; 96// kdDebug(5800) << "++++++++" << messageLine << endl;
95 messageString += messageLine + "\n"; 97 messageString += messageLine + "\n";
96 if (messageLine.find("END:VCALENDAR") >= 0) { 98 if (messageLine.find("END:VCALENDAR") >= 0) {
97 kdDebug(5800) << "---------------" << messageString << endl; 99 kdDebug(5800) << "---------------" << messageString << endl;
98 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar, 100 ScheduleMessage *message = mFormat->parseScheduleMessage(mCalendar,
99 messageString); 101 messageString);
100 kdDebug(5800) << "--Parsed" << endl; 102 kdDebug(5800) << "--Parsed" << endl;
101 if (message) { 103 if (message) {
102 messageList.append(message); 104 messageList.append(message);
diff --git a/libkcal/dummyscheduler.h b/libkcal/dummyscheduler.h
index df42153..f86d583 100644
--- a/libkcal/dummyscheduler.h
+++ b/libkcal/dummyscheduler.h
@@ -15,37 +15,39 @@
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#ifndef DUMMYSCHEDULER_H 20#ifndef DUMMYSCHEDULER_H
21#define DUMMYSCHEDULER_H 21#define DUMMYSCHEDULER_H
22// 22//
23// Dummy implementation of iTIP methods 23// Dummy implementation of iTIP methods
24// 24//
25 25
26#include "scheduler.h" 26#include "scheduler.h"
27//Added by qt3to4:
28#include <Q3PtrList>
27 29
28namespace KCal { 30namespace KCal {
29 31
30/** 32/**
31 This class implements the iTIP interface as a primitive local version for 33 This class implements the iTIP interface as a primitive local version for
32 testing. It uses a file dummyscheduler.store as inbox/outbox. 34 testing. It uses a file dummyscheduler.store as inbox/outbox.
33*/ 35*/
34class DummyScheduler : public Scheduler { 36class DummyScheduler : public Scheduler {
35 public: 37 public:
36 DummyScheduler(Calendar *); 38 DummyScheduler(Calendar *);
37 virtual ~DummyScheduler(); 39 virtual ~DummyScheduler();
38 40
39 bool publish (IncidenceBase *incidence,const QString &recipients); 41 bool publish (IncidenceBase *incidence,const QString &recipients);
40 bool performTransaction(IncidenceBase *incidence,Method method); 42 bool performTransaction(IncidenceBase *incidence,Method method);
41 bool performTransaction(IncidenceBase *incidence,Method method,const QString &recipients); 43 bool performTransaction(IncidenceBase *incidence,Method method,const QString &recipients);
42 QPtrList<ScheduleMessage> retrieveTransactions(); 44 Q3PtrList<ScheduleMessage> retrieveTransactions();
43 45
44 protected: 46 protected:
45 bool saveMessage(const QString &); 47 bool saveMessage(const QString &);
46}; 48};
47 49
48} 50}
49 51
50#endif // DUMMYSCHEDULER_H 52#endif // DUMMYSCHEDULER_H
51 53
diff --git a/libkcal/event.cpp b/libkcal/event.cpp
index fdf5657..060df81 100644
--- a/libkcal/event.cpp
+++ b/libkcal/event.cpp
@@ -375,25 +375,25 @@ QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_
375 *ok = false; 375 *ok = false;
376 return QDateTime (); 376 return QDateTime ();
377 } 377 }
378 378
379 bool enabled = false; 379 bool enabled = false;
380 Alarm* alarm; 380 Alarm* alarm;
381 int off = 0; 381 int off = 0;
382 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 382 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
383 // if ( QDateTime::currentDateTime() > incidenceStart ){ 383 // if ( QDateTime::currentDateTime() > incidenceStart ){
384// *ok = false; 384// *ok = false;
385// return incidenceStart; 385// return incidenceStart;
386// } 386// }
387 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 387 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
388 if (alarm->enabled()) { 388 if (alarm->enabled()) {
389 if ( alarm->hasTime () ) { 389 if ( alarm->hasTime () ) {
390 if ( alarm->time() < alarmStart ) { 390 if ( alarm->time() < alarmStart ) {
391 alarmStart = alarm->time(); 391 alarmStart = alarm->time();
392 enabled = true; 392 enabled = true;
393 off = alarmStart.secsTo( incidenceStart ); 393 off = alarmStart.secsTo( incidenceStart );
394 } 394 }
395 395
396 } else { 396 } else {
397 int secs = alarm->startOffset().asSeconds(); 397 int secs = alarm->startOffset().asSeconds();
398 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 398 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
399 alarmStart = incidenceStart.addSecs( secs ); 399 alarmStart = incidenceStart.addSecs( secs );
diff --git a/libkcal/event.h b/libkcal/event.h
index 6a58618..da44f81 100644
--- a/libkcal/event.h
+++ b/libkcal/event.h
@@ -16,40 +16,42 @@
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#ifndef EVENT_H 21#ifndef EVENT_H
22#define EVENT_H 22#define EVENT_H
23// 23//
24// Event component, representing a VEVENT object 24// Event component, representing a VEVENT object
25// 25//
26 26
27#include "incidence.h" 27#include "incidence.h"
28//Added by qt3to4:
29#include <Q3CString>
28namespace KCal { 30namespace KCal {
29 31
30/** 32/**
31 This class provides an Event in the sense of RFC2445. 33 This class provides an Event in the sense of RFC2445.
32*/ 34*/
33class Event : public Incidence 35class Event : public Incidence
34{ 36{
35 public: 37 public:
36 enum Transparency { Opaque, Transparent }; 38 enum Transparency { Opaque, Transparent };
37 typedef ListBase<Event> List; 39 typedef ListBase<Event> List;
38 Event(); 40 Event();
39 Event(const Event &); 41 Event(const Event &);
40 ~Event(); 42 ~Event();
41 bool matchTime(QDateTime*startDT, QDateTime* endDT); 43 bool matchTime(QDateTime*startDT, QDateTime* endDT);
42 44
43 QCString type() const { return "Event"; } 45 Q3CString type() const { return "Event"; }
44 IncTypeID typeID() const { return eventID; } 46 IncTypeID typeID() const { return eventID; }
45 47
46 Incidence *clone(); 48 Incidence *clone();
47 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; 49 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
48 50
49 /** for setting an event's ending date/time with a QDateTime. */ 51 /** for setting an event's ending date/time with a QDateTime. */
50 void setDtEnd(const QDateTime &dtEnd); 52 void setDtEnd(const QDateTime &dtEnd);
51 /** Return the event's ending date/time as a QDateTime. */ 53 /** Return the event's ending date/time as a QDateTime. */
52 virtual QDateTime dtEnd() const; 54 virtual QDateTime dtEnd() const;
53 /** returns an event's end time as a string formatted according to the 55 /** returns an event's end time as a string formatted according to the
54 users locale settings */ 56 users locale settings */
55 QString dtEndTimeStr() const; 57 QString dtEndTimeStr() const;
diff --git a/libkcal/filestorage.cpp b/libkcal/filestorage.cpp
index a139124..3d1309f 100644
--- a/libkcal/filestorage.cpp
+++ b/libkcal/filestorage.cpp
@@ -13,25 +13,25 @@
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 <stdlib.h> 21#include <stdlib.h>
22 22
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26 26
27#include <kdebug.h> 27#include <kdebug.h>
28 28
29#include "calendar.h" 29#include "calendar.h"
30#include "vcaldrag.h" 30#include "vcaldrag.h"
31#include "vcalformat.h" 31#include "vcalformat.h"
32#include "icalformat.h" 32#include "icalformat.h"
33 33
34#include "filestorage.h" 34#include "filestorage.h"
35 35
36using namespace KCal; 36using namespace KCal;
37 37
diff --git a/libkcal/freebusy.cpp b/libkcal/freebusy.cpp
index ba15d6d..e4e9ec9 100644
--- a/libkcal/freebusy.cpp
+++ b/libkcal/freebusy.cpp
@@ -12,47 +12,50 @@
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 <kdebug.h> 21#include <kdebug.h>
22 22
23#include "freebusy.h" 23#include "freebusy.h"
24//Added by qt3to4:
25#include <Q3ValueList>
26#include <Q3PtrList>
24 27
25using namespace KCal; 28using namespace KCal;
26 29
27FreeBusy::FreeBusy() 30FreeBusy::FreeBusy()
28{ 31{
29} 32}
30 33
31FreeBusy::FreeBusy(const QDateTime &start, const QDateTime &end) 34FreeBusy::FreeBusy(const QDateTime &start, const QDateTime &end)
32{ 35{
33 setDtStart(start); 36 setDtStart(start);
34 setDtEnd(end); 37 setDtEnd(end);
35} 38}
36 39
37FreeBusy::FreeBusy( Calendar *calendar, const QDateTime &start, const QDateTime &end ) 40FreeBusy::FreeBusy( Calendar *calendar, const QDateTime &start, const QDateTime &end )
38{ 41{
39 kdDebug() << "FreeBusy::FreeBusy" << endl; 42 kdDebug() << "FreeBusy::FreeBusy" << endl;
40 mCalendar = calendar; 43 mCalendar = calendar;
41 44
42 setDtStart(start); 45 setDtStart(start);
43 setDtEnd(end); 46 setDtEnd(end);
44 47
45 //Gets all the events in the calendar 48 //Gets all the events in the calendar
46 QPtrList<Event> eventList = mCalendar->events(); 49 Q3PtrList<Event> eventList = mCalendar->events();
47 Event *event; 50 Event *event;
48 51
49 int extraDays, i, x, duration; 52 int extraDays, i, x, duration;
50 duration = start.daysTo(end); 53 duration = start.daysTo(end);
51 QDate day; 54 QDate day;
52 QDateTime tmpStart; 55 QDateTime tmpStart;
53 QDateTime tmpEnd; 56 QDateTime tmpEnd;
54 //Loops through every event in the calendar 57 //Loops through every event in the calendar
55 for( event = eventList.first(); event; event = eventList.next() ) { 58 for( event = eventList.first(); event; event = eventList.next() ) {
56 //This whole for loop is for recurring events, it loops through 59 //This whole for loop is for recurring events, it loops through
57 //each of the days of the freebusy request 60 //each of the days of the freebusy request
58 61
@@ -104,25 +107,25 @@ FreeBusy::~FreeBusy()
104 107
105bool FreeBusy::setDtEnd( const QDateTime &end ) 108bool FreeBusy::setDtEnd( const QDateTime &end )
106{ 109{
107 mDtEnd = end; 110 mDtEnd = end;
108 return true; 111 return true;
109} 112}
110 113
111QDateTime FreeBusy::dtEnd() const 114QDateTime FreeBusy::dtEnd() const
112{ 115{
113 return mDtEnd; 116 return mDtEnd;
114} 117}
115 118
116QValueList<Period> FreeBusy::busyPeriods() const 119Q3ValueList<Period> FreeBusy::busyPeriods() const
117{ 120{
118 return mBusyPeriods; 121 return mBusyPeriods;
119} 122}
120 123
121bool FreeBusy::addLocalPeriod(const QDateTime &eventStart, const QDateTime &eventEnd ) { 124bool FreeBusy::addLocalPeriod(const QDateTime &eventStart, const QDateTime &eventEnd ) {
122 QDateTime tmpStart; 125 QDateTime tmpStart;
123 QDateTime tmpEnd; 126 QDateTime tmpEnd;
124 127
125 //Check to see if the start *or* end of the event is 128 //Check to see if the start *or* end of the event is
126 //between the start and end of the freebusy dates. 129 //between the start and end of the freebusy dates.
127 if (!((((this->dtStart()).secsTo(eventStart)>=0)&&(eventStart.secsTo(this->dtEnd())>=0)) 130 if (!((((this->dtStart()).secsTo(eventStart)>=0)&&(eventStart.secsTo(this->dtEnd())>=0))
128 ||(((this->dtStart()).secsTo(eventEnd) >= 0)&&(eventEnd.secsTo(this->dtEnd()) >= 0)))) 131 ||(((this->dtStart()).secsTo(eventEnd) >= 0)&&(eventEnd.secsTo(this->dtEnd()) >= 0))))
@@ -137,32 +140,32 @@ bool FreeBusy::addLocalPeriod(const QDateTime &eventStart, const QDateTime &even
137 if ( eventEnd.secsTo(this->dtEnd())<=0 ) { 140 if ( eventEnd.secsTo(this->dtEnd())<=0 ) {
138 tmpEnd = this->dtEnd(); 141 tmpEnd = this->dtEnd();
139 } else { 142 } else {
140 tmpEnd = eventEnd; 143 tmpEnd = eventEnd;
141 } 144 }
142 145
143 Period p(tmpStart, tmpEnd); 146 Period p(tmpStart, tmpEnd);
144 mBusyPeriods.append( p ); 147 mBusyPeriods.append( p );
145 148
146 return true; 149 return true;
147} 150}
148 151
149FreeBusy::FreeBusy(QValueList<Period> busyPeriods) 152FreeBusy::FreeBusy(Q3ValueList<Period> busyPeriods)
150{ 153{
151 mBusyPeriods = busyPeriods; 154 mBusyPeriods = busyPeriods;
152} 155}
153 156
154void FreeBusy::sortList() 157void FreeBusy::sortList()
155{ 158{
156 typedef QValueList<Period> PeriodList; 159 typedef Q3ValueList<Period> PeriodList;
157 160
158 PeriodList::Iterator tmpPeriod, earlyPeriod; 161 PeriodList::Iterator tmpPeriod, earlyPeriod;
159 PeriodList sortedList; 162 PeriodList sortedList;
160 QDateTime earlyTime; 163 QDateTime earlyTime;
161 164
162 while( mBusyPeriods.count() > 0 ) { 165 while( mBusyPeriods.count() > 0 ) {
163 earlyTime=(*mBusyPeriods.begin()).start(); 166 earlyTime=(*mBusyPeriods.begin()).start();
164 for (tmpPeriod=mBusyPeriods.begin(); tmpPeriod!=mBusyPeriods.end(); tmpPeriod++) { 167 for (tmpPeriod=mBusyPeriods.begin(); tmpPeriod!=mBusyPeriods.end(); tmpPeriod++) {
165 if (earlyTime.secsTo((*tmpPeriod).start()) <= 0) { 168 if (earlyTime.secsTo((*tmpPeriod).start()) <= 0) {
166 earlyTime=(*tmpPeriod).start(); 169 earlyTime=(*tmpPeriod).start();
167 earlyPeriod=tmpPeriod; 170 earlyPeriod=tmpPeriod;
168 } 171 }
diff --git a/libkcal/freebusy.h b/libkcal/freebusy.h
index d741c72..bd14cb7 100644
--- a/libkcal/freebusy.h
+++ b/libkcal/freebusy.h
@@ -15,59 +15,61 @@
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#ifndef KCAL_FREEBUSY_H 20#ifndef KCAL_FREEBUSY_H
21#define KCAL_FREEBUSY_H 21#define KCAL_FREEBUSY_H
22// 22//
23// FreeBusy - information about free/busy times 23// FreeBusy - information about free/busy times
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qvaluelist.h> 27#include <q3valuelist.h>
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29//Added by qt3to4:
30#include <Q3CString>
29 31
30#include "period.h" 32#include "period.h"
31#include "calendar.h" 33#include "calendar.h"
32 34
33#include "incidencebase.h" 35#include "incidencebase.h"
34 36
35namespace KCal { 37namespace KCal {
36 38
37/** 39/**
38 This class provides information about free/busy time of a calendar user. 40 This class provides information about free/busy time of a calendar user.
39*/ 41*/
40class FreeBusy : public IncidenceBase 42class FreeBusy : public IncidenceBase
41{ 43{
42 public: 44 public:
43 FreeBusy(); 45 FreeBusy();
44 FreeBusy(const QDateTime &start, const QDateTime &end); 46 FreeBusy(const QDateTime &start, const QDateTime &end);
45 FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end); 47 FreeBusy(Calendar *calendar, const QDateTime &start, const QDateTime &end);
46 FreeBusy(QValueList<Period> busyPeriods); 48 FreeBusy(Q3ValueList<Period> busyPeriods);
47 49
48 ~FreeBusy(); 50 ~FreeBusy();
49 51
50 QCString type() const { return "FreeBusy"; } 52 Q3CString type() const { return "FreeBusy"; }
51 IncTypeID typeID() const { return freebusyID; } 53 IncTypeID typeID() const { return freebusyID; }
52 54
53 virtual QDateTime dtEnd() const; 55 virtual QDateTime dtEnd() const;
54 bool setDtEnd( const QDateTime &end ); 56 bool setDtEnd( const QDateTime &end );
55 57
56 QValueList<Period> busyPeriods() const; 58 Q3ValueList<Period> busyPeriods() const;
57 59
58 void addPeriod(const QDateTime &start, const QDateTime &end); 60 void addPeriod(const QDateTime &start, const QDateTime &end);
59 void sortList(); 61 void sortList();
60 62
61 private: 63 private:
62 64
63 //This is used for creating a freebusy object for the current user 65 //This is used for creating a freebusy object for the current user
64 bool addLocalPeriod(const QDateTime &start, const QDateTime &end); 66 bool addLocalPeriod(const QDateTime &start, const QDateTime &end);
65 67
66 QDateTime mDtEnd; 68 QDateTime mDtEnd;
67 QValueList<Period> mBusyPeriods; 69 Q3ValueList<Period> mBusyPeriods;
68 Calendar *mCalendar; 70 Calendar *mCalendar;
69}; 71};
70 72
71} 73}
72 74
73#endif 75#endif
diff --git a/libkcal/icaldrag.cpp b/libkcal/icaldrag.cpp
index 446a115..7f5a796 100644
--- a/libkcal/icaldrag.cpp
+++ b/libkcal/icaldrag.cpp
@@ -19,25 +19,25 @@
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include "icaldrag.h" 22#include "icaldrag.h"
23 23
24#include "icalformat.h" 24#include "icalformat.h"
25 25
26#include <kdebug.h> 26#include <kdebug.h>
27 27
28using namespace KCal; 28using namespace KCal;
29 29
30ICalDrag::ICalDrag( Calendar *cal, QWidget *parent, const char *name ) 30ICalDrag::ICalDrag( Calendar *cal, QWidget *parent, const char *name )
31 : QStoredDrag( "text/calendar", parent, name ) 31 : Q3StoredDrag( "text/calendar", parent, name )
32{ 32{
33 ICalFormat icf; 33 ICalFormat icf;
34 QString scal = icf.toString( cal ); 34 QString scal = icf.toString( cal );
35 35
36 setEncodedData( scal.utf8() ); 36 setEncodedData( scal.utf8() );
37} 37}
38 38
39bool ICalDrag::canDecode( QMimeSource *me ) 39bool ICalDrag::canDecode( QMimeSource *me )
40{ 40{
41 return me->provides( "text/calendar" ); 41 return me->provides( "text/calendar" );
42} 42}
43 43
diff --git a/libkcal/icaldrag.h b/libkcal/icaldrag.h
index fdf32b7..c1f73f4 100644
--- a/libkcal/icaldrag.h
+++ b/libkcal/icaldrag.h
@@ -13,31 +13,31 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef ICALDRAG_H 22#ifndef ICALDRAG_H
23#define ICALDRAG_H 23#define ICALDRAG_H
24 24
25#include <qdragobject.h> 25#include <q3dragobject.h>
26#include "calendar.h" 26#include "calendar.h"
27 27
28namespace KCal { 28namespace KCal {
29 29
30/** iCalendar drag&drop class. */ 30/** iCalendar drag&drop class. */
31class ICalDrag : public QStoredDrag 31class ICalDrag : public Q3StoredDrag
32{ 32{
33 public: 33 public:
34 /** Create a drag&drop object for iCalendar component \a ical. */ 34 /** Create a drag&drop object for iCalendar component \a ical. */
35 ICalDrag( Calendar *cal, QWidget *parent = 0, const char *name = 0 ); 35 ICalDrag( Calendar *cal, QWidget *parent = 0, const char *name = 0 );
36 ~ICalDrag() {}; 36 ~ICalDrag() {};
37 37
38 /** Return, if drag&drop object can be decode to iCalendar. */ 38 /** Return, if drag&drop object can be decode to iCalendar. */
39 static bool canDecode( QMimeSource * ); 39 static bool canDecode( QMimeSource * );
40 /** Decode drag&drop object to iCalendar component \a cal. */ 40 /** Decode drag&drop object to iCalendar component \a cal. */
41 static bool decode( QMimeSource *e, Calendar *cal ); 41 static bool decode( QMimeSource *e, Calendar *cal );
42}; 42};
43 43
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index 6f3a799..3829bc1 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -11,29 +11,29 @@
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 <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qregexp.h> 24#include <qregexp.h>
25#include <qclipboard.h> 25#include <qclipboard.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtextstream.h> 27#include <q3textstream.h>
28#include <qtextcodec.h> 28#include <qtextcodec.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35extern "C" { 35extern "C" {
36 #include <ical.h> 36 #include <ical.h>
37 #include <icalss.h> 37 #include <icalss.h>
38 #include <icalparser.h> 38 #include <icalparser.h>
39 #include <icalrestriction.h> 39 #include <icalrestriction.h>
@@ -61,60 +61,60 @@ ICalFormat::ICalFormat( bool pe )
61ICalFormat::~ICalFormat() 61ICalFormat::~ICalFormat()
62{ 62{
63 delete mImpl; 63 delete mImpl;
64 //qDebug("delete ICalFormat "); 64 //qDebug("delete ICalFormat ");
65} 65}
66 66
67bool ICalFormat::load( Calendar *calendar, const QString &fileName) 67bool ICalFormat::load( Calendar *calendar, const QString &fileName)
68{ 68{
69 69
70 clearException(); 70 clearException();
71 71
72 QFile file( fileName ); 72 QFile file( fileName );
73 if (!file.open( IO_ReadOnly ) ) { 73 if (!file.open( QIODevice::ReadOnly ) ) {
74 setException(new ErrorFormat(ErrorFormat::LoadError)); 74 setException(new ErrorFormat(ErrorFormat::LoadError));
75 return false; 75 return false;
76 } 76 }
77 QTextStream ts( &file ); 77 Q3TextStream ts( &file );
78 QString text; 78 QString text;
79 79
80 ts.setEncoding( QTextStream::Latin1 ); 80 ts.setEncoding( Q3TextStream::Latin1 );
81 text = ts.read(); 81 text = ts.read();
82 file.close(); 82 file.close();
83 83
84 return fromString( calendar, text ); 84 return fromString( calendar, text );
85} 85}
86 86
87//#include <qdatetime.h> 87//#include <qdatetime.h>
88bool ICalFormat::save( Calendar *calendar, const QString &fileName ) 88bool ICalFormat::save( Calendar *calendar, const QString &fileName )
89{ 89{
90 //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl; 90 //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl;
91 //qDebug("ICalFormat::save "); 91 //qDebug("ICalFormat::save ");
92 clearException(); 92 clearException();
93 QString text = toString( calendar ); 93 QString text = toString( calendar );
94 //return false; 94 //return false;
95 // qDebug("to string takes ms: %d ",is.elapsed() ); 95 // qDebug("to string takes ms: %d ",is.elapsed() );
96 if ( text.isNull() ) return false; 96 if ( text.isNull() ) return false;
97 97
98 // TODO: write backup file 98 // TODO: write backup file
99 //is.restart(); 99 //is.restart();
100 QFile file( fileName ); 100 QFile file( fileName );
101 if (!file.open( IO_WriteOnly ) ) { 101 if (!file.open( QIODevice::WriteOnly ) ) {
102 setException(new ErrorFormat(ErrorFormat::SaveError, 102 setException(new ErrorFormat(ErrorFormat::SaveError,
103 i18n("Could not open file '%1'").arg(fileName))); 103 i18n("Could not open file '%1'").arg(fileName)));
104 return false; 104 return false;
105 } 105 }
106 QTextStream ts( &file ); 106 Q3TextStream ts( &file );
107 107
108 ts.setEncoding( QTextStream::Latin1 ); 108 ts.setEncoding( Q3TextStream::Latin1 );
109 ts << text; 109 ts << text;
110 file.close(); 110 file.close();
111 //qDebug("saving file takes ms: %d ", is.elapsed() ); 111 //qDebug("saving file takes ms: %d ", is.elapsed() );
112 return true; 112 return true;
113} 113}
114 114
115bool ICalFormat::fromString( Calendar *cal, const QString &text ) 115bool ICalFormat::fromString( Calendar *cal, const QString &text )
116{ 116{
117 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 117 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
118 // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1()); 118 // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1());
119 // Get first VCALENDAR component. 119 // Get first VCALENDAR component.
120 // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components 120 // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components
@@ -147,76 +147,76 @@ bool ICalFormat::fromString( Calendar *cal, const QString &text )
147 icalcomponent_free( calendar ); 147 icalcomponent_free( calendar );
148 icalmemory_free_ring(); 148 icalmemory_free_ring();
149 149
150 return success; 150 return success;
151} 151}
152 152
153Incidence *ICalFormat::fromString( const QString &text ) 153Incidence *ICalFormat::fromString( const QString &text )
154{ 154{
155 CalendarLocal cal( mTimeZoneId ); 155 CalendarLocal cal( mTimeZoneId );
156 fromString(&cal, text); 156 fromString(&cal, text);
157 157
158 Incidence *ical = 0; 158 Incidence *ical = 0;
159 QPtrList<Event> elist = cal.events(); 159 Q3PtrList<Event> elist = cal.events();
160 if ( elist.count() > 0 ) { 160 if ( elist.count() > 0 ) {
161 ical = elist.first(); 161 ical = elist.first();
162 } else { 162 } else {
163 QPtrList<Todo> tlist = cal.todos(); 163 Q3PtrList<Todo> tlist = cal.todos();
164 if ( tlist.count() > 0 ) { 164 if ( tlist.count() > 0 ) {
165 ical = tlist.first(); 165 ical = tlist.first();
166 } else { 166 } else {
167 QPtrList<Journal> jlist = cal.journals(); 167 Q3PtrList<Journal> jlist = cal.journals();
168 if ( jlist.count() > 0 ) { 168 if ( jlist.count() > 0 ) {
169 ical = jlist.first(); 169 ical = jlist.first();
170 } 170 }
171 } 171 }
172 } 172 }
173 return ical; 173 return ical;
174} 174}
175#include <qapp.h> 175#include <qapplication.h>
176 176
177QString ICalFormat::toString( Calendar *cal ) 177QString ICalFormat::toString( Calendar *cal )
178{ 178{
179 179
180 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 180 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
181 181
182 icalcomponent *calendar = mImpl->createCalendarComponent(cal); 182 icalcomponent *calendar = mImpl->createCalendarComponent(cal);
183 183
184 icalcomponent *component; 184 icalcomponent *component;
185 185
186 // todos 186 // todos
187 QPtrList<Todo> todoList = cal->rawTodos(); 187 Q3PtrList<Todo> todoList = cal->rawTodos();
188 QPtrListIterator<Todo> qlt(todoList); 188 Q3PtrListIterator<Todo> qlt(todoList);
189 for (; qlt.current(); ++qlt) { 189 for (; qlt.current(); ++qlt) {
190 component = mImpl->writeTodo(qlt.current()); 190 component = mImpl->writeTodo(qlt.current());
191 icalcomponent_add_component(calendar,component); 191 icalcomponent_add_component(calendar,component);
192 //qDebug(" todos "); 192 //qDebug(" todos ");
193 if ( mProcessEvents ) { 193 if ( mProcessEvents ) {
194 //qDebug("mProcessEvents "); 194 //qDebug("mProcessEvents ");
195 qApp->processEvents(); 195 qApp->processEvents();
196 } 196 }
197 } 197 }
198 // events 198 // events
199 QPtrList<Event> events = cal->rawEvents(); 199 Q3PtrList<Event> events = cal->rawEvents();
200 Event *ev; 200 Event *ev;
201 for(ev=events.first();ev;ev=events.next()) { 201 for(ev=events.first();ev;ev=events.next()) {
202 component = mImpl->writeEvent(ev); 202 component = mImpl->writeEvent(ev);
203 icalcomponent_add_component(calendar,component); 203 icalcomponent_add_component(calendar,component);
204 //qDebug("events "); 204 //qDebug("events ");
205 if ( mProcessEvents ) 205 if ( mProcessEvents )
206 qApp->processEvents(); 206 qApp->processEvents();
207 } 207 }
208 208
209 // journals 209 // journals
210 QPtrList<Journal> journals = cal->journals(); 210 Q3PtrList<Journal> journals = cal->journals();
211 Journal *j; 211 Journal *j;
212 for(j=journals.first();j;j=journals.next()) { 212 for(j=journals.first();j;j=journals.next()) {
213 component = mImpl->writeJournal(j); 213 component = mImpl->writeJournal(j);
214 icalcomponent_add_component(calendar,component); 214 icalcomponent_add_component(calendar,component);
215 //qDebug("journals "); 215 //qDebug("journals ");
216 if ( mProcessEvents ) 216 if ( mProcessEvents )
217 qApp->processEvents(); 217 qApp->processEvents();
218 } 218 }
219 const char *text; 219 const char *text;
220 QString ret =""; 220 QString ret ="";
221 text = icalcomponent_as_ical_string( calendar ); 221 text = icalcomponent_as_ical_string( calendar );
222 if ( mProcessEvents ) 222 if ( mProcessEvents )
diff --git a/libkcal/icalformat.h b/libkcal/icalformat.h
index a770dbb..a454b35 100644
--- a/libkcal/icalformat.h
+++ b/libkcal/icalformat.h
@@ -12,24 +12,26 @@
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#ifndef ICALFORMAT_H 20#ifndef ICALFORMAT_H
21#define ICALFORMAT_H 21#define ICALFORMAT_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24//Added by qt3to4:
25#include <Q3CString>
24 26
25#include "scheduler.h" 27#include "scheduler.h"
26 28
27#include "calformat.h" 29#include "calformat.h"
28 30
29namespace KCal { 31namespace KCal {
30 32
31class ICalFormatImpl; 33class ICalFormatImpl;
32 34
33/** 35/**
34 This class implements the iCalendar format. It provides methods for 36 This class implements the iCalendar format. It provides methods for
35 loading/saving/converting iCalendar format data into the internal KOrganizer 37 loading/saving/converting iCalendar format data into the internal KOrganizer
@@ -97,20 +99,20 @@ class ICalFormat : public CalFormat {
97 99
98 /** Set id of used time zone and whether this time zone is UTC or not. */ 100 /** Set id of used time zone and whether this time zone is UTC or not. */
99 void setTimeZone( const QString &id, bool utc ); 101 void setTimeZone( const QString &id, bool utc );
100 QString timeZoneId() const; 102 QString timeZoneId() const;
101 int timeOffset(); 103 int timeOffset();
102 const char * tzString(); 104 const char * tzString();
103 bool utc() const; 105 bool utc() const;
104 106
105 private: 107 private:
106 bool mProcessEvents; 108 bool mProcessEvents;
107 ICalFormatImpl *mImpl; 109 ICalFormatImpl *mImpl;
108 QString mTimeZoneId; 110 QString mTimeZoneId;
109 QCString mTzString; 111 Q3CString mTzString;
110 int tzOffsetMin; 112 int tzOffsetMin;
111 bool mUtc; 113 bool mUtc;
112}; 114};
113 115
114} 116}
115 117
116#endif 118#endif
diff --git a/libkcal/icalformatimpl.cpp b/libkcal/icalformatimpl.cpp
index 65eabc8..ea144ee 100644
--- a/libkcal/icalformatimpl.cpp
+++ b/libkcal/icalformatimpl.cpp
@@ -11,26 +11,29 @@
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 <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qfile.h> 24#include <qfile.h>
25//Added by qt3to4:
26#include <Q3ValueList>
27#include <Q3CString>
25 28
26#include <kdebug.h> 29#include <kdebug.h>
27#include <klocale.h> 30#include <klocale.h>
28#include <kglobal.h> 31#include <kglobal.h>
29 32
30extern "C" { 33extern "C" {
31 #include <ical.h> 34 #include <ical.h>
32 #include <icalss.h> 35 #include <icalss.h>
33 #include <icalparser.h> 36 #include <icalparser.h>
34 #include <icalrestriction.h> 37 #include <icalrestriction.h>
35} 38}
36 39
@@ -212,26 +215,26 @@ icalcomponent *ICalFormatImpl::writeFreeBusy(FreeBusy *freebusy,
212 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart( 215 icalcomponent_add_property(vfreebusy, icalproperty_new_dtstart(
213 writeICalDateTime(freebusy->dtStart()))); 216 writeICalDateTime(freebusy->dtStart())));
214 217
215 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend( 218 icalcomponent_add_property(vfreebusy, icalproperty_new_dtend(
216 writeICalDateTime(freebusy->dtEnd()))); 219 writeICalDateTime(freebusy->dtEnd())));
217 220
218 if (method == Scheduler::Request) { 221 if (method == Scheduler::Request) {
219 icalcomponent_add_property(vfreebusy,icalproperty_new_uid( 222 icalcomponent_add_property(vfreebusy,icalproperty_new_uid(
220 freebusy->uid().utf8())); 223 freebusy->uid().utf8()));
221 } 224 }
222 225
223 //Loops through all the periods in the freebusy object 226 //Loops through all the periods in the freebusy object
224 QValueList<Period> list = freebusy->busyPeriods(); 227 Q3ValueList<Period> list = freebusy->busyPeriods();
225 QValueList<Period>::Iterator it; 228 Q3ValueList<Period>::Iterator it;
226 icalperiodtype period; 229 icalperiodtype period;
227 for (it = list.begin(); it!= list.end(); ++it) { 230 for (it = list.begin(); it!= list.end(); ++it) {
228 period.start = writeICalDateTime((*it).start()); 231 period.start = writeICalDateTime((*it).start());
229 period.end = writeICalDateTime((*it).end()); 232 period.end = writeICalDateTime((*it).end());
230 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) ); 233 icalcomponent_add_property(vfreebusy, icalproperty_new_freebusy(period) );
231 } 234 }
232 235
233 return vfreebusy; 236 return vfreebusy;
234} 237}
235 238
236icalcomponent *ICalFormatImpl::writeJournal(Journal *journal) 239icalcomponent *ICalFormatImpl::writeJournal(Journal *journal)
237{ 240{
@@ -375,30 +378,30 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
375 if (incidence->doesRecur()) { 378 if (incidence->doesRecur()) {
376 icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence())); 379 icalcomponent_add_property(parent,writeRecurrenceRule(incidence->recurrence()));
377 // recurrence excpetion dates 380 // recurrence excpetion dates
378 DateList dateList = incidence->exDates(); 381 DateList dateList = incidence->exDates();
379 DateList::ConstIterator exIt; 382 DateList::ConstIterator exIt;
380 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) { 383 for(exIt = dateList.begin(); exIt != dateList.end(); ++exIt) {
381 icalcomponent_add_property(parent,icalproperty_new_exdate( 384 icalcomponent_add_property(parent,icalproperty_new_exdate(
382 writeICalDate(*exIt))); 385 writeICalDate(*exIt)));
383 } 386 }
384 } 387 }
385 388
386 // attachments 389 // attachments
387 QPtrList<Attachment> attachments = incidence->attachments(); 390 Q3PtrList<Attachment> attachments = incidence->attachments();
388 for (Attachment *at = attachments.first(); at; at = attachments.next()) 391 for (Attachment *at = attachments.first(); at; at = attachments.next())
389 icalcomponent_add_property(parent,writeAttachment(at)); 392 icalcomponent_add_property(parent,writeAttachment(at));
390 393
391 // alarms 394 // alarms
392 QPtrList<Alarm> alarms = incidence->alarms(); 395 Q3PtrList<Alarm> alarms = incidence->alarms();
393 Alarm* alarm; 396 Alarm* alarm;
394 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 397 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
395 if (alarm->enabled()) { 398 if (alarm->enabled()) {
396 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl; 399 kdDebug(5800) << "Write alarm for " << incidence->summary() << endl;
397 icalcomponent_add_component(parent,writeAlarm(alarm)); 400 icalcomponent_add_component(parent,writeAlarm(alarm));
398 } 401 }
399 } 402 }
400 if( incidence->hasRecurrenceID() ) { 403 if( incidence->hasRecurrenceID() ) {
401 icalcomponent_add_property(parent, 404 icalcomponent_add_property(parent,
402 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID()))); 405 icalproperty_new_recurrenceid( writeICalDateTime( incidence->recurrenceID())));
403 } 406 }
404 // duration 407 // duration
@@ -414,39 +417,39 @@ void ICalFormatImpl::writeIncidence(icalcomponent *parent,Incidence *incidence)
414 417
415void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase) 418void ICalFormatImpl::writeIncidenceBase(icalcomponent *parent,IncidenceBase *incidenceBase)
416{ 419{
417 icalcomponent_add_property(parent,icalproperty_new_dtstamp( 420 icalcomponent_add_property(parent,icalproperty_new_dtstamp(
418 writeICalDateTime(QDateTime::currentDateTime()))); 421 writeICalDateTime(QDateTime::currentDateTime())));
419 422
420 // organizer stuff 423 // organizer stuff
421 icalcomponent_add_property(parent,icalproperty_new_organizer( 424 icalcomponent_add_property(parent,icalproperty_new_organizer(
422 ("MAILTO:" + incidenceBase->organizer()).utf8())); 425 ("MAILTO:" + incidenceBase->organizer()).utf8()));
423 426
424 // attendees 427 // attendees
425 if (incidenceBase->attendeeCount() != 0) { 428 if (incidenceBase->attendeeCount() != 0) {
426 QPtrList<Attendee> al = incidenceBase->attendees(); 429 Q3PtrList<Attendee> al = incidenceBase->attendees();
427 QPtrListIterator<Attendee> ai(al); 430 Q3PtrListIterator<Attendee> ai(al);
428 for (; ai.current(); ++ai) { 431 for (; ai.current(); ++ai) {
429 icalcomponent_add_property(parent,writeAttendee(ai.current())); 432 icalcomponent_add_property(parent,writeAttendee(ai.current()));
430 } 433 }
431 } 434 }
432 435
433 // custom properties 436 // custom properties
434 writeCustomProperties(parent, incidenceBase); 437 writeCustomProperties(parent, incidenceBase);
435} 438}
436 439
437void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties) 440void ICalFormatImpl::writeCustomProperties(icalcomponent *parent,CustomProperties *properties)
438{ 441{
439 QMap<QCString, QString> custom = properties->customProperties(); 442 QMap<Q3CString, QString> custom = properties->customProperties();
440 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 443 for (QMap<Q3CString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
441 icalproperty *p = icalproperty_new_x(c.data().utf8()); 444 icalproperty *p = icalproperty_new_x(c.data().utf8());
442 icalproperty_set_x_name(p,c.key()); 445 icalproperty_set_x_name(p,c.key());
443 icalcomponent_add_property(parent,p); 446 icalcomponent_add_property(parent,p);
444 } 447 }
445} 448}
446 449
447icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee) 450icalproperty *ICalFormatImpl::writeAttendee(Attendee *attendee)
448{ 451{
449 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8()); 452 icalproperty *p = icalproperty_new_attendee("mailto:" + attendee->email().utf8());
450 453
451 if (!attendee->name().isEmpty()) { 454 if (!attendee->name().isEmpty()) {
452 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8())); 455 icalproperty_add_parameter(p,icalparameter_new_cn(attendee->name().utf8()));
@@ -537,26 +540,26 @@ icalproperty *ICalFormatImpl::writeAttachment(Attachment *att)
537 540
538icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur) 541icalproperty *ICalFormatImpl::writeRecurrenceRule(Recurrence *recur)
539{ 542{
540// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl; 543// kdDebug(5800) << "ICalFormatImpl::writeRecurrenceRule()" << endl;
541 544
542 icalrecurrencetype r; 545 icalrecurrencetype r;
543 546
544 icalrecurrencetype_clear(&r); 547 icalrecurrencetype_clear(&r);
545 548
546 int index = 0; 549 int index = 0;
547 int index2 = 0; 550 int index2 = 0;
548 551
549 QPtrList<Recurrence::rMonthPos> tmpPositions; 552 Q3PtrList<Recurrence::rMonthPos> tmpPositions;
550 QPtrList<int> tmpDays; 553 Q3PtrList<int> tmpDays;
551 int *tmpDay; 554 int *tmpDay;
552 Recurrence::rMonthPos *tmpPos; 555 Recurrence::rMonthPos *tmpPos;
553 bool datetime = false; 556 bool datetime = false;
554 int day; 557 int day;
555 int i; 558 int i;
556 559
557 switch(recur->doesRecur()) { 560 switch(recur->doesRecur()) {
558 case Recurrence::rMinutely: 561 case Recurrence::rMinutely:
559 r.freq = ICAL_MINUTELY_RECURRENCE; 562 r.freq = ICAL_MINUTELY_RECURRENCE;
560 datetime = true; 563 datetime = true;
561 break; 564 break;
562 case Recurrence::rHourly: 565 case Recurrence::rHourly:
@@ -695,26 +698,26 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
695 icalattach_unref( attach ); 698 icalattach_unref( attach );
696 break; 699 break;
697 case Alarm::Audio: 700 case Alarm::Audio:
698 action = ICAL_ACTION_AUDIO; 701 action = ICAL_ACTION_AUDIO;
699 if (!alarm->audioFile().isEmpty()) { 702 if (!alarm->audioFile().isEmpty()) {
700 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data()); 703 attach = icalattach_new_from_url(QFile::encodeName( alarm->audioFile() ).data());
701 icalcomponent_add_property(a,icalproperty_new_attach(attach)); 704 icalcomponent_add_property(a,icalproperty_new_attach(attach));
702 icalattach_unref( attach ); 705 icalattach_unref( attach );
703 } 706 }
704 break; 707 break;
705 case Alarm::Email: { 708 case Alarm::Email: {
706 action = ICAL_ACTION_EMAIL; 709 action = ICAL_ACTION_EMAIL;
707 QValueList<Person> addresses = alarm->mailAddresses(); 710 Q3ValueList<Person> addresses = alarm->mailAddresses();
708 for (QValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) { 711 for (Q3ValueList<Person>::Iterator ad = addresses.begin(); ad != addresses.end(); ++ad) {
709 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8()); 712 icalproperty *p = icalproperty_new_attendee("MAILTO:" + (*ad).email().utf8());
710 if (!(*ad).name().isEmpty()) { 713 if (!(*ad).name().isEmpty()) {
711 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8())); 714 icalproperty_add_parameter(p,icalparameter_new_cn((*ad).name().utf8()));
712 } 715 }
713 icalcomponent_add_property(a,p); 716 icalcomponent_add_property(a,p);
714 } 717 }
715 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8())); 718 icalcomponent_add_property(a,icalproperty_new_summary(alarm->mailSubject().utf8()));
716 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8())); 719 icalcomponent_add_property(a,icalproperty_new_description(alarm->text().utf8()));
717 QStringList attachments = alarm->mailAttachments(); 720 QStringList attachments = alarm->mailAttachments();
718 if (attachments.count() > 0) { 721 if (attachments.count() > 0) {
719 for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) { 722 for (QStringList::Iterator at = attachments.begin(); at != attachments.end(); ++at) {
720 attach = icalattach_new_from_url(QFile::encodeName( *at ).data()); 723 attach = icalattach_new_from_url(QFile::encodeName( *at ).data());
@@ -754,26 +757,26 @@ icalcomponent *ICalFormatImpl::writeAlarm(Alarm *alarm)
754 if ( alarm->hasEndOffset() ) 757 if ( alarm->hasEndOffset() )
755 icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END)); 758 icalproperty_add_parameter(p,icalparameter_new_related(ICAL_RELATED_END));
756 icalcomponent_add_property(a,p); 759 icalcomponent_add_property(a,p);
757 760
758 // Repeat count and duration 761 // Repeat count and duration
759 if (alarm->repeatCount()) { 762 if (alarm->repeatCount()) {
760 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount())); 763 icalcomponent_add_property(a,icalproperty_new_repeat(alarm->repeatCount()));
761 icalcomponent_add_property(a,icalproperty_new_duration( 764 icalcomponent_add_property(a,icalproperty_new_duration(
762 icaldurationtype_from_int(alarm->snoozeTime()*60))); 765 icaldurationtype_from_int(alarm->snoozeTime()*60)));
763 } 766 }
764 767
765 // Custom properties 768 // Custom properties
766 QMap<QCString, QString> custom = alarm->customProperties(); 769 QMap<Q3CString, QString> custom = alarm->customProperties();
767 for (QMap<QCString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) { 770 for (QMap<Q3CString, QString>::Iterator c = custom.begin(); c != custom.end(); ++c) {
768 icalproperty *p = icalproperty_new_x(c.data().utf8()); 771 icalproperty *p = icalproperty_new_x(c.data().utf8());
769 icalproperty_set_x_name(p,c.key()); 772 icalproperty_set_x_name(p,c.key());
770 icalcomponent_add_property(a,p); 773 icalcomponent_add_property(a,p);
771 } 774 }
772 775
773 return a; 776 return a;
774} 777}
775 778
776Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo) 779Todo *ICalFormatImpl::readTodo(icalcomponent *vtodo)
777{ 780{
778 Todo *todo = new Todo; 781 Todo *todo = new Todo;
779 782
@@ -1330,25 +1333,25 @@ void ICalFormatImpl::readIncidenceBase(icalcomponent *parent,IncidenceBase *inci
1330 break; 1333 break;
1331 } 1334 }
1332 1335
1333 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY); 1336 p = icalcomponent_get_next_property(parent,ICAL_ANY_PROPERTY);
1334 } 1337 }
1335 1338
1336 // custom properties 1339 // custom properties
1337 readCustomProperties(parent, incidenceBase); 1340 readCustomProperties(parent, incidenceBase);
1338} 1341}
1339 1342
1340void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties) 1343void ICalFormatImpl::readCustomProperties(icalcomponent *parent,CustomProperties *properties)
1341{ 1344{
1342 QMap<QCString, QString> customProperties; 1345 QMap<Q3CString, QString> customProperties;
1343 1346
1344 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY); 1347 icalproperty *p = icalcomponent_get_first_property(parent,ICAL_X_PROPERTY);
1345 1348
1346 while (p) { 1349 while (p) {
1347 QString value = QString::fromUtf8(icalproperty_get_x(p)); 1350 QString value = QString::fromUtf8(icalproperty_get_x(p));
1348 customProperties[icalproperty_get_x_name(p)] = value; 1351 customProperties[icalproperty_get_x_name(p)] = value;
1349 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) ); 1352 //qDebug("ICalFormatImpl::readCustomProperties %s %s",value.latin1(), icalproperty_get_x_name(p) );
1350 1353
1351 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY); 1354 p = icalcomponent_get_next_property(parent,ICAL_X_PROPERTY);
1352 } 1355 }
1353 1356
1354 properties->setCustomProperties(customProperties); 1357 properties->setCustomProperties(customProperties);
diff --git a/libkcal/icalformatimpl.h b/libkcal/icalformatimpl.h
index 203c302..3a35b4c 100644
--- a/libkcal/icalformatimpl.h
+++ b/libkcal/icalformatimpl.h
@@ -12,24 +12,26 @@
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#ifndef ICALFORMATIMPL_H 20#ifndef ICALFORMATIMPL_H
21#define ICALFORMATIMPL_H 21#define ICALFORMATIMPL_H
22 22
23#include <qstring.h> 23#include <qstring.h>
24//Added by qt3to4:
25#include <Q3PtrList>
24 26
25#include "scheduler.h" 27#include "scheduler.h"
26#include "freebusy.h" 28#include "freebusy.h"
27 29
28extern "C" { 30extern "C" {
29 #include <ical.h> 31 #include <ical.h>
30 #include <icalss.h> 32 #include <icalss.h>
31} 33}
32 34
33namespace KCal { 35namespace KCal {
34 36
35class Compat; 37class Compat;
@@ -84,26 +86,26 @@ class ICalFormatImpl {
84 void writeIncidenceBase(icalcomponent *parent,IncidenceBase *); 86 void writeIncidenceBase(icalcomponent *parent,IncidenceBase *);
85 void readIncidenceBase(icalcomponent *parent,IncidenceBase *); 87 void readIncidenceBase(icalcomponent *parent,IncidenceBase *);
86 void writeCustomProperties(icalcomponent *parent,CustomProperties *); 88 void writeCustomProperties(icalcomponent *parent,CustomProperties *);
87 void readCustomProperties(icalcomponent *parent,CustomProperties *); 89 void readCustomProperties(icalcomponent *parent,CustomProperties *);
88 void dumpIcalRecurrence(icalrecurrencetype); 90 void dumpIcalRecurrence(icalrecurrencetype);
89 91
90 ICalFormat *mParent; 92 ICalFormat *mParent;
91 Calendar *mCalendar; 93 Calendar *mCalendar;
92 94
93 QString mLoadedProductId; // PRODID string loaded from calendar file 95 QString mLoadedProductId; // PRODID string loaded from calendar file
94 int mCalendarVersion; // determines backward compatibility mode on read 96 int mCalendarVersion; // determines backward compatibility mode on read
95 97
96 QPtrList<Event> mEventsRelate; // events with relations 98 Q3PtrList<Event> mEventsRelate; // events with relations
97 QPtrList<Todo> mTodosRelate; // todos with relations 99 Q3PtrList<Todo> mTodosRelate; // todos with relations
98 100
99 static const int mSecondsPerWeek; 101 static const int mSecondsPerWeek;
100 static const int mSecondsPerDay; 102 static const int mSecondsPerDay;
101 static const int mSecondsPerHour; 103 static const int mSecondsPerHour;
102 static const int mSecondsPerMinute; 104 static const int mSecondsPerMinute;
103 105
104 Compat *mCompat; 106 Compat *mCompat;
105}; 107};
106 108
107} 109}
108 110
109#endif 111#endif
diff --git a/libkcal/imipscheduler.cpp b/libkcal/imipscheduler.cpp
index e186f8e..e6d56a6 100644
--- a/libkcal/imipscheduler.cpp
+++ b/libkcal/imipscheduler.cpp
@@ -17,42 +17,44 @@
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// 21//
22// IMIPScheduler - iMIP implementation of iTIP methods 22// IMIPScheduler - iMIP implementation of iTIP methods
23// 23//
24 24
25#include "event.h" 25#include "event.h"
26#include "icalformat.h" 26#include "icalformat.h"
27 27
28#include "imipscheduler.h" 28#include "imipscheduler.h"
29//Added by qt3to4:
30#include <Q3PtrList>
29 31
30using namespace KCal; 32using namespace KCal;
31 33
32IMIPScheduler::IMIPScheduler(Calendar *calendar) 34IMIPScheduler::IMIPScheduler(Calendar *calendar)
33 : Scheduler(calendar) 35 : Scheduler(calendar)
34{ 36{
35} 37}
36 38
37IMIPScheduler::~IMIPScheduler() 39IMIPScheduler::~IMIPScheduler()
38{ 40{
39} 41}
40 42
41bool IMIPScheduler::publish (IncidenceBase *incidence,const QString &recipients) 43bool IMIPScheduler::publish (IncidenceBase *incidence,const QString &recipients)
42{ 44{
43 return false; 45 return false;
44} 46}
45 47
46bool IMIPScheduler::performTransaction(IncidenceBase *incidence,Method method) 48bool IMIPScheduler::performTransaction(IncidenceBase *incidence,Method method)
47{ 49{
48 mFormat->createScheduleMessage(incidence,method); 50 mFormat->createScheduleMessage(incidence,method);
49 51
50 return false; 52 return false;
51} 53}
52 54
53QPtrList<ScheduleMessage> IMIPScheduler::retrieveTransactions() 55Q3PtrList<ScheduleMessage> IMIPScheduler::retrieveTransactions()
54{ 56{
55 QPtrList<ScheduleMessage> messageList; 57 Q3PtrList<ScheduleMessage> messageList;
56 58
57 return messageList; 59 return messageList;
58} 60}
diff --git a/libkcal/imipscheduler.h b/libkcal/imipscheduler.h
index f142060..5a2d38e 100644
--- a/libkcal/imipscheduler.h
+++ b/libkcal/imipscheduler.h
@@ -14,36 +14,36 @@
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#ifndef IMIPSCHEDULER_H 20#ifndef IMIPSCHEDULER_H
21#define IMIPSCHEDULER_H 21#define IMIPSCHEDULER_H
22// 22//
23// iMIP implementation of iTIP methods 23// iMIP implementation of iTIP methods
24// 24//
25 25
26#include <qptrlist.h> 26#include <q3ptrlist.h>
27 27
28#include "scheduler.h" 28#include "scheduler.h"
29 29
30namespace KCal { 30namespace KCal {
31 31
32/* 32/*
33 This class implements the iTIP interface using the email interface specified 33 This class implements the iTIP interface using the email interface specified
34 as iMIP. 34 as iMIP.
35*/ 35*/
36class IMIPScheduler : public Scheduler { 36class IMIPScheduler : public Scheduler {
37 public: 37 public:
38 IMIPScheduler(Calendar *); 38 IMIPScheduler(Calendar *);
39 virtual ~IMIPScheduler(); 39 virtual ~IMIPScheduler();
40 40
41 bool publish (IncidenceBase *incidence,const QString &recipients); 41 bool publish (IncidenceBase *incidence,const QString &recipients);
42 bool performTransaction(IncidenceBase *incidence,Method method); 42 bool performTransaction(IncidenceBase *incidence,Method method);
43 QPtrList<ScheduleMessage> retrieveTransactions(); 43 Q3PtrList<ScheduleMessage> retrieveTransactions();
44}; 44};
45 45
46} 46}
47 47
48#endif // IMIPSCHEDULER_H 48#endif // IMIPSCHEDULER_H
49 49
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 7dd9bd2..8fcdc69 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -17,24 +17,26 @@
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//Added by qt3to4:
30#include <Q3PtrList>
29 31
30using namespace KCal; 32using namespace KCal;
31 33
32Incidence::Incidence() : 34Incidence::Incidence() :
33 IncidenceBase(), 35 IncidenceBase(),
34 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) 36 mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3)
35{ 37{
36 mRecurrence = 0;//new Recurrence(this); 38 mRecurrence = 0;//new Recurrence(this);
37 mCancelled = false; 39 mCancelled = false;
38 recreate(); 40 recreate();
39 mHasStartDate = true; 41 mHasStartDate = true;
40 mAlarms.setAutoDelete(true); 42 mAlarms.setAutoDelete(true);
@@ -50,64 +52,64 @@ Incidence::Incidence( const Incidence &i ) : IncidenceBase( i )
50{ 52{
51// TODO: reenable attributes currently commented out. 53// TODO: reenable attributes currently commented out.
52 mRevision = i.mRevision; 54 mRevision = i.mRevision;
53 mCreated = i.mCreated; 55 mCreated = i.mCreated;
54 mDescription = i.mDescription; 56 mDescription = i.mDescription;
55 mSummary = i.mSummary; 57 mSummary = i.mSummary;
56 mCategories = i.mCategories; 58 mCategories = i.mCategories;
57// Incidence *mRelatedTo; Incidence *mRelatedTo; 59// Incidence *mRelatedTo; Incidence *mRelatedTo;
58 mRelatedTo = 0; 60 mRelatedTo = 0;
59 mRelatedToUid = i.mRelatedToUid; 61 mRelatedToUid = i.mRelatedToUid;
60// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; 62// QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations;
61 mExDates = i.mExDates; 63 mExDates = i.mExDates;
62 QPtrListIterator<Attachment> itat( i.mAttachments ); 64 Q3PtrListIterator<Attachment> itat( i.mAttachments );
63 Attachment *at; 65 Attachment *at;
64 while( (at = itat.current()) ) { 66 while( (at = itat.current()) ) {
65 Attachment *a = new Attachment( *at ); 67 Attachment *a = new Attachment( *at );
66 mAttachments.append( a ); 68 mAttachments.append( a );
67 ++itat; 69 ++itat;
68 } 70 }
69 mAttachments.setAutoDelete( true ); 71 mAttachments.setAutoDelete( true );
70 mResources = i.mResources; 72 mResources = i.mResources;
71 mSecrecy = i.mSecrecy; 73 mSecrecy = i.mSecrecy;
72 mPriority = i.mPriority; 74 mPriority = i.mPriority;
73 mLocation = i.mLocation; 75 mLocation = i.mLocation;
74 mCancelled = i.mCancelled; 76 mCancelled = i.mCancelled;
75 mHasStartDate = i.mHasStartDate; 77 mHasStartDate = i.mHasStartDate;
76 QPtrListIterator<Alarm> it( i.mAlarms ); 78 Q3PtrListIterator<Alarm> it( i.mAlarms );
77 const Alarm *a; 79 const Alarm *a;
78 while( (a = it.current()) ) { 80 while( (a = it.current()) ) {
79 Alarm *b = new Alarm( *a ); 81 Alarm *b = new Alarm( *a );
80 b->setParent( this ); 82 b->setParent( this );
81 mAlarms.append( b ); 83 mAlarms.append( b );
82 84
83 ++it; 85 ++it;
84 } 86 }
85 mAlarms.setAutoDelete(true); 87 mAlarms.setAutoDelete(true);
86 mHasRecurrenceID = i.mHasRecurrenceID; 88 mHasRecurrenceID = i.mHasRecurrenceID;
87 mRecurrenceID = i.mRecurrenceID; 89 mRecurrenceID = i.mRecurrenceID;
88 if ( i.mRecurrence ) 90 if ( i.mRecurrence )
89 mRecurrence = new Recurrence( *(i.mRecurrence), this ); 91 mRecurrence = new Recurrence( *(i.mRecurrence), this );
90 else 92 else
91 mRecurrence = 0; 93 mRecurrence = 0;
92 mHoliday = i.mHoliday ; 94 mHoliday = i.mHoliday ;
93 mBirthday = i.mBirthday; 95 mBirthday = i.mBirthday;
94 mAnniversary = i.mAnniversary; 96 mAnniversary = i.mAnniversary;
95} 97}
96 98
97Incidence::~Incidence() 99Incidence::~Incidence()
98{ 100{
99 101
100 Incidence *ev; 102 Incidence *ev;
101 QPtrList<Incidence> Relations = relations(); 103 Q3PtrList<Incidence> Relations = relations();
102 for (ev=Relations.first();ev;ev=Relations.next()) { 104 for (ev=Relations.first();ev;ev=Relations.next()) {
103 if (ev->relatedTo() == this) ev->setRelatedTo(0); 105 if (ev->relatedTo() == this) ev->setRelatedTo(0);
104 } 106 }
105 if (relatedTo()) relatedTo()->removeRelation(this); 107 if (relatedTo()) relatedTo()->removeRelation(this);
106 if ( mRecurrence ) 108 if ( mRecurrence )
107 delete mRecurrence; 109 delete mRecurrence;
108 110
109} 111}
110QString Incidence::durationText() 112QString Incidence::durationText()
111{ 113{
112 return "---"; 114 return "---";
113} 115}
@@ -207,26 +209,26 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
207 209
208 if( i1.alarms().count() != i2.alarms().count() ) { 210 if( i1.alarms().count() != i2.alarms().count() ) {
209 return false; // no need to check further 211 return false; // no need to check further
210 } 212 }
211 if ( i1.alarms().count() > 0 ) { 213 if ( i1.alarms().count() > 0 ) {
212 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 214 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
213 { 215 {
214 qDebug("alarm not equal "); 216 qDebug("alarm not equal ");
215 return false; 217 return false;
216 } 218 }
217 } 219 }
218#if 0 220#if 0
219 QPtrListIterator<Alarm> a1( i1.alarms() ); 221 Q3PtrListIterator<Alarm> a1( i1.alarms() );
220 QPtrListIterator<Alarm> a2( i2.alarms() ); 222 Q3PtrListIterator<Alarm> a2( i2.alarms() );
221 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 223 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
222 if( *a1.current() == *a2.current() ) { 224 if( *a1.current() == *a2.current() ) {
223 continue; 225 continue;
224 } 226 }
225 else { 227 else {
226 return false; 228 return false;
227 } 229 }
228 } 230 }
229#endif 231#endif
230 232
231 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 233 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
232 if ( i1.hasRecurrenceID() ) { 234 if ( i1.hasRecurrenceID() ) {
@@ -313,25 +315,25 @@ void Incidence::recreate()
313 315
314 setUid(CalFormat::createUniqueId()); 316 setUid(CalFormat::createUniqueId());
315 317
316 setRevision(0); 318 setRevision(0);
317 setIDStr( ":" ); 319 setIDStr( ":" );
318 setLastModified(QDateTime::currentDateTime()); 320 setLastModified(QDateTime::currentDateTime());
319} 321}
320void Incidence::cloneRelations( Incidence * newInc ) 322void Incidence::cloneRelations( Incidence * newInc )
321{ 323{
322 // newInc is already a clone of this incidence 324 // newInc is already a clone of this incidence
323 Incidence * inc; 325 Incidence * inc;
324 Incidence * cloneInc; 326 Incidence * cloneInc;
325 QPtrList<Incidence> Relations = relations(); 327 Q3PtrList<Incidence> Relations = relations();
326 for (inc=Relations.first();inc;inc=Relations.next()) { 328 for (inc=Relations.first();inc;inc=Relations.next()) {
327 cloneInc = inc->clone(); 329 cloneInc = inc->clone();
328 cloneInc->recreate(); 330 cloneInc->recreate();
329 cloneInc->setRelatedTo( newInc ); 331 cloneInc->setRelatedTo( newInc );
330 inc->cloneRelations( cloneInc ); 332 inc->cloneRelations( cloneInc );
331 } 333 }
332} 334}
333void Incidence::setReadOnly( bool readOnly ) 335void Incidence::setReadOnly( bool readOnly )
334{ 336{
335 IncidenceBase::setReadOnly( readOnly ); 337 IncidenceBase::setReadOnly( readOnly );
336 if ( mRecurrence ) 338 if ( mRecurrence )
337 mRecurrence->setRecurReadOnly( readOnly); 339 mRecurrence->setRecurReadOnly( readOnly);
@@ -347,25 +349,25 @@ QString Incidence::lastModifiedSubSortKey() const
347 if ( mLastModifiedSubSortKey.isEmpty() ) 349 if ( mLastModifiedSubSortKey.isEmpty() )
348 return lastModifiedSortKey(); 350 return lastModifiedSortKey();
349 return mLastModifiedSubSortKey; 351 return mLastModifiedSubSortKey;
350} 352}
351QDateTime Incidence::lastModifiedSub() 353QDateTime Incidence::lastModifiedSub()
352{ 354{
353 if ( !mRelations.count() ) 355 if ( !mRelations.count() )
354 return lastModified(); 356 return lastModified();
355 if ( mLastModifiedSub.isValid() ) 357 if ( mLastModifiedSub.isValid() )
356 return mLastModifiedSub; 358 return mLastModifiedSub;
357 mLastModifiedSub = lastModified(); 359 mLastModifiedSub = lastModified();
358 Incidence * inc; 360 Incidence * inc;
359 QPtrList<Incidence> Relations = relations(); 361 Q3PtrList<Incidence> Relations = relations();
360 for (inc=Relations.first();inc;inc=Relations.next()) { 362 for (inc=Relations.first();inc;inc=Relations.next()) {
361 if ( inc->lastModifiedSub() > mLastModifiedSub ) 363 if ( inc->lastModifiedSub() > mLastModifiedSub )
362 mLastModifiedSub = inc->lastModifiedSub(); 364 mLastModifiedSub = inc->lastModifiedSub();
363 } 365 }
364 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", 366 mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d",
365 mLastModifiedSub.date().year(), 367 mLastModifiedSub.date().year(),
366 mLastModifiedSub.date().month(), 368 mLastModifiedSub.date().month(),
367 mLastModifiedSub.date().day(), 369 mLastModifiedSub.date().day(),
368 mLastModifiedSub.time().hour(), 370 mLastModifiedSub.time().hour(),
369 mLastModifiedSub.time().minute(), 371 mLastModifiedSub.time().minute(),
370 mLastModifiedSub.time().second() ); 372 mLastModifiedSub.time().second() );
371 return mLastModifiedSub; 373 return mLastModifiedSub;
@@ -438,40 +440,40 @@ void Incidence::checkCategories()
438void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false 440void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false
439{ 441{
440 if (mReadOnly) return; 442 if (mReadOnly) return;
441 int i; 443 int i;
442 for( i = 0; i < categories.count(); ++i ) { 444 for( i = 0; i < categories.count(); ++i ) {
443 if ( !mCategories.contains (categories[i])) 445 if ( !mCategories.contains (categories[i]))
444 mCategories.append( categories[i] ); 446 mCategories.append( categories[i] );
445 } 447 }
446 checkCategories(); 448 checkCategories();
447 updated(); 449 updated();
448 if ( addToRelations ) { 450 if ( addToRelations ) {
449 Incidence * inc; 451 Incidence * inc;
450 QPtrList<Incidence> Relations = relations(); 452 Q3PtrList<Incidence> Relations = relations();
451 for (inc=Relations.first();inc;inc=Relations.next()) { 453 for (inc=Relations.first();inc;inc=Relations.next()) {
452 inc->addCategories( categories, true ); 454 inc->addCategories( categories, true );
453 } 455 }
454 } 456 }
455} 457}
456 458
457void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false 459void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false
458{ 460{
459 if (mReadOnly) return; 461 if (mReadOnly) return;
460 mCategories = categories; 462 mCategories = categories;
461 checkCategories(); 463 checkCategories();
462 updated(); 464 updated();
463 if ( setForRelations ) { 465 if ( setForRelations ) {
464 Incidence * inc; 466 Incidence * inc;
465 QPtrList<Incidence> Relations = relations(); 467 Q3PtrList<Incidence> Relations = relations();
466 for (inc=Relations.first();inc;inc=Relations.next()) { 468 for (inc=Relations.first();inc;inc=Relations.next()) {
467 inc->setCategories( categories, true ); 469 inc->setCategories( categories, true );
468 } 470 }
469 } 471 }
470} 472}
471 473
472// TODO: remove setCategories(QString) function 474// TODO: remove setCategories(QString) function
473void Incidence::setCategories(const QString &catStr) 475void Incidence::setCategories(const QString &catStr)
474{ 476{
475 if (mReadOnly) return; 477 if (mReadOnly) return;
476 mCategories.clear(); 478 mCategories.clear();
477 479
@@ -541,33 +543,33 @@ void Incidence::setRelatedTo(Incidence *relatedTo)
541 mRelatedTo->addRelation(this); 543 mRelatedTo->addRelation(this);
542 mRelatedToUid = mRelatedTo->uid(); 544 mRelatedToUid = mRelatedTo->uid();
543 } else { 545 } else {
544 mRelatedToUid = ""; 546 mRelatedToUid = "";
545 } 547 }
546} 548}
547 549
548Incidence *Incidence::relatedTo() const 550Incidence *Incidence::relatedTo() const
549{ 551{
550 return mRelatedTo; 552 return mRelatedTo;
551} 553}
552 554
553QPtrList<Incidence> Incidence::relations() const 555Q3PtrList<Incidence> Incidence::relations() const
554{ 556{
555 return mRelations; 557 return mRelations;
556} 558}
557 559
558void Incidence::addRelationsToList(QPtrList<Incidence> *rel) 560void Incidence::addRelationsToList(Q3PtrList<Incidence> *rel)
559{ 561{
560 Incidence* inc; 562 Incidence* inc;
561 QPtrList<Incidence> Relations = relations(); 563 Q3PtrList<Incidence> Relations = relations();
562 for (inc=Relations.first();inc;inc=Relations.next()) { 564 for (inc=Relations.first();inc;inc=Relations.next()) {
563 inc->addRelationsToList( rel ); 565 inc->addRelationsToList( rel );
564 } 566 }
565 if ( rel->findRef( this ) == -1 ) 567 if ( rel->findRef( this ) == -1 )
566 rel->append( this ); 568 rel->append( this );
567} 569}
568 570
569void Incidence::addRelation(Incidence *event) 571void Incidence::addRelation(Incidence *event)
570{ 572{
571 setLastModifiedSubInvalid(); 573 setLastModifiedSubInvalid();
572 if( mRelations.findRef( event ) == -1 ) { 574 if( mRelations.findRef( event ) == -1 ) {
573 mRelations.append(event); 575 mRelations.append(event);
@@ -638,33 +640,33 @@ void Incidence::deleteAttachment(Attachment *attachment)
638 640
639void Incidence::deleteAttachments(const QString& mime) 641void Incidence::deleteAttachments(const QString& mime)
640{ 642{
641 Attachment *at = mAttachments.first(); 643 Attachment *at = mAttachments.first();
642 while (at) { 644 while (at) {
643 if (at->mimeType() == mime) 645 if (at->mimeType() == mime)
644 mAttachments.remove(); 646 mAttachments.remove();
645 else 647 else
646 at = mAttachments.next(); 648 at = mAttachments.next();
647 } 649 }
648} 650}
649 651
650QPtrList<Attachment> Incidence::attachments() const 652Q3PtrList<Attachment> Incidence::attachments() const
651{ 653{
652 return mAttachments; 654 return mAttachments;
653} 655}
654 656
655QPtrList<Attachment> Incidence::attachments(const QString& mime) const 657Q3PtrList<Attachment> Incidence::attachments(const QString& mime) const
656{ 658{
657 QPtrList<Attachment> attachments; 659 Q3PtrList<Attachment> attachments;
658 QPtrListIterator<Attachment> it( mAttachments ); 660 Q3PtrListIterator<Attachment> it( mAttachments );
659 Attachment *at; 661 Attachment *at;
660 while ( (at = it.current()) ) { 662 while ( (at = it.current()) ) {
661 if (at->mimeType() == mime) 663 if (at->mimeType() == mime)
662 attachments.append(at); 664 attachments.append(at);
663 ++it; 665 ++it;
664 } 666 }
665 667
666 return attachments; 668 return attachments;
667} 669}
668 670
669void Incidence::setResources(const QStringList &resources) 671void Incidence::setResources(const QStringList &resources)
670{ 672{
@@ -728,25 +730,25 @@ QString Incidence::secrecyName(int secrecy)
728 730
729QStringList Incidence::secrecyList() 731QStringList Incidence::secrecyList()
730{ 732{
731 QStringList list; 733 QStringList list;
732 list << secrecyName(SecrecyPublic); 734 list << secrecyName(SecrecyPublic);
733 list << secrecyName(SecrecyPrivate); 735 list << secrecyName(SecrecyPrivate);
734 list << secrecyName(SecrecyConfidential); 736 list << secrecyName(SecrecyConfidential);
735 737
736 return list; 738 return list;
737} 739}
738 740
739 741
740QPtrList<Alarm> Incidence::alarms() const 742Q3PtrList<Alarm> Incidence::alarms() const
741{ 743{
742 return mAlarms; 744 return mAlarms;
743} 745}
744 746
745Alarm* Incidence::newAlarm() 747Alarm* Incidence::newAlarm()
746{ 748{
747 Alarm* alarm = new Alarm(this); 749 Alarm* alarm = new Alarm(this);
748 mAlarms.append(alarm); 750 mAlarms.append(alarm);
749// updated(); 751// updated();
750 return alarm; 752 return alarm;
751} 753}
752 754
@@ -762,25 +764,25 @@ void Incidence::removeAlarm(Alarm *alarm)
762 updated(); 764 updated();
763} 765}
764 766
765void Incidence::clearAlarms() 767void Incidence::clearAlarms()
766{ 768{
767 mAlarms.clear(); 769 mAlarms.clear();
768 updated(); 770 updated();
769} 771}
770 772
771bool Incidence::isAlarmEnabled() const 773bool Incidence::isAlarmEnabled() const
772{ 774{
773 Alarm* alarm; 775 Alarm* alarm;
774 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 776 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
775 if (alarm->enabled()) 777 if (alarm->enabled())
776 return true; 778 return true;
777 } 779 }
778 return false; 780 return false;
779} 781}
780#include <stdlib.h> 782#include <stdlib.h>
781Recurrence *Incidence::recurrence() 783Recurrence *Incidence::recurrence()
782{ 784{
783 if ( ! mRecurrence ) { 785 if ( ! mRecurrence ) {
784 mRecurrence = new Recurrence(this); 786 mRecurrence = new Recurrence(this);
785 mRecurrence->setRecurStart( dtStart() ); 787 mRecurrence->setRecurStart( dtStart() );
786 mRecurrence->setRecurReadOnly( isReadOnly()); 788 mRecurrence->setRecurReadOnly( isReadOnly());
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index f89942f..2940129 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -16,25 +16,27 @@
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#ifndef INCIDENCE_H 20#ifndef INCIDENCE_H
21#define INCIDENCE_H 21#define INCIDENCE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <q3valuelist.h>
29//Added by qt3to4:
30#include <Q3PtrList>
29 31
30#include "recurrence.h" 32#include "recurrence.h"
31#include "alarm.h" 33#include "alarm.h"
32#include "attachment.h" 34#include "attachment.h"
33#include "listbase.h" 35#include "listbase.h"
34#include "incidencebase.h" 36#include "incidencebase.h"
35 37
36namespace KCal { 38namespace KCal {
37 39
38class Event; 40class Event;
39class Todo; 41class Todo;
40class Journal; 42class Journal;
@@ -104,25 +106,25 @@ class Incidence : public IncidenceBase
104 106
105 /** 107 /**
106 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to 108 Accept IncidenceVisitor. A class taking part in the visitor mechanism has to
107 provide this implementation: 109 provide this implementation:
108 <pre> 110 <pre>
109 bool accept(Visitor &v) { return v.visit(this); } 111 bool accept(Visitor &v) { return v.visit(this); }
110 </pre> 112 </pre>
111 */ 113 */
112 virtual bool accept(Visitor &) { return false; } 114 virtual bool accept(Visitor &) { return false; }
113 115
114 virtual Incidence *clone() = 0; 116 virtual Incidence *clone() = 0;
115 virtual void cloneRelations( Incidence * ); 117 virtual void cloneRelations( Incidence * );
116 void addRelationsToList(QPtrList<Incidence> *rel); 118 void addRelationsToList(Q3PtrList<Incidence> *rel);
117 void clearRelations(); 119 void clearRelations();
118 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0; 120 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const = 0;
119 void setReadOnly( bool ); 121 void setReadOnly( bool );
120 122
121 /** 123 /**
122 Recreate event. The event is made a new unique event, but already stored 124 Recreate event. The event is made a new unique event, but already stored
123 event information is preserved. Sets uniquie id, creation date, last 125 event information is preserved. Sets uniquie id, creation date, last
124 modification date and revision number. 126 modification date and revision number.
125 */ 127 */
126 void recreate(); 128 void recreate();
127 Incidence* recreateCloneException(QDate); 129 Incidence* recreateCloneException(QDate);
128 130
@@ -168,52 +170,52 @@ class Incidence : public IncidenceBase
168 * exists. */ 170 * exists. */
169 void setRelatedToUid(const QString &); 171 void setRelatedToUid(const QString &);
170 /** what event does this one relate to? This function should 172 /** what event does this one relate to? This function should
171 * only be used when constructing a calendar before the related Event 173 * only be used when constructing a calendar before the related Event
172 * exists. */ 174 * exists. */
173 QString relatedToUid() const; 175 QString relatedToUid() const;
174 /** point at some other event to which the event relates */ 176 /** point at some other event to which the event relates */
175 void setRelatedTo(Incidence *relatedTo); 177 void setRelatedTo(Incidence *relatedTo);
176 void resetRelatedTo(); 178 void resetRelatedTo();
177 /** what event does this one relate to? */ 179 /** what event does this one relate to? */
178 Incidence *relatedTo() const; 180 Incidence *relatedTo() const;
179 /** All events that are related to this event */ 181 /** All events that are related to this event */
180 QPtrList<Incidence> relations() const; 182 Q3PtrList<Incidence> relations() const;
181 /** Add an event which is related to this event */ 183 /** Add an event which is related to this event */
182 void addRelation(Incidence *); 184 void addRelation(Incidence *);
183 /** Remove event that is related to this event */ 185 /** Remove event that is related to this event */
184 void removeRelation(Incidence *); 186 void removeRelation(Incidence *);
185 187
186 /** returns the list of dates which are exceptions to the recurrence rule */ 188 /** returns the list of dates which are exceptions to the recurrence rule */
187 DateList exDates() const; 189 DateList exDates() const;
188 /** sets the list of dates which are exceptions to the recurrence rule */ 190 /** sets the list of dates which are exceptions to the recurrence rule */
189 void setExDates(const DateList &_exDates); 191 void setExDates(const DateList &_exDates);
190 void setExDates(const char *dates); 192 void setExDates(const char *dates);
191 /** Add a date to the list of exceptions of the recurrence rule. */ 193 /** Add a date to the list of exceptions of the recurrence rule. */
192 void addExDate(const QDate &date); 194 void addExDate(const QDate &date);
193 195
194 /** returns true if there is an exception for this date in the recurrence 196 /** returns true if there is an exception for this date in the recurrence
195 rule set, or false otherwise. */ 197 rule set, or false otherwise. */
196 bool isException(const QDate &qd) const; 198 bool isException(const QDate &qd) const;
197 199
198 /** add attachment to this event */ 200 /** add attachment to this event */
199 void addAttachment(Attachment *attachment); 201 void addAttachment(Attachment *attachment);
200 /** remove and delete a specific attachment */ 202 /** remove and delete a specific attachment */
201 void deleteAttachment(Attachment *attachment); 203 void deleteAttachment(Attachment *attachment);
202 /** remove and delete all attachments with this mime type */ 204 /** remove and delete all attachments with this mime type */
203 void deleteAttachments(const QString& mime); 205 void deleteAttachments(const QString& mime);
204 /** return list of all associated attachments */ 206 /** return list of all associated attachments */
205 QPtrList<Attachment> attachments() const; 207 Q3PtrList<Attachment> attachments() const;
206 /** find a list of attachments with this mime type */ 208 /** find a list of attachments with this mime type */
207 QPtrList<Attachment> attachments(const QString& mime) const; 209 Q3PtrList<Attachment> attachments(const QString& mime) const;
208 210
209 /** sets the event's status the value specified. See the enumeration 211 /** sets the event's status the value specified. See the enumeration
210 * above for possible values. */ 212 * above for possible values. */
211 void setSecrecy(int); 213 void setSecrecy(int);
212 /** return the event's secrecy. */ 214 /** return the event's secrecy. */
213 int secrecy() const; 215 int secrecy() const;
214 /** return the event's secrecy in string format. */ 216 /** return the event's secrecy in string format. */
215 QString secrecyStr() const; 217 QString secrecyStr() const;
216 /** return list of all availbale secrecy classes */ 218 /** return list of all availbale secrecy classes */
217 static QStringList secrecyList(); 219 static QStringList secrecyList();
218 /** return human-readable name of secrecy class */ 220 /** return human-readable name of secrecy class */
219 static QString secrecyName(int); 221 static QString secrecyName(int);
@@ -226,25 +228,25 @@ class Incidence : public IncidenceBase
226 228
227 /** set resources used, such as Office, Car, etc. */ 229 /** set resources used, such as Office, Car, etc. */
228 void setResources(const QStringList &resources); 230 void setResources(const QStringList &resources);
229 /** return list of current resources */ 231 /** return list of current resources */
230 QStringList resources() const; 232 QStringList resources() const;
231 233
232 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */ 234 /** set the event's priority, 0 is undefined, 1 highest (decreasing order) */
233 void setPriority(int priority); 235 void setPriority(int priority);
234 /** get the event's priority */ 236 /** get the event's priority */
235 int priority() const; 237 int priority() const;
236 238
237 /** All alarms that are associated with this incidence */ 239 /** All alarms that are associated with this incidence */
238 QPtrList<Alarm> alarms() const; 240 Q3PtrList<Alarm> alarms() const;
239 /** Create a new alarm which is associated with this incidence */ 241 /** Create a new alarm which is associated with this incidence */
240 Alarm* newAlarm(); 242 Alarm* newAlarm();
241 /** Add an alarm which is associated with this incidence */ 243 /** Add an alarm which is associated with this incidence */
242 void addAlarm(Alarm*); 244 void addAlarm(Alarm*);
243 /** Remove an alarm that is associated with this incidence */ 245 /** Remove an alarm that is associated with this incidence */
244 void removeAlarm(Alarm*); 246 void removeAlarm(Alarm*);
245 /** Remove all alarms that are associated with this incidence */ 247 /** Remove all alarms that are associated with this incidence */
246 void clearAlarms(); 248 void clearAlarms();
247 /** return whether any alarm associated with this incidence is enabled */ 249 /** return whether any alarm associated with this incidence is enabled */
248 bool isAlarmEnabled() const; 250 bool isAlarmEnabled() const;
249 251
250 /** 252 /**
@@ -279,45 +281,45 @@ class Incidence : public IncidenceBase
279 bool isHoliday() const; 281 bool isHoliday() const;
280 bool isBirthday() const; 282 bool isBirthday() const;
281 bool isAnniversary() const; 283 bool isAnniversary() const;
282 QDateTime lastModifiedSub(); 284 QDateTime lastModifiedSub();
283 QString lastModifiedSubSortKey() const; 285 QString lastModifiedSubSortKey() const;
284 QString recurrenceText() const; 286 QString recurrenceText() const;
285 void setLastModifiedSubInvalid(); 287 void setLastModifiedSubInvalid();
286 288
287 virtual QString durationText(); 289 virtual QString durationText();
288 QString durationText4Time( int secs ); 290 QString durationText4Time( int secs );
289 Recurrence *mRecurrence; 291 Recurrence *mRecurrence;
290protected: 292protected:
291 QPtrList<Alarm> mAlarms; 293 Q3PtrList<Alarm> mAlarms;
292 QPtrList<Incidence> mRelations; 294 Q3PtrList<Incidence> mRelations;
293 QDateTime mRecurrenceID; 295 QDateTime mRecurrenceID;
294 bool mHasRecurrenceID; 296 bool mHasRecurrenceID;
295 private: 297 private:
296 void checkCategories(); 298 void checkCategories();
297 QString mLastModifiedSubSortKey; 299 QString mLastModifiedSubSortKey;
298 bool mHoliday, mBirthday, mAnniversary; 300 bool mHoliday, mBirthday, mAnniversary;
299 int mRevision; 301 int mRevision;
300 bool mCancelled; 302 bool mCancelled;
301 303
302 // base components of jounal, event and todo 304 // base components of jounal, event and todo
303 QDateTime mCreated; 305 QDateTime mCreated;
304 QDateTime mLastModifiedSub; 306 QDateTime mLastModifiedSub;
305 QString mDescription; 307 QString mDescription;
306 QString mSummary; 308 QString mSummary;
307 QStringList mCategories; 309 QStringList mCategories;
308 Incidence *mRelatedTo; 310 Incidence *mRelatedTo;
309 QString mRelatedToUid; 311 QString mRelatedToUid;
310 DateList mExDates; 312 DateList mExDates;
311 QPtrList<Attachment> mAttachments; 313 Q3PtrList<Attachment> mAttachments;
312 QStringList mResources; 314 QStringList mResources;
313 bool mHasStartDate; // if todo has associated start date 315 bool mHasStartDate; // if todo has associated start date
314 316
315 int mSecrecy; 317 int mSecrecy;
316 int mPriority; // 1 = highest, 2 = less, etc. 318 int mPriority; // 1 = highest, 2 = less, etc.
317 319
318 //QPtrList<Alarm> mAlarms; 320 //QPtrList<Alarm> mAlarms;
319 321
320 QString mLocation; 322 QString mLocation;
321}; 323};
322 324
323bool operator==( const Incidence&, const Incidence& ); 325bool operator==( const Incidence&, const Incidence& );
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 56c0560..f11ec54 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -18,24 +18,26 @@
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#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h" 27#include "syncdefines.h"
28 28
29#include "incidencebase.h" 29#include "incidencebase.h"
30//Added by qt3to4:
31#include <Q3PtrList>
30 32
31using namespace KCal; 33using namespace KCal;
32 34
33IncidenceBase::IncidenceBase() : 35IncidenceBase::IncidenceBase() :
34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 36 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
35 mPilotId(0), mSyncStatus(SYNCMOD) 37 mPilotId(0), mSyncStatus(SYNCMOD)
36{ 38{
37 blockLastModified = false; 39 blockLastModified = false;
38 setUid(CalFormat::createUniqueId()); 40 setUid(CalFormat::createUniqueId());
39 mOrganizer = ""; 41 mOrganizer = "";
40 mFloats = false; 42 mFloats = false;
41 mDuration = 0; 43 mDuration = 0;
@@ -55,25 +57,25 @@ IncidenceBase::IncidenceBase(const IncidenceBase &i) :
55{ 57{
56 58
57 blockLastModified = false; 59 blockLastModified = false;
58 mReadOnly = i.mReadOnly; 60 mReadOnly = i.mReadOnly;
59 mDtStart = i.mDtStart; 61 mDtStart = i.mDtStart;
60 mDuration = i.mDuration; 62 mDuration = i.mDuration;
61 mHasDuration = i.mHasDuration; 63 mHasDuration = i.mHasDuration;
62 mOrganizer = i.mOrganizer; 64 mOrganizer = i.mOrganizer;
63 mUid = i.mUid; 65 mUid = i.mUid;
64 mCalEnabled = i.mCalEnabled; 66 mCalEnabled = i.mCalEnabled;
65 mAlarmEnabled = i.mAlarmEnabled; 67 mAlarmEnabled = i.mAlarmEnabled;
66 mCalID = i.mCalID; 68 mCalID = i.mCalID;
67 QPtrList<Attendee> attendees = i.attendees(); 69 Q3PtrList<Attendee> attendees = i.attendees();
68 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 70 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
69 mAttendees.append( new Attendee( *a ) ); 71 mAttendees.append( new Attendee( *a ) );
70 } 72 }
71 mFloats = i.mFloats; 73 mFloats = i.mFloats;
72 mLastModified = i.mLastModified; 74 mLastModified = i.mLastModified;
73 mPilotId = i.mPilotId; 75 mPilotId = i.mPilotId;
74 mTempSyncStat = i.mTempSyncStat; 76 mTempSyncStat = i.mTempSyncStat;
75 mSyncStatus = i.mSyncStatus; 77 mSyncStatus = i.mSyncStatus;
76 mExternalId = i.mExternalId; 78 mExternalId = i.mExternalId;
77 // The copied object is a new one, so it isn't observed by the observer 79 // The copied object is a new one, so it isn't observed by the observer
78 // of the original object. 80 // of the original object.
79 mObservers.clear(); 81 mObservers.clear();
@@ -291,25 +293,25 @@ void IncidenceBase::setFloats(bool f)
291 if (mReadOnly) return; 293 if (mReadOnly) return;
292 mFloats = f; 294 mFloats = f;
293 updated(); 295 updated();
294} 296}
295 297
296 298
297bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) 299bool IncidenceBase::addAttendee(Attendee *a, bool doupdate)
298{ 300{
299 if (mReadOnly) return false; 301 if (mReadOnly) return false;
300 if (a->name().left(7).upper() == "MAILTO:") 302 if (a->name().left(7).upper() == "MAILTO:")
301 a->setName(a->name().remove(0,7)); 303 a->setName(a->name().remove(0,7));
302 304
303 QPtrListIterator<Attendee> qli(mAttendees); 305 Q3PtrListIterator<Attendee> qli(mAttendees);
304 306
305 qli.toFirst(); 307 qli.toFirst();
306 while (qli) { 308 while (qli) {
307 if (*qli.current() == *a) 309 if (*qli.current() == *a)
308 return false; 310 return false;
309 ++qli; 311 ++qli;
310 } 312 }
311 mAttendees.append(a); 313 mAttendees.append(a);
312 if (doupdate) updated(); 314 if (doupdate) updated();
313 return true; 315 return true;
314} 316}
315 317
@@ -334,52 +336,52 @@ void IncidenceBase::removeAttendee(const char *n)
334} 336}
335#endif 337#endif
336 338
337void IncidenceBase::clearAttendees() 339void IncidenceBase::clearAttendees()
338{ 340{
339 if (mReadOnly) return; 341 if (mReadOnly) return;
340 mAttendees.clear(); 342 mAttendees.clear();
341} 343}
342 344
343#if 0 345#if 0
344Attendee *IncidenceBase::getAttendee(const char *n) const 346Attendee *IncidenceBase::getAttendee(const char *n) const
345{ 347{
346 QPtrListIterator<Attendee> qli(mAttendees); 348 Q3PtrListIterator<Attendee> qli(mAttendees);
347 349
348 qli.toFirst(); 350 qli.toFirst();
349 while (qli) { 351 while (qli) {
350 if (qli.current()->getName() == n) 352 if (qli.current()->getName() == n)
351 return qli.current(); 353 return qli.current();
352 ++qli; 354 ++qli;
353 } 355 }
354 return 0L; 356 return 0L;
355} 357}
356#endif 358#endif
357 359
358Attendee *IncidenceBase::attendeeByMail(const QString &email) 360Attendee *IncidenceBase::attendeeByMail(const QString &email)
359{ 361{
360 QPtrListIterator<Attendee> qli(mAttendees); 362 Q3PtrListIterator<Attendee> qli(mAttendees);
361 363
362 qli.toFirst(); 364 qli.toFirst();
363 while (qli) { 365 while (qli) {
364 if (qli.current()->email().lower() == email.lower()) 366 if (qli.current()->email().lower() == email.lower())
365 return qli.current(); 367 return qli.current();
366 ++qli; 368 ++qli;
367 } 369 }
368 return 0L; 370 return 0L;
369} 371}
370 372
371Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 373Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
372{ 374{
373 QPtrListIterator<Attendee> qli(mAttendees); 375 Q3PtrListIterator<Attendee> qli(mAttendees);
374 376
375 QStringList mails = emails; 377 QStringList mails = emails;
376 if (!email.isEmpty()) { 378 if (!email.isEmpty()) {
377 mails.append(email); 379 mails.append(email);
378 } 380 }
379 qli.toFirst(); 381 qli.toFirst();
380 while (qli) { 382 while (qli) {
381 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 383 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
382 if (qli.current()->email().lower() == (*it).lower()) 384 if (qli.current()->email().lower() == (*it).lower())
383 return qli.current(); 385 return qli.current();
384 } 386 }
385 387
@@ -482,19 +484,19 @@ QString IncidenceBase::IDStr() const
482void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 484void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
483{ 485{
484 if( !mObservers.contains(observer) ) mObservers.append( observer ); 486 if( !mObservers.contains(observer) ) mObservers.append( observer );
485} 487}
486 488
487void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 489void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
488{ 490{
489 mObservers.remove( observer ); 491 mObservers.remove( observer );
490} 492}
491 493
492void IncidenceBase::updated() 494void IncidenceBase::updated()
493{ 495{
494 QPtrListIterator<Observer> it(mObservers); 496 Q3PtrListIterator<Observer> it(mObservers);
495 while( it.current() ) { 497 while( it.current() ) {
496 Observer *o = it.current(); 498 Observer *o = it.current();
497 ++it; 499 ++it;
498 o->incidenceUpdated( this ); 500 o->incidenceUpdated( this );
499 } 501 }
500} 502}
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index 3edc03b..d97f524 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -16,51 +16,53 @@
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#ifndef KCAL_INCIDENCEBASE_H 20#ifndef KCAL_INCIDENCEBASE_H
21#define KCAL_INCIDENCEBASE_H 21#define KCAL_INCIDENCEBASE_H
22// 22//
23// Incidence - base class of calendaring components 23// Incidence - base class of calendaring components
24// 24//
25 25
26#include <qdatetime.h> 26#include <qdatetime.h>
27#include <qstringlist.h> 27#include <qstringlist.h>
28#include <qvaluelist.h> 28#include <q3valuelist.h>
29#include <qptrlist.h> 29#include <q3ptrlist.h>
30//Added by qt3to4:
31#include <Q3CString>
30 32
31#include "customproperties.h" 33#include "customproperties.h"
32#include "attendee.h" 34#include "attendee.h"
33 35
34namespace KCal { 36namespace KCal {
35 37
36typedef QValueList<QDate> DateList; 38typedef Q3ValueList<QDate> DateList;
37 enum IncTypeID { eventID,todoID,journalID,freebusyID }; 39 enum IncTypeID { eventID,todoID,journalID,freebusyID };
38 40
39/** 41/**
40 This class provides the base class common to all calendar components. 42 This class provides the base class common to all calendar components.
41*/ 43*/
42class IncidenceBase : public CustomProperties 44class IncidenceBase : public CustomProperties
43{ 45{
44 public: 46 public:
45 class Observer { 47 class Observer {
46 public: 48 public:
47 virtual void incidenceUpdated( IncidenceBase * ) = 0; 49 virtual void incidenceUpdated( IncidenceBase * ) = 0;
48 }; 50 };
49 51
50 IncidenceBase(); 52 IncidenceBase();
51 IncidenceBase(const IncidenceBase &); 53 IncidenceBase(const IncidenceBase &);
52 virtual ~IncidenceBase(); 54 virtual ~IncidenceBase();
53 55
54 virtual QCString type() const = 0; 56 virtual Q3CString type() const = 0;
55 virtual IncTypeID typeID() const = 0; 57 virtual IncTypeID typeID() const = 0;
56 58
57 /** Set the unique id for the event */ 59 /** Set the unique id for the event */
58 void setUid(const QString &); 60 void setUid(const QString &);
59 /** Return the unique id for the event */ 61 /** Return the unique id for the event */
60 QString uid() const; 62 QString uid() const;
61 63
62 /** Sets the time the incidence was last modified. */ 64 /** Sets the time the incidence was last modified. */
63 void setLastModified(const QDateTime &lm); 65 void setLastModified(const QDateTime &lm);
64 /** Return the time the incidence was last modified. */ 66 /** Return the time the incidence was last modified. */
65 QDateTime lastModified() const; 67 QDateTime lastModified() const;
66 QString lastModifiedSortKey() const; 68 QString lastModifiedSortKey() const;
@@ -100,25 +102,25 @@ class IncidenceBase : public CustomProperties
100 void setFloats(bool f); 102 void setFloats(bool f);
101 103
102 /** 104 /**
103 Add Attendee to this incidence. IncidenceBase takes ownership of the 105 Add Attendee to this incidence. IncidenceBase takes ownership of the
104 Attendee object. 106 Attendee object.
105 */ 107 */
106 bool addAttendee(Attendee *a, bool doupdate=true ); 108 bool addAttendee(Attendee *a, bool doupdate=true );
107// void removeAttendee(Attendee *a); 109// void removeAttendee(Attendee *a);
108// void removeAttendee(const char *n); 110// void removeAttendee(const char *n);
109 /** Remove all Attendees. */ 111 /** Remove all Attendees. */
110 void clearAttendees(); 112 void clearAttendees();
111 /** Return list of attendees. */ 113 /** Return list of attendees. */
112 QPtrList<Attendee> attendees() const { return mAttendees; }; 114 Q3PtrList<Attendee> attendees() const { return mAttendees; };
113 /** Return number of attendees. */ 115 /** Return number of attendees. */
114 int attendeeCount() const { return mAttendees.count(); }; 116 int attendeeCount() const { return mAttendees.count(); };
115 /** Return the Attendee with this email */ 117 /** Return the Attendee with this email */
116 Attendee* attendeeByMail(const QString &); 118 Attendee* attendeeByMail(const QString &);
117 /** Return first Attendee with one of this emails */ 119 /** Return first Attendee with one of this emails */
118 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null); 120 Attendee* attendeeByMails(const QStringList &, const QString& email = QString::null);
119 121
120 /** pilot syncronization states */ 122 /** pilot syncronization states */
121 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 }; 123 enum { SYNCNONE = 0, SYNCMOD = 1, SYNCDEL = 3 };
122 /** Set synchronisation satus. */ 124 /** Set synchronisation satus. */
123 void setSyncStatus(int stat); 125 void setSyncStatus(int stat);
124 /** Return synchronisation status. */ 126 /** Return synchronisation status. */
@@ -159,32 +161,32 @@ class IncidenceBase : public CustomProperties
159 bool mReadOnly; 161 bool mReadOnly;
160 QDateTime getEvenTime( QDateTime ); 162 QDateTime getEvenTime( QDateTime );
161 163
162 private: 164 private:
163 // base components 165 // base components
164 QString mOrganizer; 166 QString mOrganizer;
165 QString mLastModifiedKey; 167 QString mLastModifiedKey;
166 QString mUid; 168 QString mUid;
167 int mCalID; 169 int mCalID;
168 bool mCalEnabled; 170 bool mCalEnabled;
169 bool mAlarmEnabled; 171 bool mAlarmEnabled;
170 QDateTime mLastModified; 172 QDateTime mLastModified;
171 QPtrList<Attendee> mAttendees; 173 Q3PtrList<Attendee> mAttendees;
172 174
173 bool mFloats; 175 bool mFloats;
174 176
175 int mDuration; 177 int mDuration;
176 bool mHasDuration; 178 bool mHasDuration;
177 QString mExternalId; 179 QString mExternalId;
178 int mTempSyncStat; 180 int mTempSyncStat;
179 181
180 // PILOT SYNCHRONIZATION STUFF 182 // PILOT SYNCHRONIZATION STUFF
181 int mPilotId; // unique id for pilot sync 183 int mPilotId; // unique id for pilot sync
182 int mSyncStatus; // status (for sync) 184 int mSyncStatus; // status (for sync)
183 185
184 QPtrList<Observer> mObservers; 186 Q3PtrList<Observer> mObservers;
185}; 187};
186 188
187bool operator==( const IncidenceBase&, const IncidenceBase& ); 189bool operator==( const IncidenceBase&, const IncidenceBase& );
188} 190}
189 191
190#endif 192#endif
diff --git a/libkcal/journal.h b/libkcal/journal.h
index 1cd0a22..c83356f 100644
--- a/libkcal/journal.h
+++ b/libkcal/journal.h
@@ -15,37 +15,39 @@
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#ifndef JOURNAL_H 20#ifndef JOURNAL_H
21#define JOURNAL_H 21#define JOURNAL_H
22// 22//
23// Journal component, representing a VJOURNAL object 23// Journal component, representing a VJOURNAL object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27//Added by qt3to4:
28#include <Q3CString>
27 29
28namespace KCal { 30namespace KCal {
29 31
30/** 32/**
31 This class provides a Journal in the sense of RFC2445. 33 This class provides a Journal in the sense of RFC2445.
32*/ 34*/
33class Journal : public Incidence 35class Journal : public Incidence
34{ 36{
35 public: 37 public:
36 Journal(); 38 Journal();
37 ~Journal(); 39 ~Journal();
38 40
39 QCString type() const { return "Journal"; } 41 Q3CString type() const { return "Journal"; }
40 IncTypeID typeID() const { return journalID; } 42 IncTypeID typeID() const { return journalID; }
41 43
42 Incidence *clone(); 44 Incidence *clone();
43 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const; 45 QDateTime getNextAlarmDateTime( bool * ok, int * offset ,QDateTime start_dt ) const;
44private: 46private:
45 bool accept(Visitor &v) { return v.visit(this); } 47 bool accept(Visitor &v) { return v.visit(this); }
46}; 48};
47 49
48 bool operator==( const Journal&, const Journal& ); 50 bool operator==( const Journal&, const Journal& );
49} 51}
50 52
51#endif 53#endif
diff --git a/libkcal/kincidenceformatter.cpp b/libkcal/kincidenceformatter.cpp
index 733b897..bce68b0 100644
--- a/libkcal/kincidenceformatter.cpp
+++ b/libkcal/kincidenceformatter.cpp
@@ -1,18 +1,20 @@
1#include "kincidenceformatter.h" 1#include "kincidenceformatter.h"
2#include <kstaticdeleter.h> 2#include <kstaticdeleter.h>
3#include <kglobal.h> 3#include <kglobal.h>
4#include <klocale.h> 4#include <klocale.h>
5#ifdef DEKTOP_VERSION 5#ifdef DEKTOP_VERSION
6#include <kabc/stdaddressbook.h> 6#include <kabc/stdaddressbook.h>
7//Added by qt3to4:
8#include <Q3PtrList>
7#define size count 9#define size count
8#endif 10#endif
9 11
10KIncidenceFormatter* KIncidenceFormatter::mInstance = 0; 12KIncidenceFormatter* KIncidenceFormatter::mInstance = 0;
11static KStaticDeleter<KIncidenceFormatter> insd; 13static KStaticDeleter<KIncidenceFormatter> insd;
12 14
13QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified ) 15QString KIncidenceFormatter::getFormattedText( Incidence * inc, bool details, bool created , bool modified )
14{ 16{
15// #ifndef QT_NO_INPUTDIALOG 17// #ifndef QT_NO_INPUTDIALOG
16// return QInputDialog::getItem( caption, label, items, current, editable ); 18// return QInputDialog::getItem( caption, label, items, current, editable );
17// #else 19// #else
18// return QString::null; 20// return QString::null;
@@ -301,25 +303,25 @@ void KIncidenceFormatter::setJournal(Journal* )
301 303
302} 304}
303 305
304void KIncidenceFormatter::formatCategories(Incidence *event) 306void KIncidenceFormatter::formatCategories(Incidence *event)
305{ 307{
306 if (!event->categoriesStr().isEmpty()) { 308 if (!event->categoriesStr().isEmpty()) {
307 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() ); 309 addTag("p",i18n("<b>Categories: </b>")+event->categoriesStrWithSpace() );
308 //mText.append(event->categoriesStr()); 310 //mText.append(event->categoriesStr());
309 } 311 }
310} 312}
311void KIncidenceFormatter::addTag(const QString & tag,const QString & text) 313void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
312{ 314{
313 int number=text.contains("\n"); 315 int number=text.count("\n");
314 QString str = "<" + tag + ">"; 316 QString str = "<" + tag + ">";
315 QString tmpText=text; 317 QString tmpText=text;
316 QString tmpStr=str; 318 QString tmpStr=str;
317 if(number !=-1) 319 if(number !=-1)
318 { 320 {
319 if (number > 0) { 321 if (number > 0) {
320 int pos=0; 322 int pos=0;
321 QString tmp; 323 QString tmp;
322 for(int i=0;i<=number;i++) { 324 for(int i=0;i<=number;i++) {
323 pos=tmpText.find("\n"); 325 pos=tmpText.find("\n");
324 tmp=tmpText.left(pos); 326 tmp=tmpText.left(pos);
325 tmpText=tmpText.right(tmpText.length()-pos-1); 327 tmpText=tmpText.right(tmpText.length()-pos-1);
@@ -330,48 +332,48 @@ void KIncidenceFormatter::addTag(const QString & tag,const QString & text)
330 tmpStr+="</" + tag + ">"; 332 tmpStr+="</" + tag + ">";
331 mText.append(tmpStr); 333 mText.append(tmpStr);
332 } 334 }
333 else 335 else
334 { 336 {
335 str += text + "</" + tag + ">"; 337 str += text + "</" + tag + ">";
336 mText.append(str); 338 mText.append(str);
337 } 339 }
338} 340}
339 341
340void KIncidenceFormatter::formatAttendees(Incidence *event) 342void KIncidenceFormatter::formatAttendees(Incidence *event)
341{ 343{
342 QPtrList<Attendee> attendees = event->attendees(); 344 Q3PtrList<Attendee> attendees = event->attendees();
343 if (attendees.count()) { 345 if (attendees.count()) {
344 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small); 346 QString iconPath = KGlobal::iconLoader()->iconPath("mailappt",KIcon::Small);
345 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small); 347 QString NOiconPath = KGlobal::iconLoader()->iconPath("nomailappt",KIcon::Small);
346 addTag("h3",i18n("Organizer")); 348 addTag("h3",i18n("Organizer"));
347 mText.append("<ul><li>"); 349 mText.append("<ul><li>");
348#if 0 350#if 0
349 //ndef KORG_NOKABC 351 //ndef KORG_NOKABC
350 352
351 KABC::AddressBook *add_book = KABC::StdAddressBook::self(); 353 KABC::AddressBook *add_book = KABC::StdAddressBook::self();
352 KABC::Addressee::List addressList; 354 KABC::Addressee::List addressList;
353 addressList = add_book->findByEmail(event->organizer()); 355 addressList = add_book->findByEmail(event->organizer());
354 KABC::Addressee o = addressList.first(); 356 KABC::Addressee o = addressList.first();
355 if (!o.isEmpty() && addressList.size()<2) { 357 if (!o.isEmpty() && addressList.size()<2) {
356 mText += "<a href=\"uid:" + o.uid() + "\">"; 358 mText += "<a href=\"uid:" + o.uid() + "\">";
357 mText += o.formattedName(); 359 mText += o.formattedName();
358 mText += "</a>\n"; 360 mText += "</a>\n";
359 } else { 361 } else {
360 mText.append(event->organizer()); 362 mText.append(event->organizer());
361 } 363 }
362#else 364#else
363 mText.append(event->organizer()); 365 mText.append(event->organizer());
364#endif 366#endif
365 if (iconPath) { 367 if (!iconPath.isEmpty()) {
366 mText += " <a href=\"mailto:" + event->organizer() + "\">"; 368 mText += " <a href=\"mailto:" + event->organizer() + "\">";
367 mText += "<IMG src=\"" + iconPath + "\">"; 369 mText += "<IMG src=\"" + iconPath + "\">";
368 mText += "</a>\n"; 370 mText += "</a>\n";
369 } 371 }
370 mText.append("</li></ul>"); 372 mText.append("</li></ul>");
371 373
372 addTag("h3",i18n("Attendees")); 374 addTag("h3",i18n("Attendees"));
373 Attendee *a; 375 Attendee *a;
374 mText.append("<ul>"); 376 mText.append("<ul>");
375 for(a=attendees.first();a;a=attendees.next()) { 377 for(a=attendees.first();a;a=attendees.next()) {
376#if 0 378#if 0
377//ndef KORG_NOKABC 379//ndef KORG_NOKABC
@@ -393,25 +395,25 @@ void KIncidenceFormatter::formatAttendees(Incidence *event)
393 else mText += a->email(); 395 else mText += a->email();
394 mText += "</a>\n"; 396 mText += "</a>\n";
395 } 397 }
396#else 398#else
397 //qDebug("nokabc "); 399 //qDebug("nokabc ");
398 mText += "<li><a href=\"uid:" + a->uid() + "\">"; 400 mText += "<li><a href=\"uid:" + a->uid() + "\">";
399 if (!a->name().isEmpty()) mText += a->name(); 401 if (!a->name().isEmpty()) mText += a->name();
400 else mText += a->email(); 402 else mText += a->email();
401 mText += "</a>\n"; 403 mText += "</a>\n";
402#endif 404#endif
403 405
404 if (!a->email().isEmpty()) { 406 if (!a->email().isEmpty()) {
405 if (iconPath) { 407 if (!iconPath.isEmpty()) {
406 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">"; 408 mText += "<a href=\"mailto:" + a->name() +" "+ "<" + a->email() + ">" + "\">";
407 if ( a->RSVP() ) 409 if ( a->RSVP() )
408 mText += "<IMG src=\"" + iconPath + "\">"; 410 mText += "<IMG src=\"" + iconPath + "\">";
409 else 411 else
410 mText += "<IMG src=\"" + NOiconPath + "\">"; 412 mText += "<IMG src=\"" + NOiconPath + "\">";
411 mText += "</a>\n"; 413 mText += "</a>\n";
412 } 414 }
413 } 415 }
414 if (a->status() != Attendee::NeedsAction ) 416 if (a->status() != Attendee::NeedsAction )
415 mText +="[" + a->statusStr() + "] "; 417 mText +="[" + a->statusStr() + "] ";
416 if (a->role() == Attendee::Chair ) 418 if (a->role() == Attendee::Chair )
417 mText +="(" + a->roleStr().left(1) + ".)"; 419 mText +="(" + a->roleStr().left(1) + ".)";
diff --git a/libkcal/libkcal.pro b/libkcal/libkcal.pro
index 33c63c3..1f43b10 100644
--- a/libkcal/libkcal.pro
+++ b/libkcal/libkcal.pro
@@ -1,15 +1,15 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = microkcal 3 TARGET = xmicrokcal
4 4
5include( ../variables.pri ) 5include( ../variables.pri )
6 6
7INCLUDEPATH += ../libkdepim ../microkde versit ../microkde/kdecore 7INCLUDEPATH += ../libkdepim ../microkde versit ../microkde/kdecore
8#../qtcompat 8#../qtcompat
9INCLUDEPATH += ../libical/src/libical 9INCLUDEPATH += ../libical/src/libical
10INCLUDEPATH += ../libical/src/libicalss 10INCLUDEPATH += ../libical/src/libicalss
11DESTDIR = ../bin 11DESTDIR = ../bin
12DEFINES += DESKTOP_VERSION 12DEFINES += DESKTOP_VERSION
13unix: { 13unix: {
14LIBS += ../libical/lib/libical.a 14LIBS += ../libical/lib/libical.a
15LIBS += ../libical/lib/libicalss.a 15LIBS += ../libical/lib/libicalss.a
@@ -97,12 +97,16 @@ SOURCES = \
97 person.cpp \ 97 person.cpp \
98 qtopiaformat.cpp \ 98 qtopiaformat.cpp \
99 recurrence.cpp \ 99 recurrence.cpp \
100 scheduler.cpp \ 100 scheduler.cpp \
101 todo.cpp \ 101 todo.cpp \
102dndfactory.cpp \ 102dndfactory.cpp \
103 vcaldrag.cpp \ 103 vcaldrag.cpp \
104 vcalformat.cpp \ 104 vcalformat.cpp \
105 versit/vcc.c \ 105 versit/vcc.c \
106 versit/vobject.c \ 106 versit/vobject.c \
107 phoneformat.cpp \ 107 phoneformat.cpp \
108 108
109#The following line was inserted by qt3to4
110QT += xml qt3support
111#The following line was inserted by qt3to4
112QT +=
diff --git a/libkcal/libkcalE.pro b/libkcal/libkcalE.pro
index 737be53..fe46656 100644
--- a/libkcal/libkcalE.pro
+++ b/libkcal/libkcalE.pro
@@ -1,15 +1,15 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3 TARGET = microkcal 3 TARGET = xmicrokcal
4 4
5INCLUDEPATH += ../libkdepim ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include 5INCLUDEPATH += ../libkdepim ../microkde ../qtcompat versit ../microkde/kdecore $(QPEDIR)/include
6INCLUDEPATH += ../libical/src/libical 6INCLUDEPATH += ../libical/src/libical
7INCLUDEPATH += ../libical/src/libicalss 7INCLUDEPATH += ../libical/src/libicalss
8OBJECTS_DIR = obj/$(PLATFORM) 8OBJECTS_DIR = obj/$(PLATFORM)
9MOC_DIR = moc/$(PLATFORM) 9MOC_DIR = moc/$(PLATFORM)
10DESTDIR = $(QPEDIR)/lib 10DESTDIR = $(QPEDIR)/lib
11#LIBS += ../libical/lib/$(PLATFORM)/libical.a 11#LIBS += ../libical/lib/$(PLATFORM)/libical.a
12#LIBS += ../libical/lib/$(PLATFORM)/libicalss.a 12#LIBS += ../libical/lib/$(PLATFORM)/libicalss.a
13LIBS += ../dest$(LIBICAL_PATH)/libical.a 13LIBS += ../dest$(LIBICAL_PATH)/libical.a
14LIBS += ../dest$(LIBICAL_PATH)/libicalss.a 14LIBS += ../dest$(LIBICAL_PATH)/libicalss.a
15 15
diff --git a/libkcal/listbase.h b/libkcal/listbase.h
index 085b13d..6c942ef 100644
--- a/libkcal/listbase.h
+++ b/libkcal/listbase.h
@@ -12,82 +12,84 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21#ifndef KCAL_LISTBASE_H 21#ifndef KCAL_LISTBASE_H
22#define KCAL_LISTBASE_H 22#define KCAL_LISTBASE_H
23 23
24#include <qvaluelist.h> 24#include <q3valuelist.h>
25//Added by qt3to4:
26#include <Q3PtrList>
25 27
26namespace KCal { 28namespace KCal {
27 class Event; 29 class Event;
28 class Todo; 30 class Todo;
29/** 31/**
30 This class provides a template for lists of pointers. It extends QValueList<T 32 This class provides a template for lists of pointers. It extends QValueList<T
31 *> by auto delete funtionality known from QPtrList. 33 *> by auto delete funtionality known from QPtrList.
32*/ 34*/
33template<class T> 35template<class T>
34class ListBase : public QValueList<T *> 36class ListBase : public Q3ValueList<T *>
35{ 37{
36 public: 38 public:
37 ListBase() 39 ListBase()
38 : QValueList<T *>(), mAutoDelete( false ) 40 : Q3ValueList<T *>(), mAutoDelete( false )
39 { 41 {
40 } 42 }
41 43
42 ListBase( const ListBase &l ) 44 ListBase( const ListBase &l )
43 : QValueList<T *>( l ), mAutoDelete( false ) 45 : Q3ValueList<T *>( l ), mAutoDelete( false )
44 { 46 {
45 } 47 }
46 48
47 ~ListBase() 49 ~ListBase()
48 { 50 {
49 if ( mAutoDelete ) { 51 if ( mAutoDelete ) {
50 QValueListIterator<T *> it; 52 Q3ValueListIterator<T *> it;
51 for( it = QValueList<T*>::begin(); it != QValueList<T*>::end(); ++it ) { 53 for( it = Q3ValueList<T*>::begin(); it != Q3ValueList<T*>::end(); ++it ) {
52 delete *it; 54 delete *it;
53 } 55 }
54 } 56 }
55 } 57 }
56 58
57 ListBase &operator=( const ListBase &l ) 59 ListBase &operator=( const ListBase &l )
58 { 60 {
59 if ( this == &l ) return *this; 61 if ( this == &l ) return *this;
60 QValueList<T *>::operator=( l ); 62 Q3ValueList<T *>::operator=( l );
61 return *this; 63 return *this;
62 } 64 }
63 65
64 void setAutoDelete( bool autoDelete ) 66 void setAutoDelete( bool autoDelete )
65 { 67 {
66 mAutoDelete = autoDelete; 68 mAutoDelete = autoDelete;
67 } 69 }
68 70
69 bool removeRef( T *t ) 71 bool removeRef( T *t )
70 { 72 {
71 QValueListIterator<T *> it = find( t ); 73 Q3ValueListIterator<T *> it = find( t );
72 if ( it == QValueList<T*>::end() ) { 74 if ( it == Q3ValueList<T*>::end() ) {
73 return false; 75 return false;
74 } else { 76 } else {
75 if ( mAutoDelete ) delete t; 77 if ( mAutoDelete ) delete t;
76 remove( it ); 78 remove( it );
77 return true; 79 return true;
78 } 80 }
79 } 81 }
80 void fill ( QPtrList<T> list ) { 82 void fill ( Q3PtrList<T> list ) {
81 QPtrListIterator<T> it (list); 83 Q3PtrListIterator<T> it (list);
82 T *item; 84 T *item;
83 while ( (item = it.current()) != 0 ) { 85 while ( (item = it.current()) != 0 ) {
84 append( item ); 86 append( item );
85 ++it; 87 ++it;
86 } 88 }
87 89
88 } 90 }
89 91
90 92
91 private: 93 private:
92 bool mAutoDelete; 94 bool mAutoDelete;
93}; 95};
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 900fc04..794e4b4 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -13,33 +13,34 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <q3textstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qdir.h> 32#include <qdir.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <QDesktopWidget>
34 35
35#include <kdebug.h> 36#include <kdebug.h>
36#include <klocale.h> 37#include <klocale.h>
37#include <kglobal.h> 38#include <kglobal.h>
38#include <kmessagebox.h> 39#include <kmessagebox.h>
39#include <phoneaccess.h> 40#include <phoneaccess.h>
40 41
41#include "calendar.h" 42#include "calendar.h"
42#include "alarm.h" 43#include "alarm.h"
43#include "recurrence.h" 44#include "recurrence.h"
44#include "calendarlocal.h" 45#include "calendarlocal.h"
45 46
@@ -192,25 +193,25 @@ ulong PhoneFormat::getCsumEvent( Event* event )
192 } 193 }
193 //pending weekdays 194 //pending weekdays
194 writeEndDate = true; 195 writeEndDate = true;
195 196
196 break; 197 break;
197 case Recurrence::rMonthlyPos:// 2 198 case Recurrence::rMonthlyPos:// 2
198 list.append( "2" ); 199 list.append( "2" );
199 list.append( QString::number( rec->frequency()) );//12 200 list.append( QString::number( rec->frequency()) );//12
200 201
201 writeEndDate = true; 202 writeEndDate = true;
202 { 203 {
203 int count = 1; 204 int count = 1;
204 QPtrList<Recurrence::rMonthPos> rmp; 205 Q3PtrList<Recurrence::rMonthPos> rmp;
205 rmp = rec->monthPositions(); 206 rmp = rec->monthPositions();
206 if ( rmp.first()->negative ) 207 if ( rmp.first()->negative )
207 count = 5 - rmp.first()->rPos - 1; 208 count = 5 - rmp.first()->rPos - 1;
208 else 209 else
209 count = rmp.first()->rPos - 1; 210 count = rmp.first()->rPos - 1;
210 list.append( QString::number( count ) ); 211 list.append( QString::number( count ) );
211 212
212 } 213 }
213 214
214 list.append( "0" ); 215 list.append( "0" );
215 break; 216 break;
216 case Recurrence::rMonthlyDay:// 3 217 case Recurrence::rMonthlyDay:// 3
@@ -232,25 +233,25 @@ ulong PhoneFormat::getCsumEvent( Event* event )
232 list.append( "255" ); 233 list.append( "255" );
233 list.append( QString() ); 234 list.append( QString() );
234 list.append( "0" ); 235 list.append( "0" );
235 list.append( QString() ); 236 list.append( QString() );
236 list.append( "0" ); 237 list.append( "0" );
237 list.append( "20991231T000000" ); 238 list.append( "20991231T000000" );
238 break; 239 break;
239 } 240 }
240 if ( writeEndDate ) { 241 if ( writeEndDate ) {
241 242
242 if ( rec->endDate().isValid() ) { // 15 + 16 243 if ( rec->endDate().isValid() ) { // 15 + 16
243 list.append( "1" ); 244 list.append( "1" );
244 list.append( PhoneParser::dtToString( rec->endDate()) ); 245 list.append( PhoneParser::dtToString( (QDateTime)rec->endDate()) );
245 } else { 246 } else {
246 list.append( "0" ); 247 list.append( "0" );
247 list.append( "20991231T000000" ); 248 list.append( "20991231T000000" );
248 } 249 }
249 250
250 } 251 }
251 attList << list.join(""); 252 attList << list.join("");
252 attList << event->categoriesStr(); 253 attList << event->categoriesStr();
253 //qDebug("csum cat %s", event->categoriesStr().latin1()); 254 //qDebug("csum cat %s", event->categoriesStr().latin1());
254 255
255 attList << event->secrecyStr(); 256 attList << event->secrecyStr();
256 return PhoneFormat::getCsum(attList ); 257 return PhoneFormat::getCsum(attList );
@@ -296,25 +297,25 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
296 fileName = "/tmp/phonefile.vcs"; 297 fileName = "/tmp/phonefile.vcs";
297#endif 298#endif
298 QString command; 299 QString command;
299 if ( ! PhoneAccess::readFromPhone( fileName )) { 300 if ( ! PhoneAccess::readFromPhone( fileName )) {
300 return false; 301 return false;
301 } 302 }
302 VCalFormat vfload; 303 VCalFormat vfload;
303 vfload.setLocalTime ( true ); 304 vfload.setLocalTime ( true );
304 qDebug("loading file ..."); 305 qDebug("loading file ...");
305 306
306 if ( ! vfload.load( calendar, fileName ) ) 307 if ( ! vfload.load( calendar, fileName ) )
307 return false; 308 return false;
308 QPtrList<Event> er = calendar->rawEvents(); 309 Q3PtrList<Event> er = calendar->rawEvents();
309 Event* ev = er.first(); 310 Event* ev = er.first();
310 qDebug("reading events... "); 311 qDebug("reading events... ");
311 while ( ev ) { 312 while ( ev ) {
312 QStringList cat = ev->categories(); 313 QStringList cat = ev->categories();
313 if ( cat.contains( "MeetingDEF" )) { 314 if ( cat.contains( "MeetingDEF" )) {
314 ev->setCategories( QStringList() ); 315 ev->setCategories( QStringList() );
315 } else 316 } else
316 if ( cat.contains( "Birthday" )) { 317 if ( cat.contains( "Birthday" )) {
317 ev->setFloats( true ); 318 ev->setFloats( true );
318 QDate da = ev->dtStart().date(); 319 QDate da = ev->dtStart().date();
319 ev->setDtStart( QDateTime( da) ); 320 ev->setDtStart( QDateTime( da) );
320 ev->setDtEnd( QDateTime( da.addDays(1)) ); 321 ev->setDtEnd( QDateTime( da.addDays(1)) );
@@ -331,25 +332,25 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
331 calendar->deleteEvent( ev ); 332 calendar->deleteEvent( ev );
332 calendar->addEvent( event); 333 calendar->addEvent( event);
333 } 334 }
334 else 335 else
335 event = ev; 336 event = ev;
336 event->setCsum( mProfileName, QString::number( cSum )); 337 event->setCsum( mProfileName, QString::number( cSum ));
337 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 338 event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
338 event->setID( mProfileName,QString::number( id ) ); 339 event->setID( mProfileName,QString::number( id ) );
339 ev = er.next(); 340 ev = er.next();
340 } 341 }
341 { 342 {
342 qDebug("reading todos... "); 343 qDebug("reading todos... ");
343 QPtrList<Todo> tr = calendar->rawTodos(); 344 Q3PtrList<Todo> tr = calendar->rawTodos();
344 Todo* ev = tr.first(); 345 Todo* ev = tr.first();
345 while ( ev ) { 346 while ( ev ) {
346 347
347 QStringList cat = ev->categories(); 348 QStringList cat = ev->categories();
348 if ( cat.contains( "MeetingDEF" )) { 349 if ( cat.contains( "MeetingDEF" )) {
349 ev->setCategories( QStringList() ); 350 ev->setCategories( QStringList() );
350 } 351 }
351 int id = ev->pilotId(); 352 int id = ev->pilotId();
352 uint cSum; 353 uint cSum;
353 cSum = PhoneFormat::getCsumTodo( ev ); 354 cSum = PhoneFormat::getCsumTodo( ev );
354 Todo *event; 355 Todo *event;
355 event = existingCal->todo( mProfileName ,QString::number( id ) ); 356 event = existingCal->todo( mProfileName ,QString::number( id ) );
@@ -456,25 +457,25 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
456 // set percentcomplete only, if to->isCompleted() 457 // set percentcomplete only, if to->isCompleted()
457 if ( to->isCompleted() ) 458 if ( to->isCompleted() )
458 to->setPercentComplete(from->percentComplete()); 459 to->setPercentComplete(from->percentComplete());
459 } 460 }
460 if( to->priority() == 2 && from->priority() == 1 ) 461 if( to->priority() == 2 && from->priority() == 1 )
461 ; //skip 462 ; //skip
462 else if (to->priority() == 4 && from->priority() == 5 ) 463 else if (to->priority() == 4 && from->priority() == 5 )
463 ; 464 ;
464 else 465 else
465 to->setPriority(from->priority()); 466 to->setPriority(from->priority());
466 467
467} 468}
468#include <qcstring.h> 469#include <q3cstring.h>
469 470
470void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum) 471void PhoneFormat::afterSave( Incidence* inc,const QString& id ,const QString& csum)
471{ 472{
472 inc->setID( mProfileName, id ); 473 inc->setID( mProfileName, id );
473 inc->setCsum( mProfileName, csum); 474 inc->setCsum( mProfileName, csum);
474 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 475 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
475 476
476} 477}
477 478
478bool PhoneFormat::writeToPhone( Calendar * calendar) 479bool PhoneFormat::writeToPhone( Calendar * calendar)
479{ 480{
480#ifdef DESKTOP_VERSION 481#ifdef DESKTOP_VERSION
@@ -488,36 +489,36 @@ bool PhoneFormat::writeToPhone( Calendar * calendar)
488 QString id = calendar->timeZoneId(); 489 QString id = calendar->timeZoneId();
489 calendar->setLocalTime(); 490 calendar->setLocalTime();
490 if ( ! vfsave.save( calendar, fileName ) ) 491 if ( ! vfsave.save( calendar, fileName ) )
491 return false; 492 return false;
492 calendar->setTimeZoneId( id ); 493 calendar->setTimeZoneId( id );
493 return PhoneAccess::writeToPhone( fileName ); 494 return PhoneAccess::writeToPhone( fileName );
494} 495}
495bool PhoneFormat::save( Calendar *calendar) 496bool PhoneFormat::save( Calendar *calendar)
496{ 497{
497 498
498 499
499 // 1 remove events which should be deleted 500 // 1 remove events which should be deleted
500 QPtrList<Event> er = calendar->rawEvents(); 501 Q3PtrList<Event> er = calendar->rawEvents();
501 Event* ev = er.first(); 502 Event* ev = er.first();
502 while ( ev ) { 503 while ( ev ) {
503 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 504 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
504 calendar->deleteEvent( ev ); 505 calendar->deleteEvent( ev );
505 } else { 506 } else {
506 507
507 } 508 }
508 ev = er.next(); 509 ev = er.next();
509 } 510 }
510 // 2 remove todos which should be deleted 511 // 2 remove todos which should be deleted
511 QPtrList<Todo> tl = calendar->rawTodos(); 512 Q3PtrList<Todo> tl = calendar->rawTodos();
512 Todo* to = tl.first(); 513 Todo* to = tl.first();
513 while ( to ) { 514 while ( to ) {
514 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { 515 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) {
515 calendar->deleteTodo( to ); 516 calendar->deleteTodo( to );
516 } else { 517 } else {
517 if ( to->isCompleted()) { 518 if ( to->isCompleted()) {
518 calendar->deleteTodo( to ); 519 calendar->deleteTodo( to );
519 } 520 }
520 } 521 }
521 to = tl.next(); 522 to = tl.next();
522 } 523 }
523 // 3 save file 524 // 3 save file
@@ -543,25 +544,25 @@ bool PhoneFormat::save( Calendar *calendar)
543 calendarTemp->setTimeZoneId( calendar->timeZoneId()); 544 calendarTemp->setTimeZoneId( calendar->timeZoneId());
544 if ( ! load( calendarTemp,calendar) ){ 545 if ( ! load( calendarTemp,calendar) ){
545 qDebug("error reloading calendar "); 546 qDebug("error reloading calendar ");
546 delete calendarTemp; 547 delete calendarTemp;
547 return false; 548 return false;
548 } 549 }
549 // 6 compare data 550 // 6 compare data
550 551
551//algo 6 compare event 552//algo 6 compare event
552 er = calendar->rawEvents(); 553 er = calendar->rawEvents();
553 ev = er.first(); 554 ev = er.first();
554 message = i18n(" Comparing event # "); 555 message = i18n(" Comparing event # ");
555 QPtrList<Event> er1 = calendarTemp->rawEvents(); 556 Q3PtrList<Event> er1 = calendarTemp->rawEvents();
556 Event* ev1; 557 Event* ev1;
557 int procCount = 0; 558 int procCount = 0;
558 while ( ev ) { 559 while ( ev ) {
559 //qDebug("event new ID %s",ev->summary().latin1()); 560 //qDebug("event new ID %s",ev->summary().latin1());
560 status.setText ( message + QString::number ( ++procCount ) ); 561 status.setText ( message + QString::number ( ++procCount ) );
561 qApp->processEvents(); 562 qApp->processEvents();
562 ev1 = er1.first(); 563 ev1 = er1.first();
563 while ( ev1 ) { 564 while ( ev1 ) {
564 if ( ev->contains( ev1 ) ) { 565 if ( ev->contains( ev1 ) ) {
565 afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName)); 566 afterSave( ev ,ev1->getID(mProfileName),ev1->getCsum(mProfileName));
566 er1.remove( ev1 ); 567 er1.remove( ev1 );
567 break; 568 break;
@@ -571,25 +572,25 @@ bool PhoneFormat::save( Calendar *calendar)
571 if ( ! ev1 ) { 572 if ( ! ev1 ) {
572 // ev->removeID(mProfileName); 573 // ev->removeID(mProfileName);
573 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); 574 qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1());
574 } 575 }
575 576
576 577
577 ev = er.next(); 578 ev = er.next();
578 } 579 }
579 //algo 6 compare todo 580 //algo 6 compare todo
580 tl = calendar->rawTodos(); 581 tl = calendar->rawTodos();
581 to = tl.first(); 582 to = tl.first();
582 procCount = 0; 583 procCount = 0;
583 QPtrList<Todo> tl1 = calendarTemp->rawTodos(); 584 Q3PtrList<Todo> tl1 = calendarTemp->rawTodos();
584 Todo* to1 ; 585 Todo* to1 ;
585 message = i18n(" Comparing todo # "); 586 message = i18n(" Comparing todo # ");
586 while ( to ) { 587 while ( to ) {
587 status.setText ( message + QString::number ( ++procCount ) ); 588 status.setText ( message + QString::number ( ++procCount ) );
588 qApp->processEvents(); 589 qApp->processEvents();
589 Todo* to1 = tl1.first(); 590 Todo* to1 = tl1.first();
590 while ( to1 ) { 591 while ( to1 ) {
591 if ( to->contains( to1 ) ) { 592 if ( to->contains( to1 ) ) {
592 afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName)); 593 afterSave( to ,to1->getID(mProfileName),to1->getCsum(mProfileName));
593 tl1.remove( to1 ); 594 tl1.remove( to1 );
594 break; 595 break;
595 } 596 }
diff --git a/libkcal/qtopiaformat.cpp b/libkcal/qtopiaformat.cpp
index 0a4a031..2dfe1a4 100644
--- a/libkcal/qtopiaformat.cpp
+++ b/libkcal/qtopiaformat.cpp
@@ -12,29 +12,29 @@
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qptrlist.h> 24#include <q3ptrlist.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qclipboard.h> 26#include <qclipboard.h>
27#include <qfile.h> 27#include <qfile.h>
28#include <qtextstream.h> 28#include <q3textstream.h>
29#include <qxml.h> 29#include <qxml.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <klocale.h> 32#include <klocale.h>
33 33
34#include "calendar.h" 34#include "calendar.h"
35#include "calendarlocal.h" 35#include "calendarlocal.h"
36 36
37#include "qtopiaformat.h" 37#include "qtopiaformat.h"
38 38
39using namespace KCal; 39using namespace KCal;
40 40
@@ -300,30 +300,30 @@ bool QtopiaFormat::load( Calendar *calendar, const QString &fileName )
300bool QtopiaFormat::save( Calendar *calendar, const QString &fileName ) 300bool QtopiaFormat::save( Calendar *calendar, const QString &fileName )
301{ 301{
302 302
303 clearException(); 303 clearException();
304 304
305 QString text = toString( calendar ); 305 QString text = toString( calendar );
306 306
307 if ( text.isNull() ) return false; 307 if ( text.isNull() ) return false;
308 308
309 // TODO: write backup file 309 // TODO: write backup file
310 310
311 QFile file( fileName ); 311 QFile file( fileName );
312 if (!file.open( IO_WriteOnly ) ) { 312 if (!file.open( QIODevice::WriteOnly ) ) {
313 setException(new ErrorFormat(ErrorFormat::SaveError, 313 setException(new ErrorFormat(ErrorFormat::SaveError,
314 i18n("Could not open file '%1'").arg(fileName))); 314 i18n("Could not open file '%1'").arg(fileName)));
315 return false; 315 return false;
316 } 316 }
317 QTextStream ts( &file ); 317 Q3TextStream ts( &file );
318 ts << text; 318 ts << text;
319 file.close(); 319 file.close();
320 320
321 return true; 321 return true;
322} 322}
323 323
324bool QtopiaFormat::fromString( Calendar *, const QString & ) 324bool QtopiaFormat::fromString( Calendar *, const QString & )
325{ 325{
326 326
327 return false; 327 return false;
328} 328}
329 329
diff --git a/libkcal/recurrence.cpp b/libkcal/recurrence.cpp
index 6ee5499..9a4e540 100644
--- a/libkcal/recurrence.cpp
+++ b/libkcal/recurrence.cpp
@@ -20,24 +20,27 @@
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#include <limits.h> 23#include <limits.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "incidence.h" 29#include "incidence.h"
30 30
31#include "recurrence.h" 31#include "recurrence.h"
32//Added by qt3to4:
33#include <Q3ValueList>
34#include <Q3PtrList>
32 35
33using namespace KCal; 36using namespace KCal;
34 37
35Recurrence::Feb29Type Recurrence::mFeb29YearlyDefaultType = Recurrence::rMar1; 38Recurrence::Feb29Type Recurrence::mFeb29YearlyDefaultType = Recurrence::rMar1;
36 39
37 40
38Recurrence::Recurrence(Incidence *parent, int compatVersion) 41Recurrence::Recurrence(Incidence *parent, int compatVersion)
39: recurs(rNone), // by default, it's not a recurring event 42: recurs(rNone), // by default, it's not a recurring event
40 rWeekStart(1), // default is Monday 43 rWeekStart(1), // default is Monday
41 rDays(7), 44 rDays(7),
42 mFloats(parent ? parent->doesFloat() : false), 45 mFloats(parent ? parent->doesFloat() : false),
43 mRecurReadOnly(false), 46 mRecurReadOnly(false),
@@ -47,51 +50,51 @@ Recurrence::Recurrence(Incidence *parent, int compatVersion)
47 mCompatRecurs(rNone), 50 mCompatRecurs(rNone),
48 mCompatDuration(0), 51 mCompatDuration(0),
49 mParent(parent) 52 mParent(parent)
50{ 53{
51 rMonthDays.setAutoDelete( true ); 54 rMonthDays.setAutoDelete( true );
52 rMonthPositions.setAutoDelete( true ); 55 rMonthPositions.setAutoDelete( true );
53 rYearNums.setAutoDelete( true ); 56 rYearNums.setAutoDelete( true );
54} 57}
55 58
56Recurrence::Recurrence(const Recurrence &r, Incidence *parent) 59Recurrence::Recurrence(const Recurrence &r, Incidence *parent)
57: recurs(r.recurs), 60: recurs(r.recurs),
58 rWeekStart(r.rWeekStart), 61 rWeekStart(r.rWeekStart),
59 rDays(r.rDays.copy()), 62 rDays(r.rDays),
60 rFreq(r.rFreq), 63 rFreq(r.rFreq),
61 rDuration(r.rDuration), 64 rDuration(r.rDuration),
62 rEndDateTime(r.rEndDateTime), 65 rEndDateTime(r.rEndDateTime),
63 mRecurStart(r.mRecurStart), 66 mRecurStart(r.mRecurStart),
64 mFloats(r.mFloats), 67 mFloats(r.mFloats),
65 mRecurReadOnly(r.mRecurReadOnly), 68 mRecurReadOnly(r.mRecurReadOnly),
66 mRecurExDatesCount(r.mRecurExDatesCount), 69 mRecurExDatesCount(r.mRecurExDatesCount),
67 mFeb29YearlyType(r.mFeb29YearlyType), 70 mFeb29YearlyType(r.mFeb29YearlyType),
68 mCompatVersion(r.mCompatVersion), 71 mCompatVersion(r.mCompatVersion),
69 mCompatRecurs(r.mCompatRecurs), 72 mCompatRecurs(r.mCompatRecurs),
70 mCompatDuration(r.mCompatDuration), 73 mCompatDuration(r.mCompatDuration),
71 mParent(parent) 74 mParent(parent)
72{ 75{
73 for (QPtrListIterator<rMonthPos> mp(r.rMonthPositions); mp.current(); ++mp) { 76 for (Q3PtrListIterator<rMonthPos> mp(r.rMonthPositions); mp.current(); ++mp) {
74 rMonthPos *tmp = new rMonthPos; 77 rMonthPos *tmp = new rMonthPos;
75 tmp->rPos = mp.current()->rPos; 78 tmp->rPos = mp.current()->rPos;
76 tmp->negative = mp.current()->negative; 79 tmp->negative = mp.current()->negative;
77 tmp->rDays = mp.current()->rDays.copy(); 80 tmp->rDays = mp.current()->rDays;
78 rMonthPositions.append(tmp); 81 rMonthPositions.append(tmp);
79 } 82 }
80 for (QPtrListIterator<int> md(r.rMonthDays); md.current(); ++md) { 83 for (Q3PtrListIterator<int> md(r.rMonthDays); md.current(); ++md) {
81 int *tmp = new int; 84 int *tmp = new int;
82 *tmp = *md.current(); 85 *tmp = *md.current();
83 rMonthDays.append(tmp); 86 rMonthDays.append(tmp);
84 } 87 }
85 for (QPtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) { 88 for (Q3PtrListIterator<int> yn(r.rYearNums); yn.current(); ++yn) {
86 int *tmp = new int; 89 int *tmp = new int;
87 *tmp = *yn.current(); 90 *tmp = *yn.current();
88 rYearNums.append(tmp); 91 rYearNums.append(tmp);
89 } 92 }
90 rMonthDays.setAutoDelete( true ); 93 rMonthDays.setAutoDelete( true );
91 rMonthPositions.setAutoDelete( true ); 94 rMonthPositions.setAutoDelete( true );
92 rYearNums.setAutoDelete( true ); 95 rYearNums.setAutoDelete( true );
93} 96}
94 97
95Recurrence::~Recurrence() 98Recurrence::~Recurrence()
96{ 99{
97} 100}
@@ -115,64 +118,64 @@ bool Recurrence::operator==( const Recurrence& r2 ) const
115 || mFloats != r2.mFloats 118 || mFloats != r2.mFloats
116 || mRecurReadOnly != r2.mRecurReadOnly 119 || mRecurReadOnly != r2.mRecurReadOnly
117 || mRecurExDatesCount != r2.mRecurExDatesCount ) 120 || mRecurExDatesCount != r2.mRecurExDatesCount )
118 return false; 121 return false;
119 // no need to compare mCompat* and mParent 122 // no need to compare mCompat* and mParent
120 // OK to compare the pointers 123 // OK to compare the pointers
121 switch ( recurs ) 124 switch ( recurs )
122 { 125 {
123 case rWeekly: 126 case rWeekly:
124 return rDays == r2.rDays 127 return rDays == r2.rDays
125 && rWeekStart == r2.rWeekStart; 128 && rWeekStart == r2.rWeekStart;
126 case rMonthlyPos: { 129 case rMonthlyPos: {
127 QPtrList<rMonthPos> MonthPositions = rMonthPositions; 130 Q3PtrList<rMonthPos> MonthPositions = rMonthPositions;
128 QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions; 131 Q3PtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
129 if ( !MonthPositions.count() ) 132 if ( !MonthPositions.count() )
130 return false; 133 return false;
131 if ( !MonthPositions2.count() ) 134 if ( !MonthPositions2.count() )
132 return false; 135 return false;
133 return MonthPositions.first()->rPos == MonthPositions2.first()->rPos; 136 return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
134 } 137 }
135 case rMonthlyDay: { 138 case rMonthlyDay: {
136 QPtrList<int> MonthDays = rMonthDays ; 139 Q3PtrList<int> MonthDays = rMonthDays ;
137 QPtrList<int> MonthDays2 = r2.rMonthDays ; 140 Q3PtrList<int> MonthDays2 = r2.rMonthDays ;
138 if ( !MonthDays.count() ) 141 if ( !MonthDays.count() )
139 return false; 142 return false;
140 if ( !MonthDays2.count() ) 143 if ( !MonthDays2.count() )
141 return false; 144 return false;
142 return *MonthDays.first() == *MonthDays2.first() ; 145 return *MonthDays.first() == *MonthDays2.first() ;
143 } 146 }
144 case rYearlyPos: { 147 case rYearlyPos: {
145 148
146 QPtrList<int> YearNums = rYearNums; 149 Q3PtrList<int> YearNums = rYearNums;
147 QPtrList<int> YearNums2 = r2.rYearNums; 150 Q3PtrList<int> YearNums2 = r2.rYearNums;
148 if ( *YearNums.first() != *YearNums2.first() ) 151 if ( *YearNums.first() != *YearNums2.first() )
149 return false; 152 return false;
150 QPtrList<rMonthPos> MonthPositions = rMonthPositions; 153 Q3PtrList<rMonthPos> MonthPositions = rMonthPositions;
151 QPtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions; 154 Q3PtrList<rMonthPos> MonthPositions2 = r2.rMonthPositions;
152 if ( !MonthPositions.count() ) 155 if ( !MonthPositions.count() )
153 return false; 156 return false;
154 if ( !MonthPositions2.count() ) 157 if ( !MonthPositions2.count() )
155 return false; 158 return false;
156 return MonthPositions.first()->rPos == MonthPositions2.first()->rPos; 159 return MonthPositions.first()->rPos == MonthPositions2.first()->rPos;
157 160
158 } 161 }
159 case rYearlyMonth: { 162 case rYearlyMonth: {
160 QPtrList<int> YearNums = rYearNums; 163 Q3PtrList<int> YearNums = rYearNums;
161 QPtrList<int> YearNums2 = r2.rYearNums; 164 Q3PtrList<int> YearNums2 = r2.rYearNums;
162 return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType); 165 return ( *YearNums.first() == *YearNums2.first() && mFeb29YearlyType == r2.mFeb29YearlyType);
163 } 166 }
164 case rYearlyDay: { 167 case rYearlyDay: {
165 QPtrList<int> YearNums = rYearNums; 168 Q3PtrList<int> YearNums = rYearNums;
166 QPtrList<int> YearNums2 = r2.rYearNums; 169 Q3PtrList<int> YearNums2 = r2.rYearNums;
167 return ( *YearNums.first() == *YearNums2.first() ); 170 return ( *YearNums.first() == *YearNums2.first() );
168 } 171 }
169 case rNone: 172 case rNone:
170 case rMinutely: 173 case rMinutely:
171 case rHourly: 174 case rHourly:
172 case rDaily: 175 case rDaily:
173 default: 176 default:
174 return true; 177 return true;
175 } 178 }
176} 179}
177/* 180/*
178bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2) 181bool Recurrence::compareLists( const QPtrList<int> &l1 ,const QPtrList<int> &l2)
@@ -348,25 +351,25 @@ QDateTime Recurrence::endDateTime() const
348 if (rDuration == 0) 351 if (rDuration == 0)
349 return rEndDateTime; 352 return rEndDateTime;
350 353
351 // The end date is determined by the recurrence count 354 // The end date is determined by the recurrence count
352 QDate dStart = mRecurStart.date(); 355 QDate dStart = mRecurStart.date();
353 switch (recurs) 356 switch (recurs)
354 { 357 {
355 case rMinutely: 358 case rMinutely:
356 return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*60); 359 return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*60);
357 case rHourly: 360 case rHourly:
358 return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*3600); 361 return mRecurStart.addSecs((rDuration-1+mRecurExDatesCount)*rFreq*3600);
359 case rDaily: 362 case rDaily:
360 return dStart.addDays((rDuration-1+mRecurExDatesCount)*rFreq); 363 return (QDateTime)dStart.addDays((rDuration-1+mRecurExDatesCount)*rFreq);
361 364
362 case rWeekly: 365 case rWeekly:
363 count = weeklyCalc(END_DATE_AND_COUNT, end); 366 count = weeklyCalc(END_DATE_AND_COUNT, end);
364 break; 367 break;
365 case rMonthlyPos: 368 case rMonthlyPos:
366 case rMonthlyDay: 369 case rMonthlyDay:
367 count = monthlyCalc(END_DATE_AND_COUNT, end); 370 count = monthlyCalc(END_DATE_AND_COUNT, end);
368 break; 371 break;
369 case rYearlyMonth: 372 case rYearlyMonth:
370 count = yearlyMonthCalc(END_DATE_AND_COUNT, end); 373 count = yearlyMonthCalc(END_DATE_AND_COUNT, end);
371 break; 374 break;
372 case rYearlyDay: 375 case rYearlyDay:
@@ -497,35 +500,35 @@ void Recurrence::setDuration(int _rDuration)
497} 500}
498 501
499QString Recurrence::endDateStr(bool shortfmt) const 502QString Recurrence::endDateStr(bool shortfmt) const
500{ 503{
501 return KGlobal::locale()->formatDate(rEndDateTime.date(),shortfmt); 504 return KGlobal::locale()->formatDate(rEndDateTime.date(),shortfmt);
502} 505}
503 506
504const QBitArray &Recurrence::days() const 507const QBitArray &Recurrence::days() const
505{ 508{
506 return rDays; 509 return rDays;
507} 510}
508 511
509const QPtrList<Recurrence::rMonthPos> &Recurrence::monthPositions() const 512const Q3PtrList<Recurrence::rMonthPos> &Recurrence::monthPositions() const
510{ 513{
511 return rMonthPositions; 514 return rMonthPositions;
512} 515}
513 516
514const QPtrList<Recurrence::rMonthPos> &Recurrence::yearMonthPositions() const 517const Q3PtrList<Recurrence::rMonthPos> &Recurrence::yearMonthPositions() const
515{ 518{
516 return rMonthPositions; 519 return rMonthPositions;
517} 520}
518 521
519const QPtrList<int> &Recurrence::monthDays() const 522const Q3PtrList<int> &Recurrence::monthDays() const
520{ 523{
521 return rMonthDays; 524 return rMonthDays;
522} 525}
523 526
524void Recurrence::setMinutely(int _rFreq, int _rDuration) 527void Recurrence::setMinutely(int _rFreq, int _rDuration)
525{ 528{
526 if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1) 529 if (mRecurReadOnly || _rDuration == 0 || _rDuration < -1)
527 return; 530 return;
528 setDailySub(rMinutely, _rFreq, _rDuration); 531 setDailySub(rMinutely, _rFreq, _rDuration);
529} 532}
530 533
531void Recurrence::setMinutely(int _rFreq, const QDateTime &_rEndDateTime) 534void Recurrence::setMinutely(int _rFreq, const QDateTime &_rEndDateTime)
@@ -750,25 +753,25 @@ void Recurrence::setYearlyByDate(Feb29Type type, int _rFreq, const QDate &_rEndD
750 rEndDateTime.setDate(_rEndDate); 753 rEndDateTime.setDate(_rEndDate);
751 rEndDateTime.setTime(mRecurStart.time()); 754 rEndDateTime.setTime(mRecurStart.time());
752 mCompatDuration = 0; 755 mCompatDuration = 0;
753 setYearly_(rYearlyMonth, type, _rFreq, 0); 756 setYearly_(rYearlyMonth, type, _rFreq, 0);
754} 757}
755 758
756void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays) 759void Recurrence::addYearlyMonthPos(short _rPos, const QBitArray &_rDays)
757{ 760{
758 if (recurs == rYearlyPos) 761 if (recurs == rYearlyPos)
759 addMonthlyPos_(_rPos, _rDays); 762 addMonthlyPos_(_rPos, _rDays);
760} 763}
761 764
762const QPtrList<int> &Recurrence::yearNums() const 765const Q3PtrList<int> &Recurrence::yearNums() const
763{ 766{
764 return rYearNums; 767 return rYearNums;
765} 768}
766void Recurrence::addYearlyMonth(short _rPos ) 769void Recurrence::addYearlyMonth(short _rPos )
767{ 770{
768 if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number 771 if (mRecurReadOnly || recurs != rYearlyMonth) // invalid day/month number
769 return; 772 return;
770 rMonthPos *tmpPos = new rMonthPos; 773 rMonthPos *tmpPos = new rMonthPos;
771 if ( _rPos > 0) { 774 if ( _rPos > 0) {
772 tmpPos->rPos = _rPos; 775 tmpPos->rPos = _rPos;
773 tmpPos->negative = false; 776 tmpPos->negative = false;
774 } else { 777 } else {
@@ -1038,31 +1041,31 @@ bool Recurrence::recursMonthly(const QDate &qd) const
1038 int month = qd.month(); 1041 int month = qd.month();
1039 int day = qd.day(); 1042 int day = qd.day();
1040 // calculate how many months ahead this date is from the original 1043 // calculate how many months ahead this date is from the original
1041 // event's date 1044 // event's date
1042 int monthsAhead = (year - dStart.year()) * 12 + (month - dStart.month()); 1045 int monthsAhead = (year - dStart.year()) * 12 + (month - dStart.month());
1043 if ((monthsAhead % rFreq) == 0) { 1046 if ((monthsAhead % rFreq) == 0) {
1044 // The date is in a month which recurs 1047 // The date is in a month which recurs
1045 if (qd >= dStart 1048 if (qd >= dStart
1046 && ((rDuration > 0 && qd <= endDate()) || 1049 && ((rDuration > 0 && qd <= endDate()) ||
1047 (rDuration == 0 && qd <= rEndDateTime.date()) || 1050 (rDuration == 0 && qd <= rEndDateTime.date()) ||
1048 rDuration == -1)) { 1051 rDuration == -1)) {
1049 // The date queried falls within the range of the event. 1052 // The date queried falls within the range of the event.
1050 QValueList<int> days; 1053 Q3ValueList<int> days;
1051 int daysInMonth = qd.daysInMonth(); 1054 int daysInMonth = qd.daysInMonth();
1052 if (recurs == rMonthlyDay) 1055 if (recurs == rMonthlyDay)
1053 getMonthlyDayDays(days, daysInMonth); 1056 getMonthlyDayDays(days, daysInMonth);
1054 else if (recurs == rMonthlyPos) 1057 else if (recurs == rMonthlyPos)
1055 getMonthlyPosDays(days, daysInMonth, QDate(year, month, 1).dayOfWeek()); 1058 getMonthlyPosDays(days, daysInMonth, QDate(year, month, 1).dayOfWeek());
1056 for (QValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) { 1059 for (Q3ValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
1057 if (*it == day) 1060 if (*it == day)
1058 return true; 1061 return true;
1059 } 1062 }
1060 // no dates matched 1063 // no dates matched
1061 } 1064 }
1062 } 1065 }
1063 return false; 1066 return false;
1064} 1067}
1065 1068
1066bool Recurrence::recursYearlyByMonth(const QDate &qd) const 1069bool Recurrence::recursYearlyByMonth(const QDate &qd) const
1067{ 1070{
1068 QDate dStart = mRecurStart.date(); 1071 QDate dStart = mRecurStart.date();
@@ -1092,25 +1095,25 @@ bool Recurrence::recursYearlyByMonth(const QDate &qd) const
1092 if (match) { 1095 if (match) {
1093 // The day of the month matches. Calculate how many years ahead 1096 // The day of the month matches. Calculate how many years ahead
1094 // this date is from the original event's date. 1097 // this date is from the original event's date.
1095 int yearsAhead = (qyear - dStart.year()); 1098 int yearsAhead = (qyear - dStart.year());
1096 if (yearsAhead % rFreq == 0) { 1099 if (yearsAhead % rFreq == 0) {
1097 // The date is in a year which recurs 1100 // The date is in a year which recurs
1098 if (qd >= dStart 1101 if (qd >= dStart
1099 && ((rDuration > 0 && qd <= endDate()) || 1102 && ((rDuration > 0 && qd <= endDate()) ||
1100 (rDuration == 0 && qd <= rEndDateTime.date()) || 1103 (rDuration == 0 && qd <= rEndDateTime.date()) ||
1101 rDuration == -1)) { 1104 rDuration == -1)) {
1102 // The date queried falls within the range of the event. 1105 // The date queried falls within the range of the event.
1103 int i = qmonth; 1106 int i = qmonth;
1104 for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) { 1107 for (Q3PtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
1105 if (i == *qlin.current()) 1108 if (i == *qlin.current())
1106 return true; 1109 return true;
1107 } 1110 }
1108 } 1111 }
1109 } 1112 }
1110 } 1113 }
1111 return false; 1114 return false;
1112} 1115}
1113 1116
1114bool Recurrence::recursYearlyByPos(const QDate &qd) const 1117bool Recurrence::recursYearlyByPos(const QDate &qd) const
1115{ 1118{
1116 QDate dStart = mRecurStart.date(); 1119 QDate dStart = mRecurStart.date();
@@ -1118,55 +1121,55 @@ bool Recurrence::recursYearlyByPos(const QDate &qd) const
1118 int month = qd.month(); 1121 int month = qd.month();
1119 int day = qd.day(); 1122 int day = qd.day();
1120 // calculate how many years ahead this date is from the original 1123 // calculate how many years ahead this date is from the original
1121 // event's date 1124 // event's date
1122 int yearsAhead = (year - dStart.year()); 1125 int yearsAhead = (year - dStart.year());
1123 if (yearsAhead % rFreq == 0) { 1126 if (yearsAhead % rFreq == 0) {
1124 // The date is in a year which recurs 1127 // The date is in a year which recurs
1125 if (qd >= dStart 1128 if (qd >= dStart
1126 && ((rDuration > 0 && qd <= endDate()) || 1129 && ((rDuration > 0 && qd <= endDate()) ||
1127 (rDuration == 0 && qd <= rEndDateTime.date()) || 1130 (rDuration == 0 && qd <= rEndDateTime.date()) ||
1128 rDuration == -1)) { 1131 rDuration == -1)) {
1129 // The date queried falls within the range of the event. 1132 // The date queried falls within the range of the event.
1130 for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) { 1133 for (Q3PtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
1131 if (month == *qlin.current()) { 1134 if (month == *qlin.current()) {
1132 // The month recurs 1135 // The month recurs
1133 QValueList<int> days; 1136 Q3ValueList<int> days;
1134 getMonthlyPosDays(days, qd.daysInMonth(), QDate(year, month, 1).dayOfWeek()); 1137 getMonthlyPosDays(days, qd.daysInMonth(), QDate(year, month, 1).dayOfWeek());
1135 for (QValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) { 1138 for (Q3ValueList<int>::Iterator it = days.begin(); it != days.end(); ++it) {
1136 if (*it == day) 1139 if (*it == day)
1137 return true; 1140 return true;
1138 } 1141 }
1139 } 1142 }
1140 } 1143 }
1141 } 1144 }
1142 } 1145 }
1143 return false; 1146 return false;
1144} 1147}
1145 1148
1146bool Recurrence::recursYearlyByDay(const QDate &qd) const 1149bool Recurrence::recursYearlyByDay(const QDate &qd) const
1147{ 1150{
1148 QDate dStart = mRecurStart.date(); 1151 QDate dStart = mRecurStart.date();
1149 // calculate how many years ahead this date is from the original 1152 // calculate how many years ahead this date is from the original
1150 // event's date 1153 // event's date
1151 int yearsAhead = (qd.year() - dStart.year()); 1154 int yearsAhead = (qd.year() - dStart.year());
1152 if (yearsAhead % rFreq == 0) { 1155 if (yearsAhead % rFreq == 0) {
1153 // The date is in a year which recurs 1156 // The date is in a year which recurs
1154 if (qd >= dStart 1157 if (qd >= dStart
1155 && ((rDuration > 0 && qd <= endDate()) || 1158 && ((rDuration > 0 && qd <= endDate()) ||
1156 (rDuration == 0 && qd <= rEndDateTime.date()) || 1159 (rDuration == 0 && qd <= rEndDateTime.date()) ||
1157 rDuration == -1)) { 1160 rDuration == -1)) {
1158 // The date queried falls within the range of the event. 1161 // The date queried falls within the range of the event.
1159 int i = qd.dayOfYear(); 1162 int i = qd.dayOfYear();
1160 for (QPtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) { 1163 for (Q3PtrListIterator<int> qlin(rYearNums); qlin.current(); ++qlin) {
1161 if (i == *qlin.current()) 1164 if (i == *qlin.current())
1162 return true; 1165 return true;
1163 } 1166 }
1164 } 1167 }
1165 } 1168 }
1166 return false; 1169 return false;
1167} 1170}
1168 1171
1169/* Get the date of the next recurrence, after the specified date. 1172/* Get the date of the next recurrence, after the specified date.
1170 * If 'last' is non-null, '*last' is set to true if the next recurrence is the 1173 * If 'last' is non-null, '*last' is set to true if the next recurrence is the
1171 * last recurrence, else false. 1174 * last recurrence, else false.
1172 * Reply = date of next recurrence, or invalid date if none. 1175 * Reply = date of next recurrence, or invalid date if none.
@@ -1540,25 +1543,25 @@ int Recurrence::recurCalc(PeriodFunc func, QDate &enddate) const
1540 break; 1543 break;
1541 case rYearlyDay: 1544 case rYearlyDay:
1542 count = yearlyDayCalc(func, enddate); 1545 count = yearlyDayCalc(func, enddate);
1543 break; 1546 break;
1544 default: 1547 default:
1545 break; 1548 break;
1546 } 1549 }
1547 1550
1548 switch (func) { 1551 switch (func) {
1549 case END_DATE_AND_COUNT: 1552 case END_DATE_AND_COUNT:
1550 case NEXT_AFTER_DATE: 1553 case NEXT_AFTER_DATE:
1551 if (count == 0) 1554 if (count == 0)
1552 endtime = QDate(); 1555 endtime = QDateTime();
1553 else if (timed) 1556 else if (timed)
1554 enddate = endtime.date(); 1557 enddate = endtime.date();
1555 break; 1558 break;
1556 case COUNT_TO_DATE: 1559 case COUNT_TO_DATE:
1557 break; 1560 break;
1558 } 1561 }
1559 return count; 1562 return count;
1560} 1563}
1561 1564
1562/* Find count and, depending on 'func', the end date/time of a secondly recurrence. 1565/* Find count and, depending on 'func', the end date/time of a secondly recurrence.
1563 * Reply = total number of occurrences up to 'endtime', or 0 if error. 1566 * Reply = total number of occurrences up to 'endtime', or 0 if error.
1564 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'endtime' is updated to the 1567 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'endtime' is updated to the
@@ -1784,42 +1787,42 @@ ex:
1784/* Find count and, depending on 'func', the end date of a monthly recurrence. 1787/* Find count and, depending on 'func', the end date of a monthly recurrence.
1785 * Reply = total number of occurrences up to 'enddate', or 0 if error. 1788 * Reply = total number of occurrences up to 'enddate', or 0 if error.
1786 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the 1789 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the
1787 * recurrence end date. 1790 * recurrence end date.
1788 */ 1791 */
1789struct Recurrence::MonthlyData { 1792struct Recurrence::MonthlyData {
1790 const Recurrence *recurrence; 1793 const Recurrence *recurrence;
1791 int year; // current year 1794 int year; // current year
1792 int month; // current month 0..11 1795 int month; // current month 0..11
1793 int day; // current day of month 1..31 1796 int day; // current day of month 1..31
1794 bool varies; // true if recurring days vary between different months 1797 bool varies; // true if recurring days vary between different months
1795 private: 1798 private:
1796 QValueList<int> days28, days29, days30, days31; // recurring days in months of each length 1799 Q3ValueList<int> days28, days29, days30, days31; // recurring days in months of each length
1797 QValueList<int> *recurDays[4]; 1800 Q3ValueList<int> *recurDays[4];
1798 public: 1801 public:
1799 MonthlyData(const Recurrence* r, const QDate &date) 1802 MonthlyData(const Recurrence* r, const QDate &date)
1800 : recurrence(r), year(date.year()), month(date.month()-1), day(date.day()) 1803 : recurrence(r), year(date.year()), month(date.month()-1), day(date.day())
1801 { recurDays[0] = &days28; 1804 { recurDays[0] = &days28;
1802 recurDays[1] = &days29; 1805 recurDays[1] = &days29;
1803 recurDays[2] = &days30; 1806 recurDays[2] = &days30;
1804 recurDays[3] = &days31; 1807 recurDays[3] = &days31;
1805 varies = (recurrence->recurs == rMonthlyPos) 1808 varies = (recurrence->recurs == rMonthlyPos)
1806 ? true : recurrence->getMonthlyDayDays(days31, 31); 1809 ? true : recurrence->getMonthlyDayDays(days31, 31);
1807 } 1810 }
1808 const QValueList<int>* dayList() const { 1811 const Q3ValueList<int>* dayList() const {
1809 if (!varies) 1812 if (!varies)
1810 return &days31; 1813 return &days31;
1811 QDate startOfMonth(year, month + 1, 1); 1814 QDate startOfMonth(year, month + 1, 1);
1812 int daysInMonth = startOfMonth.daysInMonth(); 1815 int daysInMonth = startOfMonth.daysInMonth();
1813 QValueList<int>* days = recurDays[daysInMonth - 28]; 1816 Q3ValueList<int>* days = recurDays[daysInMonth - 28];
1814 if (recurrence->recurs == rMonthlyPos) 1817 if (recurrence->recurs == rMonthlyPos)
1815 recurrence->getMonthlyPosDays(*days, daysInMonth, startOfMonth.dayOfWeek()); 1818 recurrence->getMonthlyPosDays(*days, daysInMonth, startOfMonth.dayOfWeek());
1816 else if (days->isEmpty()) 1819 else if (days->isEmpty())
1817 recurrence->getMonthlyDayDays(*days, daysInMonth); 1820 recurrence->getMonthlyDayDays(*days, daysInMonth);
1818 return days; 1821 return days;
1819 } 1822 }
1820 int yearMonth() const { return year*12 + month; } 1823 int yearMonth() const { return year*12 + month; }
1821 void addMonths(int diff) { month += diff; year += month / 12; month %= 12; } 1824 void addMonths(int diff) { month += diff; year += month / 12; month %= 12; }
1822 QDate date() const { return QDate(year, month + 1, day); } 1825 QDate date() const { return QDate(year, month + 1, day); }
1823}; 1826};
1824 1827
1825int Recurrence::monthlyCalc(PeriodFunc func, QDate &enddate) const 1828int Recurrence::monthlyCalc(PeriodFunc func, QDate &enddate) const
@@ -1835,26 +1838,26 @@ int Recurrence::monthlyCalc(PeriodFunc func, QDate &enddate) const
1835 case COUNT_TO_DATE: 1838 case COUNT_TO_DATE:
1836 return monthlyCalcToDate(enddate, data); 1839 return monthlyCalcToDate(enddate, data);
1837 case NEXT_AFTER_DATE: 1840 case NEXT_AFTER_DATE:
1838 return monthlyCalcNextAfter(enddate, data); 1841 return monthlyCalcNextAfter(enddate, data);
1839 } 1842 }
1840 return 0; 1843 return 0;
1841} 1844}
1842 1845
1843int Recurrence::monthlyCalcEndDate(QDate &enddate, MonthlyData &data) const 1846int Recurrence::monthlyCalcEndDate(QDate &enddate, MonthlyData &data) const
1844{ 1847{
1845 uint countTogo = rDuration + mRecurExDatesCount; 1848 uint countTogo = rDuration + mRecurExDatesCount;
1846 int countGone = 0; 1849 int countGone = 0;
1847 QValueList<int>::ConstIterator it; 1850 Q3ValueList<int>::ConstIterator it;
1848 const QValueList<int>* days = data.dayList(); 1851 const Q3ValueList<int>* days = data.dayList();
1849 1852
1850 if (data.day > 1) { 1853 if (data.day > 1) {
1851 // Check what remains of the start month 1854 // Check what remains of the start month
1852 for (it = days->begin(); it != days->end(); ++it) { 1855 for (it = days->begin(); it != days->end(); ++it) {
1853 if (*it >= data.day) { 1856 if (*it >= data.day) {
1854 ++countGone; 1857 ++countGone;
1855 if (--countTogo == 0) { 1858 if (--countTogo == 0) {
1856 data.day = *it; 1859 data.day = *it;
1857 break; 1860 break;
1858 } 1861 }
1859 } 1862 }
1860 } 1863 }
@@ -1901,26 +1904,26 @@ int Recurrence::monthlyCalcEndDate(QDate &enddate, MonthlyData &data) const
1901 enddate = data.date(); 1904 enddate = data.date();
1902 return countGone; 1905 return countGone;
1903} 1906}
1904 1907
1905int Recurrence::monthlyCalcToDate(const QDate &enddate, MonthlyData &data) const 1908int Recurrence::monthlyCalcToDate(const QDate &enddate, MonthlyData &data) const
1906{ 1909{
1907 int countGone = 0; 1910 int countGone = 0;
1908 int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX; 1911 int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX;
1909 int endYear = enddate.year(); 1912 int endYear = enddate.year();
1910 int endMonth = enddate.month() - 1; // zero-based 1913 int endMonth = enddate.month() - 1; // zero-based
1911 int endDay = enddate.day(); 1914 int endDay = enddate.day();
1912 int endYearMonth = endYear*12 + endMonth; 1915 int endYearMonth = endYear*12 + endMonth;
1913 QValueList<int>::ConstIterator it; 1916 Q3ValueList<int>::ConstIterator it;
1914 const QValueList<int>* days = data.dayList(); 1917 const Q3ValueList<int>* days = data.dayList();
1915 1918
1916 if (data.day > 1) { 1919 if (data.day > 1) {
1917 // Check what remains of the start month 1920 // Check what remains of the start month
1918 for (it = days->begin(); it != days->end(); ++it) { 1921 for (it = days->begin(); it != days->end(); ++it) {
1919 if (*it >= data.day) { 1922 if (*it >= data.day) {
1920 if (data.yearMonth() == endYearMonth && *it > endDay) 1923 if (data.yearMonth() == endYearMonth && *it > endDay)
1921 return countGone; 1924 return countGone;
1922 if (++countGone >= countMax) 1925 if (++countGone >= countMax)
1923 return countMax; 1926 return countMax;
1924 } 1927 }
1925 } 1928 }
1926 data.day = 1; 1929 data.day = 1;
@@ -1960,26 +1963,26 @@ int Recurrence::monthlyCalcToDate(const QDate &enddate, MonthlyData &data) const
1960 return countMax; 1963 return countMax;
1961 } 1964 }
1962 return countGone; 1965 return countGone;
1963} 1966}
1964 1967
1965int Recurrence::monthlyCalcNextAfter(QDate &enddate, MonthlyData &data) const 1968int Recurrence::monthlyCalcNextAfter(QDate &enddate, MonthlyData &data) const
1966{ 1969{
1967 uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX; 1970 uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX;
1968 int countGone = 0; 1971 int countGone = 0;
1969 int endYear = enddate.year(); 1972 int endYear = enddate.year();
1970 int endDay = enddate.day(); 1973 int endDay = enddate.day();
1971 int endYearMonth = endYear*12 + enddate.month() - 1; 1974 int endYearMonth = endYear*12 + enddate.month() - 1;
1972 QValueList<int>::ConstIterator it; 1975 Q3ValueList<int>::ConstIterator it;
1973 const QValueList<int>* days = data.dayList(); 1976 const Q3ValueList<int>* days = data.dayList();
1974 1977
1975 if (data.day > 1) { 1978 if (data.day > 1) {
1976 // Check what remains of the start month 1979 // Check what remains of the start month
1977 for (it = days->begin(); it != days->end(); ++it) { 1980 for (it = days->begin(); it != days->end(); ++it) {
1978 if (*it >= data.day) { 1981 if (*it >= data.day) {
1979 ++countGone; 1982 ++countGone;
1980 if (data.yearMonth() == endYearMonth && *it > endDay) { 1983 if (data.yearMonth() == endYearMonth && *it > endDay) {
1981 data.day = *it; 1984 data.day = *it;
1982 goto ex; 1985 goto ex;
1983 } 1986 }
1984 if (--countTogo == 0) 1987 if (--countTogo == 0)
1985 return 0; 1988 return 0;
@@ -2043,35 +2046,35 @@ ex:
2043 * Reply = total number of occurrences up to 'enddate', or 0 if error. 2046 * Reply = total number of occurrences up to 'enddate', or 0 if error.
2044 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the 2047 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the
2045 * recurrence end date. 2048 * recurrence end date.
2046 */ 2049 */
2047struct Recurrence::YearlyMonthData { 2050struct Recurrence::YearlyMonthData {
2048 const Recurrence *recurrence; 2051 const Recurrence *recurrence;
2049 int year; // current year 2052 int year; // current year
2050 int month; // current month 1..12 2053 int month; // current month 1..12
2051 int day; // current day of month 1..31 2054 int day; // current day of month 1..31
2052 bool leapyear; // true if February 29th recurs and current year is a leap year 2055 bool leapyear; // true if February 29th recurs and current year is a leap year
2053 bool feb29; // true if February 29th recurs 2056 bool feb29; // true if February 29th recurs
2054 private: 2057 private:
2055 QValueList<int> months; // recurring months in non-leap years 1..12 2058 Q3ValueList<int> months; // recurring months in non-leap years 1..12
2056 QValueList<int> leapMonths; // recurring months in leap years 1..12 2059 Q3ValueList<int> leapMonths; // recurring months in leap years 1..12
2057 public: 2060 public:
2058 YearlyMonthData(const Recurrence* r, const QDate &date) 2061 YearlyMonthData(const Recurrence* r, const QDate &date)
2059 : recurrence(r), year(date.year()), month(date.month()), day(date.day()) 2062 : recurrence(r), year(date.year()), month(date.month()), day(date.day())
2060 { feb29 = recurrence->getYearlyMonthMonths(day, months, leapMonths); 2063 { feb29 = recurrence->getYearlyMonthMonths(day, months, leapMonths);
2061 leapyear = feb29 && QDate::leapYear(year); 2064 leapyear = feb29 && QDate::leapYear(year);
2062 } 2065 }
2063 const QValueList<int>* monthList() const 2066 const Q3ValueList<int>* monthList() const
2064 { return leapyear ? &leapMonths : &months; } 2067 { return leapyear ? &leapMonths : &months; }
2065 const QValueList<int>* leapMonthList() const { return &leapMonths; } 2068 const Q3ValueList<int>* leapMonthList() const { return &leapMonths; }
2066 QDate date() const { return QDate(year, month, day); } 2069 QDate date() const { return QDate(year, month, day); }
2067}; 2070};
2068 2071
2069int Recurrence::yearlyMonthCalc(PeriodFunc func, QDate &enddate) const 2072int Recurrence::yearlyMonthCalc(PeriodFunc func, QDate &enddate) const
2070{ 2073{
2071 if (rYearNums.isEmpty()) 2074 if (rYearNums.isEmpty())
2072 return 0; 2075 return 0;
2073 YearlyMonthData data(this, mRecurStart.date()); 2076 YearlyMonthData data(this, mRecurStart.date());
2074 switch (func) { 2077 switch (func) {
2075 case END_DATE_AND_COUNT: 2078 case END_DATE_AND_COUNT:
2076 return yearlyMonthCalcEndDate(enddate, data); 2079 return yearlyMonthCalcEndDate(enddate, data);
2077 case COUNT_TO_DATE: 2080 case COUNT_TO_DATE:
@@ -2079,26 +2082,26 @@ int Recurrence::yearlyMonthCalc(PeriodFunc func, QDate &enddate) const
2079 case NEXT_AFTER_DATE: 2082 case NEXT_AFTER_DATE:
2080 return yearlyMonthCalcNextAfter(enddate, data); 2083 return yearlyMonthCalcNextAfter(enddate, data);
2081 } 2084 }
2082 return 0; 2085 return 0;
2083} 2086}
2084 2087
2085// Find total count and end date of an annual recurrence by date. 2088// Find total count and end date of an annual recurrence by date.
2086// Reply = total number of occurrences. 2089// Reply = total number of occurrences.
2087int Recurrence::yearlyMonthCalcEndDate(QDate &enddate, YearlyMonthData &data) const 2090int Recurrence::yearlyMonthCalcEndDate(QDate &enddate, YearlyMonthData &data) const
2088{ 2091{
2089 uint countTogo = rDuration + mRecurExDatesCount; 2092 uint countTogo = rDuration + mRecurExDatesCount;
2090 int countGone = 0; 2093 int countGone = 0;
2091 QValueList<int>::ConstIterator it; 2094 Q3ValueList<int>::ConstIterator it;
2092 const QValueList<int>* mons = data.monthList(); // get recurring months for this year 2095 const Q3ValueList<int>* mons = data.monthList(); // get recurring months for this year
2093 2096
2094 if (data.month > 1) { 2097 if (data.month > 1) {
2095 // Check what remains of the start year 2098 // Check what remains of the start year
2096 for (it = mons->begin(); it != mons->end(); ++it) { 2099 for (it = mons->begin(); it != mons->end(); ++it) {
2097 if (*it >= data.month) { 2100 if (*it >= data.month) {
2098 ++countGone; 2101 ++countGone;
2099 if (--countTogo == 0) { 2102 if (--countTogo == 0) {
2100 data.month = *it; 2103 data.month = *it;
2101 if (data.month == 2 && data.feb29 && !data.leapyear) { 2104 if (data.month == 2 && data.feb29 && !data.leapyear) {
2102 // The recurrence should end on February 29th, but it's a non-leap year 2105 // The recurrence should end on February 29th, but it's a non-leap year
2103 switch (mFeb29YearlyType) { 2106 switch (mFeb29YearlyType) {
2104 case rFeb28: 2107 case rFeb28:
@@ -2190,26 +2193,26 @@ int Recurrence::yearlyMonthCalcToDate(const QDate &enddate, YearlyMonthData &dat
2190 * if enddate is Feb 28th on a non-leap year. 2193 * if enddate is Feb 28th on a non-leap year.
2191 * 2) it recurs on Mar 1st in non-leap years, allow the end month to be 2194 * 2) it recurs on Mar 1st in non-leap years, allow the end month to be
2192 * adjusted to February, to simplify calculations. 2195 * adjusted to February, to simplify calculations.
2193 */ 2196 */
2194 if (data.feb29 && !QDate::leapYear(endYear) 2197 if (data.feb29 && !QDate::leapYear(endYear)
2195 && mFeb29YearlyType == rFeb28 && endDay == 28 && endMonth == 2) { 2198 && mFeb29YearlyType == rFeb28 && endDay == 28 && endMonth == 2) {
2196 } 2199 }
2197 else if (--endMonth == 0) { 2200 else if (--endMonth == 0) {
2198 endMonth = 12; 2201 endMonth = 12;
2199 --endYear; 2202 --endYear;
2200 } 2203 }
2201 } 2204 }
2202 QValueList<int>::ConstIterator it; 2205 Q3ValueList<int>::ConstIterator it;
2203 const QValueList<int>* mons = data.monthList(); 2206 const Q3ValueList<int>* mons = data.monthList();
2204 2207
2205 if (data.month > 1) { 2208 if (data.month > 1) {
2206 // Check what remains of the start year 2209 // Check what remains of the start year
2207 for (it = mons->begin(); it != mons->end(); ++it) { 2210 for (it = mons->begin(); it != mons->end(); ++it) {
2208 if (*it >= data.month) { 2211 if (*it >= data.month) {
2209 if (data.year == endYear && *it > endMonth) 2212 if (data.year == endYear && *it > endMonth)
2210 return countGone; 2213 return countGone;
2211 if (++countGone >= countMax) 2214 if (++countGone >= countMax)
2212 return countMax; 2215 return countMax;
2213 } 2216 }
2214 } 2217 }
2215 data.month = 1; 2218 data.month = 1;
@@ -2261,26 +2264,26 @@ int Recurrence::yearlyMonthCalcNextAfter(QDate &enddate, YearlyMonthData &data)
2261 bool mar1TooEarly = false; 2264 bool mar1TooEarly = false;
2262 bool feb28ok = false; 2265 bool feb28ok = false;
2263 if (endDay < data.day) { 2266 if (endDay < data.day) {
2264 if (data.feb29 && mFeb29YearlyType == rMar1 && endMonth == 3) 2267 if (data.feb29 && mFeb29YearlyType == rMar1 && endMonth == 3)
2265 mar1TooEarly = true; 2268 mar1TooEarly = true;
2266 if (data.feb29 && mFeb29YearlyType == rFeb28 && endMonth == 2 && endDay == 28) 2269 if (data.feb29 && mFeb29YearlyType == rFeb28 && endMonth == 2 && endDay == 28)
2267 feb28ok = true; 2270 feb28ok = true;
2268 else if (--endMonth == 0) { 2271 else if (--endMonth == 0) {
2269 endMonth = 12; 2272 endMonth = 12;
2270 --endYear; 2273 --endYear;
2271 } 2274 }
2272 } 2275 }
2273 QValueList<int>::ConstIterator it; 2276 Q3ValueList<int>::ConstIterator it;
2274 const QValueList<int>* mons = data.monthList(); 2277 const Q3ValueList<int>* mons = data.monthList();
2275 2278
2276 if (data.month > 1) { 2279 if (data.month > 1) {
2277 // Check what remains of the start year 2280 // Check what remains of the start year
2278 for (it = mons->begin(); it != mons->end(); ++it) { 2281 for (it = mons->begin(); it != mons->end(); ++it) {
2279 if (*it >= data.month) { 2282 if (*it >= data.month) {
2280 ++countGone; 2283 ++countGone;
2281 if (data.year == endYear 2284 if (data.year == endYear
2282 && ( *it > endMonth && (*it > 3 || !mar1TooEarly) 2285 && ( *it > endMonth && (*it > 3 || !mar1TooEarly)
2283 || *it == 2 && feb28ok && data.leapyear)) { 2286 || *it == 2 && feb28ok && data.leapyear)) {
2284 if (*it == 2 && data.feb29 && !data.leapyear) { 2287 if (*it == 2 && data.feb29 && !data.leapyear) {
2285 // The next recurrence should be on February 29th, but it's a non-leap year 2288 // The next recurrence should be on February 29th, but it's a non-leap year
2286 switch (mFeb29YearlyType) { 2289 switch (mFeb29YearlyType) {
@@ -2381,33 +2384,33 @@ ex:
2381 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the 2384 * If 'func' = END_DATE_AND_COUNT or NEXT_AFTER_DATE, 'enddate' is updated to the
2382 * recurrence end date. 2385 * recurrence end date.
2383 */ 2386 */
2384struct Recurrence::YearlyPosData { 2387struct Recurrence::YearlyPosData {
2385 const Recurrence *recurrence; 2388 const Recurrence *recurrence;
2386 int year; // current year 2389 int year; // current year
2387 int month; // current month 1..12 2390 int month; // current month 1..12
2388 int day; // current day of month 1..31 2391 int day; // current day of month 1..31
2389 int daysPerMonth; // number of days which recur each month, or -1 if variable 2392 int daysPerMonth; // number of days which recur each month, or -1 if variable
2390 int count; // number of days which recur each year, or -1 if variable 2393 int count; // number of days which recur each year, or -1 if variable
2391 bool varies; // true if number of days varies from year to year 2394 bool varies; // true if number of days varies from year to year
2392 private: 2395 private:
2393 mutable QValueList<int> days; 2396 mutable Q3ValueList<int> days;
2394 public: 2397 public:
2395 YearlyPosData(const Recurrence* r, const QDate &date) 2398 YearlyPosData(const Recurrence* r, const QDate &date)
2396 : recurrence(r), year(date.year()), month(date.month()), day(date.day()), count(-1) 2399 : recurrence(r), year(date.year()), month(date.month()), day(date.day()), count(-1)
2397 { if ((daysPerMonth = r->countMonthlyPosDays()) > 0) 2400 { if ((daysPerMonth = r->countMonthlyPosDays()) > 0)
2398 count = daysPerMonth * r->rYearNums.count(); 2401 count = daysPerMonth * r->rYearNums.count();
2399 varies = (daysPerMonth < 0); 2402 varies = (daysPerMonth < 0);
2400 } 2403 }
2401 const QValueList<int>* dayList() const { 2404 const Q3ValueList<int>* dayList() const {
2402 QDate startOfMonth(year, month, 1); 2405 QDate startOfMonth(year, month, 1);
2403 recurrence->getMonthlyPosDays(days, startOfMonth.daysInMonth(), startOfMonth.dayOfWeek()); 2406 recurrence->getMonthlyPosDays(days, startOfMonth.daysInMonth(), startOfMonth.dayOfWeek());
2404 return &days; 2407 return &days;
2405 } 2408 }
2406 int yearMonth() const { return year*12 + month - 1; } 2409 int yearMonth() const { return year*12 + month - 1; }
2407 void addMonths(int diff) { month += diff - 1; year += month / 12; month = month % 12 + 1; } 2410 void addMonths(int diff) { month += diff - 1; year += month / 12; month = month % 12 + 1; }
2408 QDate date() const { return QDate(year, month, day); } 2411 QDate date() const { return QDate(year, month, day); }
2409}; 2412};
2410 2413
2411int Recurrence::yearlyPosCalc(PeriodFunc func, QDate &enddate) const 2414int Recurrence::yearlyPosCalc(PeriodFunc func, QDate &enddate) const
2412{ 2415{
2413 if (rYearNums.isEmpty() || rMonthPositions.isEmpty()) 2416 if (rYearNums.isEmpty() || rMonthPositions.isEmpty())
@@ -2419,30 +2422,30 @@ int Recurrence::yearlyPosCalc(PeriodFunc func, QDate &enddate) const
2419 case COUNT_TO_DATE: 2422 case COUNT_TO_DATE:
2420 return yearlyPosCalcToDate(enddate, data); 2423 return yearlyPosCalcToDate(enddate, data);
2421 case NEXT_AFTER_DATE: 2424 case NEXT_AFTER_DATE:
2422 return yearlyPosCalcNextAfter(enddate, data); 2425 return yearlyPosCalcNextAfter(enddate, data);
2423 } 2426 }
2424 return 0; 2427 return 0;
2425} 2428}
2426 2429
2427int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const 2430int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const
2428{ 2431{
2429 uint countTogo = rDuration + mRecurExDatesCount; 2432 uint countTogo = rDuration + mRecurExDatesCount;
2430 int countGone = 0; 2433 int countGone = 0;
2431 QValueList<int>::ConstIterator id; 2434 Q3ValueList<int>::ConstIterator id;
2432 const QValueList<int>* days; 2435 const Q3ValueList<int>* days;
2433 2436
2434 if (data.month > 1 || data.day > 1) { 2437 if (data.month > 1 || data.day > 1) {
2435 // Check what remains of the start year 2438 // Check what remains of the start year
2436 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2439 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2437 if (*im.current() >= data.month) { 2440 if (*im.current() >= data.month) {
2438 // Check what remains of the start month 2441 // Check what remains of the start month
2439 if (data.day > 1 || data.varies 2442 if (data.day > 1 || data.varies
2440 || static_cast<uint>(data.daysPerMonth) >= countTogo) { 2443 || static_cast<uint>(data.daysPerMonth) >= countTogo) {
2441 data.month = *im.current(); 2444 data.month = *im.current();
2442 days = data.dayList(); 2445 days = data.dayList();
2443 for (id = days->begin(); id != days->end(); ++id) { 2446 for (id = days->begin(); id != days->end(); ++id) {
2444 if (*id >= data.day) { 2447 if (*id >= data.day) {
2445 ++countGone; 2448 ++countGone;
2446 if (--countTogo == 0) { 2449 if (--countTogo == 0) {
2447 data.month = *im.current(); 2450 data.month = *im.current();
2448 data.day = *id; 2451 data.day = *id;
@@ -2457,25 +2460,25 @@ int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const
2457 countTogo -= data.daysPerMonth; 2460 countTogo -= data.daysPerMonth;
2458 countGone += data.daysPerMonth; 2461 countGone += data.daysPerMonth;
2459 } 2462 }
2460 } 2463 }
2461 } 2464 }
2462 data.month = 1; 2465 data.month = 1;
2463 data.year += rFreq; 2466 data.year += rFreq;
2464 } 2467 }
2465 2468
2466 if (data.varies) { 2469 if (data.varies) {
2467 // The number of recurrences varies from year to year. 2470 // The number of recurrences varies from year to year.
2468 for ( ; ; ) { 2471 for ( ; ; ) {
2469 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2472 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2470 data.month = *im.current(); 2473 data.month = *im.current();
2471 days = data.dayList(); 2474 days = data.dayList();
2472 int n = days->count(); 2475 int n = days->count();
2473 if (static_cast<uint>(n) >= countTogo) { 2476 if (static_cast<uint>(n) >= countTogo) {
2474 // Check the last month in the recurrence 2477 // Check the last month in the recurrence
2475 for (id = days->begin(); id != days->end(); ++id) { 2478 for (id = days->begin(); id != days->end(); ++id) {
2476 ++countGone; 2479 ++countGone;
2477 if (--countTogo == 0) { 2480 if (--countTogo == 0) {
2478 data.day = *id; 2481 data.day = *id;
2479 goto ex; 2482 goto ex;
2480 } 2483 }
2481 } 2484 }
@@ -2487,25 +2490,25 @@ int Recurrence::yearlyPosCalcEndDate(QDate &enddate, YearlyPosData &data) const
2487 } 2490 }
2488 } else { 2491 } else {
2489 // The number of recurrences is the same every year, 2492 // The number of recurrences is the same every year,
2490 // so skip the year-by-year check. 2493 // so skip the year-by-year check.
2491 // Skip the remaining whole years, but leave at least 2494 // Skip the remaining whole years, but leave at least
2492 // 1 recurrence remaining, in order to get its date. 2495 // 1 recurrence remaining, in order to get its date.
2493 int wholeYears = (countTogo - 1) / data.count; 2496 int wholeYears = (countTogo - 1) / data.count;
2494 data.year += wholeYears * rFreq; 2497 data.year += wholeYears * rFreq;
2495 countGone += wholeYears * data.count; 2498 countGone += wholeYears * data.count;
2496 countTogo -= wholeYears * data.count; 2499 countTogo -= wholeYears * data.count;
2497 2500
2498 // Check the last year in the recurrence. 2501 // Check the last year in the recurrence.
2499 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2502 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2500 if (static_cast<uint>(data.daysPerMonth) >= countTogo) { 2503 if (static_cast<uint>(data.daysPerMonth) >= countTogo) {
2501 // Check the last month in the recurrence 2504 // Check the last month in the recurrence
2502 data.month = *im.current(); 2505 data.month = *im.current();
2503 days = data.dayList(); 2506 days = data.dayList();
2504 for (id = days->begin(); id != days->end(); ++id) { 2507 for (id = days->begin(); id != days->end(); ++id) {
2505 ++countGone; 2508 ++countGone;
2506 if (--countTogo == 0) { 2509 if (--countTogo == 0) {
2507 data.day = *id; 2510 data.day = *id;
2508 goto ex; 2511 goto ex;
2509 } 2512 }
2510 } 2513 }
2511 } 2514 }
@@ -2522,30 +2525,30 @@ ex:
2522int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) const 2525int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) const
2523{ 2526{
2524 int countGone = 0; 2527 int countGone = 0;
2525 int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX; 2528 int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX;
2526 int endYear = enddate.year(); 2529 int endYear = enddate.year();
2527 int endMonth = enddate.month(); 2530 int endMonth = enddate.month();
2528 int endDay = enddate.day(); 2531 int endDay = enddate.day();
2529 if (endDay < data.day && --endMonth == 0) { 2532 if (endDay < data.day && --endMonth == 0) {
2530 endMonth = 12; 2533 endMonth = 12;
2531 --endYear; 2534 --endYear;
2532 } 2535 }
2533 int endYearMonth = endYear*12 + endMonth; 2536 int endYearMonth = endYear*12 + endMonth;
2534 QValueList<int>::ConstIterator id; 2537 Q3ValueList<int>::ConstIterator id;
2535 const QValueList<int>* days; 2538 const Q3ValueList<int>* days;
2536 2539
2537 if (data.month > 1 || data.day > 1) { 2540 if (data.month > 1 || data.day > 1) {
2538 // Check what remains of the start year 2541 // Check what remains of the start year
2539 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2542 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2540 if (*im.current() >= data.month) { 2543 if (*im.current() >= data.month) {
2541 data.month = *im.current(); 2544 data.month = *im.current();
2542 if (data.yearMonth() > endYearMonth) 2545 if (data.yearMonth() > endYearMonth)
2543 return countGone; 2546 return countGone;
2544 // Check what remains of the start month 2547 // Check what remains of the start month
2545 bool lastMonth = (data.yearMonth() == endYearMonth); 2548 bool lastMonth = (data.yearMonth() == endYearMonth);
2546 if (lastMonth || data.day > 1 || data.varies) { 2549 if (lastMonth || data.day > 1 || data.varies) {
2547 days = data.dayList(); 2550 days = data.dayList();
2548 if (lastMonth || data.day > 1) { 2551 if (lastMonth || data.day > 1) {
2549 for (id = days->begin(); id != days->end(); ++id) { 2552 for (id = days->begin(); id != days->end(); ++id) {
2550 if (*id >= data.day) { 2553 if (*id >= data.day) {
2551 if (lastMonth && *id > endDay) 2554 if (lastMonth && *id > endDay)
@@ -2567,25 +2570,25 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c
2567 if (countGone >= countMax) 2570 if (countGone >= countMax)
2568 return countMax; 2571 return countMax;
2569 } 2572 }
2570 } 2573 }
2571 } 2574 }
2572 data.month = 1; 2575 data.month = 1;
2573 data.year += rFreq; 2576 data.year += rFreq;
2574 } 2577 }
2575 2578
2576 if (data.varies) { 2579 if (data.varies) {
2577 // The number of recurrences varies from year to year. 2580 // The number of recurrences varies from year to year.
2578 for ( ; ; ) { 2581 for ( ; ; ) {
2579 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2582 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2580 data.month = *im.current(); 2583 data.month = *im.current();
2581 days = data.dayList(); 2584 days = data.dayList();
2582 if (data.yearMonth() >= endYearMonth) { 2585 if (data.yearMonth() >= endYearMonth) {
2583 if (data.yearMonth() > endYearMonth) 2586 if (data.yearMonth() > endYearMonth)
2584 return countGone; 2587 return countGone;
2585 // Check the last month in the recurrence 2588 // Check the last month in the recurrence
2586 for (id = days->begin(); id != days->end(); ++id) { 2589 for (id = days->begin(); id != days->end(); ++id) {
2587 if (*id > endDay) 2590 if (*id > endDay)
2588 return countGone; 2591 return countGone;
2589 if (++countGone >= countMax) 2592 if (++countGone >= countMax)
2590 return countMax; 2593 return countMax;
2591 } 2594 }
@@ -2602,25 +2605,25 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c
2602 // so skip the year-by-year check. 2605 // so skip the year-by-year check.
2603 // Skip the remaining whole years, but leave at least 2606 // Skip the remaining whole years, but leave at least
2604 // 1 recurrence remaining, in order to get its date. 2607 // 1 recurrence remaining, in order to get its date.
2605 int wholeYears = endYear - data.year; 2608 int wholeYears = endYear - data.year;
2606 countGone += (wholeYears / rFreq) * data.count; 2609 countGone += (wholeYears / rFreq) * data.count;
2607 if (countGone >= countMax) 2610 if (countGone >= countMax)
2608 return countMax; 2611 return countMax;
2609 if (wholeYears % rFreq) 2612 if (wholeYears % rFreq)
2610 return countGone; // end year isn't a recurrence year 2613 return countGone; // end year isn't a recurrence year
2611 data.year = endYear; 2614 data.year = endYear;
2612 2615
2613 // Check the last year in the recurrence. 2616 // Check the last year in the recurrence.
2614 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2617 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2615 data.month = *im.current(); 2618 data.month = *im.current();
2616 if (data.month >= endMonth) { 2619 if (data.month >= endMonth) {
2617 if (data.month > endMonth) 2620 if (data.month > endMonth)
2618 return countGone; 2621 return countGone;
2619 // Check the last month in the recurrence 2622 // Check the last month in the recurrence
2620 days = data.dayList(); 2623 days = data.dayList();
2621 for (id = days->begin(); id != days->end(); ++id) { 2624 for (id = days->begin(); id != days->end(); ++id) {
2622 if (*id > endDay) 2625 if (*id > endDay)
2623 return countGone; 2626 return countGone;
2624 if (++countGone >= countMax) 2627 if (++countGone >= countMax)
2625 return countMax; 2628 return countMax;
2626 } 2629 }
@@ -2637,32 +2640,32 @@ int Recurrence::yearlyPosCalcToDate(const QDate &enddate, YearlyPosData &data) c
2637int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) const 2640int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) const
2638{ 2641{
2639 uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX; 2642 uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX;
2640 int countGone = 0; 2643 int countGone = 0;
2641 int endYear = enddate.year(); 2644 int endYear = enddate.year();
2642 int endMonth = enddate.month(); 2645 int endMonth = enddate.month();
2643 int endDay = enddate.day(); 2646 int endDay = enddate.day();
2644 if (endDay < data.day && --endMonth == 0) { 2647 if (endDay < data.day && --endMonth == 0) {
2645 endMonth = 12; 2648 endMonth = 12;
2646 --endYear; 2649 --endYear;
2647 } 2650 }
2648 int endYearMonth = endYear*12 + endMonth; 2651 int endYearMonth = endYear*12 + endMonth;
2649 QValueList<int>::ConstIterator id; 2652 Q3ValueList<int>::ConstIterator id;
2650 const QValueList<int>* days; 2653 const Q3ValueList<int>* days;
2651 2654
2652 if (data.varies) { 2655 if (data.varies) {
2653 // The number of recurrences varies from year to year. 2656 // The number of recurrences varies from year to year.
2654 for ( ; ; ) { 2657 for ( ; ; ) {
2655 // Check the next year 2658 // Check the next year
2656 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2659 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2657 if (*im.current() >= data.month) { 2660 if (*im.current() >= data.month) {
2658 // Check the next month 2661 // Check the next month
2659 data.month = *im.current(); 2662 data.month = *im.current();
2660 int ended = data.yearMonth() - endYearMonth; 2663 int ended = data.yearMonth() - endYearMonth;
2661 days = data.dayList(); 2664 days = data.dayList();
2662 if (ended >= 0 || data.day > 1) { 2665 if (ended >= 0 || data.day > 1) {
2663 // This is the start or end month, so check each day 2666 // This is the start or end month, so check each day
2664 for (id = days->begin(); id != days->end(); ++id) { 2667 for (id = days->begin(); id != days->end(); ++id) {
2665 if (*id >= data.day) { 2668 if (*id >= data.day) {
2666 ++countGone; 2669 ++countGone;
2667 if (ended > 0 || (ended == 0 && *id > endDay)) { 2670 if (ended > 0 || (ended == 0 && *id > endDay)) {
2668 data.day = *id; 2671 data.day = *id;
@@ -2680,25 +2683,25 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons
2680 countGone += n; 2683 countGone += n;
2681 } 2684 }
2682 data.day = 1; // we've checked the start month now 2685 data.day = 1; // we've checked the start month now
2683 } 2686 }
2684 } 2687 }
2685 data.month = 1; // we've checked the start year now 2688 data.month = 1; // we've checked the start year now
2686 data.year += rFreq; 2689 data.year += rFreq;
2687 } 2690 }
2688 } else { 2691 } else {
2689 // The number of recurrences is the same every year. 2692 // The number of recurrences is the same every year.
2690 if (data.month > 1 || data.day > 1) { 2693 if (data.month > 1 || data.day > 1) {
2691 // Check what remains of the start year 2694 // Check what remains of the start year
2692 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2695 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2693 if (*im.current() >= data.month) { 2696 if (*im.current() >= data.month) {
2694 // Check what remains of the start month 2697 // Check what remains of the start month
2695 data.month = *im.current(); 2698 data.month = *im.current();
2696 int ended = data.yearMonth() - endYearMonth; 2699 int ended = data.yearMonth() - endYearMonth;
2697 if (ended >= 0 || data.day > 1) { 2700 if (ended >= 0 || data.day > 1) {
2698 // This is the start or end month, so check each day 2701 // This is the start or end month, so check each day
2699 days = data.dayList(); 2702 days = data.dayList();
2700 for (id = days->begin(); id != days->end(); ++id) { 2703 for (id = days->begin(); id != days->end(); ++id) {
2701 if (*id >= data.day) { 2704 if (*id >= data.day) {
2702 ++countGone; 2705 ++countGone;
2703 if (ended > 0 || (ended == 0 && *id > endDay)) { 2706 if (ended > 0 || (ended == 0 && *id > endDay)) {
2704 data.day = *id; 2707 data.day = *id;
@@ -2725,25 +2728,25 @@ int Recurrence::yearlyPosCalcNextAfter(QDate &enddate, YearlyPosData &data) cons
2725 && *rYearNums.getLast() <= endMonth) 2728 && *rYearNums.getLast() <= endMonth)
2726 ++recurYears; // required year is after endYear 2729 ++recurYears; // required year is after endYear
2727 if (recurYears) { 2730 if (recurYears) {
2728 int n = recurYears * data.count; 2731 int n = recurYears * data.count;
2729 if (static_cast<uint>(n) > countTogo) 2732 if (static_cast<uint>(n) > countTogo)
2730 return 0; // reached end of recurrence 2733 return 0; // reached end of recurrence
2731 countTogo -= n; 2734 countTogo -= n;
2732 countGone += n; 2735 countGone += n;
2733 data.year += recurYears * rFreq; 2736 data.year += recurYears * rFreq;
2734 } 2737 }
2735 2738
2736 // Check the last year in the recurrence 2739 // Check the last year in the recurrence
2737 for (QPtrListIterator<int> im(rYearNums); im.current(); ++im) { 2740 for (Q3PtrListIterator<int> im(rYearNums); im.current(); ++im) {
2738 data.month = *im.current(); 2741 data.month = *im.current();
2739 int ended = data.yearMonth() - endYearMonth; 2742 int ended = data.yearMonth() - endYearMonth;
2740 if (ended >= 0) { 2743 if (ended >= 0) {
2741 // This is the end month, so check each day 2744 // This is the end month, so check each day
2742 days = data.dayList(); 2745 days = data.dayList();
2743 for (id = days->begin(); id != days->end(); ++id) { 2746 for (id = days->begin(); id != days->end(); ++id) {
2744 ++countGone; 2747 ++countGone;
2745 if (ended > 0 || (ended == 0 && *id > endDay)) { 2748 if (ended > 0 || (ended == 0 && *id > endDay)) {
2746 data.day = *id; 2749 data.day = *id;
2747 goto ex; 2750 goto ex;
2748 } 2751 }
2749 if (--countTogo == 0) 2752 if (--countTogo == 0)
@@ -2799,25 +2802,25 @@ int Recurrence::yearlyDayCalc(PeriodFunc func, QDate &enddate) const
2799 } 2802 }
2800 return 0; 2803 return 0;
2801} 2804}
2802 2805
2803int Recurrence::yearlyDayCalcEndDate(QDate &enddate, YearlyDayData &data) const 2806int Recurrence::yearlyDayCalcEndDate(QDate &enddate, YearlyDayData &data) const
2804{ 2807{
2805 uint countTogo = rDuration + mRecurExDatesCount; 2808 uint countTogo = rDuration + mRecurExDatesCount;
2806 int countGone = 0; 2809 int countGone = 0;
2807 2810
2808 if (data.day > 1) { 2811 if (data.day > 1) {
2809 // Check what remains of the start year 2812 // Check what remains of the start year
2810 bool leapOK = data.isMaxDayCount(); 2813 bool leapOK = data.isMaxDayCount();
2811 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 2814 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
2812 int d = *it.current(); 2815 int d = *it.current();
2813 if (d >= data.day && (leapOK || d < 366)) { 2816 if (d >= data.day && (leapOK || d < 366)) {
2814 ++countGone; 2817 ++countGone;
2815 if (--countTogo == 0) { 2818 if (--countTogo == 0) {
2816 data.day = d; 2819 data.day = d;
2817 goto ex; 2820 goto ex;
2818 } 2821 }
2819 } 2822 }
2820 } 2823 }
2821 data.day = 1; 2824 data.day = 1;
2822 data.year += rFreq; 2825 data.year += rFreq;
2823 } 2826 }
@@ -2837,48 +2840,48 @@ int Recurrence::yearlyDayCalcEndDate(QDate &enddate, YearlyDayData &data) const
2837 // The number of recurrences is the same every year, 2840 // The number of recurrences is the same every year,
2838 // so skip the year-by-year check. 2841 // so skip the year-by-year check.
2839 // Skip the remaining whole years, but leave at least 2842 // Skip the remaining whole years, but leave at least
2840 // 1 recurrence remaining, in order to get its date. 2843 // 1 recurrence remaining, in order to get its date.
2841 int daysPerYear = rYearNums.count(); 2844 int daysPerYear = rYearNums.count();
2842 int wholeYears = (countTogo - 1) / daysPerYear; 2845 int wholeYears = (countTogo - 1) / daysPerYear;
2843 data.year += wholeYears * rFreq; 2846 data.year += wholeYears * rFreq;
2844 countGone += wholeYears * daysPerYear; 2847 countGone += wholeYears * daysPerYear;
2845 countTogo -= wholeYears * daysPerYear; 2848 countTogo -= wholeYears * daysPerYear;
2846 } 2849 }
2847 if (countTogo) { 2850 if (countTogo) {
2848 // Check the last year in the recurrence 2851 // Check the last year in the recurrence
2849 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 2852 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
2850 ++countGone; 2853 ++countGone;
2851 if (--countTogo == 0) { 2854 if (--countTogo == 0) {
2852 data.day = *it.current(); 2855 data.day = *it.current();
2853 break; 2856 break;
2854 } 2857 }
2855 } 2858 }
2856 } 2859 }
2857ex: 2860ex:
2858 enddate = data.date(); 2861 enddate = data.date();
2859 return countGone; 2862 return countGone;
2860} 2863}
2861 2864
2862int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) const 2865int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) const
2863{ 2866{
2864 int countGone = 0; 2867 int countGone = 0;
2865 int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX; 2868 int countMax = (rDuration > 0) ? rDuration + mRecurExDatesCount : INT_MAX;
2866 int endYear = enddate.year(); 2869 int endYear = enddate.year();
2867 int endDay = enddate.dayOfYear(); 2870 int endDay = enddate.dayOfYear();
2868 2871
2869 if (data.day > 1) { 2872 if (data.day > 1) {
2870 // Check what remains of the start year 2873 // Check what remains of the start year
2871 bool leapOK = data.isMaxDayCount(); 2874 bool leapOK = data.isMaxDayCount();
2872 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 2875 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
2873 int d = *it.current(); 2876 int d = *it.current();
2874 if (d >= data.day && (leapOK || d < 366)) { 2877 if (d >= data.day && (leapOK || d < 366)) {
2875 if (data.year == endYear && d > endDay) 2878 if (data.year == endYear && d > endDay)
2876 return countGone; 2879 return countGone;
2877 if (++countGone >= countMax) 2880 if (++countGone >= countMax)
2878 return countMax; 2881 return countMax;
2879 } 2882 }
2880 } 2883 }
2881 data.day = 1; 2884 data.day = 1;
2882 data.year += rFreq; 2885 data.year += rFreq;
2883 } 2886 }
2884 2887
@@ -2899,45 +2902,45 @@ int Recurrence::yearlyDayCalcToDate(const QDate &enddate, YearlyDayData &data) c
2899 // Skip the remaining whole years. 2902 // Skip the remaining whole years.
2900 int wholeYears = endYear - data.year; 2903 int wholeYears = endYear - data.year;
2901 countGone += (wholeYears / rFreq) * rYearNums.count(); 2904 countGone += (wholeYears / rFreq) * rYearNums.count();
2902 if (countGone >= countMax) 2905 if (countGone >= countMax)
2903 return countMax; 2906 return countMax;
2904 if (wholeYears % rFreq) 2907 if (wholeYears % rFreq)
2905 return countGone; // end year isn't a recurrence year 2908 return countGone; // end year isn't a recurrence year
2906 data.year = endYear; 2909 data.year = endYear;
2907 } 2910 }
2908 2911
2909 if (data.year <= endYear) { 2912 if (data.year <= endYear) {
2910 // Check the last year in the recurrence 2913 // Check the last year in the recurrence
2911 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 2914 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
2912 if (*it.current() > endDay) 2915 if (*it.current() > endDay)
2913 return countGone; 2916 return countGone;
2914 if (++countGone >= countMax) 2917 if (++countGone >= countMax)
2915 return countMax; 2918 return countMax;
2916 } 2919 }
2917 } 2920 }
2918 return countGone; 2921 return countGone;
2919} 2922}
2920 2923
2921int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) const 2924int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) const
2922{ 2925{
2923 uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX; 2926 uint countTogo = (rDuration > 0) ? rDuration + mRecurExDatesCount : UINT_MAX;
2924 int countGone = 0; 2927 int countGone = 0;
2925 int endYear = enddate.year(); 2928 int endYear = enddate.year();
2926 int endDay = enddate.dayOfYear(); 2929 int endDay = enddate.dayOfYear();
2927 2930
2928 if (data.day > 1) { 2931 if (data.day > 1) {
2929 // Check what remains of the start year 2932 // Check what remains of the start year
2930 bool leapOK = data.isMaxDayCount(); 2933 bool leapOK = data.isMaxDayCount();
2931 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 2934 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
2932 int d = *it.current(); 2935 int d = *it.current();
2933 if (d >= data.day && (leapOK || d < 366)) { 2936 if (d >= data.day && (leapOK || d < 366)) {
2934 ++countGone; 2937 ++countGone;
2935 if (data.year == endYear && d > endDay) { 2938 if (data.year == endYear && d > endDay) {
2936 data.day = d; 2939 data.day = d;
2937 goto ex; 2940 goto ex;
2938 } 2941 }
2939 if (--countTogo == 0) 2942 if (--countTogo == 0)
2940 return 0; 2943 return 0;
2941 } 2944 }
2942 } 2945 }
2943 data.day = 1; 2946 data.day = 1;
@@ -2968,49 +2971,49 @@ int Recurrence::yearlyDayCalcNextAfter(QDate &enddate, YearlyDayData &data) cons
2968 ++recurYears; // required year is after endYear 2971 ++recurYears; // required year is after endYear
2969 if (recurYears) { 2972 if (recurYears) {
2970 int n = recurYears * daysPerYear; 2973 int n = recurYears * daysPerYear;
2971 if (static_cast<uint>(n) > countTogo) 2974 if (static_cast<uint>(n) > countTogo)
2972 return 0; // reached end of recurrence 2975 return 0; // reached end of recurrence
2973 countTogo -= n; 2976 countTogo -= n;
2974 countGone += n; 2977 countGone += n;
2975 data.year += recurYears * rFreq; 2978 data.year += recurYears * rFreq;
2976 } 2979 }
2977 } 2980 }
2978 2981
2979 // Check the last year in the recurrence 2982 // Check the last year in the recurrence
2980 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 2983 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
2981 ++countGone; 2984 ++countGone;
2982 int d = *it.current(); 2985 int d = *it.current();
2983 if (data.year > endYear || d > endDay) { 2986 if (data.year > endYear || d > endDay) {
2984 data.day = d; 2987 data.day = d;
2985 break; 2988 break;
2986 } 2989 }
2987 if (--countTogo == 0) 2990 if (--countTogo == 0)
2988 return 0; 2991 return 0;
2989 } 2992 }
2990ex: 2993ex:
2991 enddate = data.date(); 2994 enddate = data.date();
2992 return countGone; 2995 return countGone;
2993} 2996}
2994 2997
2995// Get the days in this month which recur, in numerical order. 2998// Get the days in this month which recur, in numerical order.
2996// Parameters: daysInMonth = number of days in this month 2999// Parameters: daysInMonth = number of days in this month
2997// startDayOfWeek = day of week for first day of month. 3000// startDayOfWeek = day of week for first day of month.
2998void Recurrence::getMonthlyPosDays(QValueList<int> &list, int daysInMonth, int startDayOfWeek) const 3001void Recurrence::getMonthlyPosDays(Q3ValueList<int> &list, int daysInMonth, int startDayOfWeek) const
2999{ 3002{
3000 list.clear(); 3003 list.clear();
3001 int endDayOfWeek = (startDayOfWeek + daysInMonth - 2) % 7 + 1; 3004 int endDayOfWeek = (startDayOfWeek + daysInMonth - 2) % 7 + 1;
3002 // Go through the list, compiling a bit list of actual day numbers 3005 // Go through the list, compiling a bit list of actual day numbers
3003 Q_UINT32 days = 0; 3006 Q_UINT32 days = 0;
3004 for (QPtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) { 3007 for (Q3PtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) {
3005 int weeknum = pos.current()->rPos - 1; // get 0-based week number 3008 int weeknum = pos.current()->rPos - 1; // get 0-based week number
3006 QBitArray &rdays = pos.current()->rDays; 3009 QBitArray &rdays = pos.current()->rDays;
3007 if (pos.current()->negative) { 3010 if (pos.current()->negative) {
3008 // nth days before the end of the month 3011 // nth days before the end of the month
3009 for (uint i = 1; i <= 7; ++i) { 3012 for (uint i = 1; i <= 7; ++i) {
3010 if (rdays.testBit(i - 1)) { 3013 if (rdays.testBit(i - 1)) {
3011 int day = daysInMonth - weeknum*7 - (endDayOfWeek - i + 7) % 7; 3014 int day = daysInMonth - weeknum*7 - (endDayOfWeek - i + 7) % 7;
3012 if (day > 0) 3015 if (day > 0)
3013 days |= 1 << (day - 1); 3016 days |= 1 << (day - 1);
3014 } 3017 }
3015 } 3018 }
3016 } else { 3019 } else {
@@ -3030,25 +3033,25 @@ void Recurrence::getMonthlyPosDays(QValueList<int> &list, int daysInMonth, int s
3030 if (days & mask) 3033 if (days & mask)
3031 list.append(i + 1); 3034 list.append(i + 1);
3032 } 3035 }
3033} 3036}
3034 3037
3035// Get the number of days in the month which recur. 3038// Get the number of days in the month which recur.
3036// Reply = -1 if the number varies from month to month. 3039// Reply = -1 if the number varies from month to month.
3037int Recurrence::countMonthlyPosDays() const 3040int Recurrence::countMonthlyPosDays() const
3038{ 3041{
3039 int count = 0; 3042 int count = 0;
3040 Q_UINT8 positive[5] = { 0, 0, 0, 0, 0 }; 3043 Q_UINT8 positive[5] = { 0, 0, 0, 0, 0 };
3041 Q_UINT8 negative[4] = { 0, 0, 0, 0 }; 3044 Q_UINT8 negative[4] = { 0, 0, 0, 0 };
3042 for (QPtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) { 3045 for (Q3PtrListIterator<rMonthPos> pos(rMonthPositions); pos.current(); ++pos) {
3043 int weeknum = pos.current()->rPos; 3046 int weeknum = pos.current()->rPos;
3044 Q_UINT8* wk; 3047 Q_UINT8* wk;
3045 if (pos.current()->negative) { 3048 if (pos.current()->negative) {
3046 // nth days before the end of the month 3049 // nth days before the end of the month
3047 if (weeknum > 4) 3050 if (weeknum > 4)
3048 return -1; // days in 5th week are often missing 3051 return -1; // days in 5th week are often missing
3049 wk = &negative[4 - weeknum]; 3052 wk = &negative[4 - weeknum];
3050 } else { 3053 } else {
3051 // nth days after the start of the month 3054 // nth days after the start of the month
3052 if (weeknum > 4) 3055 if (weeknum > 4)
3053 return -1; // days in 5th week are often missing 3056 return -1; // days in 5th week are often missing
3054 wk = &positive[weeknum - 1]; 3057 wk = &positive[weeknum - 1];
@@ -3063,30 +3066,30 @@ int Recurrence::countMonthlyPosDays() const
3063 } 3066 }
3064 // Check for any possible days which could be duplicated by 3067 // Check for any possible days which could be duplicated by
3065 // a positive and a negative position. 3068 // a positive and a negative position.
3066 for (int i = 0; i < 4; ++i) { 3069 for (int i = 0; i < 4; ++i) {
3067 if (negative[i] & (positive[i] | positive[i+1])) 3070 if (negative[i] & (positive[i] | positive[i+1]))
3068 return -1; 3071 return -1;
3069 } 3072 }
3070 return count; 3073 return count;
3071} 3074}
3072 3075
3073// Get the days in this month which recur, in numerical order. 3076// Get the days in this month which recur, in numerical order.
3074// Reply = true if day numbers varies from month to month. 3077// Reply = true if day numbers varies from month to month.
3075bool Recurrence::getMonthlyDayDays(QValueList<int> &list, int daysInMonth) const 3078bool Recurrence::getMonthlyDayDays(Q3ValueList<int> &list, int daysInMonth) const
3076{ 3079{
3077 list.clear(); 3080 list.clear();
3078 bool variable = false; 3081 bool variable = false;
3079 Q_UINT32 days = 0; 3082 Q_UINT32 days = 0;
3080 for (QPtrListIterator<int> it(rMonthDays); it.current(); ++it) { 3083 for (Q3PtrListIterator<int> it(rMonthDays); it.current(); ++it) {
3081 int day = *it.current(); 3084 int day = *it.current();
3082 if (day > 0) { 3085 if (day > 0) {
3083 // date in the month 3086 // date in the month
3084 if (day <= daysInMonth) 3087 if (day <= daysInMonth)
3085 days |= 1 << (day - 1); 3088 days |= 1 << (day - 1);
3086 if (day > 28 && day <= 31) 3089 if (day > 28 && day <= 31)
3087 variable = true; // this date does not appear in some months 3090 variable = true; // this date does not appear in some months
3088 } else if (day < 0) { 3091 } else if (day < 0) {
3089 // days before the end of the month 3092 // days before the end of the month
3090 variable = true; // this date varies depending on the month length 3093 variable = true; // this date varies depending on the month length
3091 day = daysInMonth + day; // zero-based day of month 3094 day = daysInMonth + day; // zero-based day of month
3092 if (day >= 0) 3095 if (day >= 0)
@@ -3097,30 +3100,30 @@ bool Recurrence::getMonthlyDayDays(QValueList<int> &list, int daysInMonth) const
3097 Q_UINT32 mask = 1; 3100 Q_UINT32 mask = 1;
3098 for (int i = 0; i < daysInMonth; mask <<= 1, ++i) { 3101 for (int i = 0; i < daysInMonth; mask <<= 1, ++i) {
3099 if (days & mask) 3102 if (days & mask)
3100 list.append(i + 1); 3103 list.append(i + 1);
3101 } 3104 }
3102 return variable; 3105 return variable;
3103} 3106}
3104 3107
3105// Get the months which recur, in numerical order, for both leap years and non-leap years. 3108// Get the months which recur, in numerical order, for both leap years and non-leap years.
3106// N.B. If February 29th recurs on March 1st in non-leap years, February (not March) is 3109// N.B. If February 29th recurs on March 1st in non-leap years, February (not March) is
3107// included in the non-leap year month list. 3110// included in the non-leap year month list.
3108// Reply = true if February 29th also recurs. 3111// Reply = true if February 29th also recurs.
3109bool Recurrence::getYearlyMonthMonths(int day, QValueList<int> &list, QValueList<int> &leaplist) const 3112bool Recurrence::getYearlyMonthMonths(int day, Q3ValueList<int> &list, Q3ValueList<int> &leaplist) const
3110{ 3113{
3111 list.clear(); 3114 list.clear();
3112 leaplist.clear(); 3115 leaplist.clear();
3113 bool feb29 = false; 3116 bool feb29 = false;
3114 for (QPtrListIterator<int> it(rYearNums); it.current(); ++it) { 3117 for (Q3PtrListIterator<int> it(rYearNums); it.current(); ++it) {
3115 int month = *it.current(); 3118 int month = *it.current();
3116 if (month == 2) { 3119 if (month == 2) {
3117 if (day <= 28) { 3120 if (day <= 28) {
3118 list.append(month); // date appears in February 3121 list.append(month); // date appears in February
3119 leaplist.append(month); 3122 leaplist.append(month);
3120 } 3123 }
3121 else if (day == 29) { 3124 else if (day == 29) {
3122 // February 29th 3125 // February 29th
3123 leaplist.append(month); 3126 leaplist.append(month);
3124 switch (mFeb29YearlyType) { 3127 switch (mFeb29YearlyType) {
3125 case rFeb28: 3128 case rFeb28:
3126 case rMar1: 3129 case rMar1:
@@ -3178,94 +3181,94 @@ int Recurrence::getLastDayInWeek(int endDay, bool useWeekStart) const
3178 3181
3179/* From the recurrence monthly day number list or monthly day of week/week of 3182/* From the recurrence monthly day number list or monthly day of week/week of
3180 * month list, get the earliest day in the specified month which is >= the 3183 * month list, get the earliest day in the specified month which is >= the
3181 * earliestDate. 3184 * earliestDate.
3182 */ 3185 */
3183QDate Recurrence::getFirstDateInMonth(const QDate &earliestDate) const 3186QDate Recurrence::getFirstDateInMonth(const QDate &earliestDate) const
3184{ 3187{
3185 int earliestDay = earliestDate.day(); 3188 int earliestDay = earliestDate.day();
3186 int daysInMonth = earliestDate.daysInMonth(); 3189 int daysInMonth = earliestDate.daysInMonth();
3187 switch (recurs) { 3190 switch (recurs) {
3188 case rMonthlyDay: { 3191 case rMonthlyDay: {
3189 int minday = daysInMonth + 1; 3192 int minday = daysInMonth + 1;
3190 for (QPtrListIterator<int> it(rMonthDays); it.current(); ++it) { 3193 for (Q3PtrListIterator<int> it(rMonthDays); it.current(); ++it) {
3191 int day = *it.current(); 3194 int day = *it.current();
3192 if (day < 0) 3195 if (day < 0)
3193 day = daysInMonth + day + 1; 3196 day = daysInMonth + day + 1;
3194 if (day >= earliestDay && day < minday) 3197 if (day >= earliestDay && day < minday)
3195 minday = day; 3198 minday = day;
3196 } 3199 }
3197 if (minday <= daysInMonth) 3200 if (minday <= daysInMonth)
3198 return earliestDate.addDays(minday - earliestDay); 3201 return earliestDate.addDays(minday - earliestDay);
3199 break; 3202 break;
3200 } 3203 }
3201 case rMonthlyPos: 3204 case rMonthlyPos:
3202 case rYearlyPos: { 3205 case rYearlyPos: {
3203 QDate monthBegin(earliestDate.addDays(1 - earliestDay)); 3206 QDate monthBegin(earliestDate.addDays(1 - earliestDay));
3204 QValueList<int> dayList; 3207 Q3ValueList<int> dayList;
3205 getMonthlyPosDays(dayList, daysInMonth, monthBegin.dayOfWeek()); 3208 getMonthlyPosDays(dayList, daysInMonth, monthBegin.dayOfWeek());
3206 for (QValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) { 3209 for (Q3ValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) {
3207 if (*id >= earliestDay) 3210 if (*id >= earliestDay)
3208 return monthBegin.addDays(*id - 1); 3211 return monthBegin.addDays(*id - 1);
3209 } 3212 }
3210 break; 3213 break;
3211 } 3214 }
3212 } 3215 }
3213 return QDate(); 3216 return QDate();
3214} 3217}
3215 3218
3216/* From the recurrence monthly day number list or monthly day of week/week of 3219/* From the recurrence monthly day number list or monthly day of week/week of
3217 * month list, get the latest day in the specified month which is <= the 3220 * month list, get the latest day in the specified month which is <= the
3218 * latestDate. 3221 * latestDate.
3219 */ 3222 */
3220QDate Recurrence::getLastDateInMonth(const QDate &latestDate) const 3223QDate Recurrence::getLastDateInMonth(const QDate &latestDate) const
3221{ 3224{
3222 int latestDay = latestDate.day(); 3225 int latestDay = latestDate.day();
3223 int daysInMonth = latestDate.daysInMonth(); 3226 int daysInMonth = latestDate.daysInMonth();
3224 switch (recurs) { 3227 switch (recurs) {
3225 case rMonthlyDay: { 3228 case rMonthlyDay: {
3226 int maxday = -1; 3229 int maxday = -1;
3227 for (QPtrListIterator<int> it(rMonthDays); it.current(); ++it) { 3230 for (Q3PtrListIterator<int> it(rMonthDays); it.current(); ++it) {
3228 int day = *it.current(); 3231 int day = *it.current();
3229 if (day < 0) 3232 if (day < 0)
3230 day = daysInMonth + day + 1; 3233 day = daysInMonth + day + 1;
3231 if (day <= latestDay && day > maxday) 3234 if (day <= latestDay && day > maxday)
3232 maxday = day; 3235 maxday = day;
3233 } 3236 }
3234 if (maxday > 0) 3237 if (maxday > 0)
3235 return QDate(latestDate.year(), latestDate.month(), maxday); 3238 return QDate(latestDate.year(), latestDate.month(), maxday);
3236 break; 3239 break;
3237 } 3240 }
3238 case rMonthlyPos: 3241 case rMonthlyPos:
3239 case rYearlyPos: { 3242 case rYearlyPos: {
3240 QDate monthBegin(latestDate.addDays(1 - latestDay)); 3243 QDate monthBegin(latestDate.addDays(1 - latestDay));
3241 QValueList<int> dayList; 3244 Q3ValueList<int> dayList;
3242 getMonthlyPosDays(dayList, daysInMonth, monthBegin.dayOfWeek()); 3245 getMonthlyPosDays(dayList, daysInMonth, monthBegin.dayOfWeek());
3243 for (QValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) { 3246 for (Q3ValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) {
3244 if (*id <= latestDay) 3247 if (*id <= latestDay)
3245 return monthBegin.addDays(*id - 1); 3248 return monthBegin.addDays(*id - 1);
3246 } 3249 }
3247 break; 3250 break;
3248 } 3251 }
3249 } 3252 }
3250 return QDate(); 3253 return QDate();
3251} 3254}
3252 3255
3253/* From the recurrence yearly month list or yearly day list, get the earliest 3256/* From the recurrence yearly month list or yearly day list, get the earliest
3254 * month or day in the specified year which is >= the earliestDate. 3257 * month or day in the specified year which is >= the earliestDate.
3255 * Note that rYearNums is sorted in numerical order. 3258 * Note that rYearNums is sorted in numerical order.
3256 */ 3259 */
3257QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const 3260QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const
3258{ 3261{
3259 QPtrListIterator<int> it(rYearNums); 3262 Q3PtrListIterator<int> it(rYearNums);
3260 switch (recurs) { 3263 switch (recurs) {
3261 case rYearlyMonth: { 3264 case rYearlyMonth: {
3262 int day = recurStart().date().day(); 3265 int day = recurStart().date().day();
3263 int earliestYear = earliestDate.year(); 3266 int earliestYear = earliestDate.year();
3264 int earliestMonth = earliestDate.month(); 3267 int earliestMonth = earliestDate.month();
3265 int earliestDay = earliestDate.day(); 3268 int earliestDay = earliestDate.day();
3266 if (earliestDay > day) { 3269 if (earliestDay > day) {
3267 // The earliest date is later in the month than the recurrence date, 3270 // The earliest date is later in the month than the recurrence date,
3268 // so skip to the next month before starting to check 3271 // so skip to the next month before starting to check
3269 if (++earliestMonth > 12) 3272 if (++earliestMonth > 12)
3270 return QDate(); 3273 return QDate();
3271 } 3274 }
@@ -3283,34 +3286,34 @@ QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const
3283 if (earliestDay <= 28) 3286 if (earliestDay <= 28)
3284 return QDate(earliestYear, 2, 28); 3287 return QDate(earliestYear, 2, 28);
3285 break; 3288 break;
3286 case rFeb29: 3289 case rFeb29:
3287 break; 3290 break;
3288 } 3291 }
3289 } 3292 }
3290 } 3293 }
3291 } 3294 }
3292 break; 3295 break;
3293 } 3296 }
3294 case rYearlyPos: { 3297 case rYearlyPos: {
3295 QValueList<int> dayList; 3298 Q3ValueList<int> dayList;
3296 int earliestYear = earliestDate.year(); 3299 int earliestYear = earliestDate.year();
3297 int earliestMonth = earliestDate.month(); 3300 int earliestMonth = earliestDate.month();
3298 int earliestDay = earliestDate.day(); 3301 int earliestDay = earliestDate.day();
3299 for ( ; it.current(); ++it) { 3302 for ( ; it.current(); ++it) {
3300 int month = *it.current(); 3303 int month = *it.current();
3301 if (month >= earliestMonth) { 3304 if (month >= earliestMonth) {
3302 QDate monthBegin(earliestYear, month, 1); 3305 QDate monthBegin(earliestYear, month, 1);
3303 getMonthlyPosDays(dayList, monthBegin.daysInMonth(), monthBegin.dayOfWeek()); 3306 getMonthlyPosDays(dayList, monthBegin.daysInMonth(), monthBegin.dayOfWeek());
3304 for (QValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) { 3307 for (Q3ValueList<int>::ConstIterator id = dayList.begin(); id != dayList.end(); ++id) {
3305 if (*id >= earliestDay) 3308 if (*id >= earliestDay)
3306 return monthBegin.addDays(*id - 1); 3309 return monthBegin.addDays(*id - 1);
3307 } 3310 }
3308 earliestDay = 1; 3311 earliestDay = 1;
3309 } 3312 }
3310 } 3313 }
3311 break; 3314 break;
3312 } 3315 }
3313 case rYearlyDay: { 3316 case rYearlyDay: {
3314 int earliestDay = earliestDate.dayOfYear(); 3317 int earliestDay = earliestDate.dayOfYear();
3315 for ( ; it.current(); ++it) { 3318 for ( ; it.current(); ++it) {
3316 int day = *it.current(); 3319 int day = *it.current();
@@ -3320,25 +3323,25 @@ QDate Recurrence::getFirstDateInYear(const QDate &earliestDate) const
3320 break; 3323 break;
3321 } 3324 }
3322 } 3325 }
3323 return QDate(); 3326 return QDate();
3324} 3327}
3325 3328
3326/* From the recurrence yearly month list or yearly day list, get the latest 3329/* From the recurrence yearly month list or yearly day list, get the latest
3327 * month or day in the specified year which is <= the latestDate. 3330 * month or day in the specified year which is <= the latestDate.
3328 * Note that rYearNums is sorted in numerical order. 3331 * Note that rYearNums is sorted in numerical order.
3329 */ 3332 */
3330QDate Recurrence::getLastDateInYear(const QDate &latestDate) const 3333QDate Recurrence::getLastDateInYear(const QDate &latestDate) const
3331{ 3334{
3332 QPtrListIterator<int> it(rYearNums); 3335 Q3PtrListIterator<int> it(rYearNums);
3333 switch (recurs) { 3336 switch (recurs) {
3334 case rYearlyMonth: { 3337 case rYearlyMonth: {
3335 int day = recurStart().date().day(); 3338 int day = recurStart().date().day();
3336 int latestYear = latestDate.year(); 3339 int latestYear = latestDate.year();
3337 int latestMonth = latestDate.month(); 3340 int latestMonth = latestDate.month();
3338 if (latestDate.day() > day) { 3341 if (latestDate.day() > day) {
3339 // The latest date is earlier in the month than the recurrence date, 3342 // The latest date is earlier in the month than the recurrence date,
3340 // so skip to the previous month before starting to check 3343 // so skip to the previous month before starting to check
3341 if (--latestMonth <= 0) 3344 if (--latestMonth <= 0)
3342 return QDate(); 3345 return QDate();
3343 } 3346 }
3344 for (it.toLast(); it.current(); --it) { 3347 for (it.toLast(); it.current(); --it) {
@@ -3355,34 +3358,34 @@ QDate Recurrence::getLastDateInYear(const QDate &latestDate) const
3355 break; 3358 break;
3356 case rFeb28: 3359 case rFeb28:
3357 return QDate(latestYear, 2, 28); 3360 return QDate(latestYear, 2, 28);
3358 case rFeb29: 3361 case rFeb29:
3359 break; 3362 break;
3360 } 3363 }
3361 } 3364 }
3362 } 3365 }
3363 } 3366 }
3364 break; 3367 break;
3365 } 3368 }
3366 case rYearlyPos: { 3369 case rYearlyPos: {
3367 QValueList<int> dayList; 3370 Q3ValueList<int> dayList;
3368 int latestYear = latestDate.year(); 3371 int latestYear = latestDate.year();
3369 int latestMonth = latestDate.month(); 3372 int latestMonth = latestDate.month();
3370 int latestDay = latestDate.day(); 3373 int latestDay = latestDate.day();
3371 for (it.toLast(); it.current(); --it) { 3374 for (it.toLast(); it.current(); --it) {
3372 int month = *it.current(); 3375 int month = *it.current();
3373 if (month <= latestMonth) { 3376 if (month <= latestMonth) {
3374 QDate monthBegin(latestYear, month, 1); 3377 QDate monthBegin(latestYear, month, 1);
3375 getMonthlyPosDays(dayList, monthBegin.daysInMonth(), monthBegin.dayOfWeek()); 3378 getMonthlyPosDays(dayList, monthBegin.daysInMonth(), monthBegin.dayOfWeek());
3376 for (QValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) { 3379 for (Q3ValueList<int>::ConstIterator id = dayList.fromLast(); id != dayList.end(); --id) {
3377 if (*id <= latestDay) 3380 if (*id <= latestDay)
3378 return monthBegin.addDays(*id - 1); 3381 return monthBegin.addDays(*id - 1);
3379 } 3382 }
3380 latestDay = 31; 3383 latestDay = 31;
3381 } 3384 }
3382 } 3385 }
3383 break; 3386 break;
3384 } 3387 }
3385 case rYearlyDay: { 3388 case rYearlyDay: {
3386 int latestDay = latestDate.dayOfYear(); 3389 int latestDay = latestDate.dayOfYear();
3387 for (it.toLast(); it.current(); --it) { 3390 for (it.toLast(); it.current(); --it) {
3388 int day = *it.current(); 3391 int day = *it.current();
diff --git a/libkcal/recurrence.h b/libkcal/recurrence.h
index b13d14f..5b5aab1 100644
--- a/libkcal/recurrence.h
+++ b/libkcal/recurrence.h
@@ -15,25 +15,27 @@
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22#ifndef KCAL_RECURRENCE_H 22#ifndef KCAL_RECURRENCE_H
23#define KCAL_RECURRENCE_H 23#define KCAL_RECURRENCE_H
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qbitarray.h> 26#include <qbitarray.h>
27#include <qptrlist.h> 27#include <q3ptrlist.h>
28//Added by qt3to4:
29#include <Q3ValueList>
28 30
29namespace KCal { 31namespace KCal {
30 32
31class Incidence; 33class Incidence;
32 34
33/** 35/**
34 This class represents a recurrence rule for a calendar incidence. 36 This class represents a recurrence rule for a calendar incidence.
35*/ 37*/
36class Recurrence 38class Recurrence
37{ 39{
38 public: 40 public:
39 /** enumeration for describing how an event recurs, if at all. */ 41 /** enumeration for describing how an event recurs, if at all. */
@@ -239,27 +241,27 @@ class Recurrence
239 * @var _rPos the position in the month for the recurrence, with valid 241 * @var _rPos the position in the month for the recurrence, with valid
240 * values being 1-5 (5 weeks max in a month). 242 * values being 1-5 (5 weeks max in a month).
241 * @var _rDays the days for the position to recur on (bit 0 = Monday). 243 * @var _rDays the days for the position to recur on (bit 0 = Monday).
242 * Example: _rPos = 2, and bits 0 and 2 are set in _rDays: 244 * Example: _rPos = 2, and bits 0 and 2 are set in _rDays:
243 * the rule is to repeat every 2nd Monday and Wednesday in the month. 245 * the rule is to repeat every 2nd Monday and Wednesday in the month.
244 */ 246 */
245 void addMonthlyPos(short _rPos, const QBitArray &_rDays); 247 void addMonthlyPos(short _rPos, const QBitArray &_rDays);
246 /** Adds a position the the recursMonthlyDay list. 248 /** Adds a position the the recursMonthlyDay list.
247 * @var _rDay the date in the month to recur. 249 * @var _rDay the date in the month to recur.
248 */ 250 */
249 void addMonthlyDay(short _rDay); 251 void addMonthlyDay(short _rDay);
250 /** Returns list of day positions in months. */ 252 /** Returns list of day positions in months. */
251 const QPtrList<rMonthPos> &monthPositions() const; 253 const Q3PtrList<rMonthPos> &monthPositions() const;
252 /** Returns list of day numbers of a month. */ 254 /** Returns list of day numbers of a month. */
253 const QPtrList<int> &monthDays() const; 255 const Q3PtrList<int> &monthDays() const;
254 256
255 /** Sets an event to recur yearly. 257 /** Sets an event to recur yearly.
256 * @var type rYearlyMonth, rYearlyPos or rYearlyDay 258 * @var type rYearlyMonth, rYearlyPos or rYearlyDay
257 * @var freq the frequency to recur, e.g. 3 for every third year. 259 * @var freq the frequency to recur, e.g. 3 for every third year.
258 * @var duration the number of times the event is to occur, or -1 to recur indefinitely. 260 * @var duration the number of times the event is to occur, or -1 to recur indefinitely.
259 */ 261 */
260 void setYearly(int type, int freq, int duration); 262 void setYearly(int type, int freq, int duration);
261 /** Sets an event to recur yearly ending at \a endDate. */ 263 /** Sets an event to recur yearly ending at \a endDate. */
262 void setYearly(int type, int freq, const QDate &endDate); 264 void setYearly(int type, int freq, const QDate &endDate);
263 /** Sets an event to recur yearly on specified dates. 265 /** Sets an event to recur yearly on specified dates.
264 * The dates must be specified by calling addYearlyNum(). 266 * The dates must be specified by calling addYearlyNum().
265 * @var type the way recurrences of February 29th are to be handled in non-leap years. 267 * @var type the way recurrences of February 29th are to be handled in non-leap years.
@@ -270,41 +272,41 @@ class Recurrence
270 /** Sets an event to recur yearly ending at \a endDate. */ 272 /** Sets an event to recur yearly ending at \a endDate. */
271 void setYearlyByDate(Feb29Type type, int freq, const QDate &endDate); 273 void setYearlyByDate(Feb29Type type, int freq, const QDate &endDate);
272 /** Adds position of day or month in year. 274 /** Adds position of day or month in year.
273 * N.B. for recursYearlyPos, addYearlyMonthPos() must also be called 275 * N.B. for recursYearlyPos, addYearlyMonthPos() must also be called
274 * to add positions within the month. */ 276 * to add positions within the month. */
275 void addYearlyNum(short _rNum); 277 void addYearlyNum(short _rNum);
276 /** Adds a position to the recursYearlyPos recurrence rule, if it is set. 278 /** Adds a position to the recursYearlyPos recurrence rule, if it is set.
277 * N.B. addYearlyNum() must also be called to add recurrence months. 279 * N.B. addYearlyNum() must also be called to add recurrence months.
278 * Parameters are the same as for addMonthlyPos(). 280 * Parameters are the same as for addMonthlyPos().
279 */ 281 */
280 void addYearlyMonthPos(short _rPos, const QBitArray &_rDays); 282 void addYearlyMonthPos(short _rPos, const QBitArray &_rDays);
281 /** Returns positions of days or months in year. */ 283 /** Returns positions of days or months in year. */
282 const QPtrList<int> &yearNums() const; 284 const Q3PtrList<int> &yearNums() const;
283 /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */ 285 /** Returns list of day positions in months, for a recursYearlyPos recurrence rule. */
284 const QPtrList<rMonthPos> &yearMonthPositions() const; 286 const Q3PtrList<rMonthPos> &yearMonthPositions() const;
285 /** Returns how yearly recurrences of February 29th are handled. */ 287 /** Returns how yearly recurrences of February 29th are handled. */
286 Feb29Type feb29YearlyType() const { return mFeb29YearlyType; } 288 Feb29Type feb29YearlyType() const { return mFeb29YearlyType; }
287 /** Sets the default method for handling yearly recurrences of February 29th. */ 289 /** Sets the default method for handling yearly recurrences of February 29th. */
288 static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; } 290 static void setFeb29YearlyTypeDefault(Feb29Type t) { mFeb29YearlyDefaultType = t; }
289 /** Returns the default method for handling yearly recurrences of February 29th. */ 291 /** Returns the default method for handling yearly recurrences of February 29th. */
290 static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; } 292 static Feb29Type setFeb29YearlyTypeDefault() { return mFeb29YearlyDefaultType; }
291 void addYearlyMonth(short _rPos ); // added LR 293 void addYearlyMonth(short _rPos ); // added LR
292 /** 294 /**
293 Debug output. 295 Debug output.
294 */ 296 */
295 void dump() const; 297 void dump() const;
296 QString recurrenceText() const; 298 QString recurrenceText() const;
297 bool getYearlyMonthMonths(int day, QValueList<int>&, 299 bool getYearlyMonthMonths(int day, Q3ValueList<int>&,
298 QValueList<int> &leaplist) const; 300 Q3ValueList<int> &leaplist) const;
299 301
300 protected: 302 protected:
301 enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE }; 303 enum PeriodFunc { END_DATE_AND_COUNT, COUNT_TO_DATE, NEXT_AFTER_DATE };
302 struct MonthlyData; friend struct MonthlyData; 304 struct MonthlyData; friend struct MonthlyData;
303 struct YearlyMonthData; friend struct YearlyMonthData; 305 struct YearlyMonthData; friend struct YearlyMonthData;
304 struct YearlyPosData; friend struct YearlyPosData; 306 struct YearlyPosData; friend struct YearlyPosData;
305 struct YearlyDayData; friend struct YearlyDayData; 307 struct YearlyDayData; friend struct YearlyDayData;
306 308
307 bool recursSecondly(const QDate &, int secondFreq) const; 309 bool recursSecondly(const QDate &, int secondFreq) const;
308 bool recursMinutelyAt(const QDateTime &dt, int minuteFreq) const; 310 bool recursMinutelyAt(const QDateTime &dt, int minuteFreq) const;
309 bool recursDaily(const QDate &) const; 311 bool recursDaily(const QDate &) const;
310 bool recursWeekly(const QDate &) const; 312 bool recursWeekly(const QDate &) const;
@@ -336,52 +338,52 @@ class Recurrence
336 int yearlyMonthCalcToDate(const QDate& enddate, YearlyMonthData&) const; 338 int yearlyMonthCalcToDate(const QDate& enddate, YearlyMonthData&) const;
337 int yearlyMonthCalcNextAfter(QDate& enddate, YearlyMonthData&) const; 339 int yearlyMonthCalcNextAfter(QDate& enddate, YearlyMonthData&) const;
338 int yearlyPosCalc(PeriodFunc, QDate &enddate) const; 340 int yearlyPosCalc(PeriodFunc, QDate &enddate) const;
339 int yearlyPosCalcEndDate(QDate& enddate, YearlyPosData&) const; 341 int yearlyPosCalcEndDate(QDate& enddate, YearlyPosData&) const;
340 int yearlyPosCalcToDate(const QDate& enddate, YearlyPosData&) const; 342 int yearlyPosCalcToDate(const QDate& enddate, YearlyPosData&) const;
341 int yearlyPosCalcNextAfter(QDate& enddate, YearlyPosData&) const; 343 int yearlyPosCalcNextAfter(QDate& enddate, YearlyPosData&) const;
342 int yearlyDayCalc(PeriodFunc, QDate &enddate) const; 344 int yearlyDayCalc(PeriodFunc, QDate &enddate) const;
343 int yearlyDayCalcEndDate(QDate& enddate, YearlyDayData&) const; 345 int yearlyDayCalcEndDate(QDate& enddate, YearlyDayData&) const;
344 int yearlyDayCalcToDate(const QDate& enddate, YearlyDayData&) const; 346 int yearlyDayCalcToDate(const QDate& enddate, YearlyDayData&) const;
345 int yearlyDayCalcNextAfter(QDate& enddate, YearlyDayData&) const; 347 int yearlyDayCalcNextAfter(QDate& enddate, YearlyDayData&) const;
346 348
347 int countMonthlyPosDays() const; 349 int countMonthlyPosDays() const;
348 void getMonthlyPosDays(QValueList<int>&, int daysInMonth, 350 void getMonthlyPosDays(Q3ValueList<int>&, int daysInMonth,
349 int startDayOfWeek) const; 351 int startDayOfWeek) const;
350 bool getMonthlyDayDays(QValueList<int>&, int daysInMonth) const; 352 bool getMonthlyDayDays(Q3ValueList<int>&, int daysInMonth) const;
351 353
352 int getFirstDayInWeek(int startDay, bool useWeekStart = true) const; 354 int getFirstDayInWeek(int startDay, bool useWeekStart = true) const;
353 int getLastDayInWeek(int endDay, bool useWeekStart = true) const; 355 int getLastDayInWeek(int endDay, bool useWeekStart = true) const;
354 QDate getFirstDateInMonth(const QDate& earliestDate) const; 356 QDate getFirstDateInMonth(const QDate& earliestDate) const;
355 QDate getLastDateInMonth(const QDate& latestDate) const; 357 QDate getLastDateInMonth(const QDate& latestDate) const;
356 QDate getFirstDateInYear(const QDate& earliestDate) const; 358 QDate getFirstDateInYear(const QDate& earliestDate) const;
357 QDate getLastDateInYear(const QDate& latestDate) const; 359 QDate getLastDateInYear(const QDate& latestDate) const;
358 360
359 private: 361 private:
360 // Prohibit copying 362 // Prohibit copying
361 Recurrence(const Recurrence&); 363 Recurrence(const Recurrence&);
362 Recurrence &operator=(const Recurrence&); 364 Recurrence &operator=(const Recurrence&);
363 365
364 short recurs; // should be one of the enums. 366 short recurs; // should be one of the enums.
365 367
366 int rWeekStart; // day which starts the week, Monday=1 .. Sunday=7 368 int rWeekStart; // day which starts the week, Monday=1 .. Sunday=7
367 QBitArray rDays; // array of days during week it recurs 369 QBitArray rDays; // array of days during week it recurs
368 370
369 QPtrList<rMonthPos> rMonthPositions; // list of positions during a month 371 Q3PtrList<rMonthPos> rMonthPositions; // list of positions during a month
370 // on which an event recurs 372 // on which an event recurs
371 373
372 QPtrList<int> rMonthDays; // list of days during a month on 374 Q3PtrList<int> rMonthDays; // list of days during a month on
373 // which the event recurs 375 // which the event recurs
374 376
375 QPtrList<int> rYearNums; // either months/days to recur on for rYearly, 377 Q3PtrList<int> rYearNums; // either months/days to recur on for rYearly,
376 // sorted in numerical order 378 // sorted in numerical order
377 379
378 int rFreq; // frequency of period 380 int rFreq; // frequency of period
379 381
380 // one of the following must be specified 382 // one of the following must be specified
381 int rDuration; // num times to recur (inc. first occurrence), -1 = infinite 383 int rDuration; // num times to recur (inc. first occurrence), -1 = infinite
382 QDateTime rEndDateTime; // date/time at which to end recurrence 384 QDateTime rEndDateTime; // date/time at which to end recurrence
383 385
384 QDateTime mRecurStart; // date/time of first recurrence 386 QDateTime mRecurStart; // date/time of first recurrence
385 bool mFloats; // the recurrence has no time, just a date 387 bool mFloats; // the recurrence has no time, just a date
386 bool mRecurReadOnly; 388 bool mRecurReadOnly;
387 int mRecurExDatesCount; // number of recurrences (in addition to rDuration) which are excluded 389 int mRecurExDatesCount; // number of recurrences (in addition to rDuration) which are excluded
diff --git a/libkcal/scheduler.cpp b/libkcal/scheduler.cpp
index 253d8b7..234cfcf 100644
--- a/libkcal/scheduler.cpp
+++ b/libkcal/scheduler.cpp
@@ -11,25 +11,27 @@
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 <qdir.h> 21#include <qdir.h>
22#include <qfile.h> 22#include <qfile.h>
23#include <qtextstream.h> 23#include <q3textstream.h>
24//Added by qt3to4:
25#include <Q3PtrList>
24 26
25#include <klocale.h> 27#include <klocale.h>
26#include <kdebug.h> 28#include <kdebug.h>
27#include <kstandarddirs.h> 29#include <kstandarddirs.h>
28 30
29#include "event.h" 31#include "event.h"
30#include "todo.h" 32#include "todo.h"
31#include "freebusy.h" 33#include "freebusy.h"
32#include "icalformat.h" 34#include "icalformat.h"
33#include "calendar.h" 35#include "calendar.h"
34 36
35#include "scheduler.h" 37#include "scheduler.h"
@@ -255,26 +257,26 @@ bool Scheduler::acceptDeclineCounter(IncidenceBase *incidence,ScheduleMessage::S
255 257
256bool Scheduler::acceptReply(IncidenceBase *incidence,ScheduleMessage::Status status, Method method) 258bool Scheduler::acceptReply(IncidenceBase *incidence,ScheduleMessage::Status status, Method method)
257{ 259{
258 if(incidence->type()=="FreeBusy") { 260 if(incidence->type()=="FreeBusy") {
259 return acceptFreeBusy(incidence, method); 261 return acceptFreeBusy(incidence, method);
260 } 262 }
261 bool ret = false; 263 bool ret = false;
262 Event *ev = mCalendar->event(incidence->uid()); 264 Event *ev = mCalendar->event(incidence->uid());
263 Todo *to = mCalendar->todo(incidence->uid()); 265 Todo *to = mCalendar->todo(incidence->uid());
264 if (ev || to) { 266 if (ev || to) {
265 //get matching attendee in calendar 267 //get matching attendee in calendar
266 kdDebug(5800) << "Scheduler::acceptTransaction match found!" << endl; 268 kdDebug(5800) << "Scheduler::acceptTransaction match found!" << endl;
267 QPtrList<Attendee> attendeesIn = incidence->attendees(); 269 Q3PtrList<Attendee> attendeesIn = incidence->attendees();
268 QPtrList<Attendee> attendeesEv; 270 Q3PtrList<Attendee> attendeesEv;
269 if (ev) attendeesEv = ev->attendees(); 271 if (ev) attendeesEv = ev->attendees();
270 if (to) attendeesEv = to->attendees(); 272 if (to) attendeesEv = to->attendees();
271 Attendee *attIn; 273 Attendee *attIn;
272 Attendee *attEv; 274 Attendee *attEv;
273 for ( attIn = attendeesIn.first(); attIn; attIn = attendeesIn.next() ) { 275 for ( attIn = attendeesIn.first(); attIn; attIn = attendeesIn.next() ) {
274 for ( attEv = attendeesEv.first(); attEv; attEv = attendeesEv.next() ) { 276 for ( attEv = attendeesEv.first(); attEv; attEv = attendeesEv.next() ) {
275 if (attIn->email()==attEv->email()) { 277 if (attIn->email()==attEv->email()) {
276 //update attendee-info 278 //update attendee-info
277 kdDebug(5800) << "Scheduler::acceptTransaction update attendee" << endl; 279 kdDebug(5800) << "Scheduler::acceptTransaction update attendee" << endl;
278 attEv->setStatus(attIn->status()); 280 attEv->setStatus(attIn->status());
279 attEv->setRSVP(false); 281 attEv->setRSVP(false);
280 // better to not update the sequence number with replys 282 // better to not update the sequence number with replys
@@ -333,23 +335,23 @@ bool Scheduler::acceptFreeBusy(IncidenceBase *incidence, Method method)
333 filename += "/"; 335 filename += "/";
334 filename += from; 336 filename += from;
335 filename += ".ifb"; 337 filename += ".ifb";
336 QFile f(filename); 338 QFile f(filename);
337 339
338 kdDebug() << "acceptFreeBusy: filename" << filename << endl; 340 kdDebug() << "acceptFreeBusy: filename" << filename << endl;
339 341
340 freebusy->clearAttendees(); 342 freebusy->clearAttendees();
341 freebusy->setOrganizer(from); 343 freebusy->setOrganizer(from);
342 344
343 QString messageText = mFormat->createScheduleMessage(freebusy, Publish); 345 QString messageText = mFormat->createScheduleMessage(freebusy, Publish);
344 346
345 if (!f.open(IO_ReadWrite)) { 347 if (!f.open(QIODevice::ReadWrite)) {
346 kdDebug() << "acceptFreeBusy: Can't open:" << filename << " for writing" << endl; 348 kdDebug() << "acceptFreeBusy: Can't open:" << filename << " for writing" << endl;
347 return false; 349 return false;
348 } 350 }
349 QTextStream t(&f); 351 Q3TextStream t(&f);
350 t << messageText; 352 t << messageText;
351 f.close(); 353 f.close();
352 354
353 deleteTransaction(incidence); 355 deleteTransaction(incidence);
354 return true; 356 return true;
355} 357}
diff --git a/libkcal/scheduler.h b/libkcal/scheduler.h
index a9f43b9..357e98e 100644
--- a/libkcal/scheduler.h
+++ b/libkcal/scheduler.h
@@ -14,25 +14,25 @@
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#ifndef SCHEDULER_H 20#ifndef SCHEDULER_H
21#define SCHEDULER_H 21#define SCHEDULER_H
22 22
23// iTIP transactions base class 23// iTIP transactions base class
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qptrlist.h> 26#include <q3ptrlist.h>
27 27
28namespace KCal { 28namespace KCal {
29 29
30class IncidenceBase; 30class IncidenceBase;
31class Event; 31class Event;
32class Calendar; 32class Calendar;
33class ICalFormat; 33class ICalFormat;
34 34
35/** 35/**
36 This class provides an encapsulation of a scheduling message. It associates an 36 This class provides an encapsulation of a scheduling message. It associates an
37 incidence with a method and status information. This class is used by the 37 incidence with a method and status information. This class is used by the
38 Scheduler class. 38 Scheduler class.
@@ -86,25 +86,25 @@ class Scheduler {
86 virtual ~Scheduler(); 86 virtual ~Scheduler();
87 87
88 /** iTIP publish action */ 88 /** iTIP publish action */
89 virtual bool publish (IncidenceBase *incidence,const QString &recipients) = 0; 89 virtual bool publish (IncidenceBase *incidence,const QString &recipients) = 0;
90 /** Perform iTIP transaction on incidence. The method is specified as the 90 /** Perform iTIP transaction on incidence. The method is specified as the
91 method argumanet and can be any valid iTIP method. */ 91 method argumanet and can be any valid iTIP method. */
92 virtual bool performTransaction(IncidenceBase *incidence,Method method) = 0; 92 virtual bool performTransaction(IncidenceBase *incidence,Method method) = 0;
93 /** Perform iTIP transaction on incidence to specified recipient(s). The 93 /** Perform iTIP transaction on incidence to specified recipient(s). The
94 method is specified as the method argumanet and can be any valid iTIP 94 method is specified as the method argumanet and can be any valid iTIP
95 method. */ 95 method. */
96 virtual bool performTransaction(IncidenceBase *incidence,Method method,const QString &recipients) = 0; 96 virtual bool performTransaction(IncidenceBase *incidence,Method method,const QString &recipients) = 0;
97 /** Retrieve incoming iTIP transactions */ 97 /** Retrieve incoming iTIP transactions */
98 virtual QPtrList<ScheduleMessage> retrieveTransactions() = 0; 98 virtual Q3PtrList<ScheduleMessage> retrieveTransactions() = 0;
99 99
100 /** 100 /**
101 Accept transaction. The incidence argument specifies the iCal compoennt 101 Accept transaction. The incidence argument specifies the iCal compoennt
102 on which the transaction acts. The status is the result of processing a 102 on which the transaction acts. The status is the result of processing a
103 iTIP message with the current calendar and specifies the action to be 103 iTIP message with the current calendar and specifies the action to be
104 taken for this incidence. 104 taken for this incidence.
105 */ 105 */
106 bool acceptTransaction(IncidenceBase *,Method method,ScheduleMessage::Status status); 106 bool acceptTransaction(IncidenceBase *,Method method,ScheduleMessage::Status status);
107 107
108 /** Return a machine-readable name for a iTIP method. */ 108 /** Return a machine-readable name for a iTIP method. */
109 static QString methodName(Method); 109 static QString methodName(Method);
110 /** Return a translated and human-readable name for a iTIP method. */ 110 /** Return a translated and human-readable name for a iTIP method. */
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index 9b757f7..b8c2aa7 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -13,30 +13,30 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qdatetime.h> 22#include <qdatetime.h>
23#include <qstring.h> 23#include <qstring.h>
24#include <qapplication.h> 24#include <qapplication.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qmessagebox.h> 27#include <qmessagebox.h>
28#include <qclipboard.h> 28#include <qclipboard.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qtextstream.h> 30#include <q3textstream.h>
31#include <qtextcodec.h> 31#include <qtextcodec.h>
32#include <qxml.h> 32#include <qxml.h>
33#include <qlabel.h> 33#include <qlabel.h>
34 34
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kglobal.h> 37#include <kglobal.h>
38 38
39#include "calendar.h" 39#include "calendar.h"
40#include "alarm.h" 40#include "alarm.h"
41#include "recurrence.h" 41#include "recurrence.h"
42#include "calendarlocal.h" 42#include "calendarlocal.h"
@@ -357,47 +357,47 @@ bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
357 status.raise(); 357 status.raise();
358 qApp->processEvents(); 358 qApp->processEvents();
359 QString fileName; 359 QString fileName;
360 if ( ! debug ) { 360 if ( ! debug ) {
361 fileName = "/tmp/kopitempout"; 361 fileName = "/tmp/kopitempout";
362 QString command ="db2file datebook -r -c "+ codec + " > " + fileName; 362 QString command ="db2file datebook -r -c "+ codec + " > " + fileName;
363 system ( command.latin1() ); 363 system ( command.latin1() );
364 } else { 364 } else {
365 fileName = "/tmp/events.txt"; 365 fileName = "/tmp/events.txt";
366 366
367 } 367 }
368 QFile file( fileName ); 368 QFile file( fileName );
369 if (!file.open( IO_ReadOnly ) ) { 369 if (!file.open( QIODevice::ReadOnly ) ) {
370 return false; 370 return false;
371 371
372 } 372 }
373 QTextStream ts( &file ); 373 Q3TextStream ts( &file );
374 ts.setCodec( QTextCodec::codecForName("utf8") ); 374 ts.setCodec( QTextCodec::codecForName("utf8") );
375 text = ts.read(); 375 text = ts.read();
376 file.close(); 376 file.close();
377 status.setText( i18n("Processing events ...") ); 377 status.setText( i18n("Processing events ...") );
378 status.raise(); 378 status.raise();
379 qApp->processEvents(); 379 qApp->processEvents();
380 fromString2Cal( calendar, existngCal, text, "Event" ); 380 fromString2Cal( calendar, existngCal, text, "Event" );
381 status.setText( i18n("Reading todos ...") ); 381 status.setText( i18n("Reading todos ...") );
382 qApp->processEvents(); 382 qApp->processEvents();
383 if ( ! debug ) { 383 if ( ! debug ) {
384 fileName = "/tmp/kopitempout"; 384 fileName = "/tmp/kopitempout";
385 QString command = "db2file todo -r -c " + codec+ " > " + fileName; 385 QString command = "db2file todo -r -c " + codec+ " > " + fileName;
386 system ( command.latin1() ); 386 system ( command.latin1() );
387 } else { 387 } else {
388 fileName = "/tmp/todo.txt"; 388 fileName = "/tmp/todo.txt";
389 } 389 }
390 file.setName( fileName ); 390 file.setName( fileName );
391 if (!file.open( IO_ReadOnly ) ) { 391 if (!file.open( QIODevice::ReadOnly ) ) {
392 return false; 392 return false;
393 393
394 } 394 }
395 ts.setDevice( &file ); 395 ts.setDevice( &file );
396 text = ts.read(); 396 text = ts.read();
397 file.close(); 397 file.close();
398 398
399 status.setText( i18n("Processing todos ...") ); 399 status.setText( i18n("Processing todos ...") );
400 status.raise(); 400 status.raise();
401 qApp->processEvents(); 401 qApp->processEvents();
402 fromString2Cal( calendar, existngCal, text, "Todo" ); 402 fromString2Cal( calendar, existngCal, text, "Todo" );
403 return true; 403 return true;
@@ -466,25 +466,25 @@ bool SharpFormat::save( Calendar *calendar)
466 int dh = QApplication::desktop()->height(); 466 int dh = QApplication::desktop()->height();
467 status.setCaption(i18n("Writing DTM Data") ); 467 status.setCaption(i18n("Writing DTM Data") );
468 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 468 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
469 status.show(); 469 status.show();
470 status.raise(); 470 status.raise();
471 qApp->processEvents(); 471 qApp->processEvents();
472 bool debug = DEBUGMODE; 472 bool debug = DEBUGMODE;
473 QString codec = "utf8"; 473 QString codec = "utf8";
474 QString answer; 474 QString answer;
475 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n"; 475 QString ePrefix = "CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY\n";
476 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n"; 476 QString tPrefix = "CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1\n";
477 QString command; 477 QString command;
478 QPtrList<Event> er = calendar->rawEvents(); 478 Q3PtrList<Event> er = calendar->rawEvents();
479 Event* ev = er.first(); 479 Event* ev = er.first();
480 QString fileName = "/tmp/kopitempout"; 480 QString fileName = "/tmp/kopitempout";
481 int i = 0; 481 int i = 0;
482 QString changeString = ePrefix; 482 QString changeString = ePrefix;
483 QString deleteString = ePrefix; 483 QString deleteString = ePrefix;
484 bool deleteEnt = false; 484 bool deleteEnt = false;
485 bool changeEnt = false; 485 bool changeEnt = false;
486 QString message = i18n("Processing event # "); 486 QString message = i18n("Processing event # ");
487 int procCount = 0; 487 int procCount = 0;
488 while ( ev ) { 488 while ( ev ) {
489 //qDebug("i %d ", ++i); 489 //qDebug("i %d ", ++i);
490 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 490 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
@@ -494,186 +494,186 @@ bool SharpFormat::save( Calendar *calendar)
494 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 494 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
495 // deleting empty strings does not work. 495 // deleting empty strings does not work.
496 // we write first and x and then delete the record with the x 496 // we write first and x and then delete the record with the x
497 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 497 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
498 changeString += eString + "\n"; 498 changeString += eString + "\n";
499 deleteString += eString + "\n"; 499 deleteString += eString + "\n";
500 deleteEnt = true; 500 deleteEnt = true;
501 changeEnt = true; 501 changeEnt = true;
502 } 502 }
503 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new 503 else if ( ev->getID("Sharp_DTM").isEmpty() ) { // add new
504 QString fileNameIn = "/tmp/kopitempin"; 504 QString fileNameIn = "/tmp/kopitempin";
505 QFile fileIn( fileNameIn ); 505 QFile fileIn( fileNameIn );
506 if (!fileIn.open( IO_WriteOnly ) ) { 506 if (!fileIn.open( QIODevice::WriteOnly ) ) {
507 return false; 507 return false;
508 } 508 }
509 QTextStream tsIn( &fileIn ); 509 Q3TextStream tsIn( &fileIn );
510 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 510 tsIn.setCodec( QTextCodec::codecForName("utf8") );
511 tsIn << ePrefix << eString ; 511 tsIn << ePrefix << eString ;
512 fileIn.close(); 512 fileIn.close();
513 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 513 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
514 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName; 514 command = "(cat /tmp/kopitempin | db2file datebook -w -g -c " + codec+ ") > "+ fileName;
515 //qDebug("command ++++++++ "); 515 //qDebug("command ++++++++ ");
516 //qDebug("%s ",command.latin1()); 516 //qDebug("%s ",command.latin1());
517 //qDebug("command -------- "); 517 //qDebug("command -------- ");
518 system ( command.utf8() ); 518 system ( command.utf8() );
519 QFile file( fileName ); 519 QFile file( fileName );
520 if (!file.open( IO_ReadOnly ) ) { 520 if (!file.open( QIODevice::ReadOnly ) ) {
521 return false; 521 return false;
522 522
523 } 523 }
524 QTextStream ts( &file ); 524 Q3TextStream ts( &file );
525 ts.setCodec( QTextCodec::codecForName("utf8") ); 525 ts.setCodec( QTextCodec::codecForName("utf8") );
526 answer = ts.read(); 526 answer = ts.read();
527 file.close(); 527 file.close();
528 //qDebug("answer \n%s ", answer.latin1()); 528 //qDebug("answer \n%s ", answer.latin1());
529 getNumFromRecord( answer, ev ) ; 529 getNumFromRecord( answer, ev ) ;
530 530
531 } 531 }
532 else { // change existing 532 else { // change existing
533 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() ); 533 //qDebug("canging %d %d",ev->zaurusStat() ,ev->zaurusId() );
534 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 534 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
535 changeString += eString + "\n"; 535 changeString += eString + "\n";
536 changeEnt = true; 536 changeEnt = true;
537 537
538 } 538 }
539 } 539 }
540 ev = er.next(); 540 ev = er.next();
541 } 541 }
542 status.setText ( i18n("Changing events ...") ); 542 status.setText ( i18n("Changing events ...") );
543 qApp->processEvents(); 543 qApp->processEvents();
544 //qDebug("changing... "); 544 //qDebug("changing... ");
545 if ( changeEnt ) { 545 if ( changeEnt ) {
546 QFile file( fileName ); 546 QFile file( fileName );
547 if (!file.open( IO_WriteOnly ) ) { 547 if (!file.open( QIODevice::WriteOnly ) ) {
548 return false; 548 return false;
549 549
550 } 550 }
551 QTextStream ts( &file ); 551 Q3TextStream ts( &file );
552 ts.setCodec( QTextCodec::codecForName("utf8") ); 552 ts.setCodec( QTextCodec::codecForName("utf8") );
553 ts << changeString ; 553 ts << changeString ;
554 file.close(); 554 file.close();
555 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName; 555 command = "db2file datebook -w -g -c " + codec+ " < "+ fileName;
556 system ( command.latin1() ); 556 system ( command.latin1() );
557 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 557 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
558 558
559 } 559 }
560 status.setText ( i18n("Deleting events ...") ); 560 status.setText ( i18n("Deleting events ...") );
561 qApp->processEvents(); 561 qApp->processEvents();
562 //qDebug("deleting... "); 562 //qDebug("deleting... ");
563 if ( deleteEnt ) { 563 if ( deleteEnt ) {
564 QFile file( fileName ); 564 QFile file( fileName );
565 if (!file.open( IO_WriteOnly ) ) { 565 if (!file.open( QIODevice::WriteOnly ) ) {
566 return false; 566 return false;
567 567
568 } 568 }
569 QTextStream ts( &file ); 569 Q3TextStream ts( &file );
570 ts.setCodec( QTextCodec::codecForName("utf8") ); 570 ts.setCodec( QTextCodec::codecForName("utf8") );
571 ts << deleteString; 571 ts << deleteString;
572 file.close(); 572 file.close();
573 command = "db2file datebook -d -c " + codec+ " < "+ fileName; 573 command = "db2file datebook -d -c " + codec+ " < "+ fileName;
574 system ( command.latin1() ); 574 system ( command.latin1() );
575 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 575 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
576 } 576 }
577 577
578 578
579 changeString = tPrefix; 579 changeString = tPrefix;
580 deleteString = tPrefix; 580 deleteString = tPrefix;
581 status.setText ( i18n("Processing todos ...") ); 581 status.setText ( i18n("Processing todos ...") );
582 qApp->processEvents(); 582 qApp->processEvents();
583 QPtrList<Todo> tl = calendar->rawTodos(); 583 Q3PtrList<Todo> tl = calendar->rawTodos();
584 Todo* to = tl.first(); 584 Todo* to = tl.first();
585 i = 0; 585 i = 0;
586 message = i18n("Processing todo # "); 586 message = i18n("Processing todo # ");
587 procCount = 0; 587 procCount = 0;
588 while ( to ) { 588 while ( to ) {
589 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 589 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
590 status.setText ( message + QString::number ( ++procCount ) ); 590 status.setText ( message + QString::number ( ++procCount ) );
591 qApp->processEvents(); 591 qApp->processEvents();
592 QString eString = getTodoString( to ); 592 QString eString = getTodoString( to );
593 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 593 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
594 // deleting empty strings does not work. 594 // deleting empty strings does not work.
595 // we write first and x and then delete the record with the x 595 // we write first and x and then delete the record with the x
596 eString = eString.replace( QRegExp(",\"\""),",\"x\"" ); 596 eString = eString.replace( QRegExp(",\"\""),",\"x\"" );
597 changeString += eString + "\n"; 597 changeString += eString + "\n";
598 deleteString += eString + "\n"; 598 deleteString += eString + "\n";
599 deleteEnt = true; 599 deleteEnt = true;
600 changeEnt = true; 600 changeEnt = true;
601 } 601 }
602 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 602 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new
603 603
604 604
605 605
606 QString fileNameIn = "/tmp/kopitempin"; 606 QString fileNameIn = "/tmp/kopitempin";
607 QFile fileIn( fileNameIn ); 607 QFile fileIn( fileNameIn );
608 if (!fileIn.open( IO_WriteOnly ) ) { 608 if (!fileIn.open( QIODevice::WriteOnly ) ) {
609 return false; 609 return false;
610 } 610 }
611 QTextStream tsIn( &fileIn ); 611 Q3TextStream tsIn( &fileIn );
612 tsIn.setCodec( QTextCodec::codecForName("utf8") ); 612 tsIn.setCodec( QTextCodec::codecForName("utf8") );
613 tsIn << tPrefix << eString ; 613 tsIn << tPrefix << eString ;
614 fileIn.close(); 614 fileIn.close();
615 command = "(cat /tmp/kopitempin | db2file todo -w -g -c " + codec+ ") > "+ fileName; 615 command = "(cat /tmp/kopitempin | db2file todo -w -g -c " + codec+ ") > "+ fileName;
616 system ( command.utf8() ); 616 system ( command.utf8() );
617 QFile file( fileName ); 617 QFile file( fileName );
618 if (!file.open( IO_ReadOnly ) ) { 618 if (!file.open( QIODevice::ReadOnly ) ) {
619 return false; 619 return false;
620 } 620 }
621 QTextStream ts( &file ); 621 Q3TextStream ts( &file );
622 ts.setCodec( QTextCodec::codecForName("utf8") ); 622 ts.setCodec( QTextCodec::codecForName("utf8") );
623 answer = ts.read(); 623 answer = ts.read();
624 file.close(); 624 file.close();
625 //qDebug("answer \n%s ", answer.latin1()); 625 //qDebug("answer \n%s ", answer.latin1());
626 getNumFromRecord( answer, to ) ; 626 getNumFromRecord( answer, to ) ;
627 627
628 } 628 }
629 else { // change existing 629 else { // change existing
630 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() ); 630 //qDebug("canging %d %d",to->zaurusStat() ,to->zaurusId() );
631 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName; 631 //command = "(echo \"" + ePrefix + eString + "\" ) | db2file datebook -w -g -c " + codec+ " > "+ fileName;
632 changeString += eString + "\n"; 632 changeString += eString + "\n";
633 changeEnt = true; 633 changeEnt = true;
634 634
635 } 635 }
636 } 636 }
637 637
638 to = tl.next(); 638 to = tl.next();
639 } 639 }
640 status.setText ( i18n("Changing todos ...") ); 640 status.setText ( i18n("Changing todos ...") );
641 qApp->processEvents(); 641 qApp->processEvents();
642 //qDebug("changing... "); 642 //qDebug("changing... ");
643 if ( changeEnt ) { 643 if ( changeEnt ) {
644 QFile file( fileName ); 644 QFile file( fileName );
645 if (!file.open( IO_WriteOnly ) ) { 645 if (!file.open( QIODevice::WriteOnly ) ) {
646 return false; 646 return false;
647 647
648 } 648 }
649 QTextStream ts( &file ); 649 Q3TextStream ts( &file );
650 ts.setCodec( QTextCodec::codecForName("utf8") ); 650 ts.setCodec( QTextCodec::codecForName("utf8") );
651 ts << changeString ; 651 ts << changeString ;
652 file.close(); 652 file.close();
653 command = "db2file todo -w -g -c " + codec+ " < "+ fileName; 653 command = "db2file todo -w -g -c " + codec+ " < "+ fileName;
654 system ( command.latin1() ); 654 system ( command.latin1() );
655 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1()); 655 //qDebug("command %s file :\n%s ", command.latin1(), changeString.latin1());
656 656
657 } 657 }
658 status.setText ( i18n("Deleting todos ...") ); 658 status.setText ( i18n("Deleting todos ...") );
659 qApp->processEvents(); 659 qApp->processEvents();
660 //qDebug("deleting... "); 660 //qDebug("deleting... ");
661 if ( deleteEnt ) { 661 if ( deleteEnt ) {
662 QFile file( fileName ); 662 QFile file( fileName );
663 if (!file.open( IO_WriteOnly ) ) { 663 if (!file.open( QIODevice::WriteOnly ) ) {
664 return false; 664 return false;
665 665
666 } 666 }
667 QTextStream ts( &file ); 667 Q3TextStream ts( &file );
668 ts.setCodec( QTextCodec::codecForName("utf8") ); 668 ts.setCodec( QTextCodec::codecForName("utf8") );
669 ts << deleteString; 669 ts << deleteString;
670 file.close(); 670 file.close();
671 command = "db2file todo -d -c " + codec+ " < "+ fileName; 671 command = "db2file todo -d -c " + codec+ " < "+ fileName;
672 system ( command.latin1() ); 672 system ( command.latin1() );
673 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1()); 673 // qDebug("command %s file :\n%s ", command.latin1(), deleteString.latin1());
674 } 674 }
675 675
676 return true; 676 return true;
677} 677}
678QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ ) 678QString SharpFormat::dtToString( const QDateTime& dti, bool useTZ )
679{ 679{
@@ -774,25 +774,25 @@ QString SharpFormat::getEventString( Event* event )
774 } 774 }
775 //pending weekdays 775 //pending weekdays
776 writeEndDate = true; 776 writeEndDate = true;
777 777
778 break; 778 break;
779 case Recurrence::rMonthlyPos:// 2 779 case Recurrence::rMonthlyPos:// 2
780 list.append( "2" ); 780 list.append( "2" );
781 list.append( QString::number( rec->frequency()) );//12 781 list.append( QString::number( rec->frequency()) );//12
782 782
783 writeEndDate = true; 783 writeEndDate = true;
784 { 784 {
785 int count = 1; 785 int count = 1;
786 QPtrList<Recurrence::rMonthPos> rmp; 786 Q3PtrList<Recurrence::rMonthPos> rmp;
787 rmp = rec->monthPositions(); 787 rmp = rec->monthPositions();
788 if ( rmp.first()->negative ) 788 if ( rmp.first()->negative )
789 count = 5 - rmp.first()->rPos - 1; 789 count = 5 - rmp.first()->rPos - 1;
790 else 790 else
791 count = rmp.first()->rPos - 1; 791 count = rmp.first()->rPos - 1;
792 list.append( QString::number( count ) ); 792 list.append( QString::number( count ) );
793 793
794 } 794 }
795 795
796 list.append( "0" ); 796 list.append( "0" );
797 break; 797 break;
798 case Recurrence::rMonthlyDay:// 3 798 case Recurrence::rMonthlyDay:// 3
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index cc1c5ae..5a0c32e 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -614,25 +614,25 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_d
614 return QDateTime (); 614 return QDateTime ();
615 } 615 }
616 QDateTime incidenceStart; 616 QDateTime incidenceStart;
617 incidenceStart = dtDue(); 617 incidenceStart = dtDue();
618 bool enabled = false; 618 bool enabled = false;
619 Alarm* alarm; 619 Alarm* alarm;
620 int off = 0; 620 int off = 0;
621 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 621 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
622 // if ( QDateTime::currentDateTime() > incidenceStart ){ 622 // if ( QDateTime::currentDateTime() > incidenceStart ){
623// *ok = false; 623// *ok = false;
624// return incidenceStart; 624// return incidenceStart;
625// } 625// }
626 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 626 for (Q3PtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
627 if (alarm->enabled()) { 627 if (alarm->enabled()) {
628 if ( alarm->hasTime () ) { 628 if ( alarm->hasTime () ) {
629 if ( alarm->time() < alarmStart ) { 629 if ( alarm->time() < alarmStart ) {
630 alarmStart = alarm->time(); 630 alarmStart = alarm->time();
631 enabled = true; 631 enabled = true;
632 off = alarmStart.secsTo( incidenceStart ); 632 off = alarmStart.secsTo( incidenceStart );
633 } 633 }
634 634
635 } else { 635 } else {
636 int secs = alarm->startOffset().asSeconds(); 636 int secs = alarm->startOffset().asSeconds();
637 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 637 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
638 alarmStart = incidenceStart.addSecs( secs ); 638 alarmStart = incidenceStart.addSecs( secs );
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 2131732..cea976c 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -17,39 +17,41 @@
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#ifndef TODO_H 20#ifndef TODO_H
21#define TODO_H 21#define TODO_H
22// 22//
23// Todo component, representing a VTODO object 23// Todo component, representing a VTODO object
24// 24//
25 25
26#include "incidence.h" 26#include "incidence.h"
27 27
28#include <qtimer.h> 28#include <qtimer.h>
29//Added by qt3to4:
30#include <Q3CString>
29 31
30namespace KCal { 32namespace KCal {
31 33
32/** 34/**
33 This class provides a Todo in the sense of RFC2445. 35 This class provides a Todo in the sense of RFC2445.
34*/ 36*/
35 class Todo : public QObject,public Incidence 37 class Todo : public QObject,public Incidence
36{ 38{
37 Q_OBJECT 39 Q_OBJECT
38 public: 40 public:
39 Todo(); 41 Todo();
40 Todo(const Todo &); 42 Todo(const Todo &);
41 ~Todo(); 43 ~Todo();
42 typedef ListBase<Todo> List; 44 typedef ListBase<Todo> List;
43 QCString type() const { return "Todo"; } 45 Q3CString type() const { return "Todo"; }
44 IncTypeID typeID() const { return todoID; } 46 IncTypeID typeID() const { return todoID; }
45 47
46 /** Return an exact copy of this todo. */ 48 /** Return an exact copy of this todo. */
47 Incidence *clone(); 49 Incidence *clone();
48 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const; 50 QDateTime getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const;
49 51
50 /** for setting the todo's due date/time with a QDateTime. */ 52 /** for setting the todo's due date/time with a QDateTime. */
51 void setDtDue(const QDateTime &dtDue); 53 void setDtDue(const QDateTime &dtDue);
52 /** returns an event's Due date/time as a QDateTime. */ 54 /** returns an event's Due date/time as a QDateTime. */
53 QDateTime dtDue() const; 55 QDateTime dtDue() const;
54 /** returns an event's due time as a string formatted according to the 56 /** returns an event's due time as a string formatted according to the
55 users locale settings */ 57 users locale settings */
diff --git a/libkcal/vcaldrag.cpp b/libkcal/vcaldrag.cpp
index f01f332..324981e 100644
--- a/libkcal/vcaldrag.cpp
+++ b/libkcal/vcaldrag.cpp
@@ -17,25 +17,25 @@
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include "vcaldrag.h" 22#include "vcaldrag.h"
23 23
24#include "vcalformat.h" 24#include "vcalformat.h"
25 25
26using namespace KCal; 26using namespace KCal;
27 27
28VCalDrag::VCalDrag( Calendar *cal, QWidget *parent, const char *name ) 28VCalDrag::VCalDrag( Calendar *cal, QWidget *parent, const char *name )
29 : QStoredDrag( "text/x-vCalendar", parent, name ) 29 : Q3StoredDrag( "text/x-vCalendar", parent, name )
30{ 30{
31 VCalFormat format; 31 VCalFormat format;
32 setEncodedData( format.toString( cal ).utf8() ); 32 setEncodedData( format.toString( cal ).utf8() );
33} 33}
34 34
35bool VCalDrag::canDecode( QMimeSource *me ) 35bool VCalDrag::canDecode( QMimeSource *me )
36{ 36{
37 return me->provides( "text/x-vCalendar" ); 37 return me->provides( "text/x-vCalendar" );
38} 38}
39 39
40bool VCalDrag::decode( QMimeSource *de, Calendar *cal ) 40bool VCalDrag::decode( QMimeSource *de, Calendar *cal )
41{ 41{
diff --git a/libkcal/vcaldrag.h b/libkcal/vcaldrag.h
index 3048124..68a320d 100644
--- a/libkcal/vcaldrag.h
+++ b/libkcal/vcaldrag.h
@@ -13,33 +13,33 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef VCALDRAG_H 22#ifndef VCALDRAG_H
23#define VCALDRAG_H 23#define VCALDRAG_H
24 24
25#include <qdragobject.h> 25#include <q3dragobject.h>
26 26
27 27
28namespace KCal { 28namespace KCal {
29 29
30class Calendar; 30class Calendar;
31 31
32/** vCalendar drag&drop class. */ 32/** vCalendar drag&drop class. */
33class VCalDrag : public QStoredDrag { 33class VCalDrag : public Q3StoredDrag {
34 public: 34 public:
35 /** Create a drag&drop object for vCalendar component \a vcal. */ 35 /** Create a drag&drop object for vCalendar component \a vcal. */
36 VCalDrag( Calendar *vcal, QWidget *parent = 0, const char *name = 0 ); 36 VCalDrag( Calendar *vcal, QWidget *parent = 0, const char *name = 0 );
37 ~VCalDrag() {}; 37 ~VCalDrag() {};
38 38
39 /** Return, if drag&drop object can be decode to vCalendar. */ 39 /** Return, if drag&drop object can be decode to vCalendar. */
40 static bool canDecode( QMimeSource * ); 40 static bool canDecode( QMimeSource * );
41 /** Decode drag&drop object to vCalendar component \a vcal. */ 41 /** Decode drag&drop object to vCalendar component \a vcal. */
42 static bool decode( QMimeSource *e, Calendar *cal ); 42 static bool decode( QMimeSource *e, Calendar *cal );
43}; 43};
44 44
45} 45}
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 2e19740..9cbaf16 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -13,29 +13,31 @@
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qfile.h> 29#include <qfile.h>
30//Added by qt3to4:
31#include <Q3CString>
30 32
31#include <kdebug.h> 33#include <kdebug.h>
32#include <kglobal.h> 34#include <kglobal.h>
33#include <kmessagebox.h> 35#include <kmessagebox.h>
34#include <kiconloader.h> 36#include <kiconloader.h>
35#include <klocale.h> 37#include <klocale.h>
36 38
37#include "vcc.h" 39#include "vcc.h"
38#include "vobject.h" 40#include "vobject.h"
39 41
40#include "vcaldrag.h" 42#include "vcaldrag.h"
41#include "calendar.h" 43#include "calendar.h"
@@ -99,55 +101,55 @@ bool VCalFormat::save(Calendar *calendar, const QString &fileName)
99 101
100 102
101 vcal = newVObject(VCCalProp); 103 vcal = newVObject(VCCalProp);
102 104
103 // addPropValue(vcal,VCLocationProp, "0.0"); 105 // addPropValue(vcal,VCLocationProp, "0.0");
104 addPropValue(vcal,VCProdIdProp, productId()); 106 addPropValue(vcal,VCProdIdProp, productId());
105 tmpStr = mCalendar->getTimeZoneStr(); 107 tmpStr = mCalendar->getTimeZoneStr();
106 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 108 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
107 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 109 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
108 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 110 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
109 111
110 // TODO STUFF 112 // TODO STUFF
111 QPtrList<Todo> todoList = mCalendar->rawTodos(); 113 Q3PtrList<Todo> todoList = mCalendar->rawTodos();
112 QPtrListIterator<Todo> qlt(todoList); 114 Q3PtrListIterator<Todo> qlt(todoList);
113 for (; qlt.current(); ++qlt) { 115 for (; qlt.current(); ++qlt) {
114 vo = eventToVTodo(qlt.current()); 116 vo = eventToVTodo(qlt.current());
115 addVObjectProp(vcal, vo); 117 addVObjectProp(vcal, vo);
116 } 118 }
117 119
118 // EVENT STUFF 120 // EVENT STUFF
119 QPtrList<Event> events = mCalendar->rawEvents(); 121 Q3PtrList<Event> events = mCalendar->rawEvents();
120 Event *ev; 122 Event *ev;
121 for(ev=events.first();ev;ev=events.next()) { 123 for(ev=events.first();ev;ev=events.next()) {
122 vo = eventToVEvent(ev); 124 vo = eventToVEvent(ev);
123 addVObjectProp(vcal, vo); 125 addVObjectProp(vcal, vo);
124 } 126 }
125 127
126 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); 128 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal);
127 cleanVObjects(vcal); 129 cleanVObjects(vcal);
128 cleanStrTbl(); 130 cleanStrTbl();
129 131
130 if (QFile::exists(fileName)) { 132 if (QFile::exists(fileName)) {
131 return true; 133 return true;
132 } else { 134 } else {
133 return false; // error 135 return false; // error
134 } 136 }
135} 137}
136 138
137bool VCalFormat::fromString( Calendar *calendar, const QString &text ) 139bool VCalFormat::fromString( Calendar *calendar, const QString &text )
138{ 140{
139 // TODO: Factor out VCalFormat::fromString() 141 // TODO: Factor out VCalFormat::fromString()
140 142
141 QCString data = text.utf8(); 143 Q3CString data = text.utf8();
142 144
143 if ( !data.size() ) return false; 145 if ( !data.size() ) return false;
144 146
145 VObject *vcal = Parse_MIME( data.data(), data.size()); 147 VObject *vcal = Parse_MIME( data.data(), data.size());
146 if ( !vcal ) return false; 148 if ( !vcal ) return false;
147 149
148 VObjectIterator i; 150 VObjectIterator i;
149 VObject *curvo; 151 VObject *curvo;
150 initPropIterator( &i, vcal ); 152 initPropIterator( &i, vcal );
151 153
152 // we only take the first object. TODO: parse all incidences. 154 // we only take the first object. TODO: parse all incidences.
153 do { 155 do {
@@ -201,25 +203,25 @@ QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal
201QString VCalFormat::toString( Calendar *calendar ) 203QString VCalFormat::toString( Calendar *calendar )
202{ 204{
203 // TODO: Factor out VCalFormat::asString() 205 // TODO: Factor out VCalFormat::asString()
204 206
205 VObject *vcal = newVObject(VCCalProp); 207 VObject *vcal = newVObject(VCCalProp);
206 208
207 addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); 209 addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
208 QString tmpStr = mCalendar->getTimeZoneStr(); 210 QString tmpStr = mCalendar->getTimeZoneStr();
209 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); 211 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() );
210 addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); 212 addPropValue( vcal, VCVersionProp, _VCAL_VERSION );
211 213
212 // TODO: Use all data. 214 // TODO: Use all data.
213 QPtrList<Event> events = calendar->events(); 215 Q3PtrList<Event> events = calendar->events();
214 Event *event = events.first(); 216 Event *event = events.first();
215 if ( !event ) return QString::null; 217 if ( !event ) return QString::null;
216 218
217 VObject *vevent = eventToVEvent( event ); 219 VObject *vevent = eventToVEvent( event );
218 220
219 addVObjectProp( vcal, vevent ); 221 addVObjectProp( vcal, vevent );
220 222
221 char *buf = writeMemVObject( 0, 0, vcal ); 223 char *buf = writeMemVObject( 0, 0, vcal );
222 224
223 QString result( buf ); 225 QString result( buf );
224 226
225 cleanVObject( vcal ); 227 cleanVObject( vcal );
@@ -262,26 +264,26 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
262 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); 264 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit());
263 265
264 // last modification date 266 // last modification date
265 tmpStr = qDateTimeToISO(anEvent->lastModified()); 267 tmpStr = qDateTimeToISO(anEvent->lastModified());
266 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); 268 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
267 269
268 // organizer stuff 270 // organizer stuff
269 tmpStr = "MAILTO:" + anEvent->organizer(); 271 tmpStr = "MAILTO:" + anEvent->organizer();
270 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); 272 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
271 273
272 // attendees 274 // attendees
273 if (anEvent->attendeeCount() != 0) { 275 if (anEvent->attendeeCount() != 0) {
274 QPtrList<Attendee> al = anEvent->attendees(); 276 Q3PtrList<Attendee> al = anEvent->attendees();
275 QPtrListIterator<Attendee> ai(al); 277 Q3PtrListIterator<Attendee> ai(al);
276 Attendee *curAttendee; 278 Attendee *curAttendee;
277 279
278 for (; ai.current(); ++ai) { 280 for (; ai.current(); ++ai) {
279 curAttendee = ai.current(); 281 curAttendee = ai.current();
280 if (!curAttendee->email().isEmpty() && 282 if (!curAttendee->email().isEmpty() &&
281 !curAttendee->name().isEmpty()) 283 !curAttendee->name().isEmpty())
282 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 284 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
283 curAttendee->email() + ">"; 285 curAttendee->email() + ">";
284 else if (curAttendee->name().isEmpty()) 286 else if (curAttendee->name().isEmpty())
285 tmpStr = "MAILTO: " + curAttendee->email(); 287 tmpStr = "MAILTO: " + curAttendee->email();
286 else if (curAttendee->email().isEmpty()) 288 else if (curAttendee->email().isEmpty())
287 tmpStr = "MAILTO: " + curAttendee->name(); 289 tmpStr = "MAILTO: " + curAttendee->name();
@@ -317,25 +319,25 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
317 "NEEDS_ACTION"); 319 "NEEDS_ACTION");
318 // completion date 320 // completion date
319 if (anEvent->hasCompletedDate()) { 321 if (anEvent->hasCompletedDate()) {
320 tmpStr = qDateTimeToISO(anEvent->completed()); 322 tmpStr = qDateTimeToISO(anEvent->completed());
321 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); 323 addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit());
322 } 324 }
323 325
324 // priority 326 // priority
325 tmpStr.sprintf("%i",anEvent->priority()); 327 tmpStr.sprintf("%i",anEvent->priority());
326 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); 328 addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit());
327 329
328 // related event 330 // related event
329 if (anEvent->relatedToUid()) { 331 if (!anEvent->relatedToUid().isEmpty()) {
330 addPropValue(vtodo, VCRelatedToProp, 332 addPropValue(vtodo, VCRelatedToProp,
331 anEvent->relatedToUid().local8Bit()); 333 anEvent->relatedToUid().local8Bit());
332 } 334 }
333 335
334 // categories 336 // categories
335 QStringList tmpStrList = anEvent->categories(); 337 QStringList tmpStrList = anEvent->categories();
336 tmpStr = ""; 338 tmpStr = "";
337 QString catStr; 339 QString catStr;
338 for ( QStringList::Iterator it = tmpStrList.begin(); 340 for ( QStringList::Iterator it = tmpStrList.begin();
339 it != tmpStrList.end(); 341 it != tmpStrList.end();
340 ++it ) { 342 ++it ) {
341 catStr = *it; 343 catStr = *it;
@@ -346,25 +348,25 @@ VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
346 // this must be a ';' character as the vCalendar specification requires! 348 // this must be a ';' character as the vCalendar specification requires!
347 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 349 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
348 // read in. 350 // read in.
349 tmpStr += ";"; 351 tmpStr += ";";
350 } 352 }
351 if (!tmpStr.isEmpty()) { 353 if (!tmpStr.isEmpty()) {
352 tmpStr.truncate(tmpStr.length()-1); 354 tmpStr.truncate(tmpStr.length()-1);
353 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); 355 addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit());
354 } 356 }
355 357
356 // alarm stuff 358 // alarm stuff
357 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; 359 kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl;
358 QPtrList<Alarm> alarms = anEvent->alarms(); 360 Q3PtrList<Alarm> alarms = anEvent->alarms();
359 Alarm* alarm; 361 Alarm* alarm;
360 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 362 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
361 if (alarm->enabled()) { 363 if (alarm->enabled()) {
362 VObject *a; 364 VObject *a;
363 tmpStr = qDateTimeToISO(alarm->time()); 365 tmpStr = qDateTimeToISO(alarm->time());
364 if (alarm->type() == Alarm::Audio) { 366 if (alarm->type() == Alarm::Audio) {
365 a = addProp(vtodo, VCAAlarmProp); 367 a = addProp(vtodo, VCAAlarmProp);
366 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 368 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
367 addPropValue(a, VCRepeatCountProp, "1"); 369 addPropValue(a, VCRepeatCountProp, "1");
368 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 370 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
369 } 371 }
370 else if (alarm->type() == Alarm::Procedure) { 372 else if (alarm->type() == Alarm::Procedure) {
@@ -424,26 +426,26 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
424 tmpStr.sprintf("%i", anEvent->revision()); 426 tmpStr.sprintf("%i", anEvent->revision());
425 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); 427 addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit());
426 428
427 // last modification date 429 // last modification date
428 tmpStr = qDateTimeToISO(anEvent->lastModified()); 430 tmpStr = qDateTimeToISO(anEvent->lastModified());
429 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); 431 addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit());
430 432
431 // attendee and organizer stuff 433 // attendee and organizer stuff
432 tmpStr = "MAILTO:" + anEvent->organizer(); 434 tmpStr = "MAILTO:" + anEvent->organizer();
433 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); 435 addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit());
434 436
435 if (anEvent->attendeeCount() != 0) { 437 if (anEvent->attendeeCount() != 0) {
436 QPtrList<Attendee> al = anEvent->attendees(); 438 Q3PtrList<Attendee> al = anEvent->attendees();
437 QPtrListIterator<Attendee> ai(al); 439 Q3PtrListIterator<Attendee> ai(al);
438 Attendee *curAttendee; 440 Attendee *curAttendee;
439 441
440 // TODO: Put this functionality into Attendee class 442 // TODO: Put this functionality into Attendee class
441 for (; ai.current(); ++ai) { 443 for (; ai.current(); ++ai) {
442 curAttendee = ai.current(); 444 curAttendee = ai.current();
443 if (!curAttendee->email().isEmpty() && 445 if (!curAttendee->email().isEmpty() &&
444 !curAttendee->name().isEmpty()) 446 !curAttendee->name().isEmpty())
445 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 447 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
446 curAttendee->email() + ">"; 448 curAttendee->email() + ">";
447 else if (curAttendee->name().isEmpty()) 449 else if (curAttendee->name().isEmpty())
448 tmpStr = "MAILTO: " + curAttendee->email(); 450 tmpStr = "MAILTO: " + curAttendee->email();
449 else if (curAttendee->email().isEmpty()) 451 else if (curAttendee->email().isEmpty())
@@ -452,26 +454,26 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
452 curAttendee->email().isEmpty()) 454 curAttendee->email().isEmpty())
453 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; 455 kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl;
454 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); 456 VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit());
455 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role())); 457 addPropValue(aProp, VCRoleProp, writeRole(curAttendee->role()));
456 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); 458 addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");
457 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); 459 addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status()));
458 } 460 }
459 } 461 }
460 462
461 // recurrence rule stuff 463 // recurrence rule stuff
462 if (anEvent->doesRecur()) { 464 if (anEvent->doesRecur()) {
463 // some more variables 465 // some more variables
464 QPtrList<Recurrence::rMonthPos> tmpPositions; 466 Q3PtrList<Recurrence::rMonthPos> tmpPositions;
465 QPtrList<int> tmpDays; 467 Q3PtrList<int> tmpDays;
466 int *tmpDay; 468 int *tmpDay;
467 Recurrence::rMonthPos *tmpPos; 469 Recurrence::rMonthPos *tmpPos;
468 QString tmpStr2; 470 QString tmpStr2;
469 int i; 471 int i;
470 472
471 switch(anEvent->recurrence()->doesRecur()) { 473 switch(anEvent->recurrence()->doesRecur()) {
472 case Recurrence::rDaily: 474 case Recurrence::rDaily:
473 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); 475 tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency());
474// if (anEvent->rDuration > 0) 476// if (anEvent->rDuration > 0)
475 //tmpStr += "#"; 477 //tmpStr += "#";
476 break; 478 break;
477 case Recurrence::rWeekly: 479 case Recurrence::rWeekly:
@@ -536,25 +538,25 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
536 break; 538 break;
537 default: 539 default:
538 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; 540 kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl;
539 break; 541 break;
540 } // switch 542 } // switch
541 543
542 if (anEvent->recurrence()->duration() > 0) { 544 if (anEvent->recurrence()->duration() > 0) {
543 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); 545 tmpStr2.sprintf("#%i",anEvent->recurrence()->duration());
544 tmpStr += tmpStr2; 546 tmpStr += tmpStr2;
545 } else if (anEvent->recurrence()->duration() == -1) { 547 } else if (anEvent->recurrence()->duration() == -1) {
546 tmpStr += "#0"; // defined as repeat forever 548 tmpStr += "#0"; // defined as repeat forever
547 } else { 549 } else {
548 tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); 550 tmpStr += qDateTimeToISO((QDateTime)anEvent->recurrence()->endDate(), FALSE);
549 } 551 }
550 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); 552 addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit());
551 553
552 } // event repeats 554 } // event repeats
553 555
554 // exceptions to recurrence 556 // exceptions to recurrence
555 DateList dateList = anEvent->exDates(); 557 DateList dateList = anEvent->exDates();
556 DateList::ConstIterator it; 558 DateList::ConstIterator it;
557 QString tmpStr2; 559 QString tmpStr2;
558 560
559 for (it = dateList.begin(); it != dateList.end(); ++it) { 561 for (it = dateList.begin(); it != dateList.end(); ++it) {
560 tmpStr = qDateToISO(*it) + ";"; 562 tmpStr = qDateToISO(*it) + ";";
@@ -616,36 +618,36 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
616 // this must be a ';' character as the vCalendar specification requires! 618 // this must be a ';' character as the vCalendar specification requires!
617 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is 619 // vcc.y has been hacked to translate the ';' to a ',' when the vcal is
618 // read in. 620 // read in.
619 tmpStr += ";"; 621 tmpStr += ";";
620 } 622 }
621 if (!tmpStr.isEmpty()) { 623 if (!tmpStr.isEmpty()) {
622 tmpStr.truncate(tmpStr.length()-1); 624 tmpStr.truncate(tmpStr.length()-1);
623 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); 625 addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit());
624 } 626 }
625 627
626 // attachments 628 // attachments
627 // TODO: handle binary attachments! 629 // TODO: handle binary attachments!
628 QPtrList<Attachment> attachments = anEvent->attachments(); 630 Q3PtrList<Attachment> attachments = anEvent->attachments();
629 for ( Attachment *at = attachments.first(); at; at = attachments.next() ) 631 for ( Attachment *at = attachments.first(); at; at = attachments.next() )
630 addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); 632 addPropValue(vevent, VCAttachProp, at->uri().local8Bit());
631 633
632 // resources 634 // resources
633 tmpStrList = anEvent->resources(); 635 tmpStrList = anEvent->resources();
634 tmpStr = tmpStrList.join(";"); 636 tmpStr = tmpStrList.join(";");
635 if (!tmpStr.isEmpty()) 637 if (!tmpStr.isEmpty())
636 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); 638 addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit());
637 639
638 // alarm stuff 640 // alarm stuff
639 QPtrList<Alarm> alarms = anEvent->alarms(); 641 Q3PtrList<Alarm> alarms = anEvent->alarms();
640 Alarm* alarm; 642 Alarm* alarm;
641 for (alarm = alarms.first(); alarm; alarm = alarms.next()) { 643 for (alarm = alarms.first(); alarm; alarm = alarms.next()) {
642 if (alarm->enabled()) { 644 if (alarm->enabled()) {
643 VObject *a ; 645 VObject *a ;
644 tmpStr = qDateTimeToISO(alarm->time()); 646 tmpStr = qDateTimeToISO(alarm->time());
645 if (alarm->type() == Alarm::Audio) { 647 if (alarm->type() == Alarm::Audio) {
646 a = addProp(vevent, VCAAlarmProp); 648 a = addProp(vevent, VCAAlarmProp);
647 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); 649 addPropValue(a, VCRunTimeProp, tmpStr.local8Bit());
648 addPropValue(a, VCRepeatCountProp, "1"); 650 addPropValue(a, VCRepeatCountProp, "1");
649 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); 651 addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile()));
650 } 652 }
651 if (alarm->type() == Alarm::Procedure) { 653 if (alarm->type() == Alarm::Procedure) {
@@ -663,25 +665,25 @@ VObject* VCalFormat::eventToVEvent(Event *anEvent)
663 } 665 }
664 } 666 }
665 667
666 // priority 668 // priority
667 tmpStr.sprintf("%i",anEvent->priority()); 669 tmpStr.sprintf("%i",anEvent->priority());
668 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); 670 addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit());
669 671
670 // transparency 672 // transparency
671 tmpStr.sprintf("%i",anEvent->transparency()); 673 tmpStr.sprintf("%i",anEvent->transparency());
672 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); 674 addPropValue(vevent, VCTranspProp, tmpStr.local8Bit());
673 675
674 // related event 676 // related event
675 if (anEvent->relatedToUid()) { 677 if (!anEvent->relatedToUid().isEmpty()) {
676 addPropValue(vevent, VCRelatedToProp, 678 addPropValue(vevent, VCRelatedToProp,
677 anEvent->relatedToUid().local8Bit()); 679 anEvent->relatedToUid().local8Bit());
678 } 680 }
679 681
680 if (anEvent->pilotId()) { 682 if (anEvent->pilotId()) {
681 // pilot sync stuff 683 // pilot sync stuff
682 tmpStr.sprintf("%i",anEvent->pilotId()); 684 tmpStr.sprintf("%i",anEvent->pilotId());
683 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); 685 addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit());
684 tmpStr.sprintf("%i",anEvent->syncStatus()); 686 tmpStr.sprintf("%i",anEvent->syncStatus());
685 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); 687 addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit());
686 } 688 }
687 689
@@ -1399,38 +1401,38 @@ Event* VCalFormat::VEventToEvent(VObject *vevent)
1399 } 1401 }
1400 else 1402 else
1401 anEvent->setSyncStatus(Event::SYNCMOD); 1403 anEvent->setSyncStatus(Event::SYNCMOD);
1402 1404
1403 return anEvent; 1405 return anEvent;
1404} 1406}
1405 1407
1406 1408
1407QString VCalFormat::qDateToISO(const QDate &qd) 1409QString VCalFormat::qDateToISO(const QDate &qd)
1408{ 1410{
1409 QString tmpStr; 1411 QString tmpStr;
1410 1412
1411 ASSERT(qd.isValid()); 1413 Q_ASSERT(qd.isValid());
1412 1414
1413 tmpStr.sprintf("%.2d%.2d%.2d", 1415 tmpStr.sprintf("%.2d%.2d%.2d",
1414 qd.year(), qd.month(), qd.day()); 1416 qd.year(), qd.month(), qd.day());
1415 return tmpStr; 1417 return tmpStr;
1416 1418
1417} 1419}
1418 1420
1419QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) 1421QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu)
1420{ 1422{
1421 QString tmpStr; 1423 QString tmpStr;
1422 1424
1423 ASSERT(qdt.date().isValid()); 1425 Q_ASSERT(qdt.date().isValid());
1424 ASSERT(qdt.time().isValid()); 1426 Q_ASSERT(qdt.time().isValid());
1425 if (zulu && !useLocalTime ) { 1427 if (zulu && !useLocalTime ) {
1426 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); 1428 QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60);
1427 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", 1429 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ",
1428 tmpDT.date().year(), tmpDT.date().month(), 1430 tmpDT.date().year(), tmpDT.date().month(),
1429 tmpDT.date().day(), tmpDT.time().hour(), 1431 tmpDT.date().day(), tmpDT.time().hour(),
1430 tmpDT.time().minute(), tmpDT.time().second()); 1432 tmpDT.time().minute(), tmpDT.time().second());
1431 } else { 1433 } else {
1432 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", 1434 tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d",
1433 qdt.date().year(), qdt.date().month(), 1435 qdt.date().year(), qdt.date().month(),
1434 qdt.date().day(), qdt.time().hour(), 1436 qdt.date().day(), qdt.time().hour(),
1435 qdt.time().minute(), qdt.time().second()); 1437 qdt.time().minute(), qdt.time().second());
1436 } 1438 }
@@ -1445,26 +1447,26 @@ QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr)
1445 int year, month, day, hour, minute, second; 1447 int year, month, day, hour, minute, second;
1446 1448
1447 tmpStr = dtStr; 1449 tmpStr = dtStr;
1448 year = tmpStr.left(4).toInt(); 1450 year = tmpStr.left(4).toInt();
1449 month = tmpStr.mid(4,2).toInt(); 1451 month = tmpStr.mid(4,2).toInt();
1450 day = tmpStr.mid(6,2).toInt(); 1452 day = tmpStr.mid(6,2).toInt();
1451 hour = tmpStr.mid(9,2).toInt(); 1453 hour = tmpStr.mid(9,2).toInt();
1452 minute = tmpStr.mid(11,2).toInt(); 1454 minute = tmpStr.mid(11,2).toInt();
1453 second = tmpStr.mid(13,2).toInt(); 1455 second = tmpStr.mid(13,2).toInt();
1454 tmpDate.setYMD(year, month, day); 1456 tmpDate.setYMD(year, month, day);
1455 tmpTime.setHMS(hour, minute, second); 1457 tmpTime.setHMS(hour, minute, second);
1456 1458
1457 ASSERT(tmpDate.isValid()); 1459 Q_ASSERT(tmpDate.isValid());
1458 ASSERT(tmpTime.isValid()); 1460 Q_ASSERT(tmpTime.isValid());
1459 QDateTime tmpDT(tmpDate, tmpTime); 1461 QDateTime tmpDT(tmpDate, tmpTime);
1460 // correct for GMT if string is in Zulu format 1462 // correct for GMT if string is in Zulu format
1461 if (dtStr.at(dtStr.length()-1) == 'Z') 1463 if (dtStr.at(dtStr.length()-1) == 'Z')
1462 tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60); 1464 tmpDT = tmpDT.addSecs (KGlobal::locale()->localTimeOffset( tmpDT )*60);
1463 return tmpDT; 1465 return tmpDT;
1464} 1466}
1465 1467
1466QDate VCalFormat::ISOToQDate(const QString &dateStr) 1468QDate VCalFormat::ISOToQDate(const QString &dateStr)
1467{ 1469{
1468 int year, month, day; 1470 int year, month, day;
1469 1471
1470 year = dateStr.left(4).toInt(); 1472 year = dateStr.left(4).toInt();
@@ -1639,25 +1641,25 @@ Attendee::Role VCalFormat::readRole(const char *s) const
1639{ 1641{
1640 QString statStr = s; 1642 QString statStr = s;
1641 statStr = statStr.upper(); 1643 statStr = statStr.upper();
1642 Attendee::Role role = Attendee::ReqParticipant; 1644 Attendee::Role role = Attendee::ReqParticipant;
1643 1645
1644 if ( statStr == "OWNER") 1646 if ( statStr == "OWNER")
1645 role = Attendee::Chair; 1647 role = Attendee::Chair;
1646 // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair }; 1648 // enum Role { ReqParticipant, OptParticipant, NonParticipant, Chair };
1647 1649
1648 return role; 1650 return role;
1649} 1651}
1650 1652
1651QCString VCalFormat::writeRole(Attendee::Role role) const 1653Q3CString VCalFormat::writeRole(Attendee::Role role) const
1652{ 1654{
1653 if ( role == Attendee::Chair ) 1655 if ( role == Attendee::Chair )
1654 return "OWNER"; 1656 return "OWNER";
1655 return "ATTENDEE"; 1657 return "ATTENDEE";
1656} 1658}
1657Attendee::PartStat VCalFormat::readStatus(const char *s) const 1659Attendee::PartStat VCalFormat::readStatus(const char *s) const
1658{ 1660{
1659 QString statStr = s; 1661 QString statStr = s;
1660 statStr = statStr.upper(); 1662 statStr = statStr.upper();
1661 Attendee::PartStat status; 1663 Attendee::PartStat status;
1662 1664
1663 if (statStr == "X-ACTION") 1665 if (statStr == "X-ACTION")
@@ -1677,25 +1679,25 @@ Attendee::PartStat VCalFormat::readStatus(const char *s) const
1677 else if (statStr== "COMPLETED") 1679 else if (statStr== "COMPLETED")
1678 status = Attendee::Completed; 1680 status = Attendee::Completed;
1679 else if (statStr== "DELEGATED") 1681 else if (statStr== "DELEGATED")
1680 status = Attendee::Delegated; 1682 status = Attendee::Delegated;
1681 else { 1683 else {
1682 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; 1684 kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl;
1683 status = Attendee::NeedsAction; 1685 status = Attendee::NeedsAction;
1684 } 1686 }
1685 1687
1686 return status; 1688 return status;
1687} 1689}
1688 1690
1689QCString VCalFormat::writeStatus(Attendee::PartStat status) const 1691Q3CString VCalFormat::writeStatus(Attendee::PartStat status) const
1690{ 1692{
1691 switch(status) { 1693 switch(status) {
1692 default: 1694 default:
1693 case Attendee::NeedsAction: 1695 case Attendee::NeedsAction:
1694 return "NEEDS ACTION"; 1696 return "NEEDS ACTION";
1695 break; 1697 break;
1696 case Attendee::Accepted: 1698 case Attendee::Accepted:
1697 return "ACCEPTED"; 1699 return "ACCEPTED";
1698 break; 1700 break;
1699 case Attendee::Declined: 1701 case Attendee::Declined:
1700 return "DECLINED"; 1702 return "DECLINED";
1701 break; 1703 break;
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index 6dae3d2..cac9634 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -14,24 +14,27 @@
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef _VCALFORMAT_H 22#ifndef _VCALFORMAT_H
23#define _VCALFORMAT_H 23#define _VCALFORMAT_H
24 24
25#include "calformat.h" 25#include "calformat.h"
26//Added by qt3to4:
27#include <Q3CString>
28#include <Q3PtrList>
26 29
27#define _VCAL_VERSION "1.0" 30#define _VCAL_VERSION "1.0"
28 31
29class VObject; 32class VObject;
30 33
31namespace KCal { 34namespace KCal {
32 35
33/** 36/**
34 This class implements the vCalendar format. It provides methods for 37 This class implements the vCalendar format. It provides methods for
35 loading/saving/converting vCalendar format data into the internal KOrganizer 38 loading/saving/converting vCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 39 representation as Calendar and Events.
37 40
@@ -86,28 +89,28 @@ class VCalFormat : public CalFormat {
86 /** takes a string in the format YYYYMMDD and returns a 89 /** takes a string in the format YYYYMMDD and returns a
87 * valid QDate. */ 90 * valid QDate. */
88 QDate ISOToQDate(const QString & dtStr); 91 QDate ISOToQDate(const QString & dtStr);
89 /** takes a vCalendar tree of VObjects, and puts all of them that have 92 /** 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. */ 93 * the "event" property into the dictionary, todos in the todo-list, etc. */
91 void populate(VObject *vcal); 94 void populate(VObject *vcal);
92 95
93 /** takes a number 0 - 6 and returns the two letter string of that day, 96 /** takes a number 0 - 6 and returns the two letter string of that day,
94 * i.e. MO, TU, WE, etc. */ 97 * i.e. MO, TU, WE, etc. */
95 const char *dayFromNum(int day); 98 const char *dayFromNum(int day);
96 /** the reverse of the above function. */ 99 /** the reverse of the above function. */
97 int numFromDay(const QString &day); 100 int numFromDay(const QString &day);
98 Attendee::Role VCalFormat::readRole(const char *s) const; 101 Attendee::Role readRole(const char *s) const;
99 QCString writeRole(Attendee::Role role) const; 102 Q3CString writeRole(Attendee::Role role) const;
100 Attendee::PartStat readStatus(const char *s) const; 103 Attendee::PartStat readStatus(const char *s) const;
101 QCString writeStatus(Attendee::PartStat status) const; 104 Q3CString writeStatus(Attendee::PartStat status) const;
102 105
103 private: 106 private:
104 Calendar *mCalendar; 107 Calendar *mCalendar;
105 bool useLocalTime; 108 bool useLocalTime;
106 109
107 QPtrList<Event> mEventsRelate; // events with relations 110 Q3PtrList<Event> mEventsRelate; // events with relations
108 QPtrList<Todo> mTodosRelate; // todos with relations 111 Q3PtrList<Todo> mTodosRelate; // todos with relations
109}; 112};
110 113
111} 114}
112 115
113#endif 116#endif