apengine/apsettingshandlerui/src/ApSelectorListBox.cpp
changeset 66 ed07dcc72692
parent 47 cb7afde124a3
equal deleted inserted replaced
64:84c6623982f6 66:ed07dcc72692
    48 // ---------------------------------------------------------
    48 // ---------------------------------------------------------
    49 //
    49 //
    50 CApSelectorListbox* CApSelectorListbox::NewL
    50 CApSelectorListbox* CApSelectorListbox::NewL
    51 ( const CCoeControl* aParent )
    51 ( const CCoeControl* aParent )
    52     {
    52     {
    53     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::NewL")
    53     return NULL;
    54     
       
    55     CApSelectorListbox* listbox =
       
    56         new ( ELeave ) CApSelectorListbox();
       
    57     CleanupStack::PushL( listbox );
       
    58     listbox->ConstructL( aParent, EAknListBoxSelectionList );
       
    59     CleanupStack::Pop();    // listbox
       
    60     
       
    61     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::NewL")
       
    62     return listbox;
       
    63     }
    54     }
    64 
    55 
    65 
    56 
    66 // ---------------------------------------------------------
    57 // ---------------------------------------------------------
    67 // CApSelectorListbox::CApSelectorListbox
    58 // CApSelectorListbox::CApSelectorListbox
    87 // ---------------------------------------------------------
    78 // ---------------------------------------------------------
    88 //
    79 //
    89 TKeyResponse CApSelectorListbox::OfferKeyEventL
    80 TKeyResponse CApSelectorListbox::OfferKeyEventL
    90 ( const TKeyEvent& aKeyEvent, TEventCode aType )
    81 ( const TKeyEvent& aKeyEvent, TEventCode aType )
    91     {
    82     {
    92     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::OfferKeyEventL")
    83     User::Leave( KErrNotSupported );
    93     
       
    94     TKeyResponse retval;
       
    95     if (    aKeyEvent.iCode == EKeyOK &&
       
    96             !( aKeyEvent.iModifiers & EModifierShift )
       
    97        )
       
    98         {
       
    99         // Enter pressed (not Shift-Enter). This will report an
       
   100         // EEnterKeyPressed event sent to the observer (the view), which may
       
   101         // delete this listbox. The code which processes keypresses by
       
   102         // default, will continue (on the already deleted listbox), and
       
   103         // will crash. So we grab this keypress here, and generate the
       
   104         // same event, but after that, quit immediately!
       
   105         ReportListBoxEventL( MEikListBoxObserver::EEventEnterKeyPressed );
       
   106         // By now the listbox may have been deleted!
       
   107         // Do not access it after this point!
       
   108         retval = EKeyWasConsumed;
       
   109         }
       
   110     else
       
   111         {
       
   112         retval = CAknSingleGraphicStyleListBox::OfferKeyEventL
       
   113             ( aKeyEvent, aType );
       
   114         }
       
   115     
       
   116     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::OfferKeyEventL")
       
   117     return retval;
       
   118     }
    84     }
   119 
    85 
   120 
    86 
   121 
    87 
   122 // ---------------------------------------------------------
    88 // ---------------------------------------------------------
   123 // CApSelectorListbox::FocusChanged
    89 // CApSelectorListbox::FocusChanged
   124 // ---------------------------------------------------------
    90 // ---------------------------------------------------------
   125 //
    91 //
   126 void CApSelectorListbox::FocusChanged( TDrawNow aDrawNow )
    92 void CApSelectorListbox::FocusChanged( TDrawNow aDrawNow )
   127     {
    93     {
   128     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::FocusChanged")
       
   129     
       
   130     // Do nothing until the listbox is fully constructed
       
   131     // The dialogpage sets the focus before calling ConstructL
       
   132     if ( iView )
       
   133         {
       
   134         CAknSingleGraphicStyleListBox::FocusChanged( aDrawNow );
       
   135         }
       
   136     
       
   137     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::FocusChanged")
       
   138     }
    94     }
   139 
    95 
   140 
    96 
   141 
    97 
   142 // ---------------------------------------------------------
    98 // ---------------------------------------------------------
   143 // CApSelectorListbox::LoadIconsL
    99 // CApSelectorListbox::LoadIconsL
   144 // ---------------------------------------------------------
   100 // ---------------------------------------------------------
   145 //
   101 //
   146 void CApSelectorListbox::LoadIconsL()
   102 void CApSelectorListbox::LoadIconsL()
   147     {
   103     {
   148     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::LoadIconsL")
       
   149 
       
   150     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( KGranularity );
       
   151     CleanupStack::PushL( icons );
       
   152 
       
   153     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   154 
       
   155     TParse mbmFile;
       
   156     User::LeaveIfError( mbmFile.Set( KFileIcons, &KDC_APP_BITMAP_DIR, NULL ) );
       
   157 
       
   158     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   159                                 skinInstance, 
       
   160                                 KAknsIIDQgnPropWmlGprs,
       
   161                                 mbmFile.FullName(), 
       
   162                                 EMbmApsettingsQgn_prop_wml_gprs, 
       
   163                                 EMbmApsettingsQgn_prop_wml_gprs_mask ) );
       
   164 
       
   165     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   166                                 skinInstance, 
       
   167                                 KAknsIIDQgnPropWmlCsd,
       
   168                                 mbmFile.FullName(), 
       
   169                                 EMbmApsettingsQgn_prop_wml_csd, 
       
   170                                 EMbmApsettingsQgn_prop_wml_csd_mask ) );
       
   171 
       
   172     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   173                                 skinInstance, 
       
   174                                 KAknsIIDQgnPropWmlHscsd,
       
   175                                 mbmFile.FullName(), 
       
   176                                 EMbmApsettingsQgn_prop_wml_hscsd, 
       
   177                                 EMbmApsettingsQgn_prop_wml_hscsd_mask ) );
       
   178 
       
   179     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   180                                 skinInstance, 
       
   181                                 KAknsIIDQgnPropWmlSms,
       
   182                                 mbmFile.FullName(), 
       
   183                                 EMbmApsettingsQgn_prop_wml_sms, 
       
   184                                 EMbmApsettingsQgn_prop_wml_sms_mask ) );
       
   185 
       
   186     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   187                                 skinInstance, 
       
   188                                 KAknsIIDQgnPropWlanBearer,
       
   189                                 mbmFile.FullName(), 
       
   190                                 EMbmApsettingsQgn_prop_wlan_bearer, 
       
   191                                 EMbmApsettingsQgn_prop_wlan_bearer_mask ) );
       
   192                                             
       
   193 
       
   194     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   195                                 skinInstance, 
       
   196                                 KAknsIIDQgnPropWlanBearer,
       
   197                                 mbmFile.FullName(), 
       
   198                                 EMbmApsettingsQgn_prop_wlan_easy, 
       
   199                                 EMbmApsettingsQgn_prop_wlan_easy_mask ) );
       
   200                                             
       
   201 
       
   202     FeatureManager::InitializeLibL();
       
   203     TBool protsupported = FeatureManager::FeatureSupported( 
       
   204                                            KFeatureIdSettingsProtection );
       
   205     FeatureManager::UnInitializeLib();
       
   206     if ( protsupported )
       
   207         {
       
   208         icons->AppendL( AknsUtils::CreateGulIconL( 
       
   209                                 skinInstance, 
       
   210                                 KAknsIIDQgnIndiSettProtectedAdd,
       
   211                                 mbmFile.FullName(), 
       
   212                                 EMbmApsettingsQgn_indi_sett_protected_add, 
       
   213                                 EMbmApsettingsQgn_indi_sett_protected_add_mask ) );
       
   214         }
       
   215 
       
   216     ItemDrawer()->ColumnData()->SetIconArray( icons );
       
   217 
       
   218     CleanupStack::Pop(); // icons
       
   219     
       
   220     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::LoadIconsL")
       
   221     }
   104     }
   222 
   105 
   223 
   106 
   224 // ---------------------------------------------------------
   107 // ---------------------------------------------------------
   225 // CApSelectorListbox::Uid4Item
   108 // CApSelectorListbox::Uid4Item
   226 // ---------------------------------------------------------
   109 // ---------------------------------------------------------
   227 //
   110 //
   228 TUint32 CApSelectorListbox::Uid4Item( TInt aItem ) const
   111 TUint32 CApSelectorListbox::Uid4Item( TInt aItem ) const
   229     {
   112     {
   230     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::Uid4Item<->")
   113     return 0;
   231     
       
   232     CApSelectorListboxModel* lbmodel =
       
   233         STATIC_CAST( CApSelectorListboxModel*, Model()->ItemTextArray() );
       
   234     return lbmodel->At( aItem )->Uid();
       
   235     }
   114     }
   236 
   115 
   237 
   116 
   238 // ---------------------------------------------------------
   117 // ---------------------------------------------------------
   239 // CApSelectorListbox::CurrentItemUid
   118 // CApSelectorListbox::CurrentItemUid
   240 // ---------------------------------------------------------
   119 // ---------------------------------------------------------
   241 //
   120 //
   242 TUint32 CApSelectorListbox::CurrentItemUid() const
   121 TUint32 CApSelectorListbox::CurrentItemUid() const
   243     {
   122     {
   244     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::CurrentItemUid")
   123     return 0;
   245     
       
   246     CApSelectorListboxModel* lbmodel =
       
   247         STATIC_CAST( CApSelectorListboxModel*, Model()->ItemTextArray() );
       
   248     TInt idx = CurrentItemIndex();
       
   249     TUint32 retval( 0 );
       
   250     if ( idx >= 0 )
       
   251         {
       
   252         retval = lbmodel->At( idx )->Uid();
       
   253         }
       
   254     
       
   255     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::CurrentItemUid")
       
   256     return retval;
       
   257     }
   124     }
   258 
   125 
   259 
   126 
   260 
   127 
   261 // ---------------------------------------------------------
   128 // ---------------------------------------------------------
   262 // CApSelectorListbox::CurrentItemNameL
   129 // CApSelectorListbox::CurrentItemNameL
   263 // ---------------------------------------------------------
   130 // ---------------------------------------------------------
   264 //
   131 //
   265 const TDesC& CApSelectorListbox::CurrentItemNameL()
   132 const TDesC& CApSelectorListbox::CurrentItemNameL()
   266     {
   133     {
   267     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::CurrentItemNameL")
   134     User::Leave( KErrNotSupported );
   268     
       
   269     CApSelectorListboxModel* lbmodel = new( ELeave )CApSelectorListboxModel;
       
   270     lbmodel = 
       
   271         STATIC_CAST( CApSelectorListboxModel*, Model()->ItemTextArray() );
       
   272     
       
   273     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::CurrentItemNameL")
       
   274     return lbmodel->At( CurrentItemIndex() )->Name();
       
   275     }
   135     }
   276 
   136 
   277 
   137 
   278 // ---------------------------------------------------------
   138 // ---------------------------------------------------------
   279 // CApSelectorListbox::HandleResourceChange
   139 // CApSelectorListbox::HandleResourceChange
   280 // ---------------------------------------------------------
   140 // ---------------------------------------------------------
   281 //
   141 //
   282 void CApSelectorListbox::HandleResourceChange(TInt aType)
   142 void CApSelectorListbox::HandleResourceChange(TInt aType)
   283     {
   143     {
   284     APSETUILOGGER_ENTERFN( EListbox,"SelListbox::HandleResourceChange")
       
   285     
       
   286     if ( aType == KAknsMessageSkinChange )
       
   287         {
       
   288         TRAP_IGNORE( LoadIconsL() );
       
   289         SizeChanged();
       
   290         }
       
   291         
       
   292     CAknSingleGraphicStyleListBox::HandleResourceChange( aType );
       
   293     
       
   294     APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::HandleResourceChange")
       
   295     }
   144     }
   296 
   145 
   297 // End of File
   146 // End of File