summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
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
@@ -648,2 +648,11 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const
return incidenceStart;
}
+QDateTime Incidence::dtStart() const
+{
+ if ( doesRecur() ) {
+ if ( type() == "Todo" ) {
+ ((Todo*)this)->checkSetCompletedFalse();
+ }
+ }
+ return mDtStart;
+}
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 38d2aaa..0ae9656 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -270,4 +270,5 @@ class Incidence : public IncidenceBase
void setRecurrenceID(QDateTime);
QDateTime recurrenceID () const;
+ QDateTime dtStart() const;
@@ -275,4 +276,6 @@ protected:
QPtrList<Alarm> mAlarms;
QPtrList<Incidence> mRelations;
+ QDateTime mRecurrenceID;
+ bool mHasRecurrenceID;
private:
int mRevision;
@@ -280,6 +283,4 @@ protected:
// base components of jounal, event and todo
- QDateTime mRecurrenceID;
- bool mHasRecurrenceID;
QDateTime mCreated;
QString mDescription;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 7525a4a..51f2e9d 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -180,4 +180,5 @@ void IncidenceBase::setDtStart(const QDateTime &dtStart)
}
+
QDateTime IncidenceBase::dtStart() const
{
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h
index f9a6558..8624786 100644
--- a/libkcal/incidencebase.h
+++ b/libkcal/incidencebase.h
@@ -75,5 +75,5 @@ class IncidenceBase : public CustomProperties
virtual void setDtStart(const QDateTime &dtStart);
/** returns an event's starting date/time as a QDateTime. */
- QDateTime dtStart() const;
+ virtual QDateTime dtStart() const;
/** returns an event's starting time as a string formatted according to the
users locale settings */
@@ -142,4 +142,5 @@ class IncidenceBase : public CustomProperties
protected:
+ QDateTime mDtStart;
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
@@ -147,5 +148,4 @@ class IncidenceBase : public CustomProperties
private:
// base components
- QDateTime mDtStart;
QString mOrganizer;
QString mUid;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 9c04a7e..1f54c2f 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -312,5 +312,7 @@ QString Todo::statusStr() const
bool Todo::isCompleted() const
{
- if (mPercentComplete == 100) return true;
+ if (mPercentComplete == 100) {
+ return true;
+ }
else return false;
}
@@ -318,4 +320,8 @@ bool Todo::isCompleted() const
void Todo::setCompleted(bool completed)
{
+ if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
+ if ( !setRecurDates() )
+ completed = false;
+ }
if (completed) mPercentComplete = 100;
else {
@@ -358,7 +364,31 @@ int Todo::percentComplete() const
return mPercentComplete;
}
-
+bool Todo::setRecurDates()
+{
+ if ( !mHasRecurrenceID )
+ return true;
+ int secs = mDtStart.secsTo( dtDue() );
+ bool ok;
+ qDebug("--------------------setRecurDates() ");
+ //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
+ QDateTime next = getNextOccurence( mRecurrenceID, &ok );
+ if ( ok ) {
+ mRecurrenceID = next;
+ mDtStart = next;
+ setDtDue( next.addSecs( secs ) );
+ if ( QDateTime::currentDateTime() > next)
+ return false;
+ } else {
+ setHasRecurrenceID( false );
+ recurrence()->unsetRecurs();
+ }
+ return true;
+}
void Todo::setPercentComplete(int v)
{
+ if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
+ if ( !setRecurDates() )
+ v = 0;
+ }
mPercentComplete = v;
if ( v != 100 )
@@ -413,2 +443,15 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
}
+void Todo::checkSetCompletedFalse()
+{
+ if ( !hasRecurrenceID() ) {
+ qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
+ }
+ // qDebug("Todo::checkSetCompletedFalse()");
+ //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
+ if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) {
+ qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
+ setCompleted( false );
+ qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ ");
+ }
+}
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 137b252..a22d4b7 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -113,4 +113,6 @@ class Todo : public Incidence
bool hasCompletedDate() const;
bool contains ( Todo*);
+ void checkSetCompletedFalse();
+ bool setRecurDates();
private: