author | zautrix <zautrix> | 2005-04-09 20:21:58 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-09 20:21:58 (UTC) |
commit | 9e43ebbe5867b2da957bb17c35bd357715424cba (patch) (side-by-side diff) | |
tree | b506ba029b50fc46a33d35a39e6f1c768c995f22 /libkcal/todo.cpp | |
parent | 2c39ac46121e8796e780a5321ab777f08792e5ba (diff) | |
download | kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.zip kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.gz kdepimpi-9e43ebbe5867b2da957bb17c35bd357715424cba.tar.bz2 |
todo tt
-rw-r--r-- | libkcal/todo.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index a496404..7dee4cd 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp @@ -1,101 +1,145 @@ /* This file is part of libkcal. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License 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. */ #include <kglobal.h> #include <klocale.h> #include <kdebug.h> #include "todo.h" 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() ) { if ( !hasStartDate() ) return false; if ( from->dtStart() != dtStart()) return false; } if ( from->hasDueDate() ){ if ( !hasDueDate() ) return false; if ( from->dtDue() != dtDue()) return false; } if ( !from->location().isEmpty() ) if ( !location().startsWith( from->location() ) ) return false; if ( !from->description().isEmpty() ) if ( !description().startsWith( from->description() )) return false; if ( from->alarms().count() ) { Alarm *a = from->alarms().first(); if ( a->enabled() ){ if ( !alarms().count() ) return false; Alarm *b = alarms().first(); if( ! b->enabled() ) return false; if ( ! (a->offset() == b->offset() )) return false; } } QStringList cat = categories(); QStringList catFrom = from->categories(); QString nCat; unsigned int iii; for ( iii = 0; iii < catFrom.count();++iii ) { nCat = catFrom[iii]; |