|
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_MODEL_H__ |
|
21 #define __LANDMARKS_MODEL_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <badesca.h> |
|
26 |
|
27 #include <EPos_Landmarks.h> |
|
28 |
|
29 |
|
30 class CPosLandmark; |
|
31 |
|
32 |
|
33 |
|
34 /** |
|
35 * Contains the data model of the landmarks view. |
|
36 * |
|
37 */ |
|
38 class CLandmarksModel : public CBase |
|
39 { |
|
40 public: // Constructors and destructor |
|
41 |
|
42 /** |
|
43 * Two-phased constructor. |
|
44 */ |
|
45 static CLandmarksModel* NewL(); |
|
46 |
|
47 /** |
|
48 * Destructor. |
|
49 */ |
|
50 ~CLandmarksModel(); |
|
51 |
|
52 public: // New functions |
|
53 |
|
54 /** |
|
55 * Sets the data member iItemIds |
|
56 * |
|
57 * @param aItemIds a pointer to an array of item ids |
|
58 */ |
|
59 void SetItemIds(RArray<TPosLmItemId>* aItemIds); |
|
60 |
|
61 /** Returns item IDs specified by aSelectionIndexes indexes */ |
|
62 void GetItemIdsL( |
|
63 const CArrayFix<TInt>& aSelectionIndexes, |
|
64 RArray<TPosLmItemId>& aItemIds ); |
|
65 |
|
66 /** |
|
67 * Returns a pointer to an array to be used for a list box. |
|
68 * |
|
69 * @return an array of descriptors formatted to fit a CEikColumnListBox |
|
70 * with one icon column to the left and one descriptor column to the |
|
71 * right. |
|
72 */ |
|
73 CDesCArraySeg* ItemList(); |
|
74 |
|
75 /** |
|
76 * Sets current item in the model. The current item should match the |
|
77 * current selected one in the listbox displaying this model. |
|
78 * |
|
79 * @param aIndex the index of the current item in the list. |
|
80 */ |
|
81 void SetCurrentItem(TInt aIndex); |
|
82 |
|
83 /** |
|
84 * Returns the item id of the current item in the model. |
|
85 * |
|
86 * @return the item id of the current item in the model. |
|
87 * KPosLmNullItemId if no item is set as current |
|
88 */ |
|
89 TPosLmItemId CurrentItemId(); |
|
90 |
|
91 /** |
|
92 * Creates an array of icons that should be displayed be the listbox |
|
93 * displaying the data of this model. |
|
94 * |
|
95 * @return an array of icons. Ownership of CIconList* is tranferred to |
|
96 * caller |
|
97 */ |
|
98 CIconList* CreateIconListL(); |
|
99 |
|
100 /** |
|
101 * Repopulates a part of the model. |
|
102 * |
|
103 * @param aLandmarks the landmarks to insert to the model |
|
104 */ |
|
105 void RepopulateModelL( |
|
106 CArrayPtr<CPosLandmark>* aLandmarks); |
|
107 |
|
108 private: |
|
109 |
|
110 /** |
|
111 * Formats a list item to fit a CEikColumnistBox with one graphic |
|
112 * column and one descriptor column. |
|
113 * |
|
114 * @param aLandmark the landmarks this list item will represent |
|
115 * @return a formatted descriptor buffer |
|
116 */ |
|
117 HBufC* FormatListItemLC(CPosLandmark& aLandmark); |
|
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: |
|
134 |
|
135 /** |
|
136 * C++ constructor. |
|
137 */ |
|
138 CLandmarksModel(); |
|
139 |
|
140 /** |
|
141 * By default Symbian 2nd phase constructor is private. |
|
142 */ |
|
143 void ConstructL(); |
|
144 |
|
145 private: |
|
146 |
|
147 //! contains the current item in the model |
|
148 TInt iCurrentItem; |
|
149 |
|
150 //! an array of formatted descriptors |
|
151 CDesCArraySeg* iListItems; |
|
152 |
|
153 //! an array of item ids matching the landmarks represented by iListItems |
|
154 RArray<TPosLmItemId>* iItemIds; |
|
155 |
|
156 //! an array of landmark icons |
|
157 CIconList* iIconList; |
|
158 |
|
159 //! the next index to repopulate |
|
160 TInt iIndexToPopulate; |
|
161 |
|
162 }; |
|
163 |
|
164 #endif // __LANDMARKS_MODEL_H__ |
|
165 |