-rw-r--r-- | libkcal/phoneformat.cpp | 58 |
1 files changed, 28 insertions, 30 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6d0da5c..178a63e 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -137,9 +137,9 @@ ulong PhoneFormat::getCsumTodo( Todo* todo ) Alarm *alarm; if ( todo->alarms().count() > 0 ) { alarm = todo->alarms().first(); if ( alarm->enabled() ) { - alarmString = QString::number(alarm->startOffset().asSeconds() ); + alarmString = QString::number(alarm->offset() ); } } attList << alarmString; attList << todo->categoriesStr(); @@ -158,9 +158,9 @@ ulong PhoneFormat::getCsumEvent( Event* event ) Alarm *alarm; if ( event->alarms().count() > 0 ) { alarm = event->alarms().first(); if ( alarm->enabled() ) { - alarmString = QString::number( alarm->startOffset().asSeconds() ); + alarmString = QString::number( alarm->offset() ); } } attList << alarmString; Recurrence* rec = event->recurrence(); @@ -276,10 +276,10 @@ ulong PhoneFormat::getCsum( const QStringList & attList) } } } - QString dump = attList.join(","); - qDebug("csum: %d %s", cSum,dump.latin1()); + //QString dump = attList.join(","); + //qDebug("csum: %d %s", cSum,dump.latin1()); return cSum; } @@ -300,9 +300,8 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) if ( ret != 0 ) { qDebug("Error::command returned %d", ret); return false; } - qDebug("Command returned %d", ret); VCalFormat vfload; vfload.setLocalTime ( true ); qDebug("loading file ..."); @@ -347,9 +346,9 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) int id = ev->pilotId(); Todo *event; event = existingCal->todo( mProfileName ,QString::number( id ) ); if ( event ) { - qDebug("copy todo %s ", event->summary().latin1()); + //qDebug("copy todo %s ", event->summary().latin1()); event = (Todo*)event->clone(); copyTodo( event, ev ); calendar->deleteTodo( ev ); @@ -379,17 +378,19 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); - QPtrListIterator<Alarm> it( from->alarms() ); - if ( it.current() ) + if ( from->alarms().count() ) { to->clearAlarms(); - const Alarm *a; - while( (a = it.current()) ) { - Alarm *b = new Alarm( *a ); - b->setParent( to ); - to->addAlarm( b ); - ++it; + Alarm *a = from->alarms().first(); + Alarm *b = to->newAlarm( ); + b->setEnabled( a->enabled() ); + if ( a->hasStartOffset() ) { + b->setStartOffset( a->startOffset() ); + } + if ( a->hasTime() ) + b->setTime( a->time() ); + } QStringList cat = to->categories(); QStringList catFrom = from->categories(); QString nCat; @@ -419,18 +420,19 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) to->setDescription( from->description() ); if ( !from->summary().isEmpty() ) to->setSummary( from->summary() ); - QPtrListIterator<Alarm> it( from->alarms() ); - if ( it.current() ) + if ( from->alarms().count() ) { to->clearAlarms(); - const Alarm *a; - while( (a = it.current()) ) { - Alarm *b = new Alarm( *a ); - b->setParent( to ); - to->addAlarm( b ); - ++it; + Alarm *a = from->alarms().first(); + Alarm *b = to->newAlarm( ); + b->setEnabled( a->enabled() ); + if ( a->hasStartOffset() ) + b->setStartOffset( a->startOffset() ); + if ( a->hasTime() ) + b->setTime( a->time() ); } + QStringList cat = to->categories(); QStringList catFrom = from->categories(); QString nCat; int iii; @@ -532,12 +534,9 @@ bool PhoneFormat::save( Calendar *calendar) i18n("Error accessing device!\nPlease turn on connection\nand retry!"),i18n("KO/Pi phone sync"),i18n("Retry"),i18n("Cancel")); if ( retval != KMessageBox::Continue ) return false; } - if ( ret != 0 ) { - qDebug("Error S::command returned %d", ret); - return false; - } + // 5 reread data message = i18n(" Rereading all data ... "); status.setText ( message ); qApp->processEvents(); @@ -578,9 +577,9 @@ bool PhoneFormat::save( Calendar *calendar) } ev1 = er1.next(); } if ( ! ev1 ) { - ev->removeID(mProfileName); + // ev->removeID(mProfileName); qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); } @@ -593,16 +592,15 @@ bool PhoneFormat::save( Calendar *calendar) QPtrList<Todo> tl1 = calendarTemp->rawTodos(); Todo* to1 ; message = i18n(" Comparing todo # "); while ( to ) { - qDebug("todo2 %d ", procCount); status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); uint csum; csum = PhoneFormat::getCsumTodo( to ); QString cSum = QString::number( csum ); //to->setCsum( mProfileName, cSum ); - qDebug("Todo cSum %s ", cSum.latin1()); + //qDebug("Todo cSum %s ", cSum.latin1()); Todo* to1 = tl1.first(); while ( to1 ) { if ( to1->getCsum( mProfileName ) == cSum ) { tl1.remove( to1 ); @@ -612,9 +610,9 @@ bool PhoneFormat::save( Calendar *calendar) } to1 = tl1.next(); } if ( ! to1 ) { - to->removeID(mProfileName); + //to->removeID(mProfileName); qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); } to = tl.next(); |