author | zautrix <zautrix> | 2005-11-25 17:41:25 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-11-25 17:41:25 (UTC) |
commit | 279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (unidiff) | |
tree | 43ab776cd108874819e7c6e73070a7d989a9078f /korganizer | |
parent | 794a5204686ad9bfc16172b01db35f1f3b7683e5 (diff) | |
download | kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.zip kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.gz kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.bz2 |
sync
-rw-r--r-- | korganizer/calendarview.cpp | 73 | ||||
-rw-r--r-- | korganizer/calendarview.h | 4 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 14 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 4 |
4 files changed, 78 insertions, 17 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, | |||
366 | 366 | ||
367 | void CalendarView::init() | 367 | void CalendarView::init() |
368 | { | 368 | { |
369 | mMultiResourceSync = false; | ||
369 | flag_blockConflict = false; | 370 | flag_blockConflict = false; |
370 | flag_blockScrollBar = false; | 371 | flag_blockScrollBar = false; |
371 | flag_checkFileFirsttime = true; | 372 | flag_checkFileFirsttime = true; |
@@ -1552,6 +1553,7 @@ Event* CalendarView::getLastSyncEvent() | |||
1552 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); | 1553 | lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); |
1553 | lse->setCategories( i18n("SyncEvent") ); | 1554 | lse->setCategories( i18n("SyncEvent") ); |
1554 | lse->setReadOnly( true ); | 1555 | lse->setReadOnly( true ); |
1556 | lse->setCalID( 1 ); | ||
1555 | mCalendar->addEvent( lse ); | 1557 | mCalendar->addEvent( lse ); |
1556 | } | 1558 | } |
1557 | 1559 | ||
@@ -1902,16 +1904,21 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int | |||
1902 | } | 1904 | } |
1903 | bar.hide(); | 1905 | bar.hide(); |
1904 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); | 1906 | mLastCalendarSync = QDateTime::currentDateTime().addSecs( 1 ); |
1905 | eventLSync->setReadOnly( false ); | 1907 | if ( mMultiResourceSync ) { |
1906 | eventLSync->setDtStart( mLastCalendarSync ); | 1908 | remote->removeSyncInfo( "" ); //all |
1907 | eventRSync->setDtStart( mLastCalendarSync ); | 1909 | |
1908 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1910 | } else { |
1909 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | 1911 | eventLSync->setReadOnly( false ); |
1910 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | 1912 | eventLSync->setDtStart( mLastCalendarSync ); |
1911 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | 1913 | eventRSync->setDtStart( mLastCalendarSync ); |
1912 | eventLSync->setReadOnly( true ); | 1914 | eventLSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); |
1915 | eventRSync->setDtEnd( mLastCalendarSync.addSecs( 3600 ) ); | ||
1916 | eventRSync->setLocation( i18n("Remote from: ")+mCurrentSyncName ) ; | ||
1917 | eventLSync->setLocation(i18n("Local from: ") + mCurrentSyncName ); | ||
1918 | eventLSync->setReadOnly( true ); | ||
1919 | } | ||
1913 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); | 1920 | qDebug("KO: Normal sync: %d ",mGlobalSyncMode == SYNC_MODE_NORMAL ); |
1914 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop()) // kde is abnormal... | 1921 | if ( mGlobalSyncMode == SYNC_MODE_NORMAL && !mSyncManager->syncWithDesktop() && !mMultiResourceSync ) // kde is abnormal... |
1915 | remote->addEvent( eventRSync ); | 1922 | remote->addEvent( eventRSync ); |
1916 | else | 1923 | else |
1917 | delete eventRSync; | 1924 | delete eventRSync; |
@@ -2435,6 +2442,32 @@ void CalendarView::mergeFile( QString fn ) | |||
2435 | updateUnmanagedViews(); | 2442 | updateUnmanagedViews(); |
2436 | updateView(); | 2443 | updateView(); |
2437 | } | 2444 | } |
2445 | void CalendarView::mergeFileResource( QString fn ,QString resource ) | ||
2446 | { | ||
2447 | |||
2448 | if ( resource == "ALL" ) { | ||
2449 | mergeFile( fn ); | ||
2450 | return; | ||
2451 | } | ||
2452 | |||
2453 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
2454 | if ( !exclusiveResource ) { | ||
2455 | qDebug("KO: CalendarView::mergeFileResource: resource not found %s", resource.latin1() ); | ||
2456 | return; | ||
2457 | } | ||
2458 | clearAllViews(); | ||
2459 | mCalendar->setCalendarRemove( exclusiveResource ); | ||
2460 | int def = mCalendar->defaultCalendar(); | ||
2461 | mCalendar->setDefaultCalendar(exclusiveResource); | ||
2462 | if ( !mCalendar->addCalendarFile( fn, exclusiveResource )) { | ||
2463 | qDebug("KO: CalendarView::mergeFileResource: error adding file %s", fn.latin1() ); | ||
2464 | } | ||
2465 | mCalendar->setDefaultCalendar( def ); | ||
2466 | mCalendar->reInitAlarmSettings(); | ||
2467 | setSyncEventsReadOnly(); | ||
2468 | updateUnmanagedViews(); | ||
2469 | updateView(); | ||
2470 | } | ||
2438 | void CalendarView::showOpenError() | 2471 | void CalendarView::showOpenError() |
2439 | { | 2472 | { |
2440 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); | 2473 | KMessageBox::error(this,i18n("Couldn't load calendar\n.")); |
@@ -2522,6 +2555,7 @@ bool CalendarView::checkFileVersion(QString fn) | |||
2522 | mSyncManager->mWriteBackFile = false; | 2555 | mSyncManager->mWriteBackFile = false; |
2523 | mSyncManager->mWriteBackExistingOnly = false; | 2556 | mSyncManager->mWriteBackExistingOnly = false; |
2524 | mSyncManager->mShowSyncSummary = false; | 2557 | mSyncManager->mShowSyncSummary = false; |
2558 | mMultiResourceSync = false; | ||
2525 | syncCalendar( fn, 3 ); | 2559 | syncCalendar( fn, 3 ); |
2526 | Event * e = getLastSyncEvent(); | 2560 | Event * e = getLastSyncEvent(); |
2527 | if ( e ) | 2561 | if ( e ) |
@@ -2558,6 +2592,23 @@ bool CalendarView::saveCalendars() | |||
2558 | } | 2592 | } |
2559 | return true; | 2593 | return true; |
2560 | } | 2594 | } |
2595 | bool CalendarView::saveCalendarResource(QString filename, QString resource) | ||
2596 | { | ||
2597 | if ( resource == "ALL" ) | ||
2598 | return saveCalendar( filename ); | ||
2599 | int exclusiveResource = KOPrefs::instance()->getFuzzyCalendarID( resource ); | ||
2600 | if ( !exclusiveResource ) { | ||
2601 | qDebug("KO: CalendarView::saveCalendarResource: resource not found %s", resource.latin1() ); | ||
2602 | return false; | ||
2603 | } | ||
2604 | mCalendar->setDefaultCalendar( exclusiveResource ); | ||
2605 | mCalendar->setDefaultCalendarEnabledOnly(); | ||
2606 | mCalendar->setSyncEventsEnabled(); | ||
2607 | bool res = saveCalendar( filename ); | ||
2608 | restoreCalendarSettings(); | ||
2609 | return res; | ||
2610 | |||
2611 | } | ||
2561 | bool CalendarView::saveCalendar( QString filename ) | 2612 | bool CalendarView::saveCalendar( QString filename ) |
2562 | { | 2613 | { |
2563 | 2614 | ||
@@ -5032,7 +5083,11 @@ void CalendarView::keyPressEvent ( QKeyEvent *e) | |||
5032 | e->ignore(); | 5083 | e->ignore(); |
5033 | } | 5084 | } |
5034 | 5085 | ||
5086 | void CalendarView::multiResourceSyncStart( bool start ) | ||
5087 | { | ||
5088 | mMultiResourceSync = start; | ||
5035 | 5089 | ||
5090 | } | ||
5036 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) | 5091 | bool CalendarView::sync(KSyncManager* manager, QString filename, int mode,QString resource) |
5037 | { | 5092 | { |
5038 | 5093 | ||
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index f85b6a3..60b1276 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h | |||
@@ -139,6 +139,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
139 | Incidence *currentSelection(); | 139 | Incidence *currentSelection(); |
140 | void checkSuspendAlarm(); | 140 | void checkSuspendAlarm(); |
141 | void mergeFile( QString fn ); | 141 | void mergeFile( QString fn ); |
142 | void mergeFileResource( QString fn ,QString res); | ||
142 | 143 | ||
143 | signals: | 144 | signals: |
144 | void save (); | 145 | void save (); |
@@ -201,6 +202,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
201 | 202 | ||
202 | 203 | ||
203 | public slots: | 204 | public slots: |
205 | void multiResourceSyncStart( bool ); | ||
204 | void displayCalendarInfo( int id ); | 206 | void displayCalendarInfo( int id ); |
205 | void nextConflict( bool all, bool allday ); | 207 | void nextConflict( bool all, bool allday ); |
206 | void conflictAll(); | 208 | void conflictAll(); |
@@ -246,6 +248,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
246 | successfully saved. | 248 | successfully saved. |
247 | */ | 249 | */ |
248 | bool saveCalendar(QString filename); | 250 | bool saveCalendar(QString filename); |
251 | bool saveCalendarResource(QString filename, QString resource); | ||
249 | 252 | ||
250 | /** | 253 | /** |
251 | Close calendar. Clear calendar data and reset views to display an empty | 254 | Close calendar. Clear calendar data and reset views to display an empty |
@@ -539,6 +542,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser | |||
539 | void setScrollBarStep(int val ); | 542 | void setScrollBarStep(int val ); |
540 | 543 | ||
541 | protected: | 544 | protected: |
545 | bool mMultiResourceSync; | ||
542 | Event *mConflictingEvent; | 546 | Event *mConflictingEvent; |
543 | void schedule(Scheduler::Method, Incidence *incidence = 0); | 547 | void schedule(Scheduler::Method, Incidence *incidence = 0); |
544 | 548 | ||
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 66bb19b..69ccde1 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp | |||
@@ -374,8 +374,10 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) : | |||
374 | 374 | ||
375 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); | 375 | connect(mSyncManager , SIGNAL( save() ), this, SLOT( save() ) ); |
376 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); | 376 | connect(mView , SIGNAL( saveStopTimer() ), this, SLOT( saveStopTimer() ) ); |
377 | connect(mSyncManager , SIGNAL( request_file() ), this, SLOT( syncFileRequest() ) ); | 377 | connect(mSyncManager , SIGNAL( request_file(const QString &) ), this, SLOT( syncFileRequest(const QString &) ) ); |
378 | connect(mSyncManager , SIGNAL( getFile( bool )), this, SLOT(getFile( bool ) ) ); | 378 | connect(mSyncManager , SIGNAL( getFile( bool, const QString &)), this, SLOT(getFile( bool,const QString & ) ) ); |
379 | connect(mSyncManager , SIGNAL( multiResourceSyncStart( bool )), mView, SLOT( multiResourceSyncStart( bool ) ) ); | ||
380 | |||
379 | mSyncManager->setDefaultFileName( sentSyncFile()); | 381 | mSyncManager->setDefaultFileName( sentSyncFile()); |
380 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); | 382 | connect ( syncMenu, SIGNAL( activated ( int ) ), mSyncManager, SLOT (slotSyncMenu( int ) ) ); |
381 | mSyncManager->fillSyncMenu(); | 383 | mSyncManager->fillSyncMenu(); |
@@ -2704,7 +2706,7 @@ QString MainWindow::sentSyncFile() | |||
2704 | #endif | 2706 | #endif |
2705 | } | 2707 | } |
2706 | 2708 | ||
2707 | void MainWindow::syncFileRequest() | 2709 | void MainWindow::syncFileRequest(const QString& resource) |
2708 | { | 2710 | { |
2709 | while ( mSyncManager->blockSave() ) { | 2711 | while ( mSyncManager->blockSave() ) { |
2710 | qApp->processEvents(); | 2712 | qApp->processEvents(); |
@@ -2716,18 +2718,18 @@ void MainWindow::syncFileRequest() | |||
2716 | } | 2718 | } |
2717 | 2719 | ||
2718 | setCaption(i18n("Saving Data to temp file ..." )); | 2720 | setCaption(i18n("Saving Data to temp file ..." )); |
2719 | mView->saveCalendar( sentSyncFile() ); | 2721 | mView->saveCalendarResource( sentSyncFile(), resource ); |
2720 | setCaption(i18n("Data saved to temp file!" )); | 2722 | setCaption(i18n("Data saved to temp file!" )); |
2721 | mSyncManager->setBlockSave( false ); | 2723 | mSyncManager->setBlockSave( false ); |
2722 | 2724 | ||
2723 | } | 2725 | } |
2724 | void MainWindow::getFile( bool success ) | 2726 | void MainWindow::getFile( bool success ,const QString& resource) |
2725 | { | 2727 | { |
2726 | if ( ! success ) { | 2728 | if ( ! success ) { |
2727 | setCaption( i18n("Error receiving file. Nothing changed!") ); | 2729 | setCaption( i18n("Error receiving file. Nothing changed!") ); |
2728 | return; | 2730 | return; |
2729 | } | 2731 | } |
2730 | mView->mergeFile( sentSyncFile() ); | 2732 | mView->mergeFileResource( sentSyncFile(), resource); |
2731 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { | 2733 | if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) { |
2732 | mSyncManager->slotSyncMenu( 999 ); | 2734 | mSyncManager->slotSyncMenu( 999 ); |
2733 | } | 2735 | } |
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index d8018b6..a533d8b 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h | |||
@@ -110,8 +110,8 @@ class MainWindow : public QMainWindow | |||
110 | void slotResetFocus(); | 110 | void slotResetFocus(); |
111 | void slotResetFocusLoop(); | 111 | void slotResetFocusLoop(); |
112 | void showConfigureAgenda(); | 112 | void showConfigureAgenda(); |
113 | void getFile( bool ); | 113 | void getFile( bool ,const QString &); |
114 | void syncFileRequest(); | 114 | void syncFileRequest(const QString &); |
115 | 115 | ||
116 | protected: | 116 | protected: |
117 | int mFocusLoop; | 117 | int mFocusLoop; |