author | zautrix <zautrix> | 2004-09-12 19:26:13 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-09-12 19:26:13 (UTC) |
commit | 5b434dd78f71bcea5e6067fc8ae0faaaea313f9d (patch) (side-by-side diff) | |
tree | ed532e602a3b503b72a46ea18d40e3a5dc97aa3f /libkcal | |
parent | bc4153a99e205f43d0144e2e910730dd1a14d402 (diff) | |
download | kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.zip kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.tar.gz kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.tar.bz2 |
phone fixes
-rw-r--r-- | libkcal/alarm.cpp | 16 | ||||
-rw-r--r-- | libkcal/alarm.h | 2 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 58 |
3 files changed, 45 insertions, 31 deletions
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp index 07812c2..29e6205 100644 --- a/libkcal/alarm.cpp +++ b/libkcal/alarm.cpp @@ -301,4 +301,20 @@ void Alarm::setTime(const QDateTime &alarmTime) mParent->updated(); } +int Alarm::offset() +{ + if ( hasTime() ) { + if (mParent->type()=="Todo") { + Todo *t = static_cast<Todo*>(mParent); + return t->dtDue().secsTo( mAlarmTime ) ; + } else + return mParent->dtStart().secsTo( mAlarmTime ) ; + } + else + { + return mOffset.asSeconds(); + } + +} + QDateTime Alarm::time() const diff --git a/libkcal/alarm.h b/libkcal/alarm.h index ae2eca3..682b626 100644 --- a/libkcal/alarm.h +++ b/libkcal/alarm.h @@ -59,5 +59,5 @@ class Alarm : public CustomProperties /** Return the type of the alarm */ Type type() const; - + int offset(); /** Set the alarm to be a display alarm. @param text text to display when the alarm is triggered. diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6d0da5c..178a63e 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp @@ -139,5 +139,5 @@ ulong PhoneFormat::getCsumTodo( Todo* todo ) alarm = todo->alarms().first(); if ( alarm->enabled() ) { - alarmString = QString::number(alarm->startOffset().asSeconds() ); + alarmString = QString::number(alarm->offset() ); } } @@ -160,5 +160,5 @@ ulong PhoneFormat::getCsumEvent( Event* event ) alarm = event->alarms().first(); if ( alarm->enabled() ) { - alarmString = QString::number( alarm->startOffset().asSeconds() ); + alarmString = QString::number( alarm->offset() ); } } @@ -278,6 +278,6 @@ 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; @@ -302,5 +302,4 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) return false; } - qDebug("Command returned %d", ret); VCalFormat vfload; vfload.setLocalTime ( true ); @@ -349,5 +348,5 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 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(); @@ -381,13 +380,15 @@ void PhoneFormat::copyEvent( Event* to, Event* from ) 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(); @@ -421,14 +422,15 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from ) 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(); @@ -534,8 +536,5 @@ bool PhoneFormat::save( Calendar *calendar) return false; } - if ( ret != 0 ) { - qDebug("Error S::command returned %d", ret); - return false; - } + // 5 reread data message = i18n(" Rereading all data ... "); @@ -580,5 +579,5 @@ bool PhoneFormat::save( Calendar *calendar) } if ( ! ev1 ) { - ev->removeID(mProfileName); + // ev->removeID(mProfileName); qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); } @@ -595,5 +594,4 @@ bool PhoneFormat::save( Calendar *calendar) message = i18n(" Comparing todo # "); while ( to ) { - qDebug("todo2 %d ", procCount); status.setText ( message + QString::number ( ++procCount ) ); qApp->processEvents(); @@ -602,5 +600,5 @@ bool PhoneFormat::save( Calendar *calendar) 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 ) { @@ -614,5 +612,5 @@ bool PhoneFormat::save( Calendar *calendar) } if ( ! to1 ) { - to->removeID(mProfileName); + //to->removeID(mProfileName); qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); } |