summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/incidence.cpp9
-rw-r--r--libkcal/incidence.h5
-rw-r--r--libkcal/incidencebase.cpp1
-rw-r--r--libkcal/incidencebase.h4
-rw-r--r--libkcal/todo.cpp47
-rw-r--r--libkcal/todo.h2
6 files changed, 62 insertions, 6 deletions
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp
index dbc159c..0684af2 100644
--- a/libkcal/incidence.cpp
+++ b/libkcal/incidence.cpp
@@ -644,6 +644,15 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
644 } 644 }
645 } 645 }
646 if ( incidenceStart > dt ) 646 if ( incidenceStart > dt )
647 *ok = true; 647 *ok = true;
648 return incidenceStart; 648 return incidenceStart;
649} 649}
650QDateTime Incidence::dtStart() const
651{
652 if ( doesRecur() ) {
653 if ( type() == "Todo" ) {
654 ((Todo*)this)->checkSetCompletedFalse();
655 }
656 }
657 return mDtStart;
658}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 38d2aaa..0ae9656 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -266,24 +266,25 @@ class Incidence : public IncidenceBase
266 266
267 bool hasRecurrenceID() const; 267 bool hasRecurrenceID() const;
268 void setHasRecurrenceID( bool b ); 268 void setHasRecurrenceID( bool b );
269 269
270 void setRecurrenceID(QDateTime); 270 void setRecurrenceID(QDateTime);
271 QDateTime recurrenceID () const; 271 QDateTime recurrenceID () const;
272 QDateTime dtStart() const;
272 273
273 274
274protected: 275protected:
275 QPtrList<Alarm> mAlarms; 276 QPtrList<Alarm> mAlarms;
276 QPtrList<Incidence> mRelations; 277 QPtrList<Incidence> mRelations;
278 QDateTime mRecurrenceID;
279 bool mHasRecurrenceID;
277 private: 280 private:
278 int mRevision; 281 int mRevision;
279 bool mCancelled; 282 bool mCancelled;
280 283
281 // base components of jounal, event and todo 284 // base components of jounal, event and todo
282 QDateTime mRecurrenceID;
283 bool mHasRecurrenceID;
284 QDateTime mCreated; 285 QDateTime mCreated;
285 QString mDescription; 286 QString mDescription;
286 QString mSummary; 287 QString mSummary;
287 QStringList mCategories; 288 QStringList mCategories;
288 Incidence *mRelatedTo; 289 Incidence *mRelatedTo;
289 QString mRelatedToUid; 290 QString mRelatedToUid;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 7525a4a..51f2e9d 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -176,12 +176,13 @@ void IncidenceBase::setDtStart(const QDateTime &dtStart)
176{ 176{
177// if (mReadOnly) return; 177// if (mReadOnly) return;
178 mDtStart = getEvenTime(dtStart); 178 mDtStart = getEvenTime(dtStart);
179 updated(); 179 updated();
180} 180}
181 181
182
182QDateTime IncidenceBase::dtStart() const 183QDateTime IncidenceBase::dtStart() const
183{ 184{
184 return mDtStart; 185 return mDtStart;
185} 186}
186 187
187QString IncidenceBase::dtStartTimeStr() const 188QString IncidenceBase::dtStartTimeStr() const
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index f9a6558..8624786 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -71,13 +71,13 @@ class IncidenceBase : public CustomProperties
71 /** Return if the object is read-only. */ 71 /** Return if the object is read-only. */
72 bool isReadOnly() const { return mReadOnly; } 72 bool isReadOnly() const { return mReadOnly; }
73 73
74 /** for setting the event's starting date/time with a QDateTime. */ 74 /** for setting the event's starting date/time with a QDateTime. */
75 virtual void setDtStart(const QDateTime &dtStart); 75 virtual void setDtStart(const QDateTime &dtStart);
76 /** returns an event's starting date/time as a QDateTime. */ 76 /** returns an event's starting date/time as a QDateTime. */
77 QDateTime dtStart() const; 77 virtual QDateTime dtStart() const;
78 /** returns an event's starting time as a string formatted according to the 78 /** returns an event's starting time as a string formatted according to the
79 users locale settings */ 79 users locale settings */
80 QString dtStartTimeStr() const; 80 QString dtStartTimeStr() const;
81 /** returns an event's starting date as a string formatted according to the 81 /** returns an event's starting date as a string formatted according to the
82 users locale settings */ 82 users locale settings */
83 QString dtStartDateStr(bool shortfmt=true) const; 83 QString dtStartDateStr(bool shortfmt=true) const;
@@ -138,18 +138,18 @@ class IncidenceBase : public CustomProperties
138 138
139 void registerObserver( Observer * ); 139 void registerObserver( Observer * );
140 void unRegisterObserver( Observer * ); 140 void unRegisterObserver( Observer * );
141 void updated(); 141 void updated();
142 142
143 protected: 143 protected:
144 QDateTime mDtStart;
144 bool mReadOnly; 145 bool mReadOnly;
145 QDateTime getEvenTime( QDateTime ); 146 QDateTime getEvenTime( QDateTime );
146 147
147 private: 148 private:
148 // base components 149 // base components
149 QDateTime mDtStart;
150 QString mOrganizer; 150 QString mOrganizer;
151 QString mUid; 151 QString mUid;
152 QDateTime mLastModified; 152 QDateTime mLastModified;
153 QPtrList<Attendee> mAttendees; 153 QPtrList<Attendee> mAttendees;
154 154
155 bool mFloats; 155 bool mFloats;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 9c04a7e..1f54c2f 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -308,18 +308,24 @@ QString Todo::statusStr() const
308 return QString(""); 308 return QString("");
309} 309}
310#endif 310#endif
311 311
312bool Todo::isCompleted() const 312bool Todo::isCompleted() const
313{ 313{
314 if (mPercentComplete == 100) return true; 314 if (mPercentComplete == 100) {
315 return true;
316 }
315 else return false; 317 else return false;
316} 318}
317 319
318void Todo::setCompleted(bool completed) 320void Todo::setCompleted(bool completed)
319{ 321{
322 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
323 if ( !setRecurDates() )
324 completed = false;
325 }
320 if (completed) mPercentComplete = 100; 326 if (completed) mPercentComplete = 100;
321 else { 327 else {
322 mPercentComplete = 0; 328 mPercentComplete = 0;
323 mHasCompletedDate = false; 329 mHasCompletedDate = false;
324 } 330 }
325 updated(); 331 updated();
@@ -354,15 +360,39 @@ bool Todo::hasCompletedDate() const
354} 360}
355 361
356int Todo::percentComplete() const 362int Todo::percentComplete() const
357{ 363{
358 return mPercentComplete; 364 return mPercentComplete;
359} 365}
360 366bool Todo::setRecurDates()
367{
368 if ( !mHasRecurrenceID )
369 return true;
370 int secs = mDtStart.secsTo( dtDue() );
371 bool ok;
372 qDebug("--------------------setRecurDates() ");
373 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
374 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
375 if ( ok ) {
376 mRecurrenceID = next;
377 mDtStart = next;
378 setDtDue( next.addSecs( secs ) );
379 if ( QDateTime::currentDateTime() > next)
380 return false;
381 } else {
382 setHasRecurrenceID( false );
383 recurrence()->unsetRecurs();
384 }
385 return true;
386}
361void Todo::setPercentComplete(int v) 387void Todo::setPercentComplete(int v)
362{ 388{
389 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
390 if ( !setRecurDates() )
391 v = 0;
392 }
363 mPercentComplete = v; 393 mPercentComplete = v;
364 if ( v != 100 ) 394 if ( v != 100 )
365 mHasCompletedDate = false; 395 mHasCompletedDate = false;
366 updated(); 396 updated();
367} 397}
368QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 398QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
@@ -409,6 +439,19 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
409 } 439 }
410 *ok = false; 440 *ok = false;
411 return QDateTime (); 441 return QDateTime ();
412 442
413} 443}
414 444
445void Todo::checkSetCompletedFalse()
446{
447 if ( !hasRecurrenceID() ) {
448 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
449 }
450 // qDebug("Todo::checkSetCompletedFalse()");
451 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
452 if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) {
453 qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
454 setCompleted( false );
455 qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ ");
456 }
457}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 137b252..a22d4b7 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -109,12 +109,14 @@ class Todo : public Incidence
109 /** set date and time of completion */ 109 /** set date and time of completion */
110 void setCompleted(const QDateTime &completed); 110 void setCompleted(const QDateTime &completed);
111 111
112 /** Return true, if todo has a date associated with completion */ 112 /** Return true, if todo has a date associated with completion */
113 bool hasCompletedDate() const; 113 bool hasCompletedDate() const;
114 bool contains ( Todo*); 114 bool contains ( Todo*);
115 void checkSetCompletedFalse();
116 bool setRecurDates();
115 117
116 private: 118 private:
117 bool accept(Visitor &v) { return v.visit(this); } 119 bool accept(Visitor &v) { return v.visit(this); }
118 120
119 QDateTime mDtDue; // due date of todo 121 QDateTime mDtDue; // due date of todo
120 122