S60 3rd Edition SDK for Symbian OS
Example Applications Guide

LandmarksCategoriesModel.h

00001 /*
00002 * ==============================================================================
00003 *  Name        : LandmarksCategoriesModel.h
00004 *  Part of     : Landmark Reference Application
00005 *  Interface   : -
00006 *  Description : See class description below
00007 *  Version     : 1.0
00008 *
00009 *  Copyright (c) 2004-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #ifndef __LANDMARKS_CATEGORIES_MODEL_H__
00017 #define __LANDMARKS_CATEGORIES_MODEL_H__
00018 
00019 // INCLUDES
00020 #include <e32base.h>
00021 
00022 // FORWARD DECLARATIONS
00023 class CPosLandmarkCategory;
00024 
00025 // CLASS DECLARATION
00026 
00027 /**
00028 *  CLandmarksCategoriesModel holds the data displayed in the category listbox.
00029 */
00030 class CLandmarksCategoriesModel : public CBase
00031         {
00032     public: // Constructors and destructor
00033 
00034         /**
00035         * Two-phased constructor.
00036         */
00037         static CLandmarksCategoriesModel* NewL();
00038 
00039         /**
00040         * Destructor.
00041         */
00042             ~CLandmarksCategoriesModel();
00043 
00044     public: // New functions
00045 
00046         /**
00047         * Sets the data member iItemIds
00048         * 
00049         * @param aItemIds a pointer to an array of item ids
00050         */
00051         void SetItemIds(RArray<TPosLmItemId>* aItemIds);
00052 
00053         /**
00054         * ItemList returns a pointer to an array to be used for the listbox
00055         *
00056         * @return a pointer to an array of descriptors to be displayed in the 
00057         * listbox
00058         */
00059             CDesCArraySeg* ItemList();
00060 
00061         /**
00062         * SetCurrentItem sets the item in the model that is selected in the 
00063         * listbox.
00064         *
00065         * @param aIndex the index in the list box that is selected
00066         */
00067             void SetCurrentItem(TInt aIndex);
00068             
00069         /**
00070         * CurrentItemId returns the id of the current item from the model.
00071         *
00072         * @return the id of the current item from the model, KPosLmNullItemId 
00073         * if there is no current item.
00074         */
00075             TPosLmItemId CurrentItemId();
00076             
00077         /**
00078         * CreateIconListL creates and returns an array of icons that is 
00079         * displayed in the listbox. Caller takes ownership of the returned 
00080         * array.
00081         *
00082         * @return a pointer to an array to be displayed in the listbox
00083         */
00084         CIconList* CreateIconListL();
00085 
00086         /**
00087         * Repopulates a part of the model.
00088         *
00089         * @param aCategories the categories to insert to the model
00090         */
00091         void RepopulateModelL(
00092             CArrayPtr<CPosLandmarkCategory>* aCategories);
00093 
00094     private:
00095 
00096         /**
00097         * C++ constructor.
00098         */
00099             CLandmarksCategoriesModel();
00100 
00101         /**
00102         * By default Symbian 2nd phase constructor is private.
00103         */
00104             void ConstructL();
00105 
00106         /**
00107         * Formats a list item to fit a CEikColumnistBox with one graphic 
00108         * column and one descriptor column.
00109         *
00110         * @param aCategory the category this list item will represent
00111         * @return a formatted descriptor buffer
00112         */
00113         HBufC* FormatListItemLC(CPosLandmarkCategory& aCategory);
00114 
00115         /**
00116         * Appends an icen to the icon array.
00117         *
00118         * @param aMbmFile the multi bitmap file containing the icon to add
00119         * @param aIconOffset the offset in the mbm-file where the icon is 
00120         * located
00121         * @param aMaskOffset the offset in the mbm-file where the icon mask is
00122         * located
00123         */
00124         void AppendIconL(
00125             const TDesC& aMbmFile, 
00126             TInt aIconOffset, 
00127             TInt aMaskOffset);
00128 
00129     private: // Data
00130 
00131         //! contains the ids idenetifying the categories in the DB
00132             RArray<TPosLmItemId>* iItemIds;
00133 
00134         //! indicates which item in the model is selected
00135             TInt iCurrentItem;
00136 
00137         /** Array of formated descriptors suitable to display in a column 
00138             listbox */
00139             CDesCArraySeg* iListItems;
00140 
00141         //! an array of category icons
00142         CIconList* iIconList;
00143 
00144         };
00145 
00146 #endif // __LANDMARKS_CATEGORIES_MODEL_H__
00147 
00148 // End of File
00149 

© Nokia 2006

Back to top