-rw-r--r-- | libkcal/incidencebase.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 022dead..cfef973 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -4,395 +4,406 @@ | |||
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 | #include <kidmanager.h> | 24 | #include <kidmanager.h> |
25 | 25 | ||
26 | #include "calformat.h" | 26 | #include "calformat.h" |
27 | #include "syncdefines.h" | 27 | #include "syncdefines.h" |
28 | 28 | ||
29 | #include "incidencebase.h" | 29 | #include "incidencebase.h" |
30 | 30 | ||
31 | using namespace KCal; | 31 | using namespace KCal; |
32 | 32 | ||
33 | IncidenceBase::IncidenceBase() : | 33 | IncidenceBase::IncidenceBase() : |
34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), | 34 | mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), |
35 | mPilotId(0), mSyncStatus(SYNCMOD) | 35 | mPilotId(0), mSyncStatus(SYNCMOD) |
36 | { | 36 | { |
37 | blockLastModified = false; | 37 | blockLastModified = false; |
38 | setUid(CalFormat::createUniqueId()); | 38 | setUid(CalFormat::createUniqueId()); |
39 | mOrganizer = ""; | 39 | mOrganizer = ""; |
40 | mFloats = false; | 40 | mFloats = false; |
41 | mDuration = 0; | 41 | mDuration = 0; |
42 | mHasDuration = false; | 42 | mHasDuration = false; |
43 | mPilotId = 0; | 43 | mPilotId = 0; |
44 | mExternalId = ":"; | 44 | mExternalId = ":"; |
45 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 45 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
46 | mSyncStatus = 0; | 46 | mSyncStatus = 0; |
47 | mAttendees.setAutoDelete( true ); | 47 | mAttendees.setAutoDelete( true ); |
48 | mCalEnabled = true; | 48 | mCalEnabled = true; |
49 | mAlarmEnabled = true; | 49 | mAlarmEnabled = true; |
50 | mCalID = 0; | 50 | mCalID = 0; |
51 | } | 51 | } |
52 | 52 | ||
53 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 53 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
54 | CustomProperties( i ) | 54 | CustomProperties( i ) |
55 | { | 55 | { |
56 | 56 | ||
57 | blockLastModified = false; | 57 | blockLastModified = false; |
58 | mReadOnly = i.mReadOnly; | 58 | mReadOnly = i.mReadOnly; |
59 | mDtStart = i.mDtStart; | 59 | mDtStart = i.mDtStart; |
60 | mDuration = i.mDuration; | 60 | mDuration = i.mDuration; |
61 | mHasDuration = i.mHasDuration; | 61 | mHasDuration = i.mHasDuration; |
62 | mOrganizer = i.mOrganizer; | 62 | mOrganizer = i.mOrganizer; |
63 | mUid = i.mUid; | 63 | mUid = i.mUid; |
64 | mCalEnabled = i.mCalEnabled; | 64 | mCalEnabled = i.mCalEnabled; |
65 | mAlarmEnabled = i.mAlarmEnabled; | 65 | mAlarmEnabled = i.mAlarmEnabled; |
66 | mCalID = i.mCalID; | 66 | mCalID = i.mCalID; |
67 | QPtrList<Attendee> attendees = i.attendees(); | 67 | QPtrList<Attendee> attendees = i.attendees(); |
68 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 68 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
69 | mAttendees.append( new Attendee( *a ) ); | 69 | mAttendees.append( new Attendee( *a ) ); |
70 | } | 70 | } |
71 | mFloats = i.mFloats; | 71 | mFloats = i.mFloats; |
72 | mLastModified = i.mLastModified; | 72 | mLastModified = i.mLastModified; |
73 | mPilotId = i.mPilotId; | 73 | mPilotId = i.mPilotId; |
74 | mTempSyncStat = i.mTempSyncStat; | 74 | mTempSyncStat = i.mTempSyncStat; |
75 | mSyncStatus = i.mSyncStatus; | 75 | mSyncStatus = i.mSyncStatus; |
76 | mExternalId = i.mExternalId; | 76 | mExternalId = i.mExternalId; |
77 | // The copied object is a new one, so it isn't observed by the observer | 77 | // The copied object is a new one, so it isn't observed by the observer |
78 | // of the original object. | 78 | // of the original object. |
79 | mObservers.clear(); | 79 | mObservers.clear(); |
80 | 80 | ||
81 | mAttendees.setAutoDelete( true ); | 81 | mAttendees.setAutoDelete( true ); |
82 | } | 82 | } |
83 | 83 | ||
84 | IncidenceBase::~IncidenceBase() | 84 | IncidenceBase::~IncidenceBase() |
85 | { | 85 | { |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 89 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
90 | { | 90 | { |
91 | // do not compare mSyncStatus and mExternalId | 91 | // do not compare mSyncStatus and mExternalId |
92 | if( i1.attendees().count() != i2.attendees().count() ) { | 92 | if( i1.attendees().count() != i2.attendees().count() ) { |
93 | return false; // no need to check further | 93 | return false; // no need to check further |
94 | } | 94 | } |
95 | if ( i1.attendees().count() > 0 ) { | 95 | if ( i1.attendees().count() > 0 ) { |
96 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 96 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
97 | while ( a1 ) { | 97 | while ( a1 ) { |
98 | if ( !( (*a1) == (*a2)) ) | 98 | if ( !( (*a1) == (*a2)) ) |
99 | { | 99 | { |
100 | //qDebug("Attendee not equal "); | 100 | //qDebug("Attendee not equal "); |
101 | return false; | 101 | return false; |
102 | } | 102 | } |
103 | a1 = i1.attendees().next(); | 103 | a1 = i1.attendees().next(); |
104 | a2 = i2.attendees().next(); | 104 | a2 = i2.attendees().next(); |
105 | } | 105 | } |
106 | } | 106 | } |
107 | //if ( i1.dtStart() != i2.dtStart() ) | 107 | //if ( i1.dtStart() != i2.dtStart() ) |
108 | // return false; | 108 | // return false; |
109 | #if 0 | 109 | #if 0 |
110 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 110 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
111 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 111 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
112 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 112 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
113 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 113 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
114 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 114 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
115 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 115 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
116 | 116 | ||
117 | #endif | 117 | #endif |
118 | if ( i1.hasDuration() == i2.hasDuration() ) { | 118 | if ( i1.hasDuration() == i2.hasDuration() ) { |
119 | if ( i1.hasDuration() ) { | 119 | if ( i1.hasDuration() ) { |
120 | if ( i1.duration() != i2.duration() ) | 120 | if ( i1.duration() != i2.duration() ) |
121 | return false; | 121 | return false; |
122 | } | 122 | } |
123 | } else { | 123 | } else { |
124 | return false; | 124 | return false; |
125 | } | 125 | } |
126 | 126 | ||
127 | return ( i1.organizer() == i2.organizer() && | 127 | return ( i1.organizer() == i2.organizer() && |
128 | // i1.uid() == i2.uid() && | 128 | // i1.uid() == i2.uid() && |
129 | // Don't compare lastModified, otherwise the operator is not | 129 | // Don't compare lastModified, otherwise the operator is not |
130 | // of much use. We are not comparing for identity, after all. | 130 | // of much use. We are not comparing for identity, after all. |
131 | i1.doesFloat() == i2.doesFloat() && | 131 | i1.doesFloat() == i2.doesFloat() && |
132 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 132 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
133 | // no need to compare mObserver | 133 | // no need to compare mObserver |
134 | } | 134 | } |
135 | 135 | ||
136 | 136 | ||
137 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 137 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
138 | { | 138 | { |
139 | QTime t = dt.time(); | 139 | QTime t = dt.time(); |
140 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 140 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
141 | return dt; | 141 | return dt; |
142 | } | 142 | } |
143 | 143 | ||
144 | bool IncidenceBase::isTagged() const | 144 | bool IncidenceBase::isTagged() const |
145 | { | 145 | { |
146 | return mIsTagged; | 146 | return mIsTagged; |
147 | } | 147 | } |
148 | void IncidenceBase::setTagged( bool b) | 148 | void IncidenceBase::setTagged( bool b) |
149 | { | 149 | { |
150 | mIsTagged = b; | 150 | mIsTagged = b; |
151 | } | 151 | } |
152 | void IncidenceBase::setCalID( int id ) | 152 | void IncidenceBase::setCalID( int id ) |
153 | { | 153 | { |
154 | if ( mCalID > 0 ) { | 154 | if ( mCalID > 0 ) { |
155 | blockLastModified = true; | 155 | blockLastModified = true; |
156 | updated(); | 156 | updated(); |
157 | blockLastModified = false; | 157 | blockLastModified = false; |
158 | } | 158 | } |
159 | mCalID = id; | 159 | mCalID = id; |
160 | } | 160 | } |
161 | int IncidenceBase::calID() const | 161 | int IncidenceBase::calID() const |
162 | { | 162 | { |
163 | return mCalID; | 163 | return mCalID; |
164 | } | 164 | } |
165 | void IncidenceBase::setCalEnabled( bool b ) | 165 | void IncidenceBase::setCalEnabled( bool b ) |
166 | { | 166 | { |
167 | mCalEnabled = b; | 167 | mCalEnabled = b; |
168 | } | 168 | } |
169 | bool IncidenceBase::calEnabled() const | 169 | bool IncidenceBase::calEnabled() const |
170 | { | 170 | { |
171 | return mCalEnabled; | 171 | return mCalEnabled; |
172 | } | 172 | } |
173 | 173 | ||
174 | void IncidenceBase::setAlarmEnabled( bool b ) | 174 | void IncidenceBase::setAlarmEnabled( bool b ) |
175 | { | 175 | { |
176 | mAlarmEnabled = b; | 176 | mAlarmEnabled = b; |
177 | } | 177 | } |
178 | bool IncidenceBase::alarmEnabled() const | 178 | bool IncidenceBase::alarmEnabled() const |
179 | { | 179 | { |
180 | return mAlarmEnabled; | 180 | return mAlarmEnabled; |
181 | } | 181 | } |
182 | 182 | ||
183 | 183 | ||
184 | void IncidenceBase::setUid(const QString &uid) | 184 | void IncidenceBase::setUid(const QString &uid) |
185 | { | 185 | { |
186 | mUid = uid; | 186 | mUid = uid; |
187 | updated(); | 187 | updated(); |
188 | } | 188 | } |
189 | 189 | ||
190 | QString IncidenceBase::uid() const | 190 | QString IncidenceBase::uid() const |
191 | { | 191 | { |
192 | return mUid; | 192 | return mUid; |
193 | } | 193 | } |
194 | void IncidenceBase::setLastModifiedSubInvalid() | 194 | void IncidenceBase::setLastModifiedSubInvalid() |
195 | { | 195 | { |
196 | 196 | // virtual method | |
197 | } | 197 | } |
198 | void IncidenceBase::setLastModified(const QDateTime &lm) | 198 | void IncidenceBase::setLastModified(const QDateTime &lm) |
199 | { | 199 | { |
200 | if ( blockLastModified ) return; | 200 | if ( blockLastModified ) return; |
201 | // DON'T! updated() because we call this from | 201 | // DON'T! updated() because we call this from |
202 | // Calendar::updateEvent(). | 202 | // Calendar::updateEvent(). |
203 | mLastModified = getEvenTime(lm); | 203 | mLastModified = getEvenTime(lm); |
204 | mLastModifiedKey.sprintf("%04d%02d%02d%02d%02d%02d", | ||
205 | mLastModified.date().year(), | ||
206 | mLastModified.date().month(), | ||
207 | mLastModified.date().day(), | ||
208 | mLastModified.time().hour(), | ||
209 | mLastModified.time().minute(), | ||
210 | mLastModified.time().second() ); | ||
204 | setLastModifiedSubInvalid(); | 211 | setLastModifiedSubInvalid(); |
205 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 212 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
206 | } | 213 | } |
214 | QString IncidenceBase::lastModifiedSortKey() const | ||
215 | { | ||
216 | return mLastModifiedKey; | ||
217 | } | ||
207 | 218 | ||
208 | QDateTime IncidenceBase::lastModified() const | 219 | QDateTime IncidenceBase::lastModified() const |
209 | { | 220 | { |
210 | return mLastModified; | 221 | return mLastModified; |
211 | } | 222 | } |
212 | 223 | ||
213 | void IncidenceBase::setOrganizer(const QString &o) | 224 | void IncidenceBase::setOrganizer(const QString &o) |
214 | { | 225 | { |
215 | // we don't check for readonly here, because it is | 226 | // we don't check for readonly here, because it is |
216 | // possible that by setting the organizer we are changing | 227 | // possible that by setting the organizer we are changing |
217 | // the event's readonly status... | 228 | // the event's readonly status... |
218 | mOrganizer = o; | 229 | mOrganizer = o; |
219 | if (mOrganizer.left(7).upper() == "MAILTO:") | 230 | if (mOrganizer.left(7).upper() == "MAILTO:") |
220 | mOrganizer = mOrganizer.remove(0,7); | 231 | mOrganizer = mOrganizer.remove(0,7); |
221 | 232 | ||
222 | updated(); | 233 | updated(); |
223 | } | 234 | } |
224 | 235 | ||
225 | QString IncidenceBase::organizer() const | 236 | QString IncidenceBase::organizer() const |
226 | { | 237 | { |
227 | return mOrganizer; | 238 | return mOrganizer; |
228 | } | 239 | } |
229 | 240 | ||
230 | void IncidenceBase::setReadOnly( bool readOnly ) | 241 | void IncidenceBase::setReadOnly( bool readOnly ) |
231 | { | 242 | { |
232 | mReadOnly = readOnly; | 243 | mReadOnly = readOnly; |
233 | } | 244 | } |
234 | 245 | ||
235 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 246 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
236 | { | 247 | { |
237 | // if (mReadOnly) return; | 248 | // if (mReadOnly) return; |
238 | mDtStart = getEvenTime(dtStart); | 249 | mDtStart = getEvenTime(dtStart); |
239 | updated(); | 250 | updated(); |
240 | } | 251 | } |
241 | 252 | ||
242 | 253 | ||
243 | QDateTime IncidenceBase::dtStart() const | 254 | QDateTime IncidenceBase::dtStart() const |
244 | { | 255 | { |
245 | return mDtStart; | 256 | return mDtStart; |
246 | } | 257 | } |
247 | 258 | ||
248 | QString IncidenceBase::dtStartTimeStr() const | 259 | QString IncidenceBase::dtStartTimeStr() const |
249 | { | 260 | { |
250 | return KGlobal::locale()->formatTime(dtStart().time()); | 261 | return KGlobal::locale()->formatTime(dtStart().time()); |
251 | } | 262 | } |
252 | 263 | ||
253 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 264 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
254 | { | 265 | { |
255 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 266 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
256 | } | 267 | } |
257 | 268 | ||
258 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 269 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
259 | { | 270 | { |
260 | if ( doesFloat() ) | 271 | if ( doesFloat() ) |
261 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 272 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
262 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 273 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
263 | } | 274 | } |
264 | 275 | ||
265 | 276 | ||
266 | bool IncidenceBase::doesFloat() const | 277 | bool IncidenceBase::doesFloat() const |
267 | { | 278 | { |
268 | return mFloats; | 279 | return mFloats; |
269 | } | 280 | } |
270 | 281 | ||
271 | void IncidenceBase::setFloats(bool f) | 282 | void IncidenceBase::setFloats(bool f) |
272 | { | 283 | { |
273 | if (mReadOnly) return; | 284 | if (mReadOnly) return; |
274 | mFloats = f; | 285 | mFloats = f; |
275 | updated(); | 286 | updated(); |
276 | } | 287 | } |
277 | 288 | ||
278 | 289 | ||
279 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 290 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
280 | { | 291 | { |
281 | if (mReadOnly) return false; | 292 | if (mReadOnly) return false; |
282 | if (a->name().left(7).upper() == "MAILTO:") | 293 | if (a->name().left(7).upper() == "MAILTO:") |
283 | a->setName(a->name().remove(0,7)); | 294 | a->setName(a->name().remove(0,7)); |
284 | 295 | ||
285 | QPtrListIterator<Attendee> qli(mAttendees); | 296 | QPtrListIterator<Attendee> qli(mAttendees); |
286 | 297 | ||
287 | qli.toFirst(); | 298 | qli.toFirst(); |
288 | while (qli) { | 299 | while (qli) { |
289 | if (*qli.current() == *a) | 300 | if (*qli.current() == *a) |
290 | return false; | 301 | return false; |
291 | ++qli; | 302 | ++qli; |
292 | } | 303 | } |
293 | mAttendees.append(a); | 304 | mAttendees.append(a); |
294 | if (doupdate) updated(); | 305 | if (doupdate) updated(); |
295 | return true; | 306 | return true; |
296 | } | 307 | } |
297 | 308 | ||
298 | #if 0 | 309 | #if 0 |
299 | void IncidenceBase::removeAttendee(Attendee *a) | 310 | void IncidenceBase::removeAttendee(Attendee *a) |
300 | { | 311 | { |
301 | if (mReadOnly) return; | 312 | if (mReadOnly) return; |
302 | mAttendees.removeRef(a); | 313 | mAttendees.removeRef(a); |
303 | updated(); | 314 | updated(); |
304 | } | 315 | } |
305 | 316 | ||
306 | void IncidenceBase::removeAttendee(const char *n) | 317 | void IncidenceBase::removeAttendee(const char *n) |
307 | { | 318 | { |
308 | Attendee *a; | 319 | Attendee *a; |
309 | 320 | ||
310 | if (mReadOnly) return; | 321 | if (mReadOnly) return; |
311 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 322 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
312 | if (a->getName() == n) { | 323 | if (a->getName() == n) { |
313 | mAttendees.remove(); | 324 | mAttendees.remove(); |
314 | break; | 325 | break; |
315 | } | 326 | } |
316 | } | 327 | } |
317 | #endif | 328 | #endif |
318 | 329 | ||
319 | void IncidenceBase::clearAttendees() | 330 | void IncidenceBase::clearAttendees() |
320 | { | 331 | { |
321 | if (mReadOnly) return; | 332 | if (mReadOnly) return; |
322 | mAttendees.clear(); | 333 | mAttendees.clear(); |
323 | } | 334 | } |
324 | 335 | ||
325 | #if 0 | 336 | #if 0 |
326 | Attendee *IncidenceBase::getAttendee(const char *n) const | 337 | Attendee *IncidenceBase::getAttendee(const char *n) const |
327 | { | 338 | { |
328 | QPtrListIterator<Attendee> qli(mAttendees); | 339 | QPtrListIterator<Attendee> qli(mAttendees); |
329 | 340 | ||
330 | qli.toFirst(); | 341 | qli.toFirst(); |
331 | while (qli) { | 342 | while (qli) { |
332 | if (qli.current()->getName() == n) | 343 | if (qli.current()->getName() == n) |
333 | return qli.current(); | 344 | return qli.current(); |
334 | ++qli; | 345 | ++qli; |
335 | } | 346 | } |
336 | return 0L; | 347 | return 0L; |
337 | } | 348 | } |
338 | #endif | 349 | #endif |
339 | 350 | ||
340 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 351 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
341 | { | 352 | { |
342 | QPtrListIterator<Attendee> qli(mAttendees); | 353 | QPtrListIterator<Attendee> qli(mAttendees); |
343 | 354 | ||
344 | qli.toFirst(); | 355 | qli.toFirst(); |
345 | while (qli) { | 356 | while (qli) { |
346 | if (qli.current()->email().lower() == email.lower()) | 357 | if (qli.current()->email().lower() == email.lower()) |
347 | return qli.current(); | 358 | return qli.current(); |
348 | ++qli; | 359 | ++qli; |
349 | } | 360 | } |
350 | return 0L; | 361 | return 0L; |
351 | } | 362 | } |
352 | 363 | ||
353 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 364 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
354 | { | 365 | { |
355 | QPtrListIterator<Attendee> qli(mAttendees); | 366 | QPtrListIterator<Attendee> qli(mAttendees); |
356 | 367 | ||
357 | QStringList mails = emails; | 368 | QStringList mails = emails; |
358 | if (!email.isEmpty()) { | 369 | if (!email.isEmpty()) { |
359 | mails.append(email); | 370 | mails.append(email); |
360 | } | 371 | } |
361 | qli.toFirst(); | 372 | qli.toFirst(); |
362 | while (qli) { | 373 | while (qli) { |
363 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 374 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
364 | if (qli.current()->email().lower() == (*it).lower()) | 375 | if (qli.current()->email().lower() == (*it).lower()) |
365 | return qli.current(); | 376 | return qli.current(); |
366 | } | 377 | } |
367 | 378 | ||
368 | ++qli; | 379 | ++qli; |
369 | } | 380 | } |
370 | return 0L; | 381 | return 0L; |
371 | } | 382 | } |
372 | 383 | ||
373 | void IncidenceBase::setDuration(int seconds) | 384 | void IncidenceBase::setDuration(int seconds) |
374 | { | 385 | { |
375 | mDuration = seconds; | 386 | mDuration = seconds; |
376 | setHasDuration(true); | 387 | setHasDuration(true); |
377 | } | 388 | } |
378 | 389 | ||
379 | int IncidenceBase::duration() const | 390 | int IncidenceBase::duration() const |
380 | { | 391 | { |
381 | return mDuration; | 392 | return mDuration; |
382 | } | 393 | } |
383 | 394 | ||
384 | void IncidenceBase::setHasDuration(bool b) | 395 | void IncidenceBase::setHasDuration(bool b) |
385 | { | 396 | { |
386 | mHasDuration = b; | 397 | mHasDuration = b; |
387 | } | 398 | } |
388 | 399 | ||
389 | bool IncidenceBase::hasDuration() const | 400 | bool IncidenceBase::hasDuration() const |
390 | { | 401 | { |
391 | return mHasDuration; | 402 | return mHasDuration; |
392 | } | 403 | } |
393 | 404 | ||
394 | void IncidenceBase::setSyncStatus(int stat) | 405 | void IncidenceBase::setSyncStatus(int stat) |
395 | { | 406 | { |
396 | if (mReadOnly) return; | 407 | if (mReadOnly) return; |
397 | mSyncStatus = stat; | 408 | mSyncStatus = stat; |
398 | } | 409 | } |