|
Nokia N97 SDK Example Applications Guide |
#include <LandmarksModel.h>
Inheritance diagram for CLandmarksModel:

Definition at line 34 of file LandmarksModel.h.
Public Member Functions |
|
| ~CLandmarksModel () | |
| void | SetItemIds (RArray< TPosLmItemId > *aItemIds) |
| CDesCArraySeg * | ItemList () |
| void | SetCurrentItem (TInt aIndex) |
| TPosLmItemId | CurrentItemId () |
| CIconList * | CreateIconListL () |
| void | RepopulateModelL (CArrayPtr< CPosLandmark > *aLandmarks) |
Static Public Member Functions |
|
| static CLandmarksModel * | NewL () |
Private Member Functions |
|
| HBufC * | FormatListItemLC (CPosLandmark &aLandmark) |
| void | AppendIconL (const TDesC &aMbmFile, TInt aIconOffset, TInt aMaskOffset) |
| CLandmarksModel () | |
| void | ConstructL () |
Private Attributes |
|
| TInt | iCurrentItem |
| contains the current item in the model |
|
| CDesCArraySeg * | iListItems |
| an array of formatted descriptors |
|
| RArray< TPosLmItemId > * | iItemIds |
| an array of item ids matching the landmarks represented by iListItems |
|
| CIconList * | iIconList |
| an array of landmark icons |
|
| TInt | iIndexToPopulate |
| the next index to repopulate |
|
|
|
Destructor. Definition at line 70 of file LandmarksModel.cpp. References iListItems. 00071 { 00072 delete iListItems; 00073 }
|
|
|
C++ constructor. Definition at line 40 of file LandmarksModel.cpp. Referenced by NewL().
|
|
|
Two-phased constructor. Definition at line 60 of file LandmarksModel.cpp. References CLandmarksModel(). Referenced by CLandmarksContainer::ConstructL(). 00061 { 00062 CLandmarksModel* self = new (ELeave) CLandmarksModel(); 00063 CleanupStack::PushL(self); 00064 self->ConstructL(); 00065 CleanupStack::Pop(self); 00066 return self; 00067 }
|
|
|
Sets the data member iItemIds
Definition at line 81 of file LandmarksModel.cpp. References iItemIds, and iListItems. Referenced by CLandmarksContainer::HandleSearchReadyL(). 00082 { 00083 iItemIds = aItemIds; 00084 00085 // Empty descriptor model 00086 iListItems->Reset(); 00087 }
|
|
|
Returns a pointer to an array to be used for a list box.
Definition at line 95 of file LandmarksModel.cpp. References iListItems. Referenced by CLandmarksContainer::ConstructL(). 00096 { 00097 return iListItems; 00098 }
|
|
|
Sets current item in the model. The current item should match the current selected one in the listbox displaying this model.
Definition at line 106 of file LandmarksModel.cpp. References iCurrentItem. Referenced by CLandmarksContainer::HandleControlEventL(), CLandmarksContainer::HandleReadReadyL(), and CLandmarksContainer::HandleSearchReadyL(). 00107 { 00108 iCurrentItem = aIndex; 00109 }
|
|
|
Returns the item id of the current item in the model.
Definition at line 117 of file LandmarksModel.cpp. References iCurrentItem, and iItemIds. Referenced by CLandmarksContainer::CurrentLandmark(), CLandmarksContainer::DeleteLandmarkL(), CLandmarksContainer::IsRefreshNeededL(), and CLandmarksContainer::StoreCurrentLandmarkNameL(). 00118 { 00119 if (!iItemIds || iCurrentItem < 0 || 00120 iCurrentItem > iItemIds->Count() - 1) 00121 { 00122 return KPosLmNullItemId; 00123 } 00124 00125 return (*iItemIds)[iCurrentItem]; 00126 }
|
|
|
Creates an array of icons that should be displayed be the listbox displaying the data of this model.
Definition at line 134 of file LandmarksModel.cpp. References iIconList. Referenced by CLandmarksContainer::ConstructL(), and CLandmarksContainer::HandleSearchReadyL(). 00135 { 00136 CIconList* iconList = new (ELeave) CAknIconArray( KGranularity ); 00137 00138 CleanupStack::PushL(iconList); 00139 00140 // Create the default landmark icon consisting of its image and mask 00141 TAknsItemID aknsItemId = {0,0}; 00142 CGulIcon* icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, 00143 KLandmarksMbmFileName, 00144 EMbmLmrefappDefault_lm, 00145 EMbmLmrefappDefault_lm_mask); 00146 CleanupStack::PushL(icon); 00147 icon->SetBitmapsOwnedExternally(EFalse); 00148 iconList->AppendL(icon); 00149 CleanupStack::Pop(2, iconList); 00150 00151 // initialze iIconList. We don't need to delete any possible previous 00152 // iIconList since ownership is transferred to calling object. 00153 iIconList = iconList; 00154 00155 return iIconList; 00156 }
|
|
|
Repopulates a part of the model.
Definition at line 164 of file LandmarksModel.cpp. References FormatListItemLC(), and iListItems. Referenced by CLandmarksContainer::HandleReadReadyL(). 00166 { 00167 TInt nrOfReadItems = aLandmarks->Count(); 00168 00169 // Format and insert the read landmarks 00170 for (TInt i = 0; i < nrOfReadItems; i++) 00171 { 00172 CPosLandmark* landmark = (*aLandmarks)[i]; 00173 HBufC* formattedListItem = FormatListItemLC(*landmark); 00174 iListItems->AppendL(*formattedListItem); 00175 CleanupStack::PopAndDestroy(formattedListItem); 00176 } 00177 }
|
|
|
Formats a list item to fit a CEikColumnistBox with one graphic column and one descriptor column.
Definition at line 186 of file LandmarksModel.cpp. References AppendIconL(), and iIconList. Referenced by RepopulateModelL(). 00187 { 00188 // Extract name 00189 TPtrC name; 00190 aLandmark.GetLandmarkName(name); 00191 // 10 extra chars for icon index and column separator 00192 const TInt KExtraChars = 10; 00193 HBufC* formattedNameBuf = HBufC::NewLC(name.Length() + KExtraChars); 00194 TPtr formattedNamePtr = formattedNameBuf->Des(); 00195 00196 // Extract icon info 00197 TPtrC mbmIconFile; 00198 TInt iconIndex, maskIndex; 00199 TInt res = aLandmark.GetIcon(mbmIconFile, iconIndex, maskIndex); 00200 00201 // Format list item 00202 if (res == KErrNone) 00203 { 00204 // Create icon and append it to icon array. 00205 TRAPD(err, AppendIconL(mbmIconFile, iconIndex, maskIndex)); 00206 if (err == KErrNone) 00207 { 00208 // Append the array index where the icon is appended 00209 formattedNamePtr.AppendNum(iIconList->Count() - 1); 00210 } 00211 else 00212 { 00213 formattedNamePtr.AppendNum(KDefaultIconIndex); 00214 } 00215 } 00216 else // res == KErrNotFound 00217 { 00218 formattedNamePtr.AppendNum(KDefaultIconIndex); 00219 } 00220 formattedNamePtr.Append(KTab); 00221 formattedNamePtr.Append(name); 00222 00223 return formattedNameBuf; 00224 }
|
|
||||||||||||||||
|
Appends an icen to the icon array.
Definition at line 232 of file LandmarksModel.cpp. References iIconList. Referenced by FormatListItemLC(). 00236 { 00237 TAknsItemID aknsItemId = {0,0}; 00238 CGulIcon* icon = AknsUtils::CreateGulIconL(NULL, aknsItemId, 00239 aMbmFile, 00240 aIconOffset, 00241 aMaskOffset); 00242 CleanupStack::PushL(icon); 00243 icon->SetBitmapsOwnedExternally(EFalse); 00244 iIconList->AppendL(icon); 00245 CleanupStack::Pop(icon); 00246 }
|
|
|
By default Symbian 2nd phase constructor is private. Definition at line 49 of file LandmarksModel.cpp. References iListItems. 00050 { 00051 // The list box model uses MDesCArray interface class to take in text items. 00052 iListItems = new (ELeave) CDesCArraySeg(KGranularity); 00053 }
|
|
© Nokia 2009 |