15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
18 #include "emailtrace.h" |
19 #include "cesmrrecurencefield.h" |
19 #include "cesmrrecurencefield.h" |
20 |
|
21 #include <eiklabel.h> |
|
22 #include <barsread.h> |
|
23 #include <esmrgui.rsg> |
|
24 #include <avkon.hrh> |
|
25 //<cmail> |
|
26 #include "esmrdef.h" |
|
27 //</cmail> |
|
28 #include <AknUtils.h> |
|
29 |
|
30 #include "cesmrrecurrence.h" |
20 #include "cesmrrecurrence.h" |
31 #include "cesmrborderlayer.h" |
|
32 #include "mesmrlistobserver.h" |
21 #include "mesmrlistobserver.h" |
33 #include "cesmrlistquery.h" |
22 #include "cesmrlistquery.h" |
34 #include "mesmrmeetingrequestentry.h" |
23 #include "mesmrmeetingrequestentry.h" |
35 #include "mesmrfieldvalidator.h" |
24 #include "mesmrfieldvalidator.h" |
36 #include "cesmrglobalnote.h" |
25 #include "cesmrglobalnote.h" |
|
26 #include "nmrlayoutmanager.h" |
|
27 #include "cmrimage.h" |
|
28 #include "cmrlabel.h" |
|
29 |
|
30 #include <barsread.h> |
|
31 #include <esmrgui.rsg> |
|
32 //<cmail> |
|
33 #include "esmrdef.h" |
|
34 //</cmail> |
|
35 |
37 |
36 |
38 // Unnamed namespace for local definitions |
37 // Unnamed namespace for local definitions |
39 namespace { // codescanner::namespace |
38 namespace { // codescanner::namespace |
40 |
39 |
41 #ifdef _DEBUG |
40 #ifdef _DEBUG |
67 |
66 |
68 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
69 // CESMRRecurrenceField::CESMRRecurrenceField |
68 // CESMRRecurrenceField::CESMRRecurrenceField |
70 // --------------------------------------------------------------------------- |
69 // --------------------------------------------------------------------------- |
71 // |
70 // |
72 CESMRRecurenceField::CESMRRecurenceField( |
71 CESMRRecurenceField::CESMRRecurenceField( MESMRFieldValidator* aValidator ) |
73 MESMRFieldValidator* aValidator ) |
72 : iIndex( 0 ) |
74 : iValidator( aValidator), |
73 { |
75 iIndex( 0 ) |
74 FUNC_LOG; |
76 { |
75 |
77 FUNC_LOG; |
76 iValidator = aValidator; |
78 //do nothing |
77 |
|
78 SetFieldId ( EESMRFieldRecurrence ); |
|
79 SetFocusType( EESMRHighlightFocus ); |
79 } |
80 } |
80 |
81 |
81 // --------------------------------------------------------------------------- |
82 // --------------------------------------------------------------------------- |
82 // CESMRRecurrenceField::~CESMRRecurrenceField |
83 // CESMRRecurrenceField::~CESMRRecurrenceField |
83 // --------------------------------------------------------------------------- |
84 // --------------------------------------------------------------------------- |
85 CESMRRecurenceField::~CESMRRecurenceField( ) |
86 CESMRRecurenceField::~CESMRRecurenceField( ) |
86 { |
87 { |
87 FUNC_LOG; |
88 FUNC_LOG; |
88 iArray.ResetAndDestroy(); |
89 iArray.ResetAndDestroy(); |
89 iArray.Close(); |
90 iArray.Close(); |
|
91 |
|
92 delete iFieldIcon; |
90 } |
93 } |
91 |
94 |
92 // --------------------------------------------------------------------------- |
95 // --------------------------------------------------------------------------- |
93 // CESMRRecurrenceField::NewL |
96 // CESMRRecurrenceField::NewL |
94 // --------------------------------------------------------------------------- |
97 // --------------------------------------------------------------------------- |
95 // |
98 // |
96 CESMRRecurenceField* CESMRRecurenceField::NewL( |
99 CESMRRecurenceField* CESMRRecurenceField::NewL( |
97 MESMRFieldValidator* aValidator ) |
100 MESMRFieldValidator* aValidator ) |
98 { |
101 { |
99 FUNC_LOG; |
102 FUNC_LOG; |
100 CESMRRecurenceField* self = |
103 CESMRRecurenceField* self = |
101 new (ELeave) CESMRRecurenceField( aValidator ); |
104 new( ELeave )CESMRRecurenceField( aValidator ); |
102 CleanupStack::PushL( self ); |
105 CleanupStack::PushL( self ); |
103 self->ConstructL(); |
106 self->ConstructL(); |
104 CleanupStack::Pop( self ); |
107 CleanupStack::Pop( self ); |
105 return self; |
108 return self; |
106 } |
109 } |
110 // --------------------------------------------------------------------------- |
113 // --------------------------------------------------------------------------- |
111 // |
114 // |
112 void CESMRRecurenceField::ConstructL( ) |
115 void CESMRRecurenceField::ConstructL( ) |
113 { |
116 { |
114 FUNC_LOG; |
117 FUNC_LOG; |
115 _LIT(KEmptyText, "" ); |
118 iRecurrence = CMRLabel::NewL(); |
116 SetFieldId ( EESMRFieldRecurrence ); |
119 iRecurrence->SetParent( this ); |
117 iRecurence = new (ELeave) CEikLabel(); |
120 CESMRField::ConstructL( iRecurrence ); |
118 iRecurence->SetTextL( KEmptyText ); |
121 |
119 CESMRIconField::ConstructL ( |
122 iRecurrence->SetTextL( KNullDesC() ); |
120 KAknsIIDQgnFscalIndiRecurrence, |
123 |
121 iRecurence ); |
124 iFieldIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapRecurrence ); |
122 } |
125 iFieldIcon->SetParent( this ); |
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CESMRRecurrenceField::InitializeL |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CESMRRecurenceField::InitializeL() |
|
129 { |
|
130 FUNC_LOG; |
|
131 iRecurence->SetFont ( iLayout->Font( iCoeEnv, iFieldId ) ); |
|
132 |
|
133 iRecurence->SetLabelAlignment( |
|
134 CESMRLayoutManager::IsMirrored() ? |
|
135 ELayoutAlignRight : ELayoutAlignLeft ); |
|
136 |
|
137 AknLayoutUtils::OverrideControlColorL( |
|
138 *iRecurence, |
|
139 EColorLabelText, |
|
140 iLayout->GeneralListAreaTextColor() ); |
|
141 } |
126 } |
142 |
127 |
143 // --------------------------------------------------------------------------- |
128 // --------------------------------------------------------------------------- |
144 // CESMRRecurrenceField::InternalizeL |
129 // CESMRRecurrenceField::InternalizeL |
145 // --------------------------------------------------------------------------- |
130 // --------------------------------------------------------------------------- |
146 // |
131 // |
147 void CESMRRecurenceField::InternalizeL( |
132 void CESMRRecurenceField::InternalizeL( MESMRCalEntry& aEntry ) |
148 MESMRCalEntry& aEntry ) |
|
149 { |
133 { |
150 FUNC_LOG; |
134 FUNC_LOG; |
151 if ( aEntry.CanSetRecurrenceL() ) |
135 if ( aEntry.CanSetRecurrenceL() ) |
152 { |
136 { |
153 CCoeEnv* env = CCoeEnv::Static ( ); |
137 CCoeEnv* env = CCoeEnv::Static ( ); |
202 |
186 |
203 // --------------------------------------------------------------------------- |
187 // --------------------------------------------------------------------------- |
204 // CESMRRecurenceField::ExecuteGenericCommandL |
188 // CESMRRecurenceField::ExecuteGenericCommandL |
205 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
206 // |
190 // |
207 void CESMRRecurenceField::ExecuteGenericCommandL( TInt aCommand ) |
191 TBool CESMRRecurenceField::ExecuteGenericCommandL( TInt aCommand ) |
208 { |
192 { |
209 FUNC_LOG; |
193 FUNC_LOG; |
|
194 TBool isUsed( EFalse ); |
210 if (aCommand == EESMRCmdOpenRecurrenceQuery || |
195 if (aCommand == EESMRCmdOpenRecurrenceQuery || |
211 aCommand == EAknCmdOpen ) |
196 aCommand == EAknCmdOpen ) |
212 { |
197 { |
213 ExecuteRecurrenceQueryL(); |
198 ExecuteRecurrenceQueryL(); |
214 } |
199 isUsed = ETrue; |
|
200 |
|
201 HandleTactileFeedbackL(); |
|
202 } |
|
203 return isUsed; |
215 } |
204 } |
216 |
205 |
217 // --------------------------------------------------------------------------- |
206 // --------------------------------------------------------------------------- |
218 // CESMRRecurenceField::ExecuteRecurrenceQueryL |
207 // CESMRRecurenceField::ExecuteRecurrenceQueryL |
219 // --------------------------------------------------------------------------- |
208 // --------------------------------------------------------------------------- |
220 // |
209 // |
221 void CESMRRecurenceField::ExecuteRecurrenceQueryL() |
210 void CESMRRecurenceField::ExecuteRecurrenceQueryL() |
222 { |
211 { |
223 FUNC_LOG; |
212 FUNC_LOG; |
224 TInt ret = CESMRListQuery::ExecuteL(CESMRListQuery::EESMRRecurrenceQuery ); |
213 TInt ret = CESMRListQuery::ExecuteL( |
|
214 CESMRListQuery::EESMRRecurrenceQuery ); |
225 |
215 |
226 if ( ret != KErrCancel ) |
216 if ( ret != KErrCancel ) |
227 { |
217 { |
228 SetRecurrenceL( ret ); |
218 SetRecurrenceL( ret ); |
229 } |
219 } |
230 } |
220 } |
231 |
|
232 |
221 |
233 // --------------------------------------------------------------------------- |
222 // --------------------------------------------------------------------------- |
234 // CESMRRecurrenceField::OfferKeyEventL |
223 // CESMRRecurrenceField::OfferKeyEventL |
235 // --------------------------------------------------------------------------- |
224 // --------------------------------------------------------------------------- |
236 // |
225 // |
286 |
275 |
287 CESMRRecurrence* rec = iArray[ aIndex ]; |
276 CESMRRecurrence* rec = iArray[ aIndex ]; |
288 TRAPD( err, iValidator->RecurrenceChangedL( rec->RecurrenceValue() ) ); |
277 TRAPD( err, iValidator->RecurrenceChangedL( rec->RecurrenceValue() ) ); |
289 if ( err == KErrNone ) |
278 if ( err == KErrNone ) |
290 { |
279 { |
291 iRecurence->SetTextL ( rec->RecurrenceText() ); |
280 iRecurrence->SetTextL( rec->RecurrenceText() ); |
292 iBorder->DrawDeferred ( ); |
281 iRecurrence->DrawDeferred(); |
293 |
282 |
294 iIndex = aIndex; |
283 iIndex = aIndex; |
295 |
284 |
296 if ( rec->RecurrenceValue() != ERecurrenceNot ) |
285 if ( rec->RecurrenceValue() != ERecurrenceNot ) |
297 { |
286 { |
298 // if recurrence is switched "on", the end date should be removed |
287 // if recurrence is switched "on", the end date should be removed |
299 iObserver->RemoveControl ( EESMRFieldStopDate ); |
288 iObserver->HideControl ( EESMRFieldStopDate ); |
300 iObserver->InsertControl ( EESMRFieldRecurrenceDate ); |
289 iObserver->ShowControl ( EESMRFieldRecurrenceDate ); |
301 } |
290 } |
302 else |
291 else |
303 { |
292 { |
304 // if recurrence is switched off, end date should be visible |
293 // if recurrence is switched off, end date should be visible |
305 iObserver->InsertControl ( EESMRFieldStopDate ); |
294 iObserver->ShowControl ( EESMRFieldStopDate ); |
306 iObserver->RemoveControl ( EESMRFieldRecurrenceDate ); |
295 iObserver->HideControl ( EESMRFieldRecurrenceDate ); |
307 } |
296 } |
308 } |
297 } |
309 else |
298 else |
310 { |
299 { |
311 // Error occured |
300 // Error occured |
312 CESMRGlobalNote::ExecuteL( |
301 CESMRGlobalNote::ExecuteL( |
313 CESMRGlobalNote::EESMRRepeatDifferentStartAndEndDate ); |
302 CESMRGlobalNote::EESMRRepeatDifferentStartAndEndDate ); |
314 } |
303 } |
315 } |
304 } |
316 |
305 |
|
306 // --------------------------------------------------------------------------- |
|
307 // CESMRRecurenceField::SizeChanged |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 void CESMRRecurenceField::SizeChanged() |
|
311 { |
|
312 FUNC_LOG; |
|
313 TRect rect = Rect(); |
|
314 |
|
315 TAknLayoutRect rowLayoutRect = |
|
316 NMRLayoutManager::GetFieldRowLayoutRect( rect, 1 ); |
|
317 rect = rowLayoutRect.Rect(); |
|
318 |
|
319 TAknWindowComponentLayout iconLayout = |
|
320 NMRLayoutManager::GetWindowComponentLayout( |
|
321 NMRLayoutManager::EMRLayoutTextEditorIcon ); |
|
322 AknLayoutUtils::LayoutImage( iFieldIcon, rect, iconLayout ); |
|
323 |
|
324 TAknLayoutRect bgLayoutRect = |
|
325 NMRLayoutManager::GetLayoutRect( |
|
326 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
|
327 TRect bgRect( bgLayoutRect.Rect() ); |
|
328 // Move focus rect so that it's relative to field's position. |
|
329 bgRect.Move( -Position() ); |
|
330 SetFocusRect( bgRect ); |
|
331 |
|
332 TAknLayoutText labelLayout = |
|
333 NMRLayoutManager::GetLayoutText( |
|
334 rect, NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
335 iRecurrence->SetRect( labelLayout.TextRect() ); |
|
336 |
|
337 // Setting font also for the field |
|
338 iRecurrence->SetFont( labelLayout.Font() ); |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // CESMRRecurenceField::CountComponentControls |
|
343 // --------------------------------------------------------------------------- |
|
344 // |
|
345 TInt CESMRRecurenceField::CountComponentControls( ) const |
|
346 { |
|
347 FUNC_LOG; |
|
348 TInt count( 0 ); |
|
349 if ( iFieldIcon ) |
|
350 { |
|
351 ++count; |
|
352 } |
|
353 if ( iRecurrence ) |
|
354 { |
|
355 ++count; |
|
356 } |
|
357 return count; |
|
358 } |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // CESMRRecurenceField::ComponentControl |
|
362 // --------------------------------------------------------------------------- |
|
363 // |
|
364 CCoeControl* CESMRRecurenceField::ComponentControl( TInt aInd ) const |
|
365 { |
|
366 FUNC_LOG; |
|
367 switch ( aInd ) |
|
368 { |
|
369 case 0: |
|
370 return iFieldIcon; |
|
371 case 1: |
|
372 return iRecurrence; |
|
373 default: |
|
374 return NULL; |
|
375 } |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------------------------- |
|
379 // CESMRRecurenceField::SetContainerWindowL |
|
380 // --------------------------------------------------------------------------- |
|
381 // |
|
382 void CESMRRecurenceField::SetContainerWindowL( |
|
383 const CCoeControl& aContainer ) |
|
384 { |
|
385 CCoeControl::SetContainerWindowL( aContainer ); |
|
386 iRecurrence->SetContainerWindowL( aContainer ); |
|
387 |
|
388 iRecurrence->SetParent( this ); |
|
389 } |
|
390 |
317 // EOF |
391 // EOF |
318 |
|