summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-02-13 17:05:02 (UTC)
committer zautrix <zautrix>2005-02-13 17:05:02 (UTC)
commit293271fe9e6a9061da329183f8f488d79580f7da (patch) (side-by-side diff)
tree3a0234eabdf58440a484e960b5eef912a63d0056 /libkcal
parent0a33f91e166747406ca2ccb5819881feeecfdb40 (diff)
downloadkdepimpi-293271fe9e6a9061da329183f8f488d79580f7da.zip
kdepimpi-293271fe9e6a9061da329183f8f488d79580f7da.tar.gz
kdepimpi-293271fe9e6a9061da329183f8f488d79580f7da.tar.bz2
todo rec fixes
Diffstat (limited to 'libkcal') (more/less context) (ignore 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.cpp51
-rw-r--r--libkcal/todo.h2
6 files changed, 64 insertions, 8 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
}
}
if ( incidenceStart > dt )
*ok = true;
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
@@ -266,24 +266,25 @@ class Incidence : public IncidenceBase
bool hasRecurrenceID() const;
void setHasRecurrenceID( bool b );
void setRecurrenceID(QDateTime);
QDateTime recurrenceID () const;
+ QDateTime dtStart() const;
protected:
QPtrList<Alarm> mAlarms;
QPtrList<Incidence> mRelations;
+ QDateTime mRecurrenceID;
+ bool mHasRecurrenceID;
private:
int mRevision;
bool mCancelled;
// base components of jounal, event and todo
- QDateTime mRecurrenceID;
- bool mHasRecurrenceID;
QDateTime mCreated;
QString mDescription;
QString mSummary;
QStringList mCategories;
Incidence *mRelatedTo;
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)
{
// if (mReadOnly) return;
mDtStart = getEvenTime(dtStart);
updated();
}
+
QDateTime IncidenceBase::dtStart() const
{
return mDtStart;
}
QString 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
/** Return if the object is read-only. */
bool isReadOnly() const { return mReadOnly; }
/** for setting the event's starting date/time with a QDateTime. */
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 */
QString dtStartTimeStr() const;
/** returns an event's starting date as a string formatted according to the
users locale settings */
QString dtStartDateStr(bool shortfmt=true) const;
@@ -138,18 +138,18 @@ class IncidenceBase : public CustomProperties
void registerObserver( Observer * );
void unRegisterObserver( Observer * );
void updated();
protected:
+ QDateTime mDtStart;
bool mReadOnly;
QDateTime getEvenTime( QDateTime );
private:
// base components
- QDateTime mDtStart;
QString mOrganizer;
QString mUid;
QDateTime mLastModified;
QPtrList<Attendee> mAttendees;
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
return QString("");
}
#endif
bool Todo::isCompleted() const
{
- if (mPercentComplete == 100) return true;
- else return false;
+ if (mPercentComplete == 100) {
+ return true;
+ }
+ else return false;
}
void Todo::setCompleted(bool completed)
{
+ if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
+ if ( !setRecurDates() )
+ completed = false;
+ }
if (completed) mPercentComplete = 100;
else {
mPercentComplete = 0;
mHasCompletedDate = false;
}
updated();
@@ -354,15 +360,39 @@ bool Todo::hasCompletedDate() const
}
int Todo::percentComplete() const
{
return mPercentComplete;
}
-
-void Todo::setPercentComplete(int v)
+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 )
mHasCompletedDate = false;
updated();
}
QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
@@ -409,6 +439,19 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
}
*ok = false;
return QDateTime ();
}
+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
@@ -109,12 +109,14 @@ class Todo : public Incidence
/** set date and time of completion */
void setCompleted(const QDateTime &completed);
/** Return true, if todo has a date associated with completion */
bool hasCompletedDate() const;
bool contains ( Todo*);
+ void checkSetCompletedFalse();
+ bool setRecurDates();
private:
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtDue; // due date of todo