summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp11
-rw-r--r--libkcal/calendar.h3
-rw-r--r--libkcal/calendarlocal.cpp17
-rw-r--r--libkcal/incidence.cpp14
-rw-r--r--libkcal/incidence.h1
5 files changed, 39 insertions, 7 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 52daaaa..88351eb 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -43,25 +43,25 @@ Calendar::Calendar()
43 43
44Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
45{ 45{
46 46
47 init(); 47 init();
48 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
49} 49}
50 50
51void Calendar::init() 51void Calendar::init()
52{ 52{
53 mObserver = 0; 53 mObserver = 0;
54 mNewObserver = false; 54 mNewObserver = false;
55 55 mUndoIncidence = 0;
56 mModified = false; 56 mModified = false;
57 57
58 // Setup default filter, which does nothing 58 // Setup default filter, which does nothing
59 mDefaultFilter = new CalFilter; 59 mDefaultFilter = new CalFilter;
60 mFilter = mDefaultFilter; 60 mFilter = mDefaultFilter;
61 mFilter->setEnabled(false); 61 mFilter->setEnabled(false);
62 62
63 // initialize random numbers. This is a hack, and not 63 // initialize random numbers. This is a hack, and not
64 // even that good of one at that. 64 // even that good of one at that.
65// srandom(time(0)); 65// srandom(time(0));
66 66
67 // user information... 67 // user information...
@@ -100,31 +100,40 @@ void Calendar::init()
100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
101 } 101 }
102 102
103 setTimeZone(tzStr); 103 setTimeZone(tzStr);
104#endif 104#endif
105 105
106// KOPrefs::instance()->writeConfig(); 106// KOPrefs::instance()->writeConfig();
107} 107}
108 108
109Calendar::~Calendar() 109Calendar::~Calendar()
110{ 110{
111 delete mDefaultFilter; 111 delete mDefaultFilter;
112 if ( mUndoIncidence )
113 delete mUndoIncidence;
112} 114}
113 115
114const QString &Calendar::getOwner() const 116const QString &Calendar::getOwner() const
115{ 117{
116 return mOwner; 118 return mOwner;
117} 119}
118 120
121bool Calendar::undoDeleteIncidence()
122{
123 if (!mUndoIncidence)
124 return false;
125 addIncidence(mUndoIncidence);
126 mUndoIncidence = 0;
127}
119void Calendar::setOwner(const QString &os) 128void Calendar::setOwner(const QString &os)
120{ 129{
121 int i; 130 int i;
122 mOwner = os; 131 mOwner = os;
123 i = mOwner.find(','); 132 i = mOwner.find(',');
124 if (i != -1) 133 if (i != -1)
125 mOwner = mOwner.left(i); 134 mOwner = mOwner.left(i);
126 135
127 setModified( true ); 136 setModified( true );
128} 137}
129 138
130void Calendar::setTimeZone(const QString & tz) 139void Calendar::setTimeZone(const QString & tz)
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index b7d6a1f..2f2c3aa 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -56,24 +56,26 @@ 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; };
69 bool undoDeleteIncidence();
68 void deleteIncidence(Incidence *in); 70 void deleteIncidence(Incidence *in);
69 void resetTempSyncStat(); 71 void resetTempSyncStat();
70 void resetPilotStat(int id); 72 void resetPilotStat(int id);
71 /** 73 /**
72 Clears out the current calendar, freeing all used memory etc. 74 Clears out the current calendar, freeing all used memory etc.
73 */ 75 */
74 virtual void close() = 0; 76 virtual void close() = 0;
75 77
76 /** 78 /**
77 Sync changes in memory to persistant storage. 79 Sync changes in memory to persistant storage.
78 */ 80 */
79 virtual void save() = 0; 81 virtual void save() = 0;
@@ -313,24 +315,25 @@ public:
313 /** 315 /**
314 Get unfiltered events, which occur on the given date. 316 Get unfiltered events, which occur on the given date.
315 */ 317 */
316 virtual QPtrList<Event> rawEventsForDate( const QDate &date, 318 virtual QPtrList<Event> rawEventsForDate( const QDate &date,
317 bool sorted = false ) = 0; 319 bool sorted = false ) = 0;
318 /** 320 /**
319 Get events in a range of dates. If inclusive is set to true, only events 321 Get events in a range of dates. If inclusive is set to true, only events
320 are returned, which are completely included in the range. 322 are returned, which are completely included in the range.
321 */ 323 */
322 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end, 324 virtual QPtrList<Event> rawEvents( const QDate &start, const QDate &end,
323 bool inclusive = false ) = 0; 325 bool inclusive = false ) = 0;
324 Incidence *mNextAlarmIncidence; 326 Incidence *mNextAlarmIncidence;
327 Incidence *mUndoIncidence;
325 328
326private: 329private:
327 void init(); 330 void init();
328 331
329 QString mOwner; // who the calendar belongs to 332 QString mOwner; // who the calendar belongs to
330 QString mOwnerEmail; // email address of the owner 333 QString mOwnerEmail; // email address of the owner
331 int mTimeZone; // timezone OFFSET from GMT (MINUTES) 334 int mTimeZone; // timezone OFFSET from GMT (MINUTES)
332 bool mLocalTime; // use local time, not UTC or a time zone 335 bool mLocalTime; // use local time, not UTC or a time zone
333 336
334 CalFilter *mFilter; 337 CalFilter *mFilter;
335 CalFilter *mDefaultFilter; 338 CalFilter *mDefaultFilter;
336 339
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp
index 3f46d53..12294c0 100644
--- a/libkcal/calendarlocal.cpp
+++ b/libkcal/calendarlocal.cpp
@@ -143,29 +143,29 @@ bool CalendarLocal::addEvent( Event *event )
143{ 143{
144 insertEvent( event ); 144 insertEvent( event );
145 145
146 event->registerObserver( this ); 146 event->registerObserver( this );
147 147
148 setModified( true ); 148 setModified( true );
149 149
150 return true; 150 return true;
151} 151}
152 152
153void CalendarLocal::deleteEvent( Event *event ) 153void CalendarLocal::deleteEvent( Event *event )
154{ 154{
155 155 if ( mUndoIncidence ) delete mUndoIncidence;
156 156 mUndoIncidence = event->clone();
157 if ( mEventList.removeRef( event ) ) { 157 if ( mEventList.removeRef( event ) ) {
158 setModified( true ); 158 setModified( true );
159 } 159 }
160} 160}
161 161
162 162
163Event *CalendarLocal::event( const QString &uid ) 163Event *CalendarLocal::event( const QString &uid )
164{ 164{
165 165
166 Event *event; 166 Event *event;
167 167
168 for ( event = mEventList.first(); event; event = mEventList.next() ) { 168 for ( event = mEventList.first(); event; event = mEventList.next() ) {
169 if ( event->uid() == uid ) { 169 if ( event->uid() == uid ) {
170 return event; 170 return event;
171 } 171 }
@@ -192,25 +192,27 @@ bool CalendarLocal::addTodo( Todo *todo )
192 192
193 // Set up subtask relations 193 // Set up subtask relations
194 setupRelations( todo ); 194 setupRelations( todo );
195 195
196 setModified( true ); 196 setModified( true );
197 197
198 return true; 198 return true;
199} 199}
200 200
201void CalendarLocal::deleteTodo( Todo *todo ) 201void CalendarLocal::deleteTodo( Todo *todo )
202{ 202{
203 // Handle orphaned children 203 // Handle orphaned children
204 removeRelations( todo ); 204 if ( mUndoIncidence ) delete mUndoIncidence;
205 mUndoIncidence = todo->clone();
206 removeRelations( todo );
205 207
206 if ( mTodoList.removeRef( todo ) ) { 208 if ( mTodoList.removeRef( todo ) ) {
207 setModified( true ); 209 setModified( true );
208 } 210 }
209} 211}
210 212
211QPtrList<Todo> CalendarLocal::rawTodos() 213QPtrList<Todo> CalendarLocal::rawTodos()
212{ 214{
213 return mTodoList; 215 return mTodoList;
214} 216}
215Todo *CalendarLocal::todo( QString syncProf, QString id ) 217Todo *CalendarLocal::todo( QString syncProf, QString id )
216{ 218{
@@ -678,24 +680,27 @@ bool CalendarLocal::addJournal(Journal *journal)
678 680
679 mJournalList.append(journal); 681 mJournalList.append(journal);
680 682
681 journal->registerObserver( this ); 683 journal->registerObserver( this );
682 684
683 setModified( true ); 685 setModified( true );
684 686
685 return true; 687 return true;
686} 688}
687 689
688void CalendarLocal::deleteJournal( Journal *journal ) 690void CalendarLocal::deleteJournal( Journal *journal )
689{ 691{
692 if ( mUndoIncidence ) delete mUndoIncidence;
693 mUndoIncidence = journal->clone();
694 mUndoIncidence->setSummary( mUndoIncidence->description().left(25));
690 if ( mJournalList.removeRef(journal) ) { 695 if ( mJournalList.removeRef(journal) ) {
691 setModified( true ); 696 setModified( true );
692 } 697 }
693} 698}
694 699
695Journal *CalendarLocal::journal( const QDate &date ) 700Journal *CalendarLocal::journal( const QDate &date )
696{ 701{
697// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl; 702// kdDebug(5800) << "CalendarLocal::journal() " << date.toString() << endl;
698 703
699 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() ) 704 for ( Journal *it = mJournalList.first(); it; it = mJournalList.next() )
700 if ( it->dtStart().date() == date ) 705 if ( it->dtStart().date() == date )
701 return it; 706 return it;
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 5a9ef0e..28402ae 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -164,24 +164,38 @@ bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
164 i1.categories() == i2.categories() && 164 i1.categories() == i2.categories() &&
165 // no need to compare mRelatedTo 165 // no need to compare mRelatedTo
166 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 166 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
167 // i1.relations() == i2.relations() && 167 // i1.relations() == i2.relations() &&
168 i1.exDates() == i2.exDates() && 168 i1.exDates() == i2.exDates() &&
169 i1.attachments() == i2.attachments() && 169 i1.attachments() == i2.attachments() &&
170 i1.resources() == i2.resources() && 170 i1.resources() == i2.resources() &&
171 i1.secrecy() == i2.secrecy() && 171 i1.secrecy() == i2.secrecy() &&
172 i1.priority() == i2.priority() && 172 i1.priority() == i2.priority() &&
173 stringCompare( i1.location(), i2.location() ); 173 stringCompare( i1.location(), i2.location() );
174} 174}
175 175
176Incidence* Incidence::recreateCloneException( QDate d )
177{
178 Incidence* newInc = clone();
179 newInc->recreate();
180 if ( doesRecur() ) {
181 addExDate( d );
182 newInc->recurrence()->unsetRecurs();
183 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
184 QTime tim = dtStart().time();
185 newInc->setDtStart( QDateTime(d, tim) );
186 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
187 }
188 return newInc;
189}
176 190
177void Incidence::recreate() 191void Incidence::recreate()
178{ 192{
179 setCreated(QDateTime::currentDateTime()); 193 setCreated(QDateTime::currentDateTime());
180 194
181 setUid(CalFormat::createUniqueId()); 195 setUid(CalFormat::createUniqueId());
182 196
183 setRevision(0); 197 setRevision(0);
184 setIDStr( ":" ); 198 setIDStr( ":" );
185 setLastModified(QDateTime::currentDateTime()); 199 setLastModified(QDateTime::currentDateTime());
186} 200}
187 201
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 7dc6f10..1807bc4 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -113,24 +113,25 @@ class Incidence : public IncidenceBase
113 113
114 virtual Incidence *clone() = 0; 114 virtual Incidence *clone() = 0;
115 115
116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0; 116 virtual QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const = 0;
117 void setReadOnly( bool ); 117 void setReadOnly( bool );
118 118
119 /** 119 /**
120 Recreate event. The event is made a new unique event, but already stored 120 Recreate event. The event is made a new unique event, but already stored
121 event information is preserved. Sets uniquie id, creation date, last 121 event information is preserved. Sets uniquie id, creation date, last
122 modification date and revision number. 122 modification date and revision number.
123 */ 123 */
124 void recreate(); 124 void recreate();
125 Incidence* recreateCloneException(QDate);
125 126
126 /** set creation date */ 127 /** set creation date */
127 void setCreated(QDateTime); 128 void setCreated(QDateTime);
128 /** return time and date of creation. */ 129 /** return time and date of creation. */
129 QDateTime created() const; 130 QDateTime created() const;
130 131
131 /** set the number of revisions this event has seen */ 132 /** set the number of revisions this event has seen */
132 void setRevision(int rev); 133 void setRevision(int rev);
133 /** return the number of revisions this event has seen */ 134 /** return the number of revisions this event has seen */
134 int revision() const; 135 int revision() const;
135 136
136 /** Set starting date/time. */ 137 /** Set starting date/time. */