-rw-r--r-- | korganizer/calendarview.cpp | 57 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 |
4 files changed, 70 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 @@ -367,4 +367,5 @@ CalendarView::CalendarView( Calendar *calendar, void CalendarView::init() { + mMultiResourceSync = false; flag_blockConflict = false; flag_blockScrollBar = false; @@ -1553,4 +1554,5 @@ Event* CalendarView::getLastSyncEvent() lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); + lse->setCalID( 1 ); mCalendar->addEvent( lse ); } @@ -1903,4 +1905,8 @@ 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 ); @@ -1911,6 +1917,7 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int 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 @@ -2436,4 +2443,30 @@ void CalendarView::mergeFile( QString fn ) 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() { @@ -2523,4 +2556,5 @@ bool CalendarView::checkFileVersion(QString fn) mSyncManager->mWriteBackExistingOnly = false; mSyncManager->mShowSyncSummary = false; + mMultiResourceSync = false; syncCalendar( fn, 3 ); Event * e = getLastSyncEvent(); @@ -2559,4 +2593,21 @@ 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 ) { @@ -5033,5 +5084,9 @@ void CalendarView::keyPressEvent ( QKeyEvent *e) } +void CalendarView::multiResourceSyncStart( bool start ) +{ + mMultiResourceSync = start; +} bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) { diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index f85b6a3..60b1276 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -140,4 +140,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void checkSuspendAlarm(); void mergeFile( QString fn ); + void mergeFileResource( QString fn ,QString res); signals: @@ -202,4 +203,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser public slots: + void multiResourceSyncStart( bool ); void displayCalendarInfo( int id ); void nextConflict( bool all, bool allday ); @@ -247,4 +249,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser */ bool saveCalendar(QString filename); + bool saveCalendarResource(QString filename, QString resource); /** @@ -540,4 +543,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser protected: + bool mMultiResourceSync; Event *mConflictingEvent; void schedule(Scheduler::Method, Incidence *incidence = 0); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 66bb19b..69ccde1 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -375,6 +375,8 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); - connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); - connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); + connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); + connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) ); + connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) ); + mSyncManager->setDefaultFileName( sentSyncFile()); connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); @@ -2705,5 +2707,5 @@ QString MainWindow::sentSyncFile() } -void MainWindow::syncFileRequest() +void MainWindow::syncFileRequest(const QString& resource) { while ( mSyncManager->blockSave() ) { @@ -2717,10 +2719,10 @@ void MainWindow::syncFileRequest() setCaption(i18n("Saving Data to temp file ..." )); - mView->saveCalendar( sentSyncFile() ); + mView->saveCalendarResource( sentSyncFile(), resource ); setCaption(i18n("Data saved to temp file!" )); mSyncManager->setBlockSave( false ); } -void MainWindow::getFile( bool success ) +void MainWindow::getFile( bool success ,const QString& resource) { if ( ! success ) { @@ -2728,5 +2730,5 @@ void MainWindow::getFile( bool success ) return; } - mView->mergeFile( sentSyncFile() ); + mView->mergeFileResource( sentSyncFile(), resource); if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { mSyncManager->slotSyncMenu( 999 ); diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index d8018b6..a533d8b 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -111,6 +111,6 @@ class MainWindow : public QMainWindow void slotResetFocusLoop(); void showConfigureAgenda(); - void getFile( bool ); - void syncFileRequest(); + void getFile( bool ,const QString &); + void syncFileRequest(const QString &); protected: |