author | zautrix <zautrix> | 2004-08-02 00:52:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-02 00:52:35 (UTC) |
commit | 54157cb44316de72d776cfae70bdadf6c52f4773 (patch) (unidiff) | |
tree | 953c8ae225a54fc43a7298d49b08e821bf741cb9 /libkcal/calendarlocal.cpp | |
parent | 3ebd85e83e6f9d4ac59ce1828548f7236e2b1af0 (diff) | |
download | kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.zip kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.tar.gz kdepimpi-54157cb44316de72d776cfae70bdadf6c52f4773.tar.bz2 |
Hack, hack, hack
-rw-r--r-- | libkcal/calendarlocal.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/libkcal/calendarlocal.cpp b/libkcal/calendarlocal.cpp index 09ce9f0..e464a77 100644 --- a/libkcal/calendarlocal.cpp +++ b/libkcal/calendarlocal.cpp | |||
@@ -119,220 +119,220 @@ bool CalendarLocal::addAnniversaryNoDup( Event *event ) | |||
119 | if ( eve->dtStart().date() != event->dtStart().date() ) | 119 | if ( eve->dtStart().date() != event->dtStart().date() ) |
120 | continue; | 120 | continue; |
121 | // now we have an event with fitting category+date | 121 | // now we have an event with fitting category+date |
122 | if ( eve->summary() != event->summary() ) | 122 | if ( eve->summary() != event->summary() ) |
123 | continue; | 123 | continue; |
124 | // now we have an event with fitting category+date+summary | 124 | // now we have an event with fitting category+date+summary |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | return addEvent( event ); | 127 | return addEvent( event ); |
128 | 128 | ||
129 | } | 129 | } |
130 | bool CalendarLocal::addEventNoDup( Event *event ) | 130 | bool CalendarLocal::addEventNoDup( Event *event ) |
131 | { | 131 | { |
132 | Event * eve; | 132 | Event * eve; |
133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { | 133 | for ( eve = mEventList.first(); eve ; eve = mEventList.next() ) { |
134 | if ( *eve == *event ) { | 134 | if ( *eve == *event ) { |
135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); | 135 | //qDebug("CalendarLocal::Duplicate event found! Not inserted! "); |
136 | return false; | 136 | return false; |
137 | } | 137 | } |
138 | } | 138 | } |
139 | return addEvent( event ); | 139 | return addEvent( event ); |
140 | } | 140 | } |
141 | 141 | ||
142 | bool CalendarLocal::addEvent( Event *event ) | 142 | 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 | ||
153 | void CalendarLocal::deleteEvent( Event *event ) | 153 | void CalendarLocal::deleteEvent( Event *event ) |
154 | { | 154 | { |
155 | 155 | ||
156 | 156 | ||
157 | if ( mEventList.removeRef( event ) ) { | 157 | if ( mEventList.removeRef( event ) ) { |
158 | setModified( true ); | 158 | setModified( true ); |
159 | } | 159 | } |
160 | } | 160 | } |
161 | 161 | ||
162 | 162 | ||
163 | Event *CalendarLocal::event( const QString &uid ) | 163 | Event *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 | } |
172 | } | 172 | } |
173 | 173 | ||
174 | return 0; | 174 | return 0; |
175 | } | 175 | } |
176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) | 176 | bool CalendarLocal::addTodoNoDup( Todo *todo ) |
177 | { | 177 | { |
178 | Todo * eve; | 178 | Todo * eve; |
179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { | 179 | for ( eve = mTodoList.first(); eve ; eve = mTodoList.next() ) { |
180 | if ( *eve == *todo ) { | 180 | if ( *eve == *todo ) { |
181 | //qDebug("duplicate todo found! not inserted! "); | 181 | //qDebug("duplicate todo found! not inserted! "); |
182 | return false; | 182 | return false; |
183 | } | 183 | } |
184 | } | 184 | } |
185 | return addTodo( todo ); | 185 | return addTodo( todo ); |
186 | } | 186 | } |
187 | bool CalendarLocal::addTodo( Todo *todo ) | 187 | bool CalendarLocal::addTodo( Todo *todo ) |
188 | { | 188 | { |
189 | mTodoList.append( todo ); | 189 | mTodoList.append( todo ); |
190 | 190 | ||
191 | todo->registerObserver( this ); | 191 | todo->registerObserver( this ); |
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 | ||
201 | void CalendarLocal::deleteTodo( Todo *todo ) | 201 | void CalendarLocal::deleteTodo( Todo *todo ) |
202 | { | 202 | { |
203 | // Handle orphaned children | 203 | // Handle orphaned children |
204 | removeRelations( todo ); | 204 | removeRelations( todo ); |
205 | 205 | ||
206 | if ( mTodoList.removeRef( todo ) ) { | 206 | if ( mTodoList.removeRef( todo ) ) { |
207 | setModified( true ); | 207 | setModified( true ); |
208 | } | 208 | } |
209 | } | 209 | } |
210 | 210 | ||
211 | QPtrList<Todo> CalendarLocal::rawTodos() | 211 | QPtrList<Todo> CalendarLocal::rawTodos() |
212 | { | 212 | { |
213 | return mTodoList; | 213 | return mTodoList; |
214 | } | 214 | } |
215 | Todo *CalendarLocal::todo( int id ) | 215 | Todo *CalendarLocal::todo( QString syncProf, int id ) |
216 | { | 216 | { |
217 | Todo *todo; | 217 | Todo *todo; |
218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 218 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
219 | if ( todo->zaurusId() == id ) return todo; | 219 | if ( todo->getID( syncProf ) == id ) return todo; |
220 | } | 220 | } |
221 | 221 | ||
222 | return 0; | 222 | return 0; |
223 | } | 223 | } |
224 | 224 | ||
225 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() | 225 | QPtrList<Event> CalendarLocal::getExternLastSyncEvents() |
226 | { | 226 | { |
227 | QPtrList<Event> el; | 227 | QPtrList<Event> el; |
228 | Event *todo; | 228 | Event *todo; |
229 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 229 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
230 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) | 230 | if ( todo->uid().left( 15 ) == QString("last-syncEvent-") ) |
231 | if ( todo->summary().left(3) == "E: " ) | 231 | if ( todo->summary().left(3) == "E: " ) |
232 | el.append( todo ); | 232 | el.append( todo ); |
233 | } | 233 | } |
234 | 234 | ||
235 | return el; | 235 | return el; |
236 | 236 | ||
237 | } | 237 | } |
238 | Event *CalendarLocal::event( int id ) | 238 | Event *CalendarLocal::event( QString syncProf, int id ) |
239 | { | 239 | { |
240 | Event *todo; | 240 | Event *todo; |
241 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { | 241 | for ( todo = mEventList.first(); todo; todo = mEventList.next() ) { |
242 | if ( todo->zaurusId() == id ) return todo; | 242 | if ( todo->getID( syncProf ) == id ) return todo; |
243 | } | 243 | } |
244 | 244 | ||
245 | return 0; | 245 | return 0; |
246 | } | 246 | } |
247 | Todo *CalendarLocal::todo( const QString &uid ) | 247 | Todo *CalendarLocal::todo( const QString &uid ) |
248 | { | 248 | { |
249 | Todo *todo; | 249 | Todo *todo; |
250 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { | 250 | for ( todo = mTodoList.first(); todo; todo = mTodoList.next() ) { |
251 | if ( todo->uid() == uid ) return todo; | 251 | if ( todo->uid() == uid ) return todo; |
252 | } | 252 | } |
253 | 253 | ||
254 | return 0; | 254 | return 0; |
255 | } | 255 | } |
256 | QString CalendarLocal::nextSummary() const | 256 | QString CalendarLocal::nextSummary() const |
257 | { | 257 | { |
258 | return mNextSummary; | 258 | return mNextSummary; |
259 | } | 259 | } |
260 | QDateTime CalendarLocal::nextAlarmEventDateTime() const | 260 | QDateTime CalendarLocal::nextAlarmEventDateTime() const |
261 | { | 261 | { |
262 | return mNextAlarmEventDateTime; | 262 | return mNextAlarmEventDateTime; |
263 | } | 263 | } |
264 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) | 264 | void CalendarLocal::checkAlarmForIncidence( Incidence * incidence, bool deleted) |
265 | { | 265 | { |
266 | //mNextAlarmIncidence | 266 | //mNextAlarmIncidence |
267 | //mNextAlarmDateTime | 267 | //mNextAlarmDateTime |
268 | //return mNextSummary; | 268 | //return mNextSummary; |
269 | //return mNextAlarmEventDateTime; | 269 | //return mNextAlarmEventDateTime; |
270 | bool newNextAlarm = false; | 270 | bool newNextAlarm = false; |
271 | bool computeNextAlarm = false; | 271 | bool computeNextAlarm = false; |
272 | bool ok; | 272 | bool ok; |
273 | int offset; | 273 | int offset; |
274 | QDateTime nextA; | 274 | QDateTime nextA; |
275 | // QString nextSum; | 275 | // QString nextSum; |
276 | //QDateTime nextEvent; | 276 | //QDateTime nextEvent; |
277 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { | 277 | if ( mNextAlarmIncidence == 0 || incidence == 0 ) { |
278 | computeNextAlarm = true; | 278 | computeNextAlarm = true; |
279 | } else { | 279 | } else { |
280 | if ( ! deleted ) { | 280 | if ( ! deleted ) { |
281 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; | 281 | nextA = incidence->getNextAlarmDateTime(& ok, &offset ) ; |
282 | if ( ok ) { | 282 | if ( ok ) { |
283 | if ( nextA < mNextAlarmDateTime ) { | 283 | if ( nextA < mNextAlarmDateTime ) { |
284 | deRegisterAlarm(); | 284 | deRegisterAlarm(); |
285 | mNextAlarmDateTime = nextA; | 285 | mNextAlarmDateTime = nextA; |
286 | mNextSummary = incidence->summary(); | 286 | mNextSummary = incidence->summary(); |
287 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; | 287 | mNextAlarmEventDateTime = nextA.addSecs(offset ) ; |
288 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); | 288 | mNextAlarmEventDateTimeString = KGlobal::locale()->formatDateTime(mNextAlarmEventDateTime); |
289 | newNextAlarm = true; | 289 | newNextAlarm = true; |
290 | mNextAlarmIncidence = incidence; | 290 | mNextAlarmIncidence = incidence; |
291 | } else { | 291 | } else { |
292 | if ( incidence == mNextAlarmIncidence ) { | 292 | if ( incidence == mNextAlarmIncidence ) { |
293 | computeNextAlarm = true; | 293 | computeNextAlarm = true; |
294 | } | 294 | } |
295 | } | 295 | } |
296 | } else { | 296 | } else { |
297 | if ( mNextAlarmIncidence == incidence ) { | 297 | if ( mNextAlarmIncidence == incidence ) { |
298 | computeNextAlarm = true; | 298 | computeNextAlarm = true; |
299 | } | 299 | } |
300 | } | 300 | } |
301 | } else { // deleted | 301 | } else { // deleted |
302 | if ( incidence == mNextAlarmIncidence ) { | 302 | if ( incidence == mNextAlarmIncidence ) { |
303 | computeNextAlarm = true; | 303 | computeNextAlarm = true; |
304 | } | 304 | } |
305 | } | 305 | } |
306 | } | 306 | } |
307 | if ( computeNextAlarm ) { | 307 | if ( computeNextAlarm ) { |
308 | deRegisterAlarm(); | 308 | deRegisterAlarm(); |
309 | nextA = nextAlarm( 1000 ); | 309 | nextA = nextAlarm( 1000 ); |
310 | if (! mNextAlarmIncidence ) { | 310 | if (! mNextAlarmIncidence ) { |
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | newNextAlarm = true; | 313 | newNextAlarm = true; |
314 | } | 314 | } |
315 | if ( newNextAlarm ) | 315 | if ( newNextAlarm ) |
316 | registerAlarm(); | 316 | registerAlarm(); |
317 | } | 317 | } |
318 | QString CalendarLocal:: getAlarmNotification() | 318 | QString CalendarLocal:: getAlarmNotification() |
319 | { | 319 | { |
320 | QString ret; | 320 | QString ret; |
321 | // this should not happen | 321 | // this should not happen |
322 | if (! mNextAlarmIncidence ) | 322 | if (! mNextAlarmIncidence ) |
323 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; | 323 | return "cal_alarm"+ mNextSummary.left( 25 )+"\n"+mNextAlarmEventDateTimeString; |
324 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); | 324 | Alarm* alarm = mNextAlarmIncidence->alarms().first(); |
325 | if ( alarm->type() == Alarm::Procedure ) { | 325 | if ( alarm->type() == Alarm::Procedure ) { |
326 | ret = "proc_alarm" + alarm->programFile()+"+++"; | 326 | ret = "proc_alarm" + alarm->programFile()+"+++"; |
327 | } else { | 327 | } else { |
328 | ret = "audio_alarm" +alarm->audioFile() +"+++"; | 328 | ret = "audio_alarm" +alarm->audioFile() +"+++"; |
329 | } | 329 | } |
330 | ret += "cal_alarm"+ mNextSummary.left( 25 ); | 330 | ret += "cal_alarm"+ mNextSummary.left( 25 ); |
331 | if ( mNextSummary.length() > 25 ) | 331 | if ( mNextSummary.length() > 25 ) |
332 | ret += "\n" + mNextSummary.mid(25, 25 ); | 332 | ret += "\n" + mNextSummary.mid(25, 25 ); |
333 | ret+= "\n"+mNextAlarmEventDateTimeString; | 333 | ret+= "\n"+mNextAlarmEventDateTimeString; |
334 | return ret; | 334 | return ret; |
335 | } | 335 | } |
336 | void CalendarLocal::registerAlarm() | 336 | void CalendarLocal::registerAlarm() |
337 | { | 337 | { |
338 | mLastAlarmNotificationString = getAlarmNotification(); | 338 | mLastAlarmNotificationString = getAlarmNotification(); |