summaryrefslogtreecommitdiffabout
path: root/libkcal
authorzautrix <zautrix>2005-04-09 20:21:58 (UTC)
committer zautrix <zautrix>2005-04-09 20:21:58 (UTC)
commit9e43ebbe5867b2da957bb17c35bd357715424cba (patch) (side-by-side diff)
treeb506ba029b50fc46a33d35a39e6f1c768c995f22 /libkcal
parent2c39ac46121e8796e780a5321ab777f08792e5ba (diff)
downloadkdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.zip
kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.gz
kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.bz2
todo tt
Diffstat (limited to 'libkcal') (more/less context) (show whitespace changes)
-rw-r--r--libkcal/todo.cpp44
-rw-r--r--libkcal/todo.h16
2 files changed, 58 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index a496404..7dee4cd 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -26,40 +26,84 @@
using namespace KCal;
Todo::Todo(): Incidence()
{
// mStatus = TENTATIVE;
mHasDueDate = false;
setHasStartDate( false );
mCompleted = getEvenTime(QDateTime::currentDateTime());
mHasCompletedDate = false;
mPercentComplete = 0;
+ mRunning = false;
+ mRunSaveTimer = 0;
}
Todo::Todo(const Todo &t) : Incidence(t)
{
mDtDue = t.mDtDue;
mHasDueDate = t.mHasDueDate;
mCompleted = t.mCompleted;
mHasCompletedDate = t.mHasCompletedDate;
mPercentComplete = t.mPercentComplete;
+ mRunning = false;
+ mRunSaveTimer = 0;
}
Todo::~Todo()
{
+ setRunning( false );
+}
+
+void Todo::setRunning( bool run )
+{
+ if ( run == mRunning )
+ return;
+ if ( !mRunSaveTimer ) {
+ mRunSaveTimer = new QTimer ( this );
+ connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
+ }
+ mRunning = run;
+ if ( mRunning ) {
+ mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
+ mRunStart = QDateTime::currentDateTime();
+ } else {
+ mRunSaveTimer->stop();
+ saveRunningInfoToFile();
+ }
+}
+void Todo::saveRunningInfoToFile()
+{
+ qDebug("Todo::saveRunningInfoToFile() ");
}
+int Todo::runTime()
+{
+ if ( !mRunning )
+ return 0;
+ return mRunStart.secsTo( QDateTime::currentDateTime() );
+}
+bool Todo::hasRunningSub()
+{
+ if ( mRunning )
+ return true;
+ Incidence *aTodo;
+ for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
+ if ( ((Todo*)aTodo)->hasRunningSub() )
+ return true;
+ }
+ return false;
+}
Incidence *Todo::clone()
{
return new Todo(*this);
}
bool Todo::contains ( Todo* from )
{
if ( !from->summary().isEmpty() )
if ( !summary().startsWith( from->summary() ))
return false;
if ( from->hasStartDate() ) {
diff --git a/libkcal/todo.h b/libkcal/todo.h
index a22d4b7..fe43357 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -16,31 +16,34 @@
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef TODO_H
#define TODO_H
//
// Todo component, representing a VTODO object
//
#include "incidence.h"
+#include <qtimer.h>
+
namespace KCal {
/**
This class provides a Todo in the sense of RFC2445.
*/
-class Todo : public Incidence
+ class Todo : public QObject,public Incidence
{
+ Q_OBJECT
public:
Todo();
Todo(const Todo &);
~Todo();
typedef ListBase<Todo> List;
QCString type() const { return "Todo"; }
/** 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. */
@@ -105,26 +108,35 @@ class Todo : public Incidence
/** return date and time when todo was completed */
QDateTime completed() const;
QString completedStr(bool shortF = true) const;
/** 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();
-
+ bool isRunning() {return mRunning;}
+ bool hasRunningSub();
+ void setRunning( bool );
+ int runTime();
+ QDateTime runStart () const { return mRunStart;}
+ public slots:
+ void saveRunningInfoToFile();
private:
+ bool mRunning;
+ QTimer * mRunSaveTimer;
+ QDateTime mRunStart;
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtDue; // due date of todo
bool mHasDueDate; // if todo has associated due date
// int mStatus; // confirmed/delegated/tentative/etc
QDateTime mCompleted;
bool mHasCompletedDate;
int mPercentComplete;