-rw-r--r-- | libkcal/incidence.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index 39c14f5..fe9f854 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -1,741 +1,754 @@ | |||
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 = 0;//new Recurrence(this); | 36 | mRecurrence = 0;//new Recurrence(this); |
37 | mCancelled = false; | 37 | mCancelled = false; |
38 | recreate(); | 38 | recreate(); |
39 | mHasStartDate = true; | 39 | mHasStartDate = true; |
40 | mAlarms.setAutoDelete(true); | 40 | mAlarms.setAutoDelete(true); |
41 | mAttachments.setAutoDelete(true); | 41 | mAttachments.setAutoDelete(true); |
42 | mHasRecurrenceID = false; | 42 | mHasRecurrenceID = false; |
43 | mHoliday = false; | 43 | mHoliday = false; |
44 | mBirthday = false; | 44 | mBirthday = false; |
45 | mAnniversary = false; | 45 | mAnniversary = false; |
46 | 46 | ||
47 | } | 47 | } |
48 | 48 | ||
49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) | 49 | Incidence::Incidence( const Incidence &i ) : IncidenceBase( i ) |
50 | { | 50 | { |
51 | // TODO: reenable attributes currently commented out. | 51 | // TODO: reenable attributes currently commented out. |
52 | mRevision = i.mRevision; | 52 | mRevision = i.mRevision; |
53 | mCreated = i.mCreated; | 53 | mCreated = i.mCreated; |
54 | mDescription = i.mDescription; | 54 | mDescription = i.mDescription; |
55 | mSummary = i.mSummary; | 55 | mSummary = i.mSummary; |
56 | mCategories = i.mCategories; | 56 | mCategories = i.mCategories; |
57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; | 57 | // Incidence *mRelatedTo; Incidence *mRelatedTo; |
58 | mRelatedTo = 0; | 58 | mRelatedTo = 0; |
59 | mRelatedToUid = i.mRelatedToUid; | 59 | mRelatedToUid = i.mRelatedToUid; |
60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; | 60 | // QPtrList<Incidence> mRelations; QPtrList<Incidence> mRelations; |
61 | mExDates = i.mExDates; | 61 | mExDates = i.mExDates; |
62 | QPtrListIterator<Attachment> itat( i.mAttachments ); | 62 | QPtrListIterator<Attachment> itat( i.mAttachments ); |
63 | Attachment *at; | 63 | Attachment *at; |
64 | while( (at = itat.current()) ) { | 64 | while( (at = itat.current()) ) { |
65 | Attachment *a = new Attachment( *at ); | 65 | Attachment *a = new Attachment( *at ); |
66 | mAttachments.append( a ); | 66 | mAttachments.append( a ); |
67 | ++itat; | 67 | ++itat; |
68 | } | 68 | } |
69 | mAttachments.setAutoDelete( true ); | 69 | mAttachments.setAutoDelete( true ); |
70 | mResources = i.mResources; | 70 | mResources = i.mResources; |
71 | mSecrecy = i.mSecrecy; | 71 | mSecrecy = i.mSecrecy; |
72 | mPriority = i.mPriority; | 72 | mPriority = i.mPriority; |
73 | mLocation = i.mLocation; | 73 | mLocation = i.mLocation; |
74 | mCancelled = i.mCancelled; | 74 | mCancelled = i.mCancelled; |
75 | mHasStartDate = i.mHasStartDate; | 75 | mHasStartDate = i.mHasStartDate; |
76 | QPtrListIterator<Alarm> it( i.mAlarms ); | 76 | QPtrListIterator<Alarm> it( i.mAlarms ); |
77 | const Alarm *a; | 77 | const Alarm *a; |
78 | while( (a = it.current()) ) { | 78 | while( (a = it.current()) ) { |
79 | Alarm *b = new Alarm( *a ); | 79 | Alarm *b = new Alarm( *a ); |
80 | b->setParent( this ); | 80 | b->setParent( this ); |
81 | mAlarms.append( b ); | 81 | mAlarms.append( b ); |
82 | 82 | ||
83 | ++it; | 83 | ++it; |
84 | } | 84 | } |
85 | mAlarms.setAutoDelete(true); | 85 | mAlarms.setAutoDelete(true); |
86 | mHasRecurrenceID = i.mHasRecurrenceID; | 86 | mHasRecurrenceID = i.mHasRecurrenceID; |
87 | mRecurrenceID = i.mRecurrenceID; | 87 | mRecurrenceID = i.mRecurrenceID; |
88 | if ( i.mRecurrence ) | 88 | if ( i.mRecurrence ) |
89 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); | 89 | mRecurrence = new Recurrence( *(i.mRecurrence), this ); |
90 | else | 90 | else |
91 | mRecurrence = 0; | 91 | mRecurrence = 0; |
92 | mHoliday = i.mHoliday ; | 92 | mHoliday = i.mHoliday ; |
93 | mBirthday = i.mBirthday; | 93 | mBirthday = i.mBirthday; |
94 | mAnniversary = i.mAnniversary; | 94 | mAnniversary = i.mAnniversary; |
95 | } | 95 | } |
96 | 96 | ||
97 | Incidence::~Incidence() | 97 | Incidence::~Incidence() |
98 | { | 98 | { |
99 | 99 | ||
100 | Incidence *ev; | 100 | Incidence *ev; |
101 | QPtrList<Incidence> Relations = relations(); | 101 | QPtrList<Incidence> Relations = relations(); |
102 | for (ev=Relations.first();ev;ev=Relations.next()) { | 102 | for (ev=Relations.first();ev;ev=Relations.next()) { |
103 | if (ev->relatedTo() == this) ev->setRelatedTo(0); | 103 | if (ev->relatedTo() == this) ev->setRelatedTo(0); |
104 | } | 104 | } |
105 | if (relatedTo()) relatedTo()->removeRelation(this); | 105 | if (relatedTo()) relatedTo()->removeRelation(this); |
106 | if ( mRecurrence ) | 106 | if ( mRecurrence ) |
107 | delete mRecurrence; | 107 | delete mRecurrence; |
108 | 108 | ||
109 | } | 109 | } |
110 | QString Incidence::durationText() | 110 | QString Incidence::durationText() |
111 | { | 111 | { |
112 | return "---"; | 112 | return "---"; |
113 | } | 113 | } |
114 | QString Incidence::durationText4Time( int offset ) | 114 | QString Incidence::durationText4Time( int offset ) |
115 | { | 115 | { |
116 | int min = offset/60; | 116 | int min = offset/60; |
117 | int hours = min /60; | 117 | int hours = min /60; |
118 | min = min % 60; | 118 | min = min % 60; |
119 | int days = hours /24; | 119 | int days = hours /24; |
120 | hours = hours % 24; | 120 | hours = hours % 24; |
121 | 121 | ||
122 | if ( doesFloat() || ( min == 0 && hours == 0 ) ) { | 122 | if ( doesFloat() || ( min == 0 && hours == 0 ) ) { |
123 | if ( days == 1 ) | 123 | if ( days == 1 ) |
124 | return "1" + i18n(" day"); | 124 | return "1" + i18n(" day"); |
125 | else | 125 | else |
126 | return QString::number( days )+ i18n(" days"); | 126 | return QString::number( days )+ i18n(" days"); |
127 | 127 | ||
128 | } | 128 | } |
129 | QString message = QString::number ( hours ) +":"; | 129 | QString message = QString::number ( hours ) +":"; |
130 | if ( min < 10 ) message += "0"; | 130 | if ( min < 10 ) message += "0"; |
131 | message += QString::number ( min ); | 131 | message += QString::number ( min ); |
132 | if ( days > 0 ) { | 132 | if ( days > 0 ) { |
133 | if ( days == 1 ) | 133 | if ( days == 1 ) |
134 | message = "1" + i18n(" day") + " "+message; | 134 | message = "1" + i18n(" day") + " "+message; |
135 | else | 135 | else |
136 | message = QString::number( days )+ i18n(" days") + " "+message; | 136 | message = QString::number( days )+ i18n(" days") + " "+message; |
137 | } | 137 | } |
138 | return message; | 138 | return message; |
139 | } | 139 | } |
140 | bool Incidence::isHoliday() const | 140 | bool Incidence::isHoliday() const |
141 | { | 141 | { |
142 | return mHoliday; | 142 | return mHoliday; |
143 | } | 143 | } |
144 | bool Incidence::isBirthday() const | 144 | bool Incidence::isBirthday() const |
145 | { | 145 | { |
146 | 146 | ||
147 | return mBirthday ; | 147 | return mBirthday ; |
148 | } | 148 | } |
149 | bool Incidence::isAnniversary() const | 149 | bool Incidence::isAnniversary() const |
150 | { | 150 | { |
151 | return mAnniversary ; | 151 | return mAnniversary ; |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | bool Incidence::hasRecurrenceID() const | 155 | bool Incidence::hasRecurrenceID() const |
156 | { | 156 | { |
157 | return mHasRecurrenceID; | 157 | return mHasRecurrenceID; |
158 | } | 158 | } |
159 | 159 | ||
160 | void Incidence::setHasRecurrenceID( bool b ) | 160 | void Incidence::setHasRecurrenceID( bool b ) |
161 | { | 161 | { |
162 | mHasRecurrenceID = b; | 162 | mHasRecurrenceID = b; |
163 | } | 163 | } |
164 | 164 | ||
165 | void Incidence::setRecurrenceID(QDateTime d) | 165 | void Incidence::setRecurrenceID(QDateTime d) |
166 | { | 166 | { |
167 | mRecurrenceID = d; | 167 | mRecurrenceID = d; |
168 | mHasRecurrenceID = true; | 168 | mHasRecurrenceID = true; |
169 | updated(); | 169 | updated(); |
170 | } | 170 | } |
171 | QDateTime Incidence::recurrenceID () const | 171 | QDateTime Incidence::recurrenceID () const |
172 | { | 172 | { |
173 | return mRecurrenceID; | 173 | return mRecurrenceID; |
174 | } | 174 | } |
175 | 175 | ||
176 | bool Incidence::cancelled() const | 176 | bool Incidence::cancelled() const |
177 | { | 177 | { |
178 | return mCancelled; | 178 | return mCancelled; |
179 | } | 179 | } |
180 | void Incidence::setCancelled( bool b ) | 180 | void Incidence::setCancelled( bool b ) |
181 | { | 181 | { |
182 | mCancelled = b; | 182 | mCancelled = b; |
183 | updated(); | 183 | updated(); |
184 | } | 184 | } |
185 | bool Incidence::hasStartDate() const | 185 | bool Incidence::hasStartDate() const |
186 | { | 186 | { |
187 | return mHasStartDate; | 187 | return mHasStartDate; |
188 | } | 188 | } |
189 | 189 | ||
190 | void Incidence::setHasStartDate(bool f) | 190 | void Incidence::setHasStartDate(bool f) |
191 | { | 191 | { |
192 | if (mReadOnly) return; | 192 | if (mReadOnly) return; |
193 | mHasStartDate = f; | 193 | mHasStartDate = f; |
194 | updated(); | 194 | updated(); |
195 | } | 195 | } |
196 | 196 | ||
197 | // A string comparison that considers that null and empty are the same | 197 | // A string comparison that considers that null and empty are the same |
198 | static bool stringCompare( const QString& s1, const QString& s2 ) | 198 | static bool stringCompare( const QString& s1, const QString& s2 ) |
199 | { | 199 | { |
200 | if ( s1.isEmpty() && s2.isEmpty() ) | 200 | if ( s1.isEmpty() && s2.isEmpty() ) |
201 | return true; | 201 | return true; |
202 | return s1 == s2; | 202 | return s1 == s2; |
203 | } | 203 | } |
204 | 204 | ||
205 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) | 205 | bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) |
206 | { | 206 | { |
207 | 207 | ||
208 | if( i1.alarms().count() != i2.alarms().count() ) { | 208 | if( i1.alarms().count() != i2.alarms().count() ) { |
209 | return false; // no need to check further | 209 | return false; // no need to check further |
210 | } | 210 | } |
211 | if ( i1.alarms().count() > 0 ) { | 211 | if ( i1.alarms().count() > 0 ) { |
212 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) | 212 | if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) |
213 | { | 213 | { |
214 | qDebug("alarm not equal "); | 214 | qDebug("alarm not equal "); |
215 | return false; | 215 | return false; |
216 | } | 216 | } |
217 | } | 217 | } |
218 | #if 0 | 218 | #if 0 |
219 | QPtrListIterator<Alarm> a1( i1.alarms() ); | 219 | QPtrListIterator<Alarm> a1( i1.alarms() ); |
220 | QPtrListIterator<Alarm> a2( i2.alarms() ); | 220 | QPtrListIterator<Alarm> a2( i2.alarms() ); |
221 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { | 221 | for( ; a1.current() && a2.current(); ++a1, ++a2 ) { |
222 | if( *a1.current() == *a2.current() ) { | 222 | if( *a1.current() == *a2.current() ) { |
223 | continue; | 223 | continue; |
224 | } | 224 | } |
225 | else { | 225 | else { |
226 | return false; | 226 | return false; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | 230 | ||
231 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { | 231 | if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { |
232 | if ( i1.hasRecurrenceID() ) { | 232 | if ( i1.hasRecurrenceID() ) { |
233 | if ( i1.recurrenceID() != i2.recurrenceID() ) | 233 | if ( i1.recurrenceID() != i2.recurrenceID() ) |
234 | return false; | 234 | return false; |
235 | } | 235 | } |
236 | 236 | ||
237 | } else { | 237 | } else { |
238 | return false; | 238 | return false; |
239 | } | 239 | } |
240 | 240 | ||
241 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) | 241 | if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) |
242 | return false; | 242 | return false; |
243 | if ( i1.hasStartDate() == i2.hasStartDate() ) { | 243 | if ( i1.hasStartDate() == i2.hasStartDate() ) { |
244 | if ( i1.hasStartDate() ) { | 244 | if ( i1.hasStartDate() ) { |
245 | if ( i1.dtStart() != i2.dtStart() ) | 245 | if ( i1.dtStart() != i2.dtStart() ) |
246 | return false; | 246 | return false; |
247 | } | 247 | } |
248 | } else { | 248 | } else { |
249 | return false; | 249 | return false; |
250 | } | 250 | } |
251 | if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { | 251 | if ( i1.mRecurrence != 0 && i2.mRecurrence != 0 ) { |
252 | if (!( *i1.mRecurrence == *i2.mRecurrence) ) { | 252 | if (!( *i1.mRecurrence == *i2.mRecurrence) ) { |
253 | //qDebug("recurrence is NOT equal "); | 253 | //qDebug("recurrence is NOT equal "); |
254 | return false; | 254 | return false; |
255 | } | 255 | } |
256 | } else { | 256 | } else { |
257 | // one ( or both ) recurrence is 0 | 257 | // one ( or both ) recurrence is 0 |
258 | if ( i1.mRecurrence == 0 ) { | 258 | if ( i1.mRecurrence == 0 ) { |
259 | if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) | 259 | if ( i2.mRecurrence != 0 && i2.mRecurrence->doesRecur() != Recurrence::rNone ) |
260 | return false; | 260 | return false; |
261 | } else { | 261 | } else { |
262 | // i1.mRecurrence != 0 | 262 | // i1.mRecurrence != 0 |
263 | // i2.mRecurrence == 0 | 263 | // i2.mRecurrence == 0 |
264 | if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) | 264 | if ( i1.mRecurrence->doesRecur() != Recurrence::rNone ) |
265 | return false; | 265 | return false; |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | return | 269 | return |
270 | // i1.created() == i2.created() && | 270 | // i1.created() == i2.created() && |
271 | stringCompare( i1.description(), i2.description() ) && | 271 | stringCompare( i1.description(), i2.description() ) && |
272 | stringCompare( i1.summary(), i2.summary() ) && | 272 | stringCompare( i1.summary(), i2.summary() ) && |
273 | i1.categories() == i2.categories() && | 273 | i1.categories() == i2.categories() && |
274 | // no need to compare mRelatedTo | 274 | // no need to compare mRelatedTo |
275 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && | 275 | stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && |
276 | // i1.relations() == i2.relations() && | 276 | // i1.relations() == i2.relations() && |
277 | i1.exDates() == i2.exDates() && | 277 | i1.exDates() == i2.exDates() && |
278 | i1.attachments() == i2.attachments() && | 278 | i1.attachments() == i2.attachments() && |
279 | i1.resources() == i2.resources() && | 279 | i1.resources() == i2.resources() && |
280 | i1.secrecy() == i2.secrecy() && | 280 | i1.secrecy() == i2.secrecy() && |
281 | i1.priority() == i2.priority() && | 281 | i1.priority() == i2.priority() && |
282 | i1.cancelled() == i2.cancelled() && | 282 | i1.cancelled() == i2.cancelled() && |
283 | stringCompare( i1.location(), i2.location() ); | 283 | stringCompare( i1.location(), i2.location() ); |
284 | } | 284 | } |
285 | 285 | ||
286 | Incidence* Incidence::recreateCloneException( QDate d ) | 286 | Incidence* Incidence::recreateCloneException( QDate d ) |
287 | { | 287 | { |
288 | Incidence* newInc = clone(); | 288 | Incidence* newInc = clone(); |
289 | newInc->recreate(); | 289 | newInc->recreate(); |
290 | if ( doesRecur() ) { | 290 | if ( doesRecur() ) { |
291 | addExDate( d ); | 291 | addExDate( d ); |
292 | newInc->recurrence()->unsetRecurs(); | 292 | newInc->recurrence()->unsetRecurs(); |
293 | if ( typeID() == eventID ) { | 293 | if ( typeID() == eventID ) { |
294 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); | 294 | int len = dtStart().secsTo( ((Event*)this)->dtEnd()); |
295 | QTime tim = dtStart().time(); | 295 | QTime tim = dtStart().time(); |
296 | newInc->setDtStart( QDateTime(d, tim) ); | 296 | newInc->setDtStart( QDateTime(d, tim) ); |
297 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); | 297 | ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); |
298 | } else { | 298 | } else { |
299 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); | 299 | int len = dtStart().secsTo( ((Todo*)this)->dtDue()); |
300 | QTime tim = ((Todo*)this)->dtDue().time(); | 300 | QTime tim = ((Todo*)this)->dtDue().time(); |
301 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); | 301 | ((Todo*)newInc)->setDtDue( QDateTime(d, tim) ); |
302 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); | 302 | ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) ); |
303 | ((Todo*)this)->setRecurDates(); | 303 | ((Todo*)this)->setRecurDates(); |
304 | } | 304 | } |
305 | newInc->setExDates( DateList () ); | 305 | newInc->setExDates( DateList () ); |
306 | } | 306 | } |
307 | return newInc; | 307 | return newInc; |
308 | } | 308 | } |
309 | 309 | ||
310 | void Incidence::recreate() | 310 | void Incidence::recreate() |
311 | { | 311 | { |
312 | setCreated(QDateTime::currentDateTime()); | 312 | setCreated(QDateTime::currentDateTime()); |
313 | 313 | ||
314 | setUid(CalFormat::createUniqueId()); | 314 | setUid(CalFormat::createUniqueId()); |
315 | 315 | ||
316 | setRevision(0); | 316 | setRevision(0); |
317 | setIDStr( ":" ); | 317 | setIDStr( ":" ); |
318 | setLastModified(QDateTime::currentDateTime()); | 318 | setLastModified(QDateTime::currentDateTime()); |
319 | } | 319 | } |
320 | void Incidence::cloneRelations( Incidence * newInc ) | 320 | void Incidence::cloneRelations( Incidence * newInc ) |
321 | { | 321 | { |
322 | // newInc is already a clone of this incidence | 322 | // newInc is already a clone of this incidence |
323 | Incidence * inc; | 323 | Incidence * inc; |
324 | Incidence * cloneInc; | 324 | Incidence * cloneInc; |
325 | QPtrList<Incidence> Relations = relations(); | 325 | QPtrList<Incidence> Relations = relations(); |
326 | for (inc=Relations.first();inc;inc=Relations.next()) { | 326 | for (inc=Relations.first();inc;inc=Relations.next()) { |
327 | cloneInc = inc->clone(); | 327 | cloneInc = inc->clone(); |
328 | cloneInc->recreate(); | 328 | cloneInc->recreate(); |
329 | cloneInc->setRelatedTo( newInc ); | 329 | cloneInc->setRelatedTo( newInc ); |
330 | inc->cloneRelations( cloneInc ); | 330 | inc->cloneRelations( cloneInc ); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | void Incidence::setReadOnly( bool readOnly ) | 333 | void Incidence::setReadOnly( bool readOnly ) |
334 | { | 334 | { |
335 | IncidenceBase::setReadOnly( readOnly ); | 335 | IncidenceBase::setReadOnly( readOnly ); |
336 | if ( mRecurrence ) | 336 | if ( mRecurrence ) |
337 | mRecurrence->setRecurReadOnly( readOnly); | 337 | mRecurrence->setRecurReadOnly( readOnly); |
338 | } | 338 | } |
339 | void Incidence::setLastModifiedSubInvalid() | 339 | void Incidence::setLastModifiedSubInvalid() |
340 | { | 340 | { |
341 | mLastModifiedSub = QDateTime(); | 341 | mLastModifiedSub = QDateTime(); |
342 | if ( mRelatedTo ) | 342 | if ( mRelatedTo ) |
343 | mRelatedTo->setLastModifiedSubInvalid(); | 343 | mRelatedTo->setLastModifiedSubInvalid(); |
344 | } | 344 | } |
345 | QString Incidence::lastModifiedSubSortKey() const | ||
346 | { | ||
347 | if ( mLastModifiedSubSortKey.isEmpty() ) | ||
348 | return lastModifiedSortKey(); | ||
349 | return mLastModifiedSubSortKey; | ||
350 | } | ||
345 | QDateTime Incidence::lastModifiedSub() | 351 | QDateTime Incidence::lastModifiedSub() |
346 | { | 352 | { |
347 | if ( !mRelations.count() ) | 353 | if ( !mRelations.count() ) |
348 | return lastModified(); | 354 | return lastModified(); |
349 | if ( mLastModifiedSub.isValid() ) | 355 | if ( mLastModifiedSub.isValid() ) |
350 | return mLastModifiedSub; | 356 | return mLastModifiedSub; |
351 | mLastModifiedSub = lastModified(); | 357 | mLastModifiedSub = lastModified(); |
352 | Incidence * inc; | 358 | Incidence * inc; |
353 | QPtrList<Incidence> Relations = relations(); | 359 | QPtrList<Incidence> Relations = relations(); |
354 | for (inc=Relations.first();inc;inc=Relations.next()) { | 360 | for (inc=Relations.first();inc;inc=Relations.next()) { |
355 | if ( inc->lastModifiedSub() > mLastModifiedSub ) | 361 | if ( inc->lastModifiedSub() > mLastModifiedSub ) |
356 | mLastModifiedSub = inc->lastModifiedSub(); | 362 | mLastModifiedSub = inc->lastModifiedSub(); |
357 | } | 363 | } |
364 | mLastModifiedSubSortKey.sprintf("%04d%02d%02d%02d%02d%02d", | ||
365 | mLastModifiedSub.date().year(), | ||
366 | mLastModifiedSub.date().month(), | ||
367 | mLastModifiedSub.date().day(), | ||
368 | mLastModifiedSub.time().hour(), | ||
369 | mLastModifiedSub.time().minute(), | ||
370 | mLastModifiedSub.time().second() ); | ||
358 | return mLastModifiedSub; | 371 | return mLastModifiedSub; |
359 | } | 372 | } |
360 | void Incidence::setCreated(QDateTime created) | 373 | void Incidence::setCreated(QDateTime created) |
361 | { | 374 | { |
362 | if (mReadOnly) return; | 375 | if (mReadOnly) return; |
363 | mCreated = getEvenTime(created); | 376 | mCreated = getEvenTime(created); |
364 | } | 377 | } |
365 | 378 | ||
366 | QDateTime Incidence::created() const | 379 | QDateTime Incidence::created() const |
367 | { | 380 | { |
368 | return mCreated; | 381 | return mCreated; |
369 | } | 382 | } |
370 | 383 | ||
371 | void Incidence::setRevision(int rev) | 384 | void Incidence::setRevision(int rev) |
372 | { | 385 | { |
373 | if (mReadOnly) return; | 386 | if (mReadOnly) return; |
374 | mRevision = rev; | 387 | mRevision = rev; |
375 | 388 | ||
376 | updated(); | 389 | updated(); |
377 | } | 390 | } |
378 | 391 | ||
379 | int Incidence::revision() const | 392 | int Incidence::revision() const |
380 | { | 393 | { |
381 | return mRevision; | 394 | return mRevision; |
382 | } | 395 | } |
383 | 396 | ||
384 | void Incidence::setDtStart(const QDateTime &dtStart) | 397 | void Incidence::setDtStart(const QDateTime &dtStart) |
385 | { | 398 | { |
386 | 399 | ||
387 | QDateTime dt = getEvenTime(dtStart); | 400 | QDateTime dt = getEvenTime(dtStart); |
388 | 401 | ||
389 | if ( mRecurrence ) | 402 | if ( mRecurrence ) |
390 | mRecurrence->setRecurStart( dt); | 403 | mRecurrence->setRecurStart( dt); |
391 | IncidenceBase::setDtStart( dt ); | 404 | IncidenceBase::setDtStart( dt ); |
392 | } | 405 | } |
393 | 406 | ||
394 | void Incidence::setDescription(const QString &description) | 407 | void Incidence::setDescription(const QString &description) |
395 | { | 408 | { |
396 | if (mReadOnly) return; | 409 | if (mReadOnly) return; |
397 | mDescription = description; | 410 | mDescription = description; |
398 | updated(); | 411 | updated(); |
399 | } | 412 | } |
400 | 413 | ||
401 | QString Incidence::description() const | 414 | QString Incidence::description() const |
402 | { | 415 | { |
403 | return mDescription; | 416 | return mDescription; |
404 | } | 417 | } |
405 | 418 | ||
406 | 419 | ||
407 | void Incidence::setSummary(const QString &summary) | 420 | void Incidence::setSummary(const QString &summary) |
408 | { | 421 | { |
409 | if (mReadOnly) return; | 422 | if (mReadOnly) return; |
410 | mSummary = summary; | 423 | mSummary = summary; |
411 | updated(); | 424 | updated(); |
412 | } | 425 | } |
413 | 426 | ||
414 | QString Incidence::summary() const | 427 | QString Incidence::summary() const |
415 | { | 428 | { |
416 | return mSummary; | 429 | return mSummary; |
417 | } | 430 | } |
418 | void Incidence::checkCategories() | 431 | void Incidence::checkCategories() |
419 | { | 432 | { |
420 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); | 433 | mHoliday = mCategories.contains("Holiday") || mCategories.contains(i18n("Holiday")); |
421 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); | 434 | mBirthday = mCategories.contains("Birthday") || mCategories.contains(i18n("Birthday")); |
422 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); | 435 | mAnniversary = mCategories.contains("Anniversary") || mCategories.contains(i18n("Anniversary")); |
423 | } | 436 | } |
424 | 437 | ||
425 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false | 438 | void Incidence::addCategories(const QStringList &categories, bool addToRelations ) //addToRelations = false |
426 | { | 439 | { |
427 | if (mReadOnly) return; | 440 | if (mReadOnly) return; |
428 | int i; | 441 | int i; |
429 | for( i = 0; i < categories.count(); ++i ) { | 442 | for( i = 0; i < categories.count(); ++i ) { |
430 | if ( !mCategories.contains (categories[i])) | 443 | if ( !mCategories.contains (categories[i])) |
431 | mCategories.append( categories[i] ); | 444 | mCategories.append( categories[i] ); |
432 | } | 445 | } |
433 | checkCategories(); | 446 | checkCategories(); |
434 | updated(); | 447 | updated(); |
435 | if ( addToRelations ) { | 448 | if ( addToRelations ) { |
436 | Incidence * inc; | 449 | Incidence * inc; |
437 | QPtrList<Incidence> Relations = relations(); | 450 | QPtrList<Incidence> Relations = relations(); |
438 | for (inc=Relations.first();inc;inc=Relations.next()) { | 451 | for (inc=Relations.first();inc;inc=Relations.next()) { |
439 | inc->addCategories( categories, true ); | 452 | inc->addCategories( categories, true ); |
440 | } | 453 | } |
441 | } | 454 | } |
442 | } | 455 | } |
443 | 456 | ||
444 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false | 457 | void Incidence::setCategories(const QStringList &categories, bool setForRelations ) //setForRelations = false |
445 | { | 458 | { |
446 | if (mReadOnly) return; | 459 | if (mReadOnly) return; |
447 | mCategories = categories; | 460 | mCategories = categories; |
448 | checkCategories(); | 461 | checkCategories(); |
449 | updated(); | 462 | updated(); |
450 | if ( setForRelations ) { | 463 | if ( setForRelations ) { |
451 | Incidence * inc; | 464 | Incidence * inc; |
452 | QPtrList<Incidence> Relations = relations(); | 465 | QPtrList<Incidence> Relations = relations(); |
453 | for (inc=Relations.first();inc;inc=Relations.next()) { | 466 | for (inc=Relations.first();inc;inc=Relations.next()) { |
454 | inc->setCategories( categories, true ); | 467 | inc->setCategories( categories, true ); |
455 | } | 468 | } |
456 | } | 469 | } |
457 | } | 470 | } |
458 | 471 | ||
459 | // TODO: remove setCategories(QString) function | 472 | // TODO: remove setCategories(QString) function |
460 | void Incidence::setCategories(const QString &catStr) | 473 | void Incidence::setCategories(const QString &catStr) |
461 | { | 474 | { |
462 | if (mReadOnly) return; | 475 | if (mReadOnly) return; |
463 | mCategories.clear(); | 476 | mCategories.clear(); |
464 | 477 | ||
465 | if (catStr.isEmpty()) return; | 478 | if (catStr.isEmpty()) return; |
466 | 479 | ||
467 | mCategories = QStringList::split(",",catStr); | 480 | mCategories = QStringList::split(",",catStr); |
468 | 481 | ||
469 | QStringList::Iterator it; | 482 | QStringList::Iterator it; |
470 | for(it = mCategories.begin();it != mCategories.end(); ++it) { | 483 | for(it = mCategories.begin();it != mCategories.end(); ++it) { |
471 | *it = (*it).stripWhiteSpace(); | 484 | *it = (*it).stripWhiteSpace(); |
472 | } | 485 | } |
473 | checkCategories(); | 486 | checkCategories(); |
474 | updated(); | 487 | updated(); |
475 | } | 488 | } |
476 | // using this makes filtering 3 times faster | 489 | // using this makes filtering 3 times faster |
477 | QStringList* Incidence::categoriesP() | 490 | QStringList* Incidence::categoriesP() |
478 | { | 491 | { |
479 | return &mCategories; | 492 | return &mCategories; |
480 | } | 493 | } |
481 | 494 | ||
482 | QStringList Incidence::categories() const | 495 | QStringList Incidence::categories() const |
483 | { | 496 | { |
484 | return mCategories; | 497 | return mCategories; |
485 | } | 498 | } |
486 | 499 | ||
487 | QString Incidence::categoriesStr() | 500 | QString Incidence::categoriesStr() |
488 | { | 501 | { |
489 | return mCategories.join(","); | 502 | return mCategories.join(","); |
490 | } | 503 | } |
491 | QString Incidence::categoriesStrWithSpace() | 504 | QString Incidence::categoriesStrWithSpace() |
492 | { | 505 | { |
493 | return mCategories.join(", "); | 506 | return mCategories.join(", "); |
494 | } | 507 | } |
495 | 508 | ||
496 | void Incidence::setRelatedToUid(const QString &relatedToUid) | 509 | void Incidence::setRelatedToUid(const QString &relatedToUid) |
497 | { | 510 | { |
498 | if (mReadOnly) return; | 511 | if (mReadOnly) return; |
499 | mRelatedToUid = relatedToUid; | 512 | mRelatedToUid = relatedToUid; |
500 | } | 513 | } |
501 | void Incidence::clearRelations() | 514 | void Incidence::clearRelations() |
502 | { | 515 | { |
503 | mRelatedTo = 0; | 516 | mRelatedTo = 0; |
504 | mRelations.clear(); | 517 | mRelations.clear(); |
505 | } | 518 | } |
506 | QString Incidence::relatedToUid() const | 519 | QString Incidence::relatedToUid() const |
507 | { | 520 | { |
508 | return mRelatedToUid; | 521 | return mRelatedToUid; |
509 | } | 522 | } |
510 | 523 | ||
511 | void Incidence::setRelatedTo(Incidence *relatedTo) | 524 | void Incidence::setRelatedTo(Incidence *relatedTo) |
512 | { | 525 | { |
513 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); | 526 | //qDebug("Incidence::setRelatedTo %d ", relatedTo); |
514 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); | 527 | //qDebug("setRelatedTo(Incidence *relatedTo) %s %s", summary().latin1(), relatedTo->summary().latin1() ); |
515 | if (mReadOnly || mRelatedTo == relatedTo) return; | 528 | if (mReadOnly || mRelatedTo == relatedTo) return; |
516 | if(mRelatedTo) { | 529 | if(mRelatedTo) { |
517 | // updated(); | 530 | // updated(); |
518 | mRelatedTo->removeRelation(this); | 531 | mRelatedTo->removeRelation(this); |
519 | } | 532 | } |
520 | mRelatedTo = relatedTo; | 533 | mRelatedTo = relatedTo; |
521 | if (mRelatedTo) { | 534 | if (mRelatedTo) { |
522 | mRelatedTo->addRelation(this); | 535 | mRelatedTo->addRelation(this); |
523 | mRelatedToUid = mRelatedTo->uid(); | 536 | mRelatedToUid = mRelatedTo->uid(); |
524 | } else { | 537 | } else { |
525 | mRelatedToUid = ""; | 538 | mRelatedToUid = ""; |
526 | } | 539 | } |
527 | } | 540 | } |
528 | 541 | ||
529 | Incidence *Incidence::relatedTo() const | 542 | Incidence *Incidence::relatedTo() const |
530 | { | 543 | { |
531 | return mRelatedTo; | 544 | return mRelatedTo; |
532 | } | 545 | } |
533 | 546 | ||
534 | QPtrList<Incidence> Incidence::relations() const | 547 | QPtrList<Incidence> Incidence::relations() const |
535 | { | 548 | { |
536 | return mRelations; | 549 | return mRelations; |
537 | } | 550 | } |
538 | 551 | ||
539 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) | 552 | void Incidence::addRelationsToList(QPtrList<Incidence> *rel) |
540 | { | 553 | { |
541 | Incidence* inc; | 554 | Incidence* inc; |
542 | QPtrList<Incidence> Relations = relations(); | 555 | QPtrList<Incidence> Relations = relations(); |
543 | for (inc=Relations.first();inc;inc=Relations.next()) { | 556 | for (inc=Relations.first();inc;inc=Relations.next()) { |
544 | inc->addRelationsToList( rel ); | 557 | inc->addRelationsToList( rel ); |
545 | } | 558 | } |
546 | if ( rel->findRef( this ) == -1 ) | 559 | if ( rel->findRef( this ) == -1 ) |
547 | rel->append( this ); | 560 | rel->append( this ); |
548 | } | 561 | } |
549 | 562 | ||
550 | void Incidence::addRelation(Incidence *event) | 563 | void Incidence::addRelation(Incidence *event) |
551 | { | 564 | { |
552 | setLastModifiedSubInvalid(); | 565 | setLastModifiedSubInvalid(); |
553 | if( mRelations.findRef( event ) == -1 ) { | 566 | if( mRelations.findRef( event ) == -1 ) { |
554 | mRelations.append(event); | 567 | mRelations.append(event); |
555 | //updated(); | 568 | //updated(); |
556 | } | 569 | } |
557 | } | 570 | } |
558 | 571 | ||
559 | void Incidence::removeRelation(Incidence *event) | 572 | void Incidence::removeRelation(Incidence *event) |
560 | { | 573 | { |
561 | setLastModifiedSubInvalid(); | 574 | setLastModifiedSubInvalid(); |
562 | mRelations.removeRef(event); | 575 | mRelations.removeRef(event); |
563 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); | 576 | // if (event->getRelatedTo() == this) event->setRelatedTo(0); |
564 | } | 577 | } |
565 | 578 | ||
566 | bool Incidence::recursOn(const QDate &qd) const | 579 | bool Incidence::recursOn(const QDate &qd) const |
567 | { | 580 | { |
568 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; | 581 | if (mRecurrence && mRecurrence->recursOnPure(qd) && !isException(qd)) return true; |
569 | else return false; | 582 | else return false; |
570 | } | 583 | } |
571 | 584 | ||
572 | void Incidence::setExDates(const DateList &exDates) | 585 | void Incidence::setExDates(const DateList &exDates) |
573 | { | 586 | { |
574 | if (mReadOnly) return; | 587 | if (mReadOnly) return; |
575 | mExDates = exDates; | 588 | mExDates = exDates; |
576 | recurrence()->setRecurExDatesCount(mExDates.count()); | 589 | recurrence()->setRecurExDatesCount(mExDates.count()); |
577 | 590 | ||
578 | updated(); | 591 | updated(); |
579 | } | 592 | } |
580 | 593 | ||
581 | void Incidence::addExDate(const QDate &date) | 594 | void Incidence::addExDate(const QDate &date) |
582 | { | 595 | { |
583 | if (mReadOnly) return; | 596 | if (mReadOnly) return; |
584 | mExDates.append(date); | 597 | mExDates.append(date); |
585 | 598 | ||
586 | recurrence()->setRecurExDatesCount(mExDates.count()); | 599 | recurrence()->setRecurExDatesCount(mExDates.count()); |
587 | 600 | ||
588 | updated(); | 601 | updated(); |
589 | } | 602 | } |
590 | 603 | ||
591 | DateList Incidence::exDates() const | 604 | DateList Incidence::exDates() const |
592 | { | 605 | { |
593 | return mExDates; | 606 | return mExDates; |
594 | } | 607 | } |
595 | 608 | ||
596 | bool Incidence::isException(const QDate &date) const | 609 | bool Incidence::isException(const QDate &date) const |
597 | { | 610 | { |
598 | DateList::ConstIterator it; | 611 | DateList::ConstIterator it; |
599 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { | 612 | for( it = mExDates.begin(); it != mExDates.end(); ++it ) { |
600 | if ( (*it) == date ) { | 613 | if ( (*it) == date ) { |
601 | return true; | 614 | return true; |
602 | } | 615 | } |
603 | } | 616 | } |
604 | 617 | ||
605 | return false; | 618 | return false; |
606 | } | 619 | } |
607 | 620 | ||
608 | void Incidence::addAttachment(Attachment *attachment) | 621 | void Incidence::addAttachment(Attachment *attachment) |
609 | { | 622 | { |
610 | if (mReadOnly || !attachment) return; | 623 | if (mReadOnly || !attachment) return; |
611 | mAttachments.append(attachment); | 624 | mAttachments.append(attachment); |
612 | updated(); | 625 | updated(); |
613 | } | 626 | } |
614 | 627 | ||
615 | void Incidence::deleteAttachment(Attachment *attachment) | 628 | void Incidence::deleteAttachment(Attachment *attachment) |
616 | { | 629 | { |
617 | mAttachments.removeRef(attachment); | 630 | mAttachments.removeRef(attachment); |
618 | } | 631 | } |
619 | 632 | ||
620 | void Incidence::deleteAttachments(const QString& mime) | 633 | void Incidence::deleteAttachments(const QString& mime) |
621 | { | 634 | { |
622 | Attachment *at = mAttachments.first(); | 635 | Attachment *at = mAttachments.first(); |
623 | while (at) { | 636 | while (at) { |
624 | if (at->mimeType() == mime) | 637 | if (at->mimeType() == mime) |
625 | mAttachments.remove(); | 638 | mAttachments.remove(); |
626 | else | 639 | else |
627 | at = mAttachments.next(); | 640 | at = mAttachments.next(); |
628 | } | 641 | } |
629 | } | 642 | } |
630 | 643 | ||
631 | QPtrList<Attachment> Incidence::attachments() const | 644 | QPtrList<Attachment> Incidence::attachments() const |
632 | { | 645 | { |
633 | return mAttachments; | 646 | return mAttachments; |
634 | } | 647 | } |
635 | 648 | ||
636 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const | 649 | QPtrList<Attachment> Incidence::attachments(const QString& mime) const |
637 | { | 650 | { |
638 | QPtrList<Attachment> attachments; | 651 | QPtrList<Attachment> attachments; |
639 | QPtrListIterator<Attachment> it( mAttachments ); | 652 | QPtrListIterator<Attachment> it( mAttachments ); |
640 | Attachment *at; | 653 | Attachment *at; |
641 | while ( (at = it.current()) ) { | 654 | while ( (at = it.current()) ) { |
642 | if (at->mimeType() == mime) | 655 | if (at->mimeType() == mime) |
643 | attachments.append(at); | 656 | attachments.append(at); |
644 | ++it; | 657 | ++it; |
645 | } | 658 | } |
646 | 659 | ||
647 | return attachments; | 660 | return attachments; |
648 | } | 661 | } |
649 | 662 | ||
650 | void Incidence::setResources(const QStringList &resources) | 663 | void Incidence::setResources(const QStringList &resources) |
651 | { | 664 | { |
652 | if (mReadOnly) return; | 665 | if (mReadOnly) return; |
653 | mResources = resources; | 666 | mResources = resources; |
654 | updated(); | 667 | updated(); |
655 | } | 668 | } |
656 | 669 | ||
657 | QStringList Incidence::resources() const | 670 | QStringList Incidence::resources() const |
658 | { | 671 | { |
659 | return mResources; | 672 | return mResources; |
660 | } | 673 | } |
661 | 674 | ||
662 | 675 | ||
663 | void Incidence::setPriority(int priority) | 676 | void Incidence::setPriority(int priority) |
664 | { | 677 | { |
665 | if (mReadOnly) return; | 678 | if (mReadOnly) return; |
666 | mPriority = priority; | 679 | mPriority = priority; |
667 | updated(); | 680 | updated(); |
668 | } | 681 | } |
669 | 682 | ||
670 | int Incidence::priority() const | 683 | int Incidence::priority() const |
671 | { | 684 | { |
672 | return mPriority; | 685 | return mPriority; |
673 | } | 686 | } |
674 | 687 | ||
675 | void Incidence::setSecrecy(int sec) | 688 | void Incidence::setSecrecy(int sec) |
676 | { | 689 | { |
677 | if (mReadOnly) return; | 690 | if (mReadOnly) return; |
678 | mSecrecy = sec; | 691 | mSecrecy = sec; |
679 | updated(); | 692 | updated(); |
680 | } | 693 | } |
681 | 694 | ||
682 | int Incidence::secrecy() const | 695 | int Incidence::secrecy() const |
683 | { | 696 | { |
684 | return mSecrecy; | 697 | return mSecrecy; |
685 | } | 698 | } |
686 | 699 | ||
687 | QString Incidence::secrecyStr() const | 700 | QString Incidence::secrecyStr() const |
688 | { | 701 | { |
689 | return secrecyName(mSecrecy); | 702 | return secrecyName(mSecrecy); |
690 | } | 703 | } |
691 | 704 | ||
692 | QString Incidence::secrecyName(int secrecy) | 705 | QString Incidence::secrecyName(int secrecy) |
693 | { | 706 | { |
694 | switch (secrecy) { | 707 | switch (secrecy) { |
695 | case SecrecyPublic: | 708 | case SecrecyPublic: |
696 | return i18n("Public"); | 709 | return i18n("Public"); |
697 | break; | 710 | break; |
698 | case SecrecyPrivate: | 711 | case SecrecyPrivate: |
699 | return i18n("Private"); | 712 | return i18n("Private"); |
700 | break; | 713 | break; |
701 | case SecrecyConfidential: | 714 | case SecrecyConfidential: |
702 | return i18n("Confidential"); | 715 | return i18n("Confidential"); |
703 | break; | 716 | break; |
704 | default: | 717 | default: |
705 | return i18n("Undefined"); | 718 | return i18n("Undefined"); |
706 | break; | 719 | break; |
707 | } | 720 | } |
708 | } | 721 | } |
709 | 722 | ||
710 | QStringList Incidence::secrecyList() | 723 | QStringList Incidence::secrecyList() |
711 | { | 724 | { |
712 | QStringList list; | 725 | QStringList list; |
713 | list << secrecyName(SecrecyPublic); | 726 | list << secrecyName(SecrecyPublic); |
714 | list << secrecyName(SecrecyPrivate); | 727 | list << secrecyName(SecrecyPrivate); |
715 | list << secrecyName(SecrecyConfidential); | 728 | list << secrecyName(SecrecyConfidential); |
716 | 729 | ||
717 | return list; | 730 | return list; |
718 | } | 731 | } |
719 | 732 | ||
720 | 733 | ||
721 | QPtrList<Alarm> Incidence::alarms() const | 734 | QPtrList<Alarm> Incidence::alarms() const |
722 | { | 735 | { |
723 | return mAlarms; | 736 | return mAlarms; |
724 | } | 737 | } |
725 | 738 | ||
726 | Alarm* Incidence::newAlarm() | 739 | Alarm* Incidence::newAlarm() |
727 | { | 740 | { |
728 | Alarm* alarm = new Alarm(this); | 741 | Alarm* alarm = new Alarm(this); |
729 | mAlarms.append(alarm); | 742 | mAlarms.append(alarm); |
730 | // updated(); | 743 | // updated(); |
731 | return alarm; | 744 | return alarm; |
732 | } | 745 | } |
733 | 746 | ||
734 | void Incidence::addAlarm(Alarm *alarm) | 747 | void Incidence::addAlarm(Alarm *alarm) |
735 | { | 748 | { |
736 | mAlarms.append(alarm); | 749 | mAlarms.append(alarm); |
737 | updated(); | 750 | updated(); |
738 | } | 751 | } |
739 | 752 | ||
740 | void Incidence::removeAlarm(Alarm *alarm) | 753 | void Incidence::removeAlarm(Alarm *alarm) |
741 | { | 754 | { |