summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-11-26 11:20:22 (UTC)
committer zautrix <zautrix>2005-11-26 11:20:22 (UTC)
commit85bd9f05564e566b296c949ce6e214ebdbf573ac (patch) (unidiff)
treeb00eb9453ea06f2b43fd896a9a4840b7d64af69b
parent3cd0013c04172b312ee21e80224a3b7734b4d413 (diff)
downloadkdepimpi-85bd9f05564e566b296c949ce6e214ebdbf573ac.zip
kdepimpi-85bd9f05564e566b296c949ce6e214ebdbf573ac.tar.gz
kdepimpi-85bd9f05564e566b296c949ce6e214ebdbf573ac.tar.bz2
sync
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/calendarview.cpp4
-rw-r--r--libkcal/calendar.h2
-rw-r--r--libkcal/calendarlocal.cpp11
-rw-r--r--libkcal/calendarlocal.h2
4 files changed, 14 insertions, 5 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp
index 538325e..9571f16 100644
--- a/korganizer/calendarview.cpp
+++ b/korganizer/calendarview.cpp
@@ -1697,49 +1697,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1697 } 1697 }
1698 int w = 300; 1698 int w = 300;
1699 if ( QApplication::desktop()->width() < 320 ) 1699 if ( QApplication::desktop()->width() < 320 )
1700 w = 220; 1700 w = 220;
1701 int h = bar.sizeHint().height() ; 1701 int h = bar.sizeHint().height() ;
1702 int dw = QApplication::desktop()->width(); 1702 int dw = QApplication::desktop()->width();
1703 int dh = QApplication::desktop()->height(); 1703 int dh = QApplication::desktop()->height();
1704 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 1704 bar.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
1705 bar.show(); 1705 bar.show();
1706 int modulo = (er.count()/10)+1; 1706 int modulo = (er.count()/10)+1;
1707 int incCounter = 0; 1707 int incCounter = 0;
1708 while ( inR ) { 1708 while ( inR ) {
1709 if ( ! bar.isVisible() ) 1709 if ( ! bar.isVisible() )
1710 return false; 1710 return false;
1711 if ( incCounter % modulo == 0 ) 1711 if ( incCounter % modulo == 0 )
1712 bar.setProgress( incCounter ); 1712 bar.setProgress( incCounter );
1713 ++incCounter; 1713 ++incCounter;
1714 uid = inR->uid(); 1714 uid = inR->uid();
1715 bool skipIncidence = false; 1715 bool skipIncidence = false;
1716 if ( uid.left(15) == QString("last-syncEvent-") ) 1716 if ( uid.left(15) == QString("last-syncEvent-") )
1717 skipIncidence = true; 1717 skipIncidence = true;
1718 QString idS; 1718 QString idS;
1719 qApp->processEvents(); 1719 qApp->processEvents();
1720 if ( !skipIncidence ) { 1720 if ( !skipIncidence ) {
1721 inL = local->incidenceForUid( uid , false ); 1721 inL = local->incidenceForUid( uid , false , true );
1722 if ( inL ) { // maybe conflict - same uid in both calendars 1722 if ( inL ) { // maybe conflict - same uid in both calendars
1723 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) { 1723 if ( (take = takeEvent( inL, inR, mode, fullDateRange )) > 0 ) {
1724 //qDebug("take %d %s ", take, inL->summary().latin1()); 1724 //qDebug("take %d %s ", take, inL->summary().latin1());
1725 if ( take == 3 ) 1725 if ( take == 3 )
1726 return false; 1726 return false;
1727 if ( take == 1 ) {// take local ********************** 1727 if ( take == 1 ) {// take local **********************
1728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) 1728 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL )
1729 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) ); 1729 inL->setCsum( mCurrentSyncDevice, inR->getCsum(mCurrentSyncDevice) );
1730 else 1730 else
1731 idS = inR->IDStr(); 1731 idS = inR->IDStr();
1732 int calID = inR->calID(); 1732 int calID = inR->calID();
1733 remote->deleteIncidence( inR ); 1733 remote->deleteIncidence( inR );
1734 inR = inL->clone(); 1734 inR = inL->clone();
1735 inR->setCalID( calID ); 1735 inR->setCalID( calID );
1736 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1736 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1737 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL ) 1737 if ( mGlobalSyncMode != SYNC_MODE_EXTERNAL )
1738 inR->setIDStr( idS ); 1738 inR->setIDStr( idS );
1739 remote->addIncidence( inR ); 1739 remote->addIncidence( inR );
1740 if ( mSyncManager->syncWithDesktop() ) 1740 if ( mSyncManager->syncWithDesktop() )
1741 inR->setPilotId( 2 ); 1741 inR->setPilotId( 2 );
1742 ++changedRemote; 1742 ++changedRemote;
1743 } else {// take remote ********************** 1743 } else {// take remote **********************
1744 if ( !inL->isReadOnly() ) { 1744 if ( !inL->isReadOnly() ) {
1745 idS = inL->IDStr(); 1745 idS = inL->IDStr();
@@ -1807,49 +1807,49 @@ bool CalendarView::synchronizeCalendar( Calendar* local, Calendar* remote, int
1807 } 1807 }
1808 QPtrList<Incidence> el = local->rawIncidences(); 1808 QPtrList<Incidence> el = local->rawIncidences();
1809 inL = el.first(); 1809 inL = el.first();
1810 modulo = (el.count()/10)+1; 1810 modulo = (el.count()/10)+1;
1811 bar.setCaption (i18n("Add / remove events") ); 1811 bar.setCaption (i18n("Add / remove events") );
1812 bar.setTotalSteps ( el.count() ) ; 1812 bar.setTotalSteps ( el.count() ) ;
1813 bar.show(); 1813 bar.show();
1814 incCounter = 0; 1814 incCounter = 0;
1815 1815
1816 while ( inL ) { 1816 while ( inL ) {
1817 1817
1818 qApp->processEvents(); 1818 qApp->processEvents();
1819 if ( ! bar.isVisible() ) 1819 if ( ! bar.isVisible() )
1820 return false; 1820 return false;
1821 if ( incCounter % modulo == 0 ) 1821 if ( incCounter % modulo == 0 )
1822 bar.setProgress( incCounter ); 1822 bar.setProgress( incCounter );
1823 ++incCounter; 1823 ++incCounter;
1824 uid = inL->uid(); 1824 uid = inL->uid();
1825 bool skipIncidence = false; 1825 bool skipIncidence = false;
1826 if ( uid.left(15) == QString("last-syncEvent-") ) 1826 if ( uid.left(15) == QString("last-syncEvent-") )
1827 skipIncidence = true; 1827 skipIncidence = true;
1828 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID ) 1828 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL && inL->typeID() == journalID )
1829 skipIncidence = true; 1829 skipIncidence = true;
1830 if ( !skipIncidence ) { 1830 if ( !skipIncidence ) {
1831 inR = remote->incidenceForUid( uid , true ); 1831 inR = remote->incidenceForUid( uid , true, true );
1832 if ( ! inR ) { 1832 if ( ! inR ) {
1833 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){ 1833 if ( !filterOUT || filterOUT->filterCalendarItem( inL ) ){
1834 // no conflict ********** add or delete local 1834 // no conflict ********** add or delete local
1835 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) { 1835 if ( mGlobalSyncMode == SYNC_MODE_EXTERNAL ) {
1836 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) { 1836 if ( !inL->getID(mCurrentSyncDevice).isEmpty() && mode != 4 ) {
1837 checkExternSyncEvent(eventLSyncSharp, inL); 1837 checkExternSyncEvent(eventLSyncSharp, inL);
1838 local->deleteIncidence( inL ); 1838 local->deleteIncidence( inL );
1839 ++deletedEventL; 1839 ++deletedEventL;
1840 } else { 1840 } else {
1841 if ( ! mSyncManager->mWriteBackExistingOnly ) { 1841 if ( ! mSyncManager->mWriteBackExistingOnly ) {
1842 inL->removeID(mCurrentSyncDevice ); 1842 inL->removeID(mCurrentSyncDevice );
1843 ++addedEventR; 1843 ++addedEventR;
1844 //qDebug("remote added Incidence %s ", inL->summary().latin1()); 1844 //qDebug("remote added Incidence %s ", inL->summary().latin1());
1845 inL->setLastModified( modifiedCalendar ); 1845 inL->setLastModified( modifiedCalendar );
1846 inR = inL->clone(); 1846 inR = inL->clone();
1847 inR->setIDStr( ":" ); 1847 inR->setIDStr( ":" );
1848 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL ); 1848 inR->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
1849 inR->setCalID( 0 );// add to default cal 1849 inR->setCalID( 0 );// add to default cal
1850 remote->addIncidence( inR ); 1850 remote->addIncidence( inR );
1851 } 1851 }
1852 } 1852 }
1853 } else { 1853 } else {
1854 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) { 1854 if ( inL->lastModified() < mLastCalendarSync && mode != 4 ) {
1855 checkExternSyncEvent(eventLSyncSharp, inL); 1855 checkExternSyncEvent(eventLSyncSharp, inL);
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 66836a1..f301768 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -56,49 +56,49 @@ namespace KCal {
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 Incidence * undoIncidence() { return mUndoIncidence; }; 68 Incidence * undoIncidence() { return mUndoIncidence; };
69 bool undoDeleteIncidence(); 69 bool undoDeleteIncidence();
70 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
71 void resetTempSyncStat(); 71 void resetTempSyncStat();
72 void resetPilotStat(int id); 72 void resetPilotStat(int id);
73 /** 73 /**
74 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
75 */ 75 */
76 virtual void close() = 0; 76 virtual void close() = 0;
77 virtual void addCalendar( Calendar* ) = 0; 77 virtual void addCalendar( Calendar* ) = 0;
78 virtual bool addCalendarFile( QString name, int id ) = 0; 78 virtual bool addCalendarFile( QString name, int id ) = 0;
79 virtual bool mergeCalendarFile( QString name ) = 0; 79 virtual bool mergeCalendarFile( QString name ) = 0;
80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ) = 0; 80 virtual Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates , bool enabledOnly = false ) = 0;
81 virtual void setSyncEventsReadOnly() = 0; 81 virtual void setSyncEventsReadOnly() = 0;
82 virtual void setSyncEventsEnabled() = 0; 82 virtual void setSyncEventsEnabled() = 0;
83 virtual void stopAllTodos() = 0; 83 virtual void stopAllTodos() = 0;
84 virtual void clearUndo( Incidence * newUndo ); 84 virtual void clearUndo( Incidence * newUndo );
85 85
86 /** 86 /**
87 Sync changes in memory to persistant storage. 87 Sync changes in memory to persistant storage.
88 */ 88 */
89 virtual void save() = 0; 89 virtual void save() = 0;
90 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 90 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
91 virtual void removeSyncInfo( QString syncProfile) = 0; 91 virtual void removeSyncInfo( QString syncProfile) = 0;
92 virtual bool isSaving() { return false; } 92 virtual bool isSaving() { return false; }
93 93
94 /** 94 /**
95 Return the owner of the calendar's full name. 95 Return the owner of the calendar's full name.
96 */ 96 */
97 const QString &getOwner() const; 97 const QString &getOwner() const;
98 /** 98 /**
99 Set the owner of the calendar. Should be owner's full name. 99 Set the owner of the calendar. Should be owner's full name.
100 */ 100 */
101 void setOwner( const QString &os ); 101 void setOwner( const QString &os );
102 /** 102 /**
103 Return the email address of the calendar owner. 103 Return the email address of the calendar owner.
104 */ 104 */
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index b02f706..ad8ace3 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -59,81 +59,90 @@ CalendarLocal::CalendarLocal(const QString &timeZoneId)
59 59
60void CalendarLocal::init() 60void CalendarLocal::init()
61{ 61{
62 mNextAlarmIncidence = 0; 62 mNextAlarmIncidence = 0;
63} 63}
64 64
65 65
66CalendarLocal::~CalendarLocal() 66CalendarLocal::~CalendarLocal()
67{ 67{
68 registerObserver( 0 ); 68 registerObserver( 0 );
69 if ( mDeleteIncidencesOnClose ) 69 if ( mDeleteIncidencesOnClose )
70 close(); 70 close();
71} 71}
72bool CalendarLocal::mergeCalendarFile( QString name ) 72bool CalendarLocal::mergeCalendarFile( QString name )
73{ 73{
74 CalendarLocal calendar( timeZoneId() ); 74 CalendarLocal calendar( timeZoneId() );
75 calendar.setDefaultCalendar( 1 ); 75 calendar.setDefaultCalendar( 1 );
76 if ( calendar.load( name ) ) { 76 if ( calendar.load( name ) ) {
77 mergeCalendar( &calendar ); 77 mergeCalendar( &calendar );
78 return true; 78 return true;
79 } 79 }
80 return false; 80 return false;
81} 81}
82 82
83Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates) 83Incidence* CalendarLocal::incidenceForUid( const QString& uid , bool doNotCheckDuplicates, bool enabledOnly )
84{ 84{
85 Todo *todo;; 85 Todo *todo;;
86 Incidence *retVal = 0; 86 Incidence *retVal = 0;
87 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { 87 for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) {
88 if ( todo->uid() == uid ) { 88 if ( todo->uid() == uid ) {
89 if ( enabledOnly )
90 if ( !todo->calEnabled() )
91 continue;
89 if ( doNotCheckDuplicates ) return todo; 92 if ( doNotCheckDuplicates ) return todo;
90 if ( retVal ) { 93 if ( retVal ) {
91 if ( retVal->calID() > todo->calID() ) { 94 if ( retVal->calID() > todo->calID() ) {
92 retVal = todo; 95 retVal = todo;
93 } 96 }
94 } else { 97 } else {
95 retVal = todo; 98 retVal = todo;
96 } 99 }
97 } 100 }
98 } 101 }
99 if ( retVal ) return retVal; 102 if ( retVal ) return retVal;
100 Event *event; 103 Event *event;
101 for ( event = mEventList.first(); event; event = mEventList.next() ) { 104 for ( event = mEventList.first(); event; event = mEventList.next() ) {
102 if ( event->uid() == uid ) { 105 if ( event->uid() == uid ) {
106 if ( enabledOnly )
107 if ( !event->calEnabled() )
108 continue;
103 if ( doNotCheckDuplicates ) return event; 109 if ( doNotCheckDuplicates ) return event;
104 if ( retVal ) { 110 if ( retVal ) {
105 if ( retVal->calID() > event->calID() ) { 111 if ( retVal->calID() > event->calID() ) {
106 retVal = event; 112 retVal = event;
107 } 113 }
108 } else { 114 } else {
109 retVal = event; 115 retVal = event;
110 } 116 }
111 } 117 }
112 } 118 }
113 if ( retVal ) return retVal; 119 if ( retVal ) return retVal;
114 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 120 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
115 if ( it->uid() == uid ) { 121 if ( it->uid() == uid ) {
122 if ( enabledOnly )
123 if ( !it->calEnabled() )
124 continue;
116 if ( doNotCheckDuplicates ) return it; 125 if ( doNotCheckDuplicates ) return it;
117 if ( retVal ) { 126 if ( retVal ) {
118 if ( retVal->calID() > it->calID() ) { 127 if ( retVal->calID() > it->calID() ) {
119 retVal = it; 128 retVal = it;
120 } 129 }
121 } else { 130 } else {
122 retVal = it; 131 retVal = it;
123 } 132 }
124 } 133 }
125 return retVal; 134 return retVal;
126} 135}
127 136
128bool CalendarLocal::mergeCalendar( Calendar* remote ) 137bool CalendarLocal::mergeCalendar( Calendar* remote )
129{ 138{
130 // 1 look for raw inc in local 139 // 1 look for raw inc in local
131 // if inc not in remote, delete in local 140 // if inc not in remote, delete in local
132 // 2 look for raw inc in remote 141 // 2 look for raw inc in remote
133 // if inc in local, replace it 142 // if inc in local, replace it
134 // if not in local, add it to default calendar 143 // if not in local, add it to default calendar
135 QPtrList<Incidence> localInc = rawIncidences(); 144 QPtrList<Incidence> localInc = rawIncidences();
136 Incidence* inL = localInc.first(); 145 Incidence* inL = localInc.first();
137 while ( inL ) { 146 while ( inL ) {
138 if ( ! inL->isReadOnly () ) 147 if ( ! inL->isReadOnly () )
139 if ( !remote->incidenceForUid( inL->uid(), true )) 148 if ( !remote->incidenceForUid( inL->uid(), true ))
diff --git a/libkcal/calendarlocal.h b/libkcal/calendarlocal.h
index b70f0c9..b611704 100644
--- a/libkcal/calendarlocal.h
+++ b/libkcal/calendarlocal.h
@@ -26,49 +26,49 @@
26 26
27namespace KCal { 27namespace KCal {
28 28
29class CalFormat; 29class CalFormat;
30 30
31/** 31/**
32 This class provides a calendar stored as a local file. 32 This class provides a calendar stored as a local file.
33*/ 33*/
34class CalendarLocal : public Calendar 34class CalendarLocal : public Calendar
35{ 35{
36 public: 36 public:
37 /** 37 /**
38 Constructs a new calendar, with variables initialized to sane values. 38 Constructs a new calendar, with variables initialized to sane values.
39 */ 39 */
40 CalendarLocal(); 40 CalendarLocal();
41 /** 41 /**
42 Constructs a new calendar, with variables initialized to sane values. 42 Constructs a new calendar, with variables initialized to sane values.
43 */ 43 */
44 CalendarLocal( const QString &timeZoneId ); 44 CalendarLocal( const QString &timeZoneId );
45 ~CalendarLocal(); 45 ~CalendarLocal();
46 void addCalendar( Calendar* ); 46 void addCalendar( Calendar* );
47 bool addCalendarFile( QString name, int id ); 47 bool addCalendarFile( QString name, int id );
48 bool mergeCalendarFile( QString name ); 48 bool mergeCalendarFile( QString name );
49 bool mergeCalendar( Calendar* cal ); 49 bool mergeCalendar( Calendar* cal );
50 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates ); 50 Incidence* incidenceForUid( const QString& uid, bool doNotCheckDuplicates, bool enabledOnly = false );
51 void setSyncEventsReadOnly(); 51 void setSyncEventsReadOnly();
52 void setSyncEventsEnabled(); 52 void setSyncEventsEnabled();
53 void stopAllTodos(); 53 void stopAllTodos();
54 /** 54 /**
55 Loads a calendar on disk in vCalendar or iCalendar format into the current 55 Loads a calendar on disk in vCalendar or iCalendar format into the current
56 calendar. Any information already present is lost. 56 calendar. Any information already present is lost.
57 @return true, if successfull, false on error. 57 @return true, if successfull, false on error.
58 @param fileName the name of the calendar on disk. 58 @param fileName the name of the calendar on disk.
59 */ 59 */
60 bool load( const QString &fileName ); 60 bool load( const QString &fileName );
61 /** 61 /**
62 Writes out the calendar to disk in the specified \a format. 62 Writes out the calendar to disk in the specified \a format.
63 CalendarLocal takes ownership of the CalFormat object. 63 CalendarLocal takes ownership of the CalFormat object.
64 @return true, if successfull, false on error. 64 @return true, if successfull, false on error.
65 @param fileName the name of the file 65 @param fileName the name of the file
66 */ 66 */
67 bool save( const QString &fileName, CalFormat *format = 0 ); 67 bool save( const QString &fileName, CalFormat *format = 0 );
68 68
69 /** 69 /**
70 Clears out the current calendar, freeing all used memory etc. etc. 70 Clears out the current calendar, freeing all used memory etc. etc.
71 */ 71 */
72 void close(); 72 void close();
73 73
74 void save() {} 74 void save() {}