author | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-13 19:07:45 (UTC) |
commit | 7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff) | |
tree | 284d1592687ea4d3e0c220fafd289a702718dee4 /libkcal/incidence.cpp | |
parent | 293271fe9e6a9061da329183f8f488d79580f7da (diff) | |
download | kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2 |
todo fixi
-rw-r--r-- | libkcal/incidence.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 0684af2..708ee6b 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,603 +1,611 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License as published by the Free Software Foundation; either | 7 | License as published by the Free Software Foundation; either |
8 | version 2 of the License, or (at your option) any later version. | 8 | version 2 of the License, or (at your option) any later version. |
9 | 9 | ||
10 | This library is distributed in the hope that it will be useful, | 10 | This library is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Library General Public License for more details. | 13 | Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public License | 15 | You should have received a copy of the GNU Library General Public License |
16 | along with this library; see the file COPYING.LIB. If not, write to | 16 | along with this library; see the file COPYING.LIB. If not, write to |
17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 17 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
18 | Boston, MA 02111-1307, USA. | 18 | Boston, MA 02111-1307, USA. |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <kglobal.h> | 21 | #include <kglobal.h> |
22 | #include <klocale.h> | 22 | #include <klocale.h> |
23 | #include <kdebug.h> | 23 | #include <kdebug.h> |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #include "incidence.h" | 27 | #include "incidence.h" |
28 | #include "todo.h" | 28 | #include "todo.h" |
29 | 29 | ||
30 | using namespace KCal; | 30 | using namespace KCal; |
31 | 31 | ||
32 | Incidence::Incidence() : | 32 | Incidence::Incidence() : |
33 | IncidenceBase(), | 33 | IncidenceBase(), |
34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) | 34 | mRelatedTo(0), mSecrecy(SecrecyPublic), mPriority(3) |
35 | { | 35 | { |
36 | mRecurrence = new Recurrence(this); | 36 | mRecurrence = new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | } | 43 | } |
44 | 44 | ||
45 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 45 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
46 | { | 46 | { |
47 | // TODO: reenable attributes currently commented out. | 47 | // TODO: reenable attributes currently commented out. |
48 | mRevision = i.mRevision; | 48 | mRevision = i.mRevision; |
49 | mCreated = i.mCreated; | 49 | mCreated = i.mCreated; |
50 | mDescription = i.mDescription; | 50 | mDescription = i.mDescription; |
51 | mSummary = i.mSummary; | 51 | mSummary = i.mSummary; |
52 | mCategories = i.mCategories; | 52 | mCategories = i.mCategories; |
53 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 53 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
54 | mRelatedTo = 0; | 54 | mRelatedTo = 0; |
55 | mRelatedToUid = i.mRelatedToUid; | 55 | mRelatedToUid = i.mRelatedToUid; |
56 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 56 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
57 | mExDates = i.mExDates; | 57 | mExDates = i.mExDates; |
58 | mAttachments = i.mAttachments; | 58 | mAttachments = i.mAttachments; |
59 | mResources = i.mResources; | 59 | mResources = i.mResources; |
60 | mSecrecy = i.mSecrecy; | 60 | mSecrecy = i.mSecrecy; |
61 | mPriority = i.mPriority; | 61 | mPriority = i.mPriority; |
62 | mLocation = i.mLocation; | 62 | mLocation = i.mLocation; |
63 | mCancelled = i.mCancelled; | 63 | mCancelled = i.mCancelled; |
64 | mHasStartDate = i.mHasStartDate; | 64 | mHasStartDate = i.mHasStartDate; |
65 | QPtrListIterator<Alarm> it( i.mAlarms ); | 65 | QPtrListIterator<Alarm> it( i.mAlarms ); |
66 | const Alarm *a; | 66 | const Alarm *a; |
67 | while( (a = it.current()) ) { | 67 | while( (a = it.current()) ) { |
68 | Alarm *b = new Alarm( *a ); | 68 | Alarm *b = new Alarm( *a ); |
69 | b->setParent( this ); | 69 | b->setParent( this ); |
70 | mAlarms.append( b ); | 70 | mAlarms.append( b ); |
71 | 71 | ||
72 | ++it; | 72 | ++it; |
73 | } | 73 | } |
74 | mAlarms.setAutoDelete(true); | 74 | mAlarms.setAutoDelete(true); |
75 | mHasRecurrenceID = i.mHasRecurrenceID; | 75 | mHasRecurrenceID = i.mHasRecurrenceID; |
76 | mRecurrenceID = i.mRecurrenceID; | 76 | mRecurrenceID = i.mRecurrenceID; |
77 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 77 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
78 | } | 78 | } |
79 | 79 | ||
80 | Incidence::~Incidence() | 80 | Incidence::~Incidence() |
81 | { | 81 | { |
82 | 82 | ||
83 | Incidence *ev; | 83 | Incidence *ev; |
84 | QPtrList<Incidence> Relations = relations(); | 84 | QPtrList<Incidence> Relations = relations(); |
85 | for (ev=Relations.first();ev;ev=Relations.next()) { | 85 | for (ev=Relations.first();ev;ev=Relations.next()) { |
86 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 86 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
87 | } | 87 | } |
88 | if (relatedTo()) relatedTo()->removeRelation(this); | 88 | if (relatedTo()) relatedTo()->removeRelation(this); |
89 | delete mRecurrence; | 89 | delete mRecurrence; |
90 | 90 | ||
91 | } | 91 | } |
92 | bool Incidence::hasRecurrenceID() const | 92 | bool Incidence::hasRecurrenceID() const |
93 | { | 93 | { |
94 | return mHasRecurrenceID; | 94 | return mHasRecurrenceID; |
95 | } | 95 | } |
96 | 96 | ||
97 | void Incidence::setHasRecurrenceID( bool b ) | 97 | void Incidence::setHasRecurrenceID( bool b ) |
98 | { | 98 | { |
99 | mHasRecurrenceID = b; | 99 | mHasRecurrenceID = b; |
100 | } | 100 | } |
101 | 101 | ||
102 | void Incidence::setRecurrenceID(QDateTime d) | 102 | void Incidence::setRecurrenceID(QDateTime d) |
103 | { | 103 | { |
104 | mRecurrenceID = d; | 104 | mRecurrenceID = d; |
105 | mHasRecurrenceID = true; | 105 | mHasRecurrenceID = true; |
106 | updated(); | 106 | updated(); |
107 | } | 107 | } |
108 | QDateTime Incidence::recurrenceID () const | 108 | QDateTime Incidence::recurrenceID () const |
109 | { | 109 | { |
110 | return mRecurrenceID; | 110 | return mRecurrenceID; |
111 | } | 111 | } |
112 | 112 | ||
113 | bool Incidence::cancelled() const | 113 | bool Incidence::cancelled() const |
114 | { | 114 | { |
115 | return mCancelled; | 115 | return mCancelled; |
116 | } | 116 | } |
117 | void Incidence::setCancelled( bool b ) | 117 | void Incidence::setCancelled( bool b ) |
118 | { | 118 | { |
119 | mCancelled = b; | 119 | mCancelled = b; |
120 | updated(); | 120 | updated(); |
121 | } | 121 | } |
122 | bool Incidence::hasStartDate() const | 122 | bool Incidence::hasStartDate() const |
123 | { | 123 | { |
124 | return mHasStartDate; | 124 | return mHasStartDate; |
125 | } | 125 | } |
126 | 126 | ||
127 | void Incidence::setHasStartDate(bool f) | 127 | void Incidence::setHasStartDate(bool f) |
128 | { | 128 | { |
129 | if (mReadOnly) return; | 129 | if (mReadOnly) return; |
130 | mHasStartDate = f; | 130 | mHasStartDate = f; |
131 | updated(); | 131 | updated(); |
132 | } | 132 | } |
133 | 133 | ||
134 | // A string comparison that considers that null and empty are the same | 134 | // A string comparison that considers that null and empty are the same |
135 | static bool stringCompare( const QString& s1, const QString& s2 ) | 135 | static bool stringCompare( const QString& s1, const QString& s2 ) |
136 | { | 136 | { |
137 | if ( s1.isEmpty() && s2.isEmpty() ) | 137 | if ( s1.isEmpty() && s2.isEmpty() ) |
138 | return true; | 138 | return true; |
139 | return s1 == s2; | 139 | return s1 == s2; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 142 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
143 | { | 143 | { |
144 | 144 | ||
145 | if( i1.alarms().count() != i2.alarms().count() ) { | 145 | if( i1.alarms().count() != i2.alarms().count() ) { |
146 | return false; // no need to check further | 146 | return false; // no need to check further |
147 | } | 147 | } |
148 | if ( i1.alarms().count() > 0 ) { | 148 | if ( i1.alarms().count() > 0 ) { |
149 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 149 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
150 | { | 150 | { |
151 | qDebug("alarm not equal "); | 151 | qDebug("alarm not equal "); |
152 | return false; | 152 | return false; |
153 | } | 153 | } |
154 | } | 154 | } |
155 | #if 0 | 155 | #if 0 |
156 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 156 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
157 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 157 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
158 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 158 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
159 | if( *a1.current() == *a2.current() ) { | 159 | if( *a1.current() == *a2.current() ) { |
160 | continue; | 160 | continue; |
161 | } | 161 | } |
162 | else { | 162 | else { |
163 | return false; | 163 | return false; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | #endif | 166 | #endif |
167 | 167 | ||
168 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 168 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
169 | if ( i1.hasRecurrenceID() ) { | 169 | if ( i1.hasRecurrenceID() ) { |
170 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 170 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
171 | return false; | 171 | return false; |
172 | } | 172 | } |
173 | 173 | ||
174 | } else { | 174 | } else { |
175 | return false; | 175 | return false; |
176 | } | 176 | } |
177 | 177 | ||
178 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 178 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
179 | return false; | 179 | return false; |
180 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 180 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
181 | if ( i1.hasStartDate() ) { | 181 | if ( i1.hasStartDate() ) { |
182 | if ( i1.dtStart() != i2.dtStart() ) | 182 | if ( i1.dtStart() != i2.dtStart() ) |
183 | return false; | 183 | return false; |
184 | } | 184 | } |
185 | } else { | 185 | } else { |
186 | return false; | 186 | return false; |
187 | } | 187 | } |
188 | if (!( *i1.recurrence() == *i2.recurrence()) ) { | 188 | if (!( *i1.recurrence() == *i2.recurrence()) ) { |
189 | qDebug("recurrence is NOT equal "); | 189 | qDebug("recurrence is NOT equal "); |
190 | return false; | 190 | return false; |
191 | } | 191 | } |
192 | return | 192 | return |
193 | // i1.created() == i2.created() && | 193 | // i1.created() == i2.created() && |
194 | stringCompare( i1.description(), i2.description() ) && | 194 | stringCompare( i1.description(), i2.description() ) && |
195 | stringCompare( i1.summary(), i2.summary() ) && | 195 | stringCompare( i1.summary(), i2.summary() ) && |
196 | i1.categories() == i2.categories() && | 196 | i1.categories() == i2.categories() && |
197 | // no need to compare mRelatedTo | 197 | // no need to compare mRelatedTo |
198 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 198 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
199 | // i1.relations() == i2.relations() && | 199 | // i1.relations() == i2.relations() && |
200 | i1.exDates() == i2.exDates() && | 200 | i1.exDates() == i2.exDates() && |
201 | i1.attachments() == i2.attachments() && | 201 | i1.attachments() == i2.attachments() && |
202 | i1.resources() == i2.resources() && | 202 | i1.resources() == i2.resources() && |
203 | i1.secrecy() == i2.secrecy() && | 203 | i1.secrecy() == i2.secrecy() && |
204 | i1.priority() == i2.priority() && | 204 | i1.priority() == i2.priority() && |
205 | i1.cancelled() == i2.cancelled() && | 205 | i1.cancelled() == i2.cancelled() && |
206 | stringCompare( i1.location(), i2.location() ); | 206 | stringCompare( i1.location(), i2.location() ); |
207 | } | 207 | } |
208 | 208 | ||
209 | Incidence* Incidence::recreateCloneException( QDate d ) | 209 | Incidence* Incidence::recreateCloneException( QDate d ) |
210 | { | 210 | { |
211 | Incidence* newInc = clone(); | 211 | Incidence* newInc = clone(); |
212 | newInc->recreate(); | 212 | newInc->recreate(); |
213 | if ( doesRecur() ) { | 213 | if ( doesRecur() ) { |
214 | addExDate( d ); | 214 | addExDate( d ); |
215 | newInc->recurrence()->unsetRecurs(); | 215 | newInc->recurrence()->unsetRecurs(); |
216 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 216 | if ( type() == "Event") { |
217 | QTime tim = dtStart().time(); | 217 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
218 | newInc->setDtStart( QDateTime(d, tim) ); | 218 | QTime tim = dtStart().time(); |
219 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 219 | newInc->setDtStart( QDateTime(d, tim) ); |
220 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | ||
221 | } else { | ||
222 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | ||
223 | QTime tim = ((Todo*)this)->dtDue().time(); | ||
224 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | ||
225 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | ||
226 | ((Todo*)this)->setRecurDates(); | ||
227 | } | ||
220 | } | 228 | } |
221 | return newInc; | 229 | return newInc; |
222 | } | 230 | } |
223 | 231 | ||
224 | void Incidence::recreate() | 232 | void Incidence::recreate() |
225 | { | 233 | { |
226 | setCreated(QDateTime::currentDateTime()); | 234 | setCreated(QDateTime::currentDateTime()); |
227 | 235 | ||
228 | setUid(CalFormat::createUniqueId()); | 236 | setUid(CalFormat::createUniqueId()); |
229 | 237 | ||
230 | setRevision(0); | 238 | setRevision(0); |
231 | setIDStr( ":" ); | 239 | setIDStr( ":" ); |
232 | setLastModified(QDateTime::currentDateTime()); | 240 | setLastModified(QDateTime::currentDateTime()); |
233 | } | 241 | } |
234 | 242 | ||
235 | void Incidence::setReadOnly( bool readOnly ) | 243 | void Incidence::setReadOnly( bool readOnly ) |
236 | { | 244 | { |
237 | IncidenceBase::setReadOnly( readOnly ); | 245 | IncidenceBase::setReadOnly( readOnly ); |
238 | recurrence()->setRecurReadOnly( readOnly); | 246 | recurrence()->setRecurReadOnly( readOnly); |
239 | } | 247 | } |
240 | 248 | ||
241 | void Incidence::setCreated(QDateTime created) | 249 | void Incidence::setCreated(QDateTime created) |
242 | { | 250 | { |
243 | if (mReadOnly) return; | 251 | if (mReadOnly) return; |
244 | mCreated = getEvenTime(created); | 252 | mCreated = getEvenTime(created); |
245 | } | 253 | } |
246 | 254 | ||
247 | QDateTime Incidence::created() const | 255 | QDateTime Incidence::created() const |
248 | { | 256 | { |
249 | return mCreated; | 257 | return mCreated; |
250 | } | 258 | } |
251 | 259 | ||
252 | void Incidence::setRevision(int rev) | 260 | void Incidence::setRevision(int rev) |
253 | { | 261 | { |
254 | if (mReadOnly) return; | 262 | if (mReadOnly) return; |
255 | mRevision = rev; | 263 | mRevision = rev; |
256 | 264 | ||
257 | updated(); | 265 | updated(); |
258 | } | 266 | } |
259 | 267 | ||
260 | int Incidence::revision() const | 268 | int Incidence::revision() const |
261 | { | 269 | { |
262 | return mRevision; | 270 | return mRevision; |
263 | } | 271 | } |
264 | 272 | ||
265 | void Incidence::setDtStart(const QDateTime &dtStart) | 273 | void Incidence::setDtStart(const QDateTime &dtStart) |
266 | { | 274 | { |
267 | 275 | ||
268 | QDateTime dt = getEvenTime(dtStart); | 276 | QDateTime dt = getEvenTime(dtStart); |
269 | recurrence()->setRecurStart( dt); | 277 | recurrence()->setRecurStart( dt); |
270 | IncidenceBase::setDtStart( dt ); | 278 | IncidenceBase::setDtStart( dt ); |
271 | } | 279 | } |
272 | 280 | ||
273 | void Incidence::setDescription(const QString &description) | 281 | void Incidence::setDescription(const QString &description) |
274 | { | 282 | { |
275 | if (mReadOnly) return; | 283 | if (mReadOnly) return; |
276 | mDescription = description; | 284 | mDescription = description; |
277 | updated(); | 285 | updated(); |
278 | } | 286 | } |
279 | 287 | ||
280 | QString Incidence::description() const | 288 | QString Incidence::description() const |
281 | { | 289 | { |
282 | return mDescription; | 290 | return mDescription; |
283 | } | 291 | } |
284 | 292 | ||
285 | 293 | ||
286 | void Incidence::setSummary(const QString &summary) | 294 | void Incidence::setSummary(const QString &summary) |
287 | { | 295 | { |
288 | if (mReadOnly) return; | 296 | if (mReadOnly) return; |
289 | mSummary = summary; | 297 | mSummary = summary; |
290 | updated(); | 298 | updated(); |
291 | } | 299 | } |
292 | 300 | ||
293 | QString Incidence::summary() const | 301 | QString Incidence::summary() const |
294 | { | 302 | { |
295 | return mSummary; | 303 | return mSummary; |
296 | } | 304 | } |
297 | 305 | ||
298 | void Incidence::setCategories(const QStringList &categories) | 306 | void Incidence::setCategories(const QStringList &categories) |
299 | { | 307 | { |
300 | if (mReadOnly) return; | 308 | if (mReadOnly) return; |
301 | mCategories = categories; | 309 | mCategories = categories; |
302 | updated(); | 310 | updated(); |
303 | } | 311 | } |
304 | 312 | ||
305 | // TODO: remove setCategories(QString) function | 313 | // TODO: remove setCategories(QString) function |
306 | void Incidence::setCategories(const QString &catStr) | 314 | void Incidence::setCategories(const QString &catStr) |
307 | { | 315 | { |
308 | if (mReadOnly) return; | 316 | if (mReadOnly) return; |
309 | mCategories.clear(); | 317 | mCategories.clear(); |
310 | 318 | ||
311 | if (catStr.isEmpty()) return; | 319 | if (catStr.isEmpty()) return; |
312 | 320 | ||
313 | mCategories = QStringList::split(",",catStr); | 321 | mCategories = QStringList::split(",",catStr); |
314 | 322 | ||
315 | QStringList::Iterator it; | 323 | QStringList::Iterator it; |
316 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 324 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
317 | *it = (*it).stripWhiteSpace(); | 325 | *it = (*it).stripWhiteSpace(); |
318 | } | 326 | } |
319 | 327 | ||
320 | updated(); | 328 | updated(); |
321 | } | 329 | } |
322 | 330 | ||
323 | QStringList Incidence::categories() const | 331 | QStringList Incidence::categories() const |
324 | { | 332 | { |
325 | return mCategories; | 333 | return mCategories; |
326 | } | 334 | } |
327 | 335 | ||
328 | QString Incidence::categoriesStr() | 336 | QString Incidence::categoriesStr() |
329 | { | 337 | { |
330 | return mCategories.join(","); | 338 | return mCategories.join(","); |
331 | } | 339 | } |
332 | 340 | ||
333 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 341 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
334 | { | 342 | { |
335 | if (mReadOnly) return; | 343 | if (mReadOnly) return; |
336 | mRelatedToUid = relatedToUid; | 344 | mRelatedToUid = relatedToUid; |
337 | } | 345 | } |
338 | 346 | ||
339 | QString Incidence::relatedToUid() const | 347 | QString Incidence::relatedToUid() const |
340 | { | 348 | { |
341 | return mRelatedToUid; | 349 | return mRelatedToUid; |
342 | } | 350 | } |
343 | 351 | ||
344 | void Incidence::setRelatedTo(Incidence *relatedTo) | 352 | void Incidence::setRelatedTo(Incidence *relatedTo) |
345 | { | 353 | { |
346 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 354 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
347 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 355 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
348 | if (mReadOnly || mRelatedTo == relatedTo) return; | 356 | if (mReadOnly || mRelatedTo == relatedTo) return; |
349 | if(mRelatedTo) { | 357 | if(mRelatedTo) { |
350 | // updated(); | 358 | // updated(); |
351 | mRelatedTo->removeRelation(this); | 359 | mRelatedTo->removeRelation(this); |
352 | } | 360 | } |
353 | mRelatedTo = relatedTo; | 361 | mRelatedTo = relatedTo; |
354 | if (mRelatedTo) mRelatedTo->addRelation(this); | 362 | if (mRelatedTo) mRelatedTo->addRelation(this); |
355 | } | 363 | } |
356 | 364 | ||
357 | Incidence *Incidence::relatedTo() const | 365 | Incidence *Incidence::relatedTo() const |
358 | { | 366 | { |
359 | return mRelatedTo; | 367 | return mRelatedTo; |
360 | } | 368 | } |
361 | 369 | ||
362 | QPtrList<Incidence> Incidence::relations() const | 370 | QPtrList<Incidence> Incidence::relations() const |
363 | { | 371 | { |
364 | return mRelations; | 372 | return mRelations; |
365 | } | 373 | } |
366 | 374 | ||
367 | void Incidence::addRelation(Incidence *event) | 375 | void Incidence::addRelation(Incidence *event) |
368 | { | 376 | { |
369 | if( mRelations.findRef( event ) == -1 ) { | 377 | if( mRelations.findRef( event ) == -1 ) { |
370 | mRelations.append(event); | 378 | mRelations.append(event); |
371 | //updated(); | 379 | //updated(); |
372 | } | 380 | } |
373 | } | 381 | } |
374 | 382 | ||
375 | void Incidence::removeRelation(Incidence *event) | 383 | void Incidence::removeRelation(Incidence *event) |
376 | { | 384 | { |
377 | 385 | ||
378 | mRelations.removeRef(event); | 386 | mRelations.removeRef(event); |
379 | 387 | ||
380 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 388 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
381 | } | 389 | } |
382 | 390 | ||
383 | bool Incidence::recursOn(const QDate &qd) const | 391 | bool Incidence::recursOn(const QDate &qd) const |
384 | { | 392 | { |
385 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; | 393 | if (recurrence()->recursOnPure(qd) && !isException(qd)) return true; |
386 | else return false; | 394 | else return false; |
387 | } | 395 | } |
388 | 396 | ||
389 | void Incidence::setExDates(const DateList &exDates) | 397 | void Incidence::setExDates(const DateList &exDates) |
390 | { | 398 | { |
391 | if (mReadOnly) return; | 399 | if (mReadOnly) return; |
392 | mExDates = exDates; | 400 | mExDates = exDates; |
393 | 401 | ||
394 | recurrence()->setRecurExDatesCount(mExDates.count()); | 402 | recurrence()->setRecurExDatesCount(mExDates.count()); |
395 | 403 | ||
396 | updated(); | 404 | updated(); |
397 | } | 405 | } |
398 | 406 | ||
399 | void Incidence::addExDate(const QDate &date) | 407 | void Incidence::addExDate(const QDate &date) |
400 | { | 408 | { |
401 | if (mReadOnly) return; | 409 | if (mReadOnly) return; |
402 | mExDates.append(date); | 410 | mExDates.append(date); |
403 | 411 | ||
404 | recurrence()->setRecurExDatesCount(mExDates.count()); | 412 | recurrence()->setRecurExDatesCount(mExDates.count()); |
405 | 413 | ||
406 | updated(); | 414 | updated(); |
407 | } | 415 | } |
408 | 416 | ||
409 | DateList Incidence::exDates() const | 417 | DateList Incidence::exDates() const |
410 | { | 418 | { |
411 | return mExDates; | 419 | return mExDates; |
412 | } | 420 | } |
413 | 421 | ||
414 | bool Incidence::isException(const QDate &date) const | 422 | bool Incidence::isException(const QDate &date) const |
415 | { | 423 | { |
416 | DateList::ConstIterator it; | 424 | DateList::ConstIterator it; |
417 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 425 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
418 | if ( (*it) == date ) { | 426 | if ( (*it) == date ) { |
419 | return true; | 427 | return true; |
420 | } | 428 | } |
421 | } | 429 | } |
422 | 430 | ||
423 | return false; | 431 | return false; |
424 | } | 432 | } |
425 | 433 | ||
426 | void Incidence::addAttachment(Attachment *attachment) | 434 | void Incidence::addAttachment(Attachment *attachment) |
427 | { | 435 | { |
428 | if (mReadOnly || !attachment) return; | 436 | if (mReadOnly || !attachment) return; |
429 | mAttachments.append(attachment); | 437 | mAttachments.append(attachment); |
430 | updated(); | 438 | updated(); |
431 | } | 439 | } |
432 | 440 | ||
433 | void Incidence::deleteAttachment(Attachment *attachment) | 441 | void Incidence::deleteAttachment(Attachment *attachment) |
434 | { | 442 | { |
435 | mAttachments.removeRef(attachment); | 443 | mAttachments.removeRef(attachment); |
436 | } | 444 | } |
437 | 445 | ||
438 | void Incidence::deleteAttachments(const QString& mime) | 446 | void Incidence::deleteAttachments(const QString& mime) |
439 | { | 447 | { |
440 | Attachment *at = mAttachments.first(); | 448 | Attachment *at = mAttachments.first(); |
441 | while (at) { | 449 | while (at) { |
442 | if (at->mimeType() == mime) | 450 | if (at->mimeType() == mime) |
443 | mAttachments.remove(); | 451 | mAttachments.remove(); |
444 | else | 452 | else |
445 | at = mAttachments.next(); | 453 | at = mAttachments.next(); |
446 | } | 454 | } |
447 | } | 455 | } |
448 | 456 | ||
449 | QPtrList<Attachment> Incidence::attachments() const | 457 | QPtrList<Attachment> Incidence::attachments() const |
450 | { | 458 | { |
451 | return mAttachments; | 459 | return mAttachments; |
452 | } | 460 | } |
453 | 461 | ||
454 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 462 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
455 | { | 463 | { |
456 | QPtrList<Attachment> attachments; | 464 | QPtrList<Attachment> attachments; |
457 | QPtrListIterator<Attachment> it( mAttachments ); | 465 | QPtrListIterator<Attachment> it( mAttachments ); |
458 | Attachment *at; | 466 | Attachment *at; |
459 | while ( (at = it.current()) ) { | 467 | while ( (at = it.current()) ) { |
460 | if (at->mimeType() == mime) | 468 | if (at->mimeType() == mime) |
461 | attachments.append(at); | 469 | attachments.append(at); |
462 | ++it; | 470 | ++it; |
463 | } | 471 | } |
464 | 472 | ||
465 | return attachments; | 473 | return attachments; |
466 | } | 474 | } |
467 | 475 | ||
468 | void Incidence::setResources(const QStringList &resources) | 476 | void Incidence::setResources(const QStringList &resources) |
469 | { | 477 | { |
470 | if (mReadOnly) return; | 478 | if (mReadOnly) return; |
471 | mResources = resources; | 479 | mResources = resources; |
472 | updated(); | 480 | updated(); |
473 | } | 481 | } |
474 | 482 | ||
475 | QStringList Incidence::resources() const | 483 | QStringList Incidence::resources() const |
476 | { | 484 | { |
477 | return mResources; | 485 | return mResources; |
478 | } | 486 | } |
479 | 487 | ||
480 | 488 | ||
481 | void Incidence::setPriority(int priority) | 489 | void Incidence::setPriority(int priority) |
482 | { | 490 | { |
483 | if (mReadOnly) return; | 491 | if (mReadOnly) return; |
484 | mPriority = priority; | 492 | mPriority = priority; |
485 | updated(); | 493 | updated(); |
486 | } | 494 | } |
487 | 495 | ||
488 | int Incidence::priority() const | 496 | int Incidence::priority() const |
489 | { | 497 | { |
490 | return mPriority; | 498 | return mPriority; |
491 | } | 499 | } |
492 | 500 | ||
493 | void Incidence::setSecrecy(int sec) | 501 | void Incidence::setSecrecy(int sec) |
494 | { | 502 | { |
495 | if (mReadOnly) return; | 503 | if (mReadOnly) return; |
496 | mSecrecy = sec; | 504 | mSecrecy = sec; |
497 | updated(); | 505 | updated(); |
498 | } | 506 | } |
499 | 507 | ||
500 | int Incidence::secrecy() const | 508 | int Incidence::secrecy() const |
501 | { | 509 | { |
502 | return mSecrecy; | 510 | return mSecrecy; |
503 | } | 511 | } |
504 | 512 | ||
505 | QString Incidence::secrecyStr() const | 513 | QString Incidence::secrecyStr() const |
506 | { | 514 | { |
507 | return secrecyName(mSecrecy); | 515 | return secrecyName(mSecrecy); |
508 | } | 516 | } |
509 | 517 | ||
510 | QString Incidence::secrecyName(int secrecy) | 518 | QString Incidence::secrecyName(int secrecy) |
511 | { | 519 | { |
512 | switch (secrecy) { | 520 | switch (secrecy) { |
513 | case SecrecyPublic: | 521 | case SecrecyPublic: |
514 | return i18n("Public"); | 522 | return i18n("Public"); |
515 | break; | 523 | break; |
516 | case SecrecyPrivate: | 524 | case SecrecyPrivate: |
517 | return i18n("Private"); | 525 | return i18n("Private"); |
518 | break; | 526 | break; |
519 | case SecrecyConfidential: | 527 | case SecrecyConfidential: |
520 | return i18n("Confidential"); | 528 | return i18n("Confidential"); |
521 | break; | 529 | break; |
522 | default: | 530 | default: |
523 | return i18n("Undefined"); | 531 | return i18n("Undefined"); |
524 | break; | 532 | break; |
525 | } | 533 | } |
526 | } | 534 | } |
527 | 535 | ||
528 | QStringList Incidence::secrecyList() | 536 | QStringList Incidence::secrecyList() |
529 | { | 537 | { |
530 | QStringList list; | 538 | QStringList list; |
531 | list << secrecyName(SecrecyPublic); | 539 | list << secrecyName(SecrecyPublic); |
532 | list << secrecyName(SecrecyPrivate); | 540 | list << secrecyName(SecrecyPrivate); |
533 | list << secrecyName(SecrecyConfidential); | 541 | list << secrecyName(SecrecyConfidential); |
534 | 542 | ||
535 | return list; | 543 | return list; |
536 | } | 544 | } |
537 | 545 | ||
538 | 546 | ||
539 | QPtrList<Alarm> Incidence::alarms() const | 547 | QPtrList<Alarm> Incidence::alarms() const |
540 | { | 548 | { |
541 | return mAlarms; | 549 | return mAlarms; |
542 | } | 550 | } |
543 | 551 | ||
544 | Alarm* Incidence::newAlarm() | 552 | Alarm* Incidence::newAlarm() |
545 | { | 553 | { |
546 | Alarm* alarm = new Alarm(this); | 554 | Alarm* alarm = new Alarm(this); |
547 | mAlarms.append(alarm); | 555 | mAlarms.append(alarm); |
548 | // updated(); | 556 | // updated(); |
549 | return alarm; | 557 | return alarm; |
550 | } | 558 | } |
551 | 559 | ||
552 | void Incidence::addAlarm(Alarm *alarm) | 560 | void Incidence::addAlarm(Alarm *alarm) |
553 | { | 561 | { |
554 | mAlarms.append(alarm); | 562 | mAlarms.append(alarm); |
555 | updated(); | 563 | updated(); |
556 | } | 564 | } |
557 | 565 | ||
558 | void Incidence::removeAlarm(Alarm *alarm) | 566 | void Incidence::removeAlarm(Alarm *alarm) |
559 | { | 567 | { |
560 | mAlarms.removeRef(alarm); | 568 | mAlarms.removeRef(alarm); |
561 | updated(); | 569 | updated(); |
562 | } | 570 | } |
563 | 571 | ||
564 | void Incidence::clearAlarms() | 572 | void Incidence::clearAlarms() |
565 | { | 573 | { |
566 | mAlarms.clear(); | 574 | mAlarms.clear(); |
567 | updated(); | 575 | updated(); |
568 | } | 576 | } |
569 | 577 | ||
570 | bool Incidence::isAlarmEnabled() const | 578 | bool Incidence::isAlarmEnabled() const |
571 | { | 579 | { |
572 | Alarm* alarm; | 580 | Alarm* alarm; |
573 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { | 581 | for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { |
574 | if (alarm->enabled()) | 582 | if (alarm->enabled()) |
575 | return true; | 583 | return true; |
576 | } | 584 | } |
577 | return false; | 585 | return false; |
578 | } | 586 | } |
579 | 587 | ||
580 | Recurrence *Incidence::recurrence() const | 588 | Recurrence *Incidence::recurrence() const |
581 | { | 589 | { |
582 | return mRecurrence; | 590 | return mRecurrence; |
583 | } | 591 | } |
584 | void Incidence::setRecurrence( Recurrence * r) | 592 | void Incidence::setRecurrence( Recurrence * r) |
585 | { | 593 | { |
586 | delete mRecurrence; | 594 | delete mRecurrence; |
587 | mRecurrence = r; | 595 | mRecurrence = r; |
588 | } | 596 | } |
589 | 597 | ||
590 | void Incidence::setLocation(const QString &location) | 598 | void Incidence::setLocation(const QString &location) |
591 | { | 599 | { |
592 | if (mReadOnly) return; | 600 | if (mReadOnly) return; |
593 | mLocation = location; | 601 | mLocation = location; |
594 | updated(); | 602 | updated(); |
595 | } | 603 | } |
596 | 604 | ||
597 | QString Incidence::location() const | 605 | QString Incidence::location() const |
598 | { | 606 | { |
599 | return mLocation; | 607 | return mLocation; |
600 | } | 608 | } |
601 | 609 | ||
602 | ushort Incidence::doesRecur() const | 610 | ushort Incidence::doesRecur() const |
603 | { | 611 | { |