summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-28 01:23:02 (UTC)
committer zautrix <zautrix>2005-11-28 01:23:02 (UTC)
commite08811c2246f63b2b63f9db6b65701344460f3d7 (patch) (side-by-side diff)
treed450f486a9472d80eb86f605237b828a0e7ffae6
parent854d4a0c686962cd73ac7418b5fbf4b2d73adab7 (diff)
downloadkdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.zip
kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.gz
kdepimpi-e08811c2246f63b2b63f9db6b65701344460f3d7.tar.bz2
ync
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp17
-rw-r--r--libkcal/calendar.cpp9
-rw-r--r--libkcal/calendar.h3
-rw-r--r--libkcal/calendarlocal.cpp77
-rw-r--r--libkcal/calendarlocal.h3
-rw-r--r--libkcal/incidence.cpp6
-rw-r--r--libkcal/incidence.h1
7 files changed, 97 insertions, 19 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 8d024c1..1800cf2 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1606,2 +1606,3 @@ void CalendarView::checkExternalId( Incidence * inc )
}
+// SSSSSSSSSSSSSSSSSSSSSS
bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode )
@@ -1725,4 +1726,11 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
if ( !skipIncidence ) {
- inL = local->incidenceForUid( uid , false , true );
+ int hasCalId = 0;
+ inL = local->incidenceForUid( uid , false , true, &hasCalId );
+ if ( hasCalId && !inL )
+ inL = local->incidenceForUid( uid , false , true, &hasCalId );
+ else
+ hasCalId = 0;
if ( inL ) { // maybe conflict - same uid in both calendars
+ if ( hasCalId )
+ qDebug("KO: Cal id %d conflict detected: %s ", hasCalId, inL->summary().latin1());
if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
@@ -1752,2 +1760,4 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
int calID = inL->calID();
+ if ( hasCalId )
+ calID = hasCalId;
local->deleteIncidence( inL );
@@ -1766,2 +1776,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
+ } else {
+ // take == 0; events equal
+ if ( hasCalId )
+ qDebug("EV EQUALLLL **************************** ");
+
}
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 8535191..1350f6d 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -9,3 +9,2 @@
version 2 of the License, or (at your option) any later version.
-
This library is distributed in the hope that it will be useful,
@@ -422,3 +421,3 @@ void Calendar::setupRelations( Incidence *incidence )
QString uid = incidence->uid();
- //qDebug("Calendar::setupRelations ");
+ //qDebug("Calendar::setupRelations %s", incidence->summary().latin1());
// First, go over the list of orphans and see if this is their parent
@@ -427,2 +426,3 @@ void Calendar::setupRelations( Incidence *incidence )
i->setRelatedTo( incidence );
+ //qDebug("Add child %s ti inc %s", i->summary().latin1(),incidence->summary().latin1());
incidence->addRelation( i );
@@ -435,5 +435,7 @@ void Calendar::setupRelations( Incidence *incidence )
// Try to find it
- Incidence* parent = this->incidence( incidence->relatedToUid() );
+ //qDebug("Test parent for %s", incidence->summary().latin1());
+ Incidence* parent = this->incidenceForUid( incidence->relatedToUid(), true );
if( parent ) {
// Found it
+ // qDebug("parent found for for %s", incidence->summary().latin1());
incidence->setRelatedTo( parent );
@@ -441,2 +443,3 @@ void Calendar::setupRelations( Incidence *incidence )
} else {
+ // qDebug("NO parent found for for %s", incidence->summary().latin1());
// Not found, put this in the mOrphans list
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index f301768..fbc40ad 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -79,3 +79,4 @@ public:
virtual bool mergeCalendarFile( QString name ) = 0;
- virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ) = 0;
+ virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ,int * isDup = 0 ) = 0;
+ virtual Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0) = 0;
virtual void setSyncEventsReadOnly() = 0;
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index ad8ace3..980663f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -82,11 +82,25 @@ bool CalendarLocal::mergeCalendarFile( QString name )
-Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly )
+Todo* CalendarLocal::todoForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly,int * isDup )
{
+
+ int calID = 0;
+ if ( isDup && *isDup > 0 )
+ calID = *isDup;
Todo *todo;;
- Incidence *retVal = 0;
+ Todo *retVal = 0;
for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
if ( todo->uid() == uid ) {
- if ( enabledOnly )
- if ( !todo->calEnabled() )
+ if( calID ) {
+ if ( todo->calID() != calID )
+ continue;
+ }
+ else {
+ if ( enabledOnly ) {
+ if ( !todo->calEnabled() ) {
+ if ( isDup )
+ *isDup = todo->calID();
continue;
+ }
+ }
+ }
if ( doNotCheckDuplicates ) return todo;
@@ -94,2 +108,4 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
if ( retVal->calID() > todo->calID() ) {
+ if ( isDup )
+ *isDup = retVal->calID();
retVal = todo;
@@ -101,2 +117,13 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
}
+ return retVal;
+}
+//if ( isDup) and * isDup == 0: store duplicate found cal id in isDup
+//if ( isDup) and * isDup > 0: search only in calendar with ID *isDup, ignore enabledOnly
+
+Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly, int * isDup )
+{
+ int calID = 0;
+ if ( isDup && *isDup > 0 )
+ calID = *isDup;
+ Incidence *retVal = todoForUid( uid , doNotCheckDuplicates,enabledOnly, isDup );
if ( retVal ) return retVal;
@@ -105,5 +132,15 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
if ( event->uid() == uid ) {
- if ( enabledOnly )
- if ( !event->calEnabled() )
+ if( calID ) {
+ if ( event->calID() != calID )
continue;
+ }
+ else {
+ if ( enabledOnly ) {
+ if ( !event->calEnabled() ) {
+ if ( isDup )
+ *isDup =event->calID() ;
+ continue;
+ }
+ }
+ }
if ( doNotCheckDuplicates ) return event;
@@ -111,2 +148,4 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
if ( retVal->calID() > event->calID() ) {
+ if ( isDup )
+ *isDup = retVal->calID();
retVal = event;
@@ -121,5 +160,15 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
if ( it->uid() == uid ) {
- if ( enabledOnly )
- if ( !it->calEnabled() )
+ if( calID ) {
+ if ( event->calID() != calID )
continue;
+ }
+ else {
+ if ( enabledOnly ) {
+ if ( !it->calEnabled() ) {
+ if ( isDup )
+ *isDup = it->calID();
+ continue;
+ }
+ }
+ }
if ( doNotCheckDuplicates ) return it;
@@ -127,2 +176,4 @@ Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckD
if ( retVal->calID() > it->calID() ) {
+ if ( isDup )
+ *isDup = retVal->calID();
retVal = it;
@@ -235,7 +286,3 @@ void CalendarLocal::addCalendar( Calendar* cal )
while ( ev ) {
- QString rel = ev->relatedToUid();
- if ( !rel.isEmpty() ){
- ev->setRelatedTo ( 0 );
- ev->setRelatedToUid( rel );
- }
+ ev->resetRelatedTo();
ev = TodoList.next();
@@ -414,2 +461,3 @@ void CalendarLocal::deleteTodo( Todo *todo )
{
+ QString uid = todo->uid();
// Handle orphaned children
@@ -421,2 +469,5 @@ void CalendarLocal::deleteTodo( Todo *todo )
}
+ Todo* dup = todoForUid( uid );
+ if ( dup )
+ setupRelations( dup );
}
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b611704..1ceabce 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -49,3 +49,4 @@ class CalendarLocal : public Calendar
bool mergeCalendar( Calendar* cal );
- Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false );
+ Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false,int * isDup = 0 );
+ Todo* todoForUid( const QString& uid, bool doNotCheckDuplicates = true, bool enabledOnly = false ,int * isDup = 0 );
void setSyncEventsReadOnly();
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index fe9f854..7dd9bd2 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -522,2 +522,8 @@ QString Incidence::relatedToUid() const
}
+void Incidence::resetRelatedTo()
+{
+ QString store = mRelatedToUid;
+ setRelatedTo( 0 );
+ mRelatedToUid = store;
+}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index dc49640..f89942f 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -175,2 +175,3 @@ class Incidence : public IncidenceBase
void setRelatedTo(Incidence *relatedTo);
+ void resetRelatedTo();
/** what event does this one relate to? */