summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-02-05 11:26:35 (UTC)
committer zautrix <zautrix>2005-02-05 11:26:35 (UTC)
commit86c0d35262454a31ed7d50d3e20cbdace954ebdf (patch) (side-by-side diff)
tree7ded091fe9111fe20014f8edbc5f338293e36386 /libkcal
parent3a822a4c4867acb28dc1b3b9557918d0971f732c (diff)
downloadkdepimpi-86c0d35262454a31ed7d50d3e20cbdace954ebdf.zip
kdepimpi-86c0d35262454a31ed7d50d3e20cbdace954ebdf.tar.gz
kdepimpi-86c0d35262454a31ed7d50d3e20cbdace954ebdf.tar.bz2
another fixx
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/incidence.h2
-rw-r--r--libkcal/todo.cpp32
-rw-r--r--libkcal/todo.h12
3 files changed, 44 insertions, 2 deletions
diff --git a/libkcal/incidence.h b/libkcal/incidence.h
index 1807bc4..de2a381 100644
--- a/libkcal/incidence.h
+++ b/libkcal/incidence.h
@@ -245,55 +245,55 @@ class Incidence : public IncidenceBase
Return the recurrence rule associated with this incidence. If there is
none, returns an appropriate (non-0) object.
*/
Recurrence *recurrence() const;
void setRecurrence(Recurrence * r);
/**
Forward to Recurrence::doesRecur().
*/
ushort doesRecur() const;
/** set the event's/todo's location. Do _not_ use it with journal */
void setLocation(const QString &location);
/** return the event's/todo's location. Do _not_ use it with journal */
QString location() const;
/** returns TRUE or FALSE depending on whether the todo has a start date */
bool hasStartDate() const;
/** sets the event's hasStartDate value. */
void setHasStartDate(bool f);
QDateTime getNextOccurence( const QDateTime& dt, bool* yes ) const;
bool cancelled() const;
void setCancelled( bool b );
protected:
QPtrList<Alarm> mAlarms;
+ QPtrList<Incidence> mRelations;
private:
int mRevision;
bool mCancelled;
// base components of jounal, event and todo
QDateTime mCreated;
QString mDescription;
QString mSummary;
QStringList mCategories;
Incidence *mRelatedTo;
QString mRelatedToUid;
- QPtrList<Incidence> mRelations;
DateList mExDates;
QPtrList<Attachment> mAttachments;
QStringList mResources;
bool mHasStartDate; // if todo has associated start date
int mSecrecy;
int mPriority; // 1 = highest, 2 = less, etc.
//QPtrList<Alarm> mAlarms;
Recurrence *mRecurrence;
QString mLocation;
};
bool operator==( const Incidence&, const Incidence& );
}
#endif
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7f1de78..d81a68f 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -172,49 +172,79 @@ void Todo::setDtDue(const QDateTime &dtDue)
alarm->setAlarmStart(mDtDue);*/
updated();
}
QDateTime Todo::dtDue() const
{
return mDtDue;
}
QString Todo::dtDueTimeStr() const
{
return KGlobal::locale()->formatTime(mDtDue.time());
}
QString Todo::dtDueDateStr(bool shortfmt) const
{
return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
}
QString Todo::dtDueStr(bool shortfmt) const
{
return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
}
-
+// retval 0 : no found
+// 1 : due for date found
+// 2 : overdue for date found
+int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
+{
+ int retval = 0;
+ if ( isCompleted() )
+ return 0;
+ if ( hasDueDate() ) {
+ if ( dtDue().date() < date )
+ return 2;
+ // we do not return, because we may find an overdue sub todo
+ if ( dtDue().date() == date )
+ retval = 1;
+ }
+ if ( checkSubtodos ) {
+ Incidence *aTodo;
+ for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
+ int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
+ if ( ret == 2 )
+ return 2;
+ if ( ret == 1)
+ retval = 1;
+ }
+ }
+ return retval;
+}
+int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
+{
+ return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
+}
bool Todo::hasDueDate() const
{
return mHasDueDate;
}
void Todo::setHasDueDate(bool f)
{
if (mReadOnly) return;
mHasDueDate = f;
updated();
}
#if 0
void Todo::setStatus(const QString &statStr)
{
if (mReadOnly) return;
QString ss(statStr.upper());
if (ss == "X-ACTION")
mStatus = NEEDS_ACTION;
else if (ss == "NEEDS ACTION")
mStatus = NEEDS_ACTION;
else if (ss == "ACCEPTED")
diff --git a/libkcal/todo.h b/libkcal/todo.h
index 41f5841..137b252 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -41,48 +41,60 @@ class Todo : public Incidence
/** Return an exact copy of this todo. */
Incidence *clone();
QDateTime getNextAlarmDateTime( bool * ok, int * offset ) const;
/** for setting the todo's due date/time with a QDateTime. */
void setDtDue(const QDateTime &dtDue);
/** returns an event's Due date/time as a QDateTime. */
QDateTime dtDue() const;
/** returns an event's due time as a string formatted according to the
users locale settings */
QString dtDueTimeStr() const;
/** returns an event's due date as a string formatted according to the
users locale settings */
QString dtDueDateStr(bool shortfmt=true) const;
/** returns an event's due date and time as a string formatted according
to the users locale settings */
QString dtDueStr(bool shortfmt=true) const;
/** returns TRUE or FALSE depending on whether the todo has a due date */
bool hasDueDate() const;
/** sets the event's hasDueDate value. */
void setHasDueDate(bool f);
+ /*
+ Looks for a subtodo (including itself ) which is not complete and is
+ - overdue, or
+ - due today.
+ It returns 0 for nothing found,
+ 1 for found a todo which is due today and no overdue found
+ 2 for found a overdue todo
+ */
+ int hasDueSubTodo( bool checkSubtodos = true );
+ /* same as above, but a specific date can be specified*/
+ int hasDueSubTodoForDate( const QDate & date, bool checkSubtodos );
+
/** sets the event's status to the string specified. The string
* must be a recognized value for the status field, i.e. a string
* equivalent of the possible status enumerations previously described. */
// void setStatus(const QString &statStr);
/** sets the event's status to the value specified. See the enumeration
* above for possible values. */
// void setStatus(int);
/** return the event's status. */
// int status() const;
/** return the event's status in string format. */
// QString statusStr() const;
/** return, if this todo is completed */
bool isCompleted() const;
/** set completed state of this todo */
void setCompleted(bool);
/**
Return how many percent of the task are completed. Returns a value
between 0 and 100.
*/
int percentComplete() const;
/**