summaryrefslogtreecommitdiffabout
path: root/libkcal/incidence.cpp
authorzautrix <zautrix>2005-02-13 19:07:45 (UTC)
committer zautrix <zautrix>2005-02-13 19:07:45 (UTC)
commit7bd83e913399b8be68a7d37e8f02118ec9eab90e (patch) (unidiff)
tree284d1592687ea4d3e0c220fafd289a702718dee4 /libkcal/incidence.cpp
parent293271fe9e6a9061da329183f8f488d79580f7da (diff)
downloadkdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.zip
kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.gz
kdepimpi-7bd83e913399b8be68a7d37e8f02118ec9eab90e.tar.bz2
todo fixi
Diffstat (limited to 'libkcal/incidence.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index 0684af2..708ee6b 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -120,196 +120,204 @@ void Incidence::setCancelled( bool b )
120 updated(); 120 updated();
121} 121}
122bool Incidence::hasStartDate() const 122bool Incidence::hasStartDate() const
123{ 123{
124 return mHasStartDate; 124 return mHasStartDate;
125} 125}
126 126
127void Incidence::setHasStartDate(bool f) 127void Incidence::setHasStartDate(bool f)
128{ 128{
129 if (mReadOnly) return; 129 if (mReadOnly) return;
130 mHasStartDate = f; 130 mHasStartDate = f;
131 updated(); 131 updated();
132} 132}
133 133
134// A string comparison that considers that null and empty are the same 134// A string comparison that considers that null and empty are the same
135static bool stringCompare( const QString& s1, const QString& s2 ) 135static bool stringCompare( const QString& s1, const QString& s2 )
136{ 136{
137 if ( s1.isEmpty() && s2.isEmpty() ) 137 if ( s1.isEmpty() && s2.isEmpty() )
138 return true; 138 return true;
139 return s1 == s2; 139 return s1 == s2;
140} 140}
141 141
142bool KCal::operator==( const Incidence& i1, const Incidence& i2 ) 142bool KCal::operator==( const Incidence& i1, const Incidence& i2 )
143{ 143{
144 144
145 if( i1.alarms().count() != i2.alarms().count() ) { 145 if( i1.alarms().count() != i2.alarms().count() ) {
146 return false; // no need to check further 146 return false; // no need to check further
147 } 147 }
148 if ( i1.alarms().count() > 0 ) { 148 if ( i1.alarms().count() > 0 ) {
149 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) ) 149 if ( !( *(i1.alarms().first()) == *(i2.alarms().first())) )
150 { 150 {
151 qDebug("alarm not equal "); 151 qDebug("alarm not equal ");
152 return false; 152 return false;
153 } 153 }
154 } 154 }
155#if 0 155#if 0
156 QPtrListIterator<Alarm> a1( i1.alarms() ); 156 QPtrListIterator<Alarm> a1( i1.alarms() );
157 QPtrListIterator<Alarm> a2( i2.alarms() ); 157 QPtrListIterator<Alarm> a2( i2.alarms() );
158 for( ; a1.current() && a2.current(); ++a1, ++a2 ) { 158 for( ; a1.current() && a2.current(); ++a1, ++a2 ) {
159 if( *a1.current() == *a2.current() ) { 159 if( *a1.current() == *a2.current() ) {
160 continue; 160 continue;
161 } 161 }
162 else { 162 else {
163 return false; 163 return false;
164 } 164 }
165 } 165 }
166#endif 166#endif
167 167
168 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) { 168 if ( i1.hasRecurrenceID() == i2.hasRecurrenceID() ) {
169 if ( i1.hasRecurrenceID() ) { 169 if ( i1.hasRecurrenceID() ) {
170 if ( i1.recurrenceID() != i2.recurrenceID() ) 170 if ( i1.recurrenceID() != i2.recurrenceID() )
171 return false; 171 return false;
172 } 172 }
173 173
174 } else { 174 } else {
175 return false; 175 return false;
176 } 176 }
177 177
178 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) ) 178 if ( ! operator==( (const IncidenceBase&)i1, (const IncidenceBase&)i2 ) )
179 return false; 179 return false;
180 if ( i1.hasStartDate() == i2.hasStartDate() ) { 180 if ( i1.hasStartDate() == i2.hasStartDate() ) {
181 if ( i1.hasStartDate() ) { 181 if ( i1.hasStartDate() ) {
182 if ( i1.dtStart() != i2.dtStart() ) 182 if ( i1.dtStart() != i2.dtStart() )
183 return false; 183 return false;
184 } 184 }
185 } else { 185 } else {
186 return false; 186 return false;
187 } 187 }
188 if (!( *i1.recurrence() == *i2.recurrence()) ) { 188 if (!( *i1.recurrence() == *i2.recurrence()) ) {
189 qDebug("recurrence is NOT equal "); 189 qDebug("recurrence is NOT equal ");
190 return false; 190 return false;
191 } 191 }
192 return 192 return
193 // i1.created() == i2.created() && 193 // i1.created() == i2.created() &&
194 stringCompare( i1.description(), i2.description() ) && 194 stringCompare( i1.description(), i2.description() ) &&
195 stringCompare( i1.summary(), i2.summary() ) && 195 stringCompare( i1.summary(), i2.summary() ) &&
196 i1.categories() == i2.categories() && 196 i1.categories() == i2.categories() &&
197 // no need to compare mRelatedTo 197 // no need to compare mRelatedTo
198 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) && 198 stringCompare( i1.relatedToUid(), i2.relatedToUid() ) &&
199 // i1.relations() == i2.relations() && 199 // i1.relations() == i2.relations() &&
200 i1.exDates() == i2.exDates() && 200 i1.exDates() == i2.exDates() &&
201 i1.attachments() == i2.attachments() && 201 i1.attachments() == i2.attachments() &&
202 i1.resources() == i2.resources() && 202 i1.resources() == i2.resources() &&
203 i1.secrecy() == i2.secrecy() && 203 i1.secrecy() == i2.secrecy() &&
204 i1.priority() == i2.priority() && 204 i1.priority() == i2.priority() &&
205 i1.cancelled() == i2.cancelled() && 205 i1.cancelled() == i2.cancelled() &&
206 stringCompare( i1.location(), i2.location() ); 206 stringCompare( i1.location(), i2.location() );
207} 207}
208 208
209Incidence* Incidence::recreateCloneException( QDate d ) 209Incidence* Incidence::recreateCloneException( QDate d )
210{ 210{
211 Incidence* newInc = clone(); 211 Incidence* newInc = clone();
212 newInc->recreate(); 212 newInc->recreate();
213 if ( doesRecur() ) { 213 if ( doesRecur() ) {
214 addExDate( d ); 214 addExDate( d );
215 newInc->recurrence()->unsetRecurs(); 215 newInc->recurrence()->unsetRecurs();
216 int len = dtStart().secsTo( ((Event*)this)->dtEnd()); 216 if ( type() == "Event") {
217 QTime tim = dtStart().time(); 217 int len = dtStart().secsTo( ((Event*)this)->dtEnd());
218 newInc->setDtStart( QDateTime(d, tim) ); 218 QTime tim = dtStart().time();
219 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) ); 219 newInc->setDtStart( QDateTime(d, tim) );
220 ((Event*)newInc)->setDtEnd( newInc->dtStart().addSecs( len ) );
221 } else {
222 int len = dtStart().secsTo( ((Todo*)this)->dtDue());
223 QTime tim = ((Todo*)this)->dtDue().time();
224 ((Todo*)newInc)->setDtDue( QDateTime(d, tim) );
225 ((Todo*)newInc)->setDtStart( ((Todo*)newInc)->dtDue().addSecs( -len ) );
226 ((Todo*)this)->setRecurDates();
227 }
220 } 228 }
221 return newInc; 229 return newInc;
222} 230}
223 231
224void Incidence::recreate() 232void Incidence::recreate()
225{ 233{
226 setCreated(QDateTime::currentDateTime()); 234 setCreated(QDateTime::currentDateTime());
227 235
228 setUid(CalFormat::createUniqueId()); 236 setUid(CalFormat::createUniqueId());
229 237
230 setRevision(0); 238 setRevision(0);
231 setIDStr( ":" ); 239 setIDStr( ":" );
232 setLastModified(QDateTime::currentDateTime()); 240 setLastModified(QDateTime::currentDateTime());
233} 241}
234 242
235void Incidence::setReadOnly( bool readOnly ) 243void Incidence::setReadOnly( bool readOnly )
236{ 244{
237 IncidenceBase::setReadOnly( readOnly ); 245 IncidenceBase::setReadOnly( readOnly );
238 recurrence()->setRecurReadOnly( readOnly); 246 recurrence()->setRecurReadOnly( readOnly);
239} 247}
240 248
241void Incidence::setCreated(QDateTime created) 249void Incidence::setCreated(QDateTime created)
242{ 250{
243 if (mReadOnly) return; 251 if (mReadOnly) return;
244 mCreated = getEvenTime(created); 252 mCreated = getEvenTime(created);
245} 253}
246 254
247QDateTime Incidence::created() const 255QDateTime Incidence::created() const
248{ 256{
249 return mCreated; 257 return mCreated;
250} 258}
251 259
252void Incidence::setRevision(int rev) 260void Incidence::setRevision(int rev)
253{ 261{
254 if (mReadOnly) return; 262 if (mReadOnly) return;
255 mRevision = rev; 263 mRevision = rev;
256 264
257 updated(); 265 updated();
258} 266}
259 267
260int Incidence::revision() const 268int Incidence::revision() const
261{ 269{
262 return mRevision; 270 return mRevision;
263} 271}
264 272
265void Incidence::setDtStart(const QDateTime &dtStart) 273void Incidence::setDtStart(const QDateTime &dtStart)
266{ 274{
267 275
268 QDateTime dt = getEvenTime(dtStart); 276 QDateTime dt = getEvenTime(dtStart);
269 recurrence()->setRecurStart( dt); 277 recurrence()->setRecurStart( dt);
270 IncidenceBase::setDtStart( dt ); 278 IncidenceBase::setDtStart( dt );
271} 279}
272 280
273void Incidence::setDescription(const QString &description) 281void Incidence::setDescription(const QString &description)
274{ 282{
275 if (mReadOnly) return; 283 if (mReadOnly) return;
276 mDescription = description; 284 mDescription = description;
277 updated(); 285 updated();
278} 286}
279 287
280QString Incidence::description() const 288QString Incidence::description() const
281{ 289{
282 return mDescription; 290 return mDescription;
283} 291}
284 292
285 293
286void Incidence::setSummary(const QString &summary) 294void Incidence::setSummary(const QString &summary)
287{ 295{
288 if (mReadOnly) return; 296 if (mReadOnly) return;
289 mSummary = summary; 297 mSummary = summary;
290 updated(); 298 updated();
291} 299}
292 300
293QString Incidence::summary() const 301QString Incidence::summary() const
294{ 302{
295 return mSummary; 303 return mSummary;
296} 304}
297 305
298void Incidence::setCategories(const QStringList &categories) 306void Incidence::setCategories(const QStringList &categories)
299{ 307{
300 if (mReadOnly) return; 308 if (mReadOnly) return;
301 mCategories = categories; 309 mCategories = categories;
302 updated(); 310 updated();
303} 311}
304 312
305// TODO: remove setCategories(QString) function 313// TODO: remove setCategories(QString) function
306void Incidence::setCategories(const QString &catStr) 314void Incidence::setCategories(const QString &catStr)
307{ 315{
308 if (mReadOnly) return; 316 if (mReadOnly) return;
309 mCategories.clear(); 317 mCategories.clear();
310 318
311 if (catStr.isEmpty()) return; 319 if (catStr.isEmpty()) return;
312 320
313 mCategories = QStringList::split(",",catStr); 321 mCategories = QStringList::split(",",catStr);
314 322
315 QStringList::Iterator it; 323 QStringList::Iterator it;