summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-06-15 18:23:08 (UTC)
committer zautrix <zautrix>2005-06-15 18:23:08 (UTC)
commitccfe3f97afd65c75ee6c7c931cb3694919a4e29b (patch) (unidiff)
tree117d3467ef1d9678f31dea1b506390707f88d94a /libkcal
parentcba0ac17d3d505805be6aa4b4fea6f63473a1e00 (diff)
downloadkdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.zip
kdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.tar.gz
kdepimpi-ccfe3f97afd65c75ee6c7c931cb3694919a4e29b.tar.bz2
fixess
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/calendarlocal.cpp10
-rw-r--r--libkcal/calendarlocal.h1
-rw-r--r--libkcal/incidencebase.cpp2
4 files changed, 14 insertions, 0 deletions
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 2243e28..3b7b183 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,174 +1,175 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
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#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 <qptrlist.h>
29#include <qdict.h> 29#include <qdict.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 {
42 42
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual void setSyncEventsReadOnly() = 0;
79 80
80 /** 81 /**
81 Sync changes in memory to persistant storage. 82 Sync changes in memory to persistant storage.
82 */ 83 */
83 virtual void save() = 0; 84 virtual void save() = 0;
84 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 85 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
85 virtual void removeSyncInfo( QString syncProfile) = 0; 86 virtual void removeSyncInfo( QString syncProfile) = 0;
86 virtual bool isSaving() { return false; } 87 virtual bool isSaving() { return false; }
87 88
88 /** 89 /**
89 Return the owner of the calendar's full name. 90 Return the owner of the calendar's full name.
90 */ 91 */
91 const QString &getOwner() const; 92 const QString &getOwner() const;
92 /** 93 /**
93 Set the owner of the calendar. Should be owner's full name. 94 Set the owner of the calendar. Should be owner's full name.
94 */ 95 */
95 void setOwner( const QString &os ); 96 void setOwner( const QString &os );
96 /** 97 /**
97 Return the email address of the calendar owner. 98 Return the email address of the calendar owner.
98 */ 99 */
99 const QString &getEmail(); 100 const QString &getEmail();
100 /** 101 /**
101 Set the email address of the calendar owner. 102 Set the email address of the calendar owner.
102 */ 103 */
103 void setEmail( const QString & ); 104 void setEmail( const QString & );
104 105
105 /** 106 /**
106 Set time zone from a timezone string (e.g. -2:00) 107 Set time zone from a timezone string (e.g. -2:00)
107 */ 108 */
108 void setTimeZone( const QString &tz ); 109 void setTimeZone( const QString &tz );
109 /** 110 /**
110 Set time zone from a minutes value (e.g. -60) 111 Set time zone from a minutes value (e.g. -60)
111 */ 112 */
112 void setTimeZone( int tz ); 113 void setTimeZone( int tz );
113 /** 114 /**
114 Return time zone as offest in minutes. 115 Return time zone as offest in minutes.
115 */ 116 */
116 int getTimeZone() const; 117 int getTimeZone() const;
117 /** 118 /**
118 Compute an ISO 8601 format string from the time zone. 119 Compute an ISO 8601 format string from the time zone.
119 */ 120 */
120 QString getTimeZoneStr() const; 121 QString getTimeZoneStr() const;
121 /** 122 /**
122 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 123 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
123 values). 124 values).
124 */ 125 */
125 void setTimeZoneId( const QString & ); 126 void setTimeZoneId( const QString & );
126 /** 127 /**
127 Return time zone id. 128 Return time zone id.
128 */ 129 */
129 QString timeZoneId() const; 130 QString timeZoneId() const;
130 /** 131 /**
131 Use local time, not UTC or a time zone. 132 Use local time, not UTC or a time zone.
132 */ 133 */
133 void setLocalTime(); 134 void setLocalTime();
134 /** 135 /**
135 Return whether local time is being used. 136 Return whether local time is being used.
136 */ 137 */
137 bool isLocalTime() const; 138 bool isLocalTime() const;
138 139
139 /** 140 /**
140 Add an incidence to calendar. 141 Add an incidence to calendar.
141 142
142 @return true on success, false on error. 143 @return true on success, false on error.
143 */ 144 */
144 virtual bool addIncidence( Incidence * ); 145 virtual bool addIncidence( Incidence * );
145 146
146 // Adds an incidence and all relatedto incidences to the cal 147 // Adds an incidence and all relatedto incidences to the cal
147 void addIncidenceBranch( Incidence * ); 148 void addIncidenceBranch( Incidence * );
148 /** 149 /**
149 Return filtered list of all incidences of this calendar. 150 Return filtered list of all incidences of this calendar.
150 */ 151 */
151 virtual QPtrList<Incidence> incidences(); 152 virtual QPtrList<Incidence> incidences();
152 153
153 /** 154 /**
154 Return unfiltered list of all incidences of this calendar. 155 Return unfiltered list of all incidences of this calendar.
155 */ 156 */
156 virtual QPtrList<Incidence> rawIncidences(); 157 virtual QPtrList<Incidence> rawIncidences();
157 158
158 /** 159 /**
159 Adds a Event to this calendar object. 160 Adds a Event to this calendar object.
160 @param anEvent a pointer to the event to add 161 @param anEvent a pointer to the event to add
161 162
162 @return true on success, false on error. 163 @return true on success, false on error.
163 */ 164 */
164 virtual bool addEventNoDup( Event *event ) = 0; 165 virtual bool addEventNoDup( Event *event ) = 0;
165 virtual bool addAnniversaryNoDup( Event *event ) = 0; 166 virtual bool addAnniversaryNoDup( Event *event ) = 0;
166 virtual bool addEvent( Event *anEvent ) = 0; 167 virtual bool addEvent( Event *anEvent ) = 0;
167 /** 168 /**
168 Delete event from calendar. 169 Delete event from calendar.
169 */ 170 */
170 virtual void deleteEvent( Event * ) = 0; 171 virtual void deleteEvent( Event * ) = 0;
171 /** 172 /**
172 Retrieves an event on the basis of the unique string ID. 173 Retrieves an event on the basis of the unique string ID.
173 */ 174 */
174 virtual Event *event( const QString &UniqueStr ) = 0; 175 virtual Event *event( const QString &UniqueStr ) = 0;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 336c3e8..8c4dde1 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -1,176 +1,186 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
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 <qptrlist.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"
38#include "filestorage.h" 38#include "filestorage.h"
39#include "calfilter.h" 39#include "calfilter.h"
40 40
41#include "calendarlocal.h" 41#include "calendarlocal.h"
42 42
43// #ifndef DESKTOP_VERSION 43// #ifndef DESKTOP_VERSION
44// #include <qtopia/alarmserver.h> 44// #include <qtopia/alarmserver.h>
45// #endif 45// #endif
46using namespace KCal; 46using namespace KCal;
47 47
48CalendarLocal::CalendarLocal() 48CalendarLocal::CalendarLocal()
49 : Calendar() 49 : Calendar()
50{ 50{
51 init(); 51 init();
52} 52}
53 53
54CalendarLocal::CalendarLocal(const QString &timeZoneId) 54CalendarLocal::CalendarLocal(const QString &timeZoneId)
55 : Calendar(timeZoneId) 55 : Calendar(timeZoneId)
56{ 56{
57 init(); 57 init();
58} 58}
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 if ( mDeleteIncidencesOnClose ) 68 if ( mDeleteIncidencesOnClose )
69 close(); 69 close();
70} 70}
71bool CalendarLocal::addCalendarFile( QString name, int id ) 71bool CalendarLocal::addCalendarFile( QString name, int id )
72{ 72{
73 CalendarLocal calendar( timeZoneId() ); 73 CalendarLocal calendar( timeZoneId() );
74 calendar.setDefaultCalendar( id ); 74 calendar.setDefaultCalendar( id );
75 if ( calendar.load( name ) ) { 75 if ( calendar.load( name ) ) {
76 addCalendar( &calendar ); 76 addCalendar( &calendar );
77 return true; 77 return true;
78 } 78 }
79 return false; 79 return false;
80} 80}
81void CalendarLocal::setSyncEventsReadOnly()
82{
83 Event * ev;
84 ev = mEventList.first();
85 while ( ev ) {
86 if ( ev->uid().left(15) == QString("last-syncEvent-") )
87 ev->setReadOnly( true );
88 ev = mEventList.next();
89 }
90}
81void CalendarLocal::addCalendar( Calendar* cal ) 91void CalendarLocal::addCalendar( Calendar* cal )
82{ 92{
83 cal->setDontDeleteIncidencesOnClose(); 93 cal->setDontDeleteIncidencesOnClose();
84 { 94 {
85 QPtrList<Event> EventList = cal->rawEvents(); 95 QPtrList<Event> EventList = cal->rawEvents();
86 Event * ev = EventList.first(); 96 Event * ev = EventList.first();
87 while ( ev ) { 97 while ( ev ) {
88 ev->unRegisterObserver( cal ); 98 ev->unRegisterObserver( cal );
89 ev->registerObserver( this ); 99 ev->registerObserver( this );
90 mEventList.append( ev ); 100 mEventList.append( ev );
91 ev = EventList.next(); 101 ev = EventList.next();
92 } 102 }
93 } 103 }
94 { 104 {
95 105
96 QPtrList<Todo> TodoList = cal->rawTodos(); 106 QPtrList<Todo> TodoList = cal->rawTodos();
97 Todo * ev = TodoList.first(); 107 Todo * ev = TodoList.first();
98 while ( ev ) { 108 while ( ev ) {
99 QString rel = ev->relatedToUid(); 109 QString rel = ev->relatedToUid();
100 if ( !rel.isEmpty() ){ 110 if ( !rel.isEmpty() ){
101 ev->setRelatedTo ( 0 ); 111 ev->setRelatedTo ( 0 );
102 ev->setRelatedToUid( rel ); 112 ev->setRelatedToUid( rel );
103 } 113 }
104 ev = TodoList.next(); 114 ev = TodoList.next();
105 } 115 }
106 //TodoList = cal->rawTodos(); 116 //TodoList = cal->rawTodos();
107 ev = TodoList.first(); 117 ev = TodoList.first();
108 while ( ev ) { 118 while ( ev ) {
109 ev->unRegisterObserver( cal ); 119 ev->unRegisterObserver( cal );
110 ev->registerObserver( this ); 120 ev->registerObserver( this );
111 mTodoList.append( ev ); 121 mTodoList.append( ev );
112 setupRelations( ev ); 122 setupRelations( ev );
113 ev = TodoList.next(); 123 ev = TodoList.next();
114 } 124 }
115 } 125 }
116 { 126 {
117 QPtrList<Journal> JournalList = cal->journals(); 127 QPtrList<Journal> JournalList = cal->journals();
118 Journal * ev = JournalList.first(); 128 Journal * ev = JournalList.first();
119 while ( ev ) { 129 while ( ev ) {
120 ev->unRegisterObserver( cal ); 130 ev->unRegisterObserver( cal );
121 ev->registerObserver( this ); 131 ev->registerObserver( this );
122 mJournalList.append( ev ); 132 mJournalList.append( ev );
123 ev = JournalList.next(); 133 ev = JournalList.next();
124 } 134 }
125 } 135 }
126 setModified( true ); 136 setModified( true );
127} 137}
128bool CalendarLocal::load( const QString &fileName ) 138bool CalendarLocal::load( const QString &fileName )
129{ 139{
130 FileStorage storage( this, fileName ); 140 FileStorage storage( this, fileName );
131 return storage.load(); 141 return storage.load();
132} 142}
133 143
134bool CalendarLocal::save( const QString &fileName, CalFormat *format ) 144bool CalendarLocal::save( const QString &fileName, CalFormat *format )
135{ 145{
136 FileStorage storage( this, fileName, format ); 146 FileStorage storage( this, fileName, format );
137 return storage.save(); 147 return storage.save();
138} 148}
139 149
140void CalendarLocal::close() 150void CalendarLocal::close()
141{ 151{
142 152
143 Todo * i; 153 Todo * i;
144 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false); 154 for( i = mTodoList.first(); i; i = mTodoList.next() ) i->setRunning(false);
145 155
146 mEventList.setAutoDelete( true ); 156 mEventList.setAutoDelete( true );
147 mTodoList.setAutoDelete( true ); 157 mTodoList.setAutoDelete( true );
148 mJournalList.setAutoDelete( false ); 158 mJournalList.setAutoDelete( false );
149 159
150 mEventList.clear(); 160 mEventList.clear();
151 mTodoList.clear(); 161 mTodoList.clear();
152 mJournalList.clear(); 162 mJournalList.clear();
153 163
154 mEventList.setAutoDelete( false ); 164 mEventList.setAutoDelete( false );
155 mTodoList.setAutoDelete( false ); 165 mTodoList.setAutoDelete( false );
156 mJournalList.setAutoDelete( false ); 166 mJournalList.setAutoDelete( false );
157 167
158 setModified( false ); 168 setModified( false );
159} 169}
160 170
161bool CalendarLocal::addAnniversaryNoDup( Event *event ) 171bool CalendarLocal::addAnniversaryNoDup( Event *event )
162{ 172{
163 QString cat; 173 QString cat;
164 bool isBirthday = true; 174 bool isBirthday = true;
165 if( event->categoriesStr() == i18n( "Anniversary" ) ) { 175 if( event->categoriesStr() == i18n( "Anniversary" ) ) {
166 isBirthday = false; 176 isBirthday = false;
167 cat = i18n( "Anniversary" ); 177 cat = i18n( "Anniversary" );
168 } else if( event->categoriesStr() == i18n( "Birthday" ) ) { 178 } else if( event->categoriesStr() == i18n( "Birthday" ) ) {
169 isBirthday = true; 179 isBirthday = true;
170 cat = i18n( "Birthday" ); 180 cat = i18n( "Birthday" );
171 } else { 181 } else {
172 qDebug("addAnniversaryNoDup called without fitting category! "); 182 qDebug("addAnniversaryNoDup called without fitting category! ");
173 return false; 183 return false;
174 } 184 }
175 Event * eve; 185 Event * eve;
176 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { 186 for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) {
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index 5bbe55f..0286b48 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -1,143 +1,144 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 3
4 Copyright (c) 1998 Preston Brown 4 Copyright (c) 1998 Preston Brown
5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org> 5 Copyright (c) 2001,2003 Cornelius Schumacher <schumacher@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
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#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 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 void setSyncEventsReadOnly();
48 /** 49 /**
49 Loads a calendar on disk in vCalendar or iCalendar format into the current 50 Loads a calendar on disk in vCalendar or iCalendar format into the current
50 calendar. Any information already present is lost. 51 calendar. Any information already present is lost.
51 @return true, if successfull, false on error. 52 @return true, if successfull, false on error.
52 @param fileName the name of the calendar on disk. 53 @param fileName the name of the calendar on disk.
53 */ 54 */
54 bool load( const QString &fileName ); 55 bool load( const QString &fileName );
55 /** 56 /**
56 Writes out the calendar to disk in the specified \a format. 57 Writes out the calendar to disk in the specified \a format.
57 CalendarLocal takes ownership of the CalFormat object. 58 CalendarLocal takes ownership of the CalFormat object.
58 @return true, if successfull, false on error. 59 @return true, if successfull, false on error.
59 @param fileName the name of the file 60 @param fileName the name of the file
60 */ 61 */
61 bool save( const QString &fileName, CalFormat *format = 0 ); 62 bool save( const QString &fileName, CalFormat *format = 0 );
62 63
63 /** 64 /**
64 Clears out the current calendar, freeing all used memory etc. etc. 65 Clears out the current calendar, freeing all used memory etc. etc.
65 */ 66 */
66 void close(); 67 void close();
67 68
68 void save() {} 69 void save() {}
69 70
70 /** 71 /**
71 Add Event to calendar. 72 Add Event to calendar.
72 */ 73 */
73 void removeSyncInfo( QString syncProfile); 74 void removeSyncInfo( QString syncProfile);
74 bool addAnniversaryNoDup( Event *event ); 75 bool addAnniversaryNoDup( Event *event );
75 bool addEventNoDup( Event *event ); 76 bool addEventNoDup( Event *event );
76 bool addEvent( Event *event ); 77 bool addEvent( Event *event );
77 /** 78 /**
78 Deletes an event from this calendar. 79 Deletes an event from this calendar.
79 */ 80 */
80 void deleteEvent( Event *event ); 81 void deleteEvent( Event *event );
81 82
82 /** 83 /**
83 Retrieves an event on the basis of the unique string ID. 84 Retrieves an event on the basis of the unique string ID.
84 */ 85 */
85 Event *event( const QString &uid ); 86 Event *event( const QString &uid );
86 /** 87 /**
87 Return unfiltered list of all events in calendar. 88 Return unfiltered list of all events in calendar.
88 */ 89 */
89 QPtrList<Event> rawEvents(); 90 QPtrList<Event> rawEvents();
90 QPtrList<Event> getExternLastSyncEvents(); 91 QPtrList<Event> getExternLastSyncEvents();
91 /** 92 /**
92 Add a todo to the todolist. 93 Add a todo to the todolist.
93 */ 94 */
94 bool addTodo( Todo *todo ); 95 bool addTodo( Todo *todo );
95 bool addTodoNoDup( Todo *todo ); 96 bool addTodoNoDup( Todo *todo );
96 /** 97 /**
97 Remove a todo from the todolist. 98 Remove a todo from the todolist.
98 */ 99 */
99 void deleteTodo( Todo * ); 100 void deleteTodo( Todo * );
100 /** 101 /**
101 Searches todolist for an event with this unique string identifier, 102 Searches todolist for an event with this unique string identifier,
102 returns a pointer or null. 103 returns a pointer or null.
103 */ 104 */
104 Todo *todo( const QString &uid ); 105 Todo *todo( const QString &uid );
105 /** 106 /**
106 Return list of all todos. 107 Return list of all todos.
107 */ 108 */
108 QPtrList<Todo> rawTodos(); 109 QPtrList<Todo> rawTodos();
109 /** 110 /**
110 Returns list of todos due on the specified date. 111 Returns list of todos due on the specified date.
111 */ 112 */
112 QPtrList<Todo> todos( const QDate &date ); 113 QPtrList<Todo> todos( const QDate &date );
113 /** 114 /**
114 Return list of all todos. 115 Return list of all todos.
115 116
116 Workaround because compiler does not recognize function of base class. 117 Workaround because compiler does not recognize function of base class.
117 */ 118 */
118 QPtrList<Todo> todos() { return Calendar::todos(); } 119 QPtrList<Todo> todos() { return Calendar::todos(); }
119 120
120 /** 121 /**
121 Add a Journal entry to calendar. 122 Add a Journal entry to calendar.
122 */ 123 */
123 bool addJournal( Journal * ); 124 bool addJournal( Journal * );
124 /** 125 /**
125 Remove a Journal from the calendar. 126 Remove a Journal from the calendar.
126 */ 127 */
127 void deleteJournal( Journal * ); 128 void deleteJournal( Journal * );
128 /** 129 /**
129 Return Journal for given date. 130 Return Journal for given date.
130 */ 131 */
131 Journal *journal( const QDate & ); 132 Journal *journal( const QDate & );
132 /** 133 /**
133 Return Journal with given UID. 134 Return Journal with given UID.
134 */ 135 */
135 Journal *journal( const QString &uid ); 136 Journal *journal( const QString &uid );
136 /** 137 /**
137 Return list of all Journals stored in calendar. 138 Return list of all Journals stored in calendar.
138 */ 139 */
139 QPtrList<Journal> journals(); 140 QPtrList<Journal> journals();
140 141
141 /** 142 /**
142 Return all alarms, which ocur in the given time interval. 143 Return all alarms, which ocur in the given time interval.
143 */ 144 */
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 2ddbb01..96039df 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -48,192 +48,194 @@ IncidenceBase::IncidenceBase() :
48 mAlarmEnabled = true; 48 mAlarmEnabled = true;
49 mCalID = 0; 49 mCalID = 0;
50} 50}
51 51
52IncidenceBase::IncidenceBase(const IncidenceBase &i) : 52IncidenceBase::IncidenceBase(const IncidenceBase &i) :
53 CustomProperties( i ) 53 CustomProperties( i )
54{ 54{
55 55
56 mReadOnly = i.mReadOnly; 56 mReadOnly = i.mReadOnly;
57 mDtStart = i.mDtStart; 57 mDtStart = i.mDtStart;
58 mDuration = i.mDuration; 58 mDuration = i.mDuration;
59 mHasDuration = i.mHasDuration; 59 mHasDuration = i.mHasDuration;
60 mOrganizer = i.mOrganizer; 60 mOrganizer = i.mOrganizer;
61 mUid = i.mUid; 61 mUid = i.mUid;
62 mCalEnabled = i.mCalEnabled; 62 mCalEnabled = i.mCalEnabled;
63 mAlarmEnabled = i.mAlarmEnabled; 63 mAlarmEnabled = i.mAlarmEnabled;
64 mCalID = i.mCalID; 64 mCalID = i.mCalID;
65 QPtrList<Attendee> attendees = i.attendees(); 65 QPtrList<Attendee> attendees = i.attendees();
66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 66 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
67 mAttendees.append( new Attendee( *a ) ); 67 mAttendees.append( new Attendee( *a ) );
68 } 68 }
69 mFloats = i.mFloats; 69 mFloats = i.mFloats;
70 mLastModified = i.mLastModified; 70 mLastModified = i.mLastModified;
71 mPilotId = i.mPilotId; 71 mPilotId = i.mPilotId;
72 mTempSyncStat = i.mTempSyncStat; 72 mTempSyncStat = i.mTempSyncStat;
73 mSyncStatus = i.mSyncStatus; 73 mSyncStatus = i.mSyncStatus;
74 mExternalId = i.mExternalId; 74 mExternalId = i.mExternalId;
75 // The copied object is a new one, so it isn't observed by the observer 75 // The copied object is a new one, so it isn't observed by the observer
76 // of the original object. 76 // of the original object.
77 mObservers.clear(); 77 mObservers.clear();
78 78
79 mAttendees.setAutoDelete( true ); 79 mAttendees.setAutoDelete( true );
80} 80}
81 81
82IncidenceBase::~IncidenceBase() 82IncidenceBase::~IncidenceBase()
83{ 83{
84} 84}
85 85
86 86
87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 87bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
88{ 88{
89 // do not compare mSyncStatus and mExternalId 89 // do not compare mSyncStatus and mExternalId
90 if( i1.attendees().count() != i2.attendees().count() ) { 90 if( i1.attendees().count() != i2.attendees().count() ) {
91 return false; // no need to check further 91 return false; // no need to check further
92 } 92 }
93 if ( i1.attendees().count() > 0 ) { 93 if ( i1.attendees().count() > 0 ) {
94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 94 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
95 while ( a1 ) { 95 while ( a1 ) {
96 if ( !( (*a1) == (*a2)) ) 96 if ( !( (*a1) == (*a2)) )
97 { 97 {
98 //qDebug("Attendee not equal "); 98 //qDebug("Attendee not equal ");
99 return false; 99 return false;
100 } 100 }
101 a1 = i1.attendees().next(); 101 a1 = i1.attendees().next();
102 a2 = i2.attendees().next(); 102 a2 = i2.attendees().next();
103 } 103 }
104 } 104 }
105 //if ( i1.dtStart() != i2.dtStart() ) 105 //if ( i1.dtStart() != i2.dtStart() )
106 // return false; 106 // return false;
107#if 0 107#if 0
108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 108 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
109 qDebug("1 %d ",i1.duration() == i2.duration() ); 109 qDebug("1 %d ",i1.duration() == i2.duration() );
110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 110 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 111 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 112 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
113 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 113 qDebug("6 %d ",i1.organizer() == i2.organizer() );
114 114
115#endif 115#endif
116 if ( i1.hasDuration() == i2.hasDuration() ) { 116 if ( i1.hasDuration() == i2.hasDuration() ) {
117 if ( i1.hasDuration() ) { 117 if ( i1.hasDuration() ) {
118 if ( i1.duration() != i2.duration() ) 118 if ( i1.duration() != i2.duration() )
119 return false; 119 return false;
120 } 120 }
121 } else { 121 } else {
122 return false; 122 return false;
123 } 123 }
124 124
125 return ( i1.organizer() == i2.organizer() && 125 return ( i1.organizer() == i2.organizer() &&
126 // i1.uid() == i2.uid() && 126 // i1.uid() == i2.uid() &&
127 // Don't compare lastModified, otherwise the operator is not 127 // Don't compare lastModified, otherwise the operator is not
128 // of much use. We are not comparing for identity, after all. 128 // of much use. We are not comparing for identity, after all.
129 i1.doesFloat() == i2.doesFloat() && 129 i1.doesFloat() == i2.doesFloat() &&
130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 130 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
131 // no need to compare mObserver 131 // no need to compare mObserver
132} 132}
133 133
134 134
135QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 135QDateTime IncidenceBase::getEvenTime( QDateTime dt )
136{ 136{
137 QTime t = dt.time(); 137 QTime t = dt.time();
138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 138 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
139 return dt; 139 return dt;
140} 140}
141 141
142void IncidenceBase::setCalID( int id ) 142void IncidenceBase::setCalID( int id )
143{ 143{
144 if ( mCalID > 0 )
145 updated();
144 mCalID = id; 146 mCalID = id;
145} 147}
146int IncidenceBase::calID() const 148int IncidenceBase::calID() const
147{ 149{
148 return mCalID; 150 return mCalID;
149} 151}
150void IncidenceBase::setCalEnabled( bool b ) 152void IncidenceBase::setCalEnabled( bool b )
151{ 153{
152 mCalEnabled = b; 154 mCalEnabled = b;
153} 155}
154bool IncidenceBase::calEnabled() const 156bool IncidenceBase::calEnabled() const
155{ 157{
156 return mCalEnabled; 158 return mCalEnabled;
157} 159}
158 160
159void IncidenceBase::setAlarmEnabled( bool b ) 161void IncidenceBase::setAlarmEnabled( bool b )
160{ 162{
161 mAlarmEnabled = b; 163 mAlarmEnabled = b;
162} 164}
163bool IncidenceBase::alarmEnabled() const 165bool IncidenceBase::alarmEnabled() const
164{ 166{
165 return mAlarmEnabled; 167 return mAlarmEnabled;
166} 168}
167 169
168 170
169void IncidenceBase::setUid(const QString &uid) 171void IncidenceBase::setUid(const QString &uid)
170{ 172{
171 mUid = uid; 173 mUid = uid;
172 updated(); 174 updated();
173} 175}
174 176
175QString IncidenceBase::uid() const 177QString IncidenceBase::uid() const
176{ 178{
177 return mUid; 179 return mUid;
178} 180}
179 181
180void IncidenceBase::setLastModified(const QDateTime &lm) 182void IncidenceBase::setLastModified(const QDateTime &lm)
181{ 183{
182 // DON'T! updated() because we call this from 184 // DON'T! updated() because we call this from
183 // Calendar::updateEvent(). 185 // Calendar::updateEvent().
184 mLastModified = getEvenTime(lm); 186 mLastModified = getEvenTime(lm);
185 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); 187 //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1());
186} 188}
187 189
188QDateTime IncidenceBase::lastModified() const 190QDateTime IncidenceBase::lastModified() const
189{ 191{
190 return mLastModified; 192 return mLastModified;
191} 193}
192 194
193void IncidenceBase::setOrganizer(const QString &o) 195void IncidenceBase::setOrganizer(const QString &o)
194{ 196{
195 // we don't check for readonly here, because it is 197 // we don't check for readonly here, because it is
196 // possible that by setting the organizer we are changing 198 // possible that by setting the organizer we are changing
197 // the event's readonly status... 199 // the event's readonly status...
198 mOrganizer = o; 200 mOrganizer = o;
199 if (mOrganizer.left(7).upper() == "MAILTO:") 201 if (mOrganizer.left(7).upper() == "MAILTO:")
200 mOrganizer = mOrganizer.remove(0,7); 202 mOrganizer = mOrganizer.remove(0,7);
201 203
202 updated(); 204 updated();
203} 205}
204 206
205QString IncidenceBase::organizer() const 207QString IncidenceBase::organizer() const
206{ 208{
207 return mOrganizer; 209 return mOrganizer;
208} 210}
209 211
210void IncidenceBase::setReadOnly( bool readOnly ) 212void IncidenceBase::setReadOnly( bool readOnly )
211{ 213{
212 mReadOnly = readOnly; 214 mReadOnly = readOnly;
213} 215}
214 216
215void IncidenceBase::setDtStart(const QDateTime &dtStart) 217void IncidenceBase::setDtStart(const QDateTime &dtStart)
216{ 218{
217// if (mReadOnly) return; 219// if (mReadOnly) return;
218 mDtStart = getEvenTime(dtStart); 220 mDtStart = getEvenTime(dtStart);
219 updated(); 221 updated();
220} 222}
221 223
222 224
223QDateTime IncidenceBase::dtStart() const 225QDateTime IncidenceBase::dtStart() const
224{ 226{
225 return mDtStart; 227 return mDtStart;
226} 228}
227 229
228QString IncidenceBase::dtStartTimeStr() const 230QString IncidenceBase::dtStartTimeStr() const
229{ 231{
230 return KGlobal::locale()->formatTime(dtStart().time()); 232 return KGlobal::locale()->formatTime(dtStart().time());
231} 233}
232 234
233QString IncidenceBase::dtStartDateStr(bool shortfmt) const 235QString IncidenceBase::dtStartDateStr(bool shortfmt) const
234{ 236{
235 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); 237 return KGlobal::locale()->formatDate(dtStart().date(),shortfmt);
236} 238}
237 239
238QString IncidenceBase::dtStartStr(bool shortfmt) const 240QString IncidenceBase::dtStartStr(bool shortfmt) const
239{ 241{