browserui/browser/FavouritesSrc/BrowserAdaptiveListPopup.cpp
branchRCL_3
changeset 50 c9249d037530
parent 37 481242ead638
child 55 08ffbd51e3fd
equal deleted inserted replaced
48:5c11946e75b3 50:c9249d037530
    40 #include "BrowserAdaptiveListPopup.h"
    40 #include "BrowserAdaptiveListPopup.h"
    41 #include "BrowserAppUi.h"
    41 #include "BrowserAppUi.h"
    42 #include "CommonConstants.h"
    42 #include "CommonConstants.h"
    43 #include "BrowserAppViewBase.h"
    43 #include "BrowserAppViewBase.h"
    44 #include <data_caging_path_literals.hrh>
    44 #include <data_caging_path_literals.hrh>
       
    45 #include <Uri8.h>
       
    46 #include <utf.h>
    45 
    47 
    46 #include "eikon.hrh"
    48 #include "eikon.hrh"
    47 
    49 
    48 // CONSTANTS
    50 // CONSTANTS
    49 const TInt KMaxIcons = 2;
    51 const TInt KMaxIcons = 2;
    52 _LIT( KDirTab, "0\t");//prefix for directories
    54 _LIT( KDirTab, "0\t");//prefix for directories
    53 const TInt KArrayGranularity = 10;
    55 const TInt KArrayGranularity = 10;
    54 _LIT( KProtocolIdentifier,"://" );
    56 _LIT( KProtocolIdentifier,"://" );
    55 const TUint KSlash('/');
    57 const TUint KSlash('/');
    56 const TUint KPeriod('.');
    58 const TUint KPeriod('.');
       
    59 const TInt KListHeight = 45;
       
    60 const TInt KFontHeight = 150;
    57 
    61 
    58 static void TextPos(TPoint *aResultArray, const TAknTextLineLayout
    62 static void TextPos(TPoint *aResultArray, const TAknTextLineLayout
    59 &aLayout, TSize aItemSize)
    63 &aLayout, TSize aItemSize)
    60     {
    64     {
    61     TRect itemRect(TPoint(0,0), aItemSize);
    65     TRect itemRect(TPoint(0,0), aItemSize);
   470     else
   474     else
   471         {
   475         {
   472         iUrlCompletionMode = EFalse;
   476         iUrlCompletionMode = EFalse;
   473         //only include recent URLs if not including the url completion items
   477         //only include recent URLs if not including the url completion items
   474         iRecentUrlStore->GetData( *iItems, *iItemNames, trimmedContent );
   478         iRecentUrlStore->GetData( *iItems, *iItemNames, trimmedContent );
       
   479         
       
   480         //sort alphabetically and...
       
   481         for(TInt i=0; i<iItems->Count(); i++)
       
   482             {
       
   483             for(TInt j=0; j<iItems->Count()-1; j++)
       
   484                 {
       
   485                     if ((*iItems)[j].CompareF((*iItems)[j+1]) > 0)
       
   486                     {  
       
   487                        RBuf tmp;
       
   488                        CleanupClosePushL(tmp);
       
   489                        tmp.Create((*iItems)[j]);
       
   490                        iItems->Delete(j);
       
   491                        iItems->InsertL( j+1, tmp );
       
   492                        tmp.Close();
       
   493                        tmp.Create((*iItemNames)[j]);
       
   494                        iItemNames->Delete(j);
       
   495                        iItemNames->InsertL( j+1, tmp );
       
   496                        CleanupStack::PopAndDestroy( &tmp );                   
       
   497                     }          
       
   498                 }
       
   499             }  
       
   500         //and move url with params i.e google.fi/m=q?xyz do the back of list
       
   501         TInt i = 0;                 //iterator
       
   502         TInt j = 0;                 //counter
       
   503         while (i < (iItems->Count()-1) && j < iItems->Count())
       
   504             {
       
   505                 TUriParser8 parser;
       
   506                 RBuf8 out;
       
   507                 CleanupClosePushL( out );
       
   508                 out.Create( (*iItems)[i].Length() );
       
   509                 RBuf in;
       
   510                 CleanupClosePushL( in );              
       
   511                 in.Create( (*iItems)[i] );
       
   512                 
       
   513                 CnvUtfConverter::ConvertFromUnicodeToUtf8(out, in );
       
   514                 
       
   515                 if (( parser.Parse( out ) == KErrNone ) &&       //if parse ok and 
       
   516                     ( parser.Extract( EUriPath ).Length() > 0 || //url contains path
       
   517                       parser.Extract( EUriQuery ).Length() > 0 )) //or query item
       
   518                     {
       
   519                     iItems->AppendL( (*iItems)[i] );//move item to back of the list
       
   520                     iItems->Delete( i );
       
   521                     iItemNames->AppendL( (*iItemNames)[i] );
       
   522                     iItemNames->Delete( i );
       
   523                     }
       
   524                 else
       
   525                     {
       
   526                     i++;
       
   527                     }
       
   528                 j++;
       
   529                 
       
   530                 CleanupStack::PopAndDestroy( &in );
       
   531                 CleanupStack::PopAndDestroy( &out );
       
   532             };   
       
   533             
       
   534 
   475         }
   535         }
   476     iDirectoryMode = EFalse;
   536     iDirectoryMode = EFalse;
   477     CleanupStack::PopAndDestroy();//newText
   537     CleanupStack::PopAndDestroy();//newText
   478     TInt k;
   538     TInt k;
   479     k = iItems->Count();
   539     k = iItems->Count();
   544 
   604 
   545         TRect rectTemp(layoutSLWRect.Rect());
   605         TRect rectTemp(layoutSLWRect.Rect());
   546         // force listbox on top of goto pane
   606         // force listbox on top of goto pane
   547         rectTemp.iBr.iY = iParent->PositionRelativeToScreen().iY;
   607         rectTemp.iBr.iY = iParent->PositionRelativeToScreen().iY;
   548         rectTemp.iTl.iX = iParent->PositionRelativeToScreen().iX;
   608         rectTemp.iTl.iX = iParent->PositionRelativeToScreen().iX;
   549         // shrink list box to size of list
   609         // shrink list box to size of list  
   550         rectTemp.iTl.iY =  rectTemp.iBr.iY - (AppLayout::list_single_graphic_popup_wml_pane( 0 ).iH * itemstoshow);
   610 #ifdef BRDO_TOUCH_ENABLED_FF
       
   611         TInt listH = KListHeight;
       
   612 #else
       
   613         TInt listH = AppLayout::list_single_graphic_popup_wml_pane( 0 ).iH;
       
   614 #endif
       
   615         rectTemp.iTl.iY =  rectTemp.iBr.iY - (listH * itemstoshow);
   551         // set bottom right x axis to full width
   616         // set bottom right x axis to full width
   552         rectTemp.iBr.iX = rect.iBr.iX;
   617         rectTemp.iBr.iX = rect.iBr.iX;
   553         
   618         
   554         // we only want to call SetRect() when we have a relayout, otherwise just
   619         // we only want to call SetRect() when we have a relayout, otherwise just
   555         // scroll the list to the correct position. Doing this will reduce the amount
   620         // scroll the list to the correct position. Doing this will reduce the amount
   570             // this scrolls list to the correct position, probably still does too much work
   635             // this scrolls list to the correct position, probably still does too much work
   571             AknListBoxLayouts::SetupListboxPos( *iList, AppLayout::list_single_graphic_popup_wml_pane( 0 ));
   636             AknListBoxLayouts::SetupListboxPos( *iList, AppLayout::list_single_graphic_popup_wml_pane( 0 ));
   572             }
   637             }
   573         //the last item is visible
   638         //the last item is visible
   574         iList->ScrollToMakeItemVisible( iList->Model()->NumberOfItems()-1 );
   639         iList->ScrollToMakeItemVisible( iList->Model()->NumberOfItems()-1 );
       
   640 #ifdef BRDO_TOUCH_ENABLED_FF
       
   641         const CFont* pFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont);
       
   642         TFontSpec fontSpec = pFont->FontSpecInTwips();
       
   643         fontSpec.iHeight =KFontHeight; 
       
   644         
       
   645         CFont* fontNew;
       
   646         CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips( ( CFont*&)fontNew, fontSpec );
       
   647         CFormattedCellListBoxData *pLBData = iList->ItemDrawer()->ColumnData();
       
   648         iList->SetItemHeightL(KListHeight);
       
   649         
       
   650         if(pLBData && pFont)
       
   651         {
       
   652             pLBData->SetSubCellFontL(1,fontNew);
       
   653         }        
       
   654         
       
   655         CEikonEnv::Static()->ScreenDevice()->ReleaseFont(fontNew);
       
   656 #endif        
       
   657         
   575         MakeVisible( ETrue );
   658         MakeVisible( ETrue );
   576         iPoppedUp = ETrue;
   659         iPoppedUp = ETrue;
   577         DrawNow();
   660         DrawNow();
   578         iList->Draw(rectTemp);
   661         iList->Draw(rectTemp);
   579         }
   662         }