145 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
146 // |
146 // |
147 inline CESMRAnnivTimeValidator::CESMRAnnivTimeValidator() |
147 inline CESMRAnnivTimeValidator::CESMRAnnivTimeValidator() |
148 : iCurrentAnnivDate( Time::NullTTime() ), |
148 : iCurrentAnnivDate( Time::NullTTime() ), |
149 iCurrentAlarmTime( Time::NullTTime() ), |
149 iCurrentAlarmTime( Time::NullTTime() ), |
150 iAlarmOnOff( EFalse ) |
150 iAlarmOnOff( EFalse ), |
|
151 iInitialAlarmTime( Time::NullTTime() ), |
|
152 iInitialAlarmOnOff( EFalse ), |
|
153 iInitialStartDate( Time::NullTTime() ) |
|
154 |
151 { |
155 { |
152 } |
156 } |
153 |
157 |
154 // --------------------------------------------------------------------------- |
158 // --------------------------------------------------------------------------- |
155 // CESMRAnnivTimeValidator::~CESMRAnnivTimeValidator |
159 // CESMRAnnivTimeValidator::~CESMRAnnivTimeValidator |
235 CCalEntry& entry( aEntry.Entry() ); |
239 CCalEntry& entry( aEntry.Entry() ); |
236 |
240 |
237 TCalTime startTime = entry.StartTimeL(); |
241 TCalTime startTime = entry.StartTimeL(); |
238 iCurrentAnnivDate = startTime.TimeLocalL(); |
242 iCurrentAnnivDate = startTime.TimeLocalL(); |
239 SetDateToEditor( *iStartDate, iCurrentAnnivDate ); |
243 SetDateToEditor( *iStartDate, iCurrentAnnivDate ); |
240 |
244 iInitialStartDate = iStartDate->Date(); |
241 |
245 |
242 CCalAlarm* alarm = entry.AlarmL(); |
246 CCalAlarm* alarm = entry.AlarmL(); |
243 CleanupStack::PushL( alarm ); |
247 CleanupStack::PushL( alarm ); |
244 |
248 |
245 if ( alarm ) |
249 if ( alarm ) |
246 { |
250 { |
247 iCurrentAlarmTime = iCurrentAnnivDate - alarm->TimeOffset(); |
251 iCurrentAlarmTime = iCurrentAnnivDate - alarm->TimeOffset(); |
248 iAlarmOnOff = ETrue; |
252 iAlarmOnOff = ETrue; |
|
253 iInitialAlarmOnOff = iAlarmOnOff; |
249 |
254 |
250 SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime ); |
255 SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime ); |
251 SetDateToEditor( *iAlarmDate, iCurrentAlarmTime ); |
256 SetDateToEditor( *iAlarmDate, iCurrentAlarmTime ); |
|
257 |
|
258 iInitialAlarmTime = iAlarmTime->Time(); |
|
259 iInitialAlarmDate = iAlarmDate->Date(); |
252 } |
260 } |
253 |
261 |
254 CleanupStack::PopAndDestroy( alarm ); |
262 CleanupStack::PopAndDestroy( alarm ); |
255 DrawEditorsDeferred(); |
263 DrawEditorsDeferred(); |
256 } |
264 } |
266 FUNC_LOG; |
274 FUNC_LOG; |
267 if ( MESMRCalEntry::EESMRCalEntryAnniversary == aEntry.Type() ) |
275 if ( MESMRCalEntry::EESMRCalEntryAnniversary == aEntry.Type() ) |
268 { |
276 { |
269 PreValidateEditorContent(); |
277 PreValidateEditorContent(); |
270 CCalEntry& entry( aEntry.Entry() ); |
278 CCalEntry& entry( aEntry.Entry() ); |
271 |
279 TDateTime annivEditorTime = StartTimeL(); |
272 TTime annivEdirotTime = StartTimeL(); |
280 |
273 |
281 // If entry has been modified, we will write new values to entry. |
274 TCalTime annivTime; |
282 // Otherwise entry will not be modified and thus saved |
275 |
283 // (ex. new entry and press only Done ) |
276 // The default mode for anniversary is EFloating, |
284 if( IsModifiedL( aEntry ) ) |
277 // But some 3rd party application might have saved a different type |
|
278 // for one reason or another. In that case we are using |
|
279 // the existing value. |
|
280 if ( aEntry.IsStoredL() ) |
|
281 { |
285 { |
282 TCalTime::TTimeMode timeMode = |
286 TCalTime annivTime; |
283 aEntry.Entry().StartTimeL().TimeMode(); |
287 |
284 |
288 // The default mode for anniversary is EFloating, |
285 switch ( timeMode ) |
289 // But some 3rd party application might have saved a different type |
|
290 // for one reason or another. In that case we are using |
|
291 // the existing value. |
|
292 if ( aEntry.IsStoredL() ) |
286 { |
293 { |
287 case TCalTime::EFixedUtc: |
294 TCalTime::TTimeMode timeMode = |
288 { |
295 aEntry.Entry().StartTimeL().TimeMode(); |
289 annivTime.SetTimeUtcL( annivEdirotTime ); |
296 |
290 break; |
297 switch ( timeMode ) |
291 } |
298 { |
292 case TCalTime::EFixedTimeZone: |
299 case TCalTime::EFixedUtc: |
293 { |
300 { |
294 annivTime.SetTimeLocalL( annivEdirotTime ); |
301 annivTime.SetTimeUtcL( annivEditorTime ); |
295 break; |
302 break; |
296 } |
303 } |
297 case TCalTime::EFloating: |
304 case TCalTime::EFixedTimeZone: |
298 default: |
305 { |
299 { |
306 annivTime.SetTimeLocalL( annivEditorTime ); |
300 annivTime.SetTimeLocalFloatingL( annivEdirotTime ); |
307 break; |
301 } |
308 } |
|
309 case TCalTime::EFloating: |
|
310 default: |
|
311 { |
|
312 annivTime.SetTimeLocalFloatingL( annivEditorTime ); |
|
313 } |
|
314 } |
|
315 } |
|
316 else |
|
317 { |
|
318 annivTime.SetTimeLocalFloatingL( annivEditorTime ); |
|
319 } |
|
320 |
|
321 entry.SetStartAndEndTimeL( annivTime, annivTime ); |
|
322 |
|
323 |
|
324 // Setting alarm only if entry needs to be saved |
|
325 if ( iAlarmOnOff ) |
|
326 { |
|
327 TTimeIntervalMinutes diff; |
|
328 |
|
329 TTime alarm = AlarmTimeL(); |
|
330 TTime editorTime = annivEditorTime; |
|
331 editorTime.MinutesFrom( alarm, diff ); |
|
332 |
|
333 CCalAlarm* alarmObject = entry.AlarmL(); |
|
334 if ( !alarmObject ) |
|
335 { |
|
336 alarmObject = CCalAlarm::NewL(); |
|
337 } |
|
338 CleanupStack::PushL( alarmObject ); |
|
339 alarmObject->SetTimeOffset( diff ); |
|
340 entry.SetAlarmL( alarmObject ); |
|
341 CleanupStack::PopAndDestroy( alarmObject ); |
|
342 alarmObject = NULL; |
|
343 } |
|
344 else |
|
345 { |
|
346 entry.SetAlarmL( NULL ); |
302 } |
347 } |
303 } |
348 } |
304 else |
|
305 { |
|
306 annivTime.SetTimeLocalFloatingL( annivEdirotTime ); |
|
307 } |
|
308 |
|
309 entry.SetStartAndEndTimeL( annivTime, annivTime ); |
|
310 if ( iAlarmOnOff ) |
|
311 { |
|
312 TTimeIntervalMinutes diff; |
|
313 |
|
314 TTime alarm = AlarmTimeL(); |
|
315 annivEdirotTime.MinutesFrom( alarm, diff ); |
|
316 |
|
317 CCalAlarm* alarmObject = entry.AlarmL(); |
|
318 if ( !alarmObject ) |
|
319 { |
|
320 alarmObject = CCalAlarm::NewL(); |
|
321 } |
|
322 CleanupStack::PushL( alarmObject ); |
|
323 alarmObject->SetTimeOffset( diff ); |
|
324 entry.SetAlarmL( alarmObject ); |
|
325 CleanupStack::PopAndDestroy( alarmObject ); |
|
326 alarmObject = NULL; |
|
327 } |
|
328 else |
|
329 { |
|
330 entry.SetAlarmL( NULL ); |
|
331 } |
|
332 } |
349 } |
333 } |
350 } |
334 |
351 |
335 // --------------------------------------------------------------------------- |
352 // --------------------------------------------------------------------------- |
336 // CESMRAnnivTimeValidator::SetStartTimeFieldL |
353 // CESMRAnnivTimeValidator::SetStartTimeFieldL |
361 void CESMRAnnivTimeValidator::SetStartDateFieldL( |
378 void CESMRAnnivTimeValidator::SetStartDateFieldL( |
362 CEikDateEditor& aStartDate ) |
379 CEikDateEditor& aStartDate ) |
363 { |
380 { |
364 FUNC_LOG; |
381 FUNC_LOG; |
365 iStartDate = &aStartDate; |
382 iStartDate = &aStartDate; |
|
383 |
|
384 if ( Time::NullTTime() != iCurrentAnnivDate ) |
|
385 { |
|
386 SetDateToEditor( *iStartDate, iCurrentAnnivDate ); |
|
387 } |
366 } |
388 } |
367 |
389 |
368 // --------------------------------------------------------------------------- |
390 // --------------------------------------------------------------------------- |
369 // CESMRAnnivTimeValidator::SetEndDateFieldL |
391 // CESMRAnnivTimeValidator::SetEndDateFieldL |
370 // --------------------------------------------------------------------------- |
392 // --------------------------------------------------------------------------- |
383 void CESMRAnnivTimeValidator::SetAlarmTimeFieldL( |
405 void CESMRAnnivTimeValidator::SetAlarmTimeFieldL( |
384 CEikTimeEditor& aAlarmTime ) |
406 CEikTimeEditor& aAlarmTime ) |
385 { |
407 { |
386 FUNC_LOG; |
408 FUNC_LOG; |
387 iAlarmTime = &aAlarmTime; |
409 iAlarmTime = &aAlarmTime; |
|
410 |
|
411 if ( iAlarmOnOff ) |
|
412 { |
|
413 SetTimeToEditor( *iAlarmTime, iCurrentAlarmTime ); |
|
414 } |
388 } |
415 } |
389 |
416 |
390 // --------------------------------------------------------------------------- |
417 // --------------------------------------------------------------------------- |
391 // CESMRAnnivTimeValidator::SetAlarmDateFieldL |
418 // CESMRAnnivTimeValidator::SetAlarmDateFieldL |
392 // --------------------------------------------------------------------------- |
419 // --------------------------------------------------------------------------- |
394 void CESMRAnnivTimeValidator::SetAlarmDateFieldL( |
421 void CESMRAnnivTimeValidator::SetAlarmDateFieldL( |
395 CEikDateEditor& aAlarmDate ) |
422 CEikDateEditor& aAlarmDate ) |
396 { |
423 { |
397 FUNC_LOG; |
424 FUNC_LOG; |
398 iAlarmDate = &aAlarmDate; |
425 iAlarmDate = &aAlarmDate; |
|
426 |
|
427 if ( iAlarmOnOff ) |
|
428 { |
|
429 SetDateToEditor( *iAlarmDate, iCurrentAlarmTime ); |
|
430 } |
399 } |
431 } |
400 |
432 |
401 // --------------------------------------------------------------------------- |
433 // --------------------------------------------------------------------------- |
402 // CESMRAnnivTimeValidator::SetRecurrenceUntilDateFieldL |
434 // CESMRAnnivTimeValidator::SetRecurrenceUntilDateFieldL |
403 // --------------------------------------------------------------------------- |
435 // --------------------------------------------------------------------------- |
404 // |
436 // |
405 void CESMRAnnivTimeValidator::SetRecurrenceUntilDateFieldL( |
437 void CESMRAnnivTimeValidator::SetRecurrenceUntilDateFieldL( |
406 CEikDateEditor& /*aRecurrenceUntil*/ ) |
438 CEikDateEditor& /*aRecurrenceUntil*/ ) |
|
439 { |
|
440 FUNC_LOG; |
|
441 // No implementation for anniversary |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // CESMRAnnivTimeValidator::SetAbsoluteAlarmOnOffFieldL |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 void CESMRAnnivTimeValidator::SetAbsoluteAlarmOnOffFieldL( |
|
449 MMRAbsoluteAlarmController& /*aAbsoluteAlarmController*/ ) |
407 { |
450 { |
408 FUNC_LOG; |
451 FUNC_LOG; |
409 // No implementation for anniversary |
452 // No implementation for anniversary |
410 } |
453 } |
411 |
454 |
729 |
772 |
730 iCurrentAlarmTime = alarm; |
773 iCurrentAlarmTime = alarm; |
731 } |
774 } |
732 } |
775 } |
733 |
776 |
|
777 // --------------------------------------------------------------------------- |
|
778 // CESMRAnnivTimeValidator::IsModifiedL |
|
779 // --------------------------------------------------------------------------- |
|
780 // |
|
781 TBool CESMRAnnivTimeValidator::IsModifiedL( MESMRCalEntry& aEntry ) |
|
782 { |
|
783 // Checks if any of the editor fields have changed from the original / |
|
784 // initial values |
|
785 TBool isEdited( EFalse ); |
|
786 |
|
787 TBool isSame = aEntry.Entry().CompareL( aEntry.OriginalEntry() ); |
|
788 |
|
789 if( !isSame || |
|
790 iInitialAlarmOnOff != iAlarmOnOff || |
|
791 iStartDate->Date() != iInitialStartDate ) |
|
792 { |
|
793 isEdited = ETrue; |
|
794 } |
|
795 |
|
796 // If alarm is on, we will check alarm time and date also for changes |
|
797 if( iAlarmOnOff ) |
|
798 { |
|
799 if( iAlarmTime->Time() != iInitialAlarmTime || |
|
800 iAlarmDate->Date() != iInitialAlarmDate ) |
|
801 { |
|
802 isEdited = ETrue; |
|
803 } |
|
804 } |
|
805 |
|
806 return isEdited; |
|
807 } |
|
808 |
734 // EOF |
809 // EOF |
735 |
|