summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp16
1 files changed, 15 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 7dee4cd..c008fe1 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,47 +1,49 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h>
22#include <klocale.h> 23#include <klocale.h>
23#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h>
24 26
25#include "todo.h" 27#include "todo.h"
26 28
27using namespace KCal; 29using namespace KCal;
28 30
29Todo::Todo(): Incidence() 31Todo::Todo(): Incidence()
30{ 32{
31// mStatus = TENTATIVE; 33// mStatus = TENTATIVE;
32 34
33 mHasDueDate = false; 35 mHasDueDate = false;
34 setHasStartDate( false ); 36 setHasStartDate( false );
35 mCompleted = getEvenTime(QDateTime::currentDateTime()); 37 mCompleted = getEvenTime(QDateTime::currentDateTime());
36 mHasCompletedDate = false; 38 mHasCompletedDate = false;
37 mPercentComplete = 0; 39 mPercentComplete = 0;
38 mRunning = false; 40 mRunning = false;
39 mRunSaveTimer = 0; 41 mRunSaveTimer = 0;
40} 42}
41 43
42Todo::Todo(const Todo &t) : Incidence(t) 44Todo::Todo(const Todo &t) : Incidence(t)
43{ 45{
44 mDtDue = t.mDtDue; 46 mDtDue = t.mDtDue;
45 mHasDueDate = t.mHasDueDate; 47 mHasDueDate = t.mHasDueDate;
46 mCompleted = t.mCompleted; 48 mCompleted = t.mCompleted;
47 mHasCompletedDate = t.mHasCompletedDate; 49 mHasCompletedDate = t.mHasCompletedDate;
@@ -54,49 +56,61 @@ Todo::~Todo()
54{ 56{
55 setRunning( false ); 57 setRunning( false );
56} 58}
57 59
58void Todo::setRunning( bool run ) 60void Todo::setRunning( bool run )
59{ 61{
60 if ( run == mRunning ) 62 if ( run == mRunning )
61 return; 63 return;
62 if ( !mRunSaveTimer ) { 64 if ( !mRunSaveTimer ) {
63 mRunSaveTimer = new QTimer ( this ); 65 mRunSaveTimer = new QTimer ( this );
64 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 66 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
65 } 67 }
66 mRunning = run; 68 mRunning = run;
67 if ( mRunning ) { 69 if ( mRunning ) {
68 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 70 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
69 mRunStart = QDateTime::currentDateTime(); 71 mRunStart = QDateTime::currentDateTime();
70 } else { 72 } else {
71 mRunSaveTimer->stop(); 73 mRunSaveTimer->stop();
72 saveRunningInfoToFile(); 74 saveRunningInfoToFile();
73 } 75 }
74} 76}
75 77
76void Todo::saveRunningInfoToFile() 78void Todo::saveRunningInfoToFile()
77{ 79{
78 qDebug("Todo::saveRunningInfoToFile() "); 80 qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
81
82 QString dir = KGlobalSettings::timeTrackerDir();
83 qDebug("%s ", dir.latin1());
84 QString file = "%1-%2-%3-%4-%5-%6-%7.tt";
85
86 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 ).arg( mRunStart.time().msec(), 3 );
87 file.replace ( QRegExp (" "), "0" );
88 file = dir +"/" +file;
89 qDebug("%s ", file.latin1());
90
91
92
79} 93}
80 94
81int Todo::runTime() 95int Todo::runTime()
82{ 96{
83 if ( !mRunning ) 97 if ( !mRunning )
84 return 0; 98 return 0;
85 return mRunStart.secsTo( QDateTime::currentDateTime() ); 99 return mRunStart.secsTo( QDateTime::currentDateTime() );
86} 100}
87bool Todo::hasRunningSub() 101bool Todo::hasRunningSub()
88{ 102{
89 if ( mRunning ) 103 if ( mRunning )
90 return true; 104 return true;
91 Incidence *aTodo; 105 Incidence *aTodo;
92 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 106 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
93 if ( ((Todo*)aTodo)->hasRunningSub() ) 107 if ( ((Todo*)aTodo)->hasRunningSub() )
94 return true; 108 return true;
95 } 109 }
96 return false; 110 return false;
97} 111}
98Incidence *Todo::clone() 112Incidence *Todo::clone()
99{ 113{
100 return new Todo(*this); 114 return new Todo(*this);
101} 115}
102 116