author | zautrix <zautrix> | 2005-07-07 20:46:00 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-07-07 20:46:00 (UTC) |
commit | de5621f2fd3924f27c05459ae555b3bd06c5e584 (patch) (unidiff) | |
tree | 589d19415e3c0ff6c08cec375db145242581c143 /libkcal | |
parent | 766b53919de14b8faec22db32b6a750acde0b760 (diff) | |
download | kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.zip kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.gz kdepimpi-de5621f2fd3924f27c05459ae555b3bd06c5e584.tar.bz2 |
fixxx
-rw-r--r-- | libkcal/event.cpp | 115 | ||||
-rw-r--r-- | libkcal/event.h | 2 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 8 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 4 |
4 files changed, 128 insertions, 1 deletions
diff --git a/libkcal/event.cpp b/libkcal/event.cpp index 7cd81fa..235ae55 100644 --- a/libkcal/event.cpp +++ b/libkcal/event.cpp | |||
@@ -170,8 +170,123 @@ 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 ) | ||
175 | { | ||
176 | if ( testEvent == this ) | ||
177 | return false; | ||
178 | if ( ! doesRecur() && !testEvent->doesRecur() ) { | ||
179 | QDateTime te; | ||
180 | if ( testEvent->doesFloat() ) | ||
181 | te = testEvent->mDtEnd.addDays( 1 ); | ||
182 | else | ||
183 | te = testEvent->mDtEnd; | ||
184 | QDateTime e; | ||
185 | if ( doesFloat() ) | ||
186 | e = mDtEnd.addDays( 1 ); | ||
187 | else | ||
188 | e = mDtEnd; | ||
189 | if ( mDtStart < te && testEvent->mDtStart < e ) { | ||
190 | if ( mDtStart < testEvent->mDtStart ) | ||
191 | *overlapDT = testEvent->mDtStart; | ||
192 | else | ||
193 | *overlapDT = mDtStart; | ||
194 | if ( inFutureOnly ) | ||
195 | return (*overlapDT >= QDateTime::currentDateTime() ); | ||
196 | return true; | ||
197 | } | ||
198 | return false; | ||
199 | } | ||
200 | Event *nonRecur = 0; | ||
201 | Event *recurEvent = 0; | ||
202 | if ( ! doesRecur() ) { | ||
203 | nonRecur = this; | ||
204 | recurEvent = testEvent; | ||
205 | } | ||
206 | else if ( !testEvent->doesRecur() ) { | ||
207 | nonRecur = testEvent; | ||
208 | recurEvent = this; | ||
209 | } | ||
210 | if ( nonRecur ) { | ||
211 | QDateTime enr; | ||
212 | if ( nonRecur->doesFloat() ) | ||
213 | enr = nonRecur->mDtEnd.addDays( 1 ); | ||
214 | else | ||
215 | enr = nonRecur->mDtEnd; | ||
216 | if ( enr < recurEvent->mDtStart ) | ||
217 | return false; | ||
218 | if ( inFutureOnly && enr < QDateTime::currentDateTime() ) | ||
219 | return false; | ||
220 | int recDuration = recurEvent->mDtStart.secsTo( recurEvent->mDtEnd ); | ||
221 | if ( recurEvent->doesFloat() ) | ||
222 | recDuration += 86400; | ||
223 | bool ok = true; | ||
224 | QDateTime recStart = recurEvent->mDtStart.addSecs( -300);; | ||
225 | while ( ok ) { | ||
226 | recStart = recurEvent->getNextOccurence( recStart.addSecs( 60 ), &ok ); | ||
227 | if ( ok ) { | ||
228 | if ( recStart > enr ) | ||
229 | return false; | ||
230 | QDateTime recEnd = recStart.addSecs( recDuration ); | ||
231 | if ( nonRecur->mDtStart < recEnd && recStart < nonRecur->mDtEnd ) { | ||
232 | if ( nonRecur->mDtStart < recStart ) | ||
233 | *overlapDT = recStart; | ||
234 | else | ||
235 | *overlapDT = nonRecur->mDtStart; | ||
236 | if ( inFutureOnly ) { | ||
237 | if ( *overlapDT >= QDateTime::currentDateTime() ) | ||
238 | return true; | ||
239 | } else | ||
240 | return true; | ||
241 | } | ||
242 | } | ||
243 | } | ||
244 | return false; | ||
245 | } | ||
246 | |||
247 | QDateTime incidenceStart = mDtStart; | ||
248 | int duration = mDtStart.secsTo( mDtEnd ); | ||
249 | if ( doesFloat() ) | ||
250 | duration += 86400; | ||
251 | QDateTime testincidenceStart = testEvent->mDtStart; | ||
252 | int testduration = testEvent->mDtStart.secsTo( testEvent->mDtEnd ); | ||
253 | if ( testEvent->doesFloat() ) | ||
254 | testduration += 86400; | ||
255 | bool computeThis = false; | ||
256 | if ( incidenceStart < testincidenceStart ) | ||
257 | computeThis = true; | ||
258 | bool ok = true; | ||
259 | if ( computeThis ) | ||
260 | incidenceStart = incidenceStart.addSecs( -300 ); | ||
261 | else | ||
262 | testincidenceStart = testincidenceStart.addSecs( -300 ); | ||
263 | int count = 0; | ||
264 | while ( ok ) { | ||
265 | ++count; | ||
266 | if ( count > 1000 ) break; | ||
267 | if ( computeThis ) | ||
268 | incidenceStart = getNextOccurence( incidenceStart.addSecs( 60 ), &ok ); | ||
269 | else | ||
270 | testincidenceStart = testEvent->getNextOccurence( testincidenceStart.addSecs( 60 ), &ok ); | ||
271 | if ( ok ) { | ||
272 | if ( incidenceStart < testincidenceStart.addSecs( testduration ) && testincidenceStart < incidenceStart.addSecs( duration ) ) { | ||
273 | if ( incidenceStart < testincidenceStart ) | ||
274 | *overlapDT = testincidenceStart; | ||
275 | else | ||
276 | *overlapDT = incidenceStart; | ||
277 | if ( inFutureOnly ) { | ||
278 | if ( *overlapDT >= QDateTime::currentDateTime() ) | ||
279 | return true; | ||
280 | } else | ||
281 | return true; | ||
282 | } | ||
283 | computeThis = ( incidenceStart < testincidenceStart ); | ||
284 | } | ||
285 | |||
286 | } | ||
287 | return false; | ||
288 | } | ||
174 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const | 289 | QDateTime Event::getNextAlarmDateTime( bool * ok, int * offset, QDateTime start_dt ) const |
175 | { | 290 | { |
176 | *ok = false; | 291 | *ok = false; |
177 | if ( !alarmEnabled() ) | 292 | if ( !alarmEnabled() ) |
diff --git a/libkcal/event.h b/libkcal/event.h index 287d403..80c11c4 100644 --- a/libkcal/event.h +++ b/libkcal/event.h | |||
@@ -73,8 +73,10 @@ class Event : public Incidence | |||
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 ); | ||
78 | |||
77 | private: | 79 | private: |
78 | bool accept(Visitor &v) { return v.visit(this); } | 80 | bool accept(Visitor &v) { return v.visit(this); } |
79 | 81 | ||
80 | QDateTime mDtEnd; | 82 | QDateTime mDtEnd; |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 96039df..dcead02 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -138,8 +138,16 @@ QDateTime IncidenceBase::getEvenTime( QDateTime dt ) | |||
138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); | 138 | dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); |
139 | return dt; | 139 | return dt; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool IncidenceBase::isTagged() const | ||
143 | { | ||
144 | return mIsTagged; | ||
145 | } | ||
146 | void IncidenceBase::setTagged( bool b) | ||
147 | { | ||
148 | mIsTagged = b; | ||
149 | } | ||
142 | void IncidenceBase::setCalID( int id ) | 150 | void IncidenceBase::setCalID( int id ) |
143 | { | 151 | { |
144 | if ( mCalID > 0 ) | 152 | if ( mCalID > 0 ) |
145 | updated(); | 153 | updated(); |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index dc6024a..bccf287 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -146,10 +146,12 @@ class IncidenceBase : public CustomProperties | |||
146 | void setCalEnabled( bool ); | 146 | void setCalEnabled( bool ); |
147 | bool calEnabled() const; | 147 | bool calEnabled() const; |
148 | void setAlarmEnabled( bool ); | 148 | void setAlarmEnabled( bool ); |
149 | bool alarmEnabled() const; | 149 | bool alarmEnabled() const; |
150 | 150 | bool isTagged() const; | |
151 | void setTagged( bool ); | ||
151 | protected: | 152 | protected: |
153 | bool mIsTagged; | ||
152 | QDateTime mDtStart; | 154 | QDateTime mDtStart; |
153 | bool mReadOnly; | 155 | bool mReadOnly; |
154 | QDateTime getEvenTime( QDateTime ); | 156 | QDateTime getEvenTime( QDateTime ); |
155 | 157 | ||