1 /* |
|
2 * Copyright (c) 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: SUPL server UI View's container |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System Includes |
|
20 #include <eikspane.h> // Status pane |
|
21 #include <akntitle.h> // CAknTitlePane |
|
22 #include <aknlists.h> |
|
23 #include <StringLoader.h> |
|
24 #include <locsuplsettingsui.rsg> |
|
25 #include <csxhelp/locsupl.hlp.hrh> // Help File |
|
26 #include <aknview.h> |
|
27 #include <eikmenub.h> |
|
28 #include <gulicon.h> |
|
29 #include <AknIconUtils.h> |
|
30 #include <AknIconArray.h> |
|
31 #include <eikclbd.h> |
|
32 #include <avkon.mbg> // for select server (mark) icon |
|
33 #include <avkon.rsg> |
|
34 #include <eiklbx.h> |
|
35 #include <ErrorUI.h> |
|
36 #include <AknsUtils.h> |
|
37 #include <aknapp.h> |
|
38 #include <locsuplsettings.mbg> // for server disable icon |
|
39 |
|
40 // User Includes |
|
41 #include "locsuplsettings.hrh" |
|
42 #include "locsuplsettingsuid.hrh" |
|
43 #include "locsuplservercontainer.h" |
|
44 #include "locsuplserverview.h" |
|
45 #include "locsuplserverlbmodel.h" |
|
46 #include "locsuplsettingsuiengine.h" |
|
47 #include "locsuplsettingseventhandler.h" |
|
48 #include "locsupldebug.h" |
|
49 |
|
50 // CONSTANT DEFINITIONS |
|
51 const TInt KIconArrayGranularity = 2; // The number of default icons |
|
52 _LIT( KLocSuplSettingsIconFileName, "locsuplsettings.mif" ); |
|
53 |
|
54 |
|
55 // ========================= MEMBER FUNCTIONS ================================ |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CLocSUPLServerContainer::CLocSUPLServerContainer |
|
59 // Overloaded Constructor |
|
60 // |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 CLocSUPLServerContainer::CLocSUPLServerContainer( CLocSUPLServerView* aView ) |
|
64 : iView( aView ) |
|
65 { |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CLocSUPLServerContainer::~CLocSUPLServerContainer |
|
70 // Destructor |
|
71 // |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CLocSUPLServerContainer::~CLocSUPLServerContainer() |
|
75 { |
|
76 DEBUG( + CLocSUPLServerContainer::~CLocSUPLServerContainer ); |
|
77 // Delete the List box model only after deleting the list box |
|
78 delete iListBox; |
|
79 iListBox = NULL; |
|
80 |
|
81 delete iListBoxModel; |
|
82 iListBoxModel = NULL; |
|
83 DEBUG( - CLocSUPLServerContainer::~CLocSUPLServerContainer ); |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CLocSUPLServerContainer* CLocSUPLServerContainer::NewL |
|
88 // Static Two phase contructor that instantiates the CLocSUPLServerContainer |
|
89 // |
|
90 // @param aRect Client rectangle |
|
91 // @param aEngine Reference to the SUPL Settings |
|
92 // engine |
|
93 // @param aEventHandler Reference to the parent view |
|
94 // @return CLocSUPLServerContainer* Reference to the object created |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 CLocSUPLServerContainer* CLocSUPLServerContainer::NewL( |
|
98 const TRect& aRect, |
|
99 CLocSUPLSettingsUiEngine& aEngine, |
|
100 CLocSUPLServerView* aView ) |
|
101 { |
|
102 DEBUG( + CLocSUPLServerContainer::NewL ); |
|
103 CLocSUPLServerContainer* self = NewLC( aRect, |
|
104 aEngine, |
|
105 aView ); |
|
106 CleanupStack::Pop( self ); |
|
107 DEBUG( - CLocSUPLServerContainer::NewL ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CLocSUPLServerContainer* CLocSUPLServerContainer::NewLC |
|
113 // Static Two phase contructor that instantiates the CLocSUPLServerContainer |
|
114 // |
|
115 // @param aRect Client rectangle |
|
116 // @param aEngine Reference to the SUPL Settings |
|
117 // engine |
|
118 // @param aEventHandler Reference to the parent view |
|
119 // @return CLocSUPLServerContainer* Reference to the object created |
|
120 // --------------------------------------------------------------------------- |
|
121 // |
|
122 CLocSUPLServerContainer* CLocSUPLServerContainer::NewLC( |
|
123 const TRect& aRect, |
|
124 CLocSUPLSettingsUiEngine& aEngine, |
|
125 CLocSUPLServerView* aView ) |
|
126 { |
|
127 CLocSUPLServerContainer* self = new ( ELeave ) CLocSUPLServerContainer( |
|
128 aView ); |
|
129 CleanupStack::PushL( self ); |
|
130 self->ConstructL( aRect, aEngine ); |
|
131 return self; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // void CLocSUPLServerContainer::ConstructL |
|
136 // Second phase of the two phase Construction process |
|
137 // |
|
138 // @param aRect Client rectangle |
|
139 // @param aEngine Reference to the SUPL Settings engine |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CLocSUPLServerContainer::ConstructL( |
|
143 const TRect& aRect , |
|
144 CLocSUPLSettingsUiEngine& aEngine ) |
|
145 { |
|
146 DEBUG( + CLocSUPLServerContainer::ConstructL ); |
|
147 //Make this control a window-owning control |
|
148 CreateWindowL(); |
|
149 |
|
150 // Create a New Title for the View |
|
151 MakeTitleL( R_LOC_SUPL_SERVER_DETAIL_TITLE ); |
|
152 |
|
153 CreateListboxL( aEngine ); |
|
154 |
|
155 // Get the Help context |
|
156 iContextName = KLOC_HLP_SUPL(); |
|
157 |
|
158 SetRect( aRect ); |
|
159 ActivateL(); |
|
160 DEBUG( - CLocSUPLServerContainer::ConstructL ); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // void CLocSUPLServerContainer::UpdateScreenL |
|
165 // Refreshes the screen so that the list box reflects the latest contents |
|
166 // --------------------------------------------------------------------------- |
|
167 // |
|
168 void CLocSUPLServerContainer::UpdateScreenL() |
|
169 { |
|
170 DEBUG( + CLocSUPLServerContainer::UpdateScreenL ); |
|
171 |
|
172 TInt oldCount = SlpIds().Count(); |
|
173 TInt64 slpId; |
|
174 if( iSelectedIndex != KErrNotFound && SlpIds().Count() > iSelectedIndex ) |
|
175 { |
|
176 slpId = SlpIds()[ iSelectedIndex ]; |
|
177 } |
|
178 |
|
179 if ( iListBoxModel ) |
|
180 { |
|
181 iListBoxModel->UpdateSlpIdsL(); |
|
182 } |
|
183 |
|
184 TInt newCount = SlpIds().Count(); |
|
185 |
|
186 if ( iListBox ) |
|
187 { |
|
188 // Update Listbox items |
|
189 if( newCount <= 0 || newCount == oldCount ) |
|
190 { |
|
191 TRAP_IGNORE( iListBox->HandleItemAdditionL() ); |
|
192 TRAP_IGNORE( iListBox->HandleItemRemovalL() ); |
|
193 } |
|
194 else if( newCount > oldCount ) |
|
195 { |
|
196 // notify the listbox for item addition |
|
197 TRAP_IGNORE( iListBox->HandleItemAdditionL() ); |
|
198 |
|
199 // set focus to newly added item |
|
200 TInt index = iListBox->CurrentItemIndex(); |
|
201 if( index == 0 && newCount == 1 ) |
|
202 { |
|
203 iListBox->SetCurrentItemIndex( 0 ); |
|
204 } |
|
205 else |
|
206 { |
|
207 iListBox->SetCurrentItemIndex( newCount - 1 ); |
|
208 } |
|
209 } |
|
210 else if( newCount < oldCount ) |
|
211 { |
|
212 // notify the listbox for item deletion |
|
213 TRAP_IGNORE( iListBox->HandleItemRemovalL() ); |
|
214 |
|
215 // set focus at last selected item or index |
|
216 if( iSelectedIndex > newCount-1 ) |
|
217 { |
|
218 iListBox->SetCurrentItemIndex( newCount - 1 ); |
|
219 } |
|
220 else |
|
221 { |
|
222 TInt newIndex = SlpIds().Find( slpId ); |
|
223 if( newIndex != KErrNotFound ) |
|
224 { |
|
225 iListBox->SetCurrentItemIndex( newIndex ); |
|
226 } |
|
227 else |
|
228 { |
|
229 iListBox->SetCurrentItemIndex( iSelectedIndex ); |
|
230 } |
|
231 } |
|
232 } |
|
233 } |
|
234 DrawDeferred(); |
|
235 DEBUG( - CLocSUPLServerContainer::UpdateScreenL ); |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // void CLocSUPLServerContainer::HandleResourceChange |
|
240 // |
|
241 // --------------------------------------------------------------------------- |
|
242 void CLocSUPLServerContainer::HandleResourceChange(TInt aType) |
|
243 { |
|
244 DEBUG( + CLocSUPLServerContainer::HandleResourceChange ); |
|
245 // Pass the event to the base class |
|
246 CCoeControl::HandleResourceChange(aType); |
|
247 switch( aType ) |
|
248 { |
|
249 // Dynamic Layout switch |
|
250 case KEikDynamicLayoutVariantSwitch: |
|
251 { |
|
252 SetRect( iView->ClientRect() ); |
|
253 break; |
|
254 } |
|
255 default: |
|
256 { |
|
257 break; |
|
258 } |
|
259 } |
|
260 DEBUG( - CLocSUPLServerContainer::HandleResourceChange ); |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CLocSUPLServerContainer::GetHelpContext |
|
265 // |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 void CLocSUPLServerContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
269 { |
|
270 DEBUG( + CLocSUPLServerContainer::GetHelpContext ); |
|
271 aContext.iContext = iContextName; |
|
272 aContext.iMajor = TUid::Uid( KLOCSUPLSETTINGSUIUID3 ); |
|
273 DEBUG( - CLocSUPLServerContainer::GetHelpContext ); |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // TInt CLocSUPLServerContainer::CountComponentControls |
|
278 // |
|
279 // --------------------------------------------------------------------------- |
|
280 TInt CLocSUPLServerContainer::CountComponentControls() const |
|
281 { |
|
282 return 1; |
|
283 } |
|
284 |
|
285 // --------------------------------------------------------------------------- |
|
286 // CCoeControl* CLocSUPLServerContainer::ComponentControl |
|
287 // |
|
288 // --------------------------------------------------------------------------- |
|
289 CCoeControl* CLocSUPLServerContainer::ComponentControl( TInt /*aIndex*/ ) const |
|
290 { |
|
291 return iListBox; |
|
292 } |
|
293 |
|
294 // --------------------------------------------------------------------------- |
|
295 // void CLocSUPLServerContainer::OfferKeyEventL |
|
296 // |
|
297 // --------------------------------------------------------------------------- |
|
298 // |
|
299 TKeyResponse CLocSUPLServerContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
300 TEventCode aType ) |
|
301 { |
|
302 if ( ( aType == EEventKey || aType == EEventKeyUp) ) |
|
303 { |
|
304 if( aKeyEvent.iCode == EKeyBackspace ) |
|
305 { |
|
306 iView->HandleCommandL( ELocSuplServerDelete ); |
|
307 return EKeyWasConsumed; |
|
308 } |
|
309 } |
|
310 // now it's iListBox's job to process the key event |
|
311 return iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
312 } |
|
313 |
|
314 // --------------------------------------------------------------------------- |
|
315 // void CLocSUPLServerContainer::HandleListBoxEventL |
|
316 // |
|
317 // --------------------------------------------------------------------------- |
|
318 // |
|
319 void CLocSUPLServerContainer::HandleListBoxEventL( CEikListBox* /* aListBox */, |
|
320 TListBoxEvent aEventType ) |
|
321 { |
|
322 DEBUG( + CLocSUPLServerContainer::HandleListBoxEventL ); |
|
323 switch ( aEventType ) |
|
324 { |
|
325 // List box Item Selection |
|
326 case EEventEnterKeyPressed: |
|
327 case EEventItemSingleClicked: |
|
328 { |
|
329 if(iListBox->SelectionIndexes()->Count() > 0) |
|
330 { |
|
331 ShowContextMenuL(); |
|
332 } |
|
333 else |
|
334 { |
|
335 iView->HandleCommandL(ELocSuplServerOpen); |
|
336 } |
|
337 break; |
|
338 } |
|
339 default: |
|
340 break; |
|
341 } |
|
342 DEBUG( - CLocSUPLServerContainer::HandleListBoxEventL ); |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // void CLocSUPLServerContainer::FocusChanged |
|
347 // |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 void CLocSUPLServerContainer::FocusChanged( TDrawNow aDrawNow ) |
|
351 { |
|
352 CCoeControl::FocusChanged( aDrawNow ); |
|
353 // The focus event has to be explicitly handed over to all the compound |
|
354 // controls since CCoeControl does not do that implicitly |
|
355 if ( iListBox ) |
|
356 { |
|
357 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
358 } |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 // CLocSUPLServerContainer::SizeChanged |
|
363 // |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CLocSUPLServerContainer::SizeChanged() |
|
367 { |
|
368 if ( iListBox ) |
|
369 { |
|
370 iListBox->SetRect( Rect() ); |
|
371 } |
|
372 } |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // void CLocSUPLServerContainer::MakeTitleL |
|
376 // Sets the Title text |
|
377 // |
|
378 // @param aResourceText Resource to create title |
|
379 // --------------------------------------------------------------------------- |
|
380 // |
|
381 void CLocSUPLServerContainer::MakeTitleL( TInt aResourceText ) |
|
382 { |
|
383 DEBUG( + CLocSUPLServerContainer::MakeTitleL ); |
|
384 // Obtain the title from the Status Pane |
|
385 CAknTitlePane* title = static_cast < CAknTitlePane* >( StatusPane()-> |
|
386 ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
387 |
|
388 // Set the Title's buffer |
|
389 HBufC* buf = StringLoader::LoadL( aResourceText ); |
|
390 title->SetText( buf ); // Takes ownership of buf |
|
391 DEBUG( - CLocSUPLServerContainer::MakeTitleL ); |
|
392 } |
|
393 |
|
394 // --------------------------------------------------------------------------- |
|
395 // void CLocSUPLServerContainer::StatusPane |
|
396 // Returns the Appui's status pane |
|
397 // |
|
398 // @return CEikStatusPane* Statuspane pointer |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 CEikStatusPane* CLocSUPLServerContainer::StatusPane() |
|
402 { |
|
403 return iEikonEnv->AppUiFactory()->StatusPane(); |
|
404 } |
|
405 |
|
406 // --------------------------------------------------------------------------- |
|
407 // void CLocSUPLServerContainer::CreateListboxL |
|
408 // Creates the List box and the Listbox model. Associates the list box model |
|
409 // with the list box |
|
410 // |
|
411 // @param aEngine Reference to the SUPL Settings |
|
412 // engine |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 void CLocSUPLServerContainer::CreateListboxL( |
|
416 CLocSUPLSettingsUiEngine& aEngine ) |
|
417 { |
|
418 DEBUG( + CLocSUPLServerContainer::CreateListboxL ); |
|
419 // Create the Listbox model |
|
420 iListBoxModel = CLocSUPLServerLBModel::NewL( aEngine ); |
|
421 |
|
422 // CAknSingleNumberStyleListBox "2\tTextLabel\t0\t1" |
|
423 |
|
424 iListBox = new ( ELeave ) CAknSingleNumberStyleListBox; |
|
425 iListBox->ConstructL( |
|
426 this, |
|
427 #ifdef RD_SCALABLE_UI_V2 |
|
428 EAknListBoxStylusMarkableList |
|
429 #else |
|
430 EAknListBoxMarkableList |
|
431 #endif //RD_SCALABLE_UI_V2 |
|
432 ); |
|
433 // Set the container control. |
|
434 iListBox->SetContainerWindowL( *this ); |
|
435 // Add scrollbars to listbox |
|
436 iListBox->CreateScrollBarFrameL( ETrue ); |
|
437 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
438 CEikScrollBarFrame::EAuto ); |
|
439 // Icon array, needed only if listbox style is single number with graphic. |
|
440 CAknIconArray* icons = new( ELeave ) CAknIconArray( KIconArrayGranularity ); |
|
441 CleanupStack::PushL( icons ); |
|
442 |
|
443 TFileName avkonIconFile = AknIconUtils::AvkonIconFileName(); |
|
444 |
|
445 TRAP_IGNORE( AddIconL( *icons, |
|
446 avkonIconFile, |
|
447 KAknsIIDQgnIndiMarkedAdd, |
|
448 EMbmAvkonQgn_indi_marked_add, |
|
449 EMbmAvkonQgn_indi_marked_add_mask ) ); |
|
450 |
|
451 TFileName *iconFile = IconFileNameLC(); |
|
452 |
|
453 TRAP_IGNORE( AddIconL( *icons, |
|
454 *iconFile, |
|
455 KAknsIIDQgnPropRadiobuttOff, |
|
456 EMbmLocsuplsettingsQgn_loc_server_disabled, |
|
457 EMbmLocsuplsettingsQgn_loc_server_disabled_mask ) ); |
|
458 |
|
459 CleanupStack::PopAndDestroy( iconFile ); |
|
460 |
|
461 iListBox->ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
462 CleanupStack::Pop( icons ); |
|
463 |
|
464 // Set the model & observer |
|
465 iListBox->SetListBoxObserver( this ); |
|
466 |
|
467 iListBox->Model()->SetItemTextArray( iListBoxModel ); |
|
468 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
469 iListBox->ActivateL(); |
|
470 DEBUG( - CLocSUPLServerContainer::CreateListboxL ); |
|
471 } |
|
472 |
|
473 // ----------------------------------------------------------------------------- |
|
474 // CLocSUPLServerContainer::AddIconL |
|
475 // ----------------------------------------------------------------------------- |
|
476 void CLocSUPLServerContainer::AddIconL( CAknIconArray& aIcons, |
|
477 const TDesC& aIconFileWithPath, |
|
478 TAknsItemID aSkinID, |
|
479 TInt aIconGraphicsIndex, |
|
480 TInt aIconGraphicsMaskIndex ) |
|
481 { |
|
482 DEBUG( + CLocSUPLServerContainer::AddIconL ); |
|
483 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
484 |
|
485 CFbsBitmap* bitmap = NULL; |
|
486 CFbsBitmap* bitmapMask = NULL; |
|
487 |
|
488 TRAPD( err, AknsUtils::CreateIconL( skin, |
|
489 aSkinID, |
|
490 bitmap, |
|
491 bitmapMask, |
|
492 aIconFileWithPath, |
|
493 aIconGraphicsIndex, |
|
494 aIconGraphicsMaskIndex ) ); |
|
495 |
|
496 if(err != KErrNone) |
|
497 { |
|
498 TRAP( err, AknIconUtils::CreateIconL( bitmap, |
|
499 bitmapMask, |
|
500 aIconFileWithPath, |
|
501 aIconGraphicsIndex, |
|
502 aIconGraphicsMaskIndex ) ); |
|
503 } |
|
504 User::LeaveIfError( err ); |
|
505 |
|
506 CleanupStack::PushL( bitmap ); |
|
507 CleanupStack::PushL( bitmapMask ); |
|
508 |
|
509 CGulIcon* icon = CGulIcon::NewL( bitmap, bitmapMask ); |
|
510 |
|
511 // Remove the Bitmap and the Bitmap Icon from the Clean up stack since |
|
512 // the ownership is taken over by the icon |
|
513 CleanupStack::Pop( bitmapMask ); |
|
514 CleanupStack::Pop( bitmap ); |
|
515 |
|
516 CleanupStack::PushL( icon ); |
|
517 aIcons.AppendL( icon ); |
|
518 CleanupStack::Pop( icon ); // icon |
|
519 DEBUG( - CLocSUPLServerContainer::AddIconL ); |
|
520 } |
|
521 |
|
522 // ----------------------------------------------------------------------------- |
|
523 // CLocSUPLServerContainer::IconFileNameLC |
|
524 // ----------------------------------------------------------------------------- |
|
525 TFileName* CLocSUPLServerContainer::IconFileNameLC() const |
|
526 { |
|
527 TFileName* fileName = new(ELeave) TFileName; |
|
528 CleanupStack::PushL( fileName ); |
|
529 |
|
530 TFileName* tmpName = new(ELeave) TFileName; |
|
531 CleanupStack::PushL( tmpName ); |
|
532 |
|
533 tmpName->Append( KDC_BITMAP_DIR ); |
|
534 tmpName->Append( KLocSuplSettingsIconFileName ); |
|
535 |
|
536 CEikAppUi *appUi = ( CEikAppUi *)( CEikonEnv::Static()->AppUi()); |
|
537 TFileName appDrive = appUi->Application()->AppFullName(); |
|
538 |
|
539 TParse parse; |
|
540 User::LeaveIfError( parse.Set( appDrive, NULL, NULL ) ); |
|
541 User::LeaveIfError( parse.Set( parse.Drive(), tmpName, NULL ) ); |
|
542 |
|
543 fileName->Copy(parse.FullName()); |
|
544 |
|
545 CleanupStack::PopAndDestroy( tmpName ); |
|
546 |
|
547 return fileName; |
|
548 } |
|
549 |
|
550 // ---------------------------------------------------------------------------- |
|
551 // CLocSUPLServerContainer::ListBoxL() |
|
552 // ---------------------------------------------------------------------------- |
|
553 // |
|
554 CEikListBox& CLocSUPLServerContainer::ListBoxL() |
|
555 { |
|
556 User::LeaveIfNull( iListBox ); |
|
557 return *iListBox; |
|
558 } |
|
559 |
|
560 // ----------------------------------------------------------------------------- |
|
561 // TInt CLocSUPLServerContainer::SelectedItemIndex |
|
562 // Returns the Selected element. The list box model defines the enumeration that |
|
563 // would determine the current element that has been selected |
|
564 // |
|
565 // @return TInt Index of the item selected |
|
566 // ----------------------------------------------------------------------------- |
|
567 // |
|
568 TInt CLocSUPLServerContainer::SelectedItemIndex() |
|
569 { |
|
570 return iListBox->CurrentItemIndex(); |
|
571 } |
|
572 |
|
573 // ---------------------------------------------------------------------------- |
|
574 // CLocSUPLServerContainer::CurrentSlpId() |
|
575 // ---------------------------------------------------------------------------- |
|
576 // |
|
577 TInt64 CLocSUPLServerContainer::CurrentSlpId() |
|
578 { |
|
579 if( SelectedItemIndex() != KErrNotFound && SelectedItemIndex() < ServerCount() ) |
|
580 return iListBoxModel->SlpIds()[ SelectedItemIndex() ]; |
|
581 else |
|
582 return KErrNotFound; |
|
583 } |
|
584 |
|
585 // ---------------------------------------------------------------------------- |
|
586 // CLocSUPLServerContainer::SelectedCount() |
|
587 // ---------------------------------------------------------------------------- |
|
588 // |
|
589 TInt CLocSUPLServerContainer::SelectedCount() |
|
590 { |
|
591 return iListBox->SelectionIndexes()->Count(); |
|
592 } |
|
593 |
|
594 // ---------------------------------------------------------------------------- |
|
595 // CLocSUPLServerContainer::SelectedCount() |
|
596 // ---------------------------------------------------------------------------- |
|
597 // |
|
598 TInt CLocSUPLServerContainer::ServerCount() |
|
599 { |
|
600 return iListBox->Model()->NumberOfItems(); |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // CLocSUPLServerContainer::SlpIds() |
|
605 // returns server id array |
|
606 // |
|
607 // --------------------------------------------------------------------------- |
|
608 // |
|
609 RArray<TInt64>& CLocSUPLServerContainer::SlpIds() |
|
610 { |
|
611 return iListBoxModel->SlpIds(); |
|
612 } |
|
613 |
|
614 // --------------------------------------------------------------------------- |
|
615 // CLocSUPLServerContainer::SetIndex() |
|
616 // sets the current selected item |
|
617 // |
|
618 // --------------------------------------------------------------------------- |
|
619 // |
|
620 void CLocSUPLServerContainer::SetSelectedIndex() |
|
621 { |
|
622 iSelectedIndex = SelectedItemIndex(); |
|
623 } |
|
624 |
|
625 // ----------------------------------------------------------------------------- |
|
626 // CLocSUPLServerContainer::ShowContextMenuL |
|
627 // ----------------------------------------------------------------------------- |
|
628 // |
|
629 void CLocSUPLServerContainer::ShowContextMenuL() |
|
630 { |
|
631 DEBUG( + CLocSUPLServerContainer::ShowContextMenuL ); |
|
632 |
|
633 // Switch to Context specific options menu, |
|
634 // Show it and switch back to main options menu. |
|
635 CEikMenuBar* menuBar = iView->MenuBar(); |
|
636 // TRAP displaying of menu bar. |
|
637 // If it fails, the correct resource is set back before leave. |
|
638 TRAPD( err, menuBar->TryDisplayContextMenuBarL() ); |
|
639 User::LeaveIfError( err ); |
|
640 |
|
641 DEBUG( - CLocSUPLServerContainer::ShowContextMenuL ); |
|
642 } |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CLocSUPLServerContainer::HandlePointerEventL |
|
645 // ----------------------------------------------------------------------------- |
|
646 // |
|
647 void CLocSUPLServerContainer::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
648 { |
|
649 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
650 if(aPointerEvent.iType == TPointerEvent::EButton1Down && iListBox->Model()->NumberOfItems() == 0) |
|
651 { |
|
652 ShowContextMenuL(); |
|
653 } |
|
654 } |
|
655 |
|
656 // End of file |
|