apengine/apsettingshandlerui/src/ApSelectorListBoxModel.cpp
changeset 66 ed07dcc72692
parent 0 5a93021fdf25
equal deleted inserted replaced
64:84c6623982f6 66:ed07dcc72692
    55 :CApListItemList(),
    55 :CApListItemList(),
    56 iOffset( 0 ),
    56 iOffset( 0 ),
    57 iFeatureInitialised(EFalse),
    57 iFeatureInitialised(EFalse),
    58 iProtectionSupported(EFalse)
    58 iProtectionSupported(EFalse)
    59     {
    59     {
    60     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::CApSelectorListboxModel<->")
       
    61     iGraphicType = aGraphicType;
       
    62     }
    60     }
    63 
    61 
    64 // ---------------------------------------------------------
    62 // ---------------------------------------------------------
    65 // CApSelectorListboxModel::~CApSelectorListboxModel
    63 // CApSelectorListboxModel::~CApSelectorListboxModel
    66 // ---------------------------------------------------------
    64 // ---------------------------------------------------------
    67 //
    65 //
    68 CApSelectorListboxModel::~CApSelectorListboxModel()
    66 CApSelectorListboxModel::~CApSelectorListboxModel()
    69     {
    67     {
    70     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::~CApSelectorListboxModel<->")
       
    71     ResetAndDestroy(); // deletes all elements...
       
    72     }
    68     }
    73 
    69 
    74 // ---------------------------------------------------------
    70 // ---------------------------------------------------------
    75 // CApSelectorListboxModel::MdcaCount
    71 // CApSelectorListboxModel::MdcaCount
    76 // ---------------------------------------------------------
    72 // ---------------------------------------------------------
    77 //
    73 //
    78 TInt CApSelectorListboxModel::MdcaCount() const
    74 TInt CApSelectorListboxModel::MdcaCount() const
    79     {
    75     {
    80     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::MdcaCount<->")
    76     return 0;
    81     
       
    82     return Count();
       
    83     }
    77     }
    84 
    78 
    85 // ---------------------------------------------------------
    79 // ---------------------------------------------------------
    86 // CApSelectorListboxModel::MdcaPoint
    80 // CApSelectorListboxModel::MdcaPoint
    87 // ---------------------------------------------------------
    81 // ---------------------------------------------------------
    88 //
    82 //
    89 TPtrC CApSelectorListboxModel::MdcaPoint( TInt aIndex ) const
    83 TPtrC CApSelectorListboxModel::MdcaPoint( TInt aIndex ) const
    90     {
    84     {
    91     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::MdcaPoint")
    85     User::Leave( KErrNotSupported );
    92     
       
    93     // We need to cast away the const-ness from the buffer.
       
    94     // It was definitely made for formatting!
       
    95     FormatListboxText( aIndex,
       
    96         ( MUTABLE_CAST(  TBuf<KMaxApSelectorListboxName>&, iBuf ) ) );
       
    97 
       
    98     APSETUILOGGER_LEAVEFN( EListbox,"SelListboxModel::MdcaPoint")
       
    99     return iBuf;
       
   100     }
    86     }
   101 
    87 
   102 
    88 
   103 // ---------------------------------------------------------
    89 // ---------------------------------------------------------
   104 // CApSelectorListboxModel::Item4Uid
    90 // CApSelectorListboxModel::Item4Uid
   105 // ---------------------------------------------------------
    91 // ---------------------------------------------------------
   106 //
    92 //
   107 TInt CApSelectorListboxModel::Item4Uid( TUint32 aUid, TInt& aErr ) const
    93 TInt CApSelectorListboxModel::Item4Uid( TUint32 aUid, TInt& aErr ) const
   108     {
    94     {
   109     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::Item4Uid")
    95     return KErrNotFound;
   110     
       
   111     aErr = KErrNone;
       
   112     TInt retval( KErrNotFound );
       
   113     for ( TInt i=0; i<Count(); i++ )
       
   114         {
       
   115         if ( At( i )->Uid() == aUid )
       
   116             {
       
   117             retval = i;
       
   118             break;
       
   119             }
       
   120         }
       
   121     if ( retval == KErrNotFound )
       
   122         {
       
   123         aErr = KErrNotFound;
       
   124         }
       
   125     
       
   126     APSETUILOGGER_LEAVEFN( EListbox,"SelListboxModel::Item4Uid")
       
   127     return retval;
       
   128     }
    96     }
   129 
    97 
   130 
    98 
   131 
    99 
   132 // ---------------------------------------------------------
   100 // ---------------------------------------------------------
   133 // CApSelectorListboxModel::SetOwnIconOffset
   101 // CApSelectorListboxModel::SetOwnIconOffset
   134 // ---------------------------------------------------------
   102 // ---------------------------------------------------------
   135 //
   103 //
   136 void CApSelectorListboxModel::SetOwnIconOffset( TInt aOffset )
   104 void CApSelectorListboxModel::SetOwnIconOffset( TInt aOffset )
   137     {
   105     {
   138     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::SetOwnIconOffset<->")
       
   139     
       
   140     iOffset = aOffset;
       
   141     }
   106     }
   142 
   107 
   143 
   108 
   144 // ---------------------------------------------------------
   109 // ---------------------------------------------------------
   145 // CApSelectorListboxModel::FormatListboxText
   110 // CApSelectorListboxModel::FormatListboxText
   146 // ---------------------------------------------------------
   111 // ---------------------------------------------------------
   147 //
   112 //
   148 void CApSelectorListboxModel::FormatListboxText( TInt aIndex,
   113 void CApSelectorListboxModel::FormatListboxText( TInt aIndex,
   149                                                 TDes& aBuf ) const
   114                                                 TDes& aBuf ) const
   150     {
   115     {
   151     APSETUILOGGER_ENTERFN( EListbox,"SelListboxModel::FormatListboxText")
       
   152     
       
   153     if ( !iFeatureInitialised )
       
   154         {
       
   155         TRAPD(err, FeatureManager::InitializeLibL());
       
   156         if (err == KErrNone)
       
   157             {
       
   158             CApSelectorListboxModel* tmp = CONST_CAST(CApSelectorListboxModel*, this);
       
   159             tmp->iProtectionSupported = FeatureManager::FeatureSupported( 
       
   160                                             KFeatureIdSettingsProtection );
       
   161             FeatureManager::UnInitializeLib();
       
   162             tmp->iFeatureInitialised = ETrue;
       
   163             }
       
   164         }
       
   165     switch ( iGraphicType )
       
   166         {
       
   167         case EGraphicBearer:
       
   168             {
       
   169             TInt iIconId;
       
   170             switch ( At( aIndex )->BearerType() )
       
   171                 {
       
   172                 case EApBearerTypeCDMA:
       
   173                     {
       
   174                     iIconId = KCDMA_ICON_ID;
       
   175                     break;
       
   176                     }
       
   177                 case EApBearerTypeGPRS:
       
   178                     {
       
   179                     iIconId = KGPRS_ICON_ID;
       
   180                     break;
       
   181                     }
       
   182                 case EApBearerTypeCSD:
       
   183                     {
       
   184                     iIconId = KCSD_ICON_ID;
       
   185                     break;
       
   186                     }
       
   187                 case EApBearerTypeHSCSD:
       
   188                     {
       
   189                     iIconId = KHSCSD_ICON_ID;
       
   190                     break;
       
   191                     }
       
   192                 case EApBearerTypeWLAN:
       
   193                     {
       
   194                     iIconId = KWLAN_ICON_ID;
       
   195                     break;
       
   196                     }
       
   197 #ifdef __TEST_LAN_BEARER
       
   198                 case EApBearerTypeLAN:
       
   199                     {
       
   200                     iIconId = KLAN_ICON_ID;
       
   201                     break;
       
   202                     }
       
   203 #endif // __TEST_LAN_BEARER
       
   204                 case EApBearerTypeLANModem:
       
   205                     { // LANMODEM get real icon ID
       
   206                     iIconId = KWLAN_ICON_ID;
       
   207                     break;
       
   208                     }
       
   209                 default:
       
   210                     {
       
   211                     // in release, shall not leave here,
       
   212                     // it is checked when filled...
       
   213                     __ASSERT_DEBUG( EFalse, Panic( EInvalidBearerType ) );
       
   214                     iIconId = KGPRS_ICON_ID;
       
   215                     break;
       
   216                     }
       
   217                 }
       
   218             if ( iProtectionSupported )
       
   219                 {
       
   220                 if ( At( aIndex )->IsReadOnly() )
       
   221                     {
       
   222                     TInt iProtectedIconId = KPROTECTED_ICON_ID;
       
   223                     aBuf.Format(
       
   224                                 KListItemFormatGraphicProtected,
       
   225                                 iOffset+iIconId,
       
   226                                 Min( At( aIndex )->Name().Length(),
       
   227                                 KMaxListItemNameLength ),
       
   228                                 &At( aIndex )->Name(),
       
   229                                 iOffset+iProtectedIconId
       
   230                                 );
       
   231                     }
       
   232                 else
       
   233                     { // protection supported, but not protected
       
   234                     aBuf.Format(
       
   235                                 KListItemFormatGraphicBearer,
       
   236                                 iOffset+iIconId,
       
   237                                 Min( At( aIndex )->Name().Length(),
       
   238                                 KMaxListItemNameLength ),
       
   239                                 &At( aIndex )->Name()
       
   240                                 );
       
   241                     }
       
   242                 }
       
   243             else
       
   244                 { // protection not supported
       
   245                 aBuf.Format(
       
   246                             KListItemFormatGraphicBearer,
       
   247                             iOffset+iIconId,
       
   248                             Min( At( aIndex )->Name().Length(),
       
   249                             KMaxListItemNameLength ),
       
   250                             &At( aIndex )->Name()
       
   251                             );
       
   252                 }
       
   253             break;
       
   254             }
       
   255         case EGraphicNone:
       
   256             {
       
   257             aBuf.Format(
       
   258                         KListItemFormatGraphicNone,
       
   259                         Min( At( aIndex )->Name().Length(),
       
   260                         KMaxListItemNameLength ),
       
   261                         &At( aIndex )->Name()
       
   262                         );
       
   263             break;
       
   264             }
       
   265         case EGraphicOnOff:
       
   266             {
       
   267             if ( iProtectionSupported )
       
   268                 {
       
   269                 TInt ProtectedIconId( 0 );
       
   270                 if ( At( aIndex )->IsReadOnly() )
       
   271                     {
       
   272                     ProtectedIconId = KPROTECTED_ICON_ID;
       
   273                     aBuf.Format( 
       
   274                                 KListItemFormatGraphicOnOffWithLock,
       
   275                                 1, 
       
   276                                 Min( At( aIndex )->Name().Length(), 
       
   277                                 KMaxListItemNameLength ), 
       
   278                                 &At( aIndex )->Name(),
       
   279                                 iOffset + ProtectedIconId
       
   280                                 );
       
   281                     }
       
   282                 else
       
   283                     {
       
   284                     aBuf.Format(
       
   285                             KListItemFormatGraphicOnOff, 
       
   286                             1, 
       
   287                             Min( At( aIndex )->Name().Length(), 
       
   288                             KMaxListItemNameLength ), 
       
   289                             &At( aIndex )->Name() 
       
   290                             ); // magic Number, does not works with anything else
       
   291                     }
       
   292                 }
       
   293             else
       
   294                 {
       
   295                 aBuf.Format(
       
   296                             KListItemFormatGraphicOnOff,
       
   297                             1,
       
   298                             Min( At( aIndex )->Name().Length(),
       
   299                             KMaxListItemNameLength ),
       
   300                             &At( aIndex )->Name()
       
   301                             );
       
   302                 }
       
   303             break;
       
   304             }
       
   305         case EGraphicProtection:
       
   306             {
       
   307             if ( iProtectionSupported )
       
   308                 {
       
   309                 TInt ProtectedIconId( 0 );
       
   310                 if ( At( aIndex )->IsReadOnly() )
       
   311                     {
       
   312                     ProtectedIconId = 0;
       
   313                     aBuf.Format( 
       
   314                                 KListItemFormatGraphicWithLock,
       
   315                                 Min( At( aIndex )->Name().Length(), 
       
   316                                 KMaxListItemNameLength ), 
       
   317                                 &At( aIndex )->Name(),
       
   318                                 iOffset + ProtectedIconId
       
   319                                 );
       
   320                     }
       
   321                 else
       
   322                     {
       
   323                     aBuf.Format(
       
   324                                 KListItemFormatGraphicNone, 
       
   325                                 Min( At( aIndex )->Name().Length(), 
       
   326                                 KMaxListItemNameLength ), 
       
   327                                 &At( aIndex )->Name() 
       
   328                                 ); 
       
   329                     }                
       
   330                 }
       
   331             else
       
   332                 {
       
   333                 aBuf.Format(
       
   334                             KListItemFormatGraphicNone, 
       
   335                             Min( At( aIndex )->Name().Length(), 
       
   336                             KMaxListItemNameLength ), 
       
   337                             &At( aIndex )->Name() 
       
   338                             );
       
   339                 }
       
   340             break;
       
   341             }
       
   342         default:
       
   343             {
       
   344             __ASSERT_DEBUG( EFalse, Panic( EInvalidBitmapType ) );
       
   345             break;
       
   346             }
       
   347         }
       
   348     
       
   349     APSETUILOGGER_LEAVEFN( EListbox,"SelListboxModel::FormatListboxText")
       
   350     }
   116     }
   351 
   117 
   352 // End of File
   118 // End of File