|
1 /* |
|
2 * Copyright (c) 2007 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: menu item presentation model |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef HNMENUITEMMODEL_H_ |
|
20 #define HNMENUITEMMODEL_H_ |
|
21 |
|
22 #include <e32base.h> |
|
23 |
|
24 class CHnMenuItemModel; |
|
25 |
|
26 /** |
|
27 * Menu item model iterator. |
|
28 * |
|
29 * Used to iterate on menu items structure. Provides basic |
|
30 * iterator interface. |
|
31 * |
|
32 * @lib hnpresentationmodel |
|
33 * @since S60 5.0 |
|
34 * @ingroup group_hnpresentationmodel |
|
35 */ |
|
36 class MHnMenuItemModelIterator |
|
37 { |
|
38 public: |
|
39 |
|
40 /** |
|
41 * Checks whether there is at least one more element. |
|
42 * |
|
43 * @since S60 5.0 |
|
44 * @return ETrue if there is a next item, otherwise EFalse. |
|
45 */ |
|
46 virtual TBool HasNext() = 0; |
|
47 |
|
48 /** |
|
49 * Gets the next item and move the cursor to the next item. |
|
50 * |
|
51 * @since S60 5.0 |
|
52 * @return A pointer to the element or NULL if there are no more elements. |
|
53 */ |
|
54 virtual CHnMenuItemModel* GetNext() = 0; |
|
55 |
|
56 /** |
|
57 * Checks whether there is at least one more element (item specific). |
|
58 * |
|
59 * @since S60 5.0 |
|
60 * @return ETrue if there is a next item, otherwise EFalse. |
|
61 */ |
|
62 virtual TBool HasNextSpecific() = 0; |
|
63 |
|
64 /** |
|
65 * Gets the next menu item ( specific for the item |
|
66 * - e.g. Applications folder item ) |
|
67 * and move the cursor to the next menu item. |
|
68 * |
|
69 * @since S60 5.0 |
|
70 * @return A pointer to the element or NULL if there are no more elements. |
|
71 */ |
|
72 virtual CHnMenuItemModel* GetNextSpecific() = 0; |
|
73 |
|
74 /** |
|
75 * Resets the iterator. |
|
76 * |
|
77 * @since S60 5.0 |
|
78 */ |
|
79 virtual void Reset() = 0; |
|
80 |
|
81 }; |
|
82 |
|
83 /** |
|
84 * Menu item model class. |
|
85 * |
|
86 * Represents menu item. Contains all data needed to display and |
|
87 * use menu item properly. Implemented as tree structure. |
|
88 * |
|
89 * @lib hnpresentationmodel |
|
90 * @since S60 5.0 |
|
91 * @ingroup group_hnpresentationmodel |
|
92 */ |
|
93 NONSHARABLE_CLASS( CHnMenuItemModel ): |
|
94 public CBase, |
|
95 public MHnMenuItemModelIterator |
|
96 { |
|
97 public: |
|
98 |
|
99 /** |
|
100 * Two-phased constructor. |
|
101 * |
|
102 * @since S60 5.0 |
|
103 * @param aName Name for menu item |
|
104 */ |
|
105 IMPORT_C static CHnMenuItemModel* NewL( const TDesC& aName ); |
|
106 |
|
107 /** |
|
108 * Virtual Destructor. |
|
109 * |
|
110 * @since S60 5.0 |
|
111 */ |
|
112 ~CHnMenuItemModel(); |
|
113 |
|
114 /** |
|
115 * Gets menu item model. |
|
116 * |
|
117 * @since S60 5.0 |
|
118 * @return Menu item structure |
|
119 */ |
|
120 IMPORT_C MHnMenuItemModelIterator* GetMenuStructure(); |
|
121 |
|
122 /** |
|
123 * @see MHnMenuItemModelIterator. |
|
124 */ |
|
125 IMPORT_C virtual TBool HasNext(); |
|
126 |
|
127 /** |
|
128 * @see MHnMenuItemModelIterator. |
|
129 */ |
|
130 IMPORT_C virtual CHnMenuItemModel* GetNext(); |
|
131 |
|
132 /** |
|
133 * @see MHnMenuItemModelIterator. |
|
134 */ |
|
135 IMPORT_C virtual TBool HasNextSpecific(); |
|
136 |
|
137 /** |
|
138 * @see MHnMenuItemModelIterator. |
|
139 */ |
|
140 IMPORT_C virtual CHnMenuItemModel* GetNextSpecific(); |
|
141 |
|
142 /** |
|
143 * @see MHnMenuItemModelIterator. |
|
144 */ |
|
145 IMPORT_C virtual void Reset(); |
|
146 |
|
147 /** |
|
148 * Gets name. |
|
149 * |
|
150 * @since S60 5.0 |
|
151 * @return Name of the menu. |
|
152 */ |
|
153 IMPORT_C const TDesC& NameL(); |
|
154 |
|
155 /** |
|
156 * Gets command id. |
|
157 * |
|
158 * @since S60 5.0 |
|
159 * @return Command id. |
|
160 */ |
|
161 IMPORT_C TInt Command(); |
|
162 |
|
163 /** |
|
164 * Sets command id. |
|
165 * |
|
166 * @since S60 5.0 |
|
167 * @param aCommandId Command id from data model. |
|
168 */ |
|
169 IMPORT_C void SetCommand( TInt aCommandId ); |
|
170 |
|
171 /** |
|
172 * Gets menu item position. |
|
173 * |
|
174 * @since S60 5.0 |
|
175 * @return Position of item in menu. |
|
176 */ |
|
177 IMPORT_C TInt Position(); |
|
178 |
|
179 /** |
|
180 * Sets menu item position. |
|
181 * |
|
182 * @since S60 5.0 |
|
183 * @param aPosition Position of item in menu. |
|
184 */ |
|
185 IMPORT_C void SetPosition( TInt aPosition ); |
|
186 |
|
187 /** |
|
188 * Sets menu item specific flag. |
|
189 * |
|
190 * @since S60 5.0 |
|
191 * @param aItemSpecific Is menu element item specific. |
|
192 */ |
|
193 IMPORT_C void SetItemSpecific( TBool aItemSpecific ); |
|
194 |
|
195 /** |
|
196 * Appends child item. |
|
197 * |
|
198 * @since S60 5.0 |
|
199 * @param aMenuModel Menu item model. |
|
200 */ |
|
201 IMPORT_C void AppendChildMenuL( CHnMenuItemModel* aMenuModel ); |
|
202 |
|
203 /** |
|
204 * Tells if menu item is item specific. |
|
205 * |
|
206 * @since S60 5.0 |
|
207 * @return ETrue if menu item is item specific. |
|
208 */ |
|
209 IMPORT_C TBool IsItemSpecific(); |
|
210 |
|
211 private: |
|
212 |
|
213 /** |
|
214 * Default constructor. |
|
215 * |
|
216 * @since S60 5.0 |
|
217 */ |
|
218 CHnMenuItemModel(); |
|
219 |
|
220 /** |
|
221 * Second phase constructor. |
|
222 * |
|
223 * @since S60 5.0 |
|
224 * @param aName Name for menu item |
|
225 */ |
|
226 void ConstructL( const TDesC& aName ); |
|
227 |
|
228 private: // data |
|
229 |
|
230 /** |
|
231 * Name value cache. |
|
232 */ |
|
233 RBuf iName; |
|
234 |
|
235 /** |
|
236 * Command Id. |
|
237 */ |
|
238 TInt iCommand; |
|
239 |
|
240 /** |
|
241 * Position. |
|
242 */ |
|
243 TInt iPosition; |
|
244 |
|
245 /** |
|
246 * Next child. |
|
247 */ |
|
248 TInt iNextMenu; |
|
249 |
|
250 /** |
|
251 * Children pointer array. |
|
252 */ |
|
253 RPointerArray< CHnMenuItemModel > iChildren; |
|
254 |
|
255 /** |
|
256 * Is menu item item specific. |
|
257 */ |
|
258 TBool iItemSpecific; |
|
259 }; |
|
260 |
|
261 #endif // HNMENUITEMMODEL_H_ |