1 /* |
|
2 * Copyright (c) 2007 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: View class for Location Centre Application UI. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // SYSTEM INCLUDES |
|
20 #include <lcapp.rsg> |
|
21 #include <hlplch.h> |
|
22 #include <featmgr.h> |
|
23 #include <eikmenup.h> |
|
24 #include <eikbtgpc.h> |
|
25 |
|
26 // USER INCLUDES |
|
27 #include "lcview.h" |
|
28 #include "lccontainer.h" |
|
29 #include "lcappui.h" |
|
30 #include "lclistboxmodel.h" |
|
31 #include "lcapp.hrh" |
|
32 |
|
33 // CONSTANT DEFINTIONS |
|
34 const TUid KLcViewId = TUid::Uid( 1 ); |
|
35 |
|
36 // ----------------- Member funtions for CLcView class ----------------------- |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CLcView::CLcView |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CLcView::CLcView( MLcEventHandler& aEventHandler, |
|
43 CLcListBoxModel& aListBoxModel ) |
|
44 :iEventHandler( aEventHandler ), |
|
45 iListBoxModel( &aListBoxModel ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CLcView::~CLcView |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CLcView::~CLcView() |
|
54 { |
|
55 if ( iContainer ) |
|
56 { |
|
57 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
58 } |
|
59 |
|
60 delete iContainer; |
|
61 |
|
62 FeatureManager::UnInitializeLib(); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CLcView* CLcView::NewL |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CLcView* CLcView::NewL( MLcEventHandler& aEventHandler, |
|
70 CLcListBoxModel& aListBoxModel ) |
|
71 { |
|
72 CLcView* self = CLcView::NewLC( aEventHandler, aListBoxModel ); |
|
73 CleanupStack::Pop(self); |
|
74 return self; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CLcView* CLcView::NewLC |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CLcView* CLcView::NewLC( MLcEventHandler& aEventHandler, |
|
82 CLcListBoxModel& aListBoxModel ) |
|
83 { |
|
84 CLcView* self = new ( ELeave ) CLcView( aEventHandler, aListBoxModel ); |
|
85 CleanupStack::PushL(self); |
|
86 self->ConstructL(); |
|
87 return self; |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // void CLcView::ConstructL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CLcView::ConstructL() |
|
95 { |
|
96 BaseConstructL( R_LC_VIEW ); |
|
97 |
|
98 // Feature manager required for Help feature check |
|
99 FeatureManager::InitializeLibL(); |
|
100 |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // void CLcView::ScreenSizeChanged |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CLcView::ScreenSizeChanged() |
|
108 { |
|
109 // Request the Client container to change its rect to a new Rect |
|
110 if( iContainer ) |
|
111 { |
|
112 iContainer->SetRect( ClientRect()); |
|
113 } |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // void CLcView::UpdateL |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CLcView::UpdateL( CLcListBoxModel& aListBoxModel ) |
|
121 { |
|
122 // Set the new List box model. |
|
123 iListBoxModel = &aListBoxModel; |
|
124 |
|
125 // Now update the contaier. |
|
126 if (iContainer) |
|
127 { |
|
128 iContainer->UpdateL(*iListBoxModel); |
|
129 } |
|
130 |
|
131 if (iListBoxModel->MdcaCount()) |
|
132 { |
|
133 if (Cba()) |
|
134 { |
|
135 Cba()->SetCommandSetL(R_LC_CBA); |
|
136 } |
|
137 } |
|
138 else |
|
139 { |
|
140 if (Cba()) |
|
141 { |
|
142 Cba()->SetCommandSetL(R_LC_CBA_EMPTY); |
|
143 } |
|
144 } |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // void CLcView::UpdateIconsL |
|
149 // --------------------------------------------------------------------------- |
|
150 // |
|
151 void CLcView::UpdateIconsL() |
|
152 { |
|
153 if ( iContainer ) |
|
154 { |
|
155 iContainer->UpdateIconsL(); |
|
156 } |
|
157 iContainer->DrawDeferred(); |
|
158 } |
|
159 |
|
160 // --------------------------------------------------------------------------- |
|
161 // TInt CLcView::GetFocussedItem |
|
162 // --------------------------------------------------------------------------- |
|
163 // |
|
164 TInt CLcView::GetFocussedItem() |
|
165 { |
|
166 if ( iContainer ) |
|
167 { |
|
168 return iContainer->GetFocussedItem(); |
|
169 } |
|
170 else |
|
171 { |
|
172 return KErrNotFound; |
|
173 } |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // void CLcView::DoActivateL |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 void CLcView::DoActivateL( const TVwsViewId& /* PrevViewId*/, |
|
181 TUid /* aCustomMessageId*/, |
|
182 const TDesC8& /* aCustomMessage */) |
|
183 { |
|
184 // Destroy the existing container if it exists |
|
185 if( iContainer ) |
|
186 { |
|
187 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
188 delete iContainer; |
|
189 iContainer=NULL; |
|
190 } |
|
191 |
|
192 // Create new Container |
|
193 iContainer = CLcContainer::NewL( ClientRect(), iEventHandler, *iListBoxModel ); |
|
194 iContainer->SetMopParent( this ); |
|
195 AppUi()->AddToViewStackL( *this, iContainer ); |
|
196 |
|
197 if( iListBoxModel->MdcaCount()) |
|
198 { |
|
199 Cba()->SetCommandSetL( R_LC_CBA ); |
|
200 } |
|
201 else |
|
202 { |
|
203 Cba()->SetCommandSetL( R_LC_CBA_EMPTY ); |
|
204 } |
|
205 } |
|
206 |
|
207 // --------------------------------------------------------------------------- |
|
208 // void CLcView::DoDeactivate |
|
209 // --------------------------------------------------------------------------- |
|
210 // |
|
211 void CLcView::DoDeactivate() |
|
212 { |
|
213 // Destroy Container |
|
214 if ( iContainer ) |
|
215 { |
|
216 AppUi()->RemoveFromViewStack( *this, iContainer ); |
|
217 delete iContainer; |
|
218 iContainer = NULL; |
|
219 } |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // TUid CLcView::Id |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 TUid CLcView::Id() const |
|
227 { |
|
228 return KLcViewId; |
|
229 } |
|
230 |
|
231 // --------------------------------------------------------------------------- |
|
232 // void CLcView::HandleCommandL |
|
233 // --------------------------------------------------------------------------- |
|
234 // |
|
235 void CLcView::HandleCommandL( TInt aCommand ) |
|
236 { |
|
237 // This Class only handles the Help feature. All the other events are handled |
|
238 // by the App UI class. |
|
239 switch( aCommand ) |
|
240 { |
|
241 case EAknCmdHelp: |
|
242 { |
|
243 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), |
|
244 AppUi()->AppHelpContextL()); |
|
245 break; |
|
246 } |
|
247 default: |
|
248 { |
|
249 AppUi()->HandleCommandL( aCommand ); |
|
250 break; |
|
251 } |
|
252 } |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // void CLcView::DynInitMenuPaneL |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 void CLcView::DynInitMenuPaneL( TInt aResourceId, |
|
260 CEikMenuPane* aMenuPane ) |
|
261 { |
|
262 if ( aResourceId == R_LC_MENU ) |
|
263 { |
|
264 HandleHelpFeature( *aMenuPane ); |
|
265 |
|
266 if( iListBoxModel->MdcaCount()) |
|
267 { |
|
268 aMenuPane->SetItemDimmed( ELcOpen, EFalse ); |
|
269 } |
|
270 else |
|
271 { |
|
272 aMenuPane->SetItemDimmed( ELcOpen, ETrue ); |
|
273 } |
|
274 } |
|
275 } |
|
276 |
|
277 // --------------------------------------------------------------------------- |
|
278 // void CLcView::HandleHelpFeature |
|
279 // --------------------------------------------------------------------------- |
|
280 // |
|
281 void CLcView::HandleHelpFeature( CEikMenuPane& aMenuPane ) const |
|
282 { |
|
283 // The Help menu item must be displayed only if the Feature is supported. |
|
284 // If not, the Help item must be dimmed in the Options menu. |
|
285 if ( FeatureManager::FeatureSupported( KFeatureIdHelp )) |
|
286 { |
|
287 aMenuPane.SetItemDimmed( EAknCmdHelp, EFalse ); |
|
288 } |
|
289 else |
|
290 { |
|
291 aMenuPane.SetItemDimmed( EAknCmdHelp, ETrue ); |
|
292 } |
|
293 } |
|