browserui/browser/FavouritesSrc/BrowserAdaptiveListPopup.cpp
branchRCL_3
changeset 64 6385c4c93049
parent 63 4baee4f15982
child 65 8e6fa1719340
equal deleted inserted replaced
63:4baee4f15982 64:6385c4c93049
     1 /*
       
     2 * Copyright (c) 2002-2006 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 CBrowserPopupList and CBrowserAdaptiveListPopup
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32std.h>
       
    22 #include <AknPopup.h>
       
    23 #include <AknListQueryDialog.h>
       
    24 #include <AknIconArray.h>
       
    25 #include <recenturlstore.h>
       
    26 #include <AknsUtils.h>
       
    27 #include <AknsListBoxBackgroundControlContext.h>
       
    28 #include <AppApacLayout.cdl.h>
       
    29 #include <AppLayout.cdl.h>
       
    30 #include <AknLayout.cdl.h>
       
    31 #include <SkinLayout.cdl.h>
       
    32 #include <AknLayout2ScalableDef.h>
       
    33 #include <AknLayoutScalable_Avkon.cdl.h>
       
    34 #include <AknLayoutScalable_Apps.cdl.h>
       
    35 #include <LayoutMetaData.cdl.h>
       
    36 #include <AknEnv.h>
       
    37 #include <aknsdrawutils.h>
       
    38 #include <browser.mbg>
       
    39 #include "BrowserContentView.h"
       
    40 #include "BrowserAdaptiveListPopup.h"
       
    41 #include "BrowserAppUi.h"
       
    42 #include "CommonConstants.h"
       
    43 #include "BrowserAppViewBase.h"
       
    44 #include <data_caging_path_literals.hrh>
       
    45 #include <Uri8.h>
       
    46 #include <utf.h>
       
    47 
       
    48 #include "eikon.hrh"
       
    49 
       
    50 // CONSTANTS
       
    51 const TInt KMaxIcons = 2;
       
    52 const TInt KListLengthToShow = 64;//the length of the string in the list
       
    53 _LIT( KItemTab, "1\t");//prefix for items
       
    54 _LIT( KDirTab, "0\t");//prefix for directories
       
    55 const TInt KArrayGranularity = 10;
       
    56 _LIT( KProtocolIdentifier,"://" );
       
    57 const TUint KSlash('/');
       
    58 const TUint KPeriod('.');
       
    59 const TInt KListHeight = 36;
       
    60 const TInt KLandscapeListItems = 5;
       
    61 const TInt KFontHeight = 150;
       
    62 
       
    63 static void TextPos(TPoint *aResultArray, const TAknTextLineLayout
       
    64 &aLayout, TSize aItemSize)
       
    65     {
       
    66     TRect itemRect(TPoint(0,0), aItemSize);
       
    67     TAknLayoutText textLayout;
       
    68     textLayout.LayoutText(itemRect, aLayout);
       
    69     aResultArray[0] = textLayout.TextRect().iTl;
       
    70     aResultArray[1] = textLayout.TextRect().iTl +
       
    71 textLayout.TextRect().Size();
       
    72     }
       
    73 
       
    74 static void GfxPos(TPoint *aResultArray, const TAknWindowLineLayout
       
    75 &aLayout, TSize aItemSize)
       
    76     {
       
    77     TRect itemRect(TPoint(0,0), aItemSize);
       
    78     TAknLayoutRect layout;
       
    79     layout.LayoutRect(itemRect, aLayout);
       
    80     aResultArray[0] = layout.Rect().iTl;
       
    81     aResultArray[1] = layout.Rect().iTl + layout.Rect().Size();
       
    82     }
       
    83 
       
    84 TSize ListBoxItemSize(CEikListBox &aListBox, CFormattedCellListBoxItemDrawer *aItemDrawer)
       
    85     {
       
    86     TSize size = TSize( aItemDrawer->LafItemSize().iWidth, aListBox.View()->ItemSize().iHeight );
       
    87     return size;
       
    88     }
       
    89 
       
    90 // ================= MEMBER FUNCTIONS =======================
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CBrowserPopupList::CBrowserPopupList()
       
    94 //
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 CBrowserPopupList::CBrowserPopupList(TParentType aParentType):CAknSingleGraphicPopupMenuStyleListBox()
       
    98     {
       
    99     iParentType = aParentType;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------
       
   103 // CBrowserPopupList::~CBrowserPopupList()
       
   104 //
       
   105 // ---------------------------------------------------------
       
   106 //
       
   107 CBrowserPopupList::~CBrowserPopupList()
       
   108     {
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // CBrowserPopupList::ConstructL
       
   113 //
       
   114 // ---------------------------------------------------------
       
   115 //
       
   116 void CBrowserPopupList::ConstructL(const CCoeControl* aParent, TInt aFlags)
       
   117     {
       
   118     CAknSingleGraphicPopupMenuStyleListBox::ConstructL( aParent, aFlags);
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------
       
   122 // CBrowserPopupList::SetHighLight
       
   123 // Sets the highlight of the list
       
   124 // ---------------------------------------------------------
       
   125 //
       
   126 void CBrowserPopupList::SetHighLight(TBool aHighLight)
       
   127     {
       
   128 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
   129     iItemDrawer->SetFlags( CListItemDrawer::ESingleClickEnabled );
       
   130 #endif    
       
   131     iListBoxFlags = ( aHighLight ?  iListBoxFlags &~ CEikListBox::EDisableHighlight : iListBoxFlags | CEikListBox::EDisableHighlight );
       
   132     if ( aHighLight )
       
   133         {
       
   134         iItemDrawer->ClearFlags( CListItemDrawer::EDisableHighlight );
       
   135         }
       
   136     else
       
   137         {
       
   138         iItemDrawer->SetFlags( CListItemDrawer::EDisableHighlight );
       
   139         }
       
   140     }
       
   141 
       
   142 // ---------------------------------------------------------
       
   143 // CBrowserPopupList::HighLightEnabled()
       
   144 // Enables the highlight in the list
       
   145 // ---------------------------------------------------------
       
   146 //
       
   147 TBool CBrowserPopupList::HighLightEnabled()
       
   148     {
       
   149     return !( iItemDrawer->Flags() & CListItemDrawer::EDisableHighlight );
       
   150     }
       
   151 
       
   152 // ---------------------------------------------------------
       
   153 // CBrowserPopupList::SizeChanged()
       
   154 // sets the inner layout
       
   155 // ---------------------------------------------------------
       
   156 //
       
   157 void CBrowserPopupList::SizeChanged()
       
   158     {
       
   159     CAknSingleGraphicPopupMenuStyleListBox::SizeChanged();
       
   160     TAknWindowLineLayout windowLineLayout;
       
   161     TAknWindowLineLayout windowLineLayoutTmp;
       
   162     TAknWindowLineLayout windowLineLayoutTmp2;
       
   163     TAknLayoutRect layoutRect;
       
   164     TPoint area[2] ;
       
   165     TRgb color;
       
   166     CEikFormattedCellListBox &aListBox = *this;
       
   167     CFormattedCellListBoxItemDrawer *itemDrawer = aListBox.ItemDrawer();
       
   168     AknListBoxLayouts::SetupStandardListBox(aListBox);
       
   169 
       
   170     AknListBoxLayouts::SetupListboxPos( aListBox, AppLayout::list_single_graphic_popup_wml_pane( 0 ));
       
   171 
       
   172     GfxPos(area,
       
   173     AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_g1(),
       
   174     ListBoxItemSize(*this, ItemDrawer()) );
       
   175 
       
   176     AknListBoxLayouts::SetupFormGfxCell(aListBox,
       
   177                                         itemDrawer,
       
   178                                         0,
       
   179                                         AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_g2(),
       
   180                                         area[0],
       
   181                                         area[1]);
       
   182 
       
   183     //sets the rectangle of the text
       
   184     TextPos(area,
       
   185     AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_t1( ),
       
   186     ListBoxItemSize(*this, ItemDrawer()) );
       
   187     AknListBoxLayouts::SetupFormAntiFlickerTextCell(aListBox,
       
   188                                                     itemDrawer,
       
   189                                                     1,
       
   190                                                     AknLayoutScalable_Apps::list_single_graphic_popup_wml_pane_t1( ),
       
   191                                                     area[0],
       
   192                                                     area[1]);
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------
       
   196 // CBrowserPopupList::Draw()
       
   197 // ---------------------------------------------------------
       
   198 //
       
   199 void CBrowserPopupList::Draw(const TRect& /*aRect*/) const
       
   200     {
       
   201     TRect windowRect = this->Rect();
       
   202     CEikFormattedCellListBox::Draw( windowRect );
       
   203     return;
       
   204     }
       
   205 
       
   206 
       
   207 // ================= CBrowserAdaptiveListPopup =======================
       
   208 
       
   209 
       
   210 // ---------------------------------------------------------
       
   211 // CBrowserAdaptiveListPopup::CBrowserAdaptiveListPopup()
       
   212 // ---------------------------------------------------------
       
   213 //
       
   214 CBrowserAdaptiveListPopup::CBrowserAdaptiveListPopup( CEikEdwin* aGotoPaneEdit, 
       
   215         CCoeControl* aParent, TParentType aParentType, TBool aSearchFeature): 
       
   216         iEditor( aGotoPaneEdit ), iParent( aParent ),
       
   217         iParentType( aParentType ), iSearchFeature( aSearchFeature )
       
   218     {
       
   219     iTouchSupported = AknLayoutUtils::PenEnabled();
       
   220     }
       
   221 
       
   222 // ---------------------------------------------------------
       
   223 // CBrowserAdaptiveListPopup::ConstructL(const TRect& aRect)
       
   224 // EPOC two-phased constructor
       
   225 // ---------------------------------------------------------
       
   226 void CBrowserAdaptiveListPopup::ConstructL( )
       
   227     {
       
   228     CreateWindowL();
       
   229 //-------- list ------
       
   230     iList = new(ELeave) CBrowserPopupList( iParentType );
       
   231 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF
       
   232     iList->ConstructL( this , CEikListBox::EDisableItemSpecificMenu );
       
   233 #else
       
   234     iList->ConstructL( this , CEikListBox::ELeftDownInViewRect );
       
   235 #endif
       
   236     iList->SetContainerWindowL( *this );
       
   237     if (iTouchSupported)
       
   238         {
       
   239         iList->SetListBoxObserver( this );
       
   240         }
       
   241     iList->CreateScrollBarFrameL( ETrue );
       
   242     iList->SetMopParent(iParent);
       
   243     iList->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   244                                 CEikScrollBarFrame::EOff,
       
   245                                 CEikScrollBarFrame::EAuto);
       
   246     iList->ScrollBarFrame()->SetTypeOfVScrollBar( CEikScrollBarFrame::EDoubleSpan );
       
   247     iList->UpdateScrollBarsL();
       
   248     iList->SetBorder(TGulBorder::ESingleBlack);
       
   249     iList->ItemDrawer()->FormattedCellData()->EnableMarqueeL( ETrue );
       
   250 //---------- items storing arrays ---------
       
   251     iItems = new(ELeave) CDesCArrayFlat(KArrayGranularity);
       
   252     iItemNames = new(ELeave) CDesCArrayFlat(KArrayGranularity);
       
   253     iItemNamesToShow = new(ELeave) CDesCArrayFlat(KArrayGranularity);
       
   254 //---------- model ----------
       
   255     CTextListBoxModel* model = iList->Model();
       
   256     model->SetItemTextArray( iItemNamesToShow );
       
   257     model->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
   258 //---------- icons -----------
       
   259     SetIconsL();
       
   260 //--------- other --------
       
   261     iFirstGotoContent = KNullDesC().AllocL();
       
   262     iPrevGotoContent = KNullDesC().AllocL();
       
   263     iPoppedUp = EFalse;
       
   264     iDirectoryMode = ETrue;
       
   265     iOpenCBA=EFalse;
       
   266     iItemDrawer = iList->ItemDrawer();
       
   267     iPrevItem = -2;
       
   268     iUrlCompletionMode = EFalse;
       
   269     iRecentUrlStore = CBrowserAppUi::Static()->RecentUrlStore();
       
   270     if (!iRecentUrlStore)
       
   271         {
       
   272         User::Leave(KErrCouldNotConnect);
       
   273         }
       
   274     iListScrollTimer = CPeriodic::NewL(CActive::EPriorityIdle);
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------
       
   278 // CBrowserAdaptiveListPopup::~CBrowserAdaptiveListPopup()
       
   279 // Destructor
       
   280 // ---------------------------------------------------------
       
   281 CBrowserAdaptiveListPopup::~CBrowserAdaptiveListPopup()
       
   282     {
       
   283     delete iList;
       
   284     delete iItems;
       
   285     delete iItemNames;
       
   286     delete iItemNamesToShow;
       
   287     delete iPrevGotoContent;
       
   288     delete iFirstGotoContent;
       
   289     if(iListScrollTimer)
       
   290     {
       
   291     iListScrollTimer->Cancel();
       
   292     delete iListScrollTimer;
       
   293     }
       
   294 }
       
   295 
       
   296 // ---------------------------------------------------------
       
   297 // CBrowserAdaptiveListPopup::SetOrdinalPosition
       
   298 // ---------------------------------------------------------
       
   299 //
       
   300 void CBrowserAdaptiveListPopup::SetOrdinalPosition( TInt aPos )
       
   301     {
       
   302     Window().SetOrdinalPosition( aPos );
       
   303     }
       
   304 
       
   305 void CBrowserAdaptiveListPopup::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   306     {
       
   307     if (iList && iTouchSupported)
       
   308         {
       
   309         //using ComponentControl(0) instead of iList because need access to a
       
   310         //protected function
       
   311         ComponentControl(0)->HandlePointerEventL( aPointerEvent );
       
   312         }
       
   313     }
       
   314 
       
   315 void CBrowserAdaptiveListPopup::HandleListBoxEventL(CEikListBox* aListBox,TListBoxEvent aEventType)
       
   316     {
       
   317     if (iList && aListBox == iList && iTouchSupported)
       
   318         {
       
   319         switch (aEventType)
       
   320             {
       
   321             case MEikListBoxObserver::EEventItemDoubleClicked:
       
   322                 {
       
   323                 TKeyEvent keyEvent;
       
   324                 keyEvent.iModifiers = 0;
       
   325                 keyEvent.iRepeats = 0;
       
   326                 keyEvent.iCode = EKeyDevice3;
       
   327                 keyEvent.iScanCode = EStdKeyDevice3;
       
   328                 if ( iParentType == EBookmarksGotoPane )
       
   329                     {
       
   330                     CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKeyDown );
       
   331                     }
       
   332                 CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKey );
       
   333                 if ( iParentType == EBookmarksGotoPane )
       
   334                     {
       
   335                     CCoeEnv::Static()->SimulateKeyEventL( keyEvent, EEventKeyUp );
       
   336                     }
       
   337                 }
       
   338                 break;
       
   339             case  MEikListBoxObserver::EEventItemClicked:
       
   340 #ifdef BRDO_SINGLE_CLICK_ENABLED_FF                
       
   341             case  MEikListBoxObserver::EEventItemSingleClicked:      
       
   342 #endif                
       
   343                 HandleItemClickedL( aListBox );
       
   344                 break;
       
   345             default:
       
   346                 break;
       
   347             }
       
   348         }
       
   349     }
       
   350 
       
   351 void CBrowserAdaptiveListPopup::HandleItemClickedL( CEikListBox* aListBox )
       
   352     {
       
   353     //the first time
       
   354    if ( !iList->HighLightEnabled() )
       
   355        {
       
   356        iList->SetHighLight( ETrue );
       
   357 
       
   358        //save the original content
       
   359        if ( !iFirstGotoContent )
       
   360            {
       
   361            delete iFirstGotoContent;
       
   362            iFirstGotoContent = NULL;
       
   363            }
       
   364        iFirstGotoContent = iEditor->GetTextInHBufL();
       
   365        if ( !iFirstGotoContent )
       
   366            {
       
   367            iFirstGotoContent = KNullDesC().AllocL();
       
   368            }
       
   369        }
       
   370     TInt index = aListBox->CurrentItemIndex();
       
   371     index = iItems->Count() - index - 1;
       
   372     TPtrC16 item((*iItems)[ index ] );
       
   373     TPtrC rightSide;
       
   374 
       
   375     //cut the slash from the end if needed
       
   376     //permanent sollution until AHLE does not
       
   377     //solve this problem related to ID: TMCN-5TTRXV error
       
   378     if ( item[item.Length() - 1] != KSlash )
       
   379       {
       
   380       rightSide.Set( item.Left( item.Length() ) );
       
   381       }
       
   382     else
       
   383       {
       
   384       rightSide.Set( item.Left( item.Length() - 1 ) );
       
   385       }
       
   386     
       
   387     //if true then append the suffix(rightSide), to the
       
   388     //user-typed data
       
   389     //else just use the recent URLs text(rightSide) only
       
   390     if ( iUrlCompletionMode )
       
   391       {
       
   392       HBufC* currentCompletion = HBufC::NewLC(
       
   393           iFirstGotoContent->Des().Length() + rightSide.Length() + 1 );
       
   394       TPtr currentCompletionPtr = currentCompletion->Des();
       
   395     
       
   396       currentCompletionPtr.Copy( iFirstGotoContent->Des() );
       
   397       currentCompletionPtr.Append( rightSide );
       
   398       currentCompletionPtr.ZeroTerminate();
       
   399       iEditor->SetTextL( currentCompletion );
       
   400       iEditor->SetCursorPosL( currentCompletionPtr.Length(), EFalse );
       
   401       CleanupStack::PopAndDestroy( currentCompletion );
       
   402       }
       
   403     else
       
   404       {
       
   405       iEditor->SetTextL( &rightSide );
       
   406       iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   407       }
       
   408     iEditor->HandleTextChangedL();
       
   409     
       
   410     delete iPrevGotoContent;
       
   411     iPrevGotoContent = NULL;
       
   412     iPrevGotoContent = item.AllocL();
       
   413     iEditor->DrawNow();
       
   414     //change the CBA depending on whether the highlight is
       
   415     //on url or domain
       
   416     CBrowserAppUi::Static()->UpdateCbaL();
       
   417     }
       
   418 
       
   419 
       
   420 //------------------------------------------------------------------
       
   421 // CBrowserAdaptiveListPopup::ShowSingleItemPopupListWithGraphicsL(TBool aShowTitle)
       
   422 // shows "List pane for single item with graphic"
       
   423 //------------------------------------------------------------------
       
   424 void CBrowserAdaptiveListPopup::ShowPopupListL(TBool aRelayout)
       
   425     {
       
   426     TAknWindowLineLayout windowLineLayout;
       
   427     TAknWindowLineLayout windowLineLayoutTmp;
       
   428     TAknWindowLineLayout windowLineLayoutMain;
       
   429     TAknWindowLineLayout windowLineLayoutMainTmp;
       
   430     TAknWindowLineLayout windowLineLayoutLW;
       
   431     TAknWindowLineLayout windowLineLayoutLWTmp;
       
   432     TAknWindowLineLayout windowLineLayoutSLW;
       
   433     TAknWindowLineLayout windowLineLayoutSLWTmp;
       
   434     TAknLayoutRect layoutRect;
       
   435     TAknLayoutRect layoutMainRect;
       
   436     TAknLayoutRect layoutLWRect;
       
   437     TAknLayoutRect layoutSLWRect;
       
   438 
       
   439     //turn of the highlight
       
   440     iList->SetHighLight( EFalse );
       
   441     //clear arrays
       
   442     iItems->Reset();
       
   443     iItemNames->Reset();
       
   444     iItemNamesToShow->Reset();
       
   445 
       
   446     TInt offset;
       
   447     HBufC* newText;
       
   448     //get create and get the string from the edit field
       
   449     if ( iEditor->TextLength() > 0 )
       
   450         {
       
   451         newText = iEditor->GetTextInHBufL();
       
   452         CleanupStack::PushL( newText );
       
   453         //cut the protokolidentifier from the string
       
   454         offset = newText->Find( KProtocolIdentifier );
       
   455         if ( offset == KErrNotFound )
       
   456             {
       
   457             offset = newText->Length();
       
   458             }
       
   459         else
       
   460             {
       
   461             offset = newText->Length() - offset - 3;
       
   462             }
       
   463         }
       
   464     else
       
   465         {
       
   466              offset = 0;
       
   467              newText = KNullDesC().AllocLC();
       
   468         }
       
   469     TPtrC trimmedContent( newText->Right( offset ) );
       
   470     TBuf<KListLengthToShow> buf;
       
   471 
       
   472     //find out if the user typed a ".", if so, bring up the url completion list
       
   473     TInt periodPos = trimmedContent.LocateReverse( TChar(KPeriod) );
       
   474     if ((periodPos != KErrNotFound) && ((periodPos + 1) == trimmedContent.Length()))
       
   475         {
       
   476         //add the url completion entries to the popup list
       
   477         iUrlCompletionMode = ETrue;
       
   478         CreateURLCompletionListL();
       
   479         }
       
   480     else
       
   481         {
       
   482         iUrlCompletionMode = EFalse;
       
   483         //only include recent URLs if not including the url completion items
       
   484         iRecentUrlStore->GetData( *iItems, *iItemNames, trimmedContent );
       
   485         
       
   486         //sort alphabetically and...
       
   487         for(TInt i=0; i<iItems->Count(); i++)
       
   488             {
       
   489             for(TInt j=0; j<iItems->Count()-1; j++)
       
   490                 {
       
   491                     if ((*iItems)[j].CompareF((*iItems)[j+1]) > 0)
       
   492                     {  
       
   493                        RBuf tmp;
       
   494                        CleanupClosePushL(tmp);
       
   495                        tmp.Create((*iItems)[j]);
       
   496                        iItems->Delete(j);
       
   497                        iItems->InsertL( j+1, tmp );
       
   498                        tmp.Close();
       
   499                        tmp.Create((*iItemNames)[j]);
       
   500                        iItemNames->Delete(j);
       
   501                        iItemNames->InsertL( j+1, tmp );
       
   502                        CleanupStack::PopAndDestroy( &tmp );                   
       
   503                     }          
       
   504                 }
       
   505             }  
       
   506         //and move url with params i.e google.fi/m=q?xyz do the back of list
       
   507         TInt i = 0;                 //iterator
       
   508         TInt j = 0;                 //counter
       
   509         while (i < (iItems->Count()-1) && j < iItems->Count())
       
   510             {
       
   511                 TUriParser8 parser;
       
   512                 RBuf8 out;
       
   513                 CleanupClosePushL( out );
       
   514                 out.Create( (*iItems)[i].Length() );
       
   515                 RBuf in;
       
   516                 CleanupClosePushL( in );              
       
   517                 in.Create( (*iItems)[i] );
       
   518                 
       
   519                 CnvUtfConverter::ConvertFromUnicodeToUtf8(out, in );
       
   520                 
       
   521                 if (( parser.Parse( out ) == KErrNone ) &&       //if parse ok and 
       
   522                     ( parser.Extract( EUriPath ).Length() > 0 || //url contains path
       
   523                       parser.Extract( EUriQuery ).Length() > 0 )) //or query item
       
   524                     {
       
   525                     iItems->AppendL( (*iItems)[i] );//move item to back of the list
       
   526                     iItems->Delete( i );
       
   527                     iItemNames->AppendL( (*iItemNames)[i] );
       
   528                     iItemNames->Delete( i );
       
   529                     }
       
   530                 else
       
   531                     {
       
   532                     i++;
       
   533                     }
       
   534                 j++;
       
   535                 
       
   536                 CleanupStack::PopAndDestroy( &in );
       
   537                 CleanupStack::PopAndDestroy( &out );
       
   538             };   
       
   539             
       
   540 
       
   541         }
       
   542     iDirectoryMode = EFalse;
       
   543     CleanupStack::PopAndDestroy();//newText
       
   544     TInt k;
       
   545     k = iItems->Count();
       
   546     iItemNo = k;
       
   547     TInt length = KListLengthToShow - 2;
       
   548     if ( k > 0 )
       
   549         {
       
   550         TInt j;
       
   551         TPtrC textToShow;
       
   552         TPtrC itemJ;
       
   553         //changeing the order
       
   554         for (j=k-1; j>-1; j--)
       
   555             {
       
   556             itemJ.Set( (*iItems)[j] );
       
   557             textToShow.Set( itemJ.Left( length ) );
       
   558             if ( iDirectoryMode )
       
   559                 {
       
   560             //directories and items
       
   561                 if ( itemJ[ itemJ.Length() - 1 ] == KSlash )
       
   562                     {
       
   563                 //item
       
   564                     buf.Format( _L( "%S%S" ), &KItemTab, &textToShow );
       
   565                     }
       
   566                 else
       
   567                     {
       
   568                     //directory
       
   569                     buf.Format( _L( "%S%S" ), &KDirTab, &textToShow );
       
   570                     }
       
   571                 }
       
   572             else
       
   573                 {
       
   574             //items only
       
   575                 buf.Format( _L( "%S%S" ), &KItemTab, &textToShow );
       
   576                 }
       
   577             iItemNamesToShow->AppendL( buf );
       
   578             }
       
   579         //set how many item will be shown
       
   580         
       
   581 #ifdef BRDO_TOUCH_ENABLED_FF        
       
   582         TInt appWidth = iEikonEnv->EikAppUi()->ApplicationRect().Width();
       
   583         TInt appHeight = iEikonEnv->EikAppUi()->ApplicationRect().Height();
       
   584         //For landscape mode only 5 items can be shown on the screen
       
   585         if(appWidth > appHeight) 
       
   586             iMaxRecentUrlsToShow = KLandscapeListItems;
       
   587 #endif     
       
   588         TInt itemstoshow;
       
   589         if ( k >  iMaxRecentUrlsToShow)
       
   590             {
       
   591             itemstoshow = iMaxRecentUrlsToShow;
       
   592             }
       
   593         else
       
   594             {
       
   595             itemstoshow = k;
       
   596             }
       
   597         //resetting to original value
       
   598         iMaxRecentUrlsToShow = CBrowserAppUi::Static()->ContentView()->ApiProvider().Preferences().MaxRecentUrls(); 
       
   599         
       
   600         //set the main rect of the window
       
   601         // fixing bug RFON-7E2PPV, don't use ApplicationRect()
       
   602         TRect  rect;
       
   603         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
       
   604         windowLineLayoutMain = AknLayout::main_pane( rect, 0, 2, 1 );
       
   605         windowLineLayoutMainTmp = windowLineLayoutMain;
       
   606         layoutMainRect.LayoutRect( rect, windowLineLayoutMainTmp );
       
   607 
       
   608       
       
   609         windowLineLayoutLW = AppLayout::popup_wml_address_window( 1, itemstoshow );
       
   610       
       
   611         windowLineLayoutLWTmp = windowLineLayoutLW;
       
   612         layoutLWRect.LayoutRect( layoutMainRect.Rect(), windowLineLayoutLWTmp );
       
   613         windowLineLayoutSLW = AknLayoutScalable_Apps::listscroll_popup_wml_pane();
       
   614         windowLineLayoutSLWTmp = windowLineLayoutSLW;
       
   615         layoutSLWRect.LayoutRect( layoutLWRect.Rect(), windowLineLayoutSLWTmp );
       
   616         windowLineLayout = AppLayout::list_wml_pane( itemstoshow - 1 );
       
   617         windowLineLayoutTmp = windowLineLayout;
       
   618         layoutRect.LayoutRect( layoutLWRect.Rect(), windowLineLayoutTmp );
       
   619 
       
   620         TRect rectTemp(layoutSLWRect.Rect());
       
   621         // force listbox on top of goto pane
       
   622         rectTemp.iBr.iY = iParent->PositionRelativeToScreen().iY;
       
   623         rectTemp.iTl.iX = iParent->PositionRelativeToScreen().iX;
       
   624         // shrink list box to size of list  
       
   625 #ifdef BRDO_TOUCH_ENABLED_FF
       
   626         TInt listH = KListHeight;
       
   627 #else
       
   628         TInt listH = AppLayout::list_single_graphic_popup_wml_pane( 0 ).iH;
       
   629 #endif
       
   630         rectTemp.iTl.iY =  rectTemp.iBr.iY - (listH * itemstoshow);
       
   631         // set bottom right x axis to full width
       
   632         rectTemp.iBr.iX = rect.iBr.iX;
       
   633         
       
   634         // we only want to call SetRect() when we have a relayout, otherwise just
       
   635         // scroll the list to the correct position. Doing this will reduce the amount
       
   636         // of flicker seen while typing into the gotopane
       
   637         if ((rectTemp.Size() != Rect().Size()) || aRelayout)
       
   638             {
       
   639             //set the window rect
       
   640             SetRect( rectTemp );
       
   641             }
       
   642         rectTemp = TRect( 0, 0, Rect().Width(), Rect().Height() );
       
   643         if ( rectTemp!=iList->Rect() )
       
   644             {
       
   645             //set the rect of the list
       
   646             iList->SetRect( rectTemp );
       
   647             }
       
   648         else
       
   649             {
       
   650             // this scrolls list to the correct position, probably still does too much work
       
   651             AknListBoxLayouts::SetupListboxPos( *iList, AppLayout::list_single_graphic_popup_wml_pane( 0 ));
       
   652             }
       
   653         //the last item is visible
       
   654         //ScrollToMakeItemVisible scrolls only after some delay        
       
   655         if(!iListScrollTimer->IsActive())
       
   656             {
       
   657 	        iListScrollTimer->Start(20, 0, 
       
   658 	                TCallBack(ListScrollTimerCallBack, this));
       
   659             }
       
   660                 
       
   661 #ifdef BRDO_TOUCH_ENABLED_FF
       
   662         const CFont* pFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont);
       
   663         TFontSpec fontSpec = pFont->FontSpecInTwips();
       
   664         fontSpec.iHeight =KFontHeight; 
       
   665         
       
   666         CFont* fontNew;
       
   667         CEikonEnv::Static()->ScreenDevice()->GetNearestFontInTwips( ( CFont*&)fontNew, fontSpec );
       
   668         CFormattedCellListBoxData *pLBData = iList->ItemDrawer()->ColumnData();
       
   669         iList->SetItemHeightL(KListHeight);
       
   670         
       
   671         if(pLBData && pFont)
       
   672         {
       
   673             pLBData->SetSubCellFontL(1,fontNew);
       
   674         }        
       
   675         
       
   676         CEikonEnv::Static()->ScreenDevice()->ReleaseFont(fontNew);
       
   677 #endif        
       
   678         
       
   679         MakeVisible( ETrue );
       
   680         iPoppedUp = ETrue;
       
   681         DrawNow();
       
   682         iList->Draw(rectTemp);
       
   683         }
       
   684     else
       
   685         {
       
   686         MakeVisible( EFalse );
       
   687         iPoppedUp = EFalse;
       
   688         CBrowserAppUi::Static()->UpdateCbaL();
       
   689         }
       
   690     if (!IsActivated())
       
   691         {
       
   692         ActivateL();
       
   693         }
       
   694     iPrevItem = -2;
       
   695     }
       
   696 
       
   697 // ---------------------------------------------------------
       
   698 // CBrowserAdaptiveListPopup::CreateURLCompletionListL
       
   699 // ---------------------------------------------------------
       
   700 //
       
   701 void CBrowserAdaptiveListPopup::CreateURLCompletionListL()
       
   702     {
       
   703     _LIT(KSeparator, ",");
       
   704 
       
   705     if (iUrlSuffixBuf)
       
   706         {
       
   707         TPtrC urlSuffix(iUrlSuffixBuf->Des());
       
   708         TInt index(urlSuffix.FindF(KSeparator));
       
   709         TInt offset = 0;
       
   710 
       
   711         while (index != KErrNotFound)
       
   712             {
       
   713             // Omit empty string
       
   714             if (index > 0)
       
   715                 {
       
   716                 iItems->AppendL( urlSuffix.Mid(offset,index) );
       
   717                 }
       
   718 
       
   719             offset += (index + 1);
       
   720             TPtrC remainder(urlSuffix.Mid(offset));
       
   721             index = remainder.FindF(KSeparator);
       
   722             }
       
   723 
       
   724         // Cover the cases where we only have one suffix in the list and/or
       
   725         // the last suffix in the list does not have a comma
       
   726         if (offset < urlSuffix.Length())
       
   727             {
       
   728             TPtrC remainderB(urlSuffix.Mid(offset, urlSuffix.Length() - offset));
       
   729             iItems->AppendL( remainderB );
       
   730             }
       
   731         }
       
   732     }
       
   733 
       
   734 // ---------------------------------------------------------
       
   735 // CBrowserAdaptiveListPopup::HandleControlEventL
       
   736 // if the content of the edit box changes
       
   737 // ---------------------------------------------------------
       
   738 //
       
   739 void CBrowserAdaptiveListPopup::HandleControlEventL(CCoeControl* aControl,enum MCoeControlObserver::TCoeEvent aEventType)
       
   740     {
       
   741     CEikEdwin* edwin = ( CEikEdwin* )aControl;
       
   742     // the content of the edit box changes
       
   743     if ( MCoeControlObserver::EEventStateChanged == aEventType )
       
   744         {
       
   745         HBufC* newText = edwin->GetTextInHBufL();
       
   746         if (!newText)
       
   747             {
       
   748             newText = KNullDesC().AllocL();
       
   749             }
       
   750         CleanupStack::PushL( newText );
       
   751         //check whether the last content is different to the one in the editbox
       
   752         if ( !iPrevGotoContent || iPrevGotoContent->Compare( *newText ) )
       
   753             {
       
   754             ShowPopupListL();
       
   755             delete iPrevGotoContent;
       
   756             iPrevGotoContent = NULL;
       
   757             iPrevGotoContent = newText;
       
   758             CleanupStack::Pop( newText );//ownership is taken
       
   759             }
       
   760         else
       
   761             {
       
   762             if ( !iPrevGotoContent )
       
   763                 {
       
   764                 CleanupStack::PopAndDestroy( newText );
       
   765                 }
       
   766             else
       
   767                 {
       
   768                 ShowPopupListL();
       
   769                 delete iPrevGotoContent;
       
   770                 iPrevGotoContent = NULL;
       
   771                 iPrevGotoContent = newText;
       
   772                 CleanupStack::Pop( newText );//ownership is taken
       
   773                 }
       
   774             }
       
   775         //change the CBA
       
   776         if ( iOpenCBA )
       
   777             {
       
   778             iOpenCBA = EFalse;
       
   779             CBrowserAppUi::Static()->UpdateCbaL();
       
   780             }
       
   781         }
       
   782     }
       
   783 
       
   784 // ---------------------------------------------------------
       
   785 // CBrowserAdaptiveListPopup::CountComponentControls
       
   786 //
       
   787 // ---------------------------------------------------------
       
   788 //
       
   789 TInt CBrowserAdaptiveListPopup::CountComponentControls() const
       
   790     {
       
   791     if ( iList == NULL )
       
   792         {
       
   793         return 0;
       
   794         }
       
   795     return 1;
       
   796     }
       
   797 
       
   798 // ---------------------------------------------------------
       
   799 // CBrowserAdaptiveListPopup::ComponentControl
       
   800 //
       
   801 // ---------------------------------------------------------
       
   802 //
       
   803 CCoeControl* CBrowserAdaptiveListPopup::ComponentControl(TInt aIndex) const
       
   804     {
       
   805     if (aIndex==0)
       
   806         {
       
   807         return iList;
       
   808         }
       
   809     else
       
   810         {
       
   811         return NULL;
       
   812         }
       
   813     }
       
   814 
       
   815 // ---------------------------------------------------------
       
   816 // CBrowserAdaptiveListPopup::OfferKeyEventL
       
   817 // Handles key events
       
   818 // ---------------------------------------------------------
       
   819 //
       
   820 TKeyResponse CBrowserAdaptiveListPopup::OfferKeyEventL
       
   821 ( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   822     {
       
   823     TKeyResponse resp = EKeyWasNotConsumed;
       
   824     if (( iPoppedUp &&
       
   825     !CBrowserAppUi::Static()->ContentView()->MenuBar()->MenuPane()->IsVisible() &&
       
   826     (CBrowserAppUi::Static()->LastActiveViewId() == KUidBrowserContentViewId) ) || (( iPoppedUp ) &&
       
   827     (CBrowserAppUi::Static()->LastActiveViewId() != KUidBrowserContentViewId)))
       
   828         {
       
   829         TInt currIndex = iItems->Count() - iList->CurrentItemIndex() - 1;
       
   830 
       
   831         //the joystick is pressed
       
   832         if ( aKeyEvent.iCode == EKeyOK )
       
   833             {
       
   834             if ( ( iList->HighLightEnabled() )
       
   835               && ( iDirectoryMode )
       
   836               && ( (*iItems)[ currIndex ][(*iItems)[ currIndex ].Length() - 1] != KSlash ) )
       
   837                 {
       
   838                 SetDirectoryModeL( EFalse );
       
   839                 resp = EKeyWasConsumed;
       
   840                 }
       
   841             else
       
   842                 {
       
   843                 if (iEditor->TextLength()!=0)
       
   844                     {
       
   845                     HidePopupL();
       
   846                     }
       
   847                 }
       
   848             }
       
   849 
       
   850         //the joystick is pressed up
       
   851         else if (    aKeyEvent.iCode == EKeyLeftUpArrow      // Northwest
       
   852                   || aKeyEvent.iCode == EStdKeyDevice10      //   : Extra KeyEvent supports diagonal event simulator wedge
       
   853                   || aKeyEvent.iCode == EKeyUpArrow          // North
       
   854                   || aKeyEvent.iCode == EKeyRightUpArrow     // Northeast
       
   855                   || aKeyEvent.iCode == EStdKeyDevice11 )    //   : Extra KeyEvent supports diagonal event simulator wedge
       
   856             {
       
   857             resp = EKeyWasConsumed;
       
   858             //the first time
       
   859             if ( !iList->HighLightEnabled() )
       
   860                 {
       
   861                 iList->SetHighLight( ETrue );
       
   862                 currIndex = iList->Model()->NumberOfItems()-1;
       
   863                 iList->ScrollToMakeItemVisible( currIndex );
       
   864                 iList->SetCurrentItemIndex( currIndex );
       
   865                 DrawNow();
       
   866                 //save the original content
       
   867                 if ( iFirstGotoContent != NULL )
       
   868                     {
       
   869                     delete iFirstGotoContent;
       
   870                     iFirstGotoContent = NULL;
       
   871                     }
       
   872                 iFirstGotoContent = iEditor->GetTextInHBufL();
       
   873                 if (iFirstGotoContent == NULL)
       
   874                     {
       
   875                     iFirstGotoContent = KNullDesC().AllocL();
       
   876                     }
       
   877                 }
       
   878             else
       
   879                 {
       
   880                 if(  iSearchFeature )
       
   881                     {
       
   882                     if( iList->CurrentItemIndex() == 0 )
       
   883                         {
       
   884                         resp = EKeyWasConsumed;
       
   885                         return resp;
       
   886                         }
       
   887                     }
       
   888                 resp=iList->OfferKeyEventL( aKeyEvent, aType );
       
   889                 }
       
   890             if ( currIndex > -1 )
       
   891                 {
       
   892                 //copy the selected item to edit field
       
   893                 TPtrC16 item;
       
   894                 TPtrC rightSide;
       
   895                 TInt newIndex;
       
   896                 newIndex = iItems->Count() - iList->CurrentItemIndex() - 1;
       
   897                 item.Set( (*iItems)[ newIndex ] );
       
   898                 //cut the slash from the end if needed
       
   899                 //permanent sollution until AHLE does not
       
   900                 //solve this problem related to ID: TMCN-5TTRXV error
       
   901 
       
   902                 //if URL completion, then we want to append the item to the item in the edit field
       
   903                 if (iUrlCompletionMode)
       
   904                     {
       
   905                     TPtr16 ptr = iFirstGotoContent->Des();
       
   906 
       
   907                     HBufC* buf = HBufC::NewLC(ptr.Length() + item.Length() + 1);
       
   908 
       
   909                     buf->Des().Copy(ptr);
       
   910                     buf->Des().Append(item);
       
   911                     buf->Des().ZeroTerminate();
       
   912 
       
   913 
       
   914                     rightSide.Set(buf->Des());
       
   915 
       
   916                     iEditor->SetTextL( &rightSide );
       
   917                     iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   918 
       
   919                     CleanupStack::PopAndDestroy(); //buf
       
   920                     }
       
   921                 else
       
   922                     {
       
   923                     if ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash )
       
   924                         {
       
   925                         rightSide.Set( item.Left( item.Length() ) );
       
   926                         }
       
   927                     else
       
   928                         {
       
   929                         rightSide.Set( item.Left( item.Length() - 1 ) );
       
   930                         }
       
   931                     iEditor->SetTextL( &rightSide );
       
   932                     iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
   933                     }
       
   934                 delete iPrevGotoContent;
       
   935                 iPrevGotoContent = NULL;
       
   936                 iPrevGotoContent = item.AllocL();
       
   937                 iEditor->DrawNow();
       
   938                 //change the CBA depending on whether the highlight is
       
   939                 //on url or domain
       
   940                 if ( ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash ) && iDirectoryMode )
       
   941                     {
       
   942                     iOpenCBA = ETrue;
       
   943                     }
       
   944                 else
       
   945                     {
       
   946                     iOpenCBA = EFalse;
       
   947                     }
       
   948                 CBrowserAppUi::Static()->UpdateCbaL();
       
   949                 }
       
   950             }
       
   951 
       
   952         //the joystisk is pressed down
       
   953         else if (    aKeyEvent.iCode == EKeyLeftDownArrow    // Southwest
       
   954                   || aKeyEvent.iCode == EStdKeyDevice13      //   : Extra KeyEvent supports diagonal event simulator wedge
       
   955                   || aKeyEvent.iCode == EKeyDownArrow        // South
       
   956                   || aKeyEvent.iCode == EKeyRightDownArrow   // Southeast
       
   957                   || aKeyEvent.iCode == EStdKeyDevice12 )    //   : Extra KeyEvent supports diagonal event simulator wedge
       
   958             {
       
   959             resp = EKeyWasConsumed;
       
   960             if(  iSearchFeature )
       
   961                 {
       
   962                 if ( iPrevItem <= 0 )
       
   963                     {
       
   964                     if(! iList->HighLightEnabled() )
       
   965                         {
       
   966                         resp = EKeyWasNotConsumed;
       
   967                         return resp;
       
   968                         }
       
   969                     }
       
   970                 }
       
   971             //it was the last item
       
   972             if ( iPrevItem == 0 )
       
   973                 {
       
   974                 //write back the original string
       
   975                 iList->SetHighLight( EFalse );
       
   976                 iEditor->SetTextL( iFirstGotoContent );
       
   977                 iEditor->HandleTextChangedL();
       
   978                 iEditor->SetCursorPosL( iFirstGotoContent->Length(), EFalse );
       
   979                 delete iPrevGotoContent;
       
   980                 iPrevGotoContent = NULL;
       
   981                 iPrevGotoContent = iFirstGotoContent->AllocL();
       
   982                 iEditor->DrawNow();
       
   983                 DrawNow();
       
   984                 //change the CBA
       
   985                 if ( iOpenCBA )
       
   986                     {
       
   987                     iOpenCBA = EFalse;
       
   988                     CBrowserAppUi::Static()->UpdateCbaL();
       
   989                     }
       
   990                 return resp;
       
   991                 }
       
   992             else if ( ( currIndex > -1 ) && iList->HighLightEnabled() )
       
   993                 {
       
   994                 //write the selected items string to the editor
       
   995                 TPtrC16 item;
       
   996                 TPtrC rightSide;
       
   997                 TInt newIndex;
       
   998                 resp = iList->OfferKeyEventL( aKeyEvent, aType );
       
   999                 newIndex = iItems->Count() - iList->CurrentItemIndex() - 1;
       
  1000                 item.Set( (*iItems)[ newIndex ] );
       
  1001                 //cut the slash from the end if needed
       
  1002                 //permanent sollution until AHLE does not
       
  1003                 //solve this problem related to ID: TMCN-5TTRXV error
       
  1004                 if ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash )
       
  1005                     {
       
  1006                     rightSide.Set( item.Left( item.Length() ) );
       
  1007                     }
       
  1008                 else
       
  1009                     {
       
  1010                     rightSide.Set( item.Left( item.Length() - 1 ) );
       
  1011                     }
       
  1012 
       
  1013                 //if true then append the suffix (rightSide), to the
       
  1014                 //user-typed data
       
  1015                 //else just use the recent URLs text(rightSide) only
       
  1016                 if ( iUrlCompletionMode )
       
  1017                     {
       
  1018                     HBufC* currentCompletion = HBufC::NewLC(
       
  1019                         iFirstGotoContent->Des().Length() + rightSide.Length() + 1 );
       
  1020                     TPtr currentCompletionPtr = currentCompletion->Des();
       
  1021 
       
  1022                     currentCompletionPtr.Copy( iFirstGotoContent->Des() );
       
  1023                     currentCompletionPtr.Append( rightSide );
       
  1024                     currentCompletionPtr.ZeroTerminate();
       
  1025                     iEditor->SetTextL( currentCompletion );
       
  1026                     iEditor->SetCursorPosL( currentCompletionPtr.Length(), EFalse );
       
  1027                     CleanupStack::PopAndDestroy( currentCompletion );
       
  1028                     }
       
  1029                 else
       
  1030                     {
       
  1031                     iEditor->SetTextL( &rightSide );
       
  1032                     iEditor->SetCursorPosL( rightSide.Length(), EFalse );
       
  1033                     }
       
  1034                 iEditor->HandleTextChangedL();
       
  1035 
       
  1036                 if ( iPrevGotoContent != NULL )
       
  1037                     {
       
  1038                     delete iPrevGotoContent;
       
  1039                     iPrevGotoContent = NULL;
       
  1040                     }
       
  1041                 iPrevGotoContent = item.AllocL();
       
  1042                 iEditor->DrawNow();
       
  1043                 //change the CBA depending on whether the highlight is
       
  1044                 //on url or domain
       
  1045                 if ( ( (*iItems)[ newIndex ][(*iItems)[ newIndex ].Length() - 1] != KSlash ) && iDirectoryMode )
       
  1046                     {
       
  1047                     iOpenCBA = ETrue;
       
  1048                     }
       
  1049                 else
       
  1050                     {
       
  1051                     iOpenCBA = EFalse;
       
  1052                     }
       
  1053                 CBrowserAppUi::Static()->UpdateCbaL();
       
  1054                 }
       
  1055             }
       
  1056 
       
  1057         if ( iList->HighLightEnabled() )
       
  1058             {
       
  1059             iPrevItem = currIndex;
       
  1060             }
       
  1061         }
       
  1062     return resp;
       
  1063     }
       
  1064 
       
  1065 
       
  1066 // ---------------------------------------------------------
       
  1067 // CBrowserAdaptiveListPopup::HidePopupL
       
  1068 // Hides the popup list
       
  1069 // ---------------------------------------------------------
       
  1070 //
       
  1071 void CBrowserAdaptiveListPopup::HidePopupL()
       
  1072     {
       
  1073     //clear the lists
       
  1074     if ( iPoppedUp )
       
  1075         {
       
  1076         HBufC* newText = HBufC::NewLC( iEditor->TextLength() );
       
  1077         TPtr newTextDes = newText->Des();
       
  1078         iEditor->GetText( newTextDes );
       
  1079         iEditor->ClearSelectionL();
       
  1080         iEditor->SetTextL( newText );
       
  1081         iEditor->SetCursorPosL( iEditor->TextLength(), EFalse );
       
  1082         CleanupStack::PopAndDestroy( newText );
       
  1083         iItemNames->Reset();
       
  1084         iList->Reset();
       
  1085         if (!IsActivated())
       
  1086             {
       
  1087             ActivateL();
       
  1088             }
       
  1089         MakeVisible(EFalse);
       
  1090         DrawNow();
       
  1091         iPrevItem = -2;
       
  1092         iPoppedUp = EFalse;
       
  1093         // highlight a directory, cancel goto pane
       
  1094         // activate goto pane again -> softkey problem
       
  1095         iOpenCBA = EFalse;
       
  1096         CBrowserAppUi::Static()->UpdateCbaL();
       
  1097         }
       
  1098     }
       
  1099 
       
  1100 // ---------------------------------------------------------
       
  1101 // CBrowserAdaptiveListPopup::IsInDirectoryMode
       
  1102 // gives back the directory mode
       
  1103 // ---------------------------------------------------------
       
  1104 //
       
  1105 TBool CBrowserAdaptiveListPopup::IsInDirectoryMode()
       
  1106     {
       
  1107     return iDirectoryMode;
       
  1108     }
       
  1109 
       
  1110 // ---------------------------------------------------------
       
  1111 // CBrowserAdaptiveListPopup::SetDirectoryMode
       
  1112 // Sets the directory mode
       
  1113 // ---------------------------------------------------------
       
  1114 //
       
  1115 void CBrowserAdaptiveListPopup::SetDirectoryModeL(TBool aDirMode)
       
  1116     {
       
  1117     iDirectoryMode = aDirMode;
       
  1118     if ( aDirMode == EFalse )
       
  1119         {
       
  1120         //put the slash to the back of the editor fileds string
       
  1121         //it will show the directory mode
       
  1122         TInt length;
       
  1123         length = iEditor->TextLength() + 1;
       
  1124         HBufC* newText = HBufC::NewLC( length );
       
  1125         TPtr newTextDes = newText->Des();
       
  1126         iEditor->GetText( newTextDes );
       
  1127         newTextDes.Append( TChar(KSlash) );
       
  1128         iEditor->SetTextL( newText );
       
  1129         iEditor->SetCursorPosL( length, EFalse );
       
  1130         CleanupStack::PopAndDestroy( newText );
       
  1131         iEditor->DrawNow();
       
  1132         ShowPopupListL();
       
  1133         //change the CBA
       
  1134         if ( iOpenCBA )
       
  1135             {
       
  1136             iOpenCBA = EFalse;
       
  1137             CBrowserAppUi::Static()->UpdateCbaL();
       
  1138             }
       
  1139         }
       
  1140     return;
       
  1141     }
       
  1142 
       
  1143 // ---------------------------------------------------------
       
  1144 // CBrowserAdaptiveListPopup::IsOpenDirToShow
       
  1145 // Show which CBA is about to show
       
  1146 // ---------------------------------------------------------
       
  1147 //
       
  1148 TBool CBrowserAdaptiveListPopup::IsOpenDirToShow()
       
  1149 {
       
  1150     return iOpenCBA;
       
  1151 }
       
  1152 
       
  1153 // ---------------------------------------------------------
       
  1154 // CBrowserAdaptiveListPopup::IsPoppedUp
       
  1155 // Show whether the list is popped up or not
       
  1156 // ---------------------------------------------------------
       
  1157 //
       
  1158 TBool CBrowserAdaptiveListPopup::IsPoppedUp()
       
  1159 {
       
  1160     return iPoppedUp;
       
  1161 }
       
  1162 
       
  1163 
       
  1164 // ---------------------------------------------------------
       
  1165 // CBrowserAdaptiveListPopup::HandleResourceChange
       
  1166 // If new skin is set the icons will be reloaded
       
  1167 // ---------------------------------------------------------
       
  1168 //
       
  1169 void CBrowserAdaptiveListPopup::HandleResourceChange( TInt aType )
       
  1170     {
       
  1171     TRAP_IGNORE( HandleResourceChangeL( aType ) );
       
  1172     }
       
  1173 
       
  1174 // ---------------------------------------------------------
       
  1175 // CBrowserAdaptiveListPopup::HandleResourceChangeL
       
  1176 // If new skin is set the icons will be reloaded
       
  1177 // ---------------------------------------------------------
       
  1178 //
       
  1179 void CBrowserAdaptiveListPopup::HandleResourceChangeL( TInt aType )
       
  1180     {
       
  1181     if (( aType == KAknsMessageSkinChange )||
       
  1182        ( aType == KEikDynamicLayoutVariantSwitch ) )
       
  1183         {
       
  1184         CArrayPtr<CGulIcon>* array =
       
  1185                             iList->ItemDrawer()->ColumnData()->IconArray();
       
  1186 
       
  1187         array->ResetAndDestroy();
       
  1188         delete array;
       
  1189         SetIconsL();
       
  1190         }
       
  1191 
       
  1192     CCoeControl::HandleResourceChange(aType);
       
  1193     if (aType == KEikDynamicLayoutVariantSwitch)
       
  1194         {
       
  1195         TRect  rect;
       
  1196         if (AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect))
       
  1197             {
       
  1198             SetRect(rect);
       
  1199             }
       
  1200         }
       
  1201 
       
  1202     if ( ( aType == KEikDynamicLayoutVariantSwitch ) && ( iPoppedUp ) )
       
  1203         {
       
  1204 
       
  1205         if ( AknLayoutUtils::PenEnabled() )
       
  1206             {
       
  1207             SetOrdinalPosition( 0 );
       
  1208             }
       
  1209 
       
  1210         TInt selectionIndex = -1;
       
  1211         HBufC* originalText = NULL;
       
  1212         TInt popitem( 0 );
       
  1213         if ( iList->HighLightEnabled() )
       
  1214             {
       
  1215             selectionIndex = iList->CurrentItemIndex();
       
  1216             //save the editors content
       
  1217             originalText = iEditor->GetTextInHBufL();
       
  1218             if (originalText == NULL)
       
  1219                 {
       
  1220                 originalText = KNullDesC().AllocL();
       
  1221                 }
       
  1222             CleanupStack::PushL( originalText );
       
  1223             ++popitem;
       
  1224             //write back the first string
       
  1225             iEditor->SetTextL( iFirstGotoContent );
       
  1226             iEditor->HandleTextChangedL();
       
  1227             }
       
  1228         ShowPopupListL(ETrue);
       
  1229         if ( selectionIndex > -1)
       
  1230             {
       
  1231             iEditor->SetTextL( originalText );
       
  1232             iEditor->SetCursorPosL( originalText->Length(), EFalse );
       
  1233             iEditor->HandleTextChangedL();
       
  1234             iList->SetHighLight( ETrue );
       
  1235             iList->ScrollToMakeItemVisible( selectionIndex );
       
  1236             iList->SetCurrentItemIndex( selectionIndex );
       
  1237             DrawNow();
       
  1238             iEditor->DrawNow();
       
  1239             }
       
  1240         if ( popitem )
       
  1241             {
       
  1242             CleanupStack::PopAndDestroy( popitem );  // originalText
       
  1243             }
       
  1244         }
       
  1245     }
       
  1246 
       
  1247 // ---------------------------------------------------------
       
  1248 // CBrowserAdaptiveListPopup::SetIconsL()
       
  1249 // ---------------------------------------------------------
       
  1250 //
       
  1251 void CBrowserAdaptiveListPopup::SetIconsL()
       
  1252 {
       
  1253     CArrayPtr<CGulIcon>* icons =
       
  1254     new(ELeave) CAknIconArray( KMaxIcons );
       
  1255     CleanupStack::PushL(icons); // PUSH Icon
       
  1256     CGulIcon* newIcon;
       
  1257     CFbsBitmap *newIconBmp;
       
  1258     CFbsBitmap *newIconMaskBmp;
       
  1259 
       
  1260     TParse* fp = new(ELeave) TParse();
       
  1261     CleanupStack::PushL(fp);
       
  1262     TInt err = fp->Set(KBrowserDirAndFile, &KDC_APP_BITMAP_DIR, NULL);
       
  1263     if (err != KErrNone)
       
  1264         {
       
  1265         User::Leave(err);
       
  1266         }
       
  1267     TBuf<KMaxFileName> iconFile= fp->FullName();
       
  1268     CleanupStack::PopAndDestroy(fp);
       
  1269 
       
  1270     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
  1271     AknsUtils::CreateIconLC( skinInstance,
       
  1272                                            KAknsIIDQgnPropWmlFolderAdap,
       
  1273                                            newIconBmp,
       
  1274                                            newIconMaskBmp,
       
  1275                                            iconFile,
       
  1276                                            EMbmBrowserQgn_prop_wml_folder_adap,
       
  1277                                            EMbmBrowserQgn_prop_wml_folder_adap_mask);
       
  1278     newIcon = CGulIcon::NewL( newIconBmp, newIconMaskBmp);
       
  1279     CleanupStack::Pop(2);
       
  1280     CleanupStack::PushL(newIcon);
       
  1281     icons->AppendL( newIcon );
       
  1282     CleanupStack::Pop(newIcon);
       
  1283     AknsUtils::CreateIconLC( skinInstance,
       
  1284                                            KAknsIIDQgnPropWmlBmAdap,
       
  1285                                            newIconBmp,
       
  1286                                            newIconMaskBmp,
       
  1287                                            iconFile,
       
  1288                                            EMbmBrowserQgn_prop_wml_bm_adap,
       
  1289                                            EMbmBrowserQgn_prop_wml_bm_adap_mask);
       
  1290     newIcon = CGulIcon::NewL( newIconBmp, newIconMaskBmp);
       
  1291     CleanupStack::Pop(2);
       
  1292     CleanupStack::PushL(newIcon);
       
  1293     icons->AppendL( newIcon );
       
  1294     CleanupStack::Pop(newIcon);
       
  1295     iList->ItemDrawer()->FormattedCellData()->SetIconArrayL(icons);
       
  1296     CleanupStack::Pop();    // POP Icon
       
  1297 }
       
  1298 
       
  1299 // ---------------------------------------------------------
       
  1300 // CBrowserAdaptiveListPopup::SetUrlSuffixList()
       
  1301 // ---------------------------------------------------------
       
  1302 //
       
  1303 void CBrowserAdaptiveListPopup::SetUrlSuffixList(HBufC* urlSuffixList)
       
  1304     {
       
  1305     iUrlSuffixBuf = urlSuffixList;
       
  1306     }
       
  1307 
       
  1308 // ---------------------------------------------------------
       
  1309 // CBrowserAdaptiveListPopup::SetMaxRecentUrls()
       
  1310 // ---------------------------------------------------------
       
  1311 //
       
  1312 void CBrowserAdaptiveListPopup::SetMaxRecentUrls (TInt maxRecentUrls)
       
  1313     {
       
  1314     iMaxRecentUrlsToShow = maxRecentUrls;
       
  1315     }
       
  1316 
       
  1317 TInt CBrowserAdaptiveListPopup::ListScrollTimerCallBack(TAny* aAny)
       
  1318     {
       
  1319     CBrowserAdaptiveListPopup* self = static_cast<CBrowserAdaptiveListPopup*>( aAny ); 
       
  1320     self->DoListScrolling();    
       
  1321     self->iListScrollTimer->Cancel();
       
  1322     return KErrNone;
       
  1323     }
       
  1324  
       
  1325 void CBrowserAdaptiveListPopup::DoListScrolling()
       
  1326     {
       
  1327     iList->ScrollToMakeItemVisible( iList->Model()->NumberOfItems()-1 );
       
  1328     }
       
  1329 
       
  1330 // End of File