|
1 /* |
|
2 * Copyright (c) 2002-2004 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 : |
|
15 * |
|
16 */ |
|
17 |
|
18 // user includes |
|
19 #include "calenrepeatfield.h" |
|
20 #include "CalenDefaultEditors.hrh" |
|
21 #include "CalenDescription.h" |
|
22 #include "calennotedatautil.h" |
|
23 #include "calenentryutil.h" |
|
24 #include "CalenEditorDataHandler.h" |
|
25 |
|
26 // system includes |
|
27 #include <AknPopupField.h> |
|
28 #include <AknQueryValueText.h> |
|
29 #include <calentry.h> |
|
30 #include <calrrule.h> |
|
31 #include <calendateutils.h> |
|
32 #include <CalenDefaultEditorsData.rsg> |
|
33 |
|
34 // debug |
|
35 #include "calendarui_debug.h" |
|
36 |
|
37 // CONSTRUCTION AND DESTRUCTION METHODS |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CCalenRepeatField::NewL |
|
41 // (other items were commented in a header). |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CCalenRepeatField* CCalenRepeatField::NewL( CCalenUnifiedEditor& aUnifiedEditor ) |
|
45 { |
|
46 TRACE_ENTRY_POINT; |
|
47 |
|
48 CCalenRepeatField* self = |
|
49 new( ELeave ) CCalenRepeatField( aUnifiedEditor ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop(); |
|
53 |
|
54 TRACE_EXIT_POINT; |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CCalenRepeatField::CCalenRepeatField |
|
60 // (other items were commented in a header). |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CCalenRepeatField::CCalenRepeatField( CCalenUnifiedEditor& aUnifiedEditor ) |
|
64 : iUnifiedEditor( aUnifiedEditor ) |
|
65 { |
|
66 TRACE_ENTRY_POINT; |
|
67 TRACE_EXIT_POINT; |
|
68 } |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CCalenRepeatField::ConstructL |
|
72 // second phase constructor |
|
73 // (other items were commented in a header). |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CCalenRepeatField::ConstructL() |
|
77 { |
|
78 TRACE_ENTRY_POINT; |
|
79 |
|
80 // read resource for confideitiality popup list |
|
81 iRepeatArrayText = iUnifiedEditor.ControlEnv()->ReadDesCArrayResourceL( |
|
82 R_CALEN_EDITOR_REPEAT_POPUP_ITEMS); |
|
83 |
|
84 // create textarray |
|
85 iRepeatArray = CAknQueryValueTextArray::NewL(); |
|
86 iRepeatTextValues = CAknQueryValueText::NewL(); |
|
87 iRepeatArray->SetArray(*iRepeatArrayText); |
|
88 iRepeatTextValues->SetArrayL(iRepeatArray); |
|
89 |
|
90 TRACE_EXIT_POINT; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CCalenRepeatField::~CCalenRepeatField |
|
95 // (other items were commented in a header). |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 CCalenRepeatField::~CCalenRepeatField() |
|
99 { |
|
100 TRACE_ENTRY_POINT; |
|
101 |
|
102 delete iRepeatArrayText; |
|
103 delete iRepeatArray; |
|
104 delete iRepeatTextValues; |
|
105 |
|
106 TRACE_EXIT_POINT; |
|
107 } |
|
108 |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CCalenRepeatField::HandleControlStateChangedL |
|
112 // (other items were commented in a header). |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CCalenRepeatField::HandleControlStateChangeL( TInt aControlId ) |
|
116 { |
|
117 TRACE_ENTRY_POINT; |
|
118 |
|
119 switch (aControlId) |
|
120 { |
|
121 case ECalenEditorRepeat: |
|
122 { |
|
123 NotifyChangeRepeatChoiceL(); |
|
124 break; |
|
125 } |
|
126 default: |
|
127 { |
|
128 break; |
|
129 } |
|
130 } |
|
131 |
|
132 TRACE_EXIT_POINT; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CCalenRepeatField::HandleErrorL |
|
137 // (other items were commented in a header). |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 TBool CCalenRepeatField::HandleErrorL( const TInt& aError ) |
|
141 { |
|
142 TRACE_ENTRY_POINT; |
|
143 |
|
144 TBool handled = EFalse; |
|
145 switch ( aError ) |
|
146 { |
|
147 case CCalenEditorDataHandler::EFormErrRepeatUntilEarlierThanNote: |
|
148 { |
|
149 // ReapetUntill is earlier that note instance |
|
150 iUnifiedEditor.TryChangeFocusToL( ECalenEditorRepeatUntil ); |
|
151 handled = ETrue; |
|
152 break; |
|
153 } |
|
154 case CCalenEditorDataHandler::EFormErrStopTimeEarlierThanStartTime: |
|
155 { |
|
156 TInt newFocusId = ECalenEditorEndDate; |
|
157 |
|
158 // Stop time erarliar that satrt time of event |
|
159 if( CalenDateUtils::OnSameDay( iUnifiedEditor.Edited().StartDateTime(), |
|
160 iUnifiedEditor.Edited().EndDateTime() ) ) |
|
161 { |
|
162 newFocusId = ECalenEditorEndTime; |
|
163 } |
|
164 iUnifiedEditor.TryChangeFocusToL( newFocusId ); |
|
165 |
|
166 handled = ETrue; |
|
167 break; |
|
168 } |
|
169 case CCalenEditorDataHandler::EFormErrCancelSaveRepNoteWhenStartChange: |
|
170 { |
|
171 iUnifiedEditor.TryChangeFocusToL( ECalenEditorStartDate ); |
|
172 handled = ETrue; |
|
173 break; |
|
174 } |
|
175 default: |
|
176 { |
|
177 handled = EFalse; |
|
178 break; |
|
179 } |
|
180 } |
|
181 |
|
182 TRACE_EXIT_POINT; |
|
183 return handled; |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CCalenRepeatField::FormRepeatType |
|
188 // (other items were commented in a header). |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TCalenRepeatIndex CCalenRepeatField::FormRepeatType() |
|
192 { |
|
193 TRACE_ENTRY_POINT; |
|
194 TRACE_EXIT_POINT; |
|
195 return static_cast<TCalenRepeatIndex>( iRepeatTextValues->CurrentValueIndex() ); |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CCalenRepeatField::FormRepeatUntilDateTimeL |
|
200 // (other items were commented in a header). |
|
201 // ----------------------------------------------------------------------------- |
|
202 // |
|
203 TTime CCalenRepeatField::FormRepeatUntilDateTimeL() |
|
204 { |
|
205 TRACE_ENTRY_POINT; |
|
206 TRACE_EXIT_POINT; |
|
207 return iUnifiedEditor.EditorFields().ReadDateField( ECalenEditorRepeatUntil ); |
|
208 } |
|
209 |
|
210 // ---------------------------------------------------- |
|
211 // CCalenMeetingForm::DeleteOtherItemFromRepeatField |
|
212 // Delete "Other" item from repeat field. |
|
213 // It MUST be called in following case. |
|
214 // 1. Default repeat value is other then "Other". |
|
215 // 2. Repeat is changed from "Other" to another value. |
|
216 // |
|
217 // If "Other" item has already been deleted, nothing is executed. |
|
218 // (other items were commented in a header). |
|
219 // ---------------------------------------------------- |
|
220 // |
|
221 void CCalenRepeatField::DeleteOtherItemFromRepeatField() |
|
222 { |
|
223 TRACE_ENTRY_POINT; |
|
224 |
|
225 TInt itemCount = iRepeatArrayText->Count(); |
|
226 |
|
227 if ( itemCount > ERepeatOther ) |
|
228 // ERepeatOther is the last item index, |
|
229 // which is zero origin. |
|
230 { |
|
231 iRepeatArrayText->Delete( ERepeatOther ); |
|
232 } |
|
233 |
|
234 TRACE_EXIT_POINT; |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------- |
|
238 // CCalenRepeatField::NotifyChangeRepeatChoiceL |
|
239 // (other items were commented in a header). |
|
240 // --------------------------------------------------------- |
|
241 // |
|
242 void CCalenRepeatField::NotifyChangeRepeatChoiceL() |
|
243 { |
|
244 TRACE_ENTRY_POINT; |
|
245 |
|
246 TInt repeatType = iRepeatTextValues->CurrentValueIndex(); |
|
247 |
|
248 if ( repeatType == ERepeatNotRepeated ) |
|
249 { |
|
250 // Repeat type field value selected as 'Non repeating' |
|
251 iUnifiedEditor.Edited().SetNonRepeatingL(); |
|
252 SetRepeatUntilLineDimmedL( ETrue ); |
|
253 UpdateEndDateTimeFields(); |
|
254 } |
|
255 else |
|
256 { |
|
257 TTime start = iUnifiedEditor.Edited().StartDateTime(); |
|
258 TTime until; |
|
259 |
|
260 if ( iUnifiedEditor.Edited().IsRepeating() ) |
|
261 { |
|
262 until = iUnifiedEditor.Edited().RepeatUntilDateTime(); |
|
263 } |
|
264 else |
|
265 { |
|
266 TDateTime repUntilDateTime( ECalenMaxYear, TMonth(ECalenMaxMonth), ECalenMaxDay, 0, 0, 0, 0 ); |
|
267 TTime aTime( repUntilDateTime ); |
|
268 until = aTime; |
|
269 } |
|
270 |
|
271 iUnifiedEditor.Edited().SetRepeatingL( static_cast<TCalenRepeatIndex>( repeatType ), until ); |
|
272 SetRepeatUntilLineDimmedL( EFalse ); |
|
273 SetDataToEditorL(); |
|
274 } |
|
275 |
|
276 if ( repeatType != ERepeatOther ) |
|
277 { |
|
278 // Nothing is executed if "Other" item has already been deleted. |
|
279 DeleteOtherItemFromRepeatField(); |
|
280 } |
|
281 |
|
282 iUnifiedEditor.UpdateFormL(); |
|
283 |
|
284 TRACE_EXIT_POINT; |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------- |
|
288 // CCalenRepeatField::SetRepeatUntilLineDimmedL |
|
289 // (other items were commented in a header). |
|
290 // --------------------------------------------------------- |
|
291 // |
|
292 void CCalenRepeatField::SetRepeatUntilLineDimmedL( const TBool& aDimmed ) |
|
293 { |
|
294 TRACE_ENTRY_POINT; |
|
295 |
|
296 CCoeControl* repUntilCtrl = iUnifiedEditor.ControlOrNull( ECalenEditorRepeatUntil ); |
|
297 |
|
298 if(aDimmed) |
|
299 { |
|
300 if( repUntilCtrl ) |
|
301 { |
|
302 // Delete RepeatUntil line from From |
|
303 iUnifiedEditor.DeleteLine( ECalenEditorRepeatUntil, ETrue ); |
|
304 } |
|
305 } |
|
306 else |
|
307 { |
|
308 if( !repUntilCtrl ) |
|
309 { |
|
310 // Insert RepeatUntil line to From |
|
311 iUnifiedEditor.InsertFieldL( R_CALEN_EDITOR_REPEAT_UNTIL_ITEM, |
|
312 ECalenEditorRepeatUntil, ECalenEditorRepeat ); |
|
313 } |
|
314 } |
|
315 |
|
316 TRACE_EXIT_POINT; |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------- |
|
320 // CCalenRepeatField::UpdateEndDateTimeFields |
|
321 // Called when "Repeat" is updated from any repeat value |
|
322 // to "Not Repeated". |
|
323 // (other items were commented in a header). |
|
324 // --------------------------------------------------------- |
|
325 // |
|
326 void CCalenRepeatField::UpdateEndDateTimeFields() |
|
327 { |
|
328 TRACE_ENTRY_POINT; |
|
329 |
|
330 TTime end = iUnifiedEditor.Edited().EndDateTime(); |
|
331 |
|
332 if( iUnifiedEditor.HasField(ECalenEditorEndDate) ) |
|
333 { |
|
334 // Set End Date field value in Editor |
|
335 iUnifiedEditor.EditorFields().SetDateField( ECalenEditorEndDate, end, EFalse ); |
|
336 } |
|
337 if( iUnifiedEditor.HasField( ECalenEditorEndTime ) ) |
|
338 { |
|
339 // Set End Time field value in Editor |
|
340 iUnifiedEditor.EditorFields().SetTimeField( ECalenEditorEndTime, end ); |
|
341 } |
|
342 TRACE_EXIT_POINT; |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // CCalenRepeatField::AskRepeatingNoteQueriesL |
|
347 // Ask the user of the repeat type when neccessary |
|
348 // (other items were commented in a header). |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 CCalenEditorDataHandler::TError CCalenRepeatField::AskRepeatingNoteQueriesL( |
|
352 CalCommon::TRecurrenceRange& aRepeatType) |
|
353 { |
|
354 TRACE_ENTRY_POINT; |
|
355 |
|
356 CCalenEditorDataHandler::TError error = CCalenEditorDataHandler::EFormErrNone; |
|
357 |
|
358 if( ShouldQueryRepeatTargetL() ) |
|
359 { |
|
360 // Query whether user want to edit This/all instanced of repeat entry. |
|
361 error = QueryRepeatTargetL( aRepeatType ); |
|
362 } |
|
363 |
|
364 TRACE_EXIT_POINT; |
|
365 return error; |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CCalenRepeatField::ShouldQueryRepeatTargetL |
|
370 // Check if the repeat query should be shown |
|
371 // (other items were commented in a header). |
|
372 // ----------------------------------------------------------------------------- |
|
373 // |
|
374 TBool CCalenRepeatField::ShouldQueryRepeatTargetL() |
|
375 { |
|
376 TRACE_ENTRY_POINT; |
|
377 |
|
378 /** |
|
379 * Show save to this/all query if: |
|
380 * Editing a repeating entry (not for child entries!!!) |
|
381 * AND |
|
382 * any of the following fields have changed: |
|
383 * subject, location, description, |
|
384 * start time, end time, (not for date changes) |
|
385 * alarm state, alarm time, alarm date |
|
386 * |
|
387 **/ |
|
388 |
|
389 if( iUnifiedEditor.IsCreatingNewEntry() || |
|
390 ! iUnifiedEditor.Original().IsRepeating() || |
|
391 ! iUnifiedEditor.Edited().IsRepeating() || |
|
392 iUnifiedEditor.EditorDataHandler().IsChildL() ) |
|
393 { |
|
394 TRACE_EXIT_POINT; |
|
395 return EFalse; |
|
396 } |
|
397 |
|
398 // This should take care of checking start date editing: |
|
399 if ( iUnifiedEditor.EditorDataHandler().IsRepeatRuleEdited() ) |
|
400 { |
|
401 TRACE_EXIT_POINT; |
|
402 return EFalse; |
|
403 } |
|
404 |
|
405 TBool isInstanceFieldEdited = |
|
406 iUnifiedEditor.EditorDataHandler().IsSummaryEdited() || |
|
407 iUnifiedEditor.EditorDataHandler().IsLocationEdited() || |
|
408 iUnifiedEditor.EditorDataHandler().IsDescriptionEdited() || |
|
409 iUnifiedEditor.EditorDataHandler().IsStartDateTimeEdited() || |
|
410 iUnifiedEditor.EditorDataHandler().IsEndDateTimeEdited() || |
|
411 iUnifiedEditor.EditorDataHandler().IsAlarmEditedL(); |
|
412 |
|
413 TRACE_EXIT_POINT; |
|
414 return isInstanceFieldEdited; |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CCalenRepeatField::QueryRepeatTargetL |
|
419 // (other items were commented in a header). |
|
420 // ----------------------------------------------------------------------------- |
|
421 // |
|
422 CCalenEditorDataHandler::TError CCalenRepeatField::QueryRepeatTargetL( |
|
423 CalCommon::TRecurrenceRange& aRepeatType ) |
|
424 { |
|
425 TRACE_ENTRY_POINT; |
|
426 |
|
427 const TBool ok = CalenNoteDataUtil::ShowRepeatTypeQueryL( aRepeatType, |
|
428 CalenNoteDataUtil::ESave ); |
|
429 |
|
430 if( !ok ) // Repeat dialog is canceled |
|
431 { |
|
432 TRACE_EXIT_POINT; |
|
433 return CCalenEditorDataHandler::EFormErrCancelChangeRepeatingNote; |
|
434 } |
|
435 |
|
436 TRACE_EXIT_POINT; |
|
437 return CCalenEditorDataHandler::EFormErrNone; |
|
438 } |
|
439 |
|
440 // ----------------------------------------------------------------------------- |
|
441 // CCalenRepeatField::ReadDataFromFormL |
|
442 // (other items were commented in a header). |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CCalenRepeatField::ReadDataFromFormL( TBool /*aContinueOnError*/ ) |
|
446 { |
|
447 TRACE_ENTRY_POINT; |
|
448 |
|
449 // read repeat type data from form |
|
450 TCalenRepeatIndex repeatType = FormRepeatType(); |
|
451 if ( repeatType == ERepeatNotRepeated ) |
|
452 { |
|
453 iUnifiedEditor.Edited().SetNonRepeatingL(); |
|
454 } |
|
455 else |
|
456 { |
|
457 TTime until = iUnifiedEditor.Edited().RepeatUntilDateTime(); |
|
458 until = FormRepeatUntilDateTimeL(); |
|
459 iUnifiedEditor.Edited().SetRepeatingL( repeatType, until ); |
|
460 } |
|
461 |
|
462 TRACE_EXIT_POINT; |
|
463 } |
|
464 |
|
465 // ----------------------------------------------------------------------------- |
|
466 // CCalenRepeatField::SetDataToEditorL |
|
467 // (other items were commented in a header). |
|
468 // ----------------------------------------------------------------------------- |
|
469 // |
|
470 void CCalenRepeatField::SetDataToEditorL() |
|
471 { |
|
472 TRACE_ENTRY_POINT; |
|
473 |
|
474 // Update repeat field data in Form |
|
475 TCalenRepeatIndex pos = iUnifiedEditor.Edited().RepeatType(); |
|
476 iRepeatTextValues->SetCurrentValueIndex( static_cast<TInt>( pos ) ); |
|
477 if ( iUnifiedEditor.Edited().IsRepeating() ) |
|
478 { |
|
479 // Set RepeatUntil date in Form |
|
480 TTime until = iUnifiedEditor.Edited().RepeatUntilDateTime(); |
|
481 iUnifiedEditor.EditorFields().SetDateField( ECalenEditorRepeatUntil, until ); |
|
482 } |
|
483 else |
|
484 { |
|
485 // Delete RepeatUntil line from Form |
|
486 SetRepeatUntilLineDimmedL( ETrue ); |
|
487 } |
|
488 |
|
489 TRACE_EXIT_POINT; |
|
490 } |
|
491 |
|
492 // ----------------------------------------------------------------------------- |
|
493 // CCalenRepeatField::InitRepetFieldLayoutL |
|
494 // (other items were commented in a header). |
|
495 // ----------------------------------------------------------------------------- |
|
496 // |
|
497 void CCalenRepeatField::InitRepetFieldLayoutL() |
|
498 { |
|
499 TRACE_ENTRY_POINT; |
|
500 |
|
501 CAknPopupField* pops = |
|
502 static_cast<CAknPopupField*>( iUnifiedEditor.Control( ECalenEditorRepeat ) ); |
|
503 pops->SetQueryValueL(iRepeatTextValues); |
|
504 |
|
505 if( iUnifiedEditor.Edited().RepeatType() != ERepeatOther ) |
|
506 { |
|
507 DeleteOtherItemFromRepeatField(); |
|
508 } |
|
509 |
|
510 if ( iUnifiedEditor.Edited().IsRepeating() ) |
|
511 { |
|
512 SetRepeatUntilLineDimmedL( EFalse ); |
|
513 } |
|
514 |
|
515 TRACE_EXIT_POINT; |
|
516 } |
|
517 |
|
518 // ----------------------------------------------------------------------------- |
|
519 // CCalenRepeatField::PrepareForFocusTransitionL |
|
520 // Prepare for focus change |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 void CCalenRepeatField::PrepareForFocusTransitionL( TInt aFocusedId ) |
|
524 { |
|
525 TRACE_ENTRY_POINT; |
|
526 |
|
527 switch( aFocusedId ) |
|
528 { |
|
529 case ECalenEditorRepeatUntil: |
|
530 { |
|
531 TBool continueOnError = EFalse; |
|
532 ReadDataFromFormL( continueOnError ); |
|
533 break; |
|
534 } |
|
535 default: |
|
536 { |
|
537 break; |
|
538 } |
|
539 } |
|
540 |
|
541 TRACE_EXIT_POINT; |
|
542 } |
|
543 |
|
544 // End of File |