-rw-r--r-- | korganizer/kotodoeditor.cpp | 29 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 40 | ||||
-rw-r--r-- | libkcal/incidence.cpp | 9 | ||||
-rw-r--r-- | libkcal/incidence.h | 5 | ||||
-rw-r--r-- | libkcal/incidencebase.cpp | 1 | ||||
-rw-r--r-- | libkcal/incidencebase.h | 4 | ||||
-rw-r--r-- | libkcal/todo.cpp | 47 | ||||
-rw-r--r-- | libkcal/todo.h | 2 |
8 files changed, 130 insertions, 7 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 069dda8..9232e09 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -320,8 +320,10 @@ void KOTodoEditor::checkRecurrence() | |||
320 | } else { | 320 | } else { |
321 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 321 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
322 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 322 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
323 | } | 323 | } |
324 | if ( to < from ) | ||
325 | to = from; | ||
324 | mRecurrence->setDefaults(from,to,!time); | 326 | mRecurrence->setDefaults(from,to,!time); |
325 | } | 327 | } |
326 | } else { | 328 | } else { |
327 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 329 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
@@ -349,8 +351,35 @@ void KOTodoEditor::writeTodo(Todo *event) | |||
349 | event->setRelatedTo(mRelatedTodo); | 351 | event->setRelatedTo(mRelatedTodo); |
350 | } | 352 | } |
351 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 353 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
352 | mRecurrence->writeEvent(event); | 354 | mRecurrence->writeEvent(event); |
355 | event->setRecurrenceID( event->dtStart().addSecs(-1) ); | ||
356 | event->setRecurDates(); | ||
357 | #if 0 | ||
358 | bool ok; | ||
359 | QDateTime next = event->getNextOccurence( event->dtStart().addSecs(-1), &ok ); | ||
360 | if ( ok ) { | ||
361 | QDateTime from,to; | ||
362 | bool time = mGeneral->mTimeButton->isChecked(); | ||
363 | if ( time ) { | ||
364 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | ||
365 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | ||
366 | } else { | ||
367 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | ||
368 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | ||
369 | } | ||
370 | if ( to < from ) | ||
371 | to = from; | ||
372 | int secs = from.secsTo( to ); | ||
373 | event->setRecurrenceID( next ); | ||
374 | event->setDtStart( next ); | ||
375 | event->setDtDue( next.addSecs( secs ) ); | ||
376 | } | ||
377 | else { | ||
378 | event->setHasRecurrenceID( false ); | ||
379 | event->recurrence()->unsetRecurs(); | ||
380 | } | ||
381 | #endif | ||
353 | } else | 382 | } else |
354 | event->recurrence()->unsetRecurs(); | 383 | event->recurrence()->unsetRecurs(); |
355 | } | 384 | } |
356 | 385 | ||
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 0e847c2..70f00c6 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -190,8 +190,16 @@ void KOTodoViewItem::setMyPixmap() | |||
190 | p. drawPixmap ( 0, pixSize, pPix); | 190 | p. drawPixmap ( 0, pixSize, pPix); |
191 | p.end(); | 191 | p.end(); |
192 | pixSize += size; | 192 | pixSize += size; |
193 | } | 193 | } |
194 | if ( mTodo->doesRecur() ) { | ||
195 | pixi.resize(size, pixSize+size); | ||
196 | pPix.fill( Qt::blue ); | ||
197 | p.begin( &pixi ); | ||
198 | p. drawPixmap ( 0, pixSize, pPix); | ||
199 | p.end(); | ||
200 | pixSize += size; | ||
201 | } | ||
194 | // } | 202 | // } |
195 | if ( pixi.width() > 1 ) { | 203 | if ( pixi.width() > 1 ) { |
196 | setPixmap ( 0,pixi ) ; | 204 | setPixmap ( 0,pixi ) ; |
197 | } else { | 205 | } else { |
@@ -199,9 +207,9 @@ void KOTodoViewItem::setMyPixmap() | |||
199 | } | 207 | } |
200 | } | 208 | } |
201 | void KOTodoViewItem::stateChange(bool state) | 209 | void KOTodoViewItem::stateChange(bool state) |
202 | { | 210 | { |
203 | // qDebug("KOTodoViewItem::stateChange "); | 211 | // qDebug("KOTodoViewItem::stateChange %d ", state); |
204 | // do not change setting on startup | 212 | // do not change setting on startup |
205 | if ( m_init ) return; | 213 | if ( m_init ) return; |
206 | if (isOn()!=state) { | 214 | if (isOn()!=state) { |
207 | setOn(state); | 215 | setOn(state); |
@@ -214,9 +222,20 @@ void KOTodoViewItem::stateChange(bool state) | |||
214 | } | 222 | } |
215 | QString keyd = "=="; | 223 | QString keyd = "=="; |
216 | QString keyt = "=="; | 224 | QString keyt = "=="; |
217 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); | 225 | //qDebug("KOTodoViewItem::stateChange %s ", text(0).latin1()); |
226 | if ( mTodo->doesRecur() ){ | ||
227 | QDateTime start = mTodo->dtStart(); | ||
218 | mTodo->setCompleted(state); | 228 | mTodo->setCompleted(state); |
229 | if ( start != mTodo->dtStart() ) { | ||
230 | if ( state && !mTodo->isCompleted() ) { | ||
231 | setOn( false ); | ||
232 | state = false; | ||
233 | } | ||
234 | } | ||
235 | } else | ||
236 | mTodo->setCompleted(state); | ||
237 | |||
219 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); | 238 | if (state) mTodo->setCompleted(QDateTime::currentDateTime()); |
220 | 239 | ||
221 | if (mTodo->hasDueDate()) { | 240 | if (mTodo->hasDueDate()) { |
222 | setText(3, mTodo->dtDueDateStr()); | 241 | setText(3, mTodo->dtDueDateStr()); |
@@ -232,8 +251,27 @@ void KOTodoViewItem::stateChange(bool state) | |||
232 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); | 251 | keyt.sprintf("%02d%02d",t.hour(),t.minute()); |
233 | setSortKey(4,keyt); | 252 | setSortKey(4,keyt); |
234 | } | 253 | } |
235 | } | 254 | } |
255 | if (mTodo->hasStartDate()) { | ||
256 | QString skeyt = "=="; | ||
257 | QString skeyd = "=="; | ||
258 | setText(5, mTodo->dtStartDateStr()); | ||
259 | QDate d = mTodo->dtStart().date(); | ||
260 | skeyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | ||
261 | |||
262 | if (mTodo->doesFloat()) { | ||
263 | setText(6,""); | ||
264 | } | ||
265 | else { | ||
266 | setText(6,mTodo->dtStartTimeStr()); | ||
267 | QTime t = mTodo->dtStart().time(); | ||
268 | skeyt.sprintf("%02d%02d",t.hour(),t.minute()); | ||
269 | |||
270 | } | ||
271 | setSortKey(5,skeyd); | ||
272 | setSortKey(6,skeyt); | ||
273 | } | ||
236 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); | 274 | if (mTodo->isCompleted()) setSortKey(1,QString::number(9)+keyd+keyt); |
237 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); | 275 | else setSortKey(1,QString::number(mTodo->priority())+keyd+keyt); |
238 | 276 | ||
239 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); | 277 | setText(2,i18n("%1 %").arg(QString::number(mTodo->percentComplete()))); |
diff --git a/libkcal/incidence.cpp b/libkcal/incidence.cpp index dbc159c..0684af2 100644 --- a/libkcal/incidence.cpp +++ b/libkcal/incidence.cpp | |||
@@ -646,4 +646,13 @@ QDateTime Incidence::getNextOccurence( const QDateTime& dt, bool* ok ) const | |||
646 | if ( incidenceStart > dt ) | 646 | if ( incidenceStart > dt ) |
647 | *ok = true; | 647 | *ok = true; |
648 | return incidenceStart; | 648 | return incidenceStart; |
649 | } | 649 | } |
650 | QDateTime Incidence::dtStart() const | ||
651 | { | ||
652 | if ( doesRecur() ) { | ||
653 | if ( type() == "Todo" ) { | ||
654 | ((Todo*)this)->checkSetCompletedFalse(); | ||
655 | } | ||
656 | } | ||
657 | return mDtStart; | ||
658 | } | ||
diff --git a/libkcal/incidence.h b/libkcal/incidence.h index 38d2aaa..0ae9656 100644 --- a/libkcal/incidence.h +++ b/libkcal/incidence.h | |||
@@ -268,20 +268,21 @@ class Incidence : public IncidenceBase | |||
268 | void setHasRecurrenceID( bool b ); | 268 | void setHasRecurrenceID( bool b ); |
269 | 269 | ||
270 | void setRecurrenceID(QDateTime); | 270 | void setRecurrenceID(QDateTime); |
271 | QDateTime recurrenceID () const; | 271 | QDateTime recurrenceID () const; |
272 | QDateTime dtStart() const; | ||
272 | 273 | ||
273 | 274 | ||
274 | protected: | 275 | protected: |
275 | QPtrList<Alarm> mAlarms; | 276 | QPtrList<Alarm> mAlarms; |
276 | QPtrList<Incidence> mRelations; | 277 | QPtrList<Incidence> mRelations; |
278 | QDateTime mRecurrenceID; | ||
279 | bool mHasRecurrenceID; | ||
277 | private: | 280 | private: |
278 | int mRevision; | 281 | int mRevision; |
279 | bool mCancelled; | 282 | bool mCancelled; |
280 | 283 | ||
281 | // base components of jounal, event and todo | 284 | // base components of jounal, event and todo |
282 | QDateTime mRecurrenceID; | ||
283 | bool mHasRecurrenceID; | ||
284 | QDateTime mCreated; | 285 | QDateTime mCreated; |
285 | QString mDescription; | 286 | QString mDescription; |
286 | QString mSummary; | 287 | QString mSummary; |
287 | QStringList mCategories; | 288 | QStringList mCategories; |
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp index 7525a4a..51f2e9d 100644 --- a/libkcal/incidencebase.cpp +++ b/libkcal/incidencebase.cpp | |||
@@ -178,8 +178,9 @@ void IncidenceBase::setDtStart(const QDateTime &dtStart) | |||
178 | mDtStart = getEvenTime(dtStart); | 178 | mDtStart = getEvenTime(dtStart); |
179 | updated(); | 179 | updated(); |
180 | } | 180 | } |
181 | 181 | ||
182 | |||
182 | QDateTime IncidenceBase::dtStart() const | 183 | QDateTime IncidenceBase::dtStart() const |
183 | { | 184 | { |
184 | return mDtStart; | 185 | return mDtStart; |
185 | } | 186 | } |
diff --git a/libkcal/incidencebase.h b/libkcal/incidencebase.h index f9a6558..8624786 100644 --- a/libkcal/incidencebase.h +++ b/libkcal/incidencebase.h | |||
@@ -73,9 +73,9 @@ class IncidenceBase : public CustomProperties | |||
73 | 73 | ||
74 | /** for setting the event's starting date/time with a QDateTime. */ | 74 | /** for setting the event's starting date/time with a QDateTime. */ |
75 | virtual void setDtStart(const QDateTime &dtStart); | 75 | virtual void setDtStart(const QDateTime &dtStart); |
76 | /** returns an event's starting date/time as a QDateTime. */ | 76 | /** returns an event's starting date/time as a QDateTime. */ |
77 | QDateTime dtStart() const; | 77 | virtual QDateTime dtStart() const; |
78 | /** returns an event's starting time as a string formatted according to the | 78 | /** returns an event's starting time as a string formatted according to the |
79 | users locale settings */ | 79 | users locale settings */ |
80 | QString dtStartTimeStr() const; | 80 | QString dtStartTimeStr() const; |
81 | /** returns an event's starting date as a string formatted according to the | 81 | /** returns an event's starting date as a string formatted according to the |
@@ -140,14 +140,14 @@ class IncidenceBase : public CustomProperties | |||
140 | void unRegisterObserver( Observer * ); | 140 | void unRegisterObserver( Observer * ); |
141 | void updated(); | 141 | void updated(); |
142 | 142 | ||
143 | protected: | 143 | protected: |
144 | QDateTime mDtStart; | ||
144 | bool mReadOnly; | 145 | bool mReadOnly; |
145 | QDateTime getEvenTime( QDateTime ); | 146 | QDateTime getEvenTime( QDateTime ); |
146 | 147 | ||
147 | private: | 148 | private: |
148 | // base components | 149 | // base components |
149 | QDateTime mDtStart; | ||
150 | QString mOrganizer; | 150 | QString mOrganizer; |
151 | QString mUid; | 151 | QString mUid; |
152 | QDateTime mLastModified; | 152 | QDateTime mLastModified; |
153 | QPtrList<Attendee> mAttendees; | 153 | QPtrList<Attendee> mAttendees; |
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp index 9c04a7e..1f54c2f 100644 --- a/libkcal/todo.cpp +++ b/libkcal/todo.cpp | |||
@@ -310,14 +310,20 @@ QString Todo::statusStr() const | |||
310 | #endif | 310 | #endif |
311 | 311 | ||
312 | bool Todo::isCompleted() const | 312 | bool Todo::isCompleted() const |
313 | { | 313 | { |
314 | if (mPercentComplete == 100) return true; | 314 | if (mPercentComplete == 100) { |
315 | return true; | ||
316 | } | ||
315 | else return false; | 317 | else return false; |
316 | } | 318 | } |
317 | 319 | ||
318 | void Todo::setCompleted(bool completed) | 320 | void Todo::setCompleted(bool completed) |
319 | { | 321 | { |
322 | if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { | ||
323 | if ( !setRecurDates() ) | ||
324 | completed = false; | ||
325 | } | ||
320 | if (completed) mPercentComplete = 100; | 326 | if (completed) mPercentComplete = 100; |
321 | else { | 327 | else { |
322 | mPercentComplete = 0; | 328 | mPercentComplete = 0; |
323 | mHasCompletedDate = false; | 329 | mHasCompletedDate = false; |
@@ -356,11 +362,35 @@ bool Todo::hasCompletedDate() const | |||
356 | int Todo::percentComplete() const | 362 | int Todo::percentComplete() const |
357 | { | 363 | { |
358 | return mPercentComplete; | 364 | return mPercentComplete; |
359 | } | 365 | } |
360 | 366 | bool Todo::setRecurDates() | |
367 | { | ||
368 | if ( !mHasRecurrenceID ) | ||
369 | return true; | ||
370 | int secs = mDtStart.secsTo( dtDue() ); | ||
371 | bool ok; | ||
372 | qDebug("--------------------setRecurDates() "); | ||
373 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
374 | QDateTime next = getNextOccurence( mRecurrenceID, &ok ); | ||
375 | if ( ok ) { | ||
376 | mRecurrenceID = next; | ||
377 | mDtStart = next; | ||
378 | setDtDue( next.addSecs( secs ) ); | ||
379 | if ( QDateTime::currentDateTime() > next) | ||
380 | return false; | ||
381 | } else { | ||
382 | setHasRecurrenceID( false ); | ||
383 | recurrence()->unsetRecurs(); | ||
384 | } | ||
385 | return true; | ||
386 | } | ||
361 | void Todo::setPercentComplete(int v) | 387 | void Todo::setPercentComplete(int v) |
362 | { | 388 | { |
389 | if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { | ||
390 | if ( !setRecurDates() ) | ||
391 | v = 0; | ||
392 | } | ||
363 | mPercentComplete = v; | 393 | mPercentComplete = v; |
364 | if ( v != 100 ) | 394 | if ( v != 100 ) |
365 | mHasCompletedDate = false; | 395 | mHasCompletedDate = false; |
366 | updated(); | 396 | updated(); |
@@ -411,4 +441,17 @@ QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const | |||
411 | return QDateTime (); | 441 | return QDateTime (); |
412 | 442 | ||
413 | } | 443 | } |
414 | 444 | ||
445 | void Todo::checkSetCompletedFalse() | ||
446 | { | ||
447 | if ( !hasRecurrenceID() ) { | ||
448 | qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); | ||
449 | } | ||
450 | // qDebug("Todo::checkSetCompletedFalse()"); | ||
451 | //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
452 | if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { | ||
453 | qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); | ||
454 | setCompleted( false ); | ||
455 | qDebug("Todo::checkSetCompletedFalse++++++++++++++++++++++++++++ "); | ||
456 | } | ||
457 | } | ||
diff --git a/libkcal/todo.h b/libkcal/todo.h index 137b252..a22d4b7 100644 --- a/libkcal/todo.h +++ b/libkcal/todo.h | |||
@@ -111,8 +111,10 @@ class Todo : public Incidence | |||
111 | 111 | ||
112 | /** Return true, if todo has a date associated with completion */ | 112 | /** Return true, if todo has a date associated with completion */ |
113 | bool hasCompletedDate() const; | 113 | bool hasCompletedDate() const; |
114 | bool contains ( Todo*); | 114 | bool contains ( Todo*); |
115 | void checkSetCompletedFalse(); | ||
116 | bool setRecurDates(); | ||
115 | 117 | ||
116 | private: | 118 | private: |
117 | bool accept(Visitor &v) { return v.visit(this); } | 119 | bool accept(Visitor &v) { return v.visit(this); } |
118 | 120 | ||