summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2004-09-12 19:26:13 (UTC)
committer zautrix <zautrix>2004-09-12 19:26:13 (UTC)
commit5b434dd78f71bcea5e6067fc8ae0faaaea313f9d (patch) (side-by-side diff)
treeed532e602a3b503b72a46ea18d40e3a5dc97aa3f /libkcal
parentbc4153a99e205f43d0144e2e910730dd1a14d402 (diff)
downloadkdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.zip
kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.tar.gz
kdepimpi-5b434dd78f71bcea5e6067fc8ae0faaaea313f9d.tar.bz2
phone fixes
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/alarm.cpp16
-rw-r--r--libkcal/alarm.h2
-rw-r--r--libkcal/phoneformat.cpp58
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
@@ -302,2 +302,18 @@ void Alarm::setTime(const QDateTime &alarmTime)
}
+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();
+ }
+
+}
+
diff --git a/libkcal/alarm.h b/libkcal/alarm.h
index ae2eca3..682b626 100644
--- a/libkcal/alarm.h
+++ b/libkcal/alarm.h
@@ -60,3 +60,3 @@ class Alarm : public CustomProperties
Type type() const;
-
+ int offset();
/** Set the alarm to be a display alarm.
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 6d0da5c..178a63e 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -140,3 +140,3 @@ ulong PhoneFormat::getCsumTodo( Todo* todo )
if ( alarm->enabled() ) {
- alarmString = QString::number(alarm->startOffset().asSeconds() );
+ alarmString = QString::number(alarm->offset() );
}
@@ -161,3 +161,3 @@ ulong PhoneFormat::getCsumEvent( Event* event )
if ( alarm->enabled() ) {
- alarmString = QString::number( alarm->startOffset().asSeconds() );
+ alarmString = QString::number( alarm->offset() );
}
@@ -279,4 +279,4 @@ 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());
@@ -303,3 +303,2 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
}
- qDebug("Command returned %d", ret);
VCalFormat vfload;
@@ -350,3 +349,3 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
if ( event ) {
- qDebug("copy todo %s ", event->summary().latin1());
+ //qDebug("copy todo %s ", event->summary().latin1());
@@ -382,11 +381,13 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
- 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() );
+
}
@@ -422,12 +423,13 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
- 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();
@@ -535,6 +537,3 @@ bool PhoneFormat::save( Calendar *calendar)
}
- if ( ret != 0 ) {
- qDebug("Error S::command returned %d", ret);
- return false;
- }
+
// 5 reread data
@@ -581,3 +580,3 @@ 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());
@@ -596,3 +595,2 @@ bool PhoneFormat::save( Calendar *calendar)
while ( to ) {
- qDebug("todo2 %d ", procCount);
status.setText ( message + QString::number ( ++procCount ) );
@@ -603,3 +601,3 @@ bool PhoneFormat::save( Calendar *calendar)
//to->setCsum( mProfileName, cSum );
- qDebug("Todo cSum %s ", cSum.latin1());
+ //qDebug("Todo cSum %s ", cSum.latin1());
Todo* to1 = tl1.first();
@@ -615,3 +613,3 @@ 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());