summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/todo.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index 5e6ac22..6a6c137 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -90,96 +90,97 @@ void Todo::saveRunningInfoToFile()
90 QString dir = KGlobalSettings::timeTrackerDir(); 90 QString dir = KGlobalSettings::timeTrackerDir();
91 //qDebug("%s ", dir.latin1()); 91 //qDebug("%s ", dir.latin1());
92 QString file = "%1%2%3-%4%5%6-"; 92 QString file = "%1%2%3-%4%5%6-";
93 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 ); 93 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 );
94 file.replace ( QRegExp (" "), "0" ); 94 file.replace ( QRegExp (" "), "0" );
95 file += uid(); 95 file += uid();
96 //qDebug("File %s ",file.latin1() ); 96 //qDebug("File %s ",file.latin1() );
97 CalendarLocal cal; 97 CalendarLocal cal;
98 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); 98 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" );
99 Todo * to = (Todo*) clone(); 99 Todo * to = (Todo*) clone();
100 to->setFloats( false ); 100 to->setFloats( false );
101 to->setDtStart( mRunStart ); 101 to->setDtStart( mRunStart );
102 to->setHasStartDate( true ); 102 to->setHasStartDate( true );
103 to->setDtDue( QDateTime::currentDateTime() ); 103 to->setDtDue( QDateTime::currentDateTime() );
104 to->setHasDueDate( true ); 104 to->setHasDueDate( true );
105 to->setUid( file ); 105 to->setUid( file );
106 cal.addIncidence( to ); 106 cal.addIncidence( to );
107 ICalFormat format; 107 ICalFormat format;
108 file = dir +"/" +file +".ics"; 108 file = dir +"/" +file +".ics";
109 format.save( &cal, file ); 109 format.save( &cal, file );
110 saveParents(); 110 saveParents();
111 111
112} 112}
113void Todo::saveParents() 113void Todo::saveParents()
114{ 114{
115 if (!relatedTo() ) 115 if (!relatedTo() )
116 return; 116 return;
117 Incidence * inc = relatedTo(); 117 Incidence * inc = relatedTo();
118 if ( inc->type() != "Todo" ) 118 if ( inc->type() != "Todo" )
119 return; 119 return;
120 Todo* to = (Todo*)inc; 120 Todo* to = (Todo*)inc;
121 bool saveTodo = false; 121 bool saveTodo = false;
122 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 122 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
123 QFileInfo fi ( file ); 123 QFileInfo fi ( file );
124 if ( fi.exists() ) { 124 if ( fi.exists() ) {
125 if ( fi.lastModified () < to->lastModified ()) 125 if ( fi.lastModified () < to->lastModified ())
126 saveTodo = true; 126 saveTodo = true;
127 } else { 127 } else {
128 saveTodo = true; 128 saveTodo = true;
129 } 129 }
130 if ( saveTodo ) { 130 if ( saveTodo ) {
131 CalendarLocal cal; 131 CalendarLocal cal;
132 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" ); 132 cal.setTimeZoneId( " 00:00 Europe/London(UTC)" );
133 Todo * par = (Todo *) to->clone(); 133 Todo * par = (Todo *) to->clone();
134 cal.addIncidence( par ); 134 cal.addIncidence( par );
135 ICalFormat format; 135 ICalFormat format;
136 format.save( &cal, file ); 136 format.save( &cal, file );
137 } 137 }
138 to->saveParents();
138} 139}
139 140
140int Todo::runTime() 141int Todo::runTime()
141{ 142{
142 if ( !mRunning ) 143 if ( !mRunning )
143 return 0; 144 return 0;
144 return mRunStart.secsTo( QDateTime::currentDateTime() ); 145 return mRunStart.secsTo( QDateTime::currentDateTime() );
145} 146}
146bool Todo::hasRunningSub() 147bool Todo::hasRunningSub()
147{ 148{
148 if ( mRunning ) 149 if ( mRunning )
149 return true; 150 return true;
150 Incidence *aTodo; 151 Incidence *aTodo;
151 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 152 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
152 if ( ((Todo*)aTodo)->hasRunningSub() ) 153 if ( ((Todo*)aTodo)->hasRunningSub() )
153 return true; 154 return true;
154 } 155 }
155 return false; 156 return false;
156} 157}
157Incidence *Todo::clone() 158Incidence *Todo::clone()
158{ 159{
159 return new Todo(*this); 160 return new Todo(*this);
160} 161}
161 162
162bool Todo::contains ( Todo* from ) 163bool Todo::contains ( Todo* from )
163{ 164{
164 165
165 if ( !from->summary().isEmpty() ) 166 if ( !from->summary().isEmpty() )
166 if ( !summary().startsWith( from->summary() )) 167 if ( !summary().startsWith( from->summary() ))
167 return false; 168 return false;
168 if ( from->hasStartDate() ) { 169 if ( from->hasStartDate() ) {
169 if ( !hasStartDate() ) 170 if ( !hasStartDate() )
170 return false; 171 return false;
171 if ( from->dtStart() != dtStart()) 172 if ( from->dtStart() != dtStart())
172 return false; 173 return false;
173 } 174 }
174 if ( from->hasDueDate() ){ 175 if ( from->hasDueDate() ){
175 if ( !hasDueDate() ) 176 if ( !hasDueDate() )
176 return false; 177 return false;
177 if ( from->dtDue() != dtDue()) 178 if ( from->dtDue() != dtDue())
178 return false; 179 return false;
179 } 180 }
180 if ( !from->location().isEmpty() ) 181 if ( !from->location().isEmpty() )
181 if ( !location().startsWith( from->location() ) ) 182 if ( !location().startsWith( from->location() ) )
182 return false; 183 return false;
183 if ( !from->description().isEmpty() ) 184 if ( !from->description().isEmpty() )
184 if ( !description().startsWith( from->description() )) 185 if ( !description().startsWith( from->description() ))
185 return false; 186 return false;