summaryrefslogtreecommitdiffabout
path: root/libkcal
Side-by-side diff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp13
-rw-r--r--libkcal/todo.h3
2 files changed, 14 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 002d3f2..f7e38a7 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -56,16 +56,24 @@ Todo::Todo(const Todo &t) : QObject(),Incidence(t)
}
Todo::~Todo()
{
setRunning( false );
//qDebug("Todo::~Todo() ");
}
+void Todo::setRunningFalse( QString s )
+{
+ if ( ! mRunning )
+ return;
+ mRunning = false;
+ mRunSaveTimer->stop();
+ saveRunningInfoToFile( s );
+}
void Todo::setRunning( bool run )
{
if ( run == mRunning )
return;
//qDebug("Todo::setRunning %d ", run);
if ( !mRunSaveTimer ) {
mRunSaveTimer = new QTimer ( this );
connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
@@ -75,17 +83,17 @@ void Todo::setRunning( bool run )
mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
mRunStart = QDateTime::currentDateTime();
} else {
mRunSaveTimer->stop();
saveRunningInfoToFile();
}
}
-void Todo::saveRunningInfoToFile()
+void Todo::saveRunningInfoToFile( QString comment )
{
//qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
qDebug("Running time < 30 seconds. Skipped. ");
return;
}
QString dir = KGlobalSettings::timeTrackerDir();
//qDebug("%s ", dir.latin1());
@@ -98,16 +106,19 @@ void Todo::saveRunningInfoToFile()
cal.setLocalTime();
Todo * to = (Todo*) clone();
to->setFloats( false );
to->setDtStart( mRunStart );
to->setHasStartDate( true );
to->setDtDue( QDateTime::currentDateTime() );
to->setHasDueDate( true );
to->setUid( file );
+ if ( !comment.isEmpty() ) {
+ to->setDescription( comment );
+ }
cal.addIncidence( to );
ICalFormat format;
file = dir +"/" +file +".ics";
format.save( &cal, file );
saveParents();
}
void Todo::saveParents()
diff --git a/libkcal/todo.h b/libkcal/todo.h
index ec1ffda..a5354ce 100644
--- a/libkcal/todo.h
+++ b/libkcal/todo.h
@@ -115,20 +115,21 @@ namespace KCal {
/** 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 );
+ void setRunningFalse( QString );
int runTime();
QDateTime runStart () const { return mRunStart;}
public slots:
- void saveRunningInfoToFile();
+ void saveRunningInfoToFile( QString st = QString::null );
void saveParents();
private:
bool mRunning;
QTimer * mRunSaveTimer;
QDateTime mRunStart;
bool accept(Visitor &v) { return v.visit(this); }
QDateTime mDtDue; // due date of todo