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