summaryrefslogtreecommitdiffabout
path: root/libkcal
Unidiff
Diffstat (limited to 'libkcal') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index c008fe1..8794f7a 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -26,128 +26,141 @@
26 26
27#include "todo.h" 27#include "todo.h"
28 28
29using namespace KCal; 29using namespace KCal;
30 30
31Todo::Todo(): Incidence() 31Todo::Todo(): Incidence()
32{ 32{
33// mStatus = TENTATIVE; 33// mStatus = TENTATIVE;
34 34
35 mHasDueDate = false; 35 mHasDueDate = false;
36 setHasStartDate( false ); 36 setHasStartDate( false );
37 mCompleted = getEvenTime(QDateTime::currentDateTime()); 37 mCompleted = getEvenTime(QDateTime::currentDateTime());
38 mHasCompletedDate = false; 38 mHasCompletedDate = false;
39 mPercentComplete = 0; 39 mPercentComplete = 0;
40 mRunning = false; 40 mRunning = false;
41 mRunSaveTimer = 0; 41 mRunSaveTimer = 0;
42} 42}
43 43
44Todo::Todo(const Todo &t) : Incidence(t) 44Todo::Todo(const Todo &t) : Incidence(t)
45{ 45{
46 mDtDue = t.mDtDue; 46 mDtDue = t.mDtDue;
47 mHasDueDate = t.mHasDueDate; 47 mHasDueDate = t.mHasDueDate;
48 mCompleted = t.mCompleted; 48 mCompleted = t.mCompleted;
49 mHasCompletedDate = t.mHasCompletedDate; 49 mHasCompletedDate = t.mHasCompletedDate;
50 mPercentComplete = t.mPercentComplete; 50 mPercentComplete = t.mPercentComplete;
51 mRunning = false; 51 mRunning = false;
52 mRunSaveTimer = 0; 52 mRunSaveTimer = 0;
53} 53}
54 54
55Todo::~Todo() 55Todo::~Todo()
56{ 56{
57 setRunning( false ); 57 setRunning( false );
58} 58}
59 59
60void Todo::setRunning( bool run ) 60void Todo::setRunning( bool run )
61{ 61{
62 if ( run == mRunning ) 62 if ( run == mRunning )
63 return; 63 return;
64 if ( !mRunSaveTimer ) { 64 if ( !mRunSaveTimer ) {
65 mRunSaveTimer = new QTimer ( this ); 65 mRunSaveTimer = new QTimer ( this );
66 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 66 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
67 } 67 }
68 mRunning = run; 68 mRunning = run;
69 if ( mRunning ) { 69 if ( mRunning ) {
70 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 70 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
71 mRunStart = QDateTime::currentDateTime(); 71 mRunStart = QDateTime::currentDateTime();
72 } else { 72 } else {
73 mRunSaveTimer->stop(); 73 mRunSaveTimer->stop();
74 saveRunningInfoToFile(); 74 saveRunningInfoToFile();
75 } 75 }
76} 76}
77 77
78void Todo::saveRunningInfoToFile() 78void Todo::saveRunningInfoToFile()
79{ 79{
80 qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 80 qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
81 81
82 QString dir = KGlobalSettings::timeTrackerDir(); 82 QString dir = KGlobalSettings::timeTrackerDir();
83 qDebug("%s ", dir.latin1()); 83 qDebug("%s ", dir.latin1());
84 QString file = "%1-%2-%3-%4-%5-%6-%7.tt"; 84 QString file = "%1-%2-%3-%4-%5-%6-%7.tt";
85 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 ); 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" ); 87 file.replace ( QRegExp (" "), "0" );
88 file = dir +"/" +file; 88 file = dir +"/" +file;
89 qDebug("%s ", file.latin1()); 89 qDebug("%s ", file.latin1());
90 QStringList dataList;
91
92 //Summary
93 //Category
94 //CategoryColor
95 //StartRuntime
96 //Runtime
97 //Due
98 //Start
99 //Prio
100 //Erledigt
101 //Uid
102 //Parents uids
90 103
91 104
92 105
93} 106}
94 107
95int Todo::runTime() 108int Todo::runTime()
96{ 109{
97 if ( !mRunning ) 110 if ( !mRunning )
98 return 0; 111 return 0;
99 return mRunStart.secsTo( QDateTime::currentDateTime() ); 112 return mRunStart.secsTo( QDateTime::currentDateTime() );
100} 113}
101bool Todo::hasRunningSub() 114bool Todo::hasRunningSub()
102{ 115{
103 if ( mRunning ) 116 if ( mRunning )
104 return true; 117 return true;
105 Incidence *aTodo; 118 Incidence *aTodo;
106 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 119 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
107 if ( ((Todo*)aTodo)->hasRunningSub() ) 120 if ( ((Todo*)aTodo)->hasRunningSub() )
108 return true; 121 return true;
109 } 122 }
110 return false; 123 return false;
111} 124}
112Incidence *Todo::clone() 125Incidence *Todo::clone()
113{ 126{
114 return new Todo(*this); 127 return new Todo(*this);
115} 128}
116 129
117bool Todo::contains ( Todo* from ) 130bool Todo::contains ( Todo* from )
118{ 131{
119 132
120 if ( !from->summary().isEmpty() ) 133 if ( !from->summary().isEmpty() )
121 if ( !summary().startsWith( from->summary() )) 134 if ( !summary().startsWith( from->summary() ))
122 return false; 135 return false;
123 if ( from->hasStartDate() ) { 136 if ( from->hasStartDate() ) {
124 if ( !hasStartDate() ) 137 if ( !hasStartDate() )
125 return false; 138 return false;
126 if ( from->dtStart() != dtStart()) 139 if ( from->dtStart() != dtStart())
127 return false; 140 return false;
128 } 141 }
129 if ( from->hasDueDate() ){ 142 if ( from->hasDueDate() ){
130 if ( !hasDueDate() ) 143 if ( !hasDueDate() )
131 return false; 144 return false;
132 if ( from->dtDue() != dtDue()) 145 if ( from->dtDue() != dtDue())
133 return false; 146 return false;
134 } 147 }
135 if ( !from->location().isEmpty() ) 148 if ( !from->location().isEmpty() )
136 if ( !location().startsWith( from->location() ) ) 149 if ( !location().startsWith( from->location() ) )
137 return false; 150 return false;
138 if ( !from->description().isEmpty() ) 151 if ( !from->description().isEmpty() )
139 if ( !description().startsWith( from->description() )) 152 if ( !description().startsWith( from->description() ))
140 return false; 153 return false;
141 if ( from->alarms().count() ) { 154 if ( from->alarms().count() ) {
142 Alarm *a = from->alarms().first(); 155 Alarm *a = from->alarms().first();
143 if ( a->enabled() ){ 156 if ( a->enabled() ){
144 if ( !alarms().count() ) 157 if ( !alarms().count() )
145 return false; 158 return false;
146 Alarm *b = alarms().first(); 159 Alarm *b = alarms().first();
147 if( ! b->enabled() ) 160 if( ! b->enabled() )
148 return false; 161 return false;
149 if ( ! (a->offset() == b->offset() )) 162 if ( ! (a->offset() == b->offset() ))
150 return false; 163 return false;
151 } 164 }
152 } 165 }
153 166