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