summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-11-25 17:41:25 (UTC)
committer zautrix <zautrix>2005-11-25 17:41:25 (UTC)
commit279e183c0325cd9565605f60af0215bb9bfdc825 (patch) (side-by-side diff)
tree43ab776cd108874819e7c6e73070a7d989a9078f /korganizer
parent794a5204686ad9bfc16172b01db35f1f3b7683e5 (diff)
downloadkdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.zip
kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.gz
kdepimpi-279e183c0325cd9565605f60af0215bb9bfdc825.tar.bz2
sync
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp73
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp14
-rw-r--r--korganizer/mainwindow.h4
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,
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,16 +1904,21 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
}
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;
@@ -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)
{
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
Incidence *currentSelection();
void checkSuspendAlarm();
void mergeFile( QString fn );
+ void mergeFileResource( QString fn ,QString res);
signals:
void save ();
@@ -201,6 +202,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
public slots:
+ void multiResourceSyncStart( bool );
void displayCalendarInfo( int id );
void nextConflict( bool all, bool allday );
void conflictAll();
@@ -246,6 +248,7 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
successfully saved.
*/
bool saveCalendar(QString filename);
+ bool saveCalendarResource(QString filename, QString resource);
/**
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
void setScrollBarStep(int val );
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
@@ -374,8 +374,10 @@ 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 ) ) );
mSyncManager->fillSyncMenu();
@@ -2704,7 +2706,7 @@ QString MainWindow::sentSyncFile()
#endif
}
-void MainWindow::syncFileRequest()
+void MainWindow::syncFileRequest(const QString& resource)
{
while ( mSyncManager->blockSave() ) {
qApp->processEvents();
@@ -2716,18 +2718,18 @@ 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 ) {
setCaption( i18n("Error receiving file. Nothing changed!") );
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
@@ -110,8 +110,8 @@ class MainWindow : public QMainWindow
void slotResetFocus();
void slotResetFocusLoop();
void showConfigureAgenda();
- void getFile( bool );
- void syncFileRequest();
+ void getFile( bool ,const QString &);
+ void syncFileRequest(const QString &);
protected:
int mFocusLoop;