|
1 /* |
|
2 * Copyright (c) 2009 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 : calendar unified editor fields control |
|
15 * |
|
16 */ |
|
17 |
|
18 // system includes |
|
19 #include <eikedwin.h> |
|
20 #include <eikmfne.h> |
|
21 #include <StringLoader.h> |
|
22 #include <e32des16.h> |
|
23 #include <calentry.h> |
|
24 #include <CalenDefaultEditorsData.rsg> |
|
25 #include <calendateutils.h> |
|
26 #include <calenservices.h> |
|
27 |
|
28 // user includes |
|
29 #include "calenunifiededitorcontrol.h" |
|
30 #include "calenunifiededitor.h" |
|
31 #include "CalenDefaultEditors.hrh" |
|
32 #include "calenentryutil.h" |
|
33 #include "caleneventtypefield.h" |
|
34 #include "calenreminderfield.h" |
|
35 #include "calenrepeatfield.h" |
|
36 #include "calenalldayfield.h" |
|
37 #include "calenpriorityfield.h" |
|
38 #include "calendbfield.h" |
|
39 #include "CalenDescription.h" |
|
40 |
|
41 // debug |
|
42 #include "calendarui_debug.h" |
|
43 |
|
44 // Constants |
|
45 const TInt KOneDay( 1 ); |
|
46 |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CCalenUnifiedEditorControl::NewL |
|
50 // Two phased constructor |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CCalenUnifiedEditorControl* CCalenUnifiedEditorControl::NewL( CCalenUnifiedEditor& aUnifiedEditor, |
|
54 MCalenServices& aServices ) |
|
55 { |
|
56 TRACE_ENTRY_POINT; |
|
57 |
|
58 CCalenUnifiedEditorControl* self = new (ELeave)CCalenUnifiedEditorControl( aUnifiedEditor ); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(aServices); |
|
61 CleanupStack::Pop(); |
|
62 |
|
63 TRACE_EXIT_POINT; |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CCalenUnifiedEditorControl::CCalenUnifiedEditorControl |
|
69 // Destructor |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CCalenUnifiedEditorControl::~CCalenUnifiedEditorControl() |
|
73 { |
|
74 TRACE_ENTRY_POINT; |
|
75 |
|
76 delete iEventTypeField; |
|
77 delete iReminderField; |
|
78 delete iRepeatField; |
|
79 delete iAllDayField; |
|
80 delete iPriorityField; |
|
81 delete iDbField; |
|
82 delete iDescription; |
|
83 |
|
84 TRACE_EXIT_POINT; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CCalenUnifiedEditorControl::ConstructL |
|
89 // Second phased construction |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CCalenUnifiedEditorControl::ConstructL(MCalenServices& aServices) |
|
93 { |
|
94 TRACE_ENTRY_POINT; |
|
95 |
|
96 iEventTypeField = CCalenEventTypeField::NewL( iUnifiedEditor ); |
|
97 iReminderField = CCalenReminderField::NewL( iUnifiedEditor ); |
|
98 iRepeatField = CCalenRepeatField::NewL( iUnifiedEditor ); |
|
99 iAllDayField = CCalenAllDayField::NewL( iUnifiedEditor ); |
|
100 iPriorityField = CCalenPriorityField::NewL( iUnifiedEditor ); |
|
101 iDbField = CCalenDbField::NewL( iUnifiedEditor,aServices ); |
|
102 iDescription = CCalenDescription::NewL( iUnifiedEditor ); |
|
103 |
|
104 TRACE_EXIT_POINT; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CCalenUnifiedEditorControl::CCalenUnifiedEditorControl |
|
109 // Default constructor |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 CCalenUnifiedEditorControl::CCalenUnifiedEditorControl( CCalenUnifiedEditor& aUnifiedEditor ) |
|
113 :iUnifiedEditor( aUnifiedEditor ) |
|
114 { |
|
115 TRACE_ENTRY_POINT; |
|
116 TRACE_EXIT_POINT; |
|
117 } |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CCalenUnifiedEditorControl::MakeUnifiedEditorL |
|
121 // Initializes the dialog's controls before the dialog is sized |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CCalenUnifiedEditorControl::MakeUnifiedEditorL() |
|
125 { |
|
126 TRACE_ENTRY_POINT; |
|
127 |
|
128 // Add default editor fields. |
|
129 AddDefaultEditorL(); |
|
130 // Initialise editor fields. |
|
131 InitDefaultEditorsL(); |
|
132 // Set data to editor fields. |
|
133 SetDataToEditorL(); |
|
134 |
|
135 // Update MSK string. |
|
136 iUnifiedEditor.SetMskFromResourceL(); |
|
137 iUnifiedEditor.UpdateFormL(); |
|
138 |
|
139 TRACE_EXIT_POINT; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CCalenUnifiedEditorControl::SetDataToEditorL |
|
144 // Set data to the collapsed unified editor |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CCalenUnifiedEditorControl::SetDataToEditorL() |
|
148 { |
|
149 TRACE_ENTRY_POINT; |
|
150 |
|
151 // Set Editor field values |
|
152 |
|
153 // Set data to EventType fields |
|
154 iEventTypeField->SetDataToEditorL(); |
|
155 |
|
156 TPtrC subject = iUnifiedEditor.Edited().Summary().Left( |
|
157 iUnifiedEditor.MaxTextEditorLength() ); |
|
158 iUnifiedEditor.SetEditorTextL( ECalenEditorSubject, &subject ); |
|
159 |
|
160 |
|
161 |
|
162 // update duration for EndTime update, with StartTime change |
|
163 UpdateMeetingDurationL(); |
|
164 |
|
165 switch( iUnifiedEditor.GetEntryType() ) |
|
166 { |
|
167 case CCalEntry::EEvent: |
|
168 { |
|
169 iAllDayField->SetDataToEditorL(); |
|
170 } |
|
171 break; |
|
172 case CCalEntry::EAnniv: |
|
173 { |
|
174 TTime birthDayYear = iUnifiedEditor.Edited().EventDateTime(); |
|
175 SetDateField( ECalenEditorStartDate, birthDayYear, ETrue ); |
|
176 } |
|
177 break; |
|
178 case CCalEntry::EAppt: |
|
179 { |
|
180 if( iUnifiedEditor.Edited().IsAllDayEvent() ) |
|
181 { |
|
182 iAllDayField->SetDataToEditorL(); |
|
183 } |
|
184 else |
|
185 { |
|
186 // Entry is Non-AllDay event |
|
187 TTime firstRDate; |
|
188 TTime rruleEndTime ; |
|
189 TTimeIntervalMinutes duration; |
|
190 |
|
191 TTime entryStartTime = iUnifiedEditor.Edited().StartDateTime(); |
|
192 TTime entryEndTime = iUnifiedEditor.Edited().EndDateTime(); |
|
193 |
|
194 User::LeaveIfError( entryEndTime.MinutesFrom( entryStartTime, duration ) ); |
|
195 |
|
196 ReadRrule(firstRDate,rruleEndTime); |
|
197 |
|
198 if( firstRDate <= entryStartTime) |
|
199 { |
|
200 SetTimeField( ECalenEditorStartTime, firstRDate, ETrue ); |
|
201 SetTimeField( ECalenEditorEndTime, rruleEndTime, ETrue ); |
|
202 SetDateField( ECalenEditorStartDate, firstRDate, ETrue); |
|
203 SetDateField( ECalenEditorEndDate, rruleEndTime, ETrue); |
|
204 } |
|
205 else{ |
|
206 SetTimeField( ECalenEditorStartTime, entryStartTime, ETrue ); |
|
207 SetTimeField( ECalenEditorEndTime, entryEndTime, ETrue ); |
|
208 SetDateField( ECalenEditorStartDate, entryStartTime, ETrue); |
|
209 SetDateField( ECalenEditorEndDate, entryEndTime, ETrue); |
|
210 } |
|
211 } |
|
212 |
|
213 } |
|
214 break; |
|
215 case CCalEntry::ETodo: |
|
216 { |
|
217 TTime dueDate = iUnifiedEditor.Edited().EventDateTime(); |
|
218 |
|
219 // update date field with todays date |
|
220 SetDateField(ECalenEditorStartDate, dueDate, ETrue); |
|
221 // set priority field value |
|
222 iPriorityField->SetDataToEditorL(); |
|
223 |
|
224 } |
|
225 break; |
|
226 default: |
|
227 break; |
|
228 } |
|
229 |
|
230 iReminderField->SetDataToEditorL(); |
|
231 |
|
232 // Anniversary, To-do, exceptional and single instance of repeat entry |
|
233 // do not have Repeat field. |
|
234 if( CCalEntry::EAnniv != iUnifiedEditor.GetEntryType() |
|
235 && CCalEntry::ETodo != iUnifiedEditor.GetEntryType() ) |
|
236 { |
|
237 iRepeatField->SetDataToEditorL(); |
|
238 } |
|
239 |
|
240 iDbField->SetDataToEditorL(); |
|
241 |
|
242 if( CCalEntry::ETodo != iUnifiedEditor.GetEntryType() ) |
|
243 { |
|
244 TPtrC location = iUnifiedEditor.Edited().Location().Left( |
|
245 iUnifiedEditor.MaxTextEditorLength() ); |
|
246 iUnifiedEditor.SetEditorTextL( ECalenEditorPlace, &location ); |
|
247 } |
|
248 |
|
249 // TODO: Uncomment this when enabling attachment support |
|
250 iUnifiedEditor.SetAttachmentNamesToEditorL(); |
|
251 |
|
252 TRACE_EXIT_POINT; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // CCalenUnifiedEditorControl::AddDefaultEditorL |
|
257 // Adds editor fields |
|
258 // ----------------------------------------------------------------------------- |
|
259 // |
|
260 void CCalenUnifiedEditorControl::AddDefaultEditorL() |
|
261 { |
|
262 TRACE_ENTRY_POINT; |
|
263 |
|
264 switch( iUnifiedEditor.GetEntryType() ) |
|
265 { |
|
266 case CCalEntry::EEvent: |
|
267 { |
|
268 AddDefaultMeetingEditorL(); |
|
269 } |
|
270 break; |
|
271 case CCalEntry::EAnniv: |
|
272 { |
|
273 AddDefaultBirthDayEditorL(); |
|
274 } |
|
275 break; |
|
276 case CCalEntry::EAppt: |
|
277 { |
|
278 AddDefaultMeetingEditorL(); |
|
279 } |
|
280 break; |
|
281 case CCalEntry::ETodo: |
|
282 { |
|
283 AddDefaultTodoEditorL(); |
|
284 } |
|
285 break; |
|
286 default: |
|
287 break; |
|
288 } |
|
289 |
|
290 TRACE_EXIT_POINT; |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CCalenUnifiedEditorControl::InitDefaultEditorsL |
|
295 // Initialise default editor contents |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CCalenUnifiedEditorControl::InitDefaultEditorsL() |
|
299 { |
|
300 TRACE_ENTRY_POINT; |
|
301 |
|
302 // Set editor lengths |
|
303 CEikEdwin* edwin = static_cast<CEikEdwin*>( iUnifiedEditor.Control( ECalenEditorSubject ) ); |
|
304 edwin->SetTextLimit( iUnifiedEditor.MaxTextEditorLength() ); |
|
305 |
|
306 iEventTypeField->InitEventTypeFieldLayoutL(); |
|
307 |
|
308 //Currently nothig to be initalized |
|
309 //as its intial value depend on entry |
|
310 iAllDayField->InitAllDayFieldLayoutL(); |
|
311 |
|
312 |
|
313 iReminderField->InitReminderFieldLdayoutL(); |
|
314 |
|
315 // To Initialise priority field for meeting tyrpe entry |
|
316 if( CCalEntry::ETodo == iUnifiedEditor.GetEntryType() ) |
|
317 { |
|
318 iPriorityField->InitPriorityFieldLayoutL(); |
|
319 } |
|
320 |
|
321 // Initialise repeat field, if it's not Anniversary. |
|
322 // To-do entry don't have repeat field, for now |
|
323 if( CCalEntry::EAnniv != iUnifiedEditor.GetEntryType() && |
|
324 CCalEntry::ETodo != iUnifiedEditor.GetEntryType() ) |
|
325 { |
|
326 iRepeatField->InitRepetFieldLayoutL(); |
|
327 } |
|
328 |
|
329 iDbField->InitDbFieldLayoutL(); |
|
330 iDescription->InitDescritpionFieldLayoutL(); |
|
331 |
|
332 TRACE_EXIT_POINT; |
|
333 } |
|
334 |
|
335 // ----------------------------------------------------------------------------- |
|
336 // CCalenUnifiedEditorControl::AddDefaultBirthDayEditorL |
|
337 // Add collapsed birthday editor contents |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 void CCalenUnifiedEditorControl::AddDefaultBirthDayEditorL() |
|
341 { |
|
342 TRACE_ENTRY_POINT; |
|
343 // event type, subject, date & year,more details |
|
344 |
|
345 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
346 ECalenEditorStartDate, ECalenEditorSubject ); |
|
347 |
|
348 // "Start Date" Label should be "Date of Birth" for Birthday |
|
349 iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, |
|
350 R_QTN_CALEN_EDITOR_DATE_OF_BIRTH ); |
|
351 |
|
352 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM, |
|
353 ECalenEditorReminder, ECalenEditorStartDate ); |
|
354 |
|
355 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PLACE_ITEM, |
|
356 ECalenEditorPlace, ECalenEditorReminder ); |
|
357 /* iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PEOPLE_ITEM, |
|
358 ECalenEditorPeople, ECalenEditorPlace ); |
|
359 */ iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM, |
|
360 ECalenEditorDBName, ECalenEditorPlace ); |
|
361 |
|
362 // TODO: Uncomment this when enabling attachment support |
|
363 // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement |
|
364 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ATTACHMENT_ITEM, |
|
365 ECalenEditorAttachment, ECalenEditorDBName ); |
|
366 |
|
367 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DESCRIPTION_ITEM, |
|
368 ECalenEditorDescription, ECalenEditorAttachment ); |
|
369 |
|
370 TRACE_EXIT_POINT; |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CCalenUnifiedEditorControl::AddDefaultMeetingEditorL |
|
375 // Add meeting editor contents |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 void CCalenUnifiedEditorControl::AddDefaultMeetingEditorL() |
|
379 { |
|
380 TRACE_ENTRY_POINT; |
|
381 // non all day event |
|
382 // event type,subject,all day,start time,end time,start date, |
|
383 // end date,place,more details |
|
384 |
|
385 // all day event |
|
386 // subject,event type,all day,start date,end date,place,more details |
|
387 |
|
388 |
|
389 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ALL_DAY_ITEM, |
|
390 ECalenEditorAllDayItem, ECalenEditorSubject ); |
|
391 |
|
392 if( !iUnifiedEditor.Edited().IsAllDayEvent() ) |
|
393 { |
|
394 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_TIME_ITEM, |
|
395 ECalenEditorStartTime, ECalenEditorAllDayItem ); |
|
396 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_TIME_ITEM, |
|
397 ECalenEditorEndTime, ECalenEditorStartTime ); |
|
398 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
399 ECalenEditorStartDate, ECalenEditorEndTime ); |
|
400 } |
|
401 else |
|
402 { |
|
403 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
404 ECalenEditorStartDate, ECalenEditorAllDayItem ); |
|
405 } |
|
406 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM, |
|
407 ECalenEditorEndDate, ECalenEditorStartDate ); |
|
408 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PLACE_ITEM, |
|
409 ECalenEditorPlace, ECalenEditorEndDate ); |
|
410 |
|
411 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM, |
|
412 ECalenEditorReminder, ECalenEditorPlace ); |
|
413 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REPEAT_ITEM, |
|
414 ECalenEditorRepeat, ECalenEditorReminder ); |
|
415 /*iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PEOPLE_ITEM, |
|
416 ECalenEditorPeople, ECalenEditorRepeat ); |
|
417 */ |
|
418 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM, |
|
419 ECalenEditorDBName, ECalenEditorRepeat ); |
|
420 |
|
421 // TODO: Uncomment this when enabling attachment support |
|
422 // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement |
|
423 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ATTACHMENT_ITEM, |
|
424 ECalenEditorAttachment, ECalenEditorDBName ); |
|
425 |
|
426 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DESCRIPTION_ITEM, |
|
427 ECalenEditorDescription, ECalenEditorAttachment ); |
|
428 |
|
429 TRACE_EXIT_POINT; |
|
430 } |
|
431 |
|
432 // ----------------------------------------------------------------------------- |
|
433 // CCalenUnifiedEditorControl::AddDefaultTodoEditorL |
|
434 // Add collapsed todo editor contents |
|
435 // ----------------------------------------------------------------------------- |
|
436 // |
|
437 void CCalenUnifiedEditorControl::AddDefaultTodoEditorL() |
|
438 { |
|
439 TRACE_ENTRY_POINT; |
|
440 // event type,subject,due date,more details |
|
441 |
|
442 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
443 ECalenEditorStartDate, ECalenEditorSubject ); |
|
444 |
|
445 // "Start Date" Label should be "Due date" for To-Do |
|
446 iUnifiedEditor.SetControlCaptionL( ECalenEditorStartDate, |
|
447 R_QTN_CALEN_EDITOR_DUE_DATE ); |
|
448 |
|
449 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_ITEM, |
|
450 ECalenEditorReminder, ECalenEditorStartDate ); |
|
451 |
|
452 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_PRIORITY_ITEM, |
|
453 ECalenEditorPriority, ECalenEditorReminder ); |
|
454 |
|
455 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DB_NAME_ITEM, |
|
456 ECalenEditorDBName, ECalenEditorPriority ); |
|
457 |
|
458 // TODO: Uncomment this when enabling attachment support |
|
459 // Replace ECalenEditorDBName with ECalenEditorAttachment in the next statement |
|
460 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_ATTACHMENT_ITEM, |
|
461 ECalenEditorAttachment, ECalenEditorDBName ); |
|
462 |
|
463 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_DESCRIPTION_ITEM, |
|
464 ECalenEditorDescription, ECalenEditorAttachment ); |
|
465 |
|
466 TRACE_EXIT_POINT; |
|
467 } |
|
468 |
|
469 // ----------------------------------------------------------------------------- |
|
470 // CCalenUnifiedEditorControl::SetTimeField |
|
471 // Sets the time field in touch layouts |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CCalenUnifiedEditorControl::SetTimeField( TInt aControlId, const TTime& aTime , |
|
475 TBool aDoDraw ) |
|
476 { |
|
477 TRACE_ENTRY_POINT; |
|
478 |
|
479 CEikTimeEditor* timeField = |
|
480 static_cast<CEikTimeEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) ); |
|
481 if( timeField ) |
|
482 { |
|
483 timeField->SetTime( aTime ); |
|
484 if ( aDoDraw ) |
|
485 { |
|
486 timeField->DrawDeferred(); |
|
487 } |
|
488 } |
|
489 |
|
490 TRACE_EXIT_POINT; |
|
491 } |
|
492 |
|
493 // ----------------------------------------------------------------------------- |
|
494 // CCalenUnifiedEditorControl::SetDateField |
|
495 // Sets a date field to the given TTime. |
|
496 // ----------------------------------------------------------------------------- |
|
497 // |
|
498 void CCalenUnifiedEditorControl::SetDateField( TInt aControlId, const TTime& aTime, |
|
499 TBool aDoDraw ) |
|
500 { |
|
501 TRACE_ENTRY_POINT; |
|
502 |
|
503 CEikDateEditor* dateField = NULL; |
|
504 dateField = static_cast<CEikDateEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) ); |
|
505 if( dateField ) |
|
506 { |
|
507 dateField->SetDate( aTime ); |
|
508 if( aDoDraw ) |
|
509 { |
|
510 dateField->DrawDeferred(); |
|
511 } |
|
512 } |
|
513 |
|
514 TRACE_EXIT_POINT; |
|
515 } |
|
516 |
|
517 // ----------------------------------------------------------------------------- |
|
518 // CCalenUnifiedEditorControl::SetDateTimeField |
|
519 // Update date and time field |
|
520 // ----------------------------------------------------------------------------- |
|
521 void CCalenUnifiedEditorControl::SetDateTimeField( TInt aControlId, const TTime& aTime, |
|
522 TBool aDoDraw ) |
|
523 { |
|
524 TRACE_ENTRY_POINT; |
|
525 |
|
526 CEikTimeAndDateEditor* dateTimeField = NULL; |
|
527 dateTimeField = static_cast<CEikTimeAndDateEditor*>( iUnifiedEditor.ControlOrNull( aControlId ) ); |
|
528 if( dateTimeField ) |
|
529 { |
|
530 dateTimeField->SetTimeAndDate( aTime ); |
|
531 if( aDoDraw ) |
|
532 { |
|
533 dateTimeField->DrawDeferred(); |
|
534 } |
|
535 } |
|
536 |
|
537 TRACE_EXIT_POINT; |
|
538 } |
|
539 |
|
540 // ----------------------------------------------------------------------------- |
|
541 // CCalenUnifiedEditorControl::SetAlarmFieldOnOffL |
|
542 // Set alarm field on or off |
|
543 // ----------------------------------------------------------------------------- |
|
544 // |
|
545 void CCalenUnifiedEditorControl::SetAlarmFieldOnOffL( TBool aOnOff ) |
|
546 { |
|
547 TRACE_ENTRY_POINT; |
|
548 |
|
549 iUnifiedEditor.SetAlarmFieldOnOffL( aOnOff ); |
|
550 |
|
551 TRACE_EXIT_POINT; |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CCalenUnifiedEditorControl::SetAlarmFieldOnOffL |
|
556 // Set alarm field on or off |
|
557 // ----------------------------------------------------------------------------- |
|
558 // |
|
559 void CCalenUnifiedEditorControl::SetAllDayFieldL( TBool aYesNo ) |
|
560 { |
|
561 TRACE_ENTRY_POINT; |
|
562 |
|
563 iUnifiedEditor.SetAllDayFieldL( aYesNo ); |
|
564 |
|
565 TRACE_EXIT_POINT; |
|
566 } |
|
567 |
|
568 |
|
569 // ----------------------------------------------------------------------------- |
|
570 // CCalenUnifiedEditorControl::IsAlarmActiveInForm |
|
571 // Check for whether alarm is activated or not |
|
572 // ----------------------------------------------------------------------------- |
|
573 // |
|
574 TBool CCalenUnifiedEditorControl::IsAlarmActiveInForm() |
|
575 { |
|
576 TRACE_ENTRY_POINT; |
|
577 TRACE_EXIT_POINT; |
|
578 return iReminderField->IsAlarmActiveInForm(); |
|
579 } |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // CCalenUnifiedEditorControl::CheckAlarmActive |
|
583 // check alarm active based on the input |
|
584 // ----------------------------------------------------------------------------- |
|
585 // |
|
586 void CCalenUnifiedEditorControl::CheckAlarmActive( TBool aActive ) |
|
587 { |
|
588 TRACE_ENTRY_POINT; |
|
589 |
|
590 iReminderField->CheckAlarmActive( aActive ); |
|
591 |
|
592 TRACE_EXIT_POINT |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CCalenUnifiedEditorControl::IsAllDayEvent |
|
597 // To check value of AllDay field |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 TBool CCalenUnifiedEditorControl::IsAllDayEvent() |
|
601 { |
|
602 TRACE_ENTRY_POINT; |
|
603 |
|
604 return iAllDayField->IsAllDayEvent(); |
|
605 |
|
606 TRACE_EXIT_POINT; |
|
607 } |
|
608 |
|
609 // ----------------------------------------------------------------------------- |
|
610 // CCalenUnifiedEditorControl::SetAllDayEvent |
|
611 // To Set AllDay field value |
|
612 // ----------------------------------------------------------------------------- |
|
613 // |
|
614 void CCalenUnifiedEditorControl::SetAllDayEvent( TBool aActive ) |
|
615 { |
|
616 TRACE_ENTRY_POINT; |
|
617 |
|
618 iAllDayField->SetAllDayEvent( aActive ); |
|
619 |
|
620 TRACE_EXIT_POINT |
|
621 } |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // CCalenUnifiedEditorControl::HandleControlStateChangeL |
|
625 // Handles a state change in the control with id aControlId. |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 void CCalenUnifiedEditorControl::HandleControlStateChangeL( TInt aControlId ) |
|
629 { |
|
630 TRACE_ENTRY_POINT; |
|
631 |
|
632 switch( aControlId ) |
|
633 { |
|
634 case ECalenEditorEventType: |
|
635 { |
|
636 iEventTypeField->HandleControlStateChangeL( aControlId ); |
|
637 } |
|
638 break; |
|
639 case ECalenEditorReminder: |
|
640 { |
|
641 iReminderField->HandleControlStateChangeL( aControlId ); |
|
642 } |
|
643 break; |
|
644 case ECalenEditorRepeat: |
|
645 { |
|
646 iRepeatField->HandleControlStateChangeL( aControlId ); |
|
647 } |
|
648 break; |
|
649 case ECalenEditorDBName: |
|
650 { |
|
651 iDbField->HandleControlStateChangeL( aControlId ); |
|
652 } |
|
653 break; |
|
654 default: |
|
655 break; |
|
656 } |
|
657 |
|
658 TRACE_EXIT_POINT; |
|
659 } |
|
660 |
|
661 // ----------------------------------------------------------------------------- |
|
662 // CCalenUnifiedEditorControl::PrepareForFocusTransitionL |
|
663 // Tries to change focus to the specified line. |
|
664 // ----------------------------------------------------------------------------- |
|
665 // |
|
666 void CCalenUnifiedEditorControl::PrepareForFocusTransitionL( TInt aFocusedId ) |
|
667 { |
|
668 switch( aFocusedId ) |
|
669 { |
|
670 case ECalenEditorSubject: |
|
671 { |
|
672 ReadSubjectFromEditorL(); |
|
673 } |
|
674 break; |
|
675 case ECalenEditorEventType: |
|
676 { |
|
677 iEventTypeField->PrepareForFocusTransitionL( aFocusedId ); |
|
678 } |
|
679 break; |
|
680 |
|
681 case ECalenEditorStartTime: |
|
682 case ECalenEditorStartDate: |
|
683 { |
|
684 ReadStartDateTimeFromEditorL( ETrue, aFocusedId ); |
|
685 UpdateMeetingDurationL(); |
|
686 } |
|
687 break; |
|
688 |
|
689 case ECalenEditorEndDate: |
|
690 case ECalenEditorEndTime: |
|
691 { |
|
692 ReadEndDateTimeFromEditorL( ETrue ); |
|
693 UpdateMeetingDurationL(); |
|
694 } |
|
695 break; |
|
696 |
|
697 case ECalenEditorBirthDayYear: |
|
698 break; |
|
699 |
|
700 case ECalenEditorDueDate: |
|
701 break; |
|
702 |
|
703 // todo: Need to check, ECalenEditorDueDate can be removed? |
|
704 case ECalenEditorAllDayItem: |
|
705 { |
|
706 iAllDayField->PrepareForFocusTransitionL( aFocusedId ); |
|
707 } |
|
708 break; |
|
709 |
|
710 case ECalenEditorPriority: |
|
711 { |
|
712 iPriorityField->PrepareForFocusTransitionL( aFocusedId ); |
|
713 } |
|
714 break; |
|
715 |
|
716 case ECalenEditorPlace: |
|
717 { |
|
718 ReadPlaceFieldFromEditorL( ETrue ); |
|
719 } |
|
720 break; |
|
721 |
|
722 case ECalenEditorRepeat: |
|
723 { |
|
724 iRepeatField->PrepareForFocusTransitionL( aFocusedId ); |
|
725 } |
|
726 break; |
|
727 |
|
728 case ECalenEditorDBName: |
|
729 { |
|
730 iDbField->PrepareForFocusTransitionL( aFocusedId ); |
|
731 } |
|
732 break; |
|
733 case ECalenEditorAttachment: |
|
734 break; |
|
735 case ECalenEditorDescription: |
|
736 break; |
|
737 default: |
|
738 break; |
|
739 } |
|
740 |
|
741 iReminderField->PrepareForFocusTransitionL( aFocusedId ); |
|
742 |
|
743 } |
|
744 |
|
745 // ----------------------------------------------------------------------------- |
|
746 // CCalenUnifiedEditorControl::OnEventTypeChangedL |
|
747 // Handles event type changed |
|
748 // ----------------------------------------------------------------------------- |
|
749 // |
|
750 void CCalenUnifiedEditorControl::OnEventTypeChangedL( CCalEntry::TType aNewEventType ) |
|
751 { |
|
752 TRACE_ENTRY_POINT; |
|
753 |
|
754 // update Entry type of Edited entry |
|
755 iUnifiedEditor.Edited().SetEntryType( aNewEventType ); |
|
756 |
|
757 // Delete, previous entry type fields from editor |
|
758 DeletePreviousEntryTypeFieldsL(); |
|
759 |
|
760 // Add new fiedls to editor |
|
761 AddNewEntryTypeFieldsL( aNewEventType ); |
|
762 iUnifiedEditor.SetEntryType( aNewEventType ); |
|
763 |
|
764 // after changing the event type, update the fields with default values |
|
765 InitDefaultEditorsL(); |
|
766 SetDataToEditorL(); |
|
767 |
|
768 iUnifiedEditor.UpdateFormL(); |
|
769 |
|
770 TRACE_EXIT_POINT; |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CCalenUnifiedEditorControl::DeletePreviousEntryTypeFieldsL |
|
775 // Delete previous entry type fields on selcting |
|
776 // the new entry type |
|
777 // ----------------------------------------------------------------------------- |
|
778 // |
|
779 void CCalenUnifiedEditorControl::DeletePreviousEntryTypeFieldsL() |
|
780 { |
|
781 TRACE_ENTRY_POINT; |
|
782 CCalEntry::TType previousEntryType = iUnifiedEditor.GetEntryType(); |
|
783 switch( previousEntryType ) |
|
784 { |
|
785 case CCalEntry::EEvent: |
|
786 { |
|
787 // Delete AllDay, StartDate, EndDate, and Place fields |
|
788 iUnifiedEditor.DeleteLine( ECalenEditorAllDayItem, ETrue ); |
|
789 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, ETrue ); |
|
790 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, ETrue ); |
|
791 iUnifiedEditor.DeleteLine( ECalenEditorPlace, ETrue ); |
|
792 } |
|
793 break; |
|
794 case CCalEntry::EAnniv: |
|
795 { |
|
796 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, ETrue ); |
|
797 } |
|
798 break; |
|
799 case CCalEntry::EAppt: |
|
800 { |
|
801 if( iUnifiedEditor.Edited().IsAllDayEvent() ) |
|
802 { |
|
803 // Delete, AllDay event fields from Editor |
|
804 iUnifiedEditor.DeleteLine( ECalenEditorAllDayItem, ETrue ); |
|
805 } |
|
806 else |
|
807 { |
|
808 // Delete, Non-AllDay event fields from Editor |
|
809 iUnifiedEditor.DeleteLine( ECalenEditorAllDayItem, ETrue ); |
|
810 iUnifiedEditor.DeleteLine( ECalenEditorStartTime, ETrue ); |
|
811 iUnifiedEditor.DeleteLine( ECalenEditorEndTime, ETrue ); |
|
812 } |
|
813 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, ETrue ); |
|
814 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, ETrue ); |
|
815 iUnifiedEditor.DeleteLine( ECalenEditorPlace, ETrue ); |
|
816 |
|
817 |
|
818 } |
|
819 break; |
|
820 case CCalEntry::ETodo: |
|
821 { |
|
822 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, ETrue ); |
|
823 iUnifiedEditor.DeleteLine( ECalenEditorPriority, ETrue ); |
|
824 } |
|
825 break; |
|
826 default: |
|
827 break; |
|
828 } |
|
829 |
|
830 // Delete, extra fields added to editor for more entry details |
|
831 DeleteExtendedEntryFields( previousEntryType ); |
|
832 |
|
833 TRACE_EXIT_POINT; |
|
834 } |
|
835 |
|
836 // ----------------------------------------------------------------------------- |
|
837 // CCalenUnifiedEditorControl::DeleteExtendedEntryfields |
|
838 // Delete previous entry type more information fields |
|
839 // ----------------------------------------------------------------------------- |
|
840 // |
|
841 void CCalenUnifiedEditorControl::DeleteExtendedEntryFields( CCalEntry::TType aPreviousEntryType ) |
|
842 { |
|
843 |
|
844 // If Reminder field is in 'ON' state, delete Reminder Date, time fields |
|
845 if( iReminderField->IsAlarmActiveInForm() ) |
|
846 { |
|
847 CCoeControl* alarmDateCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorReminderDate ); |
|
848 CCoeControl* alarmTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorReminderTime ); |
|
849 |
|
850 if( alarmTimeCtrl ) |
|
851 { |
|
852 iUnifiedEditor.DeleteLine( ECalenEditorReminderTime, ETrue ); |
|
853 } |
|
854 if( alarmDateCtrl ) |
|
855 { |
|
856 iUnifiedEditor.DeleteLine( ECalenEditorReminderDate, ETrue ); |
|
857 } |
|
858 } |
|
859 |
|
860 iUnifiedEditor.DeleteLine( ECalenEditorReminder ); |
|
861 |
|
862 /*CCoeControl* PeopleFieldCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorPeople ); |
|
863 if( PeopleFieldCtrl ) |
|
864 { |
|
865 iUnifiedEditor.DeleteLine( ECalenEditorPeople ); |
|
866 } |
|
867 */ |
|
868 iUnifiedEditor.DeleteLine( ECalenEditorDBName ); |
|
869 |
|
870 // TODO: Uncomment this when enabling attachment support |
|
871 iUnifiedEditor.DeleteLine( ECalenEditorAttachment ); |
|
872 |
|
873 iUnifiedEditor.DeleteLine( ECalenEditorDescription ); |
|
874 |
|
875 // To-Do do not have place field |
|
876 CCoeControl* editorPlaceCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorPlace ); |
|
877 if( editorPlaceCtrl ) |
|
878 { |
|
879 iUnifiedEditor.DeleteLine( ECalenEditorPlace ); |
|
880 } |
|
881 |
|
882 // Anniversary & To-Do entry, do not have Repeat field |
|
883 if( ( aPreviousEntryType != CCalEntry::EAnniv ) || |
|
884 ( aPreviousEntryType != CCalEntry::ETodo ) ) |
|
885 { |
|
886 // Delete Repeat field. |
|
887 CCoeControl* repeatCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeat ); |
|
888 CCoeControl* repeatUntilCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeatUntil ); |
|
889 if( repeatCtrl ) |
|
890 { |
|
891 iUnifiedEditor.DeleteLine( ECalenEditorRepeat ); |
|
892 } |
|
893 if( repeatUntilCtrl ) |
|
894 { |
|
895 iUnifiedEditor.DeleteLine( ECalenEditorRepeatUntil ); |
|
896 } |
|
897 } |
|
898 } |
|
899 |
|
900 // ----------------------------------------------------------------------------- |
|
901 // CCalenUnifiedEditorControl::AddNewEntryTypeFieldsL |
|
902 // Add new entry type's editor fields |
|
903 // ----------------------------------------------------------------------------- |
|
904 // |
|
905 void CCalenUnifiedEditorControl::AddNewEntryTypeFieldsL( CCalEntry::TType aNewEventType ) |
|
906 { |
|
907 TRACE_ENTRY_POINT; |
|
908 |
|
909 switch( aNewEventType ) |
|
910 { |
|
911 case CCalEntry::EEvent: |
|
912 case CCalEntry::EAppt: |
|
913 { |
|
914 AddDefaultMeetingEditorL(); |
|
915 } |
|
916 break; |
|
917 case CCalEntry::EAnniv: |
|
918 { |
|
919 AddDefaultBirthDayEditorL(); |
|
920 } |
|
921 break; |
|
922 case CCalEntry::ETodo: |
|
923 { |
|
924 AddDefaultTodoEditorL(); |
|
925 } |
|
926 break; |
|
927 default: |
|
928 break; |
|
929 } |
|
930 TRACE_EXIT_POINT; |
|
931 } |
|
932 |
|
933 // ----------------------------------------------------------------------------- |
|
934 // CCalenUnifiedEditorControl::AskRepeatingNoteQueriesL |
|
935 // Add new entry type's editor fields |
|
936 // ----------------------------------------------------------------------------- |
|
937 // |
|
938 CCalenEditorDataHandler::TError CCalenUnifiedEditorControl::AskRepeatingNoteQueriesL( |
|
939 CalCommon::TRecurrenceRange& aRepeatType ) |
|
940 { |
|
941 TRACE_ENTRY_POINT; |
|
942 TRACE_EXIT_POINT; |
|
943 return iRepeatField->AskRepeatingNoteQueriesL( aRepeatType ); |
|
944 |
|
945 } |
|
946 |
|
947 // ----------------------------------------------------------------------------- |
|
948 // CCalenUnifiedEditorControl::ReadDataFromEditorL |
|
949 // Reads editor data mainly for collapsed editor |
|
950 // ----------------------------------------------------------------------------- |
|
951 // |
|
952 void CCalenUnifiedEditorControl::ReadDataFromEditorL( TBool aContinueOnError ) |
|
953 { |
|
954 TRACE_ENTRY_POINT; |
|
955 // Read data from the editor |
|
956 ReadSubjectFromEditorL(); |
|
957 ReadStartDateTimeFromEditorL( aContinueOnError ); |
|
958 ReadEndDateTimeFromEditorL( aContinueOnError ); |
|
959 |
|
960 // ToDo do not have Place field |
|
961 if( iUnifiedEditor.GetEntryType() != CCalEntry::ETodo ) |
|
962 { |
|
963 ReadPlaceFieldFromEditorL( aContinueOnError ); |
|
964 } |
|
965 |
|
966 // TODO: Uncomment this when enabling attachment support |
|
967 ReadAttachmentFieldFromEditorL( aContinueOnError ); |
|
968 ReadDescriptionFieldFromEditorL( aContinueOnError ); |
|
969 |
|
970 iReminderField->ReadDataFromFormL( aContinueOnError ); |
|
971 |
|
972 if( iUnifiedEditor.GetEntryType() == CCalEntry::ETodo ) |
|
973 { |
|
974 iUnifiedEditor.Edited().SetNonRepeatingL(); |
|
975 iPriorityField->ReadDataFromFormL( aContinueOnError ); |
|
976 } |
|
977 else |
|
978 { |
|
979 // Anniversary, Exceptional and Single instance of repeat enty |
|
980 // do not have repeat field in editor |
|
981 CCoeControl* repeatCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeat ); |
|
982 if( repeatCtrl ) |
|
983 { |
|
984 iRepeatField->ReadDataFromFormL( aContinueOnError ); |
|
985 } |
|
986 } |
|
987 |
|
988 iDbField->ReadDataFromFormL( aContinueOnError ); |
|
989 |
|
990 TRACE_EXIT_POINT; |
|
991 } |
|
992 |
|
993 // ----------------------------------------------------------------------------- |
|
994 // CCalenUnifiedEditorControl::ReadSubjectFromEditorL |
|
995 // Reads subject field from editor |
|
996 // ----------------------------------------------------------------------------- |
|
997 // |
|
998 void CCalenUnifiedEditorControl::ReadSubjectFromEditorL() |
|
999 { |
|
1000 TRACE_ENTRY_POINT; |
|
1001 iUnifiedEditor.ReadSubjectFromEditorL(); |
|
1002 TRACE_ENTRY_POINT; |
|
1003 } |
|
1004 |
|
1005 // ----------------------------------------------------------------------------- |
|
1006 // CCalenUnifiedEditorControl::ReadStartDateTimeFromEditorL |
|
1007 // Reads start date time from the editor |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // |
|
1010 void CCalenUnifiedEditorControl::ReadStartDateTimeFromEditorL( TBool aContinueOnError , TInt /* aFocusedId */ ) |
|
1011 { |
|
1012 TRACE_ENTRY_POINT; |
|
1013 |
|
1014 TTime start = iUnifiedEditor.Edited().StartDateTime(); |
|
1015 TDateTime startDT = start.DateTime(); |
|
1016 |
|
1017 // Reading time field leaves, if it contains empty values. |
|
1018 // When editors are forced to exit, we want to continue reading |
|
1019 // other fields, even if one time field contains empty values |
|
1020 if( aContinueOnError ) |
|
1021 { |
|
1022 PIM_TRAPD_HANDLE( ( start = GetStartDateTimeL() ) ); |
|
1023 } |
|
1024 else |
|
1025 { |
|
1026 // Allow this function to leave. |
|
1027 start = GetStartDateTimeL(); |
|
1028 } |
|
1029 startDT = start.DateTime(); |
|
1030 iUnifiedEditor.Edited().SetStartDateTimeL( start ); |
|
1031 |
|
1032 UpdateEndTimeL(); |
|
1033 |
|
1034 TRACE_EXIT_POINT; |
|
1035 } |
|
1036 |
|
1037 // ----------------------------------------------------------------------------- |
|
1038 // CCalenUnifiedEditorControl::ReadStartDateTimeFromEditorL |
|
1039 // Reads End date time from the editor |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // |
|
1042 void CCalenUnifiedEditorControl::ReadEndDateTimeFromEditorL( TBool aContinueOnError ) |
|
1043 { |
|
1044 TRACE_ENTRY_POINT; |
|
1045 |
|
1046 TTime end; |
|
1047 TDateTime endDT; |
|
1048 |
|
1049 // Reading time field leaves, if it contains empty values. |
|
1050 // When editors are forced to exit, we want to continue reading |
|
1051 // other fields, even if one time field contains empty values |
|
1052 if( aContinueOnError ) |
|
1053 { |
|
1054 PIM_TRAPD_HANDLE( ( end = GetEndDateTimeL() ) ); |
|
1055 } |
|
1056 else |
|
1057 { |
|
1058 // Allow this function to leave. |
|
1059 end = GetEndDateTimeL(); |
|
1060 } |
|
1061 endDT = end.DateTime(); |
|
1062 |
|
1063 iUnifiedEditor.Edited().SetEndDateTimeL( end ); |
|
1064 |
|
1065 TRACE_EXIT_POINT; |
|
1066 } |
|
1067 |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // CCalenUnifiedEditorControl::GetStartDateTimeL |
|
1070 // Get start date time from editor |
|
1071 // ----------------------------------------------------------------------------- |
|
1072 // |
|
1073 TTime CCalenUnifiedEditorControl::GetStartDateTimeL() |
|
1074 { |
|
1075 TRACE_ENTRY_POINT; |
|
1076 |
|
1077 TTime result = ReadTimeField( ECalenEditorStartDate ); |
|
1078 TDateTime resDT = result.DateTime(); |
|
1079 CCoeControl* startTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorStartTime ); |
|
1080 |
|
1081 // For non-timed event and AllDay event StatTime field |
|
1082 // does n't exit, so do not read StartTime. |
|
1083 if( startTimeCtrl ) |
|
1084 { |
|
1085 TTime timeOfDate = ReadTimeField( ECalenEditorStartTime ); |
|
1086 if( timeOfDate > 0 ) |
|
1087 { |
|
1088 TDateTime timeOfDayTime = timeOfDate.DateTime(); |
|
1089 result += TTimeIntervalHours( timeOfDayTime.Hour() ); |
|
1090 result += TTimeIntervalMinutes( timeOfDayTime.Minute() ); |
|
1091 } |
|
1092 } |
|
1093 else |
|
1094 { |
|
1095 // To set time as beginning of the day |
|
1096 result = CalenDateUtils::BeginningOfDay( result ); |
|
1097 } |
|
1098 |
|
1099 resDT = result.DateTime(); |
|
1100 TRACE_EXIT_POINT; |
|
1101 return result; |
|
1102 } |
|
1103 |
|
1104 // ----------------------------------------------------------------------------- |
|
1105 // CCalenUnifiedEditorControl::GetEndDateTimeL |
|
1106 // Get end date time from editor |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 TTime CCalenUnifiedEditorControl::GetEndDateTimeL() |
|
1110 { |
|
1111 TRACE_ENTRY_POINT; |
|
1112 TTime result; |
|
1113 CCoeControl* endDateCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorEndDate); |
|
1114 if( endDateCtrl ) |
|
1115 { |
|
1116 result = ReadDateField( ECalenEditorEndDate ); |
|
1117 CCoeControl* endTimeCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorEndTime ); |
|
1118 // for AllDay event do not have EndTime |
|
1119 // so, do not read EndTime for them. |
|
1120 if( endTimeCtrl ) |
|
1121 { |
|
1122 TTime timeOfDate = ReadTimeField( ECalenEditorEndTime ); |
|
1123 if( timeOfDate > 0 ) |
|
1124 { |
|
1125 TDateTime timeOfDayTime = timeOfDate.DateTime(); |
|
1126 result += TTimeIntervalHours( timeOfDayTime.Hour() ); |
|
1127 result += TTimeIntervalMinutes( timeOfDayTime.Minute() ); |
|
1128 } |
|
1129 } |
|
1130 else |
|
1131 { |
|
1132 // To set time as beginning of the day |
|
1133 result = CalenDateUtils::BeginningOfDay( result ); |
|
1134 } |
|
1135 |
|
1136 if( iAllDayField->IsAllDayEvent() ) |
|
1137 { |
|
1138 // For allday (1 day) event Eg. "Start:- 12:00am, 15-08-2010 & End:-12:00am, 16-08-2010" |
|
1139 // In Editor it should be displayed as "StartDate: 15-08-2010 & EndDate:15-08-2010" |
|
1140 // But, while saving EndDate is saved as 12:00am, 16-08-2010. |
|
1141 TTime startDate = iUnifiedEditor.Edited().StartDateTime(); |
|
1142 if( result >= startDate ) |
|
1143 { |
|
1144 result += TTimeIntervalDays( KOneDay ); |
|
1145 } |
|
1146 } |
|
1147 |
|
1148 } |
|
1149 else |
|
1150 { |
|
1151 // For entries Anniversary/Todo there is no EndDate field |
|
1152 // For them EndDate is same as StartDate |
|
1153 result = ReadDateField( ECalenEditorStartDate ); |
|
1154 } |
|
1155 |
|
1156 TRACE_EXIT_POINT; |
|
1157 return result; |
|
1158 } |
|
1159 |
|
1160 // ----------------------------------------------------------------------------- |
|
1161 // CCalenUnifiedEditorControl::ReadTimeField |
|
1162 // Reads time from editor |
|
1163 // ----------------------------------------------------------------------------- |
|
1164 // |
|
1165 TTime CCalenUnifiedEditorControl::ReadTimeField( TInt aControlId ) |
|
1166 { |
|
1167 TRACE_ENTRY_POINT; |
|
1168 TRACE_EXIT_POINT; |
|
1169 return static_cast<CEikTTimeEditor*>( iUnifiedEditor.Control( aControlId ) )->GetTTime(); |
|
1170 } |
|
1171 |
|
1172 // ----------------------------------------------------------------------------- |
|
1173 // CCalenUnifiedEditorControl::ReadDateField |
|
1174 // Reads date from editor |
|
1175 // ----------------------------------------------------------------------------- |
|
1176 // |
|
1177 TTime CCalenUnifiedEditorControl::ReadDateField( TInt aControlId ) |
|
1178 { |
|
1179 TRACE_ENTRY_POINT; |
|
1180 TRACE_EXIT_POINT; |
|
1181 return static_cast<CEikDateEditor*>( iUnifiedEditor.Control( aControlId ) )->Date(); |
|
1182 } |
|
1183 |
|
1184 // ----------------------------------------------------------------------------- |
|
1185 // CCalenUnifiedEditorControl::ReadPlaceFieldFromEditorL |
|
1186 // Reads place field from editor |
|
1187 // ----------------------------------------------------------------------------- |
|
1188 // |
|
1189 void CCalenUnifiedEditorControl::ReadPlaceFieldFromEditorL( TBool /*aContinueOnError*/ ) |
|
1190 { |
|
1191 TRACE_ENTRY_POINT; |
|
1192 |
|
1193 iUnifiedEditor.ReadPlaceFromEditorL(); |
|
1194 |
|
1195 TRACE_ENTRY_POINT; |
|
1196 } |
|
1197 |
|
1198 // ----------------------------------------------------------------------------- |
|
1199 // CCalenUnifiedEditorControl::ReadPeopleFieldFromEditorL |
|
1200 // Reads people field from editor |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // |
|
1203 void CCalenUnifiedEditorControl::ReadPeopleFieldFromEditorL( TBool /*aContinueOnError*/ ) |
|
1204 { |
|
1205 TRACE_ENTRY_POINT; |
|
1206 |
|
1207 TRACE_ENTRY_POINT; |
|
1208 } |
|
1209 |
|
1210 // ----------------------------------------------------------------------------- |
|
1211 // CCalenUnifiedEditorControl::ReadAttachmentFieldFromEditorL |
|
1212 // Reads attachment field from editor |
|
1213 // ----------------------------------------------------------------------------- |
|
1214 // |
|
1215 void CCalenUnifiedEditorControl::ReadAttachmentFieldFromEditorL( TBool /*aContinueOnError*/ ) |
|
1216 { |
|
1217 TRACE_ENTRY_POINT; |
|
1218 |
|
1219 TRACE_ENTRY_POINT; |
|
1220 } |
|
1221 |
|
1222 // ----------------------------------------------------------------------------- |
|
1223 // CCalenUnifiedEditorControl::ReadDescriptionFieldFromEditorL |
|
1224 // Reads description field from editor |
|
1225 // ----------------------------------------------------------------------------- |
|
1226 // |
|
1227 void CCalenUnifiedEditorControl::ReadDescriptionFieldFromEditorL( TBool /*aContinueOnError*/ ) |
|
1228 { |
|
1229 TRACE_ENTRY_POINT; |
|
1230 |
|
1231 TRACE_ENTRY_POINT; |
|
1232 } |
|
1233 |
|
1234 // ----------------------------------------------------------------------------- |
|
1235 // CCalenUnifiedEditorControl::Description |
|
1236 // Access to the decription field |
|
1237 // ----------------------------------------------------------------------------- |
|
1238 // |
|
1239 CCalenDescription* CCalenUnifiedEditorControl::Description() |
|
1240 { |
|
1241 TRACE_ENTRY_POINT; |
|
1242 TRACE_EXIT_POINT; |
|
1243 return iDescription; |
|
1244 } |
|
1245 |
|
1246 // ----------------------------------------------------------------------------- |
|
1247 // CCalenUnifiedEditorControl::UpdateLinesOnLocaleChangeL |
|
1248 // Update editor lines on environment change notifications |
|
1249 // ----------------------------------------------------------------------------- |
|
1250 // |
|
1251 void CCalenUnifiedEditorControl::UpdateLinesOnLocaleChangeL() |
|
1252 { |
|
1253 TRACE_ENTRY_POINT; |
|
1254 |
|
1255 TInt lastFocusedItem = iUnifiedEditor.IdOfFocusedControl(); |
|
1256 switch( iUnifiedEditor.GetEntryType() ) |
|
1257 { |
|
1258 case CCalEntry::EEvent: |
|
1259 { |
|
1260 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); |
|
1261 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
1262 ECalenEditorStartDate, ECalenEditorAllDayItem ); |
|
1263 |
|
1264 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse ); |
|
1265 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM, |
|
1266 ECalenEditorEndDate, ECalenEditorStartDate ); |
|
1267 } |
|
1268 break; |
|
1269 |
|
1270 case CCalEntry::EAnniv: |
|
1271 { |
|
1272 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); |
|
1273 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_BIRTHDAY_YEAR_ITEM, |
|
1274 ECalenEditorStartDate, ECalenEditorEventType ); |
|
1275 |
|
1276 } |
|
1277 break; |
|
1278 |
|
1279 case CCalEntry::EAppt: |
|
1280 { |
|
1281 |
|
1282 if( iUnifiedEditor.Edited().IsAllDayEvent() ) |
|
1283 { |
|
1284 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); |
|
1285 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
1286 ECalenEditorStartDate, ECalenEditorAllDayItem ); |
|
1287 |
|
1288 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse ); |
|
1289 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM, |
|
1290 ECalenEditorEndDate, ECalenEditorStartDate ); |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 iUnifiedEditor.DeleteLine( ECalenEditorStartTime, EFalse ); |
|
1295 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_TIME_ITEM, |
|
1296 ECalenEditorStartTime, ECalenEditorAllDayItem ); |
|
1297 |
|
1298 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); |
|
1299 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
1300 ECalenEditorStartDate, ECalenEditorStartTime ); |
|
1301 |
|
1302 iUnifiedEditor.DeleteLine( ECalenEditorEndTime, EFalse ); |
|
1303 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_TIME_ITEM, |
|
1304 ECalenEditorEndTime, ECalenEditorStartDate ); |
|
1305 |
|
1306 iUnifiedEditor.DeleteLine( ECalenEditorEndDate, EFalse ); |
|
1307 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_END_DATE_ITEM, |
|
1308 ECalenEditorEndDate, ECalenEditorEndTime ); |
|
1309 } |
|
1310 |
|
1311 } |
|
1312 break; |
|
1313 |
|
1314 case CCalEntry::ETodo: |
|
1315 { |
|
1316 iUnifiedEditor.DeleteLine( ECalenEditorStartDate, EFalse ); |
|
1317 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_START_DATE_ITEM, |
|
1318 ECalenEditorStartDate, ECalenEditorEventType ); |
|
1319 |
|
1320 } |
|
1321 break; |
|
1322 default: |
|
1323 break; |
|
1324 } |
|
1325 |
|
1326 if( iUnifiedEditor.ControlOrNull( ECalenEditorReminderDate ) ) |
|
1327 { |
|
1328 iUnifiedEditor.DeleteLine( ECalenEditorReminderDate, EFalse ); |
|
1329 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_DATE_ITEM, |
|
1330 ECalenEditorReminderDate, ECalenEditorReminder ); |
|
1331 |
|
1332 } |
|
1333 if( iUnifiedEditor.ControlOrNull( ECalenEditorReminderTime ) ) |
|
1334 { |
|
1335 iUnifiedEditor.DeleteLine( ECalenEditorReminderTime, EFalse ); |
|
1336 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REMINDER_TIME_ITEM, |
|
1337 ECalenEditorReminderTime, ECalenEditorReminderDate ); |
|
1338 } |
|
1339 if( iUnifiedEditor.ControlOrNull( ECalenEditorRepeatUntil ) ) |
|
1340 { |
|
1341 iUnifiedEditor.DeleteLine( ECalenEditorRepeatUntil, EFalse ); |
|
1342 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REPEAT_UNTIL_ITEM, |
|
1343 ECalenEditorRepeatUntil, ECalenEditorRepeat ); |
|
1344 |
|
1345 } |
|
1346 |
|
1347 iUnifiedEditor.TryChangeFocusToL( lastFocusedItem ); |
|
1348 SetDataToEditorL(); |
|
1349 iUnifiedEditor.UpdateFormL(); |
|
1350 TRACE_EXIT_POINT; |
|
1351 } |
|
1352 |
|
1353 TInt CCalenUnifiedEditorControl::GetCalendarIndexForEntryL() |
|
1354 { |
|
1355 TRACE_ENTRY_POINT; |
|
1356 TRACE_EXIT_POINT; |
|
1357 |
|
1358 return iDbField->GetCalendarIndexForEntryL(); |
|
1359 } |
|
1360 |
|
1361 // ----------------------------------------------------------------------------- |
|
1362 // CCalenUnifiedEditorControl::GetCalendarNameForEntryL() |
|
1363 // ----------------------------------------------------------------------------- |
|
1364 // |
|
1365 const TDesC& CCalenUnifiedEditorControl::GetCalendarNameForEntryL() |
|
1366 { |
|
1367 TRACE_ENTRY_POINT; |
|
1368 TRACE_EXIT_POINT; |
|
1369 |
|
1370 return iDbField->GetCalendarNameForEntryL(); |
|
1371 } |
|
1372 |
|
1373 // ----------------------------------------------------------------------------- |
|
1374 // CCalenUnifiedEditorControl::UpdateMeetingDurationL() |
|
1375 // This function leaves if the end date/time is before the start date/time. |
|
1376 // (other items were commented in a header). |
|
1377 // ----------------------------------------------------------------------------- |
|
1378 // |
|
1379 void CCalenUnifiedEditorControl::UpdateMeetingDurationL() |
|
1380 { |
|
1381 TRACE_ENTRY_POINT; |
|
1382 |
|
1383 TTime start = iUnifiedEditor.Edited().StartDateTime(); |
|
1384 TTime end = iUnifiedEditor.Edited().EndDateTime(); |
|
1385 User::LeaveIfError( |
|
1386 end.MinutesFrom(start, iMeetingInterval ) ); |
|
1387 |
|
1388 TRACE_EXIT_POINT; |
|
1389 } |
|
1390 |
|
1391 // ----------------------------------------------------------------------------- |
|
1392 // CCalenUnifiedEditorControl::UpdateEndTimeL() |
|
1393 // Updates the end date/time when the start date/time is changed. |
|
1394 // (other items were commented in a header). |
|
1395 // ----------------------------------------------------------------------------- |
|
1396 // |
|
1397 void CCalenUnifiedEditorControl::UpdateEndTimeL() |
|
1398 { |
|
1399 TRACE_ENTRY_POINT; |
|
1400 |
|
1401 TTime start = iUnifiedEditor.Edited().StartDateTime(); |
|
1402 |
|
1403 // Update EndTime in the Editor for meeting Entry |
|
1404 TTime end = start; |
|
1405 end += iMeetingInterval; |
|
1406 end = CalenDateUtils::LimitToValidTime( end ); |
|
1407 |
|
1408 // update data model |
|
1409 iUnifiedEditor.Edited().SetEndDateTimeL( end ); |
|
1410 |
|
1411 // update form fields |
|
1412 UpdateMeetingDurationL(); |
|
1413 |
|
1414 if( iAllDayField->IsAllDayEvent() && |
|
1415 CCalEntry::EEvent == iUnifiedEditor.Edited().EntryType() ) |
|
1416 { |
|
1417 // For allday (1 day) event Eg. "Start:- 12:00am, 15-08-2010 & End:-12:00am, 16-08-2010" |
|
1418 // In Editor it should be displayed as "StartDate: 15-08-2010 & EndDate:15-08-2010" |
|
1419 // No time filed is displayed. |
|
1420 if ( end > start ) |
|
1421 { |
|
1422 //end -= TTimeIntervalDays( KOneDay ); |
|
1423 //end contains the time component also, even for same day end would be greater then start |
|
1424 //subtracting 1 from end will give end as one day before start. |
|
1425 //For All day event Start date and End Date are same so assigning start to end. |
|
1426 end = start; |
|
1427 } |
|
1428 else if( end == start ) |
|
1429 { |
|
1430 // For allday event minimum duration is 1day. |
|
1431 TTime endDate = start + TTimeIntervalDays( KOneDay ); |
|
1432 iUnifiedEditor.Edited().SetEndDateTimeL( endDate ); |
|
1433 } |
|
1434 } |
|
1435 |
|
1436 SetDateField( ECalenEditorEndDate, end, ETrue ); |
|
1437 SetTimeField( ECalenEditorEndTime, end, ETrue ); |
|
1438 TRACE_EXIT_POINT; |
|
1439 } |
|
1440 |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 // CCalenUnifiedEditorControl::ReadRrule() |
|
1443 // Checks the Rdates and RRule if there is any with the CCalEntry |
|
1444 // (other items were commented in a header). |
|
1445 // ----------------------------------------------------------------------------- |
|
1446 // |
|
1447 void CCalenUnifiedEditorControl::ReadRrule(TTime& firstRdatestartTime, TTime& endTime) |
|
1448 { |
|
1449 TRACE_ENTRY_POINT; |
|
1450 |
|
1451 RArray<TCalTime> rDateList; |
|
1452 CleanupClosePushL( rDateList ); |
|
1453 rDateList = iUnifiedEditor.Edited().GetRdatesL(); |
|
1454 |
|
1455 TInt count = rDateList.Count(); |
|
1456 TBool hasRDates = ( count > 0 ); |
|
1457 |
|
1458 // Get the firstRDate only if the entry has RDates. |
|
1459 if( hasRDates ) |
|
1460 { |
|
1461 firstRdatestartTime = rDateList[ 0 ].TimeLocalL(); |
|
1462 TDateTime firstRDateTime = firstRdatestartTime.DateTime(); |
|
1463 |
|
1464 TTimeIntervalMinutes duration; |
|
1465 TTime entryStartTime = iUnifiedEditor.Edited().StartDateTime(); |
|
1466 TTime entryEndTime = iUnifiedEditor.Edited().EndDateTime(); |
|
1467 |
|
1468 User::LeaveIfError( entryEndTime.MinutesFrom( entryStartTime, duration ) ); |
|
1469 endTime= firstRdatestartTime + duration; |
|
1470 } |
|
1471 else |
|
1472 { |
|
1473 firstRdatestartTime = iUnifiedEditor.Edited().StartDateTime(); |
|
1474 endTime = iUnifiedEditor.Edited().EndDateTime(); |
|
1475 } |
|
1476 |
|
1477 CleanupStack::PopAndDestroy(); |
|
1478 |
|
1479 TRACE_EXIT_POINT; |
|
1480 } |
|
1481 |
|
1482 // End of file |