-rw-r--r-- | korganizer/kotodoeditor.cpp | 29 | ||||
-rw-r--r-- | korganizer/kotodoviewitem.cpp | 42 |
2 files changed, 69 insertions, 2 deletions
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 069dda8..9232e09 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -292,93 +292,122 @@ void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | |||
292 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 292 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
293 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 293 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
294 | if ( mRelatedTodo->priority() < 3 ) | 294 | if ( mRelatedTodo->priority() < 3 ) |
295 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 295 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
296 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 296 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
297 | int len = mRelatedTodo->summary().length(); | 297 | int len = mRelatedTodo->summary().length(); |
298 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 298 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
299 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 299 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
300 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 300 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
301 | 301 | ||
302 | } else | 302 | } else |
303 | mGeneral->setFocusOn( 2 ); | 303 | mGeneral->setFocusOn( 2 ); |
304 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 304 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
305 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 305 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); |
306 | } | 306 | } |
307 | void KOTodoEditor::checkRecurrence() | 307 | void KOTodoEditor::checkRecurrence() |
308 | { | 308 | { |
309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
311 | 311 | ||
312 | if ( mTodo ) | 312 | if ( mTodo ) |
313 | mRecurrence->readEvent( mTodo ); | 313 | mRecurrence->readEvent( mTodo ); |
314 | else { | 314 | else { |
315 | bool time = mGeneral->mTimeButton->isChecked(); | 315 | bool time = mGeneral->mTimeButton->isChecked(); |
316 | QDateTime from,to; | 316 | QDateTime from,to; |
317 | if ( time ) { | 317 | if ( time ) { |
318 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 318 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
319 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 319 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
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 ); |
328 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 330 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); |
329 | } | 331 | } |
330 | } | 332 | } |
331 | void KOTodoEditor::readTodo(Todo *todo) | 333 | void KOTodoEditor::readTodo(Todo *todo) |
332 | { | 334 | { |
333 | mGeneral->readTodo(todo); | 335 | mGeneral->readTodo(todo); |
334 | mDetails->readEvent(todo); | 336 | mDetails->readEvent(todo); |
335 | mRelatedTodo = 0;//todo->relatedTo(); | 337 | mRelatedTodo = 0;//todo->relatedTo(); |
336 | // categories | 338 | // categories |
337 | // mCategoryDialog->setSelected(todo->categories()); | 339 | // mCategoryDialog->setSelected(todo->categories()); |
338 | 340 | ||
339 | // We should handle read-only events here. | 341 | // We should handle read-only events here. |
340 | } | 342 | } |
341 | 343 | ||
342 | void KOTodoEditor::writeTodo(Todo *event) | 344 | void KOTodoEditor::writeTodo(Todo *event) |
343 | { | 345 | { |
344 | mGeneral->writeTodo(event); | 346 | mGeneral->writeTodo(event); |
345 | mDetails->writeEvent(event); | 347 | mDetails->writeEvent(event); |
346 | 348 | ||
347 | // set related event, i.e. parent to-do in this case. | 349 | // set related event, i.e. parent to-do in this case. |
348 | if (mRelatedTodo) { | 350 | if (mRelatedTodo) { |
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 | ||
357 | bool KOTodoEditor::validateInput() | 386 | bool KOTodoEditor::validateInput() |
358 | { | 387 | { |
359 | if (!mGeneral->validateInput()) return false; | 388 | if (!mGeneral->validateInput()) return false; |
360 | if (!mDetails->validateInput()) return false; | 389 | if (!mDetails->validateInput()) return false; |
361 | return true; | 390 | return true; |
362 | } | 391 | } |
363 | 392 | ||
364 | int KOTodoEditor::msgItemDelete() | 393 | int KOTodoEditor::msgItemDelete() |
365 | { | 394 | { |
366 | return KMessageBox::warningContinueCancel(this, | 395 | return KMessageBox::warningContinueCancel(this, |
367 | i18n("This item will be permanently deleted."), | 396 | i18n("This item will be permanently deleted."), |
368 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 397 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
369 | } | 398 | } |
370 | 399 | ||
371 | void KOTodoEditor::modified (int modification) | 400 | void KOTodoEditor::modified (int modification) |
372 | { | 401 | { |
373 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 402 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
374 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 403 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
375 | // mCategoryDialog->setSelected (mTodo->categories ()); | 404 | // mCategoryDialog->setSelected (mTodo->categories ()); |
376 | mGeneral->modified (mTodo, modification); | 405 | mGeneral->modified (mTodo, modification); |
377 | 406 | ||
378 | } | 407 | } |
379 | 408 | ||
380 | void KOTodoEditor::slotLoadTemplate() | 409 | void KOTodoEditor::slotLoadTemplate() |
381 | { | 410 | { |
382 | 411 | ||
383 | QString fileName =locateLocal( "templates", "todos" ); | 412 | QString fileName =locateLocal( "templates", "todos" ); |
384 | QDir t_dir; | 413 | QDir t_dir; |
diff --git a/korganizer/kotodoviewitem.cpp b/korganizer/kotodoviewitem.cpp index 0e847c2..70f00c6 100644 --- a/korganizer/kotodoviewitem.cpp +++ b/korganizer/kotodoviewitem.cpp | |||
@@ -161,107 +161,145 @@ void KOTodoViewItem::construct() | |||
161 | m_known = false; | 161 | m_known = false; |
162 | m_init = false; | 162 | m_init = false; |
163 | 163 | ||
164 | setMyPixmap(); | 164 | setMyPixmap(); |
165 | 165 | ||
166 | } | 166 | } |
167 | void KOTodoViewItem::setMyPixmap() | 167 | void KOTodoViewItem::setMyPixmap() |
168 | { | 168 | { |
169 | int size = 5; | 169 | int size = 5; |
170 | QPixmap pixi = QPixmap( 1, 1 ); | 170 | QPixmap pixi = QPixmap( 1, 1 ); |
171 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { | 171 | // if ( !mTodo->isCompleted() && mTodo->hasDueDate() && mTodo->dtDue() < QDateTime::currentDateTime() ) { |
172 | // pixi = SmallIcon("redcross16"); | 172 | // pixi = SmallIcon("redcross16"); |
173 | // } else { | 173 | // } else { |
174 | QPainter p; | 174 | QPainter p; |
175 | 175 | ||
176 | int pixSize = 0; | 176 | int pixSize = 0; |
177 | QPixmap pPix = QPixmap( size, size ); | 177 | QPixmap pPix = QPixmap( size, size ); |
178 | if ( mTodo->description().length() > 0 ) { | 178 | if ( mTodo->description().length() > 0 ) { |
179 | pixi.resize(size, pixSize+size); | 179 | pixi.resize(size, pixSize+size); |
180 | pPix.fill( Qt::darkGreen ); | 180 | pPix.fill( Qt::darkGreen ); |
181 | p.begin( &pixi ); | 181 | p.begin( &pixi ); |
182 | p. drawPixmap ( 0, pixSize, pPix); | 182 | p. drawPixmap ( 0, pixSize, pPix); |
183 | p.end(); | 183 | p.end(); |
184 | pixSize += size; | 184 | pixSize += size; |
185 | } | 185 | } |
186 | if ( mTodo->isAlarmEnabled() ) { | 186 | if ( mTodo->isAlarmEnabled() ) { |
187 | pixi.resize(size, pixSize+size); | 187 | pixi.resize(size, pixSize+size); |
188 | pPix.fill( Qt::red ); | 188 | pPix.fill( Qt::red ); |
189 | p.begin( &pixi ); | 189 | p.begin( &pixi ); |
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 | } | ||
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; | ||
193 | } | 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 { |
198 | setPixmap ( 0,QPixmap() ) ; | 206 | setPixmap ( 0,QPixmap() ) ; |
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); |
208 | //qDebug("SETON "); | 216 | //qDebug("SETON "); |
209 | return; | 217 | return; |
210 | } | 218 | } |
211 | if ( mTodo->isCompleted() == state ) { | 219 | if ( mTodo->isCompleted() == state ) { |
212 | //qDebug("STATECHANGE:nothing to do "); | 220 | //qDebug("STATECHANGE:nothing to do "); |
213 | return; | 221 | return; |
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()); |
218 | mTodo->setCompleted(state); | 226 | if ( mTodo->doesRecur() ){ |
227 | QDateTime start = mTodo->dtStart(); | ||
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()); |
223 | QDate d = mTodo->dtDue().date(); | 242 | QDate d = mTodo->dtDue().date(); |
224 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); | 243 | keyd.sprintf("%04d%02d%02d",d.year(),d.month(),d.day()); |
225 | setSortKey(3,keyd); | 244 | setSortKey(3,keyd); |
226 | if (mTodo->doesFloat()) { | 245 | if (mTodo->doesFloat()) { |
227 | setText(4,""); | 246 | setText(4,""); |
228 | } | 247 | } |
229 | else { | 248 | else { |
230 | setText(4,mTodo->dtDueTimeStr()); | 249 | setText(4,mTodo->dtDueTimeStr()); |
231 | QTime t = mTodo->dtDue().time(); | 250 | QTime t = mTodo->dtDue().time(); |
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()))); |
240 | if (mTodo->percentComplete()<100) { | 278 | if (mTodo->percentComplete()<100) { |
241 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 279 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
242 | else setSortKey(2,QString::number(mTodo->percentComplete())); | 280 | else setSortKey(2,QString::number(mTodo->percentComplete())); |
243 | } | 281 | } |
244 | else { | 282 | else { |
245 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); | 283 | if (mTodo->isCompleted()) setSortKey(2,QString::number(999)); |
246 | else setSortKey(2,QString::number(99)); | 284 | else setSortKey(2,QString::number(99)); |
247 | } | 285 | } |
248 | if ( state ) { | 286 | if ( state ) { |
249 | QListViewItem * myChild = firstChild(); | 287 | QListViewItem * myChild = firstChild(); |
250 | KOTodoViewItem *item; | 288 | KOTodoViewItem *item; |
251 | while( myChild ) { | 289 | while( myChild ) { |
252 | //qDebug("stateCH "); | 290 | //qDebug("stateCH "); |
253 | item = static_cast<KOTodoViewItem*>(myChild); | 291 | item = static_cast<KOTodoViewItem*>(myChild); |
254 | item->stateChange(state); | 292 | item->stateChange(state); |
255 | myChild = myChild->nextSibling(); | 293 | myChild = myChild->nextSibling(); |
256 | } | 294 | } |
257 | } else { | 295 | } else { |
258 | QListViewItem * myChild = parent(); | 296 | QListViewItem * myChild = parent(); |
259 | if ( myChild ) | 297 | if ( myChild ) |
260 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); | 298 | (static_cast<KOTodoViewItem*>(myChild))->stateChange(state); |
261 | } | 299 | } |
262 | mTodoView->modified(true); | 300 | mTodoView->modified(true); |
263 | setMyPixmap(); | 301 | setMyPixmap(); |
264 | mTodoView->setTodoModified( mTodo ); | 302 | mTodoView->setTodoModified( mTodo ); |
265 | } | 303 | } |
266 | 304 | ||
267 | bool KOTodoViewItem::isAlternate() | 305 | bool KOTodoViewItem::isAlternate() |