summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp44
-rw-r--r--libkcal/calendarlocal.cpp27
2 files changed, 41 insertions, 30 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 1800cf2..8385bcc 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1731,8 +1731,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
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 ) {
//qDebug("take %d %s ", take, inL->summary().latin1());
if ( take == 3 )
@@ -1744,22 +1743,25 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
idS = inR->IDStr();
int calID = inR->calID();
remote->deleteIncidence( inR );
- inR = inL->clone();
- inR->setCalID_block( calID );
- inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
- if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
- inR->setIDStr( idS );
- remote->addIncidence( inR );
- if ( mSyncManager->syncWithDesktop() )
- inR->setPilotId( 2 );
- ++changedRemote;
+ if ( !hasCalId ) {
+ inR = inL->clone();
+ inR->setCalID_block( calID );
+ inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
+ if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
+ inR->setIDStr( idS );
+ remote->addIncidence( inR );
+ if ( mSyncManager->syncWithDesktop() )
+ inR->setPilotId( 2 );
+ ++changedRemote;
+ } else
+ ++deletedEventR;
} else {// take remote **********************
if ( !inL->isReadOnly() ) {
idS = inL->IDStr();
int pid = inL->pilotId();
int calID = inL->calID();
- if ( hasCalId )
- calID = hasCalId;
+ if ( hasCalId )
+ calID = 0;// add to default calendar
local->deleteIncidence( inL );
inL = inR->clone();
inL->setCalID_block( calID );
@@ -1776,10 +1778,14 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
} else {
// take == 0; events equal
- if ( hasCalId )
- qDebug("EV EQUALLLL **************************** ");
+ if ( hasCalId ) {
+ qDebug("KO: Changing Cal id %d to %d for : %s ", hasCalId, local->defaultCalendar(),inL->summary().latin1());
+ inL->setCalID( local->defaultCalendar() );
+ }
}
+
+
} else { // no conflict ********** add or delete remote
if ( !filterIN || filterIN->filterCalendarItem( inR ) ){
if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
@@ -2482,16 +2488,12 @@ void CalendarView::mergeFileResource( QString fn ,QString resource )
}
clearAllViews();
mCalendar->setCalendarRemove( exclusiveResource );
- int def = mCalendar->defaultCalendar();
mCalendar->setDefaultCalendar(exclusiveResource);
+ mCalendar->setAllCalendarEnabled( true );
if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) {
qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() );
}
- mCalendar->setDefaultCalendar( def );
- mCalendar->reInitAlarmSettings();
- setSyncEventsReadOnly();
- updateUnmanagedViews();
- updateView();
+ restoreCalendarSettings();
}
void CalendarView::showOpenError()
{
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 980663f..8a5a76f 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -259,25 +259,23 @@ void CalendarLocal::addCalendar( Calendar* cal )
{
cal->setDontDeleteIncidencesOnClose();
setSyncEventsEnabled();
+ QPtrList<Incidence> incList;
{
QPtrList<Event> EventList = cal->rawEvents();
- QPtrList<Event> el;
Event * ev = EventList.first();
while ( ev ) {
- if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
- Event * se = event( ev->uid() );
- if ( se )
- el.append( se );
+ if ( ev->uid().left( 15 ) == QString("last-syncEvent-") ) {
ev->setCalID_block( 1 );
}
+ Event * se = event( ev->uid() );
+ if ( se )
+ incList.append( se );
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mEventList.append( ev );
ev = EventList.next();
}
- for ( ev = el.first(); ev; ev = el.next() ) {
- deleteIncidence ( ev );
- }
+
}
{
@@ -289,7 +287,10 @@ void CalendarLocal::addCalendar( Calendar* cal )
}
//TodoList = cal->rawTodos();
ev = TodoList.first();
- while ( ev ) {
+ while ( ev ) {
+ Todo * se = todo( ev->uid() );
+ if ( se )
+ incList.append( se );
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mTodoList.append( ev );
@@ -301,12 +302,20 @@ void CalendarLocal::addCalendar( Calendar* cal )
QPtrList<Journal> JournalList = cal->journals();
Journal * ev = JournalList.first();
while ( ev ) {
+ Journal * se = journal( ev->uid() );
+ if ( se )
+ incList.append( se );
ev->unRegisterObserver( cal );
ev->registerObserver( this );
mJournalList.append( ev );
ev = JournalList.next();
}
}
+ {
+ for (Incidence * ev = incList.first(); ev; ev = incList.next() ) {
+ deleteIncidence ( ev );
+ }
+ }
setModified( true );
}
bool CalendarLocal::load( const QString &fileName )