author | zautrix <zautrix> | 2005-07-07 21:34:31 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 21:34:31 (UTC) |
commit | 3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc (patch) (unidiff) | |
tree | 6fceb199e62afe671ed34acb308749ea09cac578 /libkcal | |
parent | de5621f2fd3924f27c05459ae555b3bd06c5e584 (diff) | |
download | kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.zip kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.tar.gz kdepimpi-3fe323e4e63f3b7c1cf8c96093fa14fd63fb4efc.tar.bz2 |
fixxx
-rw-r--r-- | libkcal/event.cpp | 16 | ||||
-rw-r--r-- | libkcal/event.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 235ae55..46e8174 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -158,96 +158,96 @@ void Event::setTransparency(Event::Transparency transparency) | |||
158 | { | 158 | { |
159 | if (mReadOnly) return; | 159 | if (mReadOnly) return; |
160 | mTransparency = transparency; | 160 | mTransparency = transparency; |
161 | updated(); | 161 | updated(); |
162 | } | 162 | } |
163 | 163 | ||
164 | Event::Transparency Event::transparency() const | 164 | Event::Transparency Event::transparency() const |
165 | { | 165 | { |
166 | return mTransparency; | 166 | return mTransparency; |
167 | } | 167 | } |
168 | 168 | ||
169 | void Event::setDuration(int seconds) | 169 | void Event::setDuration(int seconds) |
170 | { | 170 | { |
171 | setHasEndDate(false); | 171 | setHasEndDate(false); |
172 | Incidence::setDuration(seconds); | 172 | Incidence::setDuration(seconds); |
173 | } | 173 | } |
174 | bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, bool inFutureOnly ) | 174 | bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, QDateTime* startDT ) |
175 | { | 175 | { |
176 | if ( testEvent == this ) | 176 | if ( testEvent == this ) |
177 | return false; | 177 | return false; |
178 | if ( ! doesRecur() && !testEvent->doesRecur() ) { | 178 | if ( ! doesRecur() && !testEvent->doesRecur() ) { |
179 | QDateTime te; | 179 | QDateTime te; |
180 | if ( testEvent->doesFloat() ) | 180 | if ( testEvent->doesFloat() ) |
181 | te = testEvent->mDtEnd.addDays( 1 ); | 181 | te = testEvent->mDtEnd.addDays( 1 ); |
182 | else | 182 | else |
183 | te = testEvent->mDtEnd; | 183 | te = testEvent->mDtEnd; |
184 | QDateTime e; | 184 | QDateTime e; |
185 | if ( doesFloat() ) | 185 | if ( doesFloat() ) |
186 | e = mDtEnd.addDays( 1 ); | 186 | e = mDtEnd.addDays( 1 ); |
187 | else | 187 | else |
188 | e = mDtEnd; | 188 | e = mDtEnd; |
189 | if ( mDtStart < te && testEvent->mDtStart < e ) { | 189 | if ( mDtStart < te && testEvent->mDtStart < e ) { |
190 | if ( mDtStart < testEvent->mDtStart ) | 190 | if ( mDtStart < testEvent->mDtStart ) |
191 | *overlapDT = testEvent->mDtStart; | 191 | *overlapDT = testEvent->mDtStart; |
192 | else | 192 | else |
193 | *overlapDT = mDtStart; | 193 | *overlapDT = mDtStart; |
194 | if ( inFutureOnly ) | 194 | if ( startDT ) |
195 | return (*overlapDT >= QDateTime::currentDateTime() ); | 195 | return (*overlapDT >= *startDT ); |
196 | return true; | 196 | return true; |
197 | } | 197 | } |
198 | return false; | 198 | return false; |
199 | } | 199 | } |
200 | Event *nonRecur = 0; | 200 | Event *nonRecur = 0; |
201 | Event *recurEvent = 0; | 201 | Event *recurEvent = 0; |
202 | if ( ! doesRecur() ) { | 202 | if ( ! doesRecur() ) { |
203 | nonRecur = this; | 203 | nonRecur = this; |
204 | recurEvent = testEvent; | 204 | recurEvent = testEvent; |
205 | } | 205 | } |
206 | else if ( !testEvent->doesRecur() ) { | 206 | else if ( !testEvent->doesRecur() ) { |
207 | nonRecur = testEvent; | 207 | nonRecur = testEvent; |
208 | recurEvent = this; | 208 | recurEvent = this; |
209 | } | 209 | } |
210 | if ( nonRecur ) { | 210 | if ( nonRecur ) { |
211 | QDateTime enr; | 211 | QDateTime enr; |
212 | if ( nonRecur->doesFloat() ) | 212 | if ( nonRecur->doesFloat() ) |
213 | enr = nonRecur->mDtEnd.addDays( 1 ); | 213 | enr = nonRecur->mDtEnd.addDays( 1 ); |
214 | else | 214 | else |
215 | enr = nonRecur->mDtEnd; | 215 | enr = nonRecur->mDtEnd; |
216 | if ( enr < recurEvent->mDtStart ) | 216 | if ( enr < recurEvent->mDtStart ) |
217 | return false; | 217 | return false; |
218 | if ( inFutureOnly && enr < QDateTime::currentDateTime() ) | 218 | if ( startDT && enr < *startDT ) |
219 | return false; | 219 | return false; |
220 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); | 220 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); |
221 | if ( recurEvent->doesFloat() ) | 221 | if ( recurEvent->doesFloat() ) |
222 | recDuration += 86400; | 222 | recDuration += 86400; |
223 | bool ok = true; | 223 | bool ok = true; |
224 | QDateTime recStart = recurEvent->mDtStart.addSecs( -300);; | 224 | QDateTime recStart = recurEvent->mDtStart.addSecs( -300);; |
225 | while ( ok ) { | 225 | while ( ok ) { |
226 | recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok ); | 226 | recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok ); |
227 | if ( ok ) { | 227 | if ( ok ) { |
228 | if ( recStart > enr ) | 228 | if ( recStart > enr ) |
229 | return false; | 229 | return false; |
230 | QDateTime recEnd = recStart.addSecs( recDuration ); | 230 | QDateTime recEnd = recStart.addSecs( recDuration ); |
231 | if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) { | 231 | if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) { |
232 | if ( nonRecur->mDtStart < recStart ) | 232 | if ( nonRecur->mDtStart < recStart ) |
233 | *overlapDT = recStart; | 233 | *overlapDT = recStart; |
234 | else | 234 | else |
235 | *overlapDT = nonRecur->mDtStart; | 235 | *overlapDT = nonRecur->mDtStart; |
236 | if ( inFutureOnly ) { | 236 | if ( startDT ) { |
237 | if ( *overlapDT >= QDateTime::currentDateTime() ) | 237 | if ( *overlapDT >= *startDT ) |
238 | return true; | 238 | return true; |
239 | } else | 239 | } else |
240 | return true; | 240 | return true; |
241 | } | 241 | } |
242 | } | 242 | } |
243 | } | 243 | } |
244 | return false; | 244 | return false; |
245 | } | 245 | } |
246 | 246 | ||
247 | QDateTime incidenceStart = mDtStart; | 247 | QDateTime incidenceStart = mDtStart; |
248 | int duration = mDtStart.secsTo( mDtEnd ); | 248 | int duration = mDtStart.secsTo( mDtEnd ); |
249 | if ( doesFloat() ) | 249 | if ( doesFloat() ) |
250 | duration += 86400; | 250 | duration += 86400; |
251 | QDateTime testincidenceStart = testEvent->mDtStart; | 251 | QDateTime testincidenceStart = testEvent->mDtStart; |
252 | int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd ); | 252 | int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd ); |
253 | if ( testEvent->doesFloat() ) | 253 | if ( testEvent->doesFloat() ) |
@@ -261,34 +261,34 @@ bool Event::isOverlapping ( Event* testEvent, QDateTime* overlapDT, bool inFut | |||
261 | else | 261 | else |
262 | testincidenceStart = testincidenceStart.addSecs( -300 ); | 262 | testincidenceStart = testincidenceStart.addSecs( -300 ); |
263 | int count = 0; | 263 | int count = 0; |
264 | while ( ok ) { | 264 | while ( ok ) { |
265 | ++count; | 265 | ++count; |
266 | if ( count > 1000 ) break; | 266 | if ( count > 1000 ) break; |
267 | if ( computeThis ) | 267 | if ( computeThis ) |
268 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); | 268 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); |
269 | else | 269 | else |
270 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); | 270 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); |
271 | if ( ok ) { | 271 | if ( ok ) { |
272 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { | 272 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { |
273 | if ( incidenceStart < testincidenceStart ) | 273 | if ( incidenceStart < testincidenceStart ) |
274 | *overlapDT = testincidenceStart; | 274 | *overlapDT = testincidenceStart; |
275 | else | 275 | else |
276 | *overlapDT = incidenceStart; | 276 | *overlapDT = incidenceStart; |
277 | if ( inFutureOnly ) { | 277 | if ( startDT ) { |
278 | if ( *overlapDT >= QDateTime::currentDateTime() ) | 278 | if ( *overlapDT >= *startDT ) |
279 | return true; | 279 | return true; |
280 | } else | 280 | } else |
281 | return true; | 281 | return true; |
282 | } | 282 | } |
283 | computeThis = ( incidenceStart < testincidenceStart ); | 283 | computeThis = ( incidenceStart < testincidenceStart ); |
284 | } | 284 | } |
285 | 285 | ||
286 | } | 286 | } |
287 | return false; | 287 | return false; |
288 | } | 288 | } |
289 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 289 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
290 | { | 290 | { |
291 | *ok = false; | 291 | *ok = false; |
292 | if ( !alarmEnabled() ) | 292 | if ( !alarmEnabled() ) |
293 | return QDateTime (); | 293 | return QDateTime (); |
294 | bool yes; | 294 | bool yes; |
diff --git a/libkcal/event.h b/libkcal/event.h index 80c11c4..e6055a5 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -61,33 +61,33 @@ class Event : public Incidence | |||
61 | void setHasEndDate(bool); | 61 | void setHasEndDate(bool); |
62 | /** Return whether the event has an end date/time. */ | 62 | /** Return whether the event has an end date/time. */ |
63 | bool hasEndDate() const; | 63 | bool hasEndDate() const; |
64 | 64 | ||
65 | /** Return true if the event spans multiple days, otherwise return false. */ | 65 | /** Return true if the event spans multiple days, otherwise return false. */ |
66 | bool isMultiDay() const; | 66 | bool isMultiDay() const; |
67 | 67 | ||
68 | /** set the event's time transparency level. */ | 68 | /** set the event's time transparency level. */ |
69 | void setTransparency(Transparency transparency); | 69 | void setTransparency(Transparency transparency); |
70 | /** get the event's time transparency level. */ | 70 | /** get the event's time transparency level. */ |
71 | Transparency transparency() const; | 71 | Transparency transparency() const; |
72 | 72 | ||
73 | void setDuration(int seconds); | 73 | void setDuration(int seconds); |
74 | 74 | ||
75 | bool contains ( Event*); | 75 | bool contains ( Event*); |
76 | 76 | ||
77 | bool isOverlapping ( Event*, QDateTime*, bool inFutureOnly ); | 77 | bool isOverlapping ( Event*, QDateTime*, QDateTime* ); |
78 | 78 | ||
79 | private: | 79 | private: |
80 | bool accept(Visitor &v) { return v.visit(this); } | 80 | bool accept(Visitor &v) { return v.visit(this); } |
81 | 81 | ||
82 | QDateTime mDtEnd; | 82 | QDateTime mDtEnd; |
83 | bool mHasEndDate; | 83 | bool mHasEndDate; |
84 | Transparency mTransparency; | 84 | Transparency mTransparency; |
85 | }; | 85 | }; |
86 | 86 | ||
87 | bool operator==( const Event&, const Event& ); | 87 | bool operator==( const Event&, const Event& ); |
88 | 88 | ||
89 | 89 | ||
90 | } | 90 | } |
91 | 91 | ||
92 | 92 | ||
93 | #endif | 93 | #endif |