|
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 CBrowserFavouritesView. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef BROWSER_FAVOURITES_VIEW_H |
|
22 #define BROWSER_FAVOURITES_VIEW_H |
|
23 |
|
24 // INCLUDE FILES |
|
25 #include <eiklbo.h> |
|
26 |
|
27 #include "BrowserFavouritesModelObserver.h" |
|
28 #include "BrowserAppViewBase.h" |
|
29 #include "CommandVisibility.h" |
|
30 #include "CommsModel.h" |
|
31 #include "BrowserFavouritesModel.h" |
|
32 #include <favouriteslimits.h> |
|
33 |
|
34 // FORWARD DECLARATION |
|
35 class CFavouritesItemList; |
|
36 class CBrowserFavouritesContainer; |
|
37 class CBrowserFavouritesModel; |
|
38 class CBrowserFavouritesIncrementalOp; |
|
39 class CBrowserFavouritesListboxState; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * Base class for Bookmarks View and Saved Decks View of the WML Browser. |
|
45 * The common behaviour of these views is collected here. This includes: |
|
46 * Handling view activation / decativation; |
|
47 * Interpreting (common) commands; |
|
48 * Providing context-specific menus. |
|
49 * Pure virtual; derived classes must provide model and control components |
|
50 * and items to display. A number of methods can be overridden. |
|
51 */ |
|
52 class CBrowserFavouritesView:public CBrowserViewBase, |
|
53 public MEikListBoxObserver, |
|
54 public MBrowserFavouritesModelObserver, |
|
55 public MCommsModelObserver |
|
56 { |
|
57 public: // construction |
|
58 |
|
59 /** |
|
60 * Destructor. |
|
61 */ |
|
62 virtual ~CBrowserFavouritesView(); |
|
63 |
|
64 public: // From MCbaSetter (CBrowserViewBase) |
|
65 |
|
66 /** |
|
67 * Return command set id, to be displayed. |
|
68 * @since 1.2 |
|
69 * @return The command set's resource id. |
|
70 */ |
|
71 virtual TInt CommandSetResourceIdL(); |
|
72 |
|
73 /** |
|
74 * Set command set lsk,rsk,msk dynamically via pointers. |
|
75 * Derived classes should implement, though it can be empty. |
|
76 * If it does nothing, empty softkeys will be assigned |
|
77 * @since 5.0 |
|
78 */ |
|
79 void CommandSetResourceDynL(TSKPair& /*lsk*/, TSKPair& /*rsk*/, TSKPair& /*msk*/) {}; |
|
80 |
|
81 /** |
|
82 * Return the resource ID of the seamless folder. |
|
83 * @param aContextID Context ID of the seamless folder. |
|
84 * @return The resource ID of the seamless folder or zero if it is not |
|
85 * seamless. |
|
86 */ |
|
87 static TInt GetSeamlessFolderResourceID( TInt aContextID ); |
|
88 |
|
89 /** |
|
90 * Return the resource ID of the seamless folder title. |
|
91 * @param aContextID Context ID of the seamless folder. |
|
92 * @return The resource ID of the seamless folder title or zero if it is not |
|
93 * seamless. |
|
94 */ |
|
95 static TInt GetSeamlessFolderTitleResourceID( TInt aContextID ); |
|
96 |
|
97 /** |
|
98 * Examines if the given ID is an ID of a seamless folder. |
|
99 * @param aContextID Context ID of the folder. |
|
100 * @return The ETrue if the given ID is a seamless ID otherwise EFalse. |
|
101 * seamless. |
|
102 */ |
|
103 static TBool IsSeamlessFolder( TInt aContextID ); |
|
104 |
|
105 |
|
106 /** |
|
107 * Configure Context Menu Resource |
|
108 * |
|
109 * context-sensitive menu when item(s) marked |
|
110 */ |
|
111 void ConfigContextMenu(); |
|
112 |
|
113 static TInt RefeshFavoriteListBox( TAny* aFavouritesView ); |
|
114 |
|
115 public: // public methods from CAknView (CBrowserViewBase) |
|
116 |
|
117 /** |
|
118 * Handle command. |
|
119 * @since 1.2 |
|
120 * @param aCommand Command id. |
|
121 */ |
|
122 virtual void HandleCommandL( TInt aCommand ); |
|
123 |
|
124 /** |
|
125 * Get view id. Derived classes must provide this method. |
|
126 * @return The view id for this view. |
|
127 */ |
|
128 virtual TUid Id() const = 0; |
|
129 |
|
130 void OpenFixedFolderL(TInt aUid); |
|
131 |
|
132 protected : |
|
133 |
|
134 // For Adaptive bookmarks folder navigation, used in Bookmarks View |
|
135 |
|
136 void SetRootFolderForAdaptiveBookmarks(); |
|
137 |
|
138 protected : // construction |
|
139 |
|
140 /** |
|
141 * Constructor. |
|
142 * @param aApiProvider The API provider. |
|
143 */ |
|
144 CBrowserFavouritesView( MApiProvider& aApiProvider, TInt aInitialFolderId = KFavouritesRootUid ); |
|
145 |
|
146 /** |
|
147 * Second phase constructor. Leaves on failure. |
|
148 * @param aViewResourceId Resource id for this view. |
|
149 * Derived classes should call this first during construction. |
|
150 */ |
|
151 void ConstructL( TInt aViewResourceId ); |
|
152 |
|
153 protected: // menu initialization |
|
154 |
|
155 /** |
|
156 * Initialize context-sensitive menu. |
|
157 * @param aResourceId Resource id of the menu pane. |
|
158 * @param aMenuPane Menu pane object being initialized. |
|
159 * @param aIndex Index into the visibility map. |
|
160 * @param aState Selection state. |
|
161 */ |
|
162 virtual void DynInitMenuPaneL |
|
163 ( |
|
164 TInt aResourceId, |
|
165 CEikMenuPane* aMenuPane, |
|
166 TCommandVisibility::TIndex aIndex, |
|
167 const TBrowserFavouritesSelectionState& aState |
|
168 ) = 0; |
|
169 |
|
170 protected: // new methods |
|
171 |
|
172 /** |
|
173 * Get resource id of text to be displayed in navi pane when |
|
174 * root folder is shown (TBUF). |
|
175 * Derived classes must provide this method. |
|
176 * @since 1.2 |
|
177 * @return Resource id. |
|
178 */ |
|
179 virtual TInt RootTitleResourceId() const = 0; |
|
180 |
|
181 /** |
|
182 * Get resource id of Options menu (RESOURCE MENU_BAR). |
|
183 * Derived classes must provide this method. |
|
184 * @since 1.2 |
|
185 * @return Resource id. |
|
186 */ |
|
187 virtual TInt OptionsMenuResourceId() const = 0; |
|
188 |
|
189 /** |
|
190 * Get resource id of OK-Options menu (RESOURCE MENU_BAR). |
|
191 * Derived classes must provide this method. |
|
192 * @since 1.2 |
|
193 * @return Resource id. |
|
194 */ |
|
195 virtual TInt OkOptionsMenuResourceId() const = 0; |
|
196 |
|
197 protected: // component creation |
|
198 |
|
199 /** |
|
200 * Create the model. Leave on failure. The model is owned by the |
|
201 * caller (this view). |
|
202 * Derived classes must provide this method. |
|
203 * @return The constructed model. |
|
204 */ |
|
205 virtual CBrowserFavouritesModel* CreateModelL() = 0; |
|
206 |
|
207 /** |
|
208 * Create the container (the main control of the view). The container |
|
209 * is owned by the caller (this view). |
|
210 * Leave on failure. |
|
211 * Derived classes must provide this method. |
|
212 * @return The constructed main control. |
|
213 */ |
|
214 virtual CBrowserFavouritesContainer* CreateContainerL() = 0; |
|
215 |
|
216 protected: // data retrieval |
|
217 |
|
218 /** |
|
219 * Get items to be displayed in a folder. Expects the model's db be |
|
220 * open. |
|
221 * @param aFolder Folder which contains the items. |
|
222 * @return List of items. Pushed on the cleanup stack. |
|
223 */ |
|
224 virtual CFavouritesItemList* GetItemsLC( TInt aFolder ); |
|
225 |
|
226 public: |
|
227 |
|
228 /** |
|
229 * Get the model. |
|
230 * @return The model. |
|
231 */ |
|
232 inline CBrowserFavouritesModel& Model() const; |
|
233 |
|
234 inline void ShowNextFolerL(TBool aNext) { OpenNextFolderL(aNext); } |
|
235 |
|
236 protected: // component retrieval |
|
237 |
|
238 /** |
|
239 * Get the container (the view's main control). |
|
240 * @return The container. Can be NULL (when view is not activated, |
|
241 * container does not exist). |
|
242 */ |
|
243 inline CBrowserFavouritesContainer* Container() const; |
|
244 |
|
245 /** |
|
246 * Get Uid of the folder shown. |
|
247 * @return Current folder's Uid. |
|
248 */ |
|
249 inline TInt CurrentFolder() const; |
|
250 |
|
251 |
|
252 protected: // new methods |
|
253 |
|
254 /** |
|
255 * If there is a preferred highlight uid, attempt to highlight that. |
|
256 * If succeeded, preferred highlight uid is cleared ("used up"). |
|
257 * Otherwise do nothing. |
|
258 */ |
|
259 void HighlightPreferredL(); |
|
260 |
|
261 /** |
|
262 * Some displayed data has changed (Favourites database, AP-s, etc). |
|
263 * Update the view so changes become visible. Safe to call if the view |
|
264 * is not active; in this case it does nothing. |
|
265 * This method should not be called if the data change is due to direct |
|
266 * user activity (opening folders etc.); only for notification |
|
267 * processing. |
|
268 * @param aDbErrorNote If ETrue, unsuccesful database access will bring |
|
269 * up an error note. |
|
270 */ |
|
271 virtual void RefreshL( TBool aDbErrorNote = EFalse ); |
|
272 |
|
273 /** |
|
274 * Redraw. |
|
275 */ |
|
276 void HandleClientRectChange(); |
|
277 |
|
278 protected: // from CAknView |
|
279 |
|
280 /** |
|
281 * Activate the view. Open the database. If it was activated |
|
282 * previously, try to restore the view as it was before deactivation. |
|
283 * @param aPrevViewId Previous View Id. |
|
284 * @param aCustomMessageId Custom Message Id. |
|
285 * @param aCustomMessage Custom Message. |
|
286 */ |
|
287 void DoActivateL |
|
288 ( |
|
289 const TVwsViewId& aPrevViewId, |
|
290 TUid aCustomMessageId, |
|
291 const TDesC8& aCustomMessage |
|
292 ); |
|
293 |
|
294 /** |
|
295 * Deactivate the view. Close the database. Save the view state, |
|
296 * so it can be restored on future activations. |
|
297 */ |
|
298 void DoDeactivate(); |
|
299 |
|
300 /** |
|
301 * Initialize context-sensitive menu. Do not override this one; |
|
302 * override the other. |
|
303 * @param aResourceId Resource id of the menu pane. |
|
304 * @param aMenuPane Menu pane object being initialized. |
|
305 */ |
|
306 void DynInitMenuPaneL |
|
307 ( TInt aResourceId, CEikMenuPane* aMenuPane ); |
|
308 |
|
309 /** |
|
310 * Handle foreground event. |
|
311 * @param aForeground ETrue if foreground. |
|
312 */ |
|
313 virtual void HandleForegroundEventL( TBool aForeground ); |
|
314 |
|
315 protected: // from MEikListBoxObserver |
|
316 |
|
317 /** |
|
318 * Handle listbox event. |
|
319 * @param aListBox Listbox in which the event occurred. |
|
320 * @param aEventType Event. |
|
321 */ |
|
322 virtual void HandleListBoxEventL |
|
323 ( CEikListBox* aListBox, |
|
324 MEikListBoxObserver::TListBoxEvent aEventType ); |
|
325 |
|
326 private: // command handling |
|
327 |
|
328 /** |
|
329 * Command "Back", when showing a folder. Open the parent folder. |
|
330 * of the currently shown folder. Highlight the folder just closed. |
|
331 */ |
|
332 void CloseCurrentFolderL(); |
|
333 |
|
334 /** |
|
335 * Command "Open (folder)". Open the highlighted folder. |
|
336 * Does nothing if no folder is highlighted. |
|
337 */ |
|
338 void OpenCurrentFolderL(); |
|
339 |
|
340 /** |
|
341 * Command "Open (folder)" from OK-Options menu. Open the marked folder. |
|
342 * Does nothing if no folder is marked or more is marked. |
|
343 */ |
|
344 void OpenMarkedFolderL(); |
|
345 |
|
346 /** |
|
347 * Command "Remove" or "Erase". Delete marked item(s). |
|
348 * Does nothing if no item is highlighted / marked. |
|
349 */ |
|
350 virtual void DeleteMarkedItemsL(); |
|
351 |
|
352 protected: |
|
353 /** |
|
354 * Command "New folder". New folders are alwas created in the root |
|
355 * folder. |
|
356 * @return The uid of the newly created folder, or KFavouritesNullUid |
|
357 * (if not created). |
|
358 */ |
|
359 TInt AddNewFolderL(); |
|
360 |
|
361 private: |
|
362 |
|
363 /** |
|
364 * Command "Move To Folder". Launch target folder selection dialog and |
|
365 * move marked item(s). |
|
366 */ |
|
367 void MoveMarkedItemsL(); |
|
368 |
|
369 |
|
370 /** |
|
371 * Command "Rename". Rename current item. |
|
372 * Does nothing if no item is highlighted. |
|
373 */ |
|
374 void RenameCurrentItemL(); |
|
375 |
|
376 protected: // implementation details. |
|
377 |
|
378 /** |
|
379 * Open a folder by Uid and display its contents. Expects the |
|
380 * model's db be open. |
|
381 * @param aFolder Folder to open. |
|
382 */ |
|
383 void OpenFolderL( TInt aFolder ); |
|
384 |
|
385 /** |
|
386 * Open next folder. |
|
387 * @param aForward Open next folder if ETrue, previous if EFalse. |
|
388 */ |
|
389 virtual void OpenNextFolderL( TBool aForward ); |
|
390 |
|
391 private: |
|
392 |
|
393 /** |
|
394 * Fill listbox with folder contents. Expects the model's db be open. |
|
395 * @param aFolder Folder to display. |
|
396 * @param aKeepState If ETrue, try to restore marks/highlight/top item |
|
397 * position. |
|
398 */ |
|
399 void FillListboxL( TInt aFolder, TBool aKeepState ); |
|
400 |
|
401 /** |
|
402 * Display confirmation dialog before deleting items. The dialog |
|
403 * displayed is context-dependent (different dialog for one/more |
|
404 * items, and for non-empty folders). |
|
405 * @param aUids List of Uids (both item & folder) about to be deleted. |
|
406 * @param aFolderUids List of folder uids about to be deleted. These |
|
407 * uids are also in aUids, and are needed only to improve performance. |
|
408 * (The non-empty folder checking, which is the only database query in |
|
409 * this method, is performed only for folders. The effect of this is |
|
410 * visible only if many items are selected.) |
|
411 * @return ETrue if delete was confirmed; EFalse if not, or in case of |
|
412 * any error (e.g. database error). |
|
413 */ |
|
414 TBool ConfirmDeleteL |
|
415 ( CArrayFix<TInt>& aUids, CArrayFix<TInt>& aFolderUids ); |
|
416 |
|
417 /** |
|
418 * After deleting items, display appropriate note about the outcome. |
|
419 * @param aUids List of Uids that were selected for deletion. |
|
420 * @param aNotDeletedUids List of Uids which are not deleted. |
|
421 */ |
|
422 void DisplayResultOfDeleteL |
|
423 ( |
|
424 const CArrayFix<TInt>& aUids, |
|
425 const CArrayFix<TInt>& aNotDeletedUids |
|
426 ); |
|
427 |
|
428 /** |
|
429 * Launch target folder selection dialog and return uid of selected |
|
430 * folder (or KFavouritesNullUid if cancelled or in case of any error). |
|
431 * If no folders exist, user is prompted to create one. |
|
432 * @param aExcludeFolder Exclude this folder from selection (current |
|
433 * folder). |
|
434 * @return Uid of selected folder, or KFavouritesNullUid. |
|
435 */ |
|
436 TInt SelectTargetFolderL( TInt aExcludeFolder ); |
|
437 |
|
438 /** |
|
439 * "First pass" of moving is done; items that could be moved without |
|
440 * user intervention, has been moved. Some of them may be still there, |
|
441 * because it is unmovable (e.g. Homepage), or conflicts with a name in |
|
442 * the target folder. For the latter ones, ask for each if replace the |
|
443 * old ones, and act accordingly. |
|
444 * Display appropriate note about what happened. |
|
445 * @param aFolder The target folder. |
|
446 * @param aUids List of Uids that were selected for moving. |
|
447 * @param aUnmovableUids List of Uids which could never be moved. |
|
448 * @param aConflictingNameUids List of conflicting name Uids. |
|
449 */ |
|
450 void HandleMoveResultL |
|
451 ( |
|
452 TInt aFolder, |
|
453 const CArrayFix<TInt>& aUids, |
|
454 const CArrayFix<TInt>& aUnmovableUids, |
|
455 const CArrayFix<TInt>& aConflictingNameUids |
|
456 ); |
|
457 |
|
458 /** |
|
459 * For each of the items in the list, display a rename dialog before |
|
460 * moving them into the folder. |
|
461 * @param aFolder The target folder. |
|
462 * @param aUids List of Uids that were selected for moving. |
|
463 */ |
|
464 void RenameAndMoveItemsL |
|
465 ( const CArrayFix<TInt>& aUids, TInt aFolder ); |
|
466 protected: // new methods |
|
467 |
|
468 /** |
|
469 * Update and draw navi pane (show tabs for root, or "1/4" style text |
|
470 * for subfolders). |
|
471 * No sanity check; expects the model's table be open. |
|
472 */ |
|
473 virtual void UpdateNaviPaneL(); |
|
474 |
|
475 private: // new methods |
|
476 |
|
477 /** |
|
478 * The container passes back key events to the view first, to |
|
479 * allow moving between folders. (The container does not know |
|
480 * anything about folders.) |
|
481 */ |
|
482 friend class CBrowserFavouritesContainer; |
|
483 |
|
484 protected: |
|
485 /** |
|
486 * Handle key event (called from the container, to allow moving between |
|
487 * folders. |
|
488 * @param aKeyEvent The key event. |
|
489 * @param aType Key event type. |
|
490 * @return Response (was the key event consumed?). |
|
491 */ |
|
492 virtual TKeyResponse OfferKeyEventL |
|
493 ( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
494 |
|
495 /** |
|
496 * Reset state with deactivation event |
|
497 */ |
|
498 void ResetStateInDeActivation(); |
|
499 |
|
500 /** |
|
501 * Needed for updating tool bar buttons when there is a up/down arrow key events received. |
|
502 **/ |
|
503 virtual void UpdateToolbarButtonsState(); |
|
504 |
|
505 private: // from MWmlBrowserFavouritesModelObserver |
|
506 |
|
507 /** |
|
508 * Handle model change. |
|
509 */ |
|
510 void HandleFavouritesModelChangeL(); |
|
511 |
|
512 private: // from MCommsModelObserver |
|
513 |
|
514 /** |
|
515 * Handle Comms Model change (AP update). |
|
516 */ |
|
517 void HandleCommsModelChangeL(); |
|
518 |
|
519 private: // default item settings |
|
520 |
|
521 /** |
|
522 * Set Prefered the current item |
|
523 */ |
|
524 void SetPreferedCurrentItemL(); |
|
525 |
|
526 /** |
|
527 * Set Prefered the current item |
|
528 */ |
|
529 void SetUnPreferedCurrentItemL(); |
|
530 |
|
531 |
|
532 protected: // data |
|
533 |
|
534 /// Preferred highlight uid. |
|
535 TInt iPreferredHighlightUid; |
|
536 |
|
537 /// If ETrue, OK-Options menu is shown instead of normal Options menu. |
|
538 TBool iShowOkOptions; |
|
539 |
|
540 /// Top-level control of the view. Owned |
|
541 CBrowserFavouritesContainer* iContainer; |
|
542 |
|
543 /// Uid of the current folder. |
|
544 TInt iCurrentFolder; |
|
545 |
|
546 /// ETrue between DoActivateL() and DoDeactivate(). |
|
547 TBool iIsActivated; |
|
548 |
|
549 private: // data |
|
550 |
|
551 /// The model (data handling). Owned. |
|
552 CBrowserFavouritesModel* iModel; |
|
553 TInt iLastSelection; |
|
554 /// Incremental operation, or NULL if no such. Owned. |
|
555 CBrowserFavouritesIncrementalOp* iIncrementalOp; |
|
556 /// ETrue if data update is missed due to incremental operation. |
|
557 TBool iUpdatePending; |
|
558 /// Asynchronously update the favourite item's List Box |
|
559 CIdle* iFavViewRefresh; |
|
560 protected: |
|
561 |
|
562 TBool iRefresh; // Flag to indicate that Bookmarks list should be refreshed. |
|
563 // ETrue by default, turned off only in cases we want to avoid |
|
564 // double refresh. Checked in HandleFavouritesModelChangeL. |
|
565 |
|
566 TInt iInitialFolder; //Folder to which browser is launched in embedded mode |
|
567 |
|
568 // Flag to indicate that we are about to open Preferences view, |
|
569 // in order not to return to root folder afterwards. |
|
570 TBool iSaveStateOnDeactivate; |
|
571 |
|
572 CBrowserFavouritesListboxState* iSavedListboxState; |
|
573 }; |
|
574 |
|
575 #include "BrowserFavouritesView.inl" |
|
576 |
|
577 #endif |
|
578 |
|
579 // End of file |