1 /* |
|
2 * Copyright (c) 2002 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 the License "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 * Declaration of class CBrowserFavouritesListboxModel. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef BROWSER_FAVOURITES_LISTBOX_MODEL_H |
|
22 #define BROWSER_FAVOURITES_LISTBOX_MODEL_H |
|
23 |
|
24 // INCLUDE FILES |
|
25 // #include <e32base.h> |
|
26 // #include <eiktxlbm.h> |
|
27 #include <calslbs.h> |
|
28 #include "Browser.hrh" |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 /** |
|
33 * Buffer size for formatting listbox text. Maximum item name |
|
34 * plus listbox internals (tabulators for icons etc.) must fit into it. |
|
35 * The format is "<icon index max 3 char>\t<name>\t<mark 1 char>\t", |
|
36 * so the added length is 7. |
|
37 */ |
|
38 const TInt KMaxFavouritesItemListboxName = |
|
39 KFavouritesMaxBookmarkNameDefine + 7; |
|
40 |
|
41 // FORWARD DECLARATION |
|
42 |
|
43 class CFavouritesItemList; |
|
44 class CBrowserFavouritesListboxModel; |
|
45 class CBrowserFavouritesIconIndexArray; |
|
46 // class CAknListBoxFilterItems; |
|
47 // class CAknSearchField; |
|
48 // class CEikListBox; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 |
|
52 /** |
|
53 * Item text array for the favourites view listbox; converts item data |
|
54 * to format what the listbox needs. (This means the returned text includes |
|
55 * listbox internals (tabulators, icon numbers). |
|
56 */ |
|
57 class TBrowserFavouritesListboxItemTextArray: public MDesCArray |
|
58 { |
|
59 public: // from MDesCArray |
|
60 |
|
61 /** |
|
62 * Get number of items in the array. |
|
63 * @return Number of items. |
|
64 */ |
|
65 TInt MdcaCount() const; |
|
66 |
|
67 /** |
|
68 * Text to be displayed for this item. |
|
69 * @param aIndex Index of item. |
|
70 * @return TPtrC for this item text. |
|
71 */ |
|
72 TPtrC MdcaPoint( TInt aIndex ) const; |
|
73 |
|
74 /** |
|
75 * The model uses this class. |
|
76 */ |
|
77 friend class CBrowserFavouritesListboxModel; |
|
78 |
|
79 private: // data |
|
80 |
|
81 /** |
|
82 * Pointer to real data. Not owned. |
|
83 */ |
|
84 const CFavouritesItemList* iItems; |
|
85 |
|
86 /** |
|
87 * Icon indexes. Not owned. |
|
88 */ |
|
89 const CBrowserFavouritesIconIndexArray* iIconIndexes; |
|
90 |
|
91 /** |
|
92 * MdcaPoint() cannot leave, so this buffer is allocated |
|
93 * to allow formatting. Fortunately, doesn't have to be very |
|
94 * large. |
|
95 * We have to use MUTABLE CAST, as MdcaPoint is const (odd enough), |
|
96 * so wouldn't allow formatting the text in a member... |
|
97 */ |
|
98 __MUTABLE TBuf<KMaxFavouritesItemListboxName> iBuf; |
|
99 }; |
|
100 |
|
101 /** |
|
102 * Item text array for the favourites view listbox filtering; converts item data |
|
103 * to format what the filter needs. (This means the returned text is what the |
|
104 * user sees, and does not include listbox internals (tabulators, icon numbers). |
|
105 */ |
|
106 class TBrowserFavouritesListboxFilterTextArray: public MDesCArray |
|
107 { |
|
108 public: // from MDesCArray |
|
109 |
|
110 /** |
|
111 * Get number of items in the array. |
|
112 * @return Number of items. |
|
113 */ |
|
114 TInt MdcaCount() const; |
|
115 |
|
116 /** |
|
117 * Text to be displayed for this item. |
|
118 * @param aIndex Index of item. |
|
119 * @return TPtrC for this item text. |
|
120 */ |
|
121 TPtrC MdcaPoint( TInt aIndex ) const; |
|
122 |
|
123 /** |
|
124 * The model uses this class. |
|
125 */ |
|
126 friend class CBrowserFavouritesListboxModel; |
|
127 |
|
128 private: // data |
|
129 |
|
130 /** |
|
131 * Pointer to real data. Not owned. |
|
132 */ |
|
133 const CFavouritesItemList* iItems; |
|
134 |
|
135 }; |
|
136 |
|
137 /** |
|
138 * Model for the bookmark item listbox. Contains an array of |
|
139 * CBrowserFavouritesItem pointers; items are owned. |
|
140 */ |
|
141 class CBrowserFavouritesListboxModel: public CAknFilteredTextListBoxModel |
|
142 { |
|
143 public: // Construct / destruct |
|
144 |
|
145 /** |
|
146 * Two-phase constructor. Leaves on failure. |
|
147 * The two arrays passed must have the same number of items. |
|
148 * @param aItems Itemarray; not owned. |
|
149 * @param aIconIndexes Icon index array, not owned. |
|
150 */ |
|
151 static CBrowserFavouritesListboxModel* NewL |
|
152 ( |
|
153 const CFavouritesItemList& aItems, |
|
154 const CBrowserFavouritesIconIndexArray& aIconIndexes |
|
155 ); |
|
156 |
|
157 /** |
|
158 * Overcoming base class bugs. Need to set itemarray after the whole |
|
159 * listbox has been constructed; as the listbox construction |
|
160 * overwrites itemarray to NULL. To be called as part of the |
|
161 * construction ("third phase constructor"), AFTER the listbox's |
|
162 * ConstructL. |
|
163 */ |
|
164 void SetItemArray(); |
|
165 |
|
166 /** |
|
167 * Destructor. |
|
168 */ |
|
169 virtual ~CBrowserFavouritesListboxModel(); |
|
170 |
|
171 public: // new methods |
|
172 |
|
173 /** |
|
174 * Set new data into the model. |
|
175 * The two arrays passed must have the same number of items. |
|
176 * @param aItems Itemarray; not owned. |
|
177 * @param aIconIndexes Icon index array, not owned. |
|
178 */ |
|
179 void SetData |
|
180 ( |
|
181 const CFavouritesItemList& aItems, |
|
182 const CBrowserFavouritesIconIndexArray& aIconIndexes |
|
183 ); |
|
184 |
|
185 /** |
|
186 * Returns pointer to item list. |
|
187 * @return Pointer to item list. |
|
188 */ |
|
189 inline const CFavouritesItemList* Items() const; |
|
190 |
|
191 public: // from CTextListBoxModel |
|
192 |
|
193 /** |
|
194 * Get matchable text array (for filtering). |
|
195 * @return The matchable text array. |
|
196 */ |
|
197 const MDesCArray* MatchableTextArray() const; |
|
198 |
|
199 protected: // Construct / destruct |
|
200 |
|
201 /** |
|
202 * Constructor. |
|
203 * The two arrays passed must have the same number of items. |
|
204 * @param aItems Itemarray; not owned. |
|
205 * @param aIconIndexes Icon index array, not owned. |
|
206 */ |
|
207 CBrowserFavouritesListboxModel |
|
208 ( |
|
209 const CFavouritesItemList& aItems, |
|
210 const CBrowserFavouritesIconIndexArray& aIconIndexes |
|
211 ); |
|
212 |
|
213 /** |
|
214 * Second phase constructor. Leaves on failure. |
|
215 */ |
|
216 void ConstructL(); |
|
217 |
|
218 private: // data |
|
219 |
|
220 /** |
|
221 * The item array (real data, array of CFavouritesItem-s). Not owned. |
|
222 */ |
|
223 const CFavouritesItemList* iItems; |
|
224 |
|
225 /** |
|
226 * Icon indexes. Not owned. |
|
227 */ |
|
228 const CBrowserFavouritesIconIndexArray* iIconIndexes; |
|
229 |
|
230 /** |
|
231 * The item text array (formatting for listbox). |
|
232 */ |
|
233 TBrowserFavouritesListboxItemTextArray iItemTexts; |
|
234 |
|
235 /** |
|
236 * The filter text array (formatting for filtering). |
|
237 */ |
|
238 TBrowserFavouritesListboxFilterTextArray iFilterTexts; |
|
239 |
|
240 }; |
|
241 |
|
242 #include "BrowserFavouritesListboxModel.inl" |
|
243 |
|
244 #endif |
|
245 |
|
246 // End of file |
|