browserui/browser/FavouritesSrc/BrowserFavouritesView.cpp
changeset 51 48e827313edd
parent 37 481242ead638
child 53 f427d27b98d8
equal deleted inserted replaced
37:481242ead638 51:48e827313edd
     1 /*
       
     2 * Copyright (c) 2002-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 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 *      Implementation of CBrowserFavouritesView.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <aknsfld.h>
       
    23 #include <eikbtgpc.h>
       
    24 #include <eikmenub.h>
       
    25 #include <aknviewappui.h>
       
    26 #include <Avkon.hrh>
       
    27 #include <Uikon.hrh>
       
    28 #include <eikmenup.h>
       
    29 #include <AknForm.h>
       
    30 #include <AknQueryDialog.h>
       
    31 #include <BrowserNG.rsg>
       
    32 #include <avkon.rsg>
       
    33 #include <favouriteslimits.h>
       
    34 #include <favouritesdb.h>
       
    35 #include <favouritesitem.h>
       
    36 #include <favouritesitemlist.h>
       
    37 #include <internetconnectionmanager.h>
       
    38 #include <FeatMgr.h>
       
    39 #include <centralrepository.h>
       
    40 #include <nifman.h>
       
    41 
       
    42 #include "BrowserUiPrivateCRKeys.h"
       
    43 #include "BrowserUtil.h"
       
    44 #include "BrowserDialogs.h"
       
    45 #include "BrowserFavouritesView.h"
       
    46 #include "BrowserFavouritesFolderSelector.h"
       
    47 #include "BrowserFavouritesContainer.h"
       
    48 #include "BrowserFavouritesListbox.h"
       
    49 #include "BrowserFavouritesListboxState.h"
       
    50 #include "BrowserFavouritesModel.h"
       
    51 #include "Browser.hrh"
       
    52 #include "BrowserAppUi.h"
       
    53 #include "BrowserApplication.h"
       
    54 #include "BrowserFavouritesIncrementalDelete.h"
       
    55 #include "BrowserFavouritesIncrementalMove.h"
       
    56 #include "BrowserUIVariant.hrh"
       
    57 #include "BrowserWindowManager.h"
       
    58 #include "CommandVisibility.h"
       
    59 #include "CommonConstants.h"
       
    60 #include "CommsModel.h"
       
    61 #include "Display.h"
       
    62 #include "Preferences.h"
       
    63 #include "logger.h" 
       
    64 
       
    65 #include "eikon.hrh"
       
    66 
       
    67 
       
    68 // MACROS
       
    69 
       
    70 /**
       
    71 * Defining this macro shows "Unmark all", even if nothing is marked (except
       
    72 * if there are no items at all).
       
    73 */
       
    74 //#define SHOW_UNMARK_ALL_ALWAYS
       
    75 /**
       
    76 * Defining this macro shows "Mark all", even if all is marked (except
       
    77 * if there are no items at all).
       
    78 */
       
    79 //#define SHOW_MARK_ALL_ALWAYS
       
    80 
       
    81 /// Cosmetic purpose macro (resource names are overly too long).
       
    82 #define _R(str) R_BROWSER_FAVOURITES_ ## str
       
    83 
       
    84 // CONSTANTS
       
    85 /// Granularity of Uid lists used in managing multiple bookmarks.
       
    86 LOCAL_C const TInt KGranularityUids = 4;
       
    87 
       
    88 /// Estimated FFS overhead for deleting (in bytes).
       
    89 LOCAL_C const TInt KEstimatedDeleteFfsOverhead = 16 * 1024;
       
    90 
       
    91 // ==================== LOCAL FUNCTIONS ====================
       
    92 
       
    93 /**
       
    94 * Create a new empty list for Uids and push it on the cleanup stack.
       
    95 * @return The constructed empty list.
       
    96 */
       
    97 LOCAL_C CArrayFix<TInt>* NewUidListLC()
       
    98     {
       
    99     // Not inline - go for size, not speed.
       
   100     CArrayFixFlat<TInt>* list;
       
   101     list = new (ELeave) CArrayFixFlat<TInt> ( KGranularityUids );
       
   102     CleanupStack::PushL( list );
       
   103     return list;
       
   104     }
       
   105 
       
   106 // ================= MEMBER FUNCTIONS =======================
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CBrowserFavouritesView::~CBrowserFavouritesView
       
   110 // ---------------------------------------------------------
       
   111 //
       
   112 CBrowserFavouritesView::~CBrowserFavouritesView()
       
   113     {
       
   114     delete iIncrementalOp;
       
   115     delete iContainer;
       
   116     delete iModel;
       
   117     delete iSavedListboxState;
       
   118     }
       
   119 
       
   120 // ---------------------------------------------------------------------------
       
   121 // CBrowserFavouritesView::CommandSetResourceIdL
       
   122 // ---------------------------------------------------------------------------
       
   123 TInt CBrowserFavouritesView::CommandSetResourceIdL()
       
   124     {
       
   125     // for 5.0, BrowserBookmarksView takes over cba-assignment duties
       
   126     // this function should not be called. We now route though BrowserBookmarksView.
       
   127     return R_AVKON_SOFTKEYS_EMPTY;
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------
       
   131 // CBrowserFavouritesView::HandleCommandL
       
   132 // ---------------------------------------------------------
       
   133 //
       
   134 void CBrowserFavouritesView::HandleCommandL( TInt aCommand )
       
   135     {
       
   136     switch ( aCommand )
       
   137         {
       
   138         case EWmlCmdBackFromFolder:
       
   139             {
       
   140             if ( ApiProvider().IsEmbeddedModeOn() )
       
   141                 {
       
   142                 AppUi()->HandleCommandL( EWmlCmdCloseBrowser );
       
   143                 }
       
   144             else
       
   145                 {
       
   146                 CloseCurrentFolderL();
       
   147                 }
       
   148             break;
       
   149             }
       
   150 
       
   151         case EWmlCmdOpenFolder:
       
   152             {
       
   153             OpenCurrentFolderL();
       
   154             break;
       
   155             }
       
   156 
       
   157         case EWmlCmdOpenMarkedFolder:
       
   158             {
       
   159             OpenMarkedFolderL();
       
   160             break;
       
   161             }
       
   162 
       
   163         case EWmlCmdFavourites:
       
   164             {
       
   165             ApiProvider().SetViewToBeActivatedIfNeededL( KUidBrowserBookmarksViewId );
       
   166             break;
       
   167             }
       
   168 
       
   169         case EWmlCmdMark:
       
   170         case EWmlCmdUnmark:
       
   171         case EWmlCmdMarkAll:
       
   172         case EWmlCmdUnmarkAll:
       
   173             {
       
   174             iContainer->Listbox()->HandleMarkableListCommandL( aCommand );
       
   175             iContainer->HandleCursorChangedL( iContainer->Listbox() );
       
   176             UpdateCbaL();
       
   177             break;
       
   178             }
       
   179 
       
   180         case EWmlCmdDelete:
       
   181             {
       
   182             DeleteMarkedItemsL();
       
   183             break;
       
   184             }
       
   185 
       
   186         case EWmlCmdNewFolder:
       
   187             {
       
   188             (void)AddNewFolderL();
       
   189             break;
       
   190             }
       
   191 
       
   192         case EWmlCmdMoveToFolder:
       
   193             {
       
   194             MoveMarkedItemsL();
       
   195             break;
       
   196             }
       
   197 
       
   198 
       
   199         case EWmlCmdRename:
       
   200             {
       
   201             RenameCurrentItemL();
       
   202             break;
       
   203             }
       
   204 
       
   205         case EWmlCmdSetPreferredBookmark:
       
   206             {
       
   207             SetPreferedCurrentItemL();
       
   208             break;
       
   209             }
       
   210 
       
   211         case EWmlCmdSetUnPreferredBookmark:
       
   212             {
       
   213             SetUnPreferedCurrentItemL();
       
   214             break;
       
   215             }
       
   216 
       
   217         case EWmlCmdPreferences:
       
   218             {
       
   219             iSaveStateOnDeactivate = ETrue;
       
   220             AppUi()->HandleCommandL( aCommand );
       
   221             break;
       
   222             }
       
   223         default :
       
   224             {
       
   225             AppUi()->HandleCommandL( aCommand );
       
   226             break;
       
   227             }
       
   228         }
       
   229     }
       
   230 
       
   231 // ----------------------------------------------------------------------------
       
   232 // CBrowserFavouritesView::CBrowserFavouritesView
       
   233 // ----------------------------------------------------------------------------
       
   234 //
       
   235 CBrowserFavouritesView::CBrowserFavouritesView( MApiProvider& aApiProvider,
       
   236                                                 TInt aInitialFolderId )
       
   237         : CBrowserViewBase( aApiProvider ),
       
   238           iPreferredHighlightUid( KFavouritesNullUid ),
       
   239           iShowOkOptions( EFalse ),
       
   240           iCurrentFolder( aInitialFolderId ),
       
   241           iIsActivated( EFalse ),
       
   242           iLastSelection( 0 ),
       
   243           iUpdatePending( EFalse ),
       
   244           iRefresh( ETrue )
       
   245     {
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------
       
   249 // CBrowserFavouritesView::ConstructL
       
   250 // ---------------------------------------------------------
       
   251 //
       
   252 void CBrowserFavouritesView::ConstructL( TInt aViewResourceId )
       
   253     {
       
   254     BaseConstructL( aViewResourceId );
       
   255     iModel = CreateModelL();
       
   256     iInitialFolder = iCurrentFolder;
       
   257     // Ap model cannot be created without opening it; so that's not done here.
       
   258     // DoActivateL / DoDecativateL does that.
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------
       
   262 // CBrowserFavouritesView::GetItemsLC
       
   263 // ---------------------------------------------------------
       
   264 //
       
   265 CFavouritesItemList* CBrowserFavouritesView::GetItemsLC( TInt aFolder )
       
   266     {
       
   267     CFavouritesItemList* items = new (ELeave) CFavouritesItemList();
       
   268     CleanupStack::PushL( items );
       
   269     iModel->Database().GetAll( *items, aFolder );
       
   270     iModel->SortL( *items );
       
   271     return items;
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------
       
   275 // CBrowserFavouritesView::GetSeamlessFolderResourceID
       
   276 // ---------------------------------------------------------
       
   277 //
       
   278 TInt CBrowserFavouritesView::GetSeamlessFolderResourceID( TInt aContextID )
       
   279     {
       
   280     TInt resId = 0;
       
   281 
       
   282     switch( aContextID ) // Check if the item is a seamless link folder
       
   283         {
       
   284         case KFavouritesApplicationContextId:
       
   285                {
       
   286             resId = R_BROWSERBM_FOLDER_DOWNLOAD_APPLICATIONS;
       
   287             break;
       
   288             }
       
   289         case KFavouritesImageContextId:
       
   290         {
       
   291             resId = R_BROWSERBM_FOLDER_DOWNLOAD_IMAGES;
       
   292             break;
       
   293             }
       
   294         case KFavouritesAudioContextId:
       
   295             {
       
   296             resId = R_BROWSERBM_FOLDER_DOWNLOAD_TONES;
       
   297             break;
       
   298             }
       
   299         case KFavouritesVideoContextId:
       
   300             {
       
   301             resId = R_BROWSERBM_FOLDER_DOWNLOAD_VIDEOS;
       
   302             break;
       
   303             }
       
   304         case KFavouritesSkinContextId:
       
   305             {
       
   306             resId = R_BROWSERBM_FOLDER_DOWNLOAD_SKINS;
       
   307             break;
       
   308             }
       
   309         case KFavouritesMusicContextId:
       
   310             {
       
   311             resId = R_BROWSERBM_FOLDER_DOWNLOAD_MUSIC;
       
   312             break;
       
   313             }
       
   314         case KFavouritesServiceContextId:
       
   315             {
       
   316             resId = R_IS_RECOMMENDATIONS;
       
   317             break;
       
   318             }
       
   319         default:
       
   320             {
       
   321             break; // not a seamless link folder.
       
   322             }
       
   323         }
       
   324 
       
   325         return resId;
       
   326     }
       
   327 
       
   328 
       
   329 // ---------------------------------------------------------
       
   330 // CBrowserFavouritesView::GetSeamlessFolderTitleResourceID
       
   331 // ---------------------------------------------------------
       
   332 //
       
   333 TInt CBrowserFavouritesView::GetSeamlessFolderTitleResourceID( TInt aContextID )
       
   334     {
       
   335     TInt resId = 0;
       
   336 
       
   337     switch( aContextID ) // Check if the item is a seamless link folder
       
   338         {
       
   339         case KFavouritesApplicationContextId:
       
   340                {
       
   341             resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_APPLICATIONS;
       
   342             break;
       
   343             }
       
   344         case KFavouritesImageContextId:
       
   345         {
       
   346             resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_IMAGES;
       
   347             break;
       
   348             }
       
   349         case KFavouritesAudioContextId:
       
   350             {
       
   351             resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_TONES;
       
   352             break;
       
   353             }
       
   354         case KFavouritesVideoContextId:
       
   355             {
       
   356             resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_VIDEOS;
       
   357             break;
       
   358             }
       
   359         case KFavouritesSkinContextId:
       
   360             {
       
   361             resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_SKINS;
       
   362             break;
       
   363             }
       
   364         case KFavouritesMusicContextId:
       
   365             {
       
   366             resId = R_BROWSERBM_FOLDER_TITLE_DOWNLOAD_MUSIC;
       
   367             break;
       
   368             }
       
   369         default:
       
   370             {
       
   371             break; // not a seamless link folder.
       
   372             }
       
   373         }
       
   374 
       
   375         return resId;
       
   376       }
       
   377 
       
   378 
       
   379 // ---------------------------------------------------------
       
   380 // CBrowserFavouritesView::IsSeamlessFolder
       
   381 // ---------------------------------------------------------
       
   382 //
       
   383 TInt CBrowserFavouritesView::IsSeamlessFolder( TInt aContextID )
       
   384      {
       
   385      return GetSeamlessFolderResourceID( aContextID ) != 0 ? ETrue : EFalse;
       
   386      }
       
   387 
       
   388 // ---------------------------------------------------------
       
   389 // CBrowserFavouritesView::HighlightPreferredL
       
   390 // ---------------------------------------------------------
       
   391 //
       
   392 void CBrowserFavouritesView::HighlightPreferredL()
       
   393     {
       
   394     if (( iContainer->Listbox()->HighlightUidNow( iPreferredHighlightUid ) ) &&
       
   395         ( iPreferredHighlightUid != KFavouritesNullUid ))
       
   396         {
       
   397         // Have a preferred uid...
       
   398         // Successfully highlighted; clear preferred now.
       
   399         iPreferredHighlightUid = KFavouritesNullUid;
       
   400         iContainer->HandleCursorChangedL( iContainer->Listbox() );
       
   401         }
       
   402     }
       
   403 
       
   404 // ---------------------------------------------------------
       
   405 // CBrowserFavouritesView::RefreshL
       
   406 // ---------------------------------------------------------
       
   407 //
       
   408 void CBrowserFavouritesView::RefreshL( TBool aDbErrorNote /*=EFalse*/ )
       
   409     {
       
   410     // Do the refresh only if activated; otherwise ignore.
       
   411     // (This is a sanity-check like functionality, but is really used.
       
   412     // Bookmarks View observes changes in active and default AP-s, even if
       
   413     // not activated (and tries to refresh); but this "activated-check" is
       
   414     // made here, not in Bookmarks View, because it makes things more safe and
       
   415     // "future-proof".)
       
   416     if ( iIsActivated )
       
   417         {
       
   418         iUpdatePending = ETrue;
       
   419         if ( !iIncrementalOp )
       
   420             {
       
   421             // During an incremental operation we should never do the update
       
   422             // and refill the listbox because some of the operations holds
       
   423             // pointers to listbox items. Update is pending then.
       
   424             if ( iModel->BeginL( /*aWrite=*/EFalse, aDbErrorNote ) ==
       
   425                     KErrNone )
       
   426                 {
       
   427                 TInt folderExists;
       
   428                 iModel->Database().FolderExists( iCurrentFolder, folderExists );
       
   429                 if ( folderExists )
       
   430                     {
       
   431                     // Current folder is still OK. Refresh.
       
   432                     FillListboxL( iCurrentFolder, /*aKeepState=*/ETrue );
       
   433                     }
       
   434                 else
       
   435                     {
       
   436                     // Cannot access current folder (maybe deleted).
       
   437                     // Go to root.
       
   438                     OpenFolderL( KFavouritesRootUid );
       
   439                     }
       
   440                 iModel->CommitL();
       
   441                 iUpdatePending = EFalse;
       
   442                 }
       
   443             // iUpdatePending stays ETrue if unsuccessful.
       
   444             }
       
   445         }
       
   446     }
       
   447 
       
   448 // ---------------------------------------------------------
       
   449 // CBrowserFavouritesView::DoActivateL
       
   450 // ---------------------------------------------------------
       
   451 //
       
   452 void CBrowserFavouritesView::DoActivateL(
       
   453                         const TVwsViewId& /*aPrevViewId*/,
       
   454                         TUid /*aCustomMessageId*/,
       
   455                         const TDesC8& /*aCustomMessage*/ )
       
   456     {
       
   457     iPreviousViewID = ApiProvider().LastActiveViewId( );
       
   458     ApiProvider().SetLastActiveViewId( Id() );
       
   459     ApiProvider().CommsModel().AddObserverL( *this );
       
   460     iContainer = CreateContainerL();
       
   461     iModel->AddObserverL( *this );
       
   462     AppUi()->AddToViewStackL( *this, iContainer );
       
   463 
       
   464     ApiProvider().StartProgressAnimationL();
       
   465 
       
   466     if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
       
   467                                                                 == KErrNone )
       
   468         {
       
   469         // Disable redraw to avoid flickering.
       
   470         // (OpenFolderL and the listbox's SetStateL both
       
   471         // wants to redraw the listbox. Do it once only.)
       
   472         TBool redrawDisabled =
       
   473             iContainer->Listbox()->View()->RedrawDisabled();
       
   474         iContainer->Listbox()->View()->SetDisableRedraw( ETrue );
       
   475         // Open folder first.
       
   476         OpenFolderL( iCurrentFolder );
       
   477         iModel->CommitL();
       
   478 
       
   479         // Now set back redraw and draw the listbox.
       
   480         if ( (iLastSelection >=0 ))
       
   481             {
       
   482             if ( iLastSelection > iContainer->Listbox()->BottomItemIndex() )
       
   483                 {
       
   484                 iLastSelection = 0;
       
   485                 }
       
   486             iContainer->Listbox()->SetCurrentItemIndex( iLastSelection );
       
   487             }
       
   488 
       
   489         iContainer->Listbox()->View()->SetDisableRedraw( redrawDisabled );
       
   490         iContainer->Listbox()->DrawNow();
       
   491         }
       
   492     else
       
   493         {
       
   494         // No folder is opened; update CBA and Navi Pane now.
       
   495         if ( iLastSelection >=0 )
       
   496             {
       
   497             iContainer->Listbox()->SetCurrentItemIndex( iLastSelection );
       
   498             UpdateGotoPaneL();
       
   499             }
       
   500         UpdateCbaL();
       
   501         UpdateNaviPaneL();
       
   502         }
       
   503 
       
   504     if (iSavedListboxState)
       
   505         {
       
   506         iContainer->Listbox()->SetStateL(*iSavedListboxState);
       
   507         }
       
   508     iIsActivated = ETrue;
       
   509     }
       
   510 
       
   511 // ----------------------------------------------------------------------------
       
   512 // CBrowserFavouritesView::ResetStateInDeActivation
       
   513 // ----------------------------------------------------------------------------
       
   514 //
       
   515 void CBrowserFavouritesView::ResetStateInDeActivation()
       
   516     {
       
   517     //Set iLastSelection to zero if there will be a folder change
       
   518     if ( iCurrentFolder != iInitialFolder )
       
   519         {
       
   520         iLastSelection = 0;
       
   521         }
       
   522     }
       
   523 
       
   524 // ---------------------------------------------------------
       
   525 // CBrowserFavouritesView::DoDeactivate
       
   526 // ---------------------------------------------------------
       
   527 //
       
   528 void CBrowserFavouritesView::DoDeactivate()
       
   529     {
       
   530     iIsActivated = EFalse;
       
   531     TRAP_IGNORE(ApiProvider().StopProgressAnimationL());
       
   532     if ( iContainer )
       
   533         {
       
   534         iLastSelection = iContainer->Listbox()->CurrentItemIndex();
       
   535         }
       
   536 
       
   537     if ( !iSaveStateOnDeactivate )
       
   538         {
       
   539         ResetStateInDeActivation();  // entering root directory
       
   540         iSaveStateOnDeactivate = EFalse;
       
   541         }
       
   542     else
       
   543         {
       
   544         CBrowserFavouritesListboxState *temp = NULL;
       
   545         TInt err( KErrNone );
       
   546         TInt tempUid( KFavouritesNullUid );
       
   547 
       
   548         temp = new CBrowserFavouritesListboxState;
       
   549         if ( temp!=NULL )
       
   550             {
       
   551             delete iSavedListboxState;
       
   552             iSavedListboxState = temp;
       
   553             // folder might be empty, no CurrentItem at all
       
   554             if ( iContainer->Listbox()->CurrentItem() )
       
   555                 {
       
   556                 tempUid = iContainer->Listbox()->CurrentItem()->Uid();
       
   557                 }
       
   558             iSavedListboxState->iHighlightUid = tempUid;
       
   559             TRAP( err, {
       
   560                 iSavedListboxState->iMarkUids = iContainer->Listbox()->MarkedUidsLC();
       
   561                 CleanupStack::Pop();    // Uid list; ownership is now in the state.
       
   562                 } )
       
   563             }
       
   564         if ( !err )
       
   565             {
       
   566             iSavedListboxState->iTopItemUid = tempUid;
       
   567             }
       
   568         else
       
   569             {
       
   570             delete iSavedListboxState;
       
   571             }
       
   572         }
       
   573 
       
   574     if ( !ApiProvider().ExitInProgress() )
       
   575         {
       
   576         ApiProvider().CommsModel().RemoveObserver( *this );
       
   577         }
       
   578     iModel->RemoveObserver( *this );
       
   579 
       
   580     if ( iContainer )
       
   581         {
       
   582         AppUi()->RemoveFromViewStack( *this, iContainer );
       
   583         delete iContainer;
       
   584         iContainer = NULL;
       
   585         }
       
   586     iModel->CloseDb();
       
   587     }
       
   588 
       
   589 // ---------------------------------------------------------
       
   590 // CBrowserFavouritesView::HandleClientRectChange
       
   591 // ---------------------------------------------------------
       
   592 //
       
   593 void CBrowserFavouritesView::HandleClientRectChange()
       
   594     {
       
   595     if ( iContainer )
       
   596         {
       
   597         iContainer->SetRect( ClientRect() );
       
   598         }
       
   599     }
       
   600 
       
   601 // ---------------------------------------------------------
       
   602 // CBrowserFavouritesView::DynInitMenuPaneL
       
   603 // ---------------------------------------------------------
       
   604 //
       
   605 void CBrowserFavouritesView::DynInitMenuPaneL
       
   606 ( TInt aResourceId, CEikMenuPane* aMenuPane )
       
   607     {
       
   608     if ( iContainer && iContainer->Listbox() )
       
   609         {
       
   610         TBrowserFavouritesSelectionState state =
       
   611             iContainer->Listbox()->SelectionStateL();
       
   612         TCommandVisibility::TIndex index =
       
   613             TCommandVisibility::Index( state, iShowOkOptions );
       
   614         DynInitMenuPaneL( aResourceId, aMenuPane, index, state );
       
   615         }
       
   616     }
       
   617 
       
   618 // ---------------------------------------------------------
       
   619 // CBrowserFavouritesView::HandleForegroundEventL
       
   620 // ---------------------------------------------------------
       
   621 //
       
   622 void CBrowserFavouritesView::HandleForegroundEventL( TBool aForeground )
       
   623     {
       
   624     // If another thread made changes to database, sometimes we could not
       
   625     // refresh when the notifcation comes in (most likely the other thread
       
   626     // closes the database and that performs an automatic compact(?)).
       
   627     // When coming foreground, check for missed updates.
       
   628     // Also, when coming to foreground Refresh if Skin has changed
       
   629     if ( aForeground && (iUpdatePending || iContainer->Listbox()->IsSkinUpdated()))
       
   630         {
       
   631         RefreshL();
       
   632         if (iContainer->Listbox()->IsSkinUpdated())
       
   633             {
       
   634             iContainer->Listbox()->SetSkinUpdated(EFalse);
       
   635             }
       
   636         }
       
   637     }
       
   638 
       
   639 // ---------------------------------------------------------
       
   640 // CBrowserFavouritesView::HandleListBoxEventL
       
   641 // ---------------------------------------------------------
       
   642 //
       
   643 void CBrowserFavouritesView::HandleListBoxEventL
       
   644 ( CEikListBox* aListBox, MEikListBoxObserver::TListBoxEvent aEventType )
       
   645     {
       
   646     if ( aListBox == iContainer->Listbox() )
       
   647         {
       
   648         switch ( aEventType )
       
   649             {
       
   650             case MEikListBoxObserver::EEventEnterKeyPressed:
       
   651             case MEikListBoxObserver::EEventItemDoubleClicked:
       
   652 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF                
       
   653             case MEikListBoxObserver::EEventItemSingleClicked:    
       
   654 #endif                
       
   655                 {
       
   656                 if ( iContainer->Listbox()->CurrentItem() )
       
   657                     {
       
   658                     if ( iContainer->Listbox()->CurrentItem()->IsFolder() )
       
   659                         {
       
   660                         OpenCurrentFolderL();
       
   661                         }
       
   662                     }
       
   663                 break;
       
   664                 }
       
   665 
       
   666             default:
       
   667                 {
       
   668                 break;
       
   669                 }
       
   670             }
       
   671         }
       
   672     }
       
   673 
       
   674 // ---------------------------------------------------------
       
   675 // CBrowserFavouritesView::CloseCurrentFolderL
       
   676 // ---------------------------------------------------------
       
   677 //
       
   678 void CBrowserFavouritesView::CloseCurrentFolderL()
       
   679     {
       
   680     if ( iCurrentFolder != KFavouritesRootUid )
       
   681         {
       
   682         // Folders are one level deep. Closing any folder takes us to root.
       
   683         if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
       
   684                                                                 == KErrNone )
       
   685             {
       
   686             if ( iContainer && iContainer->Listbox() )
       
   687                 {
       
   688                 // After closing, the highlight should be
       
   689                 // on the folder just being closed.
       
   690                 iPreferredHighlightUid = iCurrentFolder;
       
   691                 OpenFolderL( KFavouritesRootUid );
       
   692                 }
       
   693             iModel->CommitL();
       
   694             }
       
   695         }
       
   696     }
       
   697 
       
   698 // ---------------------------------------------------------
       
   699 // CBrowserFavouritesView::OpenCurrentFolderL
       
   700 // ---------------------------------------------------------
       
   701 //
       
   702 void CBrowserFavouritesView::OpenCurrentFolderL()
       
   703     {
       
   704     if ( iContainer && iContainer->Listbox() )
       
   705         {
       
   706         const CFavouritesItem* folder =
       
   707             iContainer->Listbox()->CurrentItem();
       
   708         if ( folder && folder->IsFolder() )
       
   709             {
       
   710             if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
       
   711                                                                 == KErrNone )
       
   712                 {
       
   713                 OpenFolderL( folder->Uid() );
       
   714                 iModel->CommitL();
       
   715                 }
       
   716             }
       
   717         }
       
   718     }
       
   719 
       
   720 // ---------------------------------------------------------
       
   721 // CBrowserFavouritesView::OpenMarkedFolderL
       
   722 // ---------------------------------------------------------
       
   723 //
       
   724 void CBrowserFavouritesView::OpenMarkedFolderL()
       
   725     {
       
   726     if ( iContainer && iContainer->Listbox() )
       
   727         {
       
   728         const CFavouritesItem* folder =
       
   729             iContainer->Listbox()->MarkedItemL();
       
   730         if ( folder && folder->IsFolder() )
       
   731             {
       
   732             if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
       
   733                                                                 == KErrNone )
       
   734                 {
       
   735                 OpenFolderL( folder->Uid() );
       
   736                 iModel->CommitL();
       
   737                 }
       
   738             }
       
   739         }
       
   740     }
       
   741 
       
   742 // ---------------------------------------------------------
       
   743 // CBrowserFavouritesView::DeleteMarkedItemsL
       
   744 // ---------------------------------------------------------
       
   745 //
       
   746 void CBrowserFavouritesView::DeleteMarkedItemsL()
       
   747     {
       
   748     CArrayPtr<const CFavouritesItem>* items =
       
   749         iContainer->Listbox()->SelectedItemsLC();
       
   750     // Permormance optimization: keep a separate list for folders.
       
   751     // (Make the "non-empty folder" check only for folders; this speeds up
       
   752     // things considerably when many items are selected.)
       
   753     CArrayFix<TInt>* uids = NewUidListLC();
       
   754     CArrayFix<TInt>* folderUids = NewUidListLC();
       
   755     TInt i;
       
   756     TInt count = items->Count();
       
   757     const CFavouritesItem* item = NULL;
       
   758 
       
   759     for ( i = 0; i < count; i++ )
       
   760         {
       
   761         item = items->At( i );
       
   762         uids->AppendL( item->Uid() );
       
   763         if ( item->IsFolder() )
       
   764             {
       
   765             folderUids->AppendL( item->Uid() );
       
   766             }
       
   767         }
       
   768     // Cannot delete the "items" pointer list, as other objects were pushed
       
   769     // after it. But DO NOT USE it after this point! The call to ConfirmDeleteL
       
   770     // allows other active objects to run, and the listbox may be updated.
       
   771     // If listbox is updated, all pointers in "items" point to deleted objects.
       
   772 
       
   773     if ( ConfirmDeleteL( *uids, *folderUids ) )
       
   774         {
       
   775 
       
   776         if (count ==1)
       
   777             {
       
   778             CFavouritesItemList* allItems = GetItemsLC( KFavouritesRootUid );
       
   779             item = items->At(0);
       
   780             iPreferredHighlightUid = item->Uid();
       
   781             TInt index = allItems->UidToIndex(iPreferredHighlightUid);
       
   782             index++;
       
   783             if (allItems->IndexToUid(index) != NULL)
       
   784                 {
       
   785                 iPreferredHighlightUid = allItems->IndexToUid(index);
       
   786                 }
       
   787             else
       
   788                 {
       
   789                 iPreferredHighlightUid = allItems->IndexToUid(index-2);
       
   790                 }
       
   791             CleanupStack::PopAndDestroy(); //allItems
       
   792             }
       
   793 
       
   794 
       
   795         CArrayFix<TInt>* notDeletedUids = NewUidListLC();
       
   796 
       
   797         // OOD handling. If disk space is low, we try to get some spare.
       
   798 
       
   799         CRepository* repository = CRepository::NewL( KCRUidBrowser );
       
   800 
       
   801         TBool diskLow = Util::FFSSpaceBelowCriticalLevelL
       
   802                 ( /*aShowErrorNote=*/EFalse, KEstimatedDeleteFfsOverhead );
       
   803         if ( diskLow )
       
   804             {
       
   805             // Using disk space requests is not supported by CenRep.
       
   806             delete repository;
       
   807             }
       
   808 
       
   809         if ( !iModel->BeginL
       
   810                 (
       
   811                 /*aWrite=*/ETrue,
       
   812                 /*aDbErrorNote=*/ETrue,
       
   813                 /*aLffsCheck=*/EFalse
       
   814                 )
       
   815             )
       
   816             {
       
   817             __ASSERT_DEBUG( !iIncrementalOp, Util::Panic
       
   818                 ( Util::EIncrementalOperationAlreadyRunning ) );
       
   819             // Seems we have to give lower priority to the delete operation,
       
   820             // or else the wait note does not show up.
       
   821             iIncrementalOp = CBrowserFavouritesIncrementalDelete::NewL
       
   822                 (
       
   823                 *iModel,
       
   824                 *uids,
       
   825                 *notDeletedUids,
       
   826                 CActive::EPriorityStandard - 1
       
   827                 );
       
   828             iIncrementalOp->ExecuteL();
       
   829             delete iIncrementalOp;
       
   830             iIncrementalOp = NULL;
       
   831             iModel->CommitL();
       
   832 
       
   833             if ( diskLow )
       
   834                 {
       
   835                 // Compact database now.
       
   836                 iModel->Database().Compact();
       
   837                 // Make a manual refresh. When we get notification about the
       
   838                 // commit, database is most likely busy with compact, and
       
   839                 // the refresh is missed.
       
   840                 RefreshL();
       
   841                 }
       
   842 
       
   843             // Everything that can be deleted, is deleted by now.
       
   844             // Let the user know the outcome.
       
   845             DisplayResultOfDeleteL( *uids, *notDeletedUids );
       
   846             // Refresh the view only in embedded mode because in standalone mode Refresh is called by
       
   847             // HandleFavouritesModelChangeL causing the view to refresh twice and lose the cursor position
       
   848             if ( ApiProvider().IsEmbeddedModeOn() )
       
   849                 {
       
   850                 RefreshL();
       
   851                 }
       
   852             }
       
   853 
       
   854         for ( TInt ii = 0; ii< uids->Count(); ii++ )
       
   855             {
       
   856             TInt prefUid;
       
   857             iModel->Database().PreferredUid( iCurrentFolder, prefUid );
       
   858             if ( prefUid  == uids->At( ii ) )
       
   859                 {
       
   860                 iModel->Database().SetPreferredUid( iCurrentFolder,NULL );
       
   861                 break;
       
   862                 }
       
   863             }
       
   864 
       
   865         CleanupStack::PopAndDestroy();  // notDeletedUids
       
   866         }
       
   867     CleanupStack::PopAndDestroy( 3 );   // folderUids, uids, items
       
   868     }
       
   869 
       
   870 // ---------------------------------------------------------
       
   871 // CBrowserFavouritesView::AddNewFolderL
       
   872 // ---------------------------------------------------------
       
   873 //
       
   874 TInt CBrowserFavouritesView::AddNewFolderL()
       
   875     {
       
   876     TInt uid = KFavouritesNullUid;
       
   877     // Make an item and fill it with default values.
       
   878     CFavouritesItem* folder = CFavouritesItem::NewLC();
       
   879     folder->SetType( CFavouritesItem::EFolder );
       
   880     folder->SetParentFolder( KFavouritesRootUid );
       
   881     iModel->SetNameToDefaultL( *folder );
       
   882     TInt err = iModel->MakeUniqueNameL( *folder );
       
   883     if ( !err )
       
   884         {
       
   885         // We have the folder with a default unique name.
       
   886         // Let the user rename it.
       
   887         if ( iModel->RenameQueryL( *folder, ETrue ))
       
   888             {
       
   889             // Rename accepted.
       
   890             err = iModel->AddL( *folder, /*aDbErrorNote=*/ETrue,
       
   891                 CBrowserFavouritesModel::EAskIfRename );
       
   892             if ( !err )
       
   893                 {
       
   894                 // Succesfully created. Set highlight to new folder (by setting
       
   895                 // preferred highlight uid - we have not see the new folder
       
   896                 // yet, until db notification kicks in.
       
   897                 uid = iPreferredHighlightUid = folder->Uid();
       
   898                 }
       
   899             }
       
   900         }
       
   901     CleanupStack::PopAndDestroy();  // folder
       
   902     return uid;
       
   903     }
       
   904 
       
   905 // ---------------------------------------------------------
       
   906 // CBrowserFavouritesView::MoveMarkedItemsL
       
   907 // ---------------------------------------------------------
       
   908 //
       
   909 void CBrowserFavouritesView::MoveMarkedItemsL()
       
   910     {
       
   911     TInt targetFolder = SelectTargetFolderL( iCurrentFolder );
       
   912 
       
   913     // If we have the target folder, do the move.
       
   914     if ( targetFolder != KFavouritesNullUid )
       
   915         {
       
   916         CArrayFix<TInt>* uids = iContainer->Listbox()->SelectedUidsLC();
       
   917         CArrayFix<TInt>* unmovableUids = NewUidListLC();
       
   918         CArrayFix<TInt>* conflictingNameUids = NewUidListLC();
       
   919         if ( !iModel->BeginL( /*aWrite=*/ETrue, /*aDbErrorNote=*/ETrue ) )
       
   920             {
       
   921             __ASSERT_DEBUG( !iIncrementalOp, Util::Panic
       
   922                 ( Util::EIncrementalOperationAlreadyRunning ) );
       
   923             // Seems we have to give lower priority to the move operation,
       
   924             // or else the wait note does not show up.
       
   925             iIncrementalOp = CBrowserFavouritesIncrementalMove::NewL
       
   926                 (
       
   927                 *iModel,
       
   928                 *uids,
       
   929                 *unmovableUids,
       
   930                 *conflictingNameUids,
       
   931                 targetFolder,
       
   932                 CActive::EPriorityStandard - 1
       
   933                 );
       
   934             iIncrementalOp->ExecuteL();
       
   935             delete iIncrementalOp;
       
   936             iIncrementalOp = NULL;
       
   937             iModel->CommitL();
       
   938             // Everything that can be moved, is moved by now.
       
   939             // If some items could not be moved, see why.
       
   940             HandleMoveResultL
       
   941                 ( targetFolder, *uids, *unmovableUids, *conflictingNameUids );
       
   942 
       
   943             for ( TInt ii = 0; ii< uids->Count(); ii++ )
       
   944                 {
       
   945                 TInt prefUid;
       
   946                 iModel->Database().PreferredUid( iCurrentFolder, prefUid );
       
   947                 if ( prefUid  == uids->At( ii ) )
       
   948                     {
       
   949                     iModel->Database().SetPreferredUid( iCurrentFolder,NULL );
       
   950                     break;
       
   951                     }
       
   952                 }
       
   953 
       
   954             CBrowserBookmarksOrder* bmOrder  = CBrowserBookmarksOrder::NewLC();
       
   955             CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>(KGranularityHigh);
       
   956             CleanupStack::PushL( orderArray );
       
   957             if ( Model().Database().GetData( CurrentFolder() ,*bmOrder ) == KErrNone)
       
   958                 {
       
   959                 if ( bmOrder->GetBookMarksOrder().Count() )
       
   960                     {
       
   961                     orderArray->AppendL( &( bmOrder->GetBookMarksOrder()[0] ), bmOrder->GetBookMarksOrder().Count());
       
   962                     TInt swapTo = 0;
       
   963                     TInt swappedItem;
       
   964                     for ( TInt i=0; i<orderArray->Count();i++ )
       
   965                         {
       
   966                         TInt swapFrom=0;
       
   967                         while (swapFrom<uids->Count() && ( (*uids)[swapFrom] != ( *orderArray )[i]) )
       
   968                             {
       
   969                             swapFrom++;
       
   970                             }
       
   971                         if (swapFrom<uids->Count())
       
   972                             {
       
   973                             if ((swapFrom != swapTo) && (swapTo < uids->Count() ) )
       
   974                                 {
       
   975                                 swappedItem = ( *uids )[swapFrom];
       
   976                                 ( *uids )[swapFrom] = ( *uids )[swapTo];
       
   977                                 ( *uids )[swapTo] = swappedItem;
       
   978                                 }
       
   979                             swapTo++;
       
   980                             }
       
   981                         }
       
   982                     }
       
   983                 }
       
   984 
       
   985             orderArray->Reset();
       
   986             if ( Model().Database().GetData( targetFolder ,*bmOrder ) == KErrNone)
       
   987                 {
       
   988                 if ( bmOrder->GetBookMarksOrder().Count() )
       
   989                     {
       
   990                     orderArray->AppendL( &( bmOrder->GetBookMarksOrder()[0] ), bmOrder->GetBookMarksOrder().Count());
       
   991                     if ( orderArray->Count() )
       
   992                         {
       
   993                         for ( TInt i = 0; i < uids->Count(); i++ )
       
   994                             {
       
   995                             for (TInt j = 0; j < orderArray->Count(); j++ )
       
   996                                 {
       
   997                                 if ( orderArray->At( j ) == uids->At( i ))
       
   998                                     {
       
   999                                     orderArray->Delete( j );
       
  1000                                     }
       
  1001                                 }
       
  1002                              Model().AddUidToLastPlaceL(uids->At( i ), orderArray, bmOrder);
       
  1003                              }
       
  1004                         bmOrder->SetBookMarksOrderL( *orderArray );
       
  1005                         Model().Database().SetData( targetFolder , *bmOrder );
       
  1006                         }
       
  1007                     }
       
  1008                 }
       
  1009 
       
  1010             CleanupStack::PopAndDestroy(  ); //orderArray
       
  1011             CleanupStack::PopAndDestroy(  ); //bmOrder
       
  1012             }
       
  1013         CleanupStack::PopAndDestroy( 3 );   // conflictingNameUids,
       
  1014                                             // unmovableUids, uids
       
  1015         }
       
  1016     }
       
  1017 
       
  1018 // ---------------------------------------------------------
       
  1019 // CBrowserFavouritesView::RenameCurrentItemL
       
  1020 // ---------------------------------------------------------
       
  1021 //
       
  1022 void CBrowserFavouritesView::RenameCurrentItemL()
       
  1023     {
       
  1024     if ( iContainer && iContainer->Listbox() )
       
  1025         {
       
  1026         const CFavouritesItem* listboxItem =
       
  1027             iContainer->Listbox()->CurrentItem();
       
  1028         if ( listboxItem )
       
  1029             {
       
  1030             CFavouritesItem* item = CFavouritesItem::NewLC();
       
  1031             *item = *listboxItem;
       
  1032             if ( iModel->RenameQueryL( *item, EFalse ) )
       
  1033                 {
       
  1034                 iModel->UpdateL
       
  1035                     (
       
  1036                     *item,
       
  1037                     listboxItem->Uid(),
       
  1038                     /*aDbErrorNote=*/ETrue,
       
  1039                     CBrowserFavouritesModel::EAskIfRename
       
  1040                     );
       
  1041 
       
  1042                 iPreferredHighlightUid = item->Uid();
       
  1043 
       
  1044                 // Show infonote "Unable to rename" if read-only item
       
  1045                 if ( listboxItem->IsReadOnly() )
       
  1046                     {
       
  1047                     TBrowserDialogs::InfoNoteL
       
  1048                                                 (
       
  1049                                                 R_BROWSER_INFO_NOTE,
       
  1050                                                 _R(TEXT_PRMPT_CANT_RENAME),
       
  1051                                                 listboxItem->Name()
       
  1052                                                 );
       
  1053                     }
       
  1054                 }
       
  1055             CleanupStack::PopAndDestroy();  // item
       
  1056             }
       
  1057         }
       
  1058     }
       
  1059 
       
  1060 // ---------------------------------------------------------
       
  1061 // CBrowserFavouritesView::SetRootFolderForAdaptiveBookmarks
       
  1062 // ---------------------------------------------------------
       
  1063 //
       
  1064 void CBrowserFavouritesView::SetRootFolderForAdaptiveBookmarks()
       
  1065     {
       
  1066     iCurrentFolder = KFavouritesRootUid;
       
  1067     }
       
  1068 
       
  1069 // ---------------------------------------------------------
       
  1070 // CBrowserFavouritesView::OpenFolderL
       
  1071 // ---------------------------------------------------------
       
  1072 //
       
  1073 void CBrowserFavouritesView::OpenFolderL( TInt aFolder )
       
  1074     {
       
  1075 
       
  1076     CFavouritesItem* folder = CFavouritesItem::NewLC();
       
  1077     if ( iModel->Database().Get( aFolder, *folder ) == KErrNone )
       
  1078         {
       
  1079         iContainer->Listbox()->GetDefaultData().iPreferedId = NULL;
       
  1080         iContainer->Listbox()->GetDefaultData().iInSeamlessFolder = EFalse;
       
  1081         // Set title.
       
  1082         if ( aFolder == KFavouritesRootUid )
       
  1083             {
       
  1084             UpdateNaviPaneL(); // remove NaviPane before setting title - SetTitleL redraws
       
  1085             ApiProvider().Display().SetTitleL( RootTitleResourceId() );
       
  1086             }
       
  1087         else
       
  1088             {
       
  1089             // Next get localized title text if the folder is a seamless link folder.
       
  1090             TInt resId = CBrowserFavouritesView::GetSeamlessFolderTitleResourceID(
       
  1091                     folder->ContextId() );
       
  1092             HBufC* name;
       
  1093 
       
  1094             if (resId)
       
  1095                 {
       
  1096                 iContainer->Listbox()->GetDefaultData().iInSeamlessFolder = ETrue;
       
  1097                 TInt prefUid;
       
  1098                 iModel->Database().PreferredUid( aFolder, prefUid );
       
  1099                 iContainer->Listbox()->GetDefaultData().iPreferedId = prefUid;
       
  1100                 name = iCoeEnv->AllocReadResourceLC( resId );
       
  1101                 folder->SetNameL(name->Des()); // set the localized name
       
  1102                 CleanupStack::PopAndDestroy(); // name
       
  1103                 }
       
  1104 
       
  1105             ApiProvider().Display().SetTitleL( folder->Name() );
       
  1106             }
       
  1107 
       
  1108         iCurrentFolder = aFolder;
       
  1109         FillListboxL( aFolder, /*aKeepState=*/EFalse );
       
  1110         Container()->Listbox()->ClearSelection();
       
  1111         UpdateCbaL();
       
  1112         UpdateNaviPaneL();
       
  1113         }
       
  1114     CleanupStack::PopAndDestroy();  // folder
       
  1115     }
       
  1116 
       
  1117 // ---------------------------------------------------------
       
  1118 // CBrowserFavouritesView::OpenNextFolderL
       
  1119 // ---------------------------------------------------------
       
  1120 //
       
  1121 void CBrowserFavouritesView::OpenNextFolderL( TBool aForward )
       
  1122     {
       
  1123     __ASSERT_DEBUG( iCurrentFolder != KFavouritesRootUid,
       
  1124         Util::Panic( Util::ERootLevel ) );
       
  1125 
       
  1126     if ( iModel->BeginL( /*aWrite=*/EFalse, /*aDbErrorNote=*/ETrue )
       
  1127                                                                 == KErrNone )
       
  1128         {
       
  1129         TInt nextFolder = iModel->NextFolderL( iCurrentFolder, aForward );
       
  1130         if ( nextFolder != KFavouritesNullUid )
       
  1131             {
       
  1132             OpenFolderL( nextFolder );
       
  1133             }
       
  1134         iModel->CommitL();
       
  1135         }
       
  1136     }
       
  1137 
       
  1138 // ---------------------------------------------------------
       
  1139 // CBrowserFavouritesView::FillListboxL
       
  1140 // ---------------------------------------------------------
       
  1141 //
       
  1142 void CBrowserFavouritesView::FillListboxL( TInt aFolder, TBool aKeepState )
       
  1143     {
       
  1144     // During an incremental operation we should never update the listbox
       
  1145     // because some of them holds pointers to listbox items.
       
  1146     //
       
  1147     // If we have an incremental operation, we should never get here:
       
  1148     // 1) Any change notification (faves db, ap db, preferences) handling is
       
  1149     //    skipped in RefreshL, where all change handling comes
       
  1150     //    together.
       
  1151     // 2) All incremental operations have an empty CBA, so we cannot get here
       
  1152     //    by user input either.
       
  1153     // But to make this safe from potential errors (e.g. user activity due to
       
  1154     // some error in wait notes, CBA, key handling etc., and also from bugs in
       
  1155     // this code), we double-check here.
       
  1156     // In release build do nothing (avoid the crash), in debug build panic.
       
  1157     if ( iIncrementalOp )
       
  1158         {
       
  1159 #ifdef _DEBUG
       
  1160         Util::Panic( Util::ECannotUpdateDataInUse );
       
  1161 #else
       
  1162         return;
       
  1163 #endif
       
  1164         }
       
  1165 
       
  1166     CBrowserFavouritesListbox* listbox = iContainer->Listbox();
       
  1167 
       
  1168     // Disable redraw to avoid flickering.
       
  1169     TBool redrawDisabled = listbox->View()->RedrawDisabled();
       
  1170     listbox->View()->SetDisableRedraw( ETrue );
       
  1171 
       
  1172     // Change the data.
       
  1173     CFavouritesItemList* items = GetItemsLC( aFolder );
       
  1174 
       
  1175     // Next take localized item names for seamless links.
       
  1176     TInt contextId;
       
  1177     TInt resId = 0;
       
  1178     HBufC* name;
       
  1179  
       
  1180     TBool browserService = ApiProvider().Preferences().ServiceFeature();
       
  1181     TBool firstBoot = ApiProvider().Preferences().GetIntValue( KBrowserFirstBoot );
       
  1182     TInt serviceUid = KErrNotFound;
       
  1183     
       
  1184     for(int i=0; i<items->Count(); i++)
       
  1185         {
       
  1186 	    if (!items->At(i)->IsHidden())
       
  1187             {
       
  1188             contextId = items->At(i)->ContextId();
       
  1189         
       
  1190             if ( firstBoot && browserService )
       
  1191                 {
       
  1192                 //This is the first boot and we need to move Service top of the bookmarks.
       
  1193                 //Here we save uid for Service item.
       
  1194                 if ( contextId == KFavouritesServiceContextId )
       
  1195                     {
       
  1196                     serviceUid = items->IndexToUid( i );
       
  1197                     }
       
  1198                 }
       
  1199         
       
  1200             resId = CBrowserFavouritesView::GetSeamlessFolderResourceID( 
       
  1201         			contextId );
       
  1202             if(resId)
       
  1203                 {
       
  1204                 name = iCoeEnv->AllocReadResourceLC( resId );
       
  1205                 items->At(i)->SetNameL(name->Des());
       
  1206                 CleanupStack::PopAndDestroy(); // name
       
  1207                 }
       
  1208             }
       
  1209         else
       
  1210             {
       
  1211             items->Delete(i);
       
  1212             i--;
       
  1213             }
       
  1214         }
       
  1215     
       
  1216     if ( firstBoot && browserService && serviceUid != KErrNotFound )
       
  1217         {
       
  1218         //get current order array
       
  1219         CBrowserBookmarksOrder* currentOrder = CBrowserBookmarksOrder::NewLC();
       
  1220         CArrayFixFlat<TInt>* orderArray = new (ELeave) CArrayFixFlat<TInt>( KGranularityHigh );
       
  1221         CleanupStack::PushL( orderArray );
       
  1222 
       
  1223         iModel->Database().GetData( KFavouritesRootUid, *currentOrder );
       
  1224         orderArray->AppendL( &( currentOrder->GetBookMarksOrder()[0] ), currentOrder->GetBookMarksOrder().Count());
       
  1225         
       
  1226         //First sort UI. Move Service
       
  1227         CFavouritesItem* serviceCopy = CFavouritesItem::NewLC();
       
  1228         const CFavouritesItem* serviceItem = items->ItemByUid( serviceUid );
       
  1229         if ( serviceItem )
       
  1230             {
       
  1231             *serviceCopy = *serviceItem;
       
  1232             items->Delete( serviceUid );
       
  1233             items->InsertL( 0, serviceCopy ); //ownership transfered
       
  1234             CleanupStack::Pop( serviceCopy );
       
  1235             }
       
  1236         else
       
  1237             {
       
  1238             User::Leave( KErrNotFound );
       
  1239             }
       
  1240 
       
  1241         //Next change order in db. Move Service
       
  1242         orderArray->InsertL( 0, orderArray->At( serviceUid ) );
       
  1243         orderArray->Delete( serviceUid+1 );
       
  1244         
       
  1245         //save changes to db
       
  1246         currentOrder->SetBookMarksOrderL( *orderArray );
       
  1247         iModel->Database().SetData( KFavouritesRootUid, *currentOrder );
       
  1248         
       
  1249         CleanupStack::PopAndDestroy( 2 ); //orderArray, currentOrder
       
  1250         //service moved to top of the bookmark list. We can set firstboot value to false
       
  1251         // so now we can set firstboot value to false.
       
  1252         CRepository* repository = CRepository::NewLC( KCRUidBrowser );
       
  1253         User::LeaveIfError( repository->Set(KBrowserFirstBoot, EFalse) );
       
  1254         CleanupStack::PopAndDestroy( repository );
       
  1255         
       
  1256         // Set Search item to italics font
       
  1257         iContainer->Listbox()->ItalicizeRowItemL(0);
       
  1258         }
       
  1259     CleanupStack::Pop();    // items: passing ownership to listbox.
       
  1260     iContainer->Listbox()->SetDataL
       
  1261         ( items, /*ApiProvider().CommsModel(),*/ aKeepState );
       
  1262     CAknColumnListBoxView *aknview = STATIC_CAST(CAknColumnListBoxView*, iContainer->Listbox()->View() );
       
  1263 
       
  1264     if ( !items->Count() )
       
  1265         {
       
  1266         iContainer->Listbox()->UpdateFilterL();  // ...and tell to listbox.
       
  1267         aknview->SetFindEmptyListState(EFalse);
       
  1268         }
       
  1269     else
       
  1270         {
       
  1271         aknview->SetFindEmptyListState(ETrue);
       
  1272         }
       
  1273 
       
  1274     iContainer->SizeChanged();  // Needed to show/hide Find Pane!
       
  1275     iCurrentFolder = aFolder;
       
  1276 
       
  1277     HighlightPreferredL();
       
  1278     iContainer->HandleCursorChangedL( listbox );
       
  1279     listbox->View()->SetDisableRedraw( redrawDisabled );
       
  1280     listbox->DrawNow();
       
  1281 
       
  1282     UpdateCbaL();
       
  1283     UpdateNaviPaneL();
       
  1284     }
       
  1285 
       
  1286 // ----------------------------------------------------------------------------
       
  1287 // CBrowserFavouritesView::ConfirmDeleteL
       
  1288 // ----------------------------------------------------------------------------
       
  1289 //
       
  1290 TBool CBrowserFavouritesView::ConfirmDeleteL
       
  1291 ( CArrayFix<TInt>& aUids, CArrayFix<TInt>& aFolderUids )
       
  1292     {
       
  1293     CBrowserFavouritesModel::TDbQuery anyNonEmptyFolders;
       
  1294     TInt ret = EFalse;
       
  1295 
       
  1296     anyNonEmptyFolders = iModel->AnyNonEmptyFoldersL( aFolderUids );
       
  1297     switch ( anyNonEmptyFolders )
       
  1298         {
       
  1299         case CBrowserFavouritesModel::EYes:
       
  1300             {
       
  1301             // At least one non-empty folder is selected.
       
  1302             ret = TBrowserDialogs::ConfirmQueryYesNoL(
       
  1303                                             _R(TEXT_DEL_FULL_FLDRS_QUERY) );
       
  1304             break;
       
  1305             }
       
  1306 
       
  1307         case CBrowserFavouritesModel::ENo:
       
  1308             {
       
  1309             // No non-empty folders are selected.
       
  1310             TInt count = aUids.Count();
       
  1311             switch ( count )
       
  1312                 {
       
  1313                 case 0:
       
  1314                     {
       
  1315                     // Empty selection (???);
       
  1316                     ret = EFalse;
       
  1317                     break;
       
  1318                     }
       
  1319 
       
  1320                 case 1:
       
  1321                     {
       
  1322                     // One item is selected (item or empty folder).
       
  1323                     // Get its name.
       
  1324                     const CFavouritesItem* item = iContainer->Listbox()->
       
  1325                         ItemByUid( aUids.At( 0 ) );
       
  1326                     if ( item )
       
  1327                         {
       
  1328                         ret = TBrowserDialogs::ConfirmQueryYesNoL(
       
  1329                                     _R(TEXT_QUERY_COMMON_CONF_DELETE), item->Name() );
       
  1330                         }
       
  1331                     else
       
  1332                         {
       
  1333                         // Could not get item (maybe listbox has been updated).
       
  1334                         ret = EFalse;
       
  1335                         }
       
  1336                     break;
       
  1337                     }
       
  1338 
       
  1339                 default:
       
  1340                     {
       
  1341                     // More items are selected (items or/and empty folders).
       
  1342                     ret = TBrowserDialogs::ConfirmQueryYesNoL(
       
  1343                                                 _R(TEXT_DEL_ITEMS_QUERY), count );
       
  1344                     break;
       
  1345                     }
       
  1346 
       
  1347                 }
       
  1348             break;
       
  1349             }
       
  1350 
       
  1351         case CBrowserFavouritesModel::EError:
       
  1352         default:
       
  1353             {
       
  1354             // Could not access database.
       
  1355             ret = EFalse;
       
  1356             break;
       
  1357             }
       
  1358         }
       
  1359 
       
  1360     return ret;
       
  1361     }
       
  1362 
       
  1363 // ---------------------------------------------------------
       
  1364 // CBrowserFavouritesView::DisplayResultOfDeleteL
       
  1365 // ---------------------------------------------------------
       
  1366 //
       
  1367 void CBrowserFavouritesView::DisplayResultOfDeleteL
       
  1368 ( const CArrayFix<TInt>& /*aUids*/, const CArrayFix<TInt>& aNotDeletedUids )
       
  1369     {
       
  1370     switch ( aNotDeletedUids.Count() )
       
  1371         {
       
  1372         case 0:
       
  1373             {
       
  1374             // All items deleted successfully.
       
  1375             // Display nothing.
       
  1376             break;
       
  1377             }
       
  1378         case 1:
       
  1379             {
       
  1380             // One item is not deleted.
       
  1381             const CFavouritesItem* item = iContainer->Listbox()->
       
  1382                 ItemByUid( aNotDeletedUids.At( 0 ) );
       
  1383             if ( item )
       
  1384                 {
       
  1385                 TBrowserDialogs::InfoNoteL
       
  1386                     (
       
  1387                     R_BROWSER_INFO_NOTE,
       
  1388                     _R(TEXT_CANT_DELETE_ITEM),
       
  1389                     item->Name()
       
  1390                     );
       
  1391                 }
       
  1392             // else
       
  1393             //   this item is not found in the listbox (so it does not exist,
       
  1394             //   most likely got deleted somehow) - keep quiet.
       
  1395             break;
       
  1396             }
       
  1397         default:
       
  1398             {
       
  1399             // More items are not deleted.
       
  1400             TBrowserDialogs::InfoNoteL
       
  1401                                     (
       
  1402                                     R_BROWSER_INFO_NOTE,
       
  1403                                     _R(TEXT_CANT_DELETE_ITEMS),
       
  1404                                     aNotDeletedUids.Count()
       
  1405                                     );
       
  1406             break;
       
  1407             }
       
  1408         }
       
  1409     }
       
  1410 
       
  1411 // ---------------------------------------------------------
       
  1412 // CBrowserFavouritesView::SelectTargetFolderL
       
  1413 // ---------------------------------------------------------
       
  1414 //
       
  1415 TInt CBrowserFavouritesView::SelectTargetFolderL( TInt aExcludeFolder )
       
  1416     {
       
  1417     TInt targetFolder = KFavouritesNullUid;
       
  1418 
       
  1419     switch ( iModel->AnyFoldersL() )
       
  1420         {
       
  1421         case CBrowserFavouritesModel::EYes:
       
  1422             {
       
  1423             // Select from existing folders.
       
  1424             CBrowserFavouritesFolderSelector* selector =
       
  1425                 CBrowserFavouritesFolderSelector::NewL
       
  1426                     ( *iModel, ApiProvider(), aExcludeFolder );
       
  1427             targetFolder = selector->ExecuteLD();
       
  1428             break;
       
  1429             }
       
  1430         case CBrowserFavouritesModel::ENo:
       
  1431             {
       
  1432             break;
       
  1433             }
       
  1434         case CBrowserFavouritesModel::EError:
       
  1435         default:
       
  1436             {
       
  1437             // Some error; quit.
       
  1438             break;
       
  1439             }
       
  1440         }
       
  1441     return targetFolder;
       
  1442     }
       
  1443 
       
  1444 // ---------------------------------------------------------
       
  1445 // CBrowserFavouritesView::HandleMoveResultL
       
  1446 // ---------------------------------------------------------
       
  1447 //
       
  1448 void CBrowserFavouritesView::HandleMoveResultL
       
  1449         (
       
  1450         TInt aFolder,
       
  1451         const CArrayFix<TInt>& /*aUids*/,
       
  1452         const CArrayFix<TInt>& aUnmovableUids,
       
  1453         const CArrayFix<TInt>& aConflictingNameUids
       
  1454         )
       
  1455     {
       
  1456     // See if some items has to be renamed to do the move.
       
  1457     if ( aConflictingNameUids.Count() )
       
  1458         {
       
  1459         if ( aConflictingNameUids.Count() == 1 )
       
  1460             {
       
  1461             // One item needs to be renamed if the user wants to move them.
       
  1462             // Let the user know and ask if replace.
       
  1463             const CFavouritesItem* item = iContainer->Listbox()->
       
  1464                 ItemByUid( aConflictingNameUids.At( 0 ) );
       
  1465             if ( item )
       
  1466                 {
       
  1467                 TBrowserDialogs::InfoNoteL
       
  1468                                     (
       
  1469                                     R_BROWSER_INFO_NOTE,
       
  1470                                     _R(TEXT_FLDR_NAME_ALREADY_USED),
       
  1471                                     item->Name()
       
  1472                                     );
       
  1473                 RenameAndMoveItemsL( aConflictingNameUids, aFolder );
       
  1474                 }
       
  1475             }
       
  1476         else
       
  1477             {
       
  1478             // Some items needs to be renamed if the user wants to move them.
       
  1479             // Let the user know and ask for each if replace.
       
  1480             TBrowserDialogs::InfoNoteL(  R_BROWSER_INFO_NOTE,
       
  1481                                         _R(TEXT_FLDR_NAMES_IN_USE_RENAME) );
       
  1482             RenameAndMoveItemsL( aConflictingNameUids, aFolder );
       
  1483             }
       
  1484         }
       
  1485 
       
  1486     // Check unmovable items.
       
  1487     if ( aUnmovableUids.Count() )
       
  1488         {
       
  1489         if ( aUnmovableUids.Count() == 1 )
       
  1490             {
       
  1491             // One item is not moved.
       
  1492             const CFavouritesItem* item = iContainer->Listbox()->
       
  1493                 ItemByUid( aUnmovableUids.At( 0 ) );
       
  1494             if ( item )
       
  1495                 {
       
  1496                 TBrowserDialogs::InfoNoteL
       
  1497                     (
       
  1498                     R_BROWSER_INFO_NOTE,
       
  1499                     _R(TEXT_ITEM_CANNOT_BE_MOVED),
       
  1500                     item->Name()
       
  1501                     );
       
  1502                 }
       
  1503             }
       
  1504         else
       
  1505             {
       
  1506             // More items could not be moved.
       
  1507             TBrowserDialogs::InfoNoteL
       
  1508                 (
       
  1509                 R_BROWSER_INFO_NOTE,
       
  1510                 _R(TEXT_SOME_ITEMS_CANT_MOVE),
       
  1511                 aUnmovableUids.Count()
       
  1512                 );
       
  1513             }
       
  1514         }
       
  1515     // else
       
  1516     //   All is well: all moved succesfully. Display nothing.
       
  1517     }
       
  1518 
       
  1519 // ---------------------------------------------------------
       
  1520 // CBrowserFavouritesView::RenameAndMoveItemsL
       
  1521 // ---------------------------------------------------------
       
  1522 //
       
  1523 void CBrowserFavouritesView::RenameAndMoveItemsL
       
  1524 ( const CArrayFix<TInt>& aUids, TInt aFolder )
       
  1525     {
       
  1526     TInt err = KErrNone;
       
  1527     TInt i;
       
  1528     TInt uid;
       
  1529     TInt count = aUids.Count();
       
  1530     TInt itemErr;
       
  1531 
       
  1532     CFavouritesItem* item = CFavouritesItem::NewLC();
       
  1533 
       
  1534     for ( i = 0; i < count && !err; i++ )
       
  1535         {
       
  1536         // Get each item in turn from db (ignore if any of them is not found).
       
  1537         // Let the user rename each. Quit on the first Cancel from the user.
       
  1538         // All database manipulating methods, which are called here, retry on
       
  1539         // failure, so if we ever get an error value, that means that the user
       
  1540         // cancelled something.
       
  1541         uid = aUids.At( i );
       
  1542         err = iModel->BeginL( /*aWrite=*/ETrue, /*aDbErrorNote=*/ETrue );
       
  1543         if ( !err )
       
  1544             {
       
  1545             // Check if we have the item.
       
  1546             itemErr = iModel->Database().Get( uid, *item );
       
  1547             iModel->CommitL();
       
  1548             if ( !itemErr )
       
  1549                 {
       
  1550                 // We have this item. Ask the user to rename it.
       
  1551                 if ( iModel->RenameQueryL( *item, EFalse) )
       
  1552                     {
       
  1553                     // The user renamed the item: try to update and go on.
       
  1554                     item->SetParentFolder( aFolder );
       
  1555                     err = iModel->UpdateL( *item, uid, /*aDbErrorNote=*/ETrue,
       
  1556                         CBrowserFavouritesModel::EAskIfRename );
       
  1557                     }
       
  1558                 else
       
  1559                     {
       
  1560                     // Cancelled. Quit.
       
  1561                     err = KErrCancel;
       
  1562                     }
       
  1563                 }
       
  1564             }
       
  1565         }
       
  1566     CleanupStack::PopAndDestroy();  // item
       
  1567     }
       
  1568 
       
  1569 // ---------------------------------------------------------
       
  1570 // CBrowserFavouritesView::UpdateNaviPaneL
       
  1571 // ---------------------------------------------------------
       
  1572 //
       
  1573 void CBrowserFavouritesView::UpdateNaviPaneL()
       
  1574     {
       
  1575     if ( iCurrentFolder == KFavouritesRootUid )
       
  1576         {
       
  1577         // In root folder show the tabs.
       
  1578         iContainer->ShowRootNaviPane();
       
  1579         }
       
  1580     else
       
  1581         {
       
  1582         // In other folder, show "1/4" style text.
       
  1583         TInt folderIndex;
       
  1584         TInt folderCount;
       
  1585         TInt err;
       
  1586         err = iModel->FolderInfoL( iCurrentFolder, folderCount, folderIndex );
       
  1587         if ( !err )
       
  1588             {
       
  1589             iContainer->ShowFolderNaviPaneL( folderIndex, folderCount );
       
  1590             }
       
  1591         }
       
  1592     }
       
  1593 
       
  1594 // ---------------------------------------------------------
       
  1595 // CBrowserFavouritesView::OfferKeyEventL
       
  1596 // ---------------------------------------------------------
       
  1597 //
       
  1598 TKeyResponse CBrowserFavouritesView::OfferKeyEventL
       
  1599 ( const TKeyEvent& aKeyEvent, TEventCode /*aType*/ )
       
  1600     {
       
  1601     // This method is called back from the container, to process the keypresses
       
  1602     // that cannot be handled by the container. Those are (currently) the
       
  1603     // left/right arrow keypresses, since the container does not know anything
       
  1604     // about what folder is open, which knowledge is required to process
       
  1605     // arrow presses. So we do that here.
       
  1606     // Any other key processing is still in the container.
       
  1607     TKeyResponse result = EKeyWasNotConsumed;
       
  1608     switch ( aKeyEvent.iCode )
       
  1609         {
       
  1610 
       
  1611         case EKeyLeftArrow:       // West
       
  1612             {
       
  1613             if ( iCurrentFolder != KFavouritesRootUid )
       
  1614                 {
       
  1615                 // We are in some folder. Move between subfolders in the
       
  1616                 // leftward direction.
       
  1617                 if ( !ApiProvider().IsEmbeddedModeOn() )
       
  1618                     {
       
  1619                     OpenNextFolderL( /*aForward=*/EFalse );
       
  1620                     }
       
  1621                 //return EKeyWasConsumed anyway, since in embedded mode user can access only the launch folder
       
  1622                 result = EKeyWasConsumed;
       
  1623                 }
       
  1624             break;
       
  1625             }
       
  1626 
       
  1627         case EKeyRightArrow:       // East
       
  1628             {
       
  1629             if ( iCurrentFolder != KFavouritesRootUid )
       
  1630                 {
       
  1631                 // We are in some folder. Move between subfolders in the
       
  1632                 // rightward direction.
       
  1633                 if ( !ApiProvider().IsEmbeddedModeOn() )
       
  1634                     {
       
  1635                     OpenNextFolderL( /*aForward=*/ETrue );
       
  1636                     }
       
  1637                 //return EKeyWasConsumed anyway, since in embedded mode user can access only the launch folder
       
  1638                 result = EKeyWasConsumed;
       
  1639                 }
       
  1640             break;
       
  1641             }
       
  1642 
       
  1643         case EKeyRightUpArrow:    // Northeast
       
  1644         case EStdKeyDevice11:     //   : Extra KeyEvent supports diagonal event simulator wedge
       
  1645         case EKeyRightDownArrow:  // Southeast
       
  1646         case EStdKeyDevice12:     //   : Extra KeyEvent supports diagonal event simulator wedge
       
  1647         case EKeyLeftDownArrow:   // Southwest
       
  1648         case EStdKeyDevice13:     //   : Extra KeyEvent supports diagonal event simulator wedge
       
  1649         case EKeyLeftUpArrow:     // Northwest
       
  1650         case EStdKeyDevice10:     //   : Extra KeyEvent supports diagonal event simulator wedge
       
  1651             {                     // Here, "eat" all of the diagonals so they have no effect
       
  1652             result = EKeyWasConsumed;
       
  1653             break;
       
  1654             }
       
  1655 
       
  1656 
       
  1657         case EKeyBackspace:
       
  1658         case EKeyDelete:
       
  1659             {
       
  1660             TBrowserFavouritesSelectionState state =
       
  1661                 iContainer->Listbox()->SelectionStateL();
       
  1662             if ( state.AnyDeletable() )
       
  1663                 {
       
  1664                 // We don't editing (not in Goto Pane),
       
  1665                 // and have something to delete. In this case, Clear key
       
  1666                 // deletes the selection (or highlighted items).
       
  1667                 if ( ((iContainer->Listbox()->CurrentItem()->ContextId() == NULL ) &&
       
  1668                     (iContainer->Listbox()->CurrentItem()->Uid() != KFavouritesAdaptiveItemsFolderUid) ||
       
  1669                     state.AnyMarked() )
       
  1670                   )
       
  1671                     {
       
  1672                     DeleteMarkedItemsL();
       
  1673                     }
       
  1674                 result = EKeyWasConsumed;
       
  1675                 }
       
  1676             break;
       
  1677             }
       
  1678 
       
  1679         case EKeyOK:
       
  1680             // OK key is handled through MSK handling
       
  1681             result = EKeyWasConsumed;
       
  1682             break;
       
  1683 
       
  1684         case EKeyEnter:
       
  1685             {
       
  1686             if ( !(aKeyEvent.iModifiers & EModifierShift) )
       
  1687                 {
       
  1688                 TBrowserFavouritesSelectionState state =
       
  1689                     iContainer->Listbox()->SelectionStateL();
       
  1690                 if ( state.IsEmpty() || state.AnyMarked() )
       
  1691                     {
       
  1692                     // Selection key (alone) pressed when there are marked
       
  1693                     // items or the list is empty. Bring up context sensitive
       
  1694                     // (OK-Options) menu.
       
  1695                     MenuBar( )->
       
  1696                         SetMenuTitleResourceId( OkOptionsMenuResourceId() );
       
  1697                     iShowOkOptions = ETrue;
       
  1698                     // Call to menu activation is trapped - to make sure that
       
  1699                     // iShowOkOptions and bad menu doesn't stick in.
       
  1700                     TRAP_IGNORE( ProcessCommandL( EAknSoftkeyOptions ) );
       
  1701                     iShowOkOptions = EFalse;
       
  1702                     MenuBar( )->
       
  1703                         SetMenuTitleResourceId( OptionsMenuResourceId() );
       
  1704 
       
  1705                     // Update CBA to include context menu MSK icon
       
  1706                     UpdateCbaL();
       
  1707 
       
  1708                     result = EKeyWasConsumed;
       
  1709                     }
       
  1710                 }
       
  1711             break;
       
  1712             }
       
  1713 
       
  1714         default:
       
  1715             {
       
  1716             break;
       
  1717             }
       
  1718         }
       
  1719 
       
  1720     return result;
       
  1721     }
       
  1722 
       
  1723 // ---------------------------------------------------------
       
  1724 // CBrowserFavouritesView::HandleFavouritesModelChangeL
       
  1725 // ---------------------------------------------------------
       
  1726 //
       
  1727 void CBrowserFavouritesView::HandleFavouritesModelChangeL()
       
  1728     {
       
  1729     // Change in favourites database.
       
  1730     if ( iRefresh )
       
  1731         {
       
  1732         RefreshL();
       
  1733         }
       
  1734     iRefresh = ETrue;
       
  1735     }
       
  1736 
       
  1737 // ---------------------------------------------------------
       
  1738 // CBrowserFavouritesView::HandleCommsModelChangeL
       
  1739 // ---------------------------------------------------------
       
  1740 //
       
  1741 void CBrowserFavouritesView::HandleCommsModelChangeL()
       
  1742     {
       
  1743     // Change in AP-s (CommsDb).
       
  1744     RefreshL( /*aDbErrorNote=*/EFalse );
       
  1745     }
       
  1746 
       
  1747 void CBrowserFavouritesView::OpenFixedFolderL(TInt aUid)
       
  1748     {
       
  1749     OpenFolderL(aUid);
       
  1750     }
       
  1751 
       
  1752 // ---------------------------------------------------------
       
  1753 // CBrowserFavouritesView::SetPreferedCurrentItemL
       
  1754 // ---------------------------------------------------------
       
  1755 //
       
  1756 void CBrowserFavouritesView::SetPreferedCurrentItemL()
       
  1757     {
       
  1758     //  check the current item is exist
       
  1759     if ( iContainer->Listbox()->CurrentItem() )
       
  1760         {
       
  1761         iContainer->Listbox()->GetDefaultData().iPreferedId =
       
  1762             iContainer->Listbox()->CurrentItem()->Uid();
       
  1763         iModel->Database().SetPreferredUid(
       
  1764             iCurrentFolder,iContainer->Listbox()->CurrentItem()->Uid() );
       
  1765         iRefresh = ETrue;
       
  1766         }
       
  1767     }
       
  1768 
       
  1769 // ---------------------------------------------------------
       
  1770 // CBrowserFavouritesView::SetUnPreferedCurrentItemL
       
  1771 // ---------------------------------------------------------
       
  1772 //
       
  1773 void CBrowserFavouritesView::SetUnPreferedCurrentItemL()
       
  1774     {
       
  1775     //  check the current item is exist
       
  1776     if ( iContainer->Listbox()->CurrentItem() )
       
  1777         {
       
  1778         iContainer->Listbox()->GetDefaultData().iPreferedId = NULL;
       
  1779         iModel->Database().SetPreferredUid( iCurrentFolder,NULL );
       
  1780         iRefresh = ETrue;
       
  1781         }
       
  1782     }
       
  1783 
       
  1784 // ---------------------------------------------------------
       
  1785 // CBrowserFavouritesView::ConfigContextMenu
       
  1786 // ---------------------------------------------------------
       
  1787 //
       
  1788 void CBrowserFavouritesView::ConfigContextMenu()
       
  1789     {
       
  1790     // Config Context Sensitive Menu Resource and Type when items are marked
       
  1791 
       
  1792     MenuBar()->SetContextMenuTitleResourceId( OkOptionsMenuResourceId());
       
  1793     MenuBar()->SetMenuType(CEikMenuBar::EMenuContext);
       
  1794     MenuBar()->SetMenuTitleResourceId( OptionsMenuResourceId());
       
  1795     MenuBar()->SetMenuType(CEikMenuBar::EMenuOptions);  // adds task swapper menu item first
       
  1796     }
       
  1797 
       
  1798 void CBrowserFavouritesView::UpdateToolbarButtonsState()  
       
  1799     {  
       
  1800     LOG_ENTERFN("CBrowserFavouritesView::UpdateToolbarButtonsState");    
       
  1801     BROWSER_LOG( ( _L("Implementation is not required here") ) );  
       
  1802     }  
       
  1803 
       
  1804 // End of File