-rw-r--r-- | korganizer/calendarview.cpp | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8965d3b..307027a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -366,6 +366,7 @@ CalendarView::CalendarView( Calendar *calendar, void CalendarView::init() { + mMultiResourceSync = false; flag_blockConflict = false; flag_blockScrollBar = false; flag_checkFileFirsttime = true; @@ -1552,6 +1553,7 @@ Event* CalendarView::getLastSyncEvent() lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); + lse->setCalID( 1 ); mCalendar->addEvent( lse ); } @@ -1902,6 +1904,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); + if ( mMultiResourceSync ) { + remote->removeSyncInfo( "" ); //all + + } else { eventLSync->setReadOnly( false ); eventLSync->setDtStart( mLastCalendarSync ); eventRSync->setDtStart( mLastCalendarSync ); @@ -1910,8 +1916,9 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); eventLSync->setReadOnly( true ); + } qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); - if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... + if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... remote->addEvent( eventRSync ); else delete eventRSync; @@ -2435,6 +2442,32 @@ void CalendarView::mergeFile( QString fn ) updateUnmanagedViews(); updateView(); } +void CalendarView::mergeFileResource( QString fn ,QString resource ) +{ + + if ( resource == "ALL" ) { + mergeFile( fn ); + return; + } + + int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); + if ( !exclusiveResource ) { + qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); + return; + } + clearAllViews(); + mCalendar->setCalendarRemove( exclusiveResource ); + int def = mCalendar->defaultCalendar(); + mCalendar->setDefaultCalendar(exclusiveResource); + if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { + qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); + } + mCalendar->setDefaultCalendar( def ); + mCalendar->reInitAlarmSettings(); + setSyncEventsReadOnly(); + updateUnmanagedViews(); + updateView(); +} void CalendarView::showOpenError() { KMessageBox::error(this,i18n("Couldn't load calendar\n.")); @@ -2522,6 +2555,7 @@ bool CalendarView::checkFileVersion(QString fn) mSyncManager->mWriteBackFile = false; mSyncManager->mWriteBackExistingOnly = false; mSyncManager->mShowSyncSummary = false; + mMultiResourceSync = false; syncCalendar( fn, 3 ); Event * e = getLastSyncEvent(); if ( e ) @@ -2558,6 +2592,23 @@ bool CalendarView::saveCalendars() } return true; } +bool CalendarView::saveCalendarResource(QString filename, QString resource) +{ + if ( resource == "ALL" ) + return saveCalendar( filename ); + int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); + if ( !exclusiveResource ) { + qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); + return false; + } + mCalendar->setDefaultCalendar( exclusiveResource ); + mCalendar->setDefaultCalendarEnabledOnly(); + mCalendar->setSyncEventsEnabled(); + bool res = saveCalendar( filename ); + restoreCalendarSettings(); + return res; + +} bool CalendarView::saveCalendar( QString filename ) { @@ -5032,7 +5083,11 @@ void CalendarView::keyPressEvent ( QKeyEvent *e) e->ignore(); } +void CalendarView::multiResourceSyncStart( bool start ) +{ + mMultiResourceSync = start; +} bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) { |