-rw-r--r-- | libkcal/incidencebase.cpp | 10 |
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 | |||
@@ -357,114 +357,118 @@ int IncidenceBase::zaurusUid() const | |||
357 | { | 357 | { |
358 | return mZaurusUid; | 358 | return mZaurusUid; |
359 | } | 359 | } |
360 | void IncidenceBase::setZaurusUid( int id ) | 360 | void IncidenceBase::setZaurusUid( int id ) |
361 | { | 361 | { |
362 | if (mReadOnly) return; | 362 | if (mReadOnly) return; |
363 | mZaurusUid = id; | 363 | mZaurusUid = id; |
364 | } | 364 | } |
365 | 365 | ||
366 | int IncidenceBase::tempSyncStat() const | 366 | int IncidenceBase::tempSyncStat() const |
367 | { | 367 | { |
368 | return mTempSyncStat; | 368 | return mTempSyncStat; |
369 | } | 369 | } |
370 | void IncidenceBase::setTempSyncStat( int id ) | 370 | void IncidenceBase::setTempSyncStat( int id ) |
371 | { | 371 | { |
372 | if (mReadOnly) return; | 372 | if (mReadOnly) return; |
373 | mTempSyncStat = id; | 373 | mTempSyncStat = id; |
374 | } | 374 | } |
375 | 375 | ||
376 | void IncidenceBase::setID( const QString & prof , int id ) | 376 | void 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 | } |
390 | int IncidenceBase::getID( const QString & prof) | 391 | int 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 |
409 | void IncidenceBase::setCsum( const QString & prof , int id ) | 411 | void 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 | } |
424 | int IncidenceBase::getCsum( const QString & prof) | 427 | int 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 | ||
442 | void IncidenceBase::setIDStr( const QString & s ) | 446 | void 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 | ||
448 | QString IncidenceBase::IDStr() const | 452 | QString IncidenceBase::IDStr() const |
449 | { | 453 | { |
450 | return mExternalId ; | 454 | return mExternalId ; |
451 | } | 455 | } |
452 | void IncidenceBase::registerObserver( IncidenceBase::Observer *observer ) | 456 | void 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 | ||
457 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) | 461 | void IncidenceBase::unRegisterObserver( IncidenceBase::Observer *observer ) |
458 | { | 462 | { |
459 | mObservers.remove( observer ); | 463 | mObservers.remove( observer ); |
460 | } | 464 | } |
461 | 465 | ||
462 | void IncidenceBase::updated() | 466 | void 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 | } |