author | zautrix <zautrix> | 2005-02-05 11:26:35 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-05 11:26:35 (UTC) |
commit | 86c0d35262454a31ed7d50d3e20cbdace954ebdf (patch) (unidiff) | |
tree | 7ded091fe9111fe20014f8edbc5f338293e36386 /libkcal/todo.cpp | |
parent | 3a822a4c4867acb28dc1b3b9557918d0971f732c (diff) | |
download | kdepimpi-86c0d35262454a31ed7d50d3e20cbdace954ebdf.zip kdepimpi-86c0d35262454a31ed7d50d3e20cbdace954ebdf.tar.gz kdepimpi-86c0d35262454a31ed7d50d3e20cbdace954ebdf.tar.bz2 |
another fixx
-rw-r--r-- | libkcal/todo.cpp | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 7f1de78..d81a68f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -132,129 +132,159 @@ bool KCal::operator==( const Todo& t1, const Todo& t2 ) | |||
132 | return false; | 132 | return false; |
133 | } else | 133 | } else |
134 | return false;// float != | 134 | return false;// float != |
135 | } | 135 | } |
136 | 136 | ||
137 | } else | 137 | } else |
138 | return false; | 138 | return false; |
139 | if ( t1.percentComplete() != t2.percentComplete() ) | 139 | if ( t1.percentComplete() != t2.percentComplete() ) |
140 | return false; | 140 | return false; |
141 | if ( t1.isCompleted() ) { | 141 | if ( t1.isCompleted() ) { |
142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { | 142 | if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { |
143 | if ( t1.hasCompletedDate() ) { | 143 | if ( t1.hasCompletedDate() ) { |
144 | if ( t1.completed() != t2.completed() ) | 144 | if ( t1.completed() != t2.completed() ) |
145 | return false; | 145 | return false; |
146 | } | 146 | } |
147 | 147 | ||
148 | } else | 148 | } else |
149 | return false; | 149 | return false; |
150 | } | 150 | } |
151 | return true; | 151 | return true; |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | void Todo::setDtDue(const QDateTime &dtDue) | 155 | void Todo::setDtDue(const QDateTime &dtDue) |
156 | { | 156 | { |
157 | //int diffsecs = mDtDue.secsTo(dtDue); | 157 | //int diffsecs = mDtDue.secsTo(dtDue); |
158 | 158 | ||
159 | /*if (mReadOnly) return; | 159 | /*if (mReadOnly) return; |
160 | const QPtrList<Alarm>& alarms = alarms(); | 160 | const QPtrList<Alarm>& alarms = alarms(); |
161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { | 161 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { |
162 | if (alarm->enabled()) { | 162 | if (alarm->enabled()) { |
163 | alarm->setTime(alarm->time().addSecs(diffsecs)); | 163 | alarm->setTime(alarm->time().addSecs(diffsecs)); |
164 | } | 164 | } |
165 | }*/ | 165 | }*/ |
166 | mDtDue = getEvenTime(dtDue); | 166 | mDtDue = getEvenTime(dtDue); |
167 | 167 | ||
168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; | 168 | //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; |
169 | 169 | ||
170 | /*const QPtrList<Alarm>& alarms = alarms(); | 170 | /*const QPtrList<Alarm>& alarms = alarms(); |
171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) | 171 | for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) |
172 | alarm->setAlarmStart(mDtDue);*/ | 172 | alarm->setAlarmStart(mDtDue);*/ |
173 | 173 | ||
174 | updated(); | 174 | updated(); |
175 | } | 175 | } |
176 | 176 | ||
177 | QDateTime Todo::dtDue() const | 177 | QDateTime Todo::dtDue() const |
178 | { | 178 | { |
179 | return mDtDue; | 179 | return mDtDue; |
180 | } | 180 | } |
181 | 181 | ||
182 | QString Todo::dtDueTimeStr() const | 182 | QString Todo::dtDueTimeStr() const |
183 | { | 183 | { |
184 | return KGlobal::locale()->formatTime(mDtDue.time()); | 184 | return KGlobal::locale()->formatTime(mDtDue.time()); |
185 | } | 185 | } |
186 | 186 | ||
187 | QString Todo::dtDueDateStr(bool shortfmt) const | 187 | QString Todo::dtDueDateStr(bool shortfmt) const |
188 | { | 188 | { |
189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); | 189 | return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); |
190 | } | 190 | } |
191 | 191 | ||
192 | QString Todo::dtDueStr(bool shortfmt) const | 192 | QString Todo::dtDueStr(bool shortfmt) const |
193 | { | 193 | { |
194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); | 194 | return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); |
195 | } | 195 | } |
196 | 196 | // retval 0 : no found | |
197 | // 1 : due for date found | ||
198 | // 2 : overdue for date found | ||
199 | int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) | ||
200 | { | ||
201 | int retval = 0; | ||
202 | if ( isCompleted() ) | ||
203 | return 0; | ||
204 | if ( hasDueDate() ) { | ||
205 | if ( dtDue().date() < date ) | ||
206 | return 2; | ||
207 | // we do not return, because we may find an overdue sub todo | ||
208 | if ( dtDue().date() == date ) | ||
209 | retval = 1; | ||
210 | } | ||
211 | if ( checkSubtodos ) { | ||
212 | Incidence *aTodo; | ||
213 | for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { | ||
214 | int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); | ||
215 | if ( ret == 2 ) | ||
216 | return 2; | ||
217 | if ( ret == 1) | ||
218 | retval = 1; | ||
219 | } | ||
220 | } | ||
221 | return retval; | ||
222 | } | ||
223 | int Todo::hasDueSubTodo( bool checkSubtodos ) //= true | ||
224 | { | ||
225 | return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); | ||
226 | } | ||
197 | bool Todo::hasDueDate() const | 227 | bool Todo::hasDueDate() const |
198 | { | 228 | { |
199 | return mHasDueDate; | 229 | return mHasDueDate; |
200 | } | 230 | } |
201 | 231 | ||
202 | void Todo::setHasDueDate(bool f) | 232 | void Todo::setHasDueDate(bool f) |
203 | { | 233 | { |
204 | if (mReadOnly) return; | 234 | if (mReadOnly) return; |
205 | mHasDueDate = f; | 235 | mHasDueDate = f; |
206 | updated(); | 236 | updated(); |
207 | } | 237 | } |
208 | 238 | ||
209 | 239 | ||
210 | #if 0 | 240 | #if 0 |
211 | void Todo::setStatus(const QString &statStr) | 241 | void Todo::setStatus(const QString &statStr) |
212 | { | 242 | { |
213 | if (mReadOnly) return; | 243 | if (mReadOnly) return; |
214 | QString ss(statStr.upper()); | 244 | QString ss(statStr.upper()); |
215 | 245 | ||
216 | if (ss == "X-ACTION") | 246 | if (ss == "X-ACTION") |
217 | mStatus = NEEDS_ACTION; | 247 | mStatus = NEEDS_ACTION; |
218 | else if (ss == "NEEDS ACTION") | 248 | else if (ss == "NEEDS ACTION") |
219 | mStatus = NEEDS_ACTION; | 249 | mStatus = NEEDS_ACTION; |
220 | else if (ss == "ACCEPTED") | 250 | else if (ss == "ACCEPTED") |
221 | mStatus = ACCEPTED; | 251 | mStatus = ACCEPTED; |
222 | else if (ss == "SENT") | 252 | else if (ss == "SENT") |
223 | mStatus = SENT; | 253 | mStatus = SENT; |
224 | else if (ss == "TENTATIVE") | 254 | else if (ss == "TENTATIVE") |
225 | mStatus = TENTATIVE; | 255 | mStatus = TENTATIVE; |
226 | else if (ss == "CONFIRMED") | 256 | else if (ss == "CONFIRMED") |
227 | mStatus = CONFIRMED; | 257 | mStatus = CONFIRMED; |
228 | else if (ss == "DECLINED") | 258 | else if (ss == "DECLINED") |
229 | mStatus = DECLINED; | 259 | mStatus = DECLINED; |
230 | else if (ss == "COMPLETED") | 260 | else if (ss == "COMPLETED") |
231 | mStatus = COMPLETED; | 261 | mStatus = COMPLETED; |
232 | else if (ss == "DELEGATED") | 262 | else if (ss == "DELEGATED") |
233 | mStatus = DELEGATED; | 263 | mStatus = DELEGATED; |
234 | 264 | ||
235 | updated(); | 265 | updated(); |
236 | } | 266 | } |
237 | 267 | ||
238 | void Todo::setStatus(int status) | 268 | void Todo::setStatus(int status) |
239 | { | 269 | { |
240 | if (mReadOnly) return; | 270 | if (mReadOnly) return; |
241 | mStatus = status; | 271 | mStatus = status; |
242 | updated(); | 272 | updated(); |
243 | } | 273 | } |
244 | 274 | ||
245 | int Todo::status() const | 275 | int Todo::status() const |
246 | { | 276 | { |
247 | return mStatus; | 277 | return mStatus; |
248 | } | 278 | } |
249 | 279 | ||
250 | QString Todo::statusStr() const | 280 | QString Todo::statusStr() const |
251 | { | 281 | { |
252 | switch(mStatus) { | 282 | switch(mStatus) { |
253 | case NEEDS_ACTION: | 283 | case NEEDS_ACTION: |
254 | return QString("NEEDS ACTION"); | 284 | return QString("NEEDS ACTION"); |
255 | break; | 285 | break; |
256 | case ACCEPTED: | 286 | case ACCEPTED: |
257 | return QString("ACCEPTED"); | 287 | return QString("ACCEPTED"); |
258 | break; | 288 | break; |
259 | case SENT: | 289 | case SENT: |
260 | return QString("SENT"); | 290 | return QString("SENT"); |