|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: CalenEditorData stores data from edited Symbian CCalEntry |
|
15 * to format that match Calendar Editors fields. Editor fields |
|
16 * update CalenEditorData. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 //debug |
|
22 #include "calendarui_debug.h" |
|
23 |
|
24 #include "CalenEditorData.h" |
|
25 |
|
26 #include <calendateutils.h> |
|
27 |
|
28 #include <calalarm.h> |
|
29 #include <calentry.h> |
|
30 #include <calrrule.h> |
|
31 // Utility functions |
|
32 |
|
33 // ======== LOCAL FUNCTIONS ======== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // ThrowAwaySecondsAndMicroSecondsL |
|
37 // Remove the seconds and micro seconds part from a TTime. |
|
38 // (other items were commented in a header). |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 static TTime ThrowAwaySecondsAndMicroSecondsL( const TTime& aTime ) |
|
42 { |
|
43 TRACE_ENTRY_POINT; |
|
44 |
|
45 TDateTime dt = aTime.DateTime(); |
|
46 dt.SetSecond(0); |
|
47 dt.SetMicroSecond(0); |
|
48 TTime result( dt ); |
|
49 |
|
50 TRACE_EXIT_POINT; |
|
51 return result; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // DurationL |
|
56 // Returns the difference between the start and end time of an entry. |
|
57 // (other items were commented in a header). |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 static TTimeIntervalMinutes DurationL( const CCalEntry& aEntry ) |
|
61 { |
|
62 TRACE_ENTRY_POINT; |
|
63 |
|
64 TTimeIntervalMinutes duration; |
|
65 |
|
66 TTime start = aEntry.StartTimeL().TimeLocalL(); |
|
67 TTime end = aEntry.EndTimeL().TimeLocalL(); |
|
68 end.MinutesFrom( start, duration ); |
|
69 |
|
70 TRACE_EXIT_POINT; |
|
71 return duration; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // StoreDescriptorL |
|
76 // Gets reference to target HBufC& and attempts to copy data to it. |
|
77 // (other items were commented in a header). |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 static void StoreDescriptorL(const TDesC& aSrc, HBufC*& aTgt) |
|
81 { |
|
82 TRACE_ENTRY_POINT; |
|
83 |
|
84 // Simplistic implementation |
|
85 delete aTgt; // it's safe to delete null pointers |
|
86 aTgt = NULL; |
|
87 aTgt = aSrc.AllocL(); |
|
88 // Complex and more efficient implementation |
|
89 // if ( aSrc.Length() <= aTgt->Des().MaxLength() ) |
|
90 // { |
|
91 // aTgt->Des().Copy( aSrc ); |
|
92 // } |
|
93 // else |
|
94 // { |
|
95 // delete aTgt; |
|
96 // aTgt = NULL; |
|
97 // aTgt = aSrc.AllocL(); |
|
98 // } |
|
99 |
|
100 TRACE_EXIT_POINT; |
|
101 } |
|
102 |
|
103 // ======== MEMBER FUNCTIONS ======== |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CCalenEditorData::NewL |
|
107 // Two-phased constructor. |
|
108 // (other items were commented in a header). |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 CCalenEditorData* CCalenEditorData::NewL(CCalEntry& aEntry, |
|
112 const TCalTime& aInstanceDateTime ) |
|
113 { |
|
114 TRACE_ENTRY_POINT; |
|
115 |
|
116 CCalenEditorData* self = new (ELeave) CCalenEditorData; |
|
117 CleanupStack::PushL( self ); |
|
118 self->ConstructL(aEntry, aInstanceDateTime); |
|
119 CleanupStack::Pop( self ); |
|
120 |
|
121 TRACE_EXIT_POINT; |
|
122 return self; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CCalenEditorData::~CCalenEditorData |
|
127 // Destructor. |
|
128 // (other items were commented in a header). |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 CCalenEditorData::~CCalenEditorData() |
|
132 { |
|
133 TRACE_ENTRY_POINT; |
|
134 |
|
135 delete iSummary; |
|
136 delete iLocation; |
|
137 delete iDescription; |
|
138 |
|
139 TRACE_EXIT_POINT; |
|
140 } |
|
141 |
|
142 // Getters |
|
143 const CCalEntry::TType& CCalenEditorData::EntryType() const |
|
144 { |
|
145 TRACE_ENTRY_POINT; |
|
146 |
|
147 TRACE_EXIT_POINT; |
|
148 return iEntryType; |
|
149 } |
|
150 |
|
151 const CCalEntry::TStatus& CCalenEditorData::Status() const |
|
152 { |
|
153 TRACE_ENTRY_POINT; |
|
154 |
|
155 TRACE_EXIT_POINT; |
|
156 return iEntryStatus; |
|
157 } |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // CCalenEditorData::Summary |
|
161 // Returns the summary. |
|
162 // (other items were commented in a header). |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 const TDesC& CCalenEditorData::Summary() const |
|
166 { |
|
167 TRACE_ENTRY_POINT; |
|
168 |
|
169 ASSERT( iSummary ); |
|
170 |
|
171 TRACE_EXIT_POINT; |
|
172 return *iSummary; |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CCalenEditorData::Location |
|
177 // Returns the location. |
|
178 // (other items were commented in a header). |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 const TDesC& CCalenEditorData::Location() const |
|
182 { |
|
183 TRACE_ENTRY_POINT; |
|
184 |
|
185 ASSERT( iLocation ); |
|
186 |
|
187 TRACE_EXIT_POINT; |
|
188 return *iLocation; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CCalenEditorData::Description |
|
193 // Returns the description. |
|
194 // (other items were commented in a header). |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 const TDesC& CCalenEditorData::Description() const |
|
198 { |
|
199 TRACE_ENTRY_POINT; |
|
200 |
|
201 ASSERT( iDescription ); |
|
202 |
|
203 TRACE_EXIT_POINT; |
|
204 return *iDescription; |
|
205 } |
|
206 |
|
207 // ----------------------------------------------------------------------------- |
|
208 // CCalenEditorData::StartDateTime |
|
209 // Returns the start date time. |
|
210 // (other items were commented in a header). |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 const TTime& CCalenEditorData::StartDateTime() const |
|
214 { |
|
215 TRACE_ENTRY_POINT; |
|
216 |
|
217 TRACE_EXIT_POINT; |
|
218 return iStartDateTime; |
|
219 } |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CCalenEditorData::EndDateTime |
|
223 // Returns the end date time. |
|
224 // (other items were commented in a header). |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 const TTime& CCalenEditorData::EndDateTime() const |
|
228 { |
|
229 TRACE_ENTRY_POINT; |
|
230 |
|
231 TRACE_EXIT_POINT; |
|
232 return iEndDateTime; |
|
233 } |
|
234 |
|
235 // ----------------------------------------------------------------------------- |
|
236 // CCalenEditorData::EventDateTime |
|
237 // Returns the event date time. |
|
238 // (other items were commented in a header). |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 const TTime& CCalenEditorData::EventDateTime() const |
|
242 { |
|
243 TRACE_ENTRY_POINT; |
|
244 |
|
245 TRACE_EXIT_POINT; |
|
246 return StartDateTime(); |
|
247 } |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CCalenEditorData::IsAlarmActivated |
|
251 // Returns ETrue if the alarm is activated, EFalse otherwise. |
|
252 // (other items were commented in a header). |
|
253 // ----------------------------------------------------------------------------- |
|
254 // |
|
255 TBool CCalenEditorData::IsAlarmActivated() const |
|
256 { |
|
257 TRACE_ENTRY_POINT; |
|
258 |
|
259 TRACE_EXIT_POINT; |
|
260 return iIsAlarmActivated; |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CCalenEditorData::AlarmDateTime |
|
265 // Returns the alarm date time. |
|
266 // (other items were commented in a header). |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 const TTime& CCalenEditorData::AlarmDateTime() const |
|
270 { |
|
271 TRACE_ENTRY_POINT; |
|
272 |
|
273 ASSERT( iIsAlarmActivated ); |
|
274 |
|
275 TRACE_EXIT_POINT; |
|
276 return iAlarmDateTime; |
|
277 } |
|
278 |
|
279 // ----------------------------------------------------------------------------- |
|
280 // CCalenEditorData::RepeatType |
|
281 // Returns the repeat type. |
|
282 // (other items were commented in a header). |
|
283 // ----------------------------------------------------------------------------- |
|
284 // |
|
285 TCalenRepeatIndex CCalenEditorData::RepeatType() const |
|
286 { |
|
287 TRACE_ENTRY_POINT; |
|
288 |
|
289 TRACE_EXIT_POINT; |
|
290 return iRepeatType; |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CCalenEditorData::RepeatUntilDateTime |
|
295 // Returns the date/time until which this entry repeats. |
|
296 // (other items were commented in a header). |
|
297 // ----------------------------------------------------------------------------- |
|
298 // |
|
299 const TTime& CCalenEditorData::RepeatUntilDateTime() const |
|
300 { |
|
301 TRACE_ENTRY_POINT; |
|
302 |
|
303 ASSERT( IsRepeating() ); |
|
304 |
|
305 TRACE_EXIT_POINT; |
|
306 return iRepeatUntilDateTime; |
|
307 } |
|
308 |
|
309 // ----------------------------------------------------------------------------- |
|
310 // CCalenEditorData::Priority |
|
311 // Returns the priority. |
|
312 // (other items were commented in a header). |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 CCalenEditorData::TTodoPriority CCalenEditorData::Priority() const |
|
316 { |
|
317 TRACE_ENTRY_POINT; |
|
318 |
|
319 TRACE_EXIT_POINT; |
|
320 return iPriority; |
|
321 } |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // CCalenEditorData::SynchType |
|
325 // Returns the synchronisation type. |
|
326 // (other items were commented in a header). |
|
327 // ----------------------------------------------------------------------------- |
|
328 // |
|
329 CCalenEditorData::TSynchType CCalenEditorData::SynchType() const |
|
330 { |
|
331 TRACE_ENTRY_POINT; |
|
332 |
|
333 TRACE_EXIT_POINT; |
|
334 return iSynchType; |
|
335 } |
|
336 |
|
337 // Setters |
|
338 |
|
339 // ----------------------------------------------------------------------------- |
|
340 // CCalenEditorData::SetSummaryL |
|
341 // Sets the summary. |
|
342 // (other items were commented in a header). |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void CCalenEditorData::SetSummaryL( const TDesC& aSummary ) |
|
346 { |
|
347 TRACE_ENTRY_POINT; |
|
348 |
|
349 StoreDescriptorL( aSummary, iSummary ); |
|
350 |
|
351 TRACE_EXIT_POINT; |
|
352 } |
|
353 |
|
354 // ----------------------------------------------------------------------------- |
|
355 // CCalenEditorData::SetLocationL |
|
356 // Sets the location. |
|
357 // (other items were commented in a header). |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CCalenEditorData::SetLocationL( const TDesC& aLocation ) |
|
361 { |
|
362 TRACE_ENTRY_POINT; |
|
363 |
|
364 StoreDescriptorL( aLocation, iLocation ); |
|
365 |
|
366 TRACE_EXIT_POINT; |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CCalenEditorData::SetDescriptionL |
|
371 // Sets the description. |
|
372 // (other items were commented in a header). |
|
373 // ----------------------------------------------------------------------------- |
|
374 // |
|
375 void CCalenEditorData::SetDescriptionL( const TDesC& aDescription ) |
|
376 { |
|
377 TRACE_ENTRY_POINT; |
|
378 |
|
379 StoreDescriptorL( aDescription, iDescription ); |
|
380 |
|
381 TRACE_EXIT_POINT; |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CCalenEditorData::SetDescriptionTransferOwnershipL |
|
386 // Sets the description, passing ownership of aDescription. |
|
387 // (other items were commented in a header). |
|
388 // ----------------------------------------------------------------------------- |
|
389 // |
|
390 void CCalenEditorData::SetDescriptionTransferOwnershipL( HBufC* aDescription ) |
|
391 { |
|
392 TRACE_ENTRY_POINT; |
|
393 |
|
394 delete iDescription; |
|
395 iDescription = aDescription; |
|
396 |
|
397 TRACE_EXIT_POINT; |
|
398 } |
|
399 |
|
400 // ----------------------------------------------------------------------------- |
|
401 // CCalenEditorData::SetStartDateTimeL |
|
402 // Sets the start date/time. |
|
403 // (other items were commented in a header). |
|
404 // ----------------------------------------------------------------------------- |
|
405 // |
|
406 void CCalenEditorData::SetStartDateTimeL( const TTime& aStart ) |
|
407 { |
|
408 TRACE_ENTRY_POINT; |
|
409 |
|
410 iStartDateTime = ThrowAwaySecondsAndMicroSecondsL( aStart ); |
|
411 |
|
412 TRACE_EXIT_POINT; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // CCalenEditorData::SetEndDateTimeL |
|
417 // Sets the end date/time. |
|
418 // (other items were commented in a header). |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void CCalenEditorData::SetEndDateTimeL( const TTime& aEnd ) |
|
422 { |
|
423 TRACE_ENTRY_POINT; |
|
424 |
|
425 iEndDateTime = ThrowAwaySecondsAndMicroSecondsL( aEnd ); |
|
426 |
|
427 TRACE_EXIT_POINT; |
|
428 } |
|
429 |
|
430 // ----------------------------------------------------------------------------- |
|
431 // CCalenEditorData::SetEventDateL |
|
432 // Sets the event date. |
|
433 // (other items were commented in a header). |
|
434 // ----------------------------------------------------------------------------- |
|
435 // |
|
436 void CCalenEditorData::SetEventDateL( const TTime& aDate) |
|
437 { |
|
438 TRACE_ENTRY_POINT; |
|
439 |
|
440 TTime midnight = CalenDateUtils::BeginningOfDay( aDate ); |
|
441 SetStartDateTimeL( midnight ); |
|
442 SetEndDateTimeL( midnight ); |
|
443 |
|
444 TRACE_EXIT_POINT; |
|
445 } |
|
446 |
|
447 // ----------------------------------------------------------------------------- |
|
448 // CCalenEditorData::SetAlarmOnL |
|
449 // Sets the alarm to be active at the given date/time. |
|
450 // (other items were commented in a header). |
|
451 // ----------------------------------------------------------------------------- |
|
452 // |
|
453 void CCalenEditorData::SetAlarmOnL( const TTime& aAlarmTime ) |
|
454 { |
|
455 TRACE_ENTRY_POINT; |
|
456 |
|
457 iIsAlarmActivated = ETrue; |
|
458 iAlarmDateTime = ThrowAwaySecondsAndMicroSecondsL( aAlarmTime ); |
|
459 |
|
460 TRACE_EXIT_POINT; |
|
461 } |
|
462 |
|
463 // ----------------------------------------------------------------------------- |
|
464 // CCalenEditorData::SetAlarmOffL |
|
465 // Turns off the alarm. |
|
466 // (other items were commented in a header). |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void CCalenEditorData::SetAlarmOffL() |
|
470 { |
|
471 TRACE_ENTRY_POINT; |
|
472 |
|
473 iIsAlarmActivated = EFalse; |
|
474 iAlarmDateTime = Time::NullTTime(); |
|
475 |
|
476 TRACE_EXIT_POINT; |
|
477 } |
|
478 |
|
479 // ----------------------------------------------------------------------------- |
|
480 // CCalenEditorData::SetAlarmDateTimeL |
|
481 // Sets the alarm to be at the given time. Note that you must call SetAlarmOnL() |
|
482 // before calling this function. |
|
483 // (other items were commented in a header). |
|
484 // ----------------------------------------------------------------------------- |
|
485 // |
|
486 void CCalenEditorData::SetAlarmDateTimeL( const TTime& aTime ) |
|
487 { |
|
488 TRACE_ENTRY_POINT; |
|
489 |
|
490 __ASSERT_ALWAYS( iIsAlarmActivated, User::Leave( KErrNotReady ) ); |
|
491 iAlarmDateTime = ThrowAwaySecondsAndMicroSecondsL( aTime ); |
|
492 |
|
493 TRACE_EXIT_POINT; |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CCalenEditorData::SetNonRepeatingL |
|
498 // Sets the event to be non-repeating. |
|
499 // (other items were commented in a header). |
|
500 // ----------------------------------------------------------------------------- |
|
501 // |
|
502 void CCalenEditorData::SetNonRepeatingL() |
|
503 { |
|
504 TRACE_ENTRY_POINT; |
|
505 |
|
506 iRepeatType = ERepeatNotRepeated; |
|
507 iRepeatUntilDateTime = Time::NullTTime(); |
|
508 |
|
509 TRACE_EXIT_POINT; |
|
510 } |
|
511 |
|
512 // ----------------------------------------------------------------------------- |
|
513 // CCalenEditorData::SetRepeatingL |
|
514 // Sets the event to be repeating, based on repeat type and until date/time |
|
515 // passed in. |
|
516 // (other items were commented in a header). |
|
517 // ----------------------------------------------------------------------------- |
|
518 // |
|
519 void CCalenEditorData::SetRepeatingL(TCalenRepeatIndex aRepeatType, const TTime& aUntilDateTime ) |
|
520 { |
|
521 TRACE_ENTRY_POINT; |
|
522 |
|
523 iRepeatType = aRepeatType; |
|
524 iRepeatUntilDateTime = CalenDateUtils::BeginningOfDay( aUntilDateTime ); |
|
525 |
|
526 TRACE_EXIT_POINT; |
|
527 } |
|
528 |
|
529 // ----------------------------------------------------------------------------- |
|
530 // CCalenEditorData::SetRepeatUntilDateTimeL |
|
531 // Sets the event to repeat until the given date/time. Note that you must call |
|
532 // SetRepeatingL before calling this function. |
|
533 // (other items were commented in a header). |
|
534 // ----------------------------------------------------------------------------- |
|
535 // |
|
536 void CCalenEditorData::SetRepeatUntilDateTimeL(const TTime& aTime) |
|
537 { |
|
538 TRACE_ENTRY_POINT; |
|
539 |
|
540 __ASSERT_ALWAYS( IsRepeating(), User::Leave( KErrNotReady ) ); |
|
541 SetRepeatingL( iRepeatType, aTime ); |
|
542 |
|
543 TRACE_EXIT_POINT; |
|
544 } |
|
545 |
|
546 // ----------------------------------------------------------------------------- |
|
547 // CCalenEditorData::SetPriorityL |
|
548 // Sets the priority. |
|
549 // (other items were commented in a header). |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 void CCalenEditorData::SetPriorityL(CCalenEditorData::TTodoPriority aPriority) |
|
553 { |
|
554 TRACE_ENTRY_POINT; |
|
555 |
|
556 iPriority = aPriority; |
|
557 |
|
558 TRACE_EXIT_POINT; |
|
559 } |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // CCalenEditorData::SetSynchTypeL |
|
563 // Sets the sychronisation type. |
|
564 // (other items were commented in a header). |
|
565 // ----------------------------------------------------------------------------- |
|
566 // |
|
567 void CCalenEditorData::SetSynchTypeL(CCalenEditorData::TSynchType aSynchType) |
|
568 { |
|
569 TRACE_ENTRY_POINT; |
|
570 |
|
571 iSynchType = aSynchType; |
|
572 |
|
573 TRACE_EXIT_POINT; |
|
574 } |
|
575 |
|
576 // Utility functions |
|
577 |
|
578 // ----------------------------------------------------------------------------- |
|
579 // CCalenEditorData::IsRepeating |
|
580 // Returns ETrue if the entry is repeating, EFalse otherwise. |
|
581 // (other items were commented in a header). |
|
582 // ----------------------------------------------------------------------------- |
|
583 // |
|
584 TBool CCalenEditorData::IsRepeating() const |
|
585 { |
|
586 TRACE_ENTRY_POINT; |
|
587 |
|
588 TRACE_EXIT_POINT; |
|
589 return iRepeatType != ERepeatNotRepeated; |
|
590 } |
|
591 |
|
592 // Private functions |
|
593 |
|
594 // ----------------------------------------------------------------------------- |
|
595 // CCalenEditorData::CCalenEditorData |
|
596 // Constructor. |
|
597 // (other items were commented in a header). |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 CCalenEditorData::CCalenEditorData() |
|
601 { |
|
602 TRACE_ENTRY_POINT; |
|
603 TRACE_EXIT_POINT; |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CCalenEditorData::ConstructL |
|
608 // Leaving construction. |
|
609 // (other items were commented in a header). |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CCalenEditorData::ConstructL( CCalEntry& aEntry, |
|
613 const TCalTime& aInstanceDateTime ) |
|
614 { |
|
615 TRACE_ENTRY_POINT; |
|
616 iEntryType = aEntry.EntryTypeL(); |
|
617 iEntryStatus = aEntry.StatusL(); |
|
618 CopyDataFromEntryL( aEntry, aInstanceDateTime ); |
|
619 |
|
620 TRACE_EXIT_POINT; |
|
621 } |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // CCalenEditorData::CopyDataFromEntryL |
|
625 // Copy data from the given entry to this class. |
|
626 // (other items were commented in a header). |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 void CCalenEditorData::CopyDataFromEntryL( CCalEntry& aEntry, const TCalTime& aInstanceDateTime ) |
|
630 { |
|
631 TRACE_ENTRY_POINT; |
|
632 |
|
633 SetSummaryL( aEntry.SummaryL() ); |
|
634 SetLocationL( aEntry.LocationL() ); |
|
635 SetDescriptionL( aEntry.DescriptionL() ); |
|
636 |
|
637 switch ( aEntry.EntryTypeL() ) |
|
638 { |
|
639 case CCalEntry::EAppt: |
|
640 { |
|
641 TTime start = aInstanceDateTime.TimeLocalL(); |
|
642 TTime end = start + DurationL( aEntry ); |
|
643 SetStartDateTimeL( start ); |
|
644 SetEndDateTimeL( end ); |
|
645 } |
|
646 break; |
|
647 |
|
648 case CCalEntry::EReminder: |
|
649 { |
|
650 TTime start = aInstanceDateTime.TimeLocalL(); |
|
651 TTime end = start; |
|
652 SetStartDateTimeL( start ); |
|
653 SetEndDateTimeL( end ); |
|
654 } |
|
655 break; |
|
656 |
|
657 case CCalEntry::EEvent: |
|
658 { |
|
659 TTime start = CalenDateUtils::BeginningOfDay( aInstanceDateTime.TimeLocalL() ); |
|
660 TTime end = start + DurationL( aEntry ); |
|
661 end -= TTimeIntervalDays(1); |
|
662 end = CalenDateUtils::BeginningOfDay( end ); |
|
663 // ensure that for all-day events shorter than day we use sensible value |
|
664 if (end < start) |
|
665 { |
|
666 end = start; |
|
667 } |
|
668 SetStartDateTimeL( start ); |
|
669 SetEndDateTimeL( end ); |
|
670 } |
|
671 break; |
|
672 |
|
673 case CCalEntry::EAnniv: |
|
674 { |
|
675 TTime event = aInstanceDateTime.TimeLocalL(); |
|
676 SetEventDateL( event ); |
|
677 } |
|
678 break; |
|
679 |
|
680 case CCalEntry::ETodo: |
|
681 { |
|
682 // Undated todos |
|
683 TTime dueDate = aEntry.EndTimeL().TimeLocalL(); |
|
684 if ( dueDate == Time::NullTTime() ) |
|
685 { |
|
686 TTime today; |
|
687 today.HomeTime(); |
|
688 today = CalenDateUtils::BeginningOfDay( today ); |
|
689 dueDate = today; |
|
690 } |
|
691 SetEventDateL( dueDate ); |
|
692 } |
|
693 break; |
|
694 |
|
695 default: |
|
696 ASSERT( EFalse ); |
|
697 break; |
|
698 } |
|
699 |
|
700 // Repeat rule |
|
701 TCalRRule rrule; |
|
702 TBool isRepeating = aEntry.GetRRuleL( rrule ); |
|
703 |
|
704 RArray<TCalTime> rdates; |
|
705 CleanupClosePushL( rdates ); |
|
706 aEntry.GetRDatesL( rdates ); |
|
707 TBool hasRDates = ( rdates.Count() > 0 ); |
|
708 |
|
709 // If the entry has rdates and/or got rrules, |
|
710 // need to find and set the repeat until date |
|
711 if ( hasRDates || isRepeating ) |
|
712 { |
|
713 TTime repeatUntil = aEntry.StartTimeL().TimeLocalL(); |
|
714 |
|
715 if ( isRepeating ) |
|
716 { |
|
717 // If the entry is repeating find the rrule |
|
718 // repeat until time. |
|
719 TTime rruleUntil = rrule.Until().TimeLocalL(); |
|
720 if ( rruleUntil > repeatUntil ) |
|
721 { |
|
722 repeatUntil = rruleUntil; |
|
723 } |
|
724 } |
|
725 |
|
726 if ( hasRDates ) |
|
727 { |
|
728 // Find the last rdate date, using the fact that |
|
729 // the rdates are sorted in date order |
|
730 TTime lastRDate = rdates [ rdates.Count() - 1 ].TimeLocalL(); |
|
731 |
|
732 // Compare the date of the last rdate with |
|
733 // the current repat until time. |
|
734 if ( lastRDate > repeatUntil ) |
|
735 { |
|
736 repeatUntil = lastRDate; |
|
737 } |
|
738 |
|
739 // Set the repeat type as other. |
|
740 SetRepeatingL( ERepeatOther, repeatUntil ); |
|
741 |
|
742 // If the first rDate is before the start of any rRule, |
|
743 // the first rDate will have to be disguised as |
|
744 // the start of the series |
|
745 TTime firstRDate = rdates[ 0 ].TimeLocalL(); |
|
746 if ( firstRDate < StartDateTime() ) |
|
747 { |
|
748 TTimeIntervalMinutes duration; |
|
749 |
|
750 User::LeaveIfError( EndDateTime().MinutesFrom( StartDateTime(), duration ) ); |
|
751 SetStartDateTimeL( firstRDate ); |
|
752 TTime endDate = firstRDate + duration; |
|
753 SetEndDateTimeL( endDate ); |
|
754 } |
|
755 } |
|
756 else |
|
757 { |
|
758 // Find the repeat type and set the repeat type. |
|
759 TCalenRepeatIndex repeatType = CalenNoteDataUtil::RepeatIndexL( aEntry ); |
|
760 ASSERT( repeatType != ERepeatNotRepeated ); |
|
761 |
|
762 SetRepeatingL( repeatType, repeatUntil ); |
|
763 } |
|
764 } |
|
765 else |
|
766 { |
|
767 SetNonRepeatingL(); |
|
768 } |
|
769 |
|
770 CleanupStack::PopAndDestroy(); // rdates |
|
771 |
|
772 // Alarm |
|
773 TTime alarmDateTime; |
|
774 TBool hasAlarm = CalenNoteDataUtil::GetAlarmDateTimeL( aEntry, |
|
775 alarmDateTime ); |
|
776 |
|
777 if ( hasAlarm ) |
|
778 { |
|
779 if ( isRepeating ) |
|
780 { |
|
781 // alarm time should be offset from instance date, not entry date. |
|
782 // As instance date time might have different time of day (repeating entries defined by RDATEs) |
|
783 // than entry start, we need to nudge only days to instance date, and keep time of alarm same. |
|
784 TTimeIntervalDays deltaDays = aInstanceDateTime.TimeLocalL().DaysFrom( aEntry.StartTimeL().TimeLocalL() ); |
|
785 alarmDateTime += deltaDays; |
|
786 } |
|
787 SetAlarmOnL( alarmDateTime ); |
|
788 } |
|
789 else |
|
790 { |
|
791 SetAlarmOffL(); |
|
792 } |
|
793 |
|
794 // Priority - same behaviour as todo/day views. |
|
795 TUint priority( aEntry.PriorityL() ); |
|
796 |
|
797 // Keep priority inside enumeration range |
|
798 TTodoPriority todoPriority; |
|
799 if( !priority ) |
|
800 { |
|
801 todoPriority = ETodoPriorityHigh; |
|
802 } |
|
803 else if( priority > ETodoPriorityLow ) |
|
804 { |
|
805 todoPriority = ETodoPriorityLow; |
|
806 } |
|
807 else |
|
808 { |
|
809 todoPriority = TTodoPriority(priority); |
|
810 } |
|
811 |
|
812 SetPriorityL( todoPriority ); |
|
813 |
|
814 // Synch type |
|
815 // Note: EOpen is Symbian default for new entries |
|
816 TSynchType synchType = CCalenEditorData::ESynchPrivate; |
|
817 switch ( aEntry.ReplicationStatusL() ) |
|
818 { |
|
819 case CCalEntry::EOpen: |
|
820 synchType = CCalenEditorData::ESynchPublic; |
|
821 break; |
|
822 case CCalEntry::EPrivate: |
|
823 synchType = CCalenEditorData::ESynchPrivate; |
|
824 break; |
|
825 case CCalEntry::ERestricted: |
|
826 synchType = CCalenEditorData::ESynchNoSync; |
|
827 break; |
|
828 default: |
|
829 __ASSERT_ALWAYS( EFalse, User::Invariant() ); |
|
830 synchType = CCalenEditorData::ESynchPrivate; // to please compiler; |
|
831 break; |
|
832 } |
|
833 SetSynchTypeL( synchType ); |
|
834 |
|
835 TRACE_EXIT_POINT; |
|
836 } |
|
837 |
|
838 // End of file |