13 * |
13 * |
14 * Description: ESMR Synchronization field implementation |
14 * Description: ESMR Synchronization field implementation |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 #include "emailtrace.h" |
|
19 #include "cesmrsyncfield.h" |
18 #include "cesmrsyncfield.h" |
20 |
19 #include "cmrimage.h" |
21 #include <eiklabel.h> |
20 #include "cmrlabel.h" |
|
21 #include "cesmrtextitem.h" |
|
22 #include "cesmrlistquery.h" |
|
23 #include "nmrlayoutmanager.h" |
|
24 |
22 #include <esmrgui.rsg> |
25 #include <esmrgui.rsg> |
23 #include <StringLoader.h> |
26 #include <stringloader.h> |
24 #include <barsread.h> |
27 #include <barsread.h> |
25 #include <avkon.hrh> |
28 #include <avkon.hrh> |
26 #include <AknsConstants.h> |
29 #include <aknutils.h> |
27 #include <AknUtils.h> |
|
28 |
|
29 #include "cesmrsync.h" |
|
30 #include "cesmrlistquery.h" |
|
31 #include <calentry.h> |
30 #include <calentry.h> |
|
31 // DEBUG |
|
32 #include "emailtrace.h" |
32 |
33 |
33 // Unnamed namespace for local definitions and functions |
34 // Unnamed namespace for local definitions and functions |
34 namespace{ // codescanner::namespace |
35 namespace // codescanner::namespace |
35 |
36 { |
36 CCalEntry::TReplicationStatus MapToReplicationStatus( |
37 CCalEntry::TReplicationStatus MapToReplicationStatus( |
37 TESMRSyncValue aSyncValue ) |
38 TESMRSyncValue aSyncValue ) |
38 { |
39 { |
39 CCalEntry::TReplicationStatus ret; |
40 CCalEntry::TReplicationStatus ret; |
40 switch ( aSyncValue ) |
41 switch ( aSyncValue ) |
41 { |
42 { |
42 case ESyncNone: |
43 case ESyncNone: |
43 { |
44 { |
44 ret = CCalEntry::ERestricted; |
45 ret = CCalEntry::ERestricted; |
45 break; |
46 break; |
46 } |
47 } |
47 case ESyncPrivate: |
48 case ESyncPrivate: |
48 { |
49 { |
49 ret = CCalEntry::EPrivate; |
50 ret = CCalEntry::EPrivate; |
50 break; |
51 break; |
51 } |
52 } |
52 case ESyncPublic: |
53 case ESyncPublic: |
53 { |
54 { |
54 ret = CCalEntry::EOpen; |
55 ret = CCalEntry::EOpen; |
55 break; |
56 break; |
56 } |
57 } |
57 default: |
58 default: |
58 { |
59 { |
59 ret = CCalEntry::ERestricted; |
60 ret = CCalEntry::ERestricted; |
60 } |
61 } |
61 } |
62 } |
62 |
63 |
63 return ret; |
64 return ret; |
64 } |
65 } |
65 |
66 |
66 } // namespace |
67 // Field's component count, icon and label |
|
68 const TInt KComponentCount( 2 ); |
|
69 } // namespace |
67 |
70 |
68 // ======== MEMBER FUNCTIONS ======== |
71 // ======== MEMBER FUNCTIONS ======== |
69 |
72 |
70 // --------------------------------------------------------------------------- |
73 // --------------------------------------------------------------------------- |
71 // CESMRSyncField::NewL |
74 // CESMRSyncField::NewL |
88 CESMRSyncField::~CESMRSyncField( ) |
91 CESMRSyncField::~CESMRSyncField( ) |
89 { |
92 { |
90 FUNC_LOG; |
93 FUNC_LOG; |
91 iArray.ResetAndDestroy ( ); |
94 iArray.ResetAndDestroy ( ); |
92 iArray.Close ( ); |
95 iArray.Close ( ); |
93 } |
96 |
94 |
97 delete iIcon; |
95 // --------------------------------------------------------------------------- |
|
96 // CESMRSyncField::InitializeL |
|
97 // --------------------------------------------------------------------------- |
|
98 // |
|
99 void CESMRSyncField::InitializeL() |
|
100 { |
|
101 FUNC_LOG; |
|
102 iSync->SetFont( iLayout->Font( iCoeEnv, iFieldId ) ); |
|
103 iSync->SetLabelAlignment( CESMRLayoutManager::IsMirrored() |
|
104 ? ELayoutAlignRight : ELayoutAlignLeft ); |
|
105 AknLayoutUtils::OverrideControlColorL(*iSync, |
|
106 EColorLabelText, |
|
107 iLayout->GeneralListAreaTextColor() ); |
|
108 } |
98 } |
109 |
99 |
110 // --------------------------------------------------------------------------- |
100 // --------------------------------------------------------------------------- |
111 // CESMRSyncField::InternalizeL |
101 // CESMRSyncField::InternalizeL |
112 // --------------------------------------------------------------------------- |
102 // --------------------------------------------------------------------------- |
123 // Read sync items to array |
113 // Read sync items to array |
124 iArray.ResetAndDestroy( ); |
114 iArray.ResetAndDestroy( ); |
125 TInt count = reader.ReadInt16 ( ); |
115 TInt count = reader.ReadInt16 ( ); |
126 for (TInt i(0); i < count; i++ ) |
116 for (TInt i(0); i < count; i++ ) |
127 { |
117 { |
128 CESMRSync* sync = new (ELeave) CESMRSync(); |
118 CESMRTextItem* sync = new (ELeave) CESMRTextItem(); |
129 CleanupStack::PushL( sync ); |
119 CleanupStack::PushL( sync ); |
130 sync->ConstructFromResourceL ( reader ); |
120 sync->ConstructFromResourceL ( reader ); |
131 iArray.AppendL ( sync ); |
121 iArray.AppendL ( sync ); |
132 CleanupStack::Pop( sync ); |
122 CleanupStack::Pop( sync ); |
133 if ( synchValue == MapToReplicationStatus ( sync->Id ( ) ) ) |
123 if ( synchValue == MapToReplicationStatus ( static_cast<TESMRSyncValue>( sync->Id ( ) ) ) ) |
134 { |
124 { |
135 iIndex = i; |
125 iIndex = i; |
136 iSync->SetTextL ( sync->TextL ( ) ); |
126 iSync->SetTextL ( sync->TextL ( ) ); |
137 } |
127 } |
138 } |
128 } |
177 |
167 |
178 // --------------------------------------------------------------------------- |
168 // --------------------------------------------------------------------------- |
179 // CESMRPriorityField::ExecuteGenericCommandL |
169 // CESMRPriorityField::ExecuteGenericCommandL |
180 // --------------------------------------------------------------------------- |
170 // --------------------------------------------------------------------------- |
181 // |
171 // |
182 void CESMRSyncField::ExecuteGenericCommandL( TInt aCommand ) |
172 TBool CESMRSyncField::ExecuteGenericCommandL( TInt aCommand ) |
183 { |
173 { |
184 FUNC_LOG; |
174 FUNC_LOG; |
|
175 TBool isUsed( EFalse ); |
185 if(aCommand == EESMRCmdOpenSyncQuery || |
176 if(aCommand == EESMRCmdOpenSyncQuery || |
186 aCommand == EAknCmdOpen ) |
177 aCommand == EAknCmdOpen ) |
187 { |
178 { |
188 ExecuteSyncQueryL(); |
179 ExecuteSyncQueryL(); |
189 } |
180 isUsed = ETrue; |
|
181 |
|
182 HandleTactileFeedbackL(); |
|
183 } |
|
184 return isUsed; |
190 } |
185 } |
191 |
186 |
192 // --------------------------------------------------------------------------- |
187 // --------------------------------------------------------------------------- |
193 // CESMRPriorityField::ExecuteSyncQuery |
188 // CESMRPriorityField::ExecuteSyncQuery |
194 // --------------------------------------------------------------------------- |
189 // --------------------------------------------------------------------------- |
253 // |
248 // |
254 CESMRSyncField::CESMRSyncField( ) : |
249 CESMRSyncField::CESMRSyncField( ) : |
255 iIndex(0) |
250 iIndex(0) |
256 { |
251 { |
257 FUNC_LOG; |
252 FUNC_LOG; |
258 //do nothing |
253 SetFieldId( EESMRFieldSync ); |
|
254 SetFocusType( EESMRHighlightFocus ); |
259 } |
255 } |
260 |
256 |
261 // --------------------------------------------------------------------------- |
257 // --------------------------------------------------------------------------- |
262 // CESMRSyncField::ConstructL |
258 // CESMRSyncField::ConstructL |
263 // --------------------------------------------------------------------------- |
259 // --------------------------------------------------------------------------- |
264 // |
260 // |
265 void CESMRSyncField::ConstructL( ) |
261 void CESMRSyncField::ConstructL( ) |
266 { |
262 { |
267 FUNC_LOG; |
263 FUNC_LOG; |
268 SetFieldId( EESMRFieldSync ); |
264 iSync = CMRLabel::NewL(); |
269 |
265 CESMRField::ConstructL( iSync ); |
270 iSync = new (ELeave) CEikLabel; |
266 iSync->SetTextL( KNullDesC() ); |
271 iSync->SetTextL( KNullDesC ); |
|
272 |
267 |
273 TGulAlignment align; |
268 TGulAlignment align; |
274 align.SetHAlignment( EHLeft ); |
269 align.SetHAlignment( EHLeft ); |
275 align.SetVAlignment( EVCenter ); |
270 align.SetVAlignment( EVCenter ); |
276 iSync->SetAlignment( align ); |
271 iSync->SetAlignment( align ); |
277 |
272 |
278 CESMRIconField::ConstructL( |
273 iIcon = CMRImage::NewL( NMRBitmapManager::EMRBitmapSynchronization ); |
279 KAknsIIDQgnFscalIndiSynchronisation, |
|
280 iSync ); |
|
281 } |
274 } |
282 |
275 |
283 // --------------------------------------------------------------------------- |
276 // --------------------------------------------------------------------------- |
284 // CESMRSyncField::UpdateLabelL |
277 // CESMRSyncField::UpdateLabelL |
285 // --------------------------------------------------------------------------- |
278 // --------------------------------------------------------------------------- |
286 // |
279 // |
287 void CESMRSyncField::UpdateLabelL( TInt aIndex ) |
280 void CESMRSyncField::UpdateLabelL( TInt aIndex ) |
288 { |
281 { |
289 FUNC_LOG; |
282 FUNC_LOG; |
290 CESMRSync* sync = iArray[ aIndex ]; |
283 CESMRTextItem* sync = iArray[ aIndex ]; |
291 iSync->SetTextL( sync->TextL() ); |
284 iSync->SetTextL( sync->TextL() ); |
292 iSync->DrawDeferred(); |
285 iSync->DrawDeferred(); |
293 } |
286 } |
294 |
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CESMRSyncField::CountComponentControls |
|
290 // --------------------------------------------------------------------------- |
|
291 // |
|
292 TInt CESMRSyncField::CountComponentControls() const |
|
293 { |
|
294 return KComponentCount; |
|
295 } |
|
296 |
|
297 // --------------------------------------------------------------------------- |
|
298 // CESMRSyncField::ComponentControl |
|
299 // --------------------------------------------------------------------------- |
|
300 // |
|
301 CCoeControl* CESMRSyncField::ComponentControl( TInt aIndex ) const |
|
302 { |
|
303 CCoeControl* control = NULL; |
|
304 switch( aIndex ) |
|
305 { |
|
306 case 0: |
|
307 { |
|
308 control = iSync; |
|
309 break; |
|
310 } |
|
311 case 1: |
|
312 { |
|
313 control = iIcon; |
|
314 break; |
|
315 } |
|
316 default: |
|
317 ASSERT( EFalse ); |
|
318 } |
|
319 |
|
320 return control; |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // CESMRSyncField::SizeChanged |
|
325 // --------------------------------------------------------------------------- |
|
326 // |
|
327 void CESMRSyncField::SizeChanged() |
|
328 { |
|
329 TRect rect( Rect() ); |
|
330 TAknLayoutRect iconLayout = |
|
331 NMRLayoutManager::GetLayoutRect( |
|
332 rect, NMRLayoutManager::EMRLayoutTextEditorIcon ); |
|
333 TRect iconRect( iconLayout.Rect() ); |
|
334 iIcon->SetRect( iconRect ); |
|
335 |
|
336 TAknLayoutRect bgLayoutRect = |
|
337 NMRLayoutManager::GetLayoutRect( |
|
338 rect, NMRLayoutManager::EMRLayoutTextEditorBg ); |
|
339 TRect bgRect( bgLayoutRect.Rect() ); |
|
340 // Move focus rect so that it's relative to field's position. |
|
341 bgRect.Move( -Position() ); |
|
342 SetFocusRect( bgRect ); |
|
343 |
|
344 TAknTextComponentLayout editorLayout = |
|
345 NMRLayoutManager::GetTextComponentLayout( |
|
346 NMRLayoutManager::EMRTextLayoutTextEditor ); |
|
347 |
|
348 AknLayoutUtils::LayoutLabel( iSync, rect, editorLayout ); |
|
349 } |
|
350 |
295 // EOF |
351 // EOF |
296 |
352 |