-rw-r--r-- | libkcal/todo.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 70a7711..29f725f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -1,386 +1,386 @@ | |||
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 <kglobalsettings.h> |
23 | #include <klocale.h> | 23 | #include <klocale.h> |
24 | #include <kdebug.h> | 24 | #include <kdebug.h> |
25 | #include <qregexp.h> | 25 | #include <qregexp.h> |
26 | #include <qfileinfo.h> | 26 | #include <qfileinfo.h> |
27 | 27 | ||
28 | #include "calendarlocal.h" | 28 | #include "calendarlocal.h" |
29 | #include "icalformat.h" | 29 | #include "icalformat.h" |
30 | #include "todo.h" | 30 | #include "todo.h" |
31 | 31 | ||
32 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | #define SAVETIMER_TIMEOUT_SECONDS 300 | 36 | #define SAVETIMER_TIMEOUT_SECONDS 300 |
37 | //#define SAVETIMER_TIMEOUT_SECONDS 8 | 37 | //#define SAVETIMER_TIMEOUT_SECONDS 8 |
38 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 | 38 | #define SAVETIMER_TIMEOUT_RETRY_SECONDS 5 |
39 | 39 | ||
40 | using namespace KCal; | 40 | using namespace KCal; |
41 | 41 | ||
42 | Todo::Todo(): QObject(), Incidence() | 42 | Todo::Todo(): QObject(), Incidence() |
43 | { | 43 | { |
44 | // mStatus = TENTATIVE; | 44 | // mStatus = TENTATIVE; |
45 | 45 | ||
46 | mHasDueDate = false; | 46 | mHasDueDate = false; |
47 | setHasStartDate( false ); | 47 | setHasStartDate( false ); |
48 | mCompleted = getEvenTime(QDateTime::currentDateTime()); | 48 | mCompleted = getEvenTime(QDateTime::currentDateTime()); |
49 | mHasCompletedDate = false; | 49 | mHasCompletedDate = false; |
50 | mPercentComplete = 0; | 50 | mPercentComplete = 0; |
51 | mRunning = false; | 51 | mRunning = false; |
52 | mRunSaveTimer = 0; | 52 | mRunSaveTimer = 0; |
53 | setFloats( true ); | 53 | setFloats( true ); |
54 | mCurrentTimerDelay = 0; | 54 | mCurrentTimerDelay = 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) | 57 | Todo::Todo(const Todo &t) : QObject(),Incidence(t) |
58 | { | 58 | { |
59 | mDtDue = t.mDtDue; | 59 | mDtDue = t.mDtDue; |
60 | mHasDueDate = t.mHasDueDate; | 60 | mHasDueDate = t.mHasDueDate; |
61 | mCompleted = t.mCompleted; | 61 | mCompleted = t.mCompleted; |
62 | mHasCompletedDate = t.mHasCompletedDate; | 62 | mHasCompletedDate = t.mHasCompletedDate; |
63 | mPercentComplete = t.mPercentComplete; | 63 | mPercentComplete = t.mPercentComplete; |
64 | mRunning = false; | 64 | mRunning = false; |
65 | mRunSaveTimer = 0; | 65 | mRunSaveTimer = 0; |
66 | mCurrentTimerDelay = 0; | 66 | mCurrentTimerDelay = 0; |
67 | } | 67 | } |
68 | 68 | ||
69 | Todo::~Todo() | 69 | Todo::~Todo() |
70 | { | 70 | { |
71 | setRunning( false ); | 71 | setRunning( false ); |
72 | //qDebug("Todo::~Todo() "); | 72 | //qDebug("Todo::~Todo() "); |
73 | } | 73 | } |
74 | 74 | ||
75 | void Todo::setRunningFalse( QString s ) | 75 | void Todo::setRunningFalse( QString s ) |
76 | { | 76 | { |
77 | if ( ! mRunning ) | 77 | if ( ! mRunning ) |
78 | return; | 78 | return; |
79 | mRunning = false; | 79 | mRunning = false; |
80 | if ( mRunSaveTimer ) | 80 | if ( mRunSaveTimer ) |
81 | mRunSaveTimer->stop(); | 81 | mRunSaveTimer->stop(); |
82 | saveRunningInfoToFile( s ); | 82 | saveRunningInfoToFile( s ); |
83 | } | 83 | } |
84 | void Todo::stopRunning() | 84 | void Todo::stopRunning() |
85 | { | 85 | { |
86 | if ( !mRunning ) | 86 | if ( !mRunning ) |
87 | return; | 87 | return; |
88 | if ( mRunSaveTimer ) | 88 | if ( mRunSaveTimer ) |
89 | mRunSaveTimer->stop(); | 89 | mRunSaveTimer->stop(); |
90 | mRunning = false; | 90 | mRunning = false; |
91 | } | 91 | } |
92 | void Todo::setRunning( bool run ) | 92 | void Todo::setRunning( bool run ) |
93 | { | 93 | { |
94 | if ( run == mRunning ) | 94 | if ( run == mRunning ) |
95 | return; | 95 | return; |
96 | //qDebug("Todo::setRunning %d ", run); | 96 | //qDebug("Todo::setRunning %d ", run); |
97 | if ( !mRunSaveTimer ) { | 97 | if ( !mRunSaveTimer ) { |
98 | mRunSaveTimer = new QTimer ( this ); | 98 | mRunSaveTimer = new QTimer ( this ); |
99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); | 99 | connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( timerSlotSaveRunningInfoToFile() ) ); |
100 | } | 100 | } |
101 | mRunning = run; | 101 | mRunning = run; |
102 | mRunLastSave = QDateTime::currentDateTime(); | 102 | mRunLastSave = QDateTime::currentDateTime(); |
103 | if ( mRunning ) { | 103 | if ( mRunning ) { |
104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 104 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
105 | mRunStart = QDateTime::currentDateTime(); | 105 | mRunStart = QDateTime::currentDateTime(); |
106 | } else { | 106 | } else { |
107 | mRunSaveTimer->stop(); | 107 | mRunSaveTimer->stop(); |
108 | saveRunningInfoToFile(); | 108 | saveRunningInfoToFile(); |
109 | } | 109 | } |
110 | } | 110 | } |
111 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) | 111 | void Todo::saveRunningInfo( QString comment, QDateTime start, QDateTime end ) |
112 | { | 112 | { |
113 | if ( !mRunning) return; | 113 | if ( !mRunning) return; |
114 | mRunning = false; | 114 | mRunning = false; |
115 | mRunStart = start; | 115 | mRunStart = start; |
116 | mRunEnd = end; | 116 | mRunEnd = end; |
117 | saveRunningInfoToFile( comment ); | 117 | saveRunningInfoToFile( comment ); |
118 | } | 118 | } |
119 | void Todo::restartSaveTimer( int secs ) | 119 | void Todo::restartSaveTimer( int secs ) |
120 | { | 120 | { |
121 | mRunSaveTimer->start( secs * 1000 ); | 121 | mRunSaveTimer->start( secs * 1000 ); |
122 | mRunLastSave = QDateTime::currentDateTime(); | 122 | mRunLastSave = QDateTime::currentDateTime(); |
123 | mCurrentTimerDelay = secs; | 123 | mCurrentTimerDelay = secs; |
124 | } | 124 | } |
125 | void Todo::timerSlotSaveRunningInfoToFile() | 125 | void Todo::timerSlotSaveRunningInfoToFile() |
126 | { | 126 | { |
127 | mRunEnd = QDateTime::currentDateTime(); | 127 | mRunEnd = QDateTime::currentDateTime(); |
128 | int secsTo = mRunLastSave.secsTo( mRunEnd ); | 128 | int secsTo = mRunLastSave.secsTo( mRunEnd ); |
129 | //if( secsTo == 8 ) ++secsTo; | 129 | //if( secsTo == 8 ) ++secsTo; |
130 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); | 130 | qDebug("KO Todo::saveTimerTimeout %d %d", secsTo, mCurrentTimerDelay ); |
131 | if ( secsTo > mCurrentTimerDelay ) { | 131 | if ( secsTo > mCurrentTimerDelay ) { |
132 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 132 | qDebug("KO Todo::saveTimerTimeout restart %d ", SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
133 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 133 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
134 | return; | 134 | return; |
135 | } | 135 | } |
136 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); | 136 | int msecs = mRunLastSave.time().msecsTo( mRunEnd.time()); |
137 | if ( msecs < 0 ) { | 137 | if ( msecs < 0 ) { |
138 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 138 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
139 | return; | 139 | return; |
140 | } | 140 | } |
141 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 141 | // qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
142 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { | 142 | if ( msecs > ( ( mCurrentTimerDelay * 1000 ) + 50 )) { |
143 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); | 143 | qDebug("KO Todo::saveTimerTimeout restarting! millisecs %d", msecs - ( ( mCurrentTimerDelay * 1000 ) + 50 ) ); |
144 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); | 144 | restartSaveTimer( SAVETIMER_TIMEOUT_RETRY_SECONDS ); |
145 | return; | 145 | return; |
146 | } | 146 | } |
147 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); | 147 | restartSaveTimer( SAVETIMER_TIMEOUT_SECONDS ); |
148 | saveRunningInfoToFile( QString::null ); | 148 | saveRunningInfoToFile( QString::null ); |
149 | } | 149 | } |
150 | void Todo::saveRunningInfoToFile() | 150 | void Todo::saveRunningInfoToFile() |
151 | { | 151 | { |
152 | mRunEnd = QDateTime::currentDateTime(); | 152 | mRunEnd = QDateTime::currentDateTime(); |
153 | saveRunningInfoToFile( QString::null ); | 153 | saveRunningInfoToFile( QString::null ); |
154 | } | 154 | } |
155 | void Todo::saveRunningInfoToFile( QString comment ) | 155 | void Todo::saveRunningInfoToFile( QString comment ) |
156 | { | 156 | { |
157 | #ifndef DESKTOP_VERSION | 157 | #ifndef DESKTOP_VERSION |
158 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); | 158 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Disable ); |
159 | #endif | 159 | #endif |
160 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); | 160 | //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); |
161 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { | 161 | if ( mRunStart.secsTo ( mRunEnd) < 15 ) { |
162 | qDebug("Running time < 15 seconds. Skipped. "); | 162 | qDebug("Running time < 15 seconds. Skipped. "); |
163 | return; | 163 | return; |
164 | } | 164 | } |
165 | QString dir = KGlobalSettings::timeTrackerDir(); | 165 | QString dir = KGlobalSettings::timeTrackerDir(); |
166 | //qDebug("%s ", dir.latin1()); | 166 | //qDebug("%s ", dir.latin1()); |
167 | QString file = "%1%2%3-%4%5%6-"; | 167 | QString file = "%1%2%3-%4%5%6-"; |
168 | 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 ); | 168 | 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 ); |
169 | file.replace ( QRegExp (" "), "0" ); | 169 | file.replace ( QRegExp (" "), "0" ); |
170 | file += uid(); | 170 | file += uid(); |
171 | //qDebug("File %s ",file.latin1() ); | 171 | //qDebug("File %s ",file.latin1() ); |
172 | CalendarLocal cal; | 172 | CalendarLocal cal; |
173 | cal.setLocalTime(); | 173 | cal.setLocalTime(); |
174 | Todo * to = (Todo*) clone(); | 174 | Todo * to = (Todo*) clone(); |
175 | to->setFloats( false ); | 175 | to->setFloats( false ); |
176 | to->setDtStart( mRunStart ); | 176 | to->setDtStart( mRunStart ); |
177 | to->setHasStartDate( true ); | 177 | to->setHasStartDate( true ); |
178 | to->setDtDue( mRunEnd ); | 178 | to->setDtDue( mRunEnd ); |
179 | to->setHasDueDate( true ); | 179 | to->setHasDueDate( true ); |
180 | to->setUid( file ); | 180 | to->setUid( file ); |
181 | if ( !comment.isEmpty() ) { | 181 | if ( !comment.isEmpty() ) { |
182 | QString des = to->description(); | 182 | QString des = to->description(); |
183 | if ( des.isEmpty () ) | 183 | if ( des.isEmpty () ) |
184 | to->setDescription( "TT-Note: " + comment ); | 184 | to->setDescription( "TT-Note: " + comment ); |
185 | else | 185 | else |
186 | to->setDescription( "TT-Note: " + comment +"\n" + des ); | 186 | to->setDescription( "TT-Note: " + comment +"\n" + des ); |
187 | } | 187 | } |
188 | cal.addIncidence( to ); | 188 | cal.addIncidence( to ); |
189 | ICalFormat format( false ); | 189 | ICalFormat format( false ); |
190 | file = dir +"/" +file +".ics"; | 190 | file = dir +"/" +file +".ics"; |
191 | format.save( &cal, file ); | 191 | format.save( &cal, file ); |
192 | saveParents(); | 192 | saveParents(); |
193 | #ifndef DESKTOP_VERSION | 193 | #ifndef DESKTOP_VERSION |
194 | QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); | 194 | //QPEApplication::setTempScreenSaverMode ( QPEApplication::Enable ); |
195 | #endif | 195 | #endif |
196 | } | 196 | } |
197 | void Todo::saveParents() | 197 | void Todo::saveParents() |
198 | { | 198 | { |
199 | if (!relatedTo() ) | 199 | if (!relatedTo() ) |
200 | return; | 200 | return; |
201 | Incidence * inc = relatedTo(); | 201 | Incidence * inc = relatedTo(); |
202 | if ( inc->typeID() != todoID ) | 202 | if ( inc->typeID() != todoID ) |
203 | return; | 203 | return; |
204 | Todo* to = (Todo*)inc; | 204 | Todo* to = (Todo*)inc; |
205 | bool saveTodo = false; | 205 | bool saveTodo = false; |
206 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; | 206 | QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; |
207 | QFileInfo fi ( file ); | 207 | QFileInfo fi ( file ); |
208 | if ( fi.exists() ) { | 208 | if ( fi.exists() ) { |
209 | if ( fi.lastModified () < to->lastModified ()) | 209 | if ( fi.lastModified () < to->lastModified ()) |
210 | saveTodo = true; | 210 | saveTodo = true; |
211 | } else { | 211 | } else { |
212 | saveTodo = true; | 212 | saveTodo = true; |
213 | } | 213 | } |
214 | if ( saveTodo ) { | 214 | if ( saveTodo ) { |
215 | CalendarLocal cal; | 215 | CalendarLocal cal; |
216 | cal.setLocalTime(); | 216 | cal.setLocalTime(); |
217 | Todo * par = (Todo *) to->clone(); | 217 | Todo * par = (Todo *) to->clone(); |
218 | cal.addIncidence( par ); | 218 | cal.addIncidence( par ); |
219 | ICalFormat format( false ); | 219 | ICalFormat format( false ); |
220 | format.save( &cal, file ); | 220 | format.save( &cal, file ); |
221 | } | 221 | } |
222 | to->saveParents(); | 222 | to->saveParents(); |
223 | } | 223 | } |
224 | 224 | ||
225 | int Todo::runTime() | 225 | int Todo::runTime() |
226 | { | 226 | { |
227 | if ( !mRunning ) | 227 | if ( !mRunning ) |
228 | return 0; | 228 | return 0; |
229 | return mRunStart.secsTo( QDateTime::currentDateTime() ); | 229 | return mRunStart.secsTo( QDateTime::currentDateTime() ); |
230 | } | 230 | } |
231 | bool Todo::hasRunningSub() | 231 | bool Todo::hasRunningSub() |
232 | { | 232 | { |
233 | if ( mRunning ) | 233 | if ( mRunning ) |
234 | return true; | 234 | return true; |
235 | Incidence *aTodo; | 235 | Incidence *aTodo; |
236 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | 236 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { |
237 | if ( ((Todo*)aTodo)->hasRunningSub() ) | 237 | if ( ((Todo*)aTodo)->hasRunningSub() ) |
238 | return true; | 238 | return true; |
239 | } | 239 | } |
240 | return false; | 240 | return false; |
241 | } | 241 | } |
242 | Incidence *Todo::clone() | 242 | Incidence *Todo::clone() |
243 | { | 243 | { |
244 | return new Todo(*this); | 244 | return new Todo(*this); |
245 | } | 245 | } |
246 | 246 | ||
247 | bool Todo::contains ( Todo* from ) | 247 | bool Todo::contains ( Todo* from ) |
248 | { | 248 | { |
249 | 249 | ||
250 | if ( !from->summary().isEmpty() ) | 250 | if ( !from->summary().isEmpty() ) |
251 | if ( !summary().startsWith( from->summary() )) | 251 | if ( !summary().startsWith( from->summary() )) |
252 | return false; | 252 | return false; |
253 | if ( from->hasStartDate() ) { | 253 | if ( from->hasStartDate() ) { |
254 | if ( !hasStartDate() ) | 254 | if ( !hasStartDate() ) |
255 | return false; | 255 | return false; |
256 | if ( from->dtStart() != dtStart()) | 256 | if ( from->dtStart() != dtStart()) |
257 | return false; | 257 | return false; |
258 | } | 258 | } |
259 | if ( from->hasDueDate() ){ | 259 | if ( from->hasDueDate() ){ |
260 | if ( !hasDueDate() ) | 260 | if ( !hasDueDate() ) |
261 | return false; | 261 | return false; |
262 | if ( from->dtDue() != dtDue()) | 262 | if ( from->dtDue() != dtDue()) |
263 | return false; | 263 | return false; |
264 | } | 264 | } |
265 | if ( !from->location().isEmpty() ) | 265 | if ( !from->location().isEmpty() ) |
266 | if ( !location().startsWith( from->location() ) ) | 266 | if ( !location().startsWith( from->location() ) ) |
267 | return false; | 267 | return false; |
268 | if ( !from->description().isEmpty() ) | 268 | if ( !from->description().isEmpty() ) |
269 | if ( !description().startsWith( from->description() )) | 269 | if ( !description().startsWith( from->description() )) |
270 | return false; | 270 | return false; |
271 | if ( from->alarms().count() ) { | 271 | if ( from->alarms().count() ) { |
272 | Alarm *a = from->alarms().first(); | 272 | Alarm *a = from->alarms().first(); |
273 | if ( a->enabled() ){ | 273 | if ( a->enabled() ){ |
274 | if ( !alarms().count() ) | 274 | if ( !alarms().count() ) |
275 | return false; | 275 | return false; |
276 | Alarm *b = alarms().first(); | 276 | Alarm *b = alarms().first(); |
277 | if( ! b->enabled() ) | 277 | if( ! b->enabled() ) |
278 | return false; | 278 | return false; |
279 | if ( ! (a->offset() == b->offset() )) | 279 | if ( ! (a->offset() == b->offset() )) |
280 | return false; | 280 | return false; |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | QStringList cat = categories(); | 284 | QStringList cat = categories(); |
285 | QStringList catFrom = from->categories(); | 285 | QStringList catFrom = from->categories(); |
286 | QString nCat; | 286 | QString nCat; |
287 | unsigned int iii; | 287 | unsigned int iii; |
288 | for ( iii = 0; iii < catFrom.count();++iii ) { | 288 | for ( iii = 0; iii < catFrom.count();++iii ) { |
289 | nCat = catFrom[iii]; | 289 | nCat = catFrom[iii]; |
290 | if ( !nCat.isEmpty() ) | 290 | if ( !nCat.isEmpty() ) |
291 | if ( !cat.contains( nCat )) { | 291 | if ( !cat.contains( nCat )) { |
292 | return false; | 292 | return false; |
293 | } | 293 | } |
294 | } | 294 | } |
295 | if ( from->isCompleted() ) { | 295 | if ( from->isCompleted() ) { |
296 | if ( !isCompleted() ) | 296 | if ( !isCompleted() ) |
297 | return false; | 297 | return false; |
298 | } | 298 | } |
299 | if( priority() != from->priority() ) | 299 | if( priority() != from->priority() ) |
300 | return false; | 300 | return false; |
301 | 301 | ||
302 | 302 | ||
303 | return true; | 303 | return true; |
304 | 304 | ||
305 | } | 305 | } |
306 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) | 306 | bool KCal::operator==( const Todo& t1, const Todo& t2 ) |
307 | { | 307 | { |
308 | 308 | ||
309 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); | 309 | bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); |
310 | if ( ! ret ) | 310 | if ( ! ret ) |
311 | return false; | 311 | return false; |
312 | if ( t1.hasDueDate() == t2.hasDueDate() ) { | 312 | if ( t1.hasDueDate() == t2.hasDueDate() ) { |
313 | if ( t1.hasDueDate() ) { | 313 | if ( t1.hasDueDate() ) { |
314 | if ( t1.doesFloat() == t2.doesFloat() ) { | 314 | if ( t1.doesFloat() == t2.doesFloat() ) { |
315 | if ( t1.doesFloat() ) { | 315 | if ( t1.doesFloat() ) { |
316 | if ( t1.dtDue().date() != t2.dtDue().date() ) | 316 | if ( t1.dtDue().date() != t2.dtDue().date() ) |
317 | return false; | 317 | return false; |
318 | } else | 318 | } else |
319 | if ( t1.dtDue() != t2.dtDue() ) | 319 | if ( t1.dtDue() != t2.dtDue() ) |
320 | return false; | 320 | return false; |
321 | } else | 321 | } else |
322 | return false;// float != | 322 | return false;// float != |
323 | } | 323 | } |
324 | 324 | ||
325 | } else | 325 | } else |
326 | return false; | 326 | return false; |
327 | if ( t1.percentComplete() != t2.percentComplete() ) | 327 | if ( t1.percentComplete() != t2.percentComplete() ) |
328 | return false; | 328 | return false; |
329 | if ( t1.isCompleted() ) { | 329 | if ( t1.isCompleted() ) { |
330 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 330 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
331 | if ( t1.hasCompletedDate() ) { | 331 | if ( t1.hasCompletedDate() ) { |
332 | if ( t1.completed() != t2.completed() ) | 332 | if ( t1.completed() != t2.completed() ) |
333 | return false; | 333 | return false; |
334 | } | 334 | } |
335 | 335 | ||
336 | } else | 336 | } else |
337 | return false; | 337 | return false; |
338 | } | 338 | } |
339 | return true; | 339 | return true; |
340 | 340 | ||
341 | } | 341 | } |
342 | 342 | ||
343 | void Todo::setDtDue(const QDateTime &dtDue) | 343 | void Todo::setDtDue(const QDateTime &dtDue) |
344 | { | 344 | { |
345 | //int diffsecs = mDtDue.secsTo(dtDue); | 345 | //int diffsecs = mDtDue.secsTo(dtDue); |
346 | 346 | ||
347 | /*if (mReadOnly) return; | 347 | /*if (mReadOnly) return; |
348 | const QPtrList<Alarm>& alarms = alarms(); | 348 | const QPtrList<Alarm>& alarms = alarms(); |
349 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 349 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
350 | if (alarm->enabled()) { | 350 | if (alarm->enabled()) { |
351 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 351 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
352 | } | 352 | } |
353 | }*/ | 353 | }*/ |
354 | mDtDue = getEvenTime(dtDue); | 354 | mDtDue = getEvenTime(dtDue); |
355 | 355 | ||
356 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 356 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
357 | 357 | ||
358 | /*const QPtrList<Alarm>& alarms = alarms(); | 358 | /*const QPtrList<Alarm>& alarms = alarms(); |
359 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 359 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
360 | alarm->setAlarmStart(mDtDue);*/ | 360 | alarm->setAlarmStart(mDtDue);*/ |
361 | updated(); | 361 | updated(); |
362 | } | 362 | } |
363 | 363 | ||
364 | QDateTime Todo::dtDue() const | 364 | QDateTime Todo::dtDue() const |
365 | { | 365 | { |
366 | return mDtDue; | 366 | return mDtDue; |
367 | } | 367 | } |
368 | 368 | ||
369 | QString Todo::dtDueTimeStr() const | 369 | QString Todo::dtDueTimeStr() const |
370 | { | 370 | { |
371 | return KGlobal::locale()->formatTime(mDtDue.time()); | 371 | return KGlobal::locale()->formatTime(mDtDue.time()); |
372 | } | 372 | } |
373 | 373 | ||
374 | QString Todo::dtDueDateStr(bool shortfmt) const | 374 | QString Todo::dtDueDateStr(bool shortfmt) const |
375 | { | 375 | { |
376 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 376 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
377 | } | 377 | } |
378 | 378 | ||
379 | QString Todo::dtDueStr(bool shortfmt) const | 379 | QString Todo::dtDueStr(bool shortfmt) const |
380 | { | 380 | { |
381 | if ( doesFloat() ) | 381 | if ( doesFloat() ) |
382 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 382 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
383 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 383 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
384 | } | 384 | } |
385 | // retval 0 : no found | 385 | // retval 0 : no found |
386 | // 1 : due for date found | 386 | // 1 : due for date found |