|
1 /* |
|
2 * Copyright (c) 2002-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: A service dialing name list view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPsu2ServiceDialingView.h" |
|
22 |
|
23 // Phonebook 2 |
|
24 #include <CPbk2UIExtensionView.h> |
|
25 #include <MPbk2ViewActivationTransaction.h> |
|
26 #include <CPbk2AppUiBase.h> |
|
27 #include <MPbk2ViewExplorer.h> |
|
28 #include <Pbk2USimUIRes.rsg> |
|
29 #include <CPbk2ViewState.h> |
|
30 #include <CPbk2NamesListControl.h> |
|
31 #include <Pbk2UIControls.rsg> |
|
32 |
|
33 // System includes |
|
34 #include <StringLoader.h> |
|
35 #include <eikmenup.h> |
|
36 #include <aknnavide.h> |
|
37 #include <aknnavi.h> |
|
38 #include <AknUtils.h> |
|
39 #include <eikmenub.h> |
|
40 |
|
41 |
|
42 /// Unnamed namespace for local definitions |
|
43 namespace { |
|
44 |
|
45 /** |
|
46 * Returns ETrue if shift is depressed in given key event. |
|
47 * |
|
48 * @param aKeyEvent Key event. |
|
49 * @return ETrue if shift is pressed. |
|
50 */ |
|
51 inline TBool ShiftDown( const TKeyEvent& aKeyEvent ) |
|
52 { |
|
53 return ( aKeyEvent.iModifiers & |
|
54 ( EModifierShift | EModifierLeftShift | EModifierRightShift ) ) != 0; |
|
55 } |
|
56 |
|
57 } /// namespace |
|
58 |
|
59 |
|
60 // -------------------------------------------------------------------------- |
|
61 // CPsu2ServiceDialingView::CPsu2ServiceDialingView |
|
62 // C++ default constructor can NOT contain any code, that |
|
63 // might leave. |
|
64 // -------------------------------------------------------------------------- |
|
65 // |
|
66 CPsu2ServiceDialingView::CPsu2ServiceDialingView( |
|
67 CPbk2UIExtensionView& aExtensionView, CPsu2ViewManager& aViewManager) |
|
68 : CPsu2NameListViewBase(aExtensionView, aViewManager) |
|
69 { |
|
70 } |
|
71 |
|
72 // -------------------------------------------------------------------------- |
|
73 // CPsu2ServiceDialingView::~CPsu2ServiceDialingView |
|
74 // -------------------------------------------------------------------------- |
|
75 // |
|
76 CPsu2ServiceDialingView::~CPsu2ServiceDialingView() |
|
77 { |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 // CPsu2ServiceDialingView::NewL |
|
82 // -------------------------------------------------------------------------- |
|
83 // |
|
84 CPsu2ServiceDialingView* CPsu2ServiceDialingView::NewL |
|
85 ( CPbk2UIExtensionView& aExtensionView, |
|
86 CPsu2ViewManager& aViewManager ) |
|
87 { |
|
88 CPsu2ServiceDialingView* self = new ( ELeave ) CPsu2ServiceDialingView |
|
89 ( aExtensionView, aViewManager ); |
|
90 return self; |
|
91 } |
|
92 |
|
93 // -------------------------------------------------------------------------- |
|
94 // CPsu2ServiceDialingView::HandleCommandKeyL |
|
95 // -------------------------------------------------------------------------- |
|
96 // |
|
97 TBool CPsu2ServiceDialingView::HandleCommandKeyL( const TKeyEvent& aKeyEvent, |
|
98 TEventCode aType) |
|
99 { |
|
100 const TBool marked( iControl->ContactsMarked() ); |
|
101 if ( aKeyEvent.iCode == EKeyOK && |
|
102 aType == EEventKey ) |
|
103 { |
|
104 if ( !ShiftDown( aKeyEvent ) ) |
|
105 { |
|
106 if ( marked ) |
|
107 { |
|
108 iExtensionView.LaunchPopupMenuL( |
|
109 R_PSU2_SERVICE_DIALING_CONTEXT_MENUBAR); |
|
110 } |
|
111 else |
|
112 { |
|
113 if ( iControl->NumberOfContacts() > 0 ) |
|
114 { |
|
115 OpenInfoViewCmdL( *iControl ); |
|
116 } |
|
117 } |
|
118 return ETrue; |
|
119 } |
|
120 } |
|
121 // green call |
|
122 else if( aKeyEvent.iCode == EKeyPhoneSend && |
|
123 aType == EEventKey ) |
|
124 { |
|
125 if ( iControl->NumberOfContacts() > 0 && !marked ) |
|
126 { |
|
127 HandleCommandL(EPbk2CmdCall); |
|
128 } |
|
129 return ETrue; |
|
130 } |
|
131 |
|
132 if ( ShiftDown( aKeyEvent ) ) |
|
133 { |
|
134 // Update cbas when shift and msk is pressed. |
|
135 UpdateCbasL(); |
|
136 } |
|
137 |
|
138 return CPsu2NameListViewBase::HandleCommandKeyL( aKeyEvent, aType ); |
|
139 } |
|
140 |
|
141 // -------------------------------------------------------------------------- |
|
142 // CPsu2ServiceDialingView::DoActivateL |
|
143 // -------------------------------------------------------------------------- |
|
144 // |
|
145 void CPsu2ServiceDialingView::DoActivateL(const TVwsViewId& aPrevViewId, |
|
146 TUid aCustomMessageId, const TDesC8& aCustomMessage) |
|
147 { |
|
148 HBufC* title = StringLoader::LoadLC(R_QTN_SDN_TITLE); |
|
149 TContextPaneIcon icon(EPsu2qgn_menu_simin); |
|
150 CEikImage* image = icon.CreateLC(); |
|
151 |
|
152 MPbk2ViewActivationTransaction* viewActivationTransaction = |
|
153 Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()-> |
|
154 HandleViewActivationLC |
|
155 ( iExtensionView.Id(), aPrevViewId, title, image, |
|
156 Phonebook2::EUpdateNaviPane | |
|
157 Phonebook2::EUpdateContextPane | |
|
158 Phonebook2::EUpdateTitlePane ); |
|
159 |
|
160 // Call base class |
|
161 CPsu2NameListViewBase::DoActivateL( |
|
162 aPrevViewId, aCustomMessageId, aCustomMessage); |
|
163 |
|
164 viewActivationTransaction->Commit(); |
|
165 CleanupStack::PopAndDestroy(3,title); // viewActivationTransaction, |
|
166 // title, image |
|
167 // Create empty navigation pane |
|
168 if (!iNaviPane) |
|
169 { |
|
170 iNaviPane = static_cast<CAknNavigationControlContainer*>( |
|
171 iAvkonAppUi->StatusPane()->ControlL( |
|
172 TUid::Uid(EEikStatusPaneUidNavi))); |
|
173 } |
|
174 if ( !iNaviDecorator ) |
|
175 { |
|
176 iNaviDecorator = iNaviPane->CreateNavigationLabelL(); |
|
177 iNaviPane->PushL(*iNaviDecorator); |
|
178 } |
|
179 } |
|
180 |
|
181 // -------------------------------------------------------------------------- |
|
182 // CPsu2FixedDialingView::DoDeactivate |
|
183 // -------------------------------------------------------------------------- |
|
184 // |
|
185 void CPsu2ServiceDialingView::DoDeactivate() |
|
186 { |
|
187 if (iNaviPane && iNaviDecorator) |
|
188 { |
|
189 iNaviPane->Pop(iNaviDecorator); |
|
190 } |
|
191 delete iNaviDecorator; |
|
192 iNaviDecorator = NULL; |
|
193 CPsu2NameListViewBase::DoDeactivate(); |
|
194 } |
|
195 |
|
196 // -------------------------------------------------------------------------- |
|
197 // CPsu2ServiceDialingView::HandleCommandL |
|
198 // -------------------------------------------------------------------------- |
|
199 // |
|
200 void CPsu2ServiceDialingView::HandleCommandL(TInt aCommand) |
|
201 { |
|
202 switch( aCommand ) |
|
203 { |
|
204 case EPsu2CmdOpenServiceDialingInfoView: |
|
205 { |
|
206 OpenInfoViewCmdL( *iControl ); |
|
207 break; |
|
208 } |
|
209 default: |
|
210 { |
|
211 CPsu2NameListViewBase::HandleCommandL( aCommand ); |
|
212 break; |
|
213 } |
|
214 }; |
|
215 } |
|
216 |
|
217 // -------------------------------------------------------------------------- |
|
218 // CPsu2ServiceDialingView::DynInitMenuPaneL |
|
219 // -------------------------------------------------------------------------- |
|
220 // |
|
221 void CPsu2ServiceDialingView::DynInitMenuPaneL(TInt aResourceId, |
|
222 CEikMenuPane* aMenuPane) |
|
223 { |
|
224 switch( aResourceId ) |
|
225 { |
|
226 case R_PSU2_SERVICE_DIALING_OPEN_MENUPANE: |
|
227 { |
|
228 const TInt count( iControl->NumberOfContacts() ); |
|
229 const TBool marked( iControl->ContactsMarked() ); |
|
230 |
|
231 if ( count <= 0 || marked ) |
|
232 { |
|
233 aMenuPane->SetItemDimmed( EPsu2CmdOpenServiceDialingInfoView , ETrue ); |
|
234 } |
|
235 break; |
|
236 } |
|
237 case R_PSU2_SERVICE_DIALING_COPY_MENUPANE: |
|
238 { |
|
239 const TInt count( iControl->NumberOfContacts() ); |
|
240 if ( count <= 0 ) |
|
241 { |
|
242 aMenuPane->SetItemDimmed( EPbk2CmdCopy, ETrue ); |
|
243 } |
|
244 break; |
|
245 } |
|
246 default: |
|
247 { |
|
248 CPsu2NameListViewBase::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
249 break; |
|
250 } |
|
251 }; |
|
252 } |
|
253 |
|
254 // -------------------------------------------------------------------------- |
|
255 // CPsu2ServiceDialingView::NameListControlResourceId |
|
256 // -------------------------------------------------------------------------- |
|
257 // |
|
258 TInt CPsu2ServiceDialingView::NameListControlResourceId() const |
|
259 { |
|
260 return R_PSU2_SERVICE_DIALING_NAME_LIST_CONTROL; |
|
261 } |
|
262 |
|
263 // -------------------------------------------------------------------------- |
|
264 // CPsu2ServiceDialingView::OpenInfoViewCmdL |
|
265 // -------------------------------------------------------------------------- |
|
266 // |
|
267 void CPsu2ServiceDialingView::OpenInfoViewCmdL |
|
268 ( MPbk2ContactUiControl& aUiControl ) const |
|
269 { |
|
270 if (!aUiControl.ContactsMarked()) |
|
271 { |
|
272 CPbk2ViewState* state = aUiControl.ControlStateL(); |
|
273 CleanupStack::PushL(state); |
|
274 Phonebook2::Pbk2AppUi()->Pbk2ViewExplorer()-> |
|
275 ActivatePhonebook2ViewL( TUid::Uid |
|
276 ( EPsu2ServiceDialingInfoViewId ), state ); |
|
277 |
|
278 CleanupStack::PopAndDestroy(); // state |
|
279 aUiControl.UpdateAfterCommandExecution(); |
|
280 } |
|
281 } |
|
282 |
|
283 // -------------------------------------------------------------------------- |
|
284 // CPsu2ServiceDialingView::UpdateCbasL |
|
285 // -------------------------------------------------------------------------- |
|
286 // |
|
287 void CPsu2ServiceDialingView::UpdateCbasL() |
|
288 { |
|
289 if ( iControl->NumberOfContacts() > 0 |
|
290 && !iControl->ContactsMarked() ) |
|
291 { |
|
292 // Set middle softkey as Open. |
|
293 iExtensionView.Cba()->SetCommandSetL(R_PSU_SOFTKEYS_OPTIONS_BACK_OPEN); |
|
294 iExtensionView.Cba()->DrawDeferred(); |
|
295 } |
|
296 else |
|
297 { |
|
298 if ( iControl->ContactsMarked() ) |
|
299 { |
|
300 // Set middle softkey as Context menu. |
|
301 iExtensionView.Cba()->SetCommandSetL(R_PBK2_SOFTKEYS_OPTIONS_BACK_CONTEXT); |
|
302 iExtensionView.Cba()->DrawDeferred(); |
|
303 // Change context menu when marked items |
|
304 iExtensionView.MenuBar()->SetContextMenuTitleResourceId |
|
305 ( R_PSU2_SERVICE_DIALING_CONTEXT_MENUBAR ); |
|
306 } |
|
307 else |
|
308 { |
|
309 // Set middle softkey as Open. |
|
310 iExtensionView.Cba()->SetCommandSetL(R_PBK2_SOFTKEYS_OPTIONS_BACK_EMPTY); |
|
311 iExtensionView.Cba()->DrawDeferred(); |
|
312 // Change context menu when nameslist is empty |
|
313 iExtensionView.MenuBar()->SetContextMenuTitleResourceId |
|
314 ( R_PSU2_SERVICE_DIALING_CONTEXT_MENUBAR ); |
|
315 } |
|
316 } |
|
317 } |
|
318 |
|
319 // -------------------------------------------------------------------------- |
|
320 // CPsu2ServiceDialingView::HandleControlEventL |
|
321 // -------------------------------------------------------------------------- |
|
322 // |
|
323 void CPsu2ServiceDialingView::HandleControlEventL( |
|
324 MPbk2ContactUiControl& aControl, |
|
325 const TPbk2ControlEvent& aEvent ) |
|
326 { |
|
327 switch ( aEvent.iEventType ) |
|
328 { |
|
329 case TPbk2ControlEvent::EContactDoubleTapped: |
|
330 { |
|
331 if ( iControl->ContactsMarked() ) |
|
332 { |
|
333 iExtensionView.LaunchPopupMenuL( |
|
334 R_PSU2_SERVICE_DIALING_CONTEXT_MENUBAR); |
|
335 } |
|
336 else |
|
337 { |
|
338 // Open contact |
|
339 HandleCommandL( EPsu2CmdOpenServiceDialingInfoView ); |
|
340 } |
|
341 break; |
|
342 } |
|
343 |
|
344 default: |
|
345 { |
|
346 CPsu2NameListViewBase::HandleControlEventL( aControl, aEvent ); |
|
347 break; |
|
348 } |
|
349 } |
|
350 } |
|
351 // End of File |