|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Implements control for the application. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.h" |
|
19 #include <AknUtils.h> |
|
20 // <cmail> SF |
|
21 #include <alf/alfevent.h> |
|
22 // </cmail> |
|
23 #include "FreestyleEmailUiFolderListControl.h" |
|
24 #include "FreestyleEmailUiFolderListVisualiser.h" |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Two-phased constructor. |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CFSEmailUiFolderListControl* CFSEmailUiFolderListControl::NewL(CAlfEnv& aEnv, CFSEmailUiFolderListVisualiser& aVisualiser) |
|
31 { |
|
32 FUNC_LOG; |
|
33 CFSEmailUiFolderListControl* self = CFSEmailUiFolderListControl::NewLC(aEnv, aVisualiser); |
|
34 CleanupStack::Pop(self); |
|
35 return self; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Two-phased constructor. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CFSEmailUiFolderListControl* CFSEmailUiFolderListControl::NewLC(CAlfEnv& aEnv, CFSEmailUiFolderListVisualiser& aVisualiser) |
|
43 { |
|
44 FUNC_LOG; |
|
45 CFSEmailUiFolderListControl* self = new (ELeave) CFSEmailUiFolderListControl(aVisualiser); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aEnv); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 //C++ constructor. |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CFSEmailUiFolderListControl::CFSEmailUiFolderListControl(CFSEmailUiFolderListVisualiser& aVisualiser) |
|
56 : CAlfControl(), |
|
57 iVisualiser(aVisualiser) |
|
58 { |
|
59 FUNC_LOG; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Two-phased constructor. |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CFSEmailUiFolderListControl::ConstructL(CAlfEnv& aEnv) |
|
67 { |
|
68 FUNC_LOG; |
|
69 CAlfControl::ConstructL(aEnv); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // Virtual destructor. |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CFSEmailUiFolderListControl::~CFSEmailUiFolderListControl() |
|
77 { |
|
78 FUNC_LOG; |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------------------------- |
|
82 // CFSEmailUiFolderListControl::OfferEventL |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 TBool CFSEmailUiFolderListControl::OfferEventL( const TAlfEvent& aEvent ) |
|
86 { |
|
87 FUNC_LOG; |
|
88 // Handle expand/collapse functionality, but only in full screen mode |
|
89 if ( aEvent.IsKeyEvent() && iVisualiser.IsFullScreen() ) |
|
90 { |
|
91 // Recalculate the horizontal position when scrolling is finished |
|
92 if ( aEvent.Code() == EEventKeyUp && |
|
93 ( aEvent.KeyEvent().iScanCode == EStdKeyUpArrow || |
|
94 aEvent.KeyEvent().iScanCode == EStdKeyDownArrow ) ) |
|
95 { |
|
96 iVisualiser.DoHorizontalScrollL(); |
|
97 } |
|
98 |
|
99 // Check expanding an collapsing |
|
100 else if ( aEvent.Code() == EEventKey ) |
|
101 { |
|
102 // Swap left and right with mirrored layout |
|
103 TInt scanCode = aEvent.KeyEvent().iScanCode; |
|
104 if ( AknLayoutUtils::LayoutMirrored() ) |
|
105 { |
|
106 if ( scanCode == EStdKeyLeftArrow ) scanCode = EStdKeyRightArrow; |
|
107 else if ( scanCode == EStdKeyRightArrow ) scanCode = EStdKeyLeftArrow; |
|
108 } |
|
109 |
|
110 // Left click collapses the current node, right click expands it |
|
111 switch ( scanCode ) |
|
112 { |
|
113 case EStdKeyLeftArrow: |
|
114 { |
|
115 iVisualiser.ExpandOrCollapseL( |
|
116 CFSEmailUiFolderListVisualiser::EFolderListCollapse ); |
|
117 } |
|
118 break; |
|
119 |
|
120 case EStdKeyRightArrow: |
|
121 { |
|
122 iVisualiser.ExpandOrCollapseL( |
|
123 CFSEmailUiFolderListVisualiser::EFolderListExpand ); |
|
124 } |
|
125 break; |
|
126 |
|
127 default: |
|
128 break; |
|
129 } |
|
130 } |
|
131 } |
|
132 |
|
133 // <cmail> Touch |
|
134 // Offer events to view |
|
135 |
|
136 TBool result = EFalse; |
|
137 |
|
138 if ( aEvent.IsPointerEvent() ) |
|
139 { |
|
140 |
|
141 result = iVisualiser.HandlePointerEventL( aEvent ); |
|
142 } |
|
143 else |
|
144 { |
|
145 result = iVisualiser.OfferEventL( aEvent ); |
|
146 } |
|
147 return result; |
|
148 // </cmail> |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CFSEmailUiFolderListControl::HandleCommandL |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CFSEmailUiFolderListControl::HandleCommandL( TInt aCommand ) |
|
156 { |
|
157 FUNC_LOG; |
|
158 // Offer aCommand to view |
|
159 return iVisualiser.HandleCommandL( aCommand ); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 // --------------------------------------------------------------------------- |
|
165 // |
|
166 void CFSEmailUiFolderListControl::TimerEventL( CFSEmailUiGenericTimer* /*aTriggeredTimer*/ ) |
|
167 { |
|
168 FUNC_LOG; |
|
169 iVisualiser.ExpandOrCollapseL( |
|
170 CFSEmailUiFolderListVisualiser::EFolderListAutomatic ); |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 // --------------------------------------------------------------------------- |
|
176 /* |
|
177 void CFSEmailUiFolderListControl::StartTestTimer() |
|
178 { |
|
179 iFolderListTimer.Start( KAutoExpandCollapseDelay * 5 ); |
|
180 } |
|
181 */ |
|
182 |