summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/calendarview.cpp57
-rw-r--r--korganizer/calendarview.h4
-rw-r--r--korganizer/mainwindow.cpp14
-rw-r--r--korganizer/mainwindow.h4
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
@@ -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 );
+ 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" ) {
diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h
index f85b6a3..60b1276 100644
--- a/korganizer/calendarview.h
+++ b/korganizer/calendarview.h
@@ -136,12 +136,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void addView(KOrg::BaseView *);
void showView(KOrg::BaseView *);
KOEventViewerDialog* getEventViewerDialog();
Incidence *currentSelection();
void checkSuspendAlarm();
void mergeFile( QString fn );
+ void mergeFileResource( QString fn ,QString res);
signals:
void save ();
void saveStopTimer ();
void tempDisableBR(bool);
/** This todo has been modified */
@@ -198,12 +199,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
void calendarViewExpanded( bool );
void updateSearchDialog();
void filtersUpdated();
public slots:
+ void multiResourceSyncStart( bool );
void displayCalendarInfo( int id );
void nextConflict( bool all, bool allday );
void conflictAll();
void conflictAllday();
void conflictNotAll();
void setCalReadOnly( int id, bool readO );
@@ -243,12 +245,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
/**
Save calendar data to file. Return true if calendar could be
successfully saved.
*/
bool saveCalendar(QString filename);
+ bool saveCalendarResource(QString filename, QString resource);
/**
Close calendar. Clear calendar data and reset views to display an empty
calendar.
*/
void closeCalendar();
@@ -536,12 +539,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser
int takeEvent( Incidence* local, Incidence* remote, int mode, bool full = false );
//Attendee* getYourAttendee(Event *event);
void setBlockShowDates( bool b ) { mBlockShowDates = b ;}
void setScrollBarStep(int val );
protected:
+ bool mMultiResourceSync;
Event *mConflictingEvent;
void schedule(Scheduler::Method, Incidence *incidence = 0);
// returns KMsgBox::OKCandel()
int msgItemDelete(const QString name);
void showEventEditor();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 66bb19b..69ccde1 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -371,14 +371,16 @@ MainWindow::MainWindow( QWidget *parent, const char *name ) :
//qDebug("MainView x %d y %d w %d h %d", mView->x(),mView-> y(), mView->width(), mView->height ());
//fillSyncMenu();
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();
@@ -2701,36 +2703,36 @@ QString MainWindow::sentSyncFile()
return QDir::convertSeparators( locateLocal( "tmp", "copysynccal.ics" ) );
#else
return QString( "/tmp/copysynccal.ics" );
#endif
}
-void MainWindow::syncFileRequest()
+void MainWindow::syncFileRequest(const QString& resource)
{
while ( mSyncManager->blockSave() ) {
qApp->processEvents();
}
mSyncManager->setBlockSave(true);
if ( KOPrefs::instance()->mPassiveSyncWithDesktop ) {
mSyncManager->slotSyncMenu( 999 );
}
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 );
}
setCaption( i18n("Pi-Sync successful!") );
}
void MainWindow::printListView()
diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h
index d8018b6..a533d8b 100644
--- a/korganizer/mainwindow.h
+++ b/korganizer/mainwindow.h
@@ -107,14 +107,14 @@ class MainWindow : public QMainWindow
signals:
void selectWeek ( int );
private slots:
void slotResetFocus();
void slotResetFocusLoop();
void showConfigureAgenda();
- void getFile( bool );
- void syncFileRequest();
+ void getFile( bool ,const QString &);
+ void syncFileRequest(const QString &);
protected:
int mFocusLoop;
void hideEvent ( QHideEvent * );
QString sentSyncFile();
void displayText( QString, QString);