author | zautrix <zautrix> | 2005-04-28 09:08:21 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-28 09:08:21 (UTC) |
commit | 8fbdf5d2b0ee1e1496cb856e0ead37c668066353 (patch) (side-by-side diff) | |
tree | 964dd57f1492857fb9471a0af9943d08c56e5c6e /libkcal | |
parent | 42786862c89c0de78cec783f251eae66bcbc53db (diff) | |
download | kdepimpi-8fbdf5d2b0ee1e1496cb856e0ead37c668066353.zip kdepimpi-8fbdf5d2b0ee1e1496cb856e0ead37c668066353.tar.gz kdepimpi-8fbdf5d2b0ee1e1496cb856e0ead37c668066353.tar.bz2 |
added comment for todo
-rw-r--r-- | libkcal/todo.cpp | 13 | ||||
-rw-r--r-- | libkcal/todo.h | 3 |
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 @@ -32,106 +32,117 @@ using namespace KCal; Todo::Todo(): QObject(), Incidence() { // mStatus = TENTATIVE; mHasDueDate = false; setHasStartDate( false ); mCompleted = getEvenTime(QDateTime::currentDateTime()); mHasCompletedDate = false; mPercentComplete = 0; mRunning = false; mRunSaveTimer = 0; } Todo::Todo(const Todo &t) : QObject(),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 ); //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() ) ); } mRunning = run; if ( mRunning ) { 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()); QString file = "%1%2%3-%4%5%6-"; file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); file.replace ( QRegExp (" "), "0" ); file += uid(); //qDebug("File %s ",file.latin1() ); CalendarLocal cal; 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() { if (!relatedTo() ) return; Incidence * inc = relatedTo(); if ( inc->type() != "Todo" ) return; Todo* to = (Todo*)inc; bool saveTodo = false; QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; QFileInfo fi ( file ); if ( fi.exists() ) { if ( fi.lastModified () < to->lastModified ()) saveTodo = true; } else { saveTodo = true; } if ( saveTodo ) { CalendarLocal cal; cal.setLocalTime(); Todo * par = (Todo *) to->clone(); cal.addIncidence( par ); ICalFormat format; format.save( &cal, file ); } diff --git a/libkcal/todo.h b/libkcal/todo.h index ec1ffda..a5354ce 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h @@ -91,59 +91,60 @@ namespace KCal { // 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; /** Set how many percent of the task are completed. Valid values are in the range from 0 to 100. */ void setPercentComplete(int); /** 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 ); + 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 bool mHasDueDate; // if todo has associated due date // int mStatus; // confirmed/delegated/tentative/etc QDateTime mCompleted; bool mHasCompletedDate; int mPercentComplete; }; bool operator==( const Todo&, const Todo& ); } #endif |