-rw-r--r-- | korganizer/calendarview.cpp | 73 |
1 files changed, 64 insertions, 9 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 8965d3b..307027a 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -363,12 +363,13 @@ CalendarView::CalendarView( Calendar *calendar, mTodoEditor = 0; init(); } void CalendarView::init() { + mMultiResourceSync = false; flag_blockConflict = false; flag_blockScrollBar = false; flag_checkFileFirsttime = true; flag_clearallviewsEventDisplay = false; flag_clearallviewsupdateView = false; mNextAlarmDateTime = QDateTime::currentDateTime(); @@ -1549,12 +1550,13 @@ Event* CalendarView::getLastSyncEvent() sum = "E: "; lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); + lse->setCalID( 1 ); mCalendar->addEvent( lse ); } return lse; } @@ -1899,22 +1901,27 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } inR = er.next(); } } bar.hide(); mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); - eventLSync->setReadOnly( false ); - eventLSync->setDtStart( mLastCalendarSync ); - eventRSync->setDtStart( mLastCalendarSync ); - eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); - eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); - eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; - eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); - eventLSync->setReadOnly( true ); + if ( mMultiResourceSync ) { + remote->removeSyncInfo( "" ); //all + + } else { + eventLSync->setReadOnly( false ); + eventLSync->setDtStart( mLastCalendarSync ); + eventRSync->setDtStart( mLastCalendarSync ); + eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); + eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); + 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; qDebug("KO: Sync with desktop %d ",mSyncManager->syncWithDesktop() ); 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 %d incoming filtered out\n %d outgoing filtered out\n"),addedEvent, addedEventR, changedLocal, changedRemote, deletedEventL, deletedEventR, filteredIN, filteredOUT ); @@ -2432,12 +2439,38 @@ void CalendarView::mergeFile( QString fn ) mCalendar->mergeCalendarFile( fn ); mCalendar->reInitAlarmSettings(); setSyncEventsReadOnly(); 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.")); } void CalendarView::setLoadedFileVersion(QDateTime dt) { @@ -2519,12 +2552,13 @@ bool CalendarView::checkFileVersion(QString fn) setSyncDevice("deleteaftersync" ); mSyncManager->mAskForPreferences = true; mSyncManager->mSyncAlgoPrefs = 3; mSyncManager->mWriteBackFile = false; mSyncManager->mWriteBackExistingOnly = false; mSyncManager->mShowSyncSummary = false; + mMultiResourceSync = false; syncCalendar( fn, 3 ); Event * e = getLastSyncEvent(); if ( e ) mCalendar->deleteEvent( e ); return true; } @@ -2555,12 +2589,29 @@ bool CalendarView::saveCalendars() saveError = KGlobal::formatMessage( i18n("Calendar(s) not saved:"),0 )+"\n" + saveError; KMessageBox::error(this, saveError, i18n("Error saving data")); return false; } 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 ) { // Store back all unsaved data into calendar object // qDebug("file %s %d ", filename.latin1() , mViewManager->currentView() ); if ( mViewManager->currentView() ) @@ -5029,13 +5080,17 @@ void CalendarView::slotCalendarChanged() void CalendarView::keyPressEvent ( QKeyEvent *e) { //qDebug("CalendarView::keyPressEvent "); e->ignore(); } +void CalendarView::multiResourceSyncStart( bool start ) +{ + mMultiResourceSync = start; +} bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) { if ( manager != mSyncManager) qDebug("KO: Internal error-1. SyncManager mismatch "); if ( filename == QDir::homeDirPath ()+"/.kdecalendardump.ics" ) { |