166 // --------------------------------------------------------------------------- |
159 // --------------------------------------------------------------------------- |
167 // |
160 // |
168 inline CESMRTodoTimeValidator::CESMRTodoTimeValidator() |
161 inline CESMRTodoTimeValidator::CESMRTodoTimeValidator() |
169 : iCurrentDueDate( Time::NullTTime() ), |
162 : iCurrentDueDate( Time::NullTTime() ), |
170 iCurrentAlarmTime( Time::NullTTime() ), |
163 iCurrentAlarmTime( Time::NullTTime() ), |
171 iAlarmOnOff( EFalse ) |
164 iAlarmOnOff( EFalse ), |
|
165 iInitialAlarmTime( Time::NullTTime() ), |
|
166 iInitialAlarmOnOff( EFalse ), |
|
167 iInitialDueDate( Time::NullTTime() ) |
|
168 |
172 { |
169 { |
173 FUNC_LOG; |
170 FUNC_LOG; |
174 // Do nothing |
171 // Do nothing |
175 } |
172 } |
176 |
173 |
256 CCalEntry& entry( aEntry.Entry() ); |
263 CCalEntry& entry( aEntry.Entry() ); |
257 |
264 |
258 TCalTime dueDate = entry.EndTimeL(); |
265 TCalTime dueDate = entry.EndTimeL(); |
259 iCurrentDueDate = dueDate.TimeLocalL(); |
266 iCurrentDueDate = dueDate.TimeLocalL(); |
260 SetDateToEditor( *iDueDate, iCurrentDueDate ); |
267 SetDateToEditor( *iDueDate, iCurrentDueDate ); |
|
268 |
|
269 iInitialDueDate = iDueDate->Date(); |
261 |
270 |
262 TDateTime dueDt = iCurrentDueDate.DateTime(); |
271 TDateTime dueDt = iCurrentDueDate.DateTime(); |
263 |
272 |
264 CCalAlarm* alarm = entry.AlarmL(); |
273 CCalAlarm* alarm = entry.AlarmL(); |
265 CleanupStack::PushL( alarm ); |
274 CleanupStack::PushL( alarm ); |
266 |
275 |
267 if ( alarm ) |
276 if ( alarm ) |
268 { |
277 { |
269 iCurrentAlarmTime = iCurrentDueDate - alarm->TimeOffset(); |
278 iCurrentAlarmTime = iCurrentDueDate - alarm->TimeOffset(); |
270 iAlarmOnOff = ETrue; |
279 iAlarmOnOff = ETrue; |
|
280 iInitialAlarmOnOff = iAlarmOnOff; |
271 |
281 |
272 SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime ); |
282 SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime ); |
273 SetDateToEditor( *iAlarmDate, iCurrentAlarmTime ); |
283 SetDateToEditor( *iAlarmDate, iCurrentAlarmTime ); |
|
284 |
|
285 iInitialAlarmTime = iAlarmTime->Time(); |
|
286 iInitialAlarmDate = iAlarmDate->Date(); |
274 } |
287 } |
275 |
288 |
276 CleanupStack::PopAndDestroy( alarm ); |
289 CleanupStack::PopAndDestroy( alarm ); |
277 alarm = NULL; |
290 alarm = NULL; |
278 |
291 |
291 if ( MESMRCalEntry::EESMRCalEntryTodo == aEntry.Type() ) |
304 if ( MESMRCalEntry::EESMRCalEntryTodo == aEntry.Type() ) |
292 { |
305 { |
293 PreValidateEditorContent(); |
306 PreValidateEditorContent(); |
294 CCalEntry& entry( aEntry.Entry() ); |
307 CCalEntry& entry( aEntry.Entry() ); |
295 |
308 |
296 TTime toEditorDueDate = DueDateTimeL(); |
309 // If entry has been modified, we will write new values to entry. |
297 TCalTime todoDueDate; |
310 // Otherwise entry will not be modified and thus saved |
298 |
311 // (ex. new entry and press only Done ) |
299 // The default mode for To-do is EFloating, |
312 if( IsModifiedL( aEntry ) ) |
300 // But some 3rd party application might have saved a different type |
|
301 // for one reason or another. In that case we are using |
|
302 // the existing value. |
|
303 if ( aEntry.IsStoredL() ) |
|
304 { |
313 { |
305 TCalTime::TTimeMode timeMode = |
314 TTime toEditorDueDate = DueDateTimeL(); |
306 aEntry.Entry().StartTimeL().TimeMode(); |
315 TCalTime todoDueDate; |
307 |
316 |
308 switch ( timeMode ) |
317 // The default mode for To-do is EFloating, |
|
318 // But some 3rd party application might have saved a different type |
|
319 // for one reason or another. In that case we are using |
|
320 // the existing value. |
|
321 if ( aEntry.IsStoredL() ) |
309 { |
322 { |
310 case TCalTime::EFixedUtc: |
323 TCalTime::TTimeMode timeMode = |
311 { |
324 aEntry.Entry().StartTimeL().TimeMode(); |
312 todoDueDate.SetTimeUtcL( toEditorDueDate ); |
325 |
313 break; |
326 switch ( timeMode ) |
314 } |
327 { |
315 case TCalTime::EFixedTimeZone: |
328 case TCalTime::EFixedUtc: |
316 { |
329 { |
317 todoDueDate.SetTimeLocalL( toEditorDueDate ); |
330 todoDueDate.SetTimeUtcL( toEditorDueDate ); |
318 break; |
331 break; |
319 } |
332 } |
320 case TCalTime::EFloating: // Fall through |
333 case TCalTime::EFixedTimeZone: |
321 default: |
334 { |
322 { |
335 todoDueDate.SetTimeLocalL( toEditorDueDate ); |
323 todoDueDate.SetTimeLocalFloatingL( toEditorDueDate ); |
336 break; |
324 break; |
337 } |
325 } |
338 case TCalTime::EFloating: // Fall through |
|
339 default: |
|
340 { |
|
341 todoDueDate.SetTimeLocalFloatingL( toEditorDueDate ); |
|
342 break; |
|
343 } |
|
344 } |
|
345 } |
|
346 else |
|
347 { |
|
348 todoDueDate.SetTimeLocalFloatingL( toEditorDueDate ); |
|
349 } |
|
350 |
|
351 entry.SetStartAndEndTimeL( todoDueDate, todoDueDate ); |
|
352 |
|
353 if ( iAlarmOnOff ) |
|
354 { |
|
355 TTimeIntervalMinutes diff; |
|
356 |
|
357 TTime alarm = AlarmDateTimeL(); |
|
358 toEditorDueDate.MinutesFrom( alarm, diff ); |
|
359 |
|
360 CCalAlarm* alarmObject = entry.AlarmL(); |
|
361 if ( !alarmObject ) |
|
362 { |
|
363 alarmObject = CCalAlarm::NewL(); |
|
364 } |
|
365 CleanupStack::PushL( alarmObject ); |
|
366 alarmObject->SetTimeOffset( diff ); |
|
367 entry.SetAlarmL( alarmObject ); |
|
368 CleanupStack::PopAndDestroy( alarmObject ); |
|
369 alarmObject = NULL; |
|
370 } |
|
371 else |
|
372 { |
|
373 entry.SetAlarmL( NULL ); |
326 } |
374 } |
327 } |
375 } |
328 else |
|
329 { |
|
330 todoDueDate.SetTimeLocalFloatingL( toEditorDueDate ); |
|
331 } |
|
332 |
|
333 entry.SetStartAndEndTimeL( todoDueDate, todoDueDate ); |
|
334 |
|
335 if ( iAlarmOnOff ) |
|
336 { |
|
337 TTimeIntervalMinutes diff; |
|
338 |
|
339 TTime alarm = AlarmDateTimeL(); |
|
340 toEditorDueDate.MinutesFrom( alarm, diff ); |
|
341 |
|
342 CCalAlarm* alarmObject = entry.AlarmL(); |
|
343 if ( !alarmObject ) |
|
344 { |
|
345 alarmObject = CCalAlarm::NewL(); |
|
346 } |
|
347 CleanupStack::PushL( alarmObject ); |
|
348 alarmObject->SetTimeOffset( diff ); |
|
349 entry.SetAlarmL( alarmObject ); |
|
350 CleanupStack::PopAndDestroy( alarmObject ); |
|
351 alarmObject = NULL; |
|
352 } |
|
353 else |
|
354 { |
|
355 entry.SetAlarmL( NULL ); |
|
356 } |
|
357 } |
376 } |
358 } |
377 } |
359 |
378 |
360 // --------------------------------------------------------------------------- |
379 // --------------------------------------------------------------------------- |
361 // CESMRTodoTimeValidator::SetStartTimeFieldL |
380 // CESMRTodoTimeValidator::SetStartTimeFieldL |
397 void CESMRTodoTimeValidator::SetEndDateFieldL( |
416 void CESMRTodoTimeValidator::SetEndDateFieldL( |
398 CEikDateEditor& aEndDate ) |
417 CEikDateEditor& aEndDate ) |
399 { |
418 { |
400 FUNC_LOG; |
419 FUNC_LOG; |
401 iDueDate = &aEndDate; |
420 iDueDate = &aEndDate; |
|
421 |
|
422 if ( Time::NullTTime() != iCurrentDueDate ) |
|
423 { |
|
424 SetDateToEditor( *iDueDate, iCurrentDueDate ); |
|
425 } |
402 } |
426 } |
403 |
427 |
404 // --------------------------------------------------------------------------- |
428 // --------------------------------------------------------------------------- |
405 // CESMRTodoTimeValidator::SetAlarmTimeFieldL |
429 // CESMRTodoTimeValidator::SetAlarmTimeFieldL |
406 // --------------------------------------------------------------------------- |
430 // --------------------------------------------------------------------------- |
408 void CESMRTodoTimeValidator::SetAlarmTimeFieldL( |
432 void CESMRTodoTimeValidator::SetAlarmTimeFieldL( |
409 CEikTimeEditor& aAlarmTime ) |
433 CEikTimeEditor& aAlarmTime ) |
410 { |
434 { |
411 FUNC_LOG; |
435 FUNC_LOG; |
412 iAlarmTime = &aAlarmTime; |
436 iAlarmTime = &aAlarmTime; |
|
437 |
|
438 if ( iAlarmOnOff ) |
|
439 { |
|
440 SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime ); |
|
441 } |
413 } |
442 } |
414 |
443 |
415 // --------------------------------------------------------------------------- |
444 // --------------------------------------------------------------------------- |
416 // CESMRTodoTimeValidator::SetAlarmDateFieldL |
445 // CESMRTodoTimeValidator::SetAlarmDateFieldL |
417 // --------------------------------------------------------------------------- |
446 // --------------------------------------------------------------------------- |
419 void CESMRTodoTimeValidator::SetAlarmDateFieldL( |
448 void CESMRTodoTimeValidator::SetAlarmDateFieldL( |
420 CEikDateEditor& aAlarmDate ) |
449 CEikDateEditor& aAlarmDate ) |
421 { |
450 { |
422 FUNC_LOG; |
451 FUNC_LOG; |
423 iAlarmDate = &aAlarmDate; |
452 iAlarmDate = &aAlarmDate; |
|
453 |
|
454 if ( iAlarmOnOff ) |
|
455 { |
|
456 SetDateToEditor( *iAlarmDate, iCurrentAlarmTime ); |
|
457 } |
424 } |
458 } |
425 |
459 |
426 // --------------------------------------------------------------------------- |
460 // --------------------------------------------------------------------------- |
427 // CESMRTodoTimeValidator::SetRecurrenceUntilDateFieldL |
461 // CESMRTodoTimeValidator::SetRecurrenceUntilDateFieldL |
428 // --------------------------------------------------------------------------- |
462 // --------------------------------------------------------------------------- |
429 // |
463 // |
430 void CESMRTodoTimeValidator::SetRecurrenceUntilDateFieldL( |
464 void CESMRTodoTimeValidator::SetRecurrenceUntilDateFieldL( |
431 CEikDateEditor& /*aRecurrenceUntil*/ ) |
465 CEikDateEditor& /*aRecurrenceUntil*/ ) |
|
466 { |
|
467 FUNC_LOG; |
|
468 // No implementation for to-do |
|
469 } |
|
470 |
|
471 // --------------------------------------------------------------------------- |
|
472 // CESMRTodoTimeValidator::SetAbsoluteAlarmOnOffFieldL |
|
473 // --------------------------------------------------------------------------- |
|
474 // |
|
475 void CESMRTodoTimeValidator::SetAbsoluteAlarmOnOffFieldL( |
|
476 MMRAbsoluteAlarmController& /*aAbsoluteAlarmController*/ ) |
432 { |
477 { |
433 FUNC_LOG; |
478 FUNC_LOG; |
434 // No implementation for to-do |
479 // No implementation for to-do |
435 } |
480 } |
436 |
481 |
787 |
832 |
788 iCurrentAlarmTime = alarm; |
833 iCurrentAlarmTime = alarm; |
789 } |
834 } |
790 } |
835 } |
791 |
836 |
|
837 // --------------------------------------------------------------------------- |
|
838 // CESMRTodoTimeValidator::IsModifiedL |
|
839 // --------------------------------------------------------------------------- |
|
840 // |
|
841 TBool CESMRTodoTimeValidator::IsModifiedL( MESMRCalEntry& aEntry ) |
|
842 { |
|
843 // Checks if any of the editor fields have changed from the original / |
|
844 // initial values |
|
845 TBool isEdited( EFalse ); |
|
846 |
|
847 TBool isSame = aEntry.Entry().CompareL( aEntry.OriginalEntry() ); |
|
848 |
|
849 if( !isSame || |
|
850 iInitialAlarmOnOff != iAlarmOnOff || |
|
851 iDueDate->Date() != iInitialDueDate ) |
|
852 { |
|
853 isEdited = ETrue; |
|
854 } |
|
855 |
|
856 // If alarm is on, we will check alarm time and date also for changes |
|
857 if( iAlarmOnOff ) |
|
858 { |
|
859 if( iAlarmTime->Time() != iInitialAlarmTime || |
|
860 iAlarmDate->Date() != iInitialAlarmDate ) |
|
861 { |
|
862 isEdited = ETrue; |
|
863 } |
|
864 } |
|
865 |
|
866 return isEdited; |
|
867 } |
|
868 |
792 // EOF |
869 // EOF |
793 |
|