author | zautrix <zautrix> | 2004-08-02 00:09:04 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-02 00:09:04 (UTC) |
commit | 3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0 (patch) (side-by-side diff) | |
tree | fdff56329649c084b6f5af8d8e96c0157686575e | |
parent | 3b4aa1cd78395c0f94b99decd901842944765746 (diff) | |
download | kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.zip kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.tar.gz kdepimpi-3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0.tar.bz2 |
More sync hacking
-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 @@ -851,9 +851,12 @@ 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 ) ); @@ -866,20 +869,43 @@ Event* CalendarView::getLastSyncEvent() } -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(); + } } @@ -900,10 +926,10 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int 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(); @@ -914,5 +940,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int 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 ) ); @@ -966,5 +992,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int uid = inR->uid(); bool skipIncidence = false; - if ( uid.left(21) == QString("last-syncEvent-device") ) + if ( uid.left(15) == QString("last-syncEvent-") ) skipIncidence = true; @@ -1016,5 +1042,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int ++addedEvent; } else { - checkSharpEvent(eventRSyncSharp, inR); + checkExternSyncEvent(eventRSyncSharp, inR); remote->deleteIncidence( inR ); ++deletedEventR; @@ -1043,5 +1069,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int 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" ) @@ -1064,5 +1090,5 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int } else { if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { - checkSharpEvent(eventLSyncSharp, inL); + checkExternSyncEvent(eventLSyncSharp, inL); local->deleteIncidence( inL ); ++deletedEventL; @@ -1343,5 +1369,5 @@ void CalendarView::setSyncEventsReadOnly() 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(); @@ -1807,5 +1833,5 @@ 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(); diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index 8aa5e1c..557554f 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -114,4 +114,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser KOEventViewerDialog* getEventViewerDialog(); Incidence *currentSelection(); + void setupExternSyncProfiles(); signals: @@ -482,5 +483,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser QDateTime loadedFileVersion; - void checkSharpEvent( Event* lastSync, Incidence* toDelete ); + void checkExternSyncEvent( QPtrList<Event> lastSync , Incidence* toDelete ); void checkZaurusId( int id, bool todo = false ); int mGlobalSyncMode; @@ -535,5 +536,5 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser Incidence *mSelectedIncidence; Incidence *mMoveIncidence; - + QPtrList<Event> mExternLastSyncEvent; KOTodoView *mTodoList; KOEventEditor * mEventEditor; diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 3ba5ab2..f3231ff 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -178,14 +178,15 @@ KOPrefs::KOPrefs() : 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); @@ -198,9 +199,9 @@ KOPrefs::KOPrefs() : 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" ); diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index fe044e6..424fa98 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -216,4 +216,5 @@ class KOPrefs : public KPimPrefs int mRingSyncAlgoPrefs; QStringList mSyncProfileNames; + QStringList mExternSyncProfiles; QString mLocalMachineName; void setCategoryColor(QString cat,const QColor & color); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 44b1264..6020a46 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -837,7 +837,9 @@ void MainWindow::fillSyncMenu() 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; @@ -852,4 +854,5 @@ void MainWindow::fillSyncMenu() syncMenu->setItemEnabled( false , 1000 ); } + mView->setupExternSyncProfiles(); } diff --git a/libkcal/calendar.h b/libkcal/calendar.h index 7d23619..df5bbcf 100644 --- a/libkcal/calendar.h +++ b/libkcal/calendar.h @@ -76,5 +76,5 @@ public: */ virtual void save() = 0; - + virtual QPtrList<Event> getExternLastSyncEvents() = 0; virtual bool isSaving() { return false; } diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 3c572f0..09ce9f0 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp @@ -223,4 +223,17 @@ Todo *CalendarLocal::todo( int id ) } +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 ) { @@ -321,5 +334,4 @@ QString CalendarLocal:: getAlarmNotification() return ret; } - void CalendarLocal::registerAlarm() { diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h index a2e50e3..3257198 100644 --- a/libkcal/calendarlocal.h +++ b/libkcal/calendarlocal.h @@ -86,5 +86,5 @@ class CalendarLocal : public Calendar */ QPtrList<Event> rawEvents(); - + QPtrList<Event> getExternLastSyncEvents(); /** Add a todo to the todolist. |