summaryrefslogtreecommitdiffabout
path: root/libkcal/todo.cpp
Unidiff
Diffstat (limited to 'libkcal/todo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 4ada2d8..7bf756a 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -57,25 +57,26 @@ Todo::Todo(const Todo &t) : QObject(),Incidence(t)
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 if ( mRunSaveTimer )
70 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 71 saveRunningInfoToFile( s );
71} 72}
72void Todo::stopRunning() 73void Todo::stopRunning()
73{ 74{
74 if ( !mRunning ) 75 if ( !mRunning )
75 return; 76 return;
76 if ( mRunSaveTimer ) 77 if ( mRunSaveTimer )
77 mRunSaveTimer->stop(); 78 mRunSaveTimer->stop();
78 mRunning = false; 79 mRunning = false;
79} 80}
80void Todo::setRunning( bool run ) 81void Todo::setRunning( bool run )
81{ 82{
@@ -130,25 +131,25 @@ void Todo::saveRunningInfoToFile( QString comment )
130 to->setHasStartDate( true ); 131 to->setHasStartDate( true );
131 to->setDtDue( mRunEnd ); 132 to->setDtDue( mRunEnd );
132 to->setHasDueDate( true ); 133 to->setHasDueDate( true );
133 to->setUid( file ); 134 to->setUid( file );
134 if ( !comment.isEmpty() ) { 135 if ( !comment.isEmpty() ) {
135 QString des = to->description(); 136 QString des = to->description();
136 if ( des.isEmpty () ) 137 if ( des.isEmpty () )
137 to->setDescription( "TT-Note: " + comment ); 138 to->setDescription( "TT-Note: " + comment );
138 else 139 else
139 to->setDescription( "TT-Note: " + comment +"\n" + des ); 140 to->setDescription( "TT-Note: " + comment +"\n" + des );
140 } 141 }
141 cal.addIncidence( to ); 142 cal.addIncidence( to );
142 ICalFormat format; 143 ICalFormat format( false );
143 file = dir +"/" +file +".ics"; 144 file = dir +"/" +file +".ics";
144 format.save( &cal, file ); 145 format.save( &cal, file );
145 saveParents(); 146 saveParents();
146 147
147} 148}
148void Todo::saveParents() 149void Todo::saveParents()
149{ 150{
150 if (!relatedTo() ) 151 if (!relatedTo() )
151 return; 152 return;
152 Incidence * inc = relatedTo(); 153 Incidence * inc = relatedTo();
153 if ( inc->typeID() != todoID ) 154 if ( inc->typeID() != todoID )
154 return; 155 return;
@@ -158,25 +159,25 @@ void Todo::saveParents()
158 QFileInfo fi ( file ); 159 QFileInfo fi ( file );
159 if ( fi.exists() ) { 160 if ( fi.exists() ) {
160 if ( fi.lastModified () < to->lastModified ()) 161 if ( fi.lastModified () < to->lastModified ())
161 saveTodo = true; 162 saveTodo = true;
162 } else { 163 } else {
163 saveTodo = true; 164 saveTodo = true;
164 } 165 }
165 if ( saveTodo ) { 166 if ( saveTodo ) {
166 CalendarLocal cal; 167 CalendarLocal cal;
167 cal.setLocalTime(); 168 cal.setLocalTime();
168 Todo * par = (Todo *) to->clone(); 169 Todo * par = (Todo *) to->clone();
169 cal.addIncidence( par ); 170 cal.addIncidence( par );
170 ICalFormat format; 171 ICalFormat format( false );
171 format.save( &cal, file ); 172 format.save( &cal, file );
172 } 173 }
173 to->saveParents(); 174 to->saveParents();
174} 175}
175 176
176int Todo::runTime() 177int Todo::runTime()
177{ 178{
178 if ( !mRunning ) 179 if ( !mRunning )
179 return 0; 180 return 0;
180 return mRunStart.secsTo( QDateTime::currentDateTime() ); 181 return mRunStart.secsTo( QDateTime::currentDateTime() );
181} 182}
182bool Todo::hasRunningSub() 183bool Todo::hasRunningSub()