|
S60 3rd Edition SDK for Symbian OS Example Applications Guide |
#include <LandmarksCategoriesModel.h>
Public Member Functions | |
| ~CLandmarksCategoriesModel () | |
| void | SetItemIds (RArray< TPosLmItemId > *aItemIds) |
| CDesCArraySeg * | ItemList () |
| void | SetCurrentItem (TInt aIndex) |
| TPosLmItemId | CurrentItemId () |
| CIconList * | CreateIconListL () |
| void | RepopulateModelL (CArrayPtr< CPosLandmarkCategory > *aCategories) |
Static Public Member Functions | |
| static CLandmarksCategoriesModel * | NewL () |
Private Member Functions | |
| CLandmarksCategoriesModel () | |
| void | ConstructL () |
| HBufC * | FormatListItemLC (CPosLandmarkCategory &aCategory) |
| void | AppendIconL (const TDesC &aMbmFile, TInt aIconOffset, TInt aMaskOffset) |
Private Attributes | |
| RArray< TPosLmItemId > * | iItemIds |
| contains the ids idenetifying the categories in the DB | |
| TInt | iCurrentItem |
| indicates which item in the model is selected | |
| CDesCArraySeg * | iListItems |
| CIconList * | iIconList |
| an array of category icons | |
Definition at line 30 of file LandmarksCategoriesModel.h.
|
|
Destructor. Definition at line 110 of file LandmarksCategoriesModel.cpp. References iListItems. 00111 { 00112 delete iListItems; 00113 }
|
|
|
C++ constructor. Definition at line 79 of file LandmarksCategoriesModel.cpp.
|
|
|
Two-phased constructor. Definition at line 99 of file LandmarksCategoriesModel.cpp. References CLandmarksCategoriesModel(). 00100 { 00101 CLandmarksCategoriesModel* self = 00102 new (ELeave) CLandmarksCategoriesModel(); 00103 CleanupStack::PushL(self); 00104 self->ConstructL(); 00105 CleanupStack::Pop(self); 00106 return self; 00107 }
|
|
|
Sets the data member iItemIds
Definition at line 121 of file LandmarksCategoriesModel.cpp. References iItemIds, and iListItems. 00122 { 00123 iItemIds = aItemIds; 00124 00125 // Empty descriptor model 00126 iListItems->Reset(); 00127 }
|
|
|
ItemList returns a pointer to an array to be used for the listbox
Definition at line 135 of file LandmarksCategoriesModel.cpp. References iListItems. 00136 { 00137 return iListItems; 00138 }
|
|
|
SetCurrentItem sets the item in the model that is selected in the listbox.
Definition at line 146 of file LandmarksCategoriesModel.cpp. References iCurrentItem. 00147 { 00148 iCurrentItem = aIndex; 00149 }
|
|
|
CurrentItemId returns the id of the current item from the model.
Definition at line 157 of file LandmarksCategoriesModel.cpp. References iCurrentItem, and iItemIds. 00158 { 00159 if (iCurrentItem < 0 || iCurrentItem > iItemIds->Count() - 1) 00160 { 00161 return KPosLmNullItemId; 00162 } 00163 00164 return (*iItemIds)[iCurrentItem]; 00165 }
|
|
|
CreateIconListL creates and returns an array of icons that is displayed in the listbox. Caller takes ownership of the returned array.
Definition at line 173 of file LandmarksCategoriesModel.cpp. References iIconList. 00174 { 00175 CIconList* iconList = new (ELeave) CArrayPtrFlat<CGulIcon>(KGranularity); 00176 CleanupStack::PushL(TCleanupItem(ResetAndDestroyIcons, iconList)); 00177 00178 // Create the global category icon consisting of its image and mask. 00179 TAknsItemID aknsItemId ={0,0}; 00180 CGulIcon* icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, 00181 KLandmarksMbmFileName, 00182 EMbmLmrefappCategory_global, 00183 EMbmLmrefappCategory_global_mask); 00184 CleanupStack::PushL(icon); 00185 icon->SetBitmapsOwnedExternally(EFalse); 00186 iconList->AppendL(icon); 00187 CleanupStack::Pop(icon); 00188 00189 // Create the user defined category icon consisting of its image and mask. 00190 icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, 00191 KLandmarksMbmFileName, 00192 EMbmLmrefappCategory_user, 00193 EMbmLmrefappCategory_user_mask); 00194 CleanupStack::PushL(icon); 00195 icon->SetBitmapsOwnedExternally(EFalse); 00196 iconList->AppendL(icon); 00197 CleanupStack::Pop(icon); 00198 00199 CleanupStack::Pop(); // iconList 00200 00201 // initialze iIconList. We don't need to delete any possible previous 00202 // iIconList since ownership is transferred to calling object. 00203 iIconList = iconList; 00204 00205 return iconList; 00206 }
|
|
|
Repopulates a part of the model.
Definition at line 216 of file LandmarksCategoriesModel.cpp. References FormatListItemLC(), and iListItems. 00218 { 00219 TInt nrOfReadItems = aCategories->Count(); 00220 00221 // Format and insert the read categories 00222 for (TInt i = 0; i < nrOfReadItems; i++) 00223 { 00224 // Format name and icon 00225 CPosLandmarkCategory* category = (*aCategories)[i]; 00226 HBufC* formattedName = FormatListItemLC(*category); 00227 00228 // Insert formatted descriptor into model 00229 iListItems->AppendL(*formattedName); 00230 00231 CleanupStack::PopAndDestroy(formattedName); 00232 } 00233 }
|
|
|
By default Symbian 2nd phase constructor is private. Definition at line 88 of file LandmarksCategoriesModel.cpp. References iListItems. 00089 { 00090 // The list box model uses MDesCArray interface class to take in text items. 00091 iListItems = new(ELeave) CDesCArraySeg(KGranularity); 00092 }
|
|
|
Formats a list item to fit a CEikColumnistBox with one graphic column and one descriptor column.
Definition at line 242 of file LandmarksCategoriesModel.cpp. References AppendIconL(), and iIconList. 00243 { 00244 // Extract name 00245 TPtrC name; 00246 aCategory.GetCategoryName(name); 00247 // 10 extra chars for icon index and column separator 00248 const TInt KExtraChars = 10; 00249 HBufC* formattedNameBuf = HBufC::NewLC(name.Length() + KExtraChars); 00250 TPtr formattedNamePtr = formattedNameBuf->Des(); 00251 00252 // Extract icon info 00253 TPtrC mbmIconFile; 00254 TInt iconIndex, maskIndex; 00255 TInt res = aCategory.GetIcon(mbmIconFile, iconIndex, maskIndex); 00256 00257 // Format list item 00258 if (res == KErrNone) 00259 { 00260 // Create icon and append it to icon array. 00261 TRAPD(err, AppendIconL(mbmIconFile, iconIndex, maskIndex)); 00262 if (err == KErrNone) 00263 { 00264 // Append the array index where the icon is appended 00265 formattedNamePtr.AppendNum(iIconList->Count() - 1); 00266 } 00267 else // Unable to create icon, use appropriate default icon. 00268 { 00269 formattedNamePtr.AppendNum(DefaultIconIndex(aCategory)); 00270 } 00271 } 00272 else // res == KErrNotFound 00273 { 00274 formattedNamePtr.AppendNum(DefaultIconIndex(aCategory)); 00275 } 00276 formattedNamePtr.Append(KTab); 00277 formattedNamePtr.Append(name); 00278 00279 return formattedNameBuf; 00280 }
|
|
||||||||||||||||
|
Appends an icen to the icon array.
Definition at line 288 of file LandmarksCategoriesModel.cpp. References iIconList. 00292 { 00293 TAknsItemID aknsItemId = {0,0}; 00294 CGulIcon* icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, 00295 aMbmFile, 00296 aIconOffset, 00297 aMaskOffset); 00298 CleanupStack::PushL(icon); 00299 icon->SetBitmapsOwnedExternally(EFalse); 00300 iIconList->AppendL(icon); 00301 CleanupStack::Pop(icon); 00302 }
|
|
|
Array of formated descriptors suitable to display in a column listbox Definition at line 139 of file LandmarksCategoriesModel.h. |
|
© Nokia 2006 |