browserui/browser/FavouritesSrc/BrowserFavouritesView.cpp
changeset 31 868cceedabd3
parent 22 d6f226a5ad2c
child 37 481242ead638
equal deleted inserted replaced
27:b57c5fc53578 31:868cceedabd3
    28 #include <eikmenup.h>
    28 #include <eikmenup.h>
    29 #include <AknForm.h>
    29 #include <AknForm.h>
    30 #include <AknQueryDialog.h>
    30 #include <AknQueryDialog.h>
    31 #include <BrowserNG.rsg>
    31 #include <BrowserNG.rsg>
    32 #include <avkon.rsg>
    32 #include <avkon.rsg>
    33 #include <FavouritesLimits.h>
    33 #include <favouriteslimits.h>
    34 #include <FavouritesDb.h>
    34 #include <favouritesdb.h>
    35 #include <FavouritesItem.h>
    35 #include <favouritesitem.h>
    36 #include <FavouritesItemList.h>
    36 #include <favouritesitemlist.h>
    37 #include <InternetConnectionManager.h>
    37 #include <internetconnectionmanager.h>
    38 #include <FeatMgr.h>
    38 #include <FeatMgr.h>
    39 #include <centralrepository.h>
    39 #include <centralrepository.h>
    40 #include <nifman.h>
    40 #include <nifman.h>
    41 
    41 
    42 #include "BrowserUiPrivateCRKeys.h"
    42 #include "BrowserUiPrivateCRKeys.h"
   239           iShowOkOptions( EFalse ),
   239           iShowOkOptions( EFalse ),
   240           iCurrentFolder( aInitialFolderId ),
   240           iCurrentFolder( aInitialFolderId ),
   241           iIsActivated( EFalse ),
   241           iIsActivated( EFalse ),
   242           iLastSelection( 0 ),
   242           iLastSelection( 0 ),
   243           iUpdatePending( EFalse ),
   243           iUpdatePending( EFalse ),
   244           iRefresh( EFalse )
   244           iRefresh( ETrue )
   245     {
   245     {
   246     }
   246     }
   247 
   247 
   248 // ---------------------------------------------------------
   248 // ---------------------------------------------------------
   249 // CBrowserFavouritesView::ConstructL
   249 // CBrowserFavouritesView::ConstructL
   257     // Ap model cannot be created without opening it; so that's not done here.
   257     // Ap model cannot be created without opening it; so that's not done here.
   258     // DoActivateL / DoDecativateL does that.
   258     // DoActivateL / DoDecativateL does that.
   259     }
   259     }
   260 
   260 
   261 // ---------------------------------------------------------
   261 // ---------------------------------------------------------
   262 // CBrowserFavouritesView::GetItemsL
   262 // CBrowserFavouritesView::GetItemsLC
   263 // ---------------------------------------------------------
   263 // ---------------------------------------------------------
   264 //
   264 //
   265 CFavouritesItemList* CBrowserFavouritesView::GetItemsL( TInt aFolder )
   265 CFavouritesItemList* CBrowserFavouritesView::GetItemsLC( TInt aFolder )
   266     {
   266     {
   267     CFavouritesItemList* items = new (ELeave) CFavouritesItemList();
   267     CFavouritesItemList* items = new (ELeave) CFavouritesItemList();
       
   268     CleanupStack::PushL( items );
   268     iModel->Database().GetAll( *items, aFolder );
   269     iModel->Database().GetAll( *items, aFolder );
   269     iModel->SortL( *items );
   270     iModel->SortL( *items );
   270     return items;
   271     return items;
   271     }
   272     }
   272 
   273 
   410     // (This is a sanity-check like functionality, but is really used.
   411     // (This is a sanity-check like functionality, but is really used.
   411     // Bookmarks View observes changes in active and default AP-s, even if
   412     // Bookmarks View observes changes in active and default AP-s, even if
   412     // not activated (and tries to refresh); but this "activated-check" is
   413     // not activated (and tries to refresh); but this "activated-check" is
   413     // made here, not in Bookmarks View, because it makes things more safe and
   414     // made here, not in Bookmarks View, because it makes things more safe and
   414     // "future-proof".)
   415     // "future-proof".)
   415     //Making iRefresh ETrue
       
   416     iRefresh = ETrue;
       
   417     if ( iIsActivated )
   416     if ( iIsActivated )
   418         {
   417         {
   419         iUpdatePending = ETrue;
   418         iUpdatePending = ETrue;
   420         if ( !iIncrementalOp )
   419         if ( !iIncrementalOp )
   421             {
   420             {
   771     if ( ConfirmDeleteL( *uids, *folderUids ) )
   770     if ( ConfirmDeleteL( *uids, *folderUids ) )
   772         {
   771         {
   773 
   772 
   774         if (count ==1)
   773         if (count ==1)
   775             {
   774             {
   776             CFavouritesItemList* allItems=NULL;
   775             CFavouritesItemList* allItems = GetItemsLC( KFavouritesRootUid );
   777             if(iRefresh)
       
   778                 {
       
   779                 allItems = GetItemsL( KFavouritesRootUid );
       
   780                 CleanupStack::PushL(allItems);
       
   781                 }
       
   782             else 
       
   783                 {
       
   784                 allItems = iBookmarkitems;
       
   785                 }
       
   786             item = items->At(0);
   776             item = items->At(0);
   787             iPreferredHighlightUid = item->Uid();
   777             iPreferredHighlightUid = item->Uid();
   788             TInt index = allItems->UidToIndex(iPreferredHighlightUid);
   778             TInt index = allItems->UidToIndex(iPreferredHighlightUid);
   789             index++;
   779             index++;
   790             if (allItems->IndexToUid(index) != NULL)
   780             if (allItems->IndexToUid(index) != NULL)
  1175     // Disable redraw to avoid flickering.
  1165     // Disable redraw to avoid flickering.
  1176     TBool redrawDisabled = listbox->View()->RedrawDisabled();
  1166     TBool redrawDisabled = listbox->View()->RedrawDisabled();
  1177     listbox->View()->SetDisableRedraw( ETrue );
  1167     listbox->View()->SetDisableRedraw( ETrue );
  1178 
  1168 
  1179     // Change the data.
  1169     // Change the data.
  1180     CFavouritesItemList* items = NULL; 
  1170     CFavouritesItemList* items = GetItemsLC( aFolder );
  1181     if (iRefresh)
  1171 
  1182         {
       
  1183         items = GetItemsL( aFolder );
       
  1184         CleanupStack::PushL(items);
       
  1185         }
       
  1186     else
       
  1187         {
       
  1188         items = iBookmarkitems;
       
  1189         }
       
  1190     // Next take localized item names for seamless links.
  1172     // Next take localized item names for seamless links.
  1191     TInt contextId;
  1173     TInt contextId;
  1192     TInt resId = 0;
  1174     TInt resId = 0;
  1193     HBufC* name;
  1175     HBufC* name;
  1194  
  1176  
  1269         CleanupStack::PopAndDestroy( repository );
  1251         CleanupStack::PopAndDestroy( repository );
  1270         
  1252         
  1271         // Set Search item to italics font
  1253         // Set Search item to italics font
  1272         iContainer->Listbox()->ItalicizeRowItemL(0);
  1254         iContainer->Listbox()->ItalicizeRowItemL(0);
  1273         }
  1255         }
  1274     if(iRefresh)
  1256     CleanupStack::Pop();    // items: passing ownership to listbox.
  1275         {
       
  1276         CleanupStack::Pop();    // items: passing ownership to listbox.
       
  1277         }
       
  1278     iContainer->Listbox()->SetDataL
  1257     iContainer->Listbox()->SetDataL
  1279         ( items, /*ApiProvider().CommsModel(),*/ aKeepState );
  1258         ( items, /*ApiProvider().CommsModel(),*/ aKeepState );
  1280     CAknColumnListBoxView *aknview = STATIC_CAST(CAknColumnListBoxView*, iContainer->Listbox()->View() );
  1259     CAknColumnListBoxView *aknview = STATIC_CAST(CAknColumnListBoxView*, iContainer->Listbox()->View() );
  1281 
  1260 
  1282     if ( !items->Count() )
  1261     if ( !items->Count() )