48
|
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 CBrowserFavouritesListbox.
|
|
16 |
*
|
|
17 |
*
|
|
18 |
*/
|
|
19 |
|
|
20 |
|
|
21 |
#ifndef BROWSER_FAVOURITES_LISTBOX_H
|
|
22 |
#define BROWSER_FAVOURITES_LISTBOX_H
|
|
23 |
|
|
24 |
// INCLUDES
|
|
25 |
#include <aknlists.h>
|
|
26 |
#include "BrowserFavouritesSelectionState.h"
|
|
27 |
#include "BrowserFaviconHandler.h"
|
|
28 |
|
|
29 |
// FORWARD DECLARATIONS
|
|
30 |
class CFavouritesItem;
|
|
31 |
class CFavouritesItemList;
|
|
32 |
class CBrowserFavouritesIconIndexArray;
|
|
33 |
class MBrowserFavouritesListboxIconHandler;
|
|
34 |
class CBrowserFavouritesListboxModel;
|
|
35 |
class MBrowserFavouritesListboxCursorObserver;
|
|
36 |
class CBrowserFavouritesListboxState;
|
|
37 |
class MApiProvider;
|
|
38 |
|
|
39 |
// MACROS
|
|
40 |
|
|
41 |
// CLASS DECLARATION
|
|
42 |
|
|
43 |
/**
|
|
44 |
* Listbox to display and browse bookmarks and folders.
|
|
45 |
* Display is sorted: Homepage first, Last Visited next, bookmarks sorted
|
|
46 |
* alphabetically, folders come last alphabetically. Markable single-graphics
|
|
47 |
* style listbox.
|
|
48 |
*/
|
|
49 |
struct TBrowserFavouritesListboxDefaultDatas
|
|
50 |
{
|
|
51 |
TInt iPreferedId;
|
|
52 |
TBool iInSeamlessFolder;
|
|
53 |
};
|
|
54 |
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Listbox to display and browse bookmarks and folders.
|
|
58 |
* Display is sorted: Homepage first, Last Visited next, bookmarks sorted
|
|
59 |
* alphabetically, folders come last alphabetically. Markable single-graphics
|
|
60 |
* style listbox.
|
|
61 |
*/
|
|
62 |
class CBrowserFavouritesListbox : public CAknSingleGraphicStyleListBox
|
|
63 |
,public MBrowserFaviconObserver
|
|
64 |
{
|
|
65 |
public: // Constructors and destructor
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Two-phased constructor. Leaves on failure.
|
|
69 |
* @param aParent Parent control.
|
|
70 |
* @param aIconHandler The icon handler. Not owned.
|
|
71 |
* @return The constructed listbox.
|
|
72 |
*/
|
|
73 |
static CBrowserFavouritesListbox* NewL
|
|
74 |
(
|
|
75 |
MApiProvider& aApiProvider,
|
|
76 |
const CCoeControl* aParent,
|
|
77 |
const MBrowserFavouritesListboxIconHandler& aIconHandler
|
|
78 |
);
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Destructor.
|
|
82 |
*/
|
|
83 |
virtual ~CBrowserFavouritesListbox();
|
|
84 |
|
|
85 |
public: // new methods
|
|
86 |
|
|
87 |
/**
|
|
88 |
* Set listbox observer.
|
|
89 |
* @param Observer for this listbox.
|
|
90 |
*/
|
|
91 |
void SetListboxCursorObserver
|
|
92 |
( MBrowserFavouritesListboxCursorObserver* aObserver );
|
|
93 |
|
|
94 |
/**
|
|
95 |
* Set new data to listbox.
|
|
96 |
* @param aItems Items to display. Ownership is taken. Should not be on
|
|
97 |
* cleanup stack when calling this (this method will push).
|
|
98 |
* @param aCommsModel to be used when setting bearer icons.
|
|
99 |
* (Ownership not taken.)
|
|
100 |
* @param aKeepState If ETrue, try to keep current state (marks etc.).
|
|
101 |
*/
|
|
102 |
void SetDataL
|
|
103 |
(
|
|
104 |
CFavouritesItemList* aItems,
|
|
105 |
TBool aKeepState
|
|
106 |
);
|
|
107 |
|
|
108 |
/**
|
|
109 |
* Get selection state.
|
|
110 |
* @return Selection state.
|
|
111 |
*/
|
|
112 |
TBrowserFavouritesSelectionState SelectionStateL() const;
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Get currently highlighted item.
|
|
116 |
* @return Pointer to highlighted object or NULL.
|
|
117 |
*/
|
|
118 |
const CFavouritesItem* CurrentItem() const;
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Get currently marked one item (if more is marked, or nothing
|
|
122 |
* is marked, return NULL).
|
|
123 |
* @return Pointer to marked one object or NULL.
|
|
124 |
*/
|
|
125 |
const CFavouritesItem* MarkedItemL() const;
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Highlight the item having uid aUid. Does nothing
|
|
129 |
* if no item in the listbox has this uid.
|
|
130 |
* @param aUid Uid of item to highlight.
|
|
131 |
* @return ETrue if the item was found and highlighted; EFalse if not.
|
|
132 |
*/
|
|
133 |
TBool HighlightUidNow( TInt aUid );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Handle markable list command. Does nothing
|
|
137 |
* if listbox is not markable or empty.
|
|
138 |
*/
|
|
139 |
void HandleMarkableListCommandL( TInt aCommand );
|
|
140 |
|
|
141 |
/**
|
|
142 |
* Return Uids of marked items.
|
|
143 |
* @return Array of Uids. The array has been placed on the cleanup
|
|
144 |
* stack. The caller must destroy it and pop after no longer needed.
|
|
145 |
*/
|
|
146 |
CArrayFix<TInt>* MarkedUidsLC() const;
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Return Uids of selected items. These are the marked ones, if no marks
|
|
150 |
* then the highlighted one.
|
|
151 |
* @return Array of Uids. The array has been placed on the cleanup
|
|
152 |
* stack. The caller must destroy it and pop after no longer needed.
|
|
153 |
*/
|
|
154 |
CArrayFix<TInt>* SelectedUidsLC() const;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Return a list of pointers to selected items. These are the marked
|
|
158 |
* ones, if no marks then the highlighted one.
|
|
159 |
* Note that the items exist within the listbox,
|
|
160 |
* and may be updated! So if you do something with the list which
|
|
161 |
* can be interrupted by some (other) active objects, copy the items
|
|
162 |
* first.
|
|
163 |
* Owner of the items is still the listbox, the owner of the list is
|
|
164 |
* the caller (i.e. you should delete the list, but not ResetAndDestroy
|
|
165 |
* it).
|
|
166 |
* @param aIncludeSpecialItems When ETrue, everything is included. When EFalse,
|
|
167 |
* homepage, last visited and folder types are excluded.
|
|
168 |
* @return Array of pointers to items. Items are owned by the listbox.
|
|
169 |
* The array has been placed on the cleanup stack. The caller must
|
|
170 |
* destroy it and pop after no longer needed.
|
|
171 |
*/
|
|
172 |
CArrayPtr<const CFavouritesItem>* SelectedItemsLC(TBool aIncludeSpecialItems=ETrue) const;
|
|
173 |
|
|
174 |
/**
|
|
175 |
* Return a pointer to item having aUid. Note that the item exists
|
|
176 |
* within the listbox, and may be deleted! So if you do something with
|
|
177 |
* it which can be interrupted by some (other) active objects, copy the
|
|
178 |
* item first.
|
|
179 |
* @param aUid Uid of item to look for.
|
|
180 |
* @return Pointer to item (owned by the listbox), having this uid; or
|
|
181 |
* NULL if no such item is found.
|
|
182 |
*/
|
|
183 |
const CFavouritesItem* ItemByUid( TInt aUid ) const;
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Return number of items in the listbox, not considering filters.
|
|
187 |
*/
|
|
188 |
TInt UnfilteredNumberOfItems();
|
|
189 |
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Return number of filtered items in the listbox
|
|
193 |
*/
|
|
194 |
TInt FilteredNumberOfItems();
|
|
195 |
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Update filtering (e.g. item array changed, or filter text changed
|
|
199 |
* from outside).
|
|
200 |
*/
|
|
201 |
void UpdateFilterL();
|
|
202 |
|
|
203 |
/**
|
|
204 |
* Query if there is any folder in the listbox.
|
|
205 |
* @return ETrue if there is any folder.
|
|
206 |
*/
|
|
207 |
TBool AnyFoldersL();
|
|
208 |
|
|
209 |
/*
|
|
210 |
* Return real indexes of selected items. These are the marked
|
|
211 |
* ones, if no marks then the highlighted one.
|
|
212 |
* @param aIncludeCurrent When ETrue, highlighted item is included, even
|
|
213 |
* if not marked.
|
|
214 |
* @return Array of view indexes. The array has been placed on the
|
|
215 |
* cleanup stack. The caller must destroy it and pop after no longer
|
|
216 |
* needed.
|
|
217 |
*/
|
|
218 |
CArrayFix<TInt>* SelectedRealIndexesLC() const;
|
|
219 |
|
|
220 |
/**
|
|
221 |
* Get the real index of current item (index into the model).
|
|
222 |
* @return View index or KErrNotFound if no current item.
|
|
223 |
*/
|
|
224 |
TInt CurrentItemRealIndex() const;
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Set highlight / marks / top item index state.
|
|
228 |
* @param aState State to restore from.
|
|
229 |
*/
|
|
230 |
void SetStateL( const CBrowserFavouritesListboxState& aState );
|
|
231 |
|
|
232 |
|
|
233 |
public: // Functions from CAknSingleGraphicStyleListBox
|
|
234 |
|
|
235 |
/**
|
|
236 |
* Handle key event.
|
|
237 |
* @param aKeyEvent The key event.
|
|
238 |
* @param aType Key event type.
|
|
239 |
* @return Response (was the key event consumed?).
|
|
240 |
*/
|
|
241 |
TKeyResponse OfferKeyEventL
|
|
242 |
( const TKeyEvent& aKeyEvent, TEventCode aType );
|
|
243 |
|
|
244 |
/**
|
|
245 |
* Handle focus change.
|
|
246 |
* @param aDrawNow Draw now?
|
|
247 |
*/
|
|
248 |
void FocusChanged( TDrawNow aDrawNow );
|
|
249 |
|
|
250 |
/*
|
|
251 |
* Create listbox model.
|
|
252 |
* @return The model for this listbox.
|
|
253 |
*/
|
|
254 |
void CreateModelL();
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Create listbox view.
|
|
258 |
* @return The view for this listbox.
|
|
259 |
*/
|
|
260 |
CListBoxView* MakeViewClassInstanceL();
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Create item drawer.
|
|
264 |
*/
|
|
265 |
void CreateItemDrawerL();
|
|
266 |
|
|
267 |
void HandleResourceChange( TInt aType );
|
|
268 |
|
|
269 |
public: // from MBrowserFaviconObserver
|
|
270 |
TInt DrawFavicons();
|
|
271 |
|
|
272 |
public: // defualt item access
|
|
273 |
inline TBrowserFavouritesListboxDefaultDatas& GetDefaultData()
|
|
274 |
{ return iDefaultDatas; }
|
|
275 |
|
|
276 |
inline CBrowserFaviconHandler* FaviconHandler()
|
|
277 |
{ return iFaviconHandler; }
|
|
278 |
|
|
279 |
inline TBool IsSkinUpdated ()
|
|
280 |
{ return iSkinUpdated; }
|
|
281 |
|
|
282 |
void SetSkinUpdated(TBool aSkinUpdated);
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Italicizes listbox row at index aRowIndex
|
|
286 |
*
|
|
287 |
* @param aRowIndex - index of row to be italicized
|
|
288 |
*/
|
|
289 |
void ItalicizeRowItemL(TInt aRowIndex);
|
|
290 |
|
|
291 |
/**
|
|
292 |
* Updates the favourites icons in the list. Initiates async operation
|
|
293 |
* to fetch and draw icons in background during idle time.
|
|
294 |
*/
|
|
295 |
void UpdateFavIconsL();
|
|
296 |
|
|
297 |
|
|
298 |
protected: // Construct / destruct
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Constructor.
|
|
302 |
*/
|
|
303 |
CBrowserFavouritesListbox( MApiProvider& aApiProvider );
|
|
304 |
|
|
305 |
/**
|
|
306 |
* Second phase constructor. Leaves on failure.
|
|
307 |
* @param aParent Parent control.
|
|
308 |
* @param aIconHandler The icon handler. Not owned.
|
|
309 |
*/
|
|
310 |
void ConstructL
|
|
311 |
(
|
|
312 |
const CCoeControl* aParent,
|
|
313 |
const MBrowserFavouritesListboxIconHandler& aIconHandler
|
|
314 |
);
|
|
315 |
|
|
316 |
/**
|
|
317 |
* Get listbox flags (markable etc.).
|
|
318 |
* @return listbox flags.
|
|
319 |
*/
|
|
320 |
virtual TInt ListboxFlags();
|
|
321 |
|
|
322 |
private: // new methods, getting listbox data
|
|
323 |
|
|
324 |
/**
|
|
325 |
* Return items to be displayed in a list. Owner is the caller.
|
|
326 |
* The returned list must have exactly as much items as aItems.
|
|
327 |
* @param aCommsModel Comms model to be used for getting AP data.
|
|
328 |
* @param aItems Item list.
|
|
329 |
* @return Icon index array.
|
|
330 |
*/
|
|
331 |
CBrowserFavouritesIconIndexArray* GetIconIndexesLC
|
|
332 |
( CFavouritesItemList& aItems );
|
|
333 |
|
|
334 |
/**
|
|
335 |
* Based on existing items and listbox state, calculate the new
|
|
336 |
* state which will be applied if items are replaced with new ones.
|
|
337 |
* @param aNewItems New item list.
|
|
338 |
* @return The new state. Owner is the caller, it must free the
|
|
339 |
* returned state.
|
|
340 |
*/
|
|
341 |
void CalcNewStateL( CFavouritesItemList& aNewItems );
|
|
342 |
|
|
343 |
/**
|
|
344 |
* Callback for fetching and drawing favicons
|
|
345 |
*/
|
|
346 |
static TInt UpdateFavIconsCallback( TAny* aParam );
|
|
347 |
|
|
348 |
|
|
349 |
private: // new methods: index <--> Uid conversion
|
|
350 |
|
|
351 |
/**
|
|
352 |
* Convert Uid to index.
|
|
353 |
* @param aUid Uid to convert.
|
|
354 |
* @return View index of item having aUid, or KErrNotFound.
|
|
355 |
*/
|
|
356 |
TInt UidToViewIndex( TInt aUid ) const;
|
|
357 |
|
|
358 |
/**
|
|
359 |
* Convert Uids to view indexes on the list. If any Uid is not found,
|
|
360 |
* it is removed from the list (list may contain less elements
|
|
361 |
* after calling).
|
|
362 |
* @param aList List of Uids to convert.
|
|
363 |
*/
|
|
364 |
void UidsToViewIndexes( CArrayFix<TInt>& aList ) const;
|
|
365 |
|
|
366 |
/**
|
|
367 |
* Convert real indexes to Uids on the list.
|
|
368 |
* @param aList List of indexes to convert.
|
|
369 |
*/
|
|
370 |
void RealIndexesToUids( CArrayFix<TInt>& aList ) const;
|
|
371 |
|
|
372 |
/**
|
|
373 |
* Return real indexes of marked items.
|
|
374 |
* @param aIncludeCurrent When ETrue, highlighted item is included, even
|
|
375 |
* if not marked.
|
|
376 |
* @return Array of view indexes. The array has been placed on the
|
|
377 |
* cleanup stack. The caller must destroy it and pop after no longer
|
|
378 |
* needed.
|
|
379 |
*/
|
|
380 |
CArrayFix<TInt>* MarkedRealIndexesLC() const;
|
|
381 |
|
|
382 |
|
|
383 |
|
|
384 |
private: // Conversion between uid <--> view index <--> real index.
|
|
385 |
|
|
386 |
// Note: there are two kinds of indexes in the listbox. One set is
|
|
387 |
// what is visible in the view (called View index), and the other
|
|
388 |
// what data is actually stored in the model (called Real index).
|
|
389 |
// When filtering kicks in, the two kind of indexes do not necessarily
|
|
390 |
// match, and a mapping between the two must be established.
|
|
391 |
|
|
392 |
|
|
393 |
/**
|
|
394 |
* Convert view index to real index.
|
|
395 |
* @param aViewlIndex View index (indexing to the visible elements).
|
|
396 |
* @return Real index or KErrNotFound if not found / not visible.
|
|
397 |
*/
|
|
398 |
TInt RealIndex( TInt aViewIndex ) const;
|
|
399 |
|
|
400 |
/**
|
|
401 |
* Convert view indexes to real indexes on the list. If any index is
|
|
402 |
* not found / not visible, it is removed from the list (list may
|
|
403 |
* contain less elements after calling).
|
|
404 |
* @param aList List of indexes to convert.
|
|
405 |
*/
|
|
406 |
void RealIndexes( CArrayFix<TInt>& aList ) const;
|
|
407 |
|
|
408 |
/**
|
|
409 |
* Get flags for constructing selection state.
|
|
410 |
* @param aItem Extract flags from this item.
|
|
411 |
* @return Flags originating from the item.
|
|
412 |
*/
|
|
413 |
TInt SelectionFlags( const CFavouritesItem& aItem ) const;
|
|
414 |
|
|
415 |
/**
|
|
416 |
* Convenience method; return the model.
|
|
417 |
* @return The model.
|
|
418 |
*/
|
|
419 |
CBrowserFavouritesListboxModel* TheModel() const;
|
|
420 |
|
|
421 |
protected: // data
|
|
422 |
|
|
423 |
/**
|
|
424 |
* Icon handler (this creates icons and calculates icon indexes).
|
|
425 |
*/
|
|
426 |
const MBrowserFavouritesListboxIconHandler* iIconHandler;
|
|
427 |
|
|
428 |
protected: // data
|
|
429 |
|
|
430 |
/**
|
|
431 |
* Real data for this listbox, array of items. Owned.
|
|
432 |
*/
|
|
433 |
CFavouritesItemList* iItems;
|
|
434 |
|
|
435 |
/**
|
|
436 |
* Icon indexes for the items. Owned.
|
|
437 |
*/
|
|
438 |
CBrowserFavouritesIconIndexArray* iIconIndexes;
|
|
439 |
|
|
440 |
/**
|
|
441 |
* Skin updated status
|
|
442 |
*/
|
|
443 |
TBool iSkinUpdated;
|
|
444 |
|
|
445 |
private: // data
|
|
446 |
|
|
447 |
MApiProvider& iApiProvider; // not owned
|
|
448 |
|
|
449 |
/**
|
|
450 |
* Observer for cursor changes.
|
|
451 |
*/
|
|
452 |
MBrowserFavouritesListboxCursorObserver* iCursorObserver;
|
|
453 |
|
|
454 |
/**
|
|
455 |
* Placeholder for new listbox state, when listbox content changes.
|
|
456 |
* This should really be a local variable, but it just cannot be done!
|
|
457 |
* because the cleanup stack cannot be managed (can't swap items in
|
|
458 |
* the stack).
|
|
459 |
*/
|
|
460 |
CBrowserFavouritesListboxState* iNewState;
|
|
461 |
TBrowserFavouritesListboxDefaultDatas iDefaultDatas;
|
|
462 |
CBrowserFaviconHandler* iFaviconHandler;
|
|
463 |
|
|
464 |
/**
|
|
465 |
* Italicized font for setting listbox rows to italics font.
|
|
466 |
*/
|
|
467 |
CFbsFont *iFontItalic;
|
|
468 |
|
|
469 |
CIdle *iIconUpdateCallback;
|
|
470 |
|
|
471 |
|
|
472 |
};
|
|
473 |
|
|
474 |
#endif
|
|
475 |
|
|
476 |
// End of File
|