author | zautrix <zautrix> | 2005-06-10 20:13:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-10 20:13:31 (UTC) |
commit | cdc55afb3d2c3ebd970843b7dce02acb1e6a189b (patch) (unidiff) | |
tree | 45f3bfa69a72de4e8b53bbcb2414478ec65cd183 /libkcal/incidencebase.cpp | |
parent | 31fed261955dcb25d06052a8154ac4cc630b0f7d (diff) | |
download | kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.zip kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.gz kdepimpi-cdc55afb3d2c3ebd970843b7dce02acb1e6a189b.tar.bz2 |
many preparations for multiple calendars
-rw-r--r-- | libkcal/incidencebase.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index b5fe2e6..2ddbb01 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -1,429 +1,462 @@ | |||
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 | #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 | setUid(CalFormat::createUniqueId()); | 37 | setUid(CalFormat::createUniqueId()); |
38 | mOrganizer = ""; | 38 | mOrganizer = ""; |
39 | mFloats = false; | 39 | mFloats = false; |
40 | mDuration = 0; | 40 | mDuration = 0; |
41 | mHasDuration = false; | 41 | mHasDuration = false; |
42 | mPilotId = 0; | 42 | mPilotId = 0; |
43 | mExternalId = ":"; | 43 | mExternalId = ":"; |
44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; | 44 | mTempSyncStat = SYNC_TEMPSTATE_INITIAL; |
45 | mSyncStatus = 0; | 45 | mSyncStatus = 0; |
46 | mAttendees.setAutoDelete( true ); | 46 | mAttendees.setAutoDelete( true ); |
47 | mCalEnabled = true; | ||
48 | mAlarmEnabled = true; | ||
49 | mCalID = 0; | ||
47 | } | 50 | } |
48 | 51 | ||
49 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : | 52 | IncidenceBase::IncidenceBase(const IncidenceBase &i) : |
50 | CustomProperties( i ) | 53 | CustomProperties( i ) |
51 | { | 54 | { |
55 | |||
52 | mReadOnly = i.mReadOnly; | 56 | mReadOnly = i.mReadOnly; |
53 | mDtStart = i.mDtStart; | 57 | mDtStart = i.mDtStart; |
54 | mDuration = i.mDuration; | 58 | mDuration = i.mDuration; |
55 | mHasDuration = i.mHasDuration; | 59 | mHasDuration = i.mHasDuration; |
56 | mOrganizer = i.mOrganizer; | 60 | mOrganizer = i.mOrganizer; |
57 | mUid = i.mUid; | 61 | mUid = i.mUid; |
62 | mCalEnabled = i.mCalEnabled; | ||
63 | mAlarmEnabled = i.mAlarmEnabled; | ||
64 | mCalID = i.mCalID; | ||
58 | QPtrList<Attendee> attendees = i.attendees(); | 65 | QPtrList<Attendee> attendees = i.attendees(); |
59 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { | 66 | for( Attendee *a = attendees.first(); a; a = attendees.next() ) { |
60 | mAttendees.append( new Attendee( *a ) ); | 67 | mAttendees.append( new Attendee( *a ) ); |
61 | } | 68 | } |
62 | mFloats = i.mFloats; | 69 | mFloats = i.mFloats; |
63 | mLastModified = i.mLastModified; | 70 | mLastModified = i.mLastModified; |
64 | mPilotId = i.mPilotId; | 71 | mPilotId = i.mPilotId; |
65 | mTempSyncStat = i.mTempSyncStat; | 72 | mTempSyncStat = i.mTempSyncStat; |
66 | mSyncStatus = i.mSyncStatus; | 73 | mSyncStatus = i.mSyncStatus; |
67 | mExternalId = i.mExternalId; | 74 | mExternalId = i.mExternalId; |
68 | // The copied object is a new one, so it isn't observed by the observer | 75 | // The copied object is a new one, so it isn't observed by the observer |
69 | // of the original object. | 76 | // of the original object. |
70 | mObservers.clear(); | 77 | mObservers.clear(); |
71 | 78 | ||
72 | mAttendees.setAutoDelete( true ); | 79 | mAttendees.setAutoDelete( true ); |
73 | } | 80 | } |
74 | 81 | ||
75 | IncidenceBase::~IncidenceBase() | 82 | IncidenceBase::~IncidenceBase() |
76 | { | 83 | { |
77 | } | 84 | } |
78 | 85 | ||
79 | 86 | ||
80 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) | 87 | bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) |
81 | { | 88 | { |
82 | // do not compare mSyncStatus and mExternalId | 89 | // do not compare mSyncStatus and mExternalId |
83 | if( i1.attendees().count() != i2.attendees().count() ) { | 90 | if( i1.attendees().count() != i2.attendees().count() ) { |
84 | return false; // no need to check further | 91 | return false; // no need to check further |
85 | } | 92 | } |
86 | if ( i1.attendees().count() > 0 ) { | 93 | if ( i1.attendees().count() > 0 ) { |
87 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; | 94 | Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; |
88 | while ( a1 ) { | 95 | while ( a1 ) { |
89 | if ( !( (*a1) == (*a2)) ) | 96 | if ( !( (*a1) == (*a2)) ) |
90 | { | 97 | { |
91 | //qDebug("Attendee not equal "); | 98 | //qDebug("Attendee not equal "); |
92 | return false; | 99 | return false; |
93 | } | 100 | } |
94 | a1 = i1.attendees().next(); | 101 | a1 = i1.attendees().next(); |
95 | a2 = i2.attendees().next(); | 102 | a2 = i2.attendees().next(); |
96 | } | 103 | } |
97 | } | 104 | } |
98 | //if ( i1.dtStart() != i2.dtStart() ) | 105 | //if ( i1.dtStart() != i2.dtStart() ) |
99 | // return false; | 106 | // return false; |
100 | #if 0 | 107 | #if 0 |
101 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); | 108 | qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); |
102 | qDebug("1 %d ",i1.duration() == i2.duration() ); | 109 | qDebug("1 %d ",i1.duration() == i2.duration() ); |
103 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); | 110 | qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); |
104 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); | 111 | qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); |
105 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); | 112 | qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); |
106 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); | 113 | qDebug("6 %d ",i1.organizer() == i2.organizer() ); |
107 | 114 | ||
108 | #endif | 115 | #endif |
109 | if ( i1.hasDuration() == i2.hasDuration() ) { | 116 | if ( i1.hasDuration() == i2.hasDuration() ) { |
110 | if ( i1.hasDuration() ) { | 117 | if ( i1.hasDuration() ) { |
111 | if ( i1.duration() != i2.duration() ) | 118 | if ( i1.duration() != i2.duration() ) |
112 | return false; | 119 | return false; |
113 | } | 120 | } |
114 | } else { | 121 | } else { |
115 | return false; | 122 | return false; |
116 | } | 123 | } |
117 | 124 | ||
118 | return ( i1.organizer() == i2.organizer() && | 125 | return ( i1.organizer() == i2.organizer() && |
119 | // i1.uid() == i2.uid() && | 126 | // i1.uid() == i2.uid() && |
120 | // Don't compare lastModified, otherwise the operator is not | 127 | // Don't compare lastModified, otherwise the operator is not |
121 | // of much use. We are not comparing for identity, after all. | 128 | // of much use. We are not comparing for identity, after all. |
122 | i1.doesFloat() == i2.doesFloat() && | 129 | i1.doesFloat() == i2.doesFloat() && |
123 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); | 130 | i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); |
124 | // no need to compare mObserver | 131 | // no need to compare mObserver |
125 | } | 132 | } |
126 | 133 | ||
127 | 134 | ||
128 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | 135 | QDateTime IncidenceBase::getEvenTime( QDateTime dt ) |
129 | { | 136 | { |
130 | QTime t = dt.time(); | 137 | QTime t = dt.time(); |
131 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
132 | return dt; | 139 | return dt; |
133 | } | 140 | } |
134 | 141 | ||
142 | void IncidenceBase::setCalID( int id ) | ||
143 | { | ||
144 | mCalID = id; | ||
145 | } | ||
146 | int IncidenceBase::calID() const | ||
147 | { | ||
148 | return mCalID; | ||
149 | } | ||
150 | void IncidenceBase::setCalEnabled( bool b ) | ||
151 | { | ||
152 | mCalEnabled = b; | ||
153 | } | ||
154 | bool IncidenceBase::calEnabled() const | ||
155 | { | ||
156 | return mCalEnabled; | ||
157 | } | ||
158 | |||
159 | void IncidenceBase::setAlarmEnabled( bool b ) | ||
160 | { | ||
161 | mAlarmEnabled = b; | ||
162 | } | ||
163 | bool IncidenceBase::alarmEnabled() const | ||
164 | { | ||
165 | return mAlarmEnabled; | ||
166 | } | ||
167 | |||
135 | 168 | ||
136 | void IncidenceBase::setUid(const QString &uid) | 169 | void IncidenceBase::setUid(const QString &uid) |
137 | { | 170 | { |
138 | mUid = uid; | 171 | mUid = uid; |
139 | updated(); | 172 | updated(); |
140 | } | 173 | } |
141 | 174 | ||
142 | QString IncidenceBase::uid() const | 175 | QString IncidenceBase::uid() const |
143 | { | 176 | { |
144 | return mUid; | 177 | return mUid; |
145 | } | 178 | } |
146 | 179 | ||
147 | void IncidenceBase::setLastModified(const QDateTime &lm) | 180 | void IncidenceBase::setLastModified(const QDateTime &lm) |
148 | { | 181 | { |
149 | // DON'T! updated() because we call this from | 182 | // DON'T! updated() because we call this from |
150 | // Calendar::updateEvent(). | 183 | // Calendar::updateEvent(). |
151 | mLastModified = getEvenTime(lm); | 184 | mLastModified = getEvenTime(lm); |
152 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); | 185 | //qDebug("IncidenceBase::setLastModified %s ",lm.toString().latin1()); |
153 | } | 186 | } |
154 | 187 | ||
155 | QDateTime IncidenceBase::lastModified() const | 188 | QDateTime IncidenceBase::lastModified() const |
156 | { | 189 | { |
157 | return mLastModified; | 190 | return mLastModified; |
158 | } | 191 | } |
159 | 192 | ||
160 | void IncidenceBase::setOrganizer(const QString &o) | 193 | void IncidenceBase::setOrganizer(const QString &o) |
161 | { | 194 | { |
162 | // we don't check for readonly here, because it is | 195 | // we don't check for readonly here, because it is |
163 | // possible that by setting the organizer we are changing | 196 | // possible that by setting the organizer we are changing |
164 | // the event's readonly status... | 197 | // the event's readonly status... |
165 | mOrganizer = o; | 198 | mOrganizer = o; |
166 | if (mOrganizer.left(7).upper() == "MAILTO:") | 199 | if (mOrganizer.left(7).upper() == "MAILTO:") |
167 | mOrganizer = mOrganizer.remove(0,7); | 200 | mOrganizer = mOrganizer.remove(0,7); |
168 | 201 | ||
169 | updated(); | 202 | updated(); |
170 | } | 203 | } |
171 | 204 | ||
172 | QString IncidenceBase::organizer() const | 205 | QString IncidenceBase::organizer() const |
173 | { | 206 | { |
174 | return mOrganizer; | 207 | return mOrganizer; |
175 | } | 208 | } |
176 | 209 | ||
177 | void IncidenceBase::setReadOnly( bool readOnly ) | 210 | void IncidenceBase::setReadOnly( bool readOnly ) |
178 | { | 211 | { |
179 | mReadOnly = readOnly; | 212 | mReadOnly = readOnly; |
180 | } | 213 | } |
181 | 214 | ||
182 | void IncidenceBase::setDtStart(const QDateTime &dtStart) | 215 | void IncidenceBase::setDtStart(const QDateTime &dtStart) |
183 | { | 216 | { |
184 | // if (mReadOnly) return; | 217 | // if (mReadOnly) return; |
185 | mDtStart = getEvenTime(dtStart); | 218 | mDtStart = getEvenTime(dtStart); |
186 | updated(); | 219 | updated(); |
187 | } | 220 | } |
188 | 221 | ||
189 | 222 | ||
190 | QDateTime IncidenceBase::dtStart() const | 223 | QDateTime IncidenceBase::dtStart() const |
191 | { | 224 | { |
192 | return mDtStart; | 225 | return mDtStart; |
193 | } | 226 | } |
194 | 227 | ||
195 | QString IncidenceBase::dtStartTimeStr() const | 228 | QString IncidenceBase::dtStartTimeStr() const |
196 | { | 229 | { |
197 | return KGlobal::locale()->formatTime(dtStart().time()); | 230 | return KGlobal::locale()->formatTime(dtStart().time()); |
198 | } | 231 | } |
199 | 232 | ||
200 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const | 233 | QString IncidenceBase::dtStartDateStr(bool shortfmt) const |
201 | { | 234 | { |
202 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 235 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
203 | } | 236 | } |
204 | 237 | ||
205 | QString IncidenceBase::dtStartStr(bool shortfmt) const | 238 | QString IncidenceBase::dtStartStr(bool shortfmt) const |
206 | { | 239 | { |
207 | if ( doesFloat() ) | 240 | if ( doesFloat() ) |
208 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); | 241 | return KGlobal::locale()->formatDate(dtStart().date(),shortfmt); |
209 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); | 242 | return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); |
210 | } | 243 | } |
211 | 244 | ||
212 | 245 | ||
213 | bool IncidenceBase::doesFloat() const | 246 | bool IncidenceBase::doesFloat() const |
214 | { | 247 | { |
215 | return mFloats; | 248 | return mFloats; |
216 | } | 249 | } |
217 | 250 | ||
218 | void IncidenceBase::setFloats(bool f) | 251 | void IncidenceBase::setFloats(bool f) |
219 | { | 252 | { |
220 | if (mReadOnly) return; | 253 | if (mReadOnly) return; |
221 | mFloats = f; | 254 | mFloats = f; |
222 | updated(); | 255 | updated(); |
223 | } | 256 | } |
224 | 257 | ||
225 | 258 | ||
226 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) | 259 | bool IncidenceBase::addAttendee(Attendee *a, bool doupdate) |
227 | { | 260 | { |
228 | if (mReadOnly) return false; | 261 | if (mReadOnly) return false; |
229 | if (a->name().left(7).upper() == "MAILTO:") | 262 | if (a->name().left(7).upper() == "MAILTO:") |
230 | a->setName(a->name().remove(0,7)); | 263 | a->setName(a->name().remove(0,7)); |
231 | 264 | ||
232 | QPtrListIterator<Attendee> qli(mAttendees); | 265 | QPtrListIterator<Attendee> qli(mAttendees); |
233 | 266 | ||
234 | qli.toFirst(); | 267 | qli.toFirst(); |
235 | while (qli) { | 268 | while (qli) { |
236 | if (*qli.current() == *a) | 269 | if (*qli.current() == *a) |
237 | return false; | 270 | return false; |
238 | ++qli; | 271 | ++qli; |
239 | } | 272 | } |
240 | mAttendees.append(a); | 273 | mAttendees.append(a); |
241 | if (doupdate) updated(); | 274 | if (doupdate) updated(); |
242 | return true; | 275 | return true; |
243 | } | 276 | } |
244 | 277 | ||
245 | #if 0 | 278 | #if 0 |
246 | void IncidenceBase::removeAttendee(Attendee *a) | 279 | void IncidenceBase::removeAttendee(Attendee *a) |
247 | { | 280 | { |
248 | if (mReadOnly) return; | 281 | if (mReadOnly) return; |
249 | mAttendees.removeRef(a); | 282 | mAttendees.removeRef(a); |
250 | updated(); | 283 | updated(); |
251 | } | 284 | } |
252 | 285 | ||
253 | void IncidenceBase::removeAttendee(const char *n) | 286 | void IncidenceBase::removeAttendee(const char *n) |
254 | { | 287 | { |
255 | Attendee *a; | 288 | Attendee *a; |
256 | 289 | ||
257 | if (mReadOnly) return; | 290 | if (mReadOnly) return; |
258 | for (a = mAttendees.first(); a; a = mAttendees.next()) | 291 | for (a = mAttendees.first(); a; a = mAttendees.next()) |
259 | if (a->getName() == n) { | 292 | if (a->getName() == n) { |
260 | mAttendees.remove(); | 293 | mAttendees.remove(); |
261 | break; | 294 | break; |
262 | } | 295 | } |
263 | } | 296 | } |
264 | #endif | 297 | #endif |
265 | 298 | ||
266 | void IncidenceBase::clearAttendees() | 299 | void IncidenceBase::clearAttendees() |
267 | { | 300 | { |
268 | if (mReadOnly) return; | 301 | if (mReadOnly) return; |
269 | mAttendees.clear(); | 302 | mAttendees.clear(); |
270 | } | 303 | } |
271 | 304 | ||
272 | #if 0 | 305 | #if 0 |
273 | Attendee *IncidenceBase::getAttendee(const char *n) const | 306 | Attendee *IncidenceBase::getAttendee(const char *n) const |
274 | { | 307 | { |
275 | QPtrListIterator<Attendee> qli(mAttendees); | 308 | QPtrListIterator<Attendee> qli(mAttendees); |
276 | 309 | ||
277 | qli.toFirst(); | 310 | qli.toFirst(); |
278 | while (qli) { | 311 | while (qli) { |
279 | if (qli.current()->getName() == n) | 312 | if (qli.current()->getName() == n) |
280 | return qli.current(); | 313 | return qli.current(); |
281 | ++qli; | 314 | ++qli; |
282 | } | 315 | } |
283 | return 0L; | 316 | return 0L; |
284 | } | 317 | } |
285 | #endif | 318 | #endif |
286 | 319 | ||
287 | Attendee *IncidenceBase::attendeeByMail(const QString &email) | 320 | Attendee *IncidenceBase::attendeeByMail(const QString &email) |
288 | { | 321 | { |
289 | QPtrListIterator<Attendee> qli(mAttendees); | 322 | QPtrListIterator<Attendee> qli(mAttendees); |
290 | 323 | ||
291 | qli.toFirst(); | 324 | qli.toFirst(); |
292 | while (qli) { | 325 | while (qli) { |
293 | if (qli.current()->email().lower() == email.lower()) | 326 | if (qli.current()->email().lower() == email.lower()) |
294 | return qli.current(); | 327 | return qli.current(); |
295 | ++qli; | 328 | ++qli; |
296 | } | 329 | } |
297 | return 0L; | 330 | return 0L; |
298 | } | 331 | } |
299 | 332 | ||
300 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) | 333 | Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) |
301 | { | 334 | { |
302 | QPtrListIterator<Attendee> qli(mAttendees); | 335 | QPtrListIterator<Attendee> qli(mAttendees); |
303 | 336 | ||
304 | QStringList mails = emails; | 337 | QStringList mails = emails; |
305 | if (!email.isEmpty()) { | 338 | if (!email.isEmpty()) { |
306 | mails.append(email); | 339 | mails.append(email); |
307 | } | 340 | } |
308 | qli.toFirst(); | 341 | qli.toFirst(); |
309 | while (qli) { | 342 | while (qli) { |
310 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { | 343 | for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { |
311 | if (qli.current()->email().lower() == (*it).lower()) | 344 | if (qli.current()->email().lower() == (*it).lower()) |
312 | return qli.current(); | 345 | return qli.current(); |
313 | } | 346 | } |
314 | 347 | ||
315 | ++qli; | 348 | ++qli; |
316 | } | 349 | } |
317 | return 0L; | 350 | return 0L; |
318 | } | 351 | } |
319 | 352 | ||
320 | void IncidenceBase::setDuration(int seconds) | 353 | void IncidenceBase::setDuration(int seconds) |
321 | { | 354 | { |
322 | mDuration = seconds; | 355 | mDuration = seconds; |
323 | setHasDuration(true); | 356 | setHasDuration(true); |
324 | } | 357 | } |
325 | 358 | ||
326 | int IncidenceBase::duration() const | 359 | int IncidenceBase::duration() const |
327 | { | 360 | { |
328 | return mDuration; | 361 | return mDuration; |
329 | } | 362 | } |
330 | 363 | ||
331 | void IncidenceBase::setHasDuration(bool b) | 364 | void IncidenceBase::setHasDuration(bool b) |
332 | { | 365 | { |
333 | mHasDuration = b; | 366 | mHasDuration = b; |
334 | } | 367 | } |
335 | 368 | ||
336 | bool IncidenceBase::hasDuration() const | 369 | bool IncidenceBase::hasDuration() const |
337 | { | 370 | { |
338 | return mHasDuration; | 371 | return mHasDuration; |
339 | } | 372 | } |
340 | 373 | ||
341 | void IncidenceBase::setSyncStatus(int stat) | 374 | void IncidenceBase::setSyncStatus(int stat) |
342 | { | 375 | { |
343 | if (mReadOnly) return; | 376 | if (mReadOnly) return; |
344 | mSyncStatus = stat; | 377 | mSyncStatus = stat; |
345 | } | 378 | } |
346 | 379 | ||
347 | int IncidenceBase::syncStatus() const | 380 | int IncidenceBase::syncStatus() const |
348 | { | 381 | { |
349 | return mSyncStatus; | 382 | return mSyncStatus; |
350 | } | 383 | } |
351 | 384 | ||
352 | void IncidenceBase::setPilotId( int id ) | 385 | void IncidenceBase::setPilotId( int id ) |
353 | { | 386 | { |
354 | if (mReadOnly) return; | 387 | if (mReadOnly) return; |
355 | mPilotId = id; | 388 | mPilotId = id; |
356 | } | 389 | } |
357 | 390 | ||
358 | int IncidenceBase::pilotId() const | 391 | int IncidenceBase::pilotId() const |
359 | { | 392 | { |
360 | return mPilotId; | 393 | return mPilotId; |
361 | } | 394 | } |
362 | 395 | ||
363 | int IncidenceBase::tempSyncStat() const | 396 | int IncidenceBase::tempSyncStat() const |
364 | { | 397 | { |
365 | return mTempSyncStat; | 398 | return mTempSyncStat; |
366 | } | 399 | } |
367 | void IncidenceBase::setTempSyncStat( int id ) | 400 | void IncidenceBase::setTempSyncStat( int id ) |
368 | { | 401 | { |
369 | if (mReadOnly) return; | 402 | if (mReadOnly) return; |
370 | mTempSyncStat = id; | 403 | mTempSyncStat = id; |
371 | } | 404 | } |
372 | 405 | ||
373 | void IncidenceBase::removeID(const QString &prof) | 406 | void IncidenceBase::removeID(const QString &prof) |
374 | { | 407 | { |
375 | if ( prof.isEmpty() ) | 408 | if ( prof.isEmpty() ) |
376 | mExternalId = ":"; | 409 | mExternalId = ":"; |
377 | else | 410 | else |
378 | mExternalId = KIdManager::removeId ( mExternalId, prof); | 411 | mExternalId = KIdManager::removeId ( mExternalId, prof); |
379 | 412 | ||
380 | } | 413 | } |
381 | void IncidenceBase::setID( const QString & prof , const QString & id ) | 414 | void IncidenceBase::setID( const QString & prof , const QString & id ) |
382 | { | 415 | { |
383 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); | 416 | mExternalId = KIdManager::setId ( mExternalId, prof, id ); |
384 | } | 417 | } |
385 | QString IncidenceBase::getID( const QString & prof) | 418 | QString IncidenceBase::getID( const QString & prof) |
386 | { | 419 | { |
387 | return KIdManager::getId ( mExternalId, prof ); | 420 | return KIdManager::getId ( mExternalId, prof ); |
388 | } | 421 | } |
389 | 422 | ||
390 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: | 423 | // example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: |
391 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 | 424 | // format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 |
392 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) | 425 | void IncidenceBase::setCsum( const QString & prof , const QString & id ) |
393 | { | 426 | { |
394 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); | 427 | mExternalId = KIdManager::setCsum ( mExternalId, prof, id ); |
395 | } | 428 | } |
396 | QString IncidenceBase::getCsum( const QString & prof) | 429 | QString IncidenceBase::getCsum( const QString & prof) |
397 | { | 430 | { |
398 | return KIdManager::getCsum ( mExternalId, prof ); | 431 | return KIdManager::getCsum ( mExternalId, prof ); |
399 | } | 432 | } |
400 | 433 | ||
401 | void IncidenceBase::setIDStr( const QString & s ) | 434 | void IncidenceBase::setIDStr( const QString & s ) |
402 | { | 435 | { |
403 | if (mReadOnly) return; | 436 | if (mReadOnly) return; |
404 | mExternalId = s; | 437 | mExternalId = s; |
405 | } | 438 | } |
406 | 439 | ||
407 | QString IncidenceBase::IDStr() const | 440 | QString IncidenceBase::IDStr() const |
408 | { | 441 | { |
409 | return mExternalId ; | 442 | return mExternalId ; |
410 | } | 443 | } |
411 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 444 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) |
412 | { | 445 | { |
413 | if( !mObservers.contains(observer) ) mObservers.append( observer ); | 446 | if( !mObservers.contains(observer) ) mObservers.append( observer ); |
414 | } | 447 | } |
415 | 448 | ||
416 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 449 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
417 | { | 450 | { |
418 | mObservers.remove( observer ); | 451 | mObservers.remove( observer ); |
419 | } | 452 | } |
420 | 453 | ||
421 | void IncidenceBase::updated() | 454 | void IncidenceBase::updated() |
422 | { | 455 | { |
423 | QPtrListIterator<Observer> it(mObservers); | 456 | QPtrListIterator<Observer> it(mObservers); |
424 | while( it.current() ) { | 457 | while( it.current() ) { |
425 | Observer *o = it.current(); | 458 | Observer *o = it.current(); |
426 | ++it; | 459 | ++it; |
427 | o->incidenceUpdated( this ); | 460 | o->incidenceUpdated( this ); |
428 | } | 461 | } |
429 | } | 462 | } |