-rw-r--r-- | korganizer/calendarview.cpp | 76 | ||||
-rw-r--r-- | korganizer/calendarview.h | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 27 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 | ||||
-rw-r--r-- | libkcal/calendar.h | 2 | ||||
-rw-r--r-- | libkcal/calendarlocal.cpp | 14 | ||||
-rw-r--r-- | libkcal/calendarlocal.h | 2 |
8 files changed, 87 insertions, 43 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index cfc6b10..9160e1d 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -845,47 +845,73 @@ int CalendarView::takeEvent( Incidence* local, Incidence* remote, int mode , b break; } return 0; } Event* CalendarView::getLastSyncEvent() { Event* lse; //qDebug("CurrentSyncDevice %s ",mCurrentSyncDevice .latin1() ); - lse = mCalendar->event( "last-syncEvent-device-"+mCurrentSyncDevice ); + lse = mCalendar->event( "last-syncEvent-"+mCurrentSyncDevice ); if (!lse) { lse = new Event(); - lse->setUid( "last-syncEvent-device-"+mCurrentSyncDevice ); - lse->setSummary(mCurrentSyncDevice + i18n(" - sync event")); + lse->setUid( "last-syncEvent-"+mCurrentSyncDevice ); + QString sum = ""; + if ( KOPrefs::instance()->mExternSyncProfiles.contains( mCurrentSyncDevice ) ) + sum = "E: "; + lse->setSummary(sum+mCurrentSyncDevice + i18n(" - sync event")); lse->setDtStart( mLastCalendarSync ); lse->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); lse->setCategories( i18n("SyncEvent") ); lse->setReadOnly( true ); mCalendar->addEvent( lse ); } return lse; } -void CalendarView::checkSharpEvent( Event* lastSync, Incidence* toDelete ) +void CalendarView::setupExternSyncProfiles() { - if ( ! lastSync ) - return; - if ( toDelete->zaurusId() < 0 ) + Event* lse; + mExternLastSyncEvent.clear(); + int i; + for ( i = 0; i < KOPrefs::instance()->mExternSyncProfiles.count(); ++i ) { + lse = mCalendar->event( "last-syncEvent-"+ KOPrefs::instance()->mExternSyncProfiles[i] ); + if ( lse ) + mExternLastSyncEvent.append( lse ); + else + qDebug("Last Sync event not found for %s ", KOPrefs::instance()->mExternSyncProfiles[i].latin1()); + } + +} +// we check, if the to delete event has a id for a profile +// if yes, we set this id in the profile to delete +void CalendarView::checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ) +{ + if ( ! lastSync.count() == 0 ) return; if ( toDelete->type() == "Journal" ) return; - QString des = lastSync->description(); - QString pref = "e"; - if ( toDelete->type() == "Todo" ) - pref = "t"; - des += pref+ QString::number ( toDelete->zaurusId() ) + ","; - lastSync->setReadOnly( false ); - lastSync->setDescription( des ); - lastSync->setReadOnly( true ); + + Event* eve = lastSync.first(); + + while ( eve ) { + int id = toDelete->getID( eve->uid().mid( 15 ) ); // this is the sync profile name + if ( id >= 0 ) { + QString des = eve->description(); + QString pref = "e"; + if ( toDelete->type() == "Todo" ) + pref = "t"; + des += pref+ QString::number ( id ) + ","; + eve->setReadOnly( false ); + eve->setDescription( des ); + eve->setReadOnly( true ); + } + eve = lastSync.next(); + } } bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int mode ) { bool syncOK = true; int addedEvent = 0; int addedEventR = 0; int deletedEventR = 0; @@ -894,31 +920,31 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int int changedRemote = 0; //QPtrList<Event> el = local->rawEvents(); Event* eventR; QString uid; int take; Event* eventL; Event* eventRSync; Event* eventLSync; - Event* eventRSyncSharp = remote->event( "last-syncEvent-device-Sharp-DTM"); - Event* eventLSyncSharp = local->event( "last-syncEvent-device-Sharp-DTM"); + QPtrList<Event> eventRSyncSharp = remote->getExternLastSyncEvents(); + QPtrList<Event> eventLSyncSharp = local->getExternLastSyncEvents(); bool fullDateRange = false; mLastCalendarSync = QDateTime::currentDateTime(); QDateTime modifiedCalendar = mLastCalendarSync;; - eventR = remote->event("last-syncEvent-device-"+mCurrentSyncName ); + eventR = remote->event("last-syncEvent-"+mCurrentSyncName ); if ( eventR ) { eventRSync = (Event*) eventR->clone(); remote->deleteEvent(eventR ); } else { fullDateRange = true; eventRSync = new Event(); eventRSync->setSummary(mCurrentSyncName + i18n(" - sync event")); - eventRSync->setUid("last-syncEvent-device-"+mCurrentSyncName ); + eventRSync->setUid("last-syncEvent-"+mCurrentSyncName ); eventRSync->setDtStart( mLastCalendarSync ); eventRSync->setDtEnd( mLastCalendarSync.addSecs( 7200 ) ); eventRSync->setCategories( i18n("SyncEvent") ); } eventLSync = getLastSyncEvent(); if ( eventLSync->dtStart() == mLastCalendarSync ) fullDateRange = true; @@ -960,17 +986,17 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int while ( inR ) { if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inR->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; qApp->processEvents(); if ( !skipIncidence ) { inL = local->incidence( uid ); if ( inL ) { // maybe conflict - same uid in both calendars int maxrev = inL->revision(); if ( maxrev < inR->revision() ) @@ -1010,17 +1036,17 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int ++addedEvent; } } else { if ( inR->lastModified() > mLastCalendarSync || mode == 5 ) { inR->setLastModified( modifiedCalendar ); local->addIncidence( inR->clone() ); ++addedEvent; } else { - checkSharpEvent(eventRSyncSharp, inR); + checkExternSyncEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); ++deletedEventR; } } } } inR = er.next(); } @@ -1037,17 +1063,17 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int qApp->processEvents(); if ( ! bar.isVisible() ) return false; if ( incCounter % modulo == 0 ) bar.setProgress( incCounter ); ++incCounter; uid = inL->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->type() == "Journal" ) skipIncidence = true; if ( !skipIncidence ) { inR = remote->incidence( uid ); if ( ! inR ) { if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { if ( inL->zaurusId() >= 0 && mode != 4 ) { @@ -1058,17 +1084,17 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int inL->setZaurusId( -1 ); ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } } } else { if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { - checkSharpEvent(eventLSyncSharp, inL); + checkExternSyncEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; } else { if ( ! KOPrefs::instance()->mWriteBackExistingOnly ) { ++addedEventR; inL->setLastModified( modifiedCalendar ); remote->addIncidence( inL->clone() ); } @@ -1337,17 +1363,17 @@ bool CalendarView::importQtopia( const QString &categories, } void CalendarView::setSyncEventsReadOnly() { Event * ev; QPtrList<Event> eL = mCalendar->rawEvents(); ev = eL.first(); while ( ev ) { - if ( ev->uid().left(21) == QString("last-syncEvent-device") ) + if ( ev->uid().left(15) == QString("last-syncEvent-") ) ev->setReadOnly( true ); ev = eL.next(); } } bool CalendarView::openCalendar(QString filename, bool merge) { if (filename.isEmpty()) { @@ -1801,17 +1827,17 @@ void CalendarView::eventDeleted() } void CalendarView::changeTodoDisplay(Todo *which, int action) { changeIncidenceDisplay((Incidence *)which, action); } void CalendarView::checkZaurusId( int id, bool todo ) { if ( id >= 0 ) { - Incidence* lse = mCalendar->event( "last-syncEvent-device-Sharp-DTM"); + Incidence* lse = mCalendar->event( "last-syncEvent-Sharp-DTM"); if ( lse ) { QString des = lse->description(); QString pref = "e"; if ( todo ) pref = "t"; des += pref+ QString::number ( id ) + ","; lse->setReadOnly( false ); lse->setDescription( des ); diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 8aa5e1c..557554f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -108,16 +108,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser DateNavigator *dateNavigator(); KDateNavigator *dateNavigatorWidget(); void addView(KOrg::BaseView *); void showView(KOrg::BaseView *); KOEventViewerDialog* getEventViewerDialog(); Incidence *currentSelection(); + void setupExternSyncProfiles(); signals: /** This todo has been modified */ void todoModified(Todo *, int); /** when change is made to options dialog, the topwidget will catch this * and emit this signal which notifies all widgets which have registered * for notification to update their settings. */ @@ -476,17 +477,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; void computeAlarm( QString ); void startAlarm( QString, QString ); void setSyncEventsReadOnly(); QDateTime loadedFileVersion; - void checkSharpEvent( Event* lastSync, Incidence* toDelete ); + void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); void checkZaurusId( int id, bool todo = false ); int mGlobalSyncMode; QString mCurrentSyncDevice; QString mCurrentSyncName; KOBeamPrefs* beamDialog; void init(); int mDatePickerMode; bool mFlagEditDescription; @@ -529,17 +530,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser // various housekeeping variables. bool mModified; // flag indicating if calendar is modified bool mReadOnly; // flag indicating if calendar is read-only QDate mSaveSingleDate; Incidence *mSelectedIncidence; Incidence *mMoveIncidence; - + QPtrList<Event> mExternLastSyncEvent; KOTodoView *mTodoList; KOEventEditor * mEventEditor; KOTodoEditor * mTodoEditor; KOEventViewerDialog * mEventViewerDialog; void keyPressEvent ( QKeyEvent *e) ; //QMap<Incidence*,KOIncidenceEditor*> mDialogList; }; diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 3ba5ab2..f3231ff 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -172,41 +172,42 @@ KOPrefs::KOPrefs() : addItemFont("TodoView Font",&mTodoViewFont); addItemFont("ListView Font",&mListViewFont); addItemFont("DateNavigator Font",&mDateNavigatorFont); addItemFont("EditBox Font",&mEditBoxFont); addItemFont("JournalView Font",&mJornalViewFont); addItemFont("WhatsNextView Font",&mWhatsNextFont); addItemFont("EventView Font",&mEventViewFont); - KPrefs::setCurrentGroup("SyncProfiles"); - addItemString("LocalMachineName",&mLocalMachineName, "undefined"); - addItemStringList("SyncProfileNames",&mSyncProfileNames); +// KPrefs::setCurrentGroup("SyncProfiles"); +// addItemString("LocalMachineName",&mLocalMachineName, "undefined"); +// addItemStringList("SyncProfileNames",&mSyncProfileNames); +// addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); KPrefs::setCurrentGroup("RemoteSyncing"); - addItemBool("UsePasswd",&mUsePassWd,false); - addItemBool("WriteBackFile",&mWriteBackFile,true); - addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); - addItemBool("AskForPreferences",&mAskForPreferences,true); - addItemBool("ShowSyncSummary",&mShowSyncSummary,true); +// addItemBool("UsePasswd",&mUsePassWd,false); +// addItemBool("WriteBackFile",&mWriteBackFile,true); +// addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); +// addItemBool("AskForPreferences",&mAskForPreferences,true); +// addItemBool("ShowSyncSummary",&mShowSyncSummary,true); addItemBool("ShowSyncEvents",&mShowSyncEvents,false); addItemInt("LastSyncTime",&mLastSyncTime,0); addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif - addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); - addItemString("RemoteUser",&mRemoteUser, "zaurus"); - addItemString("RemotePassWd",&mRemotePassWd, ""); - addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); - addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); +// addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); +// addItemString("RemoteUser",&mRemoteUser, "zaurus"); +// addItemString("RemotePassWd",&mRemotePassWd, ""); +// addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); +// addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); KPrefs::setCurrentGroup("LoadSaveFileNames"); addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index fe044e6..424fa98 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -210,16 +210,17 @@ class KOPrefs : public KPimPrefs QString mRemotePassWd; QString mRemoteFile; QString mLocalTempFile; int mLastSyncTime; int mSyncAlgoPrefs; int mRingSyncAlgoPrefs; QStringList mSyncProfileNames; + QStringList mExternSyncProfiles; QString mLocalMachineName; void setCategoryColor(QString cat,const QColor & color); QColor *categoryColor(QString cat); QString mArchiveFile; QString mHtmlExportFile; bool mHtmlWithSave; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 44b1264..6020a46 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -831,31 +831,34 @@ void MainWindow::fillSyncMenu() temp->setName( prof[0] ); temp->writeConfig(&config); temp->setName( prof[1] ); temp->writeConfig(&config); temp->setName( prof[2] ); temp->writeConfig(&config); config.setGroup("General"); config.writeEntry("SyncProfileNames",prof); + config.writeEntry("ExternSyncProfiles","Sharp_DTM"); config.sync(); delete temp; } + KOPrefs::instance()->mExternSyncProfiles = config.readListEntry("ExternSyncProfiles"); KOPrefs::instance()->mSyncProfileNames = prof; int i; for ( i = 0; i < prof.count(); ++i ) { syncMenu->insertItem( prof[i], 1000+i ); if ( i == 2 ) syncMenu->insertSeparator(); } QDir app_dir; if ( !app_dir.exists(QDir::homeDirPath()+"/Applications/dtm" ) ) { syncMenu->setItemEnabled( false , 1000 ); } + mView->setupExternSyncProfiles(); } int MainWindow::ringSync() { int syncedProfiles = 0; int i; QTime timer; KConfig config ( locateLocal( "config","syncprofilesrc" ) ); diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 7d23619..df5bbcf 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -70,17 +70,17 @@ public: Clears out the current calendar, freeing all used memory etc. */ virtual void close() = 0; /** Sync changes in memory to persistant storage. */ virtual void save() = 0; - + virtual QPtrList<Event> getExternLastSyncEvents() = 0; virtual bool isSaving() { return false; } /** Return the owner of the calendar's full name. */ const QString &getOwner() const; /** Set the owner of the calendar. Should be owner's full name. diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3c572f0..09ce9f0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -217,16 +217,29 @@ Todo *CalendarLocal::todo( int id ) Todo *todo; for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { if ( todo->zaurusId() == id ) return todo; } return 0; } +QPtrList<Event> CalendarLocal::getExternLastSyncEvents() +{ + QPtrList<Event> el; + Event *todo; + for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { + if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) + if ( todo->summary().left(3) == "E: " ) + el.append( todo ); + } + + return el; + +} Event *CalendarLocal::event( int id ) { Event *todo; for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { if ( todo->zaurusId() == id ) return todo; } return 0; @@ -315,17 +328,16 @@ QString CalendarLocal:: getAlarmNotification() ret = "audio_alarm" +alarm->audioFile() +"+++"; } ret += "cal_alarm"+ mNextSummary.left( 25 ); if ( mNextSummary.length() > 25 ) ret += "\n" + mNextSummary.mid(25, 25 ); ret+= "\n"+mNextAlarmEventDateTimeString; return ret; } - void CalendarLocal::registerAlarm() { mLastAlarmNotificationString = getAlarmNotification(); // qDebug("++ register Alarm %s %s",mNextAlarmDateTime.toString().latin1(), mLastAlarmNotificationString.latin1() ); emit addAlarm ( mNextAlarmDateTime, mLastAlarmNotificationString ); // #ifndef DESKTOP_VERSION // AlarmServer::addAlarm ( mNextAlarmDateTime,"koalarm", mLastAlarmNotificationString.latin1() ); // #endif diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a2e50e3..3257198 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -80,17 +80,17 @@ class CalendarLocal : public Calendar /** Retrieves an event on the basis of the unique string ID. */ Event *event( const QString &uid ); /** Return unfiltered list of all events in calendar. */ QPtrList<Event> rawEvents(); - + QPtrList<Event> getExternLastSyncEvents(); /** Add a todo to the todolist. */ bool addTodo( Todo *todo ); bool addTodoNoDup( Todo *todo ); /** Remove a todo from the todolist. */ |