summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp23
-rw-r--r--libkcal/alarm.cpp16
-rw-r--r--libkcal/alarm.h2
-rw-r--r--libkcal/phoneformat.cpp58
4 files changed, 63 insertions, 36 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index cfd9290..d5d31e2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1124,6 +1124,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
inL = el.next();
}
+ int delFut = 0;
if ( KOPrefs::instance()->mWriteBackInFuture ) {
er = remote->rawIncidences();
inR = er.first();
@@ -1138,9 +1139,18 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
else
dt = cur.addSecs( 62 );
}
- else dt = inR->dtStart();
- if ( dt < cur || dt > end )
+ else if (inR->type() == "Event" ) {
+ bool ok;
+ dt = inR->getNextOccurence( cur, &ok );
+ if ( !ok )
+ dt = cur.addSecs( -62 );
+ }
+ else
+ dt = inR->dtStart();
+ if ( dt < cur || dt > end ) {
remote->deleteIncidence( inR );
+ ++delFut;
+ }
inR = er.next();
}
}
@@ -1158,6 +1168,11 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
remote->addEvent( eventRSync );
QString mes;
mes .sprintf( i18n("Synchronization summary:\n\n %d items added to local\n %d items added to remote\n %d items updated on local\n %d items updated on remote\n %d items deleted on local\n %d items deleted on remote\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR );
+ QString delmess;
+ if ( delFut ) {
+ delmess.sprintf( i18n("%d items skipped on remote,\nbecause they are in the past or\nmore than %d weeks in the future.\n"),delFut, KOPrefs::instance()->mWriteBackInFuture );
+ mes += delmess;
+ }
if ( KOPrefs::instance()->mShowSyncSummary ) {
KMessageBox::information(this, mes, i18n("KO/Pi Synchronization") );
}
@@ -1245,12 +1260,10 @@ void CalendarView::syncExternal( int mode )
{
QPtrList<Incidence> iL = mCalendar->rawIncidences();
Incidence* inc = iL.first();
- /* obsolete
while ( inc ) {
- inc->setZaurusStat( inc->revision () );
+ inc->removeID(mCurrentSyncDevice);
inc = iL.next();
}
- */
#ifndef DESKTOP_VERSION
if ( sharpFormat )
sharpFormat->save(calendar);
diff --git a/libkcal/alarm.cpp b/libkcal/alarm.cpp
index 07812c2..29e6205 100644
--- a/libkcal/alarm.cpp
+++ b/libkcal/alarm.cpp
@@ -300,6 +300,22 @@ 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
@@ -58,7 +58,7 @@ class Alarm : public CustomProperties
void setType(Type type);
/** 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
@@ -138,7 +138,7 @@ ulong PhoneFormat::getCsumTodo( Todo* todo )
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;
@@ -159,7 +159,7 @@ ulong PhoneFormat::getCsumEvent( Event* event )
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;
@@ -277,8 +277,8 @@ 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;
@@ -301,7 +301,6 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
qDebug("Error::command returned %d", ret);
return false;
}
- qDebug("Command returned %d", ret);
VCalFormat vfload;
vfload.setLocalTime ( true );
qDebug("loading file ...");
@@ -348,7 +347,7 @@ bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
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 );
@@ -380,15 +379,17 @@ void PhoneFormat::copyEvent( Event* to, Event* from )
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();
@@ -420,16 +421,17 @@ void PhoneFormat::copyTodo( Todo* to, Todo* from )
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;
@@ -533,10 +535,7 @@ bool PhoneFormat::save( Calendar *calendar)
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 );
@@ -579,7 +578,7 @@ 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());
}
@@ -594,14 +593,13 @@ bool PhoneFormat::save( Calendar *calendar)
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 ) {
@@ -613,7 +611,7 @@ 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());
}