|
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 |
|
114 public: // public methods from CAknView (CBrowserViewBase) |
|
115 |
|
116 /** |
|
117 * Handle command. |
|
118 * @since 1.2 |
|
119 * @param aCommand Command id. |
|
120 */ |
|
121 virtual void HandleCommandL( TInt aCommand ); |
|
122 |
|
123 /** |
|
124 * Get view id. Derived classes must provide this method. |
|
125 * @return The view id for this view. |
|
126 */ |
|
127 virtual TUid Id() const = 0; |
|
128 |
|
129 void OpenFixedFolderL(TInt aUid); |
|
130 |
|
131 protected : |
|
132 |
|
133 // For Adaptive bookmarks folder navigation, used in Bookmarks View |
|
134 |
|
135 void SetRootFolderForAdaptiveBookmarks(); |
|
136 |
|
137 protected : // construction |
|
138 |
|
139 /** |
|
140 * Constructor. |
|
141 * @param aApiProvider The API provider. |
|
142 */ |
|
143 CBrowserFavouritesView( MApiProvider& aApiProvider, TInt aInitialFolderId = KFavouritesRootUid ); |
|
144 |
|
145 /** |
|
146 * Second phase constructor. Leaves on failure. |
|
147 * @param aViewResourceId Resource id for this view. |
|
148 * Derived classes should call this first during construction. |
|
149 */ |
|
150 void ConstructL( TInt aViewResourceId ); |
|
151 |
|
152 protected: // menu initialization |
|
153 |
|
154 /** |
|
155 * Initialize context-sensitive menu. |
|
156 * @param aResourceId Resource id of the menu pane. |
|
157 * @param aMenuPane Menu pane object being initialized. |
|
158 * @param aIndex Index into the visibility map. |
|
159 * @param aState Selection state. |
|
160 */ |
|
161 virtual void DynInitMenuPaneL |
|
162 ( |
|
163 TInt aResourceId, |
|
164 CEikMenuPane* aMenuPane, |
|
165 TCommandVisibility::TIndex aIndex, |
|
166 const TBrowserFavouritesSelectionState& aState |
|
167 ) = 0; |
|
168 |
|
169 protected: // new methods |
|
170 |
|
171 /** |
|
172 * Get resource id of text to be displayed in navi pane when |
|
173 * root folder is shown (TBUF). |
|
174 * Derived classes must provide this method. |
|
175 * @since 1.2 |
|
176 * @return Resource id. |
|
177 */ |
|
178 virtual TInt RootTitleResourceId() const = 0; |
|
179 |
|
180 /** |
|
181 * Get resource id of Options menu (RESOURCE MENU_BAR). |
|
182 * Derived classes must provide this method. |
|
183 * @since 1.2 |
|
184 * @return Resource id. |
|
185 */ |
|
186 virtual TInt OptionsMenuResourceId() const = 0; |
|
187 |
|
188 /** |
|
189 * Get resource id of OK-Options menu (RESOURCE MENU_BAR). |
|
190 * Derived classes must provide this method. |
|
191 * @since 1.2 |
|
192 * @return Resource id. |
|
193 */ |
|
194 virtual TInt OkOptionsMenuResourceId() const = 0; |
|
195 |
|
196 protected: // component creation |
|
197 |
|
198 /** |
|
199 * Create the model. Leave on failure. The model is owned by the |
|
200 * caller (this view). |
|
201 * Derived classes must provide this method. |
|
202 * @return The constructed model. |
|
203 */ |
|
204 virtual CBrowserFavouritesModel* CreateModelL() = 0; |
|
205 |
|
206 /** |
|
207 * Create the container (the main control of the view). The container |
|
208 * is owned by the caller (this view). |
|
209 * Leave on failure. |
|
210 * Derived classes must provide this method. |
|
211 * @return The constructed main control. |
|
212 */ |
|
213 virtual CBrowserFavouritesContainer* CreateContainerL() = 0; |
|
214 |
|
215 protected: // data retrieval |
|
216 |
|
217 /** |
|
218 * Get items to be displayed in a folder. Expects the model's db be |
|
219 * open. |
|
220 * @param aFolder Folder which contains the items. |
|
221 * @return List of items. Pushed on the cleanup stack. |
|
222 */ |
|
223 virtual CFavouritesItemList* GetItemsLC( TInt aFolder ); |
|
224 |
|
225 public: |
|
226 |
|
227 /** |
|
228 * Get the model. |
|
229 * @return The model. |
|
230 */ |
|
231 inline CBrowserFavouritesModel& Model() const; |
|
232 |
|
233 inline void ShowNextFolerL(TBool aNext) { OpenNextFolderL(aNext); } |
|
234 |
|
235 protected: // component retrieval |
|
236 |
|
237 /** |
|
238 * Get the container (the view's main control). |
|
239 * @return The container. Can be NULL (when view is not activated, |
|
240 * container does not exist). |
|
241 */ |
|
242 inline CBrowserFavouritesContainer* Container() const; |
|
243 |
|
244 /** |
|
245 * Get Uid of the folder shown. |
|
246 * @return Current folder's Uid. |
|
247 */ |
|
248 inline TInt CurrentFolder() const; |
|
249 |
|
250 |
|
251 protected: // new methods |
|
252 |
|
253 /** |
|
254 * If there is a preferred highlight uid, attempt to highlight that. |
|
255 * If succeeded, preferred highlight uid is cleared ("used up"). |
|
256 * Otherwise do nothing. |
|
257 */ |
|
258 void HighlightPreferredL(); |
|
259 |
|
260 /** |
|
261 * Some displayed data has changed (Favourites database, AP-s, etc). |
|
262 * Update the view so changes become visible. Safe to call if the view |
|
263 * is not active; in this case it does nothing. |
|
264 * This method should not be called if the data change is due to direct |
|
265 * user activity (opening folders etc.); only for notification |
|
266 * processing. |
|
267 * @param aDbErrorNote If ETrue, unsuccesful database access will bring |
|
268 * up an error note. |
|
269 */ |
|
270 virtual void RefreshL( TBool aDbErrorNote = EFalse ); |
|
271 |
|
272 /** |
|
273 * Redraw. |
|
274 */ |
|
275 void HandleClientRectChange(); |
|
276 |
|
277 protected: // from CAknView |
|
278 |
|
279 /** |
|
280 * Activate the view. Open the database. If it was activated |
|
281 * previously, try to restore the view as it was before deactivation. |
|
282 * @param aPrevViewId Previous View Id. |
|
283 * @param aCustomMessageId Custom Message Id. |
|
284 * @param aCustomMessage Custom Message. |
|
285 */ |
|
286 void DoActivateL |
|
287 ( |
|
288 const TVwsViewId& aPrevViewId, |
|
289 TUid aCustomMessageId, |
|
290 const TDesC8& aCustomMessage |
|
291 ); |
|
292 |
|
293 /** |
|
294 * Deactivate the view. Close the database. Save the view state, |
|
295 * so it can be restored on future activations. |
|
296 */ |
|
297 void DoDeactivate(); |
|
298 |
|
299 /** |
|
300 * Initialize context-sensitive menu. Do not override this one; |
|
301 * override the other. |
|
302 * @param aResourceId Resource id of the menu pane. |
|
303 * @param aMenuPane Menu pane object being initialized. |
|
304 */ |
|
305 void DynInitMenuPaneL |
|
306 ( TInt aResourceId, CEikMenuPane* aMenuPane ); |
|
307 |
|
308 /** |
|
309 * Handle foreground event. |
|
310 * @param aForeground ETrue if foreground. |
|
311 */ |
|
312 void HandleForegroundEventL( TBool aForeground ); |
|
313 |
|
314 protected: // from MEikListBoxObserver |
|
315 |
|
316 /** |
|
317 * Handle listbox event. |
|
318 * @param aListBox Listbox in which the event occurred. |
|
319 * @param aEventType Event. |
|
320 */ |
|
321 virtual void HandleListBoxEventL |
|
322 ( CEikListBox* aListBox, |
|
323 MEikListBoxObserver::TListBoxEvent aEventType ); |
|
324 |
|
325 private: // command handling |
|
326 |
|
327 /** |
|
328 * Command "Back", when showing a folder. Open the parent folder. |
|
329 * of the currently shown folder. Highlight the folder just closed. |
|
330 */ |
|
331 void CloseCurrentFolderL(); |
|
332 |
|
333 /** |
|
334 * Command "Open (folder)". Open the highlighted folder. |
|
335 * Does nothing if no folder is highlighted. |
|
336 */ |
|
337 void OpenCurrentFolderL(); |
|
338 |
|
339 /** |
|
340 * Command "Open (folder)" from OK-Options menu. Open the marked folder. |
|
341 * Does nothing if no folder is marked or more is marked. |
|
342 */ |
|
343 void OpenMarkedFolderL(); |
|
344 |
|
345 /** |
|
346 * Command "Remove" or "Erase". Delete marked item(s). |
|
347 * Does nothing if no item is highlighted / marked. |
|
348 */ |
|
349 virtual void DeleteMarkedItemsL(); |
|
350 |
|
351 protected: |
|
352 /** |
|
353 * Command "New folder". New folders are alwas created in the root |
|
354 * folder. |
|
355 * @return The uid of the newly created folder, or KFavouritesNullUid |
|
356 * (if not created). |
|
357 */ |
|
358 TInt AddNewFolderL(); |
|
359 |
|
360 private: |
|
361 |
|
362 /** |
|
363 * Command "Move To Folder". Launch target folder selection dialog and |
|
364 * move marked item(s). |
|
365 */ |
|
366 void MoveMarkedItemsL(); |
|
367 |
|
368 |
|
369 /** |
|
370 * Command "Rename". Rename current item. |
|
371 * Does nothing if no item is highlighted. |
|
372 */ |
|
373 void RenameCurrentItemL(); |
|
374 |
|
375 protected: // implementation details. |
|
376 |
|
377 /** |
|
378 * Open a folder by Uid and display its contents. Expects the |
|
379 * model's db be open. |
|
380 * @param aFolder Folder to open. |
|
381 */ |
|
382 void OpenFolderL( TInt aFolder ); |
|
383 |
|
384 /** |
|
385 * Open next folder. |
|
386 * @param aForward Open next folder if ETrue, previous if EFalse. |
|
387 */ |
|
388 virtual void OpenNextFolderL( TBool aForward ); |
|
389 |
|
390 private: |
|
391 |
|
392 /** |
|
393 * Fill listbox with folder contents. Expects the model's db be open. |
|
394 * @param aFolder Folder to display. |
|
395 * @param aKeepState If ETrue, try to restore marks/highlight/top item |
|
396 * position. |
|
397 */ |
|
398 void FillListboxL( TInt aFolder, TBool aKeepState ); |
|
399 |
|
400 /** |
|
401 * Display confirmation dialog before deleting items. The dialog |
|
402 * displayed is context-dependent (different dialog for one/more |
|
403 * items, and for non-empty folders). |
|
404 * @param aUids List of Uids (both item & folder) about to be deleted. |
|
405 * @param aFolderUids List of folder uids about to be deleted. These |
|
406 * uids are also in aUids, and are needed only to improve performance. |
|
407 * (The non-empty folder checking, which is the only database query in |
|
408 * this method, is performed only for folders. The effect of this is |
|
409 * visible only if many items are selected.) |
|
410 * @return ETrue if delete was confirmed; EFalse if not, or in case of |
|
411 * any error (e.g. database error). |
|
412 */ |
|
413 TBool ConfirmDeleteL |
|
414 ( CArrayFix<TInt>& aUids, CArrayFix<TInt>& aFolderUids ); |
|
415 |
|
416 /** |
|
417 * After deleting items, display appropriate note about the outcome. |
|
418 * @param aUids List of Uids that were selected for deletion. |
|
419 * @param aNotDeletedUids List of Uids which are not deleted. |
|
420 */ |
|
421 void DisplayResultOfDeleteL |
|
422 ( |
|
423 const CArrayFix<TInt>& aUids, |
|
424 const CArrayFix<TInt>& aNotDeletedUids |
|
425 ); |
|
426 |
|
427 /** |
|
428 * Launch target folder selection dialog and return uid of selected |
|
429 * folder (or KFavouritesNullUid if cancelled or in case of any error). |
|
430 * If no folders exist, user is prompted to create one. |
|
431 * @param aExcludeFolder Exclude this folder from selection (current |
|
432 * folder). |
|
433 * @return Uid of selected folder, or KFavouritesNullUid. |
|
434 */ |
|
435 TInt SelectTargetFolderL( TInt aExcludeFolder ); |
|
436 |
|
437 /** |
|
438 * "First pass" of moving is done; items that could be moved without |
|
439 * user intervention, has been moved. Some of them may be still there, |
|
440 * because it is unmovable (e.g. Homepage), or conflicts with a name in |
|
441 * the target folder. For the latter ones, ask for each if replace the |
|
442 * old ones, and act accordingly. |
|
443 * Display appropriate note about what happened. |
|
444 * @param aFolder The target folder. |
|
445 * @param aUids List of Uids that were selected for moving. |
|
446 * @param aUnmovableUids List of Uids which could never be moved. |
|
447 * @param aConflictingNameUids List of conflicting name Uids. |
|
448 */ |
|
449 void HandleMoveResultL |
|
450 ( |
|
451 TInt aFolder, |
|
452 const CArrayFix<TInt>& aUids, |
|
453 const CArrayFix<TInt>& aUnmovableUids, |
|
454 const CArrayFix<TInt>& aConflictingNameUids |
|
455 ); |
|
456 |
|
457 /** |
|
458 * For each of the items in the list, display a rename dialog before |
|
459 * moving them into the folder. |
|
460 * @param aFolder The target folder. |
|
461 * @param aUids List of Uids that were selected for moving. |
|
462 */ |
|
463 void RenameAndMoveItemsL |
|
464 ( const CArrayFix<TInt>& aUids, TInt aFolder ); |
|
465 |
|
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 private: // from MWmlBrowserFavouritesModelObserver |
|
501 |
|
502 /** |
|
503 * Handle model change. |
|
504 */ |
|
505 void HandleFavouritesModelChangeL(); |
|
506 |
|
507 private: // from MCommsModelObserver |
|
508 |
|
509 /** |
|
510 * Handle Comms Model change (AP update). |
|
511 */ |
|
512 void HandleCommsModelChangeL(); |
|
513 |
|
514 private: // default item settings |
|
515 |
|
516 /** |
|
517 * Set Prefered the current item |
|
518 */ |
|
519 void SetPreferedCurrentItemL(); |
|
520 |
|
521 /** |
|
522 * Set Prefered the current item |
|
523 */ |
|
524 void SetUnPreferedCurrentItemL(); |
|
525 |
|
526 |
|
527 protected: // data |
|
528 |
|
529 /// Preferred highlight uid. |
|
530 TInt iPreferredHighlightUid; |
|
531 |
|
532 /// If ETrue, OK-Options menu is shown instead of normal Options menu. |
|
533 TBool iShowOkOptions; |
|
534 |
|
535 /// Top-level control of the view. Owned |
|
536 CBrowserFavouritesContainer* iContainer; |
|
537 |
|
538 /// Uid of the current folder. |
|
539 TInt iCurrentFolder; |
|
540 |
|
541 /// ETrue between DoActivateL() and DoDeactivate(). |
|
542 TBool iIsActivated; |
|
543 |
|
544 private: // data |
|
545 |
|
546 /// The model (data handling). Owned. |
|
547 CBrowserFavouritesModel* iModel; |
|
548 TInt iLastSelection; |
|
549 /// Incremental operation, or NULL if no such. Owned. |
|
550 CBrowserFavouritesIncrementalOp* iIncrementalOp; |
|
551 /// ETrue if data update is missed due to incremental operation. |
|
552 TBool iUpdatePending; |
|
553 |
|
554 protected: |
|
555 |
|
556 TBool iRefresh; // Flag to indicate that Bookmarks list should be refreshed. |
|
557 // ETrue by default, turned off only in cases we want to avoid |
|
558 // double refresh. Checked in HandleFavouritesModelChangeL. |
|
559 |
|
560 TInt iInitialFolder; //Folder to which browser is launched in embedded mode |
|
561 |
|
562 // Flag to indicate that we are about to open Preferences view, |
|
563 // in order not to return to root folder afterwards. |
|
564 TBool iSaveStateOnDeactivate; |
|
565 |
|
566 CBrowserFavouritesListboxState* iSavedListboxState; |
|
567 }; |
|
568 |
|
569 #include "BrowserFavouritesView.inl" |
|
570 |
|
571 #endif |
|
572 |
|
573 // End of file |