summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidencebase.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index d7c4595..f1db8b7 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -197,274 +197,278 @@ QString IncidenceBase::dtStartDateStr(bool shortfmt) const
197} 197}
198 198
199QString IncidenceBase::dtStartStr(bool shortfmt) const 199QString IncidenceBase::dtStartStr(bool shortfmt) const
200{ 200{
201 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt); 201 return KGlobal::locale()->formatDateTime(dtStart(), shortfmt);
202} 202}
203 203
204 204
205bool IncidenceBase::doesFloat() const 205bool IncidenceBase::doesFloat() const
206{ 206{
207 return mFloats; 207 return mFloats;
208} 208}
209 209
210void IncidenceBase::setFloats(bool f) 210void IncidenceBase::setFloats(bool f)
211{ 211{
212 if (mReadOnly) return; 212 if (mReadOnly) return;
213 mFloats = f; 213 mFloats = f;
214 updated(); 214 updated();
215} 215}
216 216
217 217
218void IncidenceBase::addAttendee(Attendee *a, bool doupdate) 218void IncidenceBase::addAttendee(Attendee *a, bool doupdate)
219{ 219{
220 if (mReadOnly) return; 220 if (mReadOnly) return;
221 if (a->name().left(7).upper() == "MAILTO:") 221 if (a->name().left(7).upper() == "MAILTO:")
222 a->setName(a->name().remove(0,7)); 222 a->setName(a->name().remove(0,7));
223 223
224 mAttendees.append(a); 224 mAttendees.append(a);
225 if (doupdate) updated(); 225 if (doupdate) updated();
226} 226}
227 227
228#if 0 228#if 0
229void IncidenceBase::removeAttendee(Attendee *a) 229void IncidenceBase::removeAttendee(Attendee *a)
230{ 230{
231 if (mReadOnly) return; 231 if (mReadOnly) return;
232 mAttendees.removeRef(a); 232 mAttendees.removeRef(a);
233 updated(); 233 updated();
234} 234}
235 235
236void IncidenceBase::removeAttendee(const char *n) 236void IncidenceBase::removeAttendee(const char *n)
237{ 237{
238 Attendee *a; 238 Attendee *a;
239 239
240 if (mReadOnly) return; 240 if (mReadOnly) return;
241 for (a = mAttendees.first(); a; a = mAttendees.next()) 241 for (a = mAttendees.first(); a; a = mAttendees.next())
242 if (a->getName() == n) { 242 if (a->getName() == n) {
243 mAttendees.remove(); 243 mAttendees.remove();
244 break; 244 break;
245 } 245 }
246} 246}
247#endif 247#endif
248 248
249void IncidenceBase::clearAttendees() 249void IncidenceBase::clearAttendees()
250{ 250{
251 if (mReadOnly) return; 251 if (mReadOnly) return;
252 mAttendees.clear(); 252 mAttendees.clear();
253} 253}
254 254
255#if 0 255#if 0
256Attendee *IncidenceBase::getAttendee(const char *n) const 256Attendee *IncidenceBase::getAttendee(const char *n) const
257{ 257{
258 QPtrListIterator<Attendee> qli(mAttendees); 258 QPtrListIterator<Attendee> qli(mAttendees);
259 259
260 qli.toFirst(); 260 qli.toFirst();
261 while (qli) { 261 while (qli) {
262 if (qli.current()->getName() == n) 262 if (qli.current()->getName() == n)
263 return qli.current(); 263 return qli.current();
264 ++qli; 264 ++qli;
265 } 265 }
266 return 0L; 266 return 0L;
267} 267}
268#endif 268#endif
269 269
270Attendee *IncidenceBase::attendeeByMail(const QString &email) 270Attendee *IncidenceBase::attendeeByMail(const QString &email)
271{ 271{
272 QPtrListIterator<Attendee> qli(mAttendees); 272 QPtrListIterator<Attendee> qli(mAttendees);
273 273
274 qli.toFirst(); 274 qli.toFirst();
275 while (qli) { 275 while (qli) {
276 if (qli.current()->email() == email) 276 if (qli.current()->email() == email)
277 return qli.current(); 277 return qli.current();
278 ++qli; 278 ++qli;
279 } 279 }
280 return 0L; 280 return 0L;
281} 281}
282 282
283Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email) 283Attendee *IncidenceBase::attendeeByMails(const QStringList &emails, const QString& email)
284{ 284{
285 QPtrListIterator<Attendee> qli(mAttendees); 285 QPtrListIterator<Attendee> qli(mAttendees);
286 286
287 QStringList mails = emails; 287 QStringList mails = emails;
288 if (!email.isEmpty()) { 288 if (!email.isEmpty()) {
289 mails.append(email); 289 mails.append(email);
290 } 290 }
291 qli.toFirst(); 291 qli.toFirst();
292 while (qli) { 292 while (qli) {
293 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) { 293 for ( QStringList::Iterator it = mails.begin(); it != mails.end(); ++it ) {
294 if (qli.current()->email() == *it) 294 if (qli.current()->email() == *it)
295 return qli.current(); 295 return qli.current();
296 } 296 }
297 297
298 ++qli; 298 ++qli;
299 } 299 }
300 return 0L; 300 return 0L;
301} 301}
302 302
303void IncidenceBase::setDuration(int seconds) 303void IncidenceBase::setDuration(int seconds)
304{ 304{
305 mDuration = seconds; 305 mDuration = seconds;
306 setHasDuration(true); 306 setHasDuration(true);
307} 307}
308 308
309int IncidenceBase::duration() const 309int IncidenceBase::duration() const
310{ 310{
311 return mDuration; 311 return mDuration;
312} 312}
313 313
314void IncidenceBase::setHasDuration(bool b) 314void IncidenceBase::setHasDuration(bool b)
315{ 315{
316 mHasDuration = b; 316 mHasDuration = b;
317} 317}
318 318
319bool IncidenceBase::hasDuration() const 319bool IncidenceBase::hasDuration() const
320{ 320{
321 return mHasDuration; 321 return mHasDuration;
322} 322}
323 323
324void IncidenceBase::setSyncStatus(int stat) 324void IncidenceBase::setSyncStatus(int stat)
325{ 325{
326 if (mReadOnly) return; 326 if (mReadOnly) return;
327 mSyncStatus = stat; 327 mSyncStatus = stat;
328} 328}
329 329
330int IncidenceBase::syncStatus() const 330int IncidenceBase::syncStatus() const
331{ 331{
332 return mSyncStatus; 332 return mSyncStatus;
333} 333}
334 334
335void IncidenceBase::setPilotId( int id ) 335void IncidenceBase::setPilotId( int id )
336{ 336{
337 if (mReadOnly) return; 337 if (mReadOnly) return;
338 mPilotId = id; 338 mPilotId = id;
339} 339}
340 340
341int IncidenceBase::pilotId() const 341int IncidenceBase::pilotId() const
342{ 342{
343 return mPilotId; 343 return mPilotId;
344} 344}
345void IncidenceBase::setZaurusId( int id ) 345void IncidenceBase::setZaurusId( int id )
346{ 346{
347 if (mReadOnly) return; 347 if (mReadOnly) return;
348 mZaurusId = id; 348 mZaurusId = id;
349} 349}
350 350
351int IncidenceBase::zaurusId() const 351int IncidenceBase::zaurusId() const
352{ 352{
353 return mZaurusId; 353 return mZaurusId;
354} 354}
355 355
356int IncidenceBase::zaurusUid() const 356int IncidenceBase::zaurusUid() const
357{ 357{
358 return mZaurusUid; 358 return mZaurusUid;
359} 359}
360void IncidenceBase::setZaurusUid( int id ) 360void IncidenceBase::setZaurusUid( int id )
361{ 361{
362 if (mReadOnly) return; 362 if (mReadOnly) return;
363 mZaurusUid = id; 363 mZaurusUid = id;
364} 364}
365 365
366int IncidenceBase::tempSyncStat() const 366int IncidenceBase::tempSyncStat() const
367{ 367{
368 return mTempSyncStat; 368 return mTempSyncStat;
369} 369}
370void IncidenceBase::setTempSyncStat( int id ) 370void IncidenceBase::setTempSyncStat( int id )
371{ 371{
372 if (mReadOnly) return; 372 if (mReadOnly) return;
373 mTempSyncStat = id; 373 mTempSyncStat = id;
374} 374}
375 375
376void IncidenceBase::setID( const QString & prof , int id ) 376void IncidenceBase::setID( const QString & prof , int id )
377{ 377{
378 int num = mExternalId.find( ":"+prof+";" ); 378 int num = mExternalId.find( ":"+prof+";" );
379 if ( num >= 0 ) { 379 if ( num >= 0 ) {
380 int len = prof.length()+2; 380 int len = prof.length()+2;
381 int end = mExternalId.find( ";", num+len ); 381 int end = mExternalId.find( ";", num+len );
382 if ( end > 0 ) { 382 if ( end > 0 ) {
383 mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end ); 383 mExternalId = mExternalId.left( num+len ) +QString::number( id)+mExternalId.mid( end );
384 } else 384 } else
385 qDebug("Error in IncidenceBase::setID "); 385 qDebug("Error in IncidenceBase::setID ");
386 } else { 386 } else {
387 mExternalId += prof+";"+QString::number( id) +";0:"; 387 mExternalId += prof+";"+QString::number( id) +";0:";
388 } 388 }
389 qDebug("setID*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() );
389} 390}
390int IncidenceBase::getID( const QString & prof) 391int IncidenceBase::getID( const QString & prof)
391{ 392{
392 int ret = -1; 393 int ret = -1;
393 int num = mExternalId.find(":"+ prof+";" ); 394 int num = mExternalId.find(":"+ prof+";" );
394 if ( num >= 0 ) { 395 if ( num >= 0 ) {
395 int len = prof.length()+2; 396 int len = prof.length()+2;
396 int end = mExternalId.find( ";", num+len ); 397 int end = mExternalId.find( ";", num+len );
397 if ( end > 0 ) { 398 if ( end > 0 ) {
398 bool ok; 399 bool ok;
399 ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok ); 400 ret = mExternalId.mid ( num + len,end-len-num).toInt( &ok );
400 if (!ok) 401 if (!ok)
401 return -1; 402 ret = -1;
402 } 403 }
403 } 404 }
404 return ret; 405 qDebug("getID*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() );
406 return ret;
405} 407}
406 408
407// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0: 409// example :Sharp_DTM;22;23566:TP;-1;8654:TPP;18;0:
408// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0 410// format name;III;JJJ: III >= 0, may be -1. JJJ always >= 0
409void IncidenceBase::setCsum( const QString & prof , int id ) 411void IncidenceBase::setCsum( const QString & prof , int id )
410{ 412{
411 int num = mExternalId.find( ":"+prof+";"); 413 int num = mExternalId.find( ":"+prof+";");
412 if ( num >= 0 ) { 414 if ( num >= 0 ) {
413 int len = prof.length()+2; 415 int len = prof.length()+2;
414 num = mExternalId.find( ";", num+len ); 416 num = mExternalId.find( ";", num+len );
415 int end = mExternalId.find( ":", num+1 ); 417 int end = mExternalId.find( ":", num+1 );
416 if ( end > 0 ) { 418 if ( end > 0 ) {
417 mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end ); 419 mExternalId = mExternalId.left( num ) +QString::number(id)+mExternalId.mid( end );
418 } else 420 } else
419 qDebug("Error in IncidenceBase::setCsum "); 421 qDebug("Error in IncidenceBase::setCsum ");
420 } else { 422 } else {
421 mExternalId += prof+";-1;"+QString::number( id) +":"; 423 mExternalId += prof+";-1;"+QString::number( id) +":";
422 } 424 }
425 qDebug("setCsum*%s*%d*%s* ", prof.latin1(), id,mExternalId.latin1() );
423} 426}
424int IncidenceBase::getCsum( const QString & prof) 427int IncidenceBase::getCsum( const QString & prof)
425{ 428{
426 int ret = -1; 429 int ret = -1;
427 int num = mExternalId.find( ":"+prof+";" ); 430 int num = mExternalId.find( ":"+prof+";" );
428 if ( num >= 0 ) { 431 if ( num >= 0 ) {
429 int len = prof.length()+2; 432 int len = prof.length()+2;
430 num = mExternalId.find( ";", num+len ); 433 num = mExternalId.find( ";", num+len );
431 int end = mExternalId.find( ":", num+1 ); 434 int end = mExternalId.find( ":", num+1 );
432 if ( end > 0 ) { 435 if ( end > 0 ) {
433 bool ok; 436 bool ok;
434 ret = mExternalId.mid ( num ,end-num).toInt( &ok ); 437 ret = mExternalId.mid ( num ,end-num).toInt( &ok );
435 if (!ok) 438 if (!ok)
436 return -1; 439 ret = -1;
437 } 440 }
438 } 441 }
442 qDebug("getCsum*%s*%d*%s* ", prof.latin1(), ret,mExternalId.latin1() );
439 return ret; 443 return ret;
440} 444}
441 445
442void IncidenceBase::setIDStr( const QString & s ) 446void IncidenceBase::setIDStr( const QString & s )
443{ 447{
444 if (mReadOnly) return; 448 if (mReadOnly) return;
445 mExternalId = s; 449 mExternalId = s;
446} 450}
447 451
448QString IncidenceBase::IDStr() const 452QString IncidenceBase::IDStr() const
449{ 453{
450 return mExternalId ; 454 return mExternalId ;
451} 455}
452void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) 456void IncidenceBase::registerObserver( IncidenceBase::Observer *observer )
453{ 457{
454 if( !mObservers.contains(observer) ) mObservers.append( observer ); 458 if( !mObservers.contains(observer) ) mObservers.append( observer );
455} 459}
456 460
457void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) 461void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer )
458{ 462{
459 mObservers.remove( observer ); 463 mObservers.remove( observer );
460} 464}
461 465
462void IncidenceBase::updated() 466void IncidenceBase::updated()
463{ 467{
464 QPtrListIterator<Observer> it(mObservers); 468 QPtrListIterator<Observer> it(mObservers);
465 while( it.current() ) { 469 while( it.current() ) {
466 Observer *o = it.current(); 470 Observer *o = it.current();
467 ++it; 471 ++it;
468 o->incidenceUpdated( this ); 472 o->incidenceUpdated( this );
469 } 473 }
470} 474}