|
1 /* |
|
2 * Copyright (c) 2004-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * See class description below |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __LANDMARKS_CATEGORIES_MODEL_H__ |
|
21 #define __LANDMARKS_CATEGORIES_MODEL_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 |
|
26 |
|
27 class CPosLandmarkCategory; |
|
28 |
|
29 |
|
30 |
|
31 /** |
|
32 * CLandmarksCategoriesModel holds the data displayed in the category listbox. |
|
33 */ |
|
34 class CLandmarksCategoriesModel : public CBase |
|
35 { |
|
36 public: // Constructors and destructor |
|
37 |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 */ |
|
41 static CLandmarksCategoriesModel* NewL(); |
|
42 |
|
43 /** |
|
44 * Destructor. |
|
45 */ |
|
46 ~CLandmarksCategoriesModel(); |
|
47 |
|
48 public: // New functions |
|
49 |
|
50 /** |
|
51 * Sets the data member iItemIds |
|
52 * |
|
53 * @param aItemIds a pointer to an array of item ids |
|
54 */ |
|
55 void SetItemIds(RArray<TPosLmItemId>* aItemIds); |
|
56 |
|
57 /** |
|
58 * ItemList returns a pointer to an array to be used for the listbox |
|
59 * |
|
60 * @return a pointer to an array of descriptors to be displayed in the |
|
61 * listbox |
|
62 */ |
|
63 CDesCArraySeg* ItemList(); |
|
64 |
|
65 /** |
|
66 * SetCurrentItem sets the item in the model that is selected in the |
|
67 * listbox. |
|
68 * |
|
69 * @param aIndex the index in the list box that is selected |
|
70 */ |
|
71 void SetCurrentItem(TInt aIndex); |
|
72 |
|
73 /** |
|
74 * CurrentItemId returns the id of the current item from the model. |
|
75 * |
|
76 * @return the id of the current item from the model, KPosLmNullItemId |
|
77 * if there is no current item. |
|
78 */ |
|
79 TPosLmItemId CurrentItemId(); |
|
80 |
|
81 /** |
|
82 * CreateIconListL creates and returns an array of icons that is |
|
83 * displayed in the listbox. Caller takes ownership of the returned |
|
84 * array. |
|
85 * |
|
86 * @return a pointer to an array to be displayed in the listbox |
|
87 */ |
|
88 CIconList* CreateIconListL(); |
|
89 |
|
90 /** |
|
91 * Repopulates a part of the model. |
|
92 * |
|
93 * @param aCategories the categories to insert to the model |
|
94 */ |
|
95 void RepopulateModelL( |
|
96 CArrayPtr<CPosLandmarkCategory>* aCategories); |
|
97 |
|
98 private: |
|
99 |
|
100 /** |
|
101 * C++ constructor. |
|
102 */ |
|
103 CLandmarksCategoriesModel(); |
|
104 |
|
105 /** |
|
106 * By default Symbian 2nd phase constructor is private. |
|
107 */ |
|
108 void ConstructL(); |
|
109 |
|
110 /** |
|
111 * Formats a list item to fit a CEikColumnistBox with one graphic |
|
112 * column and one descriptor column. |
|
113 * |
|
114 * @param aCategory the category this list item will represent |
|
115 * @return a formatted descriptor buffer |
|
116 */ |
|
117 HBufC* FormatListItemLC(CPosLandmarkCategory& aCategory); |
|
118 |
|
119 /** |
|
120 * Appends an icen to the icon array. |
|
121 * |
|
122 * @param aMbmFile the multi bitmap file containing the icon to add |
|
123 * @param aIconOffset the offset in the mbm-file where the icon is |
|
124 * located |
|
125 * @param aMaskOffset the offset in the mbm-file where the icon mask is |
|
126 * located |
|
127 */ |
|
128 void AppendIconL( |
|
129 const TDesC& aMbmFile, |
|
130 TInt aIconOffset, |
|
131 TInt aMaskOffset); |
|
132 |
|
133 private: // Data |
|
134 |
|
135 //! contains the ids idenetifying the categories in the DB |
|
136 RArray<TPosLmItemId>* iItemIds; |
|
137 |
|
138 //! indicates which item in the model is selected |
|
139 TInt iCurrentItem; |
|
140 |
|
141 /** Array of formated descriptors suitable to display in a column |
|
142 listbox */ |
|
143 CDesCArraySeg* iListItems; |
|
144 |
|
145 //! an array of category icons |
|
146 CIconList* iIconList; |
|
147 |
|
148 }; |
|
149 |
|
150 #endif // __LANDMARKS_CATEGORIES_MODEL_H__ |
|
151 |