emailuis/uicomponents/src/fsfastaddressinglist.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 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 "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:  Implementation of CFsFastAddressingList class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //<cmail> removed __FS_ALFRED_SUPPORT flag (other places in this file not tagged!)
       
    20 /*#include <fsconfig.h>
       
    21 #ifdef __FS_ALFRED_SUPPORT*/
       
    22 #include "emailtrace.h"
       
    23 #include <alf/alfevent.h>
       
    24 /*#else // !__FS_ALFRED_SUPPORT
       
    25 #include <hitchcock.h>
       
    26 #endif // __FS_ALFRED_SUPPORT*/
       
    27 //<cmail> removed __FS_ALFRED_SUPPORT flag (other places in this file not tagged!)
       
    28 #include <txtrich.h>
       
    29 
       
    30 #include "fsfastaddressinglist.h"
       
    31 #include "fsfastaddressinglistobserver.h"
       
    32 #include "fstreelist.h"
       
    33 #include "fstreevisualizerbase.h"
       
    34 #include "fstextinputfield.h"
       
    35 #include "fsfastaddressingvisualizer.h"
       
    36 #include "fstreeplainonelineitemdata.h"
       
    37 #include "fstreeplainonelineitemvisualizer.h"
       
    38 #include "fstreeitemdata.h"
       
    39 // ======== MEMBER FUNCTIONS ========
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // Constructor
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CFsFastAddressingList::CFsFastAddressingList( CAlfEnv& /*aEnv*/,
       
    46     MFsFastAddressingListObserver& aObserver ) :
       
    47     iObserver( aObserver )
       
    48     {
       
    49     FUNC_LOG;
       
    50     //No implementation nedeed
       
    51     }
       
    52 
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Two phased constructor
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CFsFastAddressingList::ConstructL( CAlfEnv& aEnv )
       
    59     {
       
    60     FUNC_LOG;
       
    61     CAlfControl::ConstructL( aEnv );
       
    62     iTextInputField = CFsTextInputField::NewL( *this );
       
    63     iTextInputField->ActivateL();
       
    64     iVisualizer = CFsFastAddressingVisualizer::NewL( *this, *iTextInputField );
       
    65 /*
       
    66     iTreeVisualizer = CFsTreeVisualizerBase::NewL( this,
       
    67                                   *iVisualizer->GetMainLayout() );
       
    68 
       
    69     iTreeList = CFsTreeList::NewL( *iTreeVisualizer,
       
    70                                    Env() );
       
    71 */
       
    72 //    iTreeList->SetLooping( ETrue );
       
    73 
       
    74     iTextInputField->SetFocus( ETrue );
       
    75     iVisualizer->SetTextFieldVisible( ETrue );
       
    76     iTextInputField->MakeVisible( ETrue );
       
    77     }
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // Two phased constructor
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 EXPORT_C CFsFastAddressingList* CFsFastAddressingList::NewL( CAlfEnv& aEnv,
       
    84     MFsFastAddressingListObserver& aObserver )
       
    85     {
       
    86     FUNC_LOG;
       
    87     CFsFastAddressingList* self =
       
    88              new ( ELeave ) CFsFastAddressingList( aEnv, aObserver );
       
    89     CleanupStack::PushL( self );
       
    90     self->ConstructL( aEnv );
       
    91     CleanupStack::Pop( self );
       
    92     return self;
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // Destructor
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 CFsFastAddressingList::~CFsFastAddressingList()
       
   100     {
       
   101     FUNC_LOG;
       
   102     delete iVisualizer;
       
   103     delete iTreeList;
       
   104     delete iTextInputField;
       
   105 
       
   106     iPlainItemDataArr.ResetAndDestroy();
       
   107     iPlainItemDataArr.Close();
       
   108     iPlainItemVisualizerArr.ResetAndDestroy();
       
   109     iPlainItemVisualizerArr.Close();
       
   110     }
       
   111 
       
   112 // ---------------------------------------------------------------------------
       
   113 // Loads image from file and sets texture for icon
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C void CFsFastAddressingList::SetIconL( const TIconID aIconID,
       
   117     const TDesC& aFilename )
       
   118     {
       
   119     FUNC_LOG;
       
   120     if ( aIconID == EIconA )
       
   121         {
       
   122 #pragma message( "Unigue number needed" )
       
   123         const TInt KFsUniqueId = 12345; // Number should be unique inside the application.
       
   124         iIconA.SetTexture( Env().TextureManager().LoadTextureL( 
       
   125             aFilename, TSize( 0, 0 ),  EAlfTextureFlagDefault, KFsUniqueId ) );
       
   126         iVisualizer->SetIcon( aIconID, iIconA );
       
   127         }
       
   128     else if ( aIconID == EIconB )
       
   129         {
       
   130 #pragma message( "Unigue number needed" )
       
   131         const TInt KFsUniqueId = 123456; // Number should be unique inside the application.
       
   132         iIconB.SetTexture( Env().TextureManager().LoadTextureL( 
       
   133             aFilename, TSize( 0, 0 ),  EAlfTextureFlagDefault, KFsUniqueId ) );
       
   134         iVisualizer->SetIcon( aIconID, iIconB );
       
   135         }
       
   136     }
       
   137 
       
   138 
       
   139 // ---------------------------------------------------------------------------
       
   140 // Creates texture from bitmap and sets icon.
       
   141 // ---------------------------------------------------------------------------
       
   142 //
       
   143 EXPORT_C void CFsFastAddressingList::SetIconL( const TIconID aIconID,
       
   144     const CFbsBitmap* aBitmap )
       
   145     {
       
   146     FUNC_LOG;
       
   147     if (aIconID == EIconA)
       
   148         {
       
   149         CAlfTexture& texture = Env().TextureManager().BlankTexture();
       
   150 #pragma message( "Investigation needed" )
       
   151         //texture.UploadL( *aBitmap );
       
   152         iIconA.SetTexture( texture );
       
   153         iVisualizer->SetIcon( aIconID, iIconA );
       
   154         }
       
   155     else if ( aIconID == EIconB )
       
   156         {
       
   157         CAlfTexture& texture = Env().TextureManager().BlankTexture();
       
   158 #pragma message( "Investigation needed" )
       
   159         //texture.UploadL( *aBitmap );
       
   160         iIconB.SetTexture( texture );
       
   161         iVisualizer->SetIcon( aIconID, iIconB );
       
   162         }
       
   163     }
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // Controls visibility of the icon
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 EXPORT_C void CFsFastAddressingList::SetIconVisible( const TIconID aIconID,
       
   170     const TBool aVisible )
       
   171     {
       
   172     FUNC_LOG;
       
   173     iVisualizer->SetIconVisible( aIconID, aVisible );
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // Returns visibility of the icon
       
   178 // ---------------------------------------------------------------------------
       
   179 //
       
   180 EXPORT_C TBool CFsFastAddressingList::IconVisible(
       
   181     const TIconID /*aIconID */) const
       
   182     {
       
   183     FUNC_LOG;
       
   184    
       
   185     return ETrue;
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------------------------
       
   189 // Controls atomic mode of text input field.
       
   190 // ---------------------------------------------------------------------------
       
   191 //
       
   192 EXPORT_C void CFsFastAddressingList::SetTextInputFieldAtomic(
       
   193     const TBool aAtomic)
       
   194     {
       
   195     FUNC_LOG;
       
   196     if (aAtomic)
       
   197         {
       
   198         iTextInputField->SetTextInputMode(
       
   199             CFsTextInputField::EAtomicInput );
       
   200         }
       
   201     else
       
   202         {
       
   203         iTextInputField->SetTextInputMode(
       
   204             CFsTextInputField::ENotAtomicInput );
       
   205         }
       
   206     }
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // Resturns state of atomic mode of the text input field.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 EXPORT_C TBool CFsFastAddressingList::TextInputFieldAtomic() const
       
   213     {
       
   214     FUNC_LOG;
       
   215     return (iTextInputField->TextInputMode() ==
       
   216         CFsTextInputField::EAtomicInput);
       
   217     }
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // Controls read only mode of text input field.
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C void CFsFastAddressingList::SetTextInputFieldReadOnly(
       
   224     const TBool aReadOnly)
       
   225     {
       
   226     FUNC_LOG;
       
   227     iTextInputField->SetReadOnly( aReadOnly );
       
   228     }
       
   229 
       
   230 // ---------------------------------------------------------------------------
       
   231 // Returns status of the read only mode of the text input field
       
   232 // ---------------------------------------------------------------------------
       
   233 //
       
   234 EXPORT_C TBool CFsFastAddressingList::TextInputFieldReadOnly() const
       
   235     {
       
   236     FUNC_LOG;
       
   237     return iTextInputField->IsReadOnly();
       
   238     }
       
   239 
       
   240 // ---------------------------------------------------------------------------
       
   241 // Sets content of the text input field
       
   242 // ---------------------------------------------------------------------------
       
   243 //
       
   244 EXPORT_C void CFsFastAddressingList::SetTextFieldContentsL(
       
   245     const TDesC& aText )
       
   246     {
       
   247     FUNC_LOG;
       
   248     iTextInputField->SetCursorPosL(
       
   249      0, EFalse );
       
   250     iTextInputField->SetTextL( &aText );
       
   251     iTextInputField->SetCursorPosL(
       
   252      aText.Length(), EFalse );
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 // Returns content of the text input field
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 EXPORT_C void CFsFastAddressingList::TextFieldContents( TDes& aText ) const
       
   260     {
       
   261     FUNC_LOG;
       
   262     iTextInputField->GetText( aText );
       
   263     }
       
   264 
       
   265 // ---------------------------------------------------------------------------
       
   266 // Controls visibility of the text input field
       
   267 // ---------------------------------------------------------------------------
       
   268 //
       
   269 EXPORT_C void CFsFastAddressingList::SetTextFieldVisibile(
       
   270     const TBool aVisibility )
       
   271     {
       
   272     FUNC_LOG;
       
   273     iVisualizer->SetTextFieldVisible( aVisibility );
       
   274     iTextInputField->MakeVisible( aVisibility );
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // Returns status of the visibility of the text input field.
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 EXPORT_C TBool CFsFastAddressingList::IsTextFieldVisible() const
       
   282     {
       
   283     FUNC_LOG;
       
   284     return iVisualizer->IsTextFieldVisible();
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // Controls visility of the tree list
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C void CFsFastAddressingList::SetListVisibility(
       
   292     const TBool /*aVisible*/)
       
   293     {
       
   294     FUNC_LOG;
       
   295     
       
   296     }
       
   297 
       
   298 // ---------------------------------------------------------------------------
       
   299 // Returns visibility status of the tree list
       
   300 // ---------------------------------------------------------------------------
       
   301 //
       
   302 EXPORT_C TBool CFsFastAddressingList::ListVisibile() const
       
   303     {
       
   304     FUNC_LOG;
       
   305     
       
   306     return ETrue;
       
   307     }
       
   308 
       
   309 // ---------------------------------------------------------------------------
       
   310 // Copies items from array to the list. Previous itemset of the list is
       
   311 // cleared
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 EXPORT_C void CFsFastAddressingList::SetListItemsL(
       
   315     const RPointerArray<HBufC>& aItemTexts)
       
   316     {
       
   317     FUNC_LOG;
       
   318     //====== Uncomment these lines when the method RemoveAll
       
   319     //             will be implemented
       
   320     //iTreeList->RemoveAll();
       
   321     //iPlainItemDataArr.ResetAndDestroy();
       
   322     //iPlainItemVisualizerArr.ResetAndDestroy();
       
   323     for ( TInt item = 0 ; item < aItemTexts.Count() ; item++ )
       
   324         {
       
   325         CFsTreePlainOneLineItemData* plainItemData;
       
   326         MFsTreeItemVisualizer* plainItemVisualizer;
       
   327         plainItemData = CFsTreePlainOneLineItemData::NewL( );
       
   328         plainItemData->SetDataL( *aItemTexts[item] );
       
   329         plainItemVisualizer = CFsTreePlainOneLineItemVisualizer::NewL(
       
   330             *iTreeList->TreeControl() );
       
   331         iTreeList->InsertItemL( *plainItemData,
       
   332                                 *plainItemVisualizer,
       
   333                                 KFsTreeRootID );
       
   334         iPlainItemDataArr.AppendL( plainItemData );
       
   335         iPlainItemVisualizerArr.AppendL( plainItemVisualizer );
       
   336         }
       
   337     }
       
   338 
       
   339 // ---------------------------------------------------------------------------
       
   340 // Add passed item to the List.
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 EXPORT_C void CFsFastAddressingList::AddListItemL( const TDesC& aItemText )
       
   344     {
       
   345     FUNC_LOG;
       
   346     CFsTreePlainOneLineItemData* plainItemData;
       
   347     MFsTreeItemVisualizer* plainItemVisualizer;
       
   348     plainItemData = CFsTreePlainOneLineItemData::NewL( );
       
   349     plainItemData->SetDataL( aItemText );
       
   350     plainItemVisualizer = CFsTreePlainOneLineItemVisualizer::NewL(
       
   351         *iTreeList->TreeControl() );
       
   352     iTreeList->InsertItemL( *plainItemData,
       
   353                             *plainItemVisualizer,
       
   354                             KFsTreeRootID );
       
   355     iPlainItemDataArr.AppendL( plainItemData );
       
   356     iPlainItemVisualizerArr.AppendL( plainItemVisualizer );
       
   357     }
       
   358 
       
   359 // ---------------------------------------------------------------------------
       
   360 // Finds the passed text in itemset and highlight it
       
   361 // ---------------------------------------------------------------------------
       
   362 //
       
   363 EXPORT_C void CFsFastAddressingList::HighlightText( const TDesC& /*aText*/)
       
   364     {
       
   365     FUNC_LOG;
       
   366     
       
   367     }
       
   368 
       
   369 // ---------------------------------------------------------------------------
       
   370 // Controls position of the list (above the text input field or below)
       
   371 // ---------------------------------------------------------------------------
       
   372 //
       
   373 EXPORT_C void CFsFastAddressingList::SetListPosition( TFsListPosition aPos )
       
   374     {
       
   375     FUNC_LOG;
       
   376     iVisualizer->SetListPosition( aPos );
       
   377     }
       
   378 
       
   379 // ---------------------------------------------------------------------------
       
   380 // Returns the list position (above the text input field or below)
       
   381 // ---------------------------------------------------------------------------
       
   382 //
       
   383 EXPORT_C CFsFastAddressingList::TFsListPosition
       
   384     CFsFastAddressingList::ListPosition() const
       
   385     {
       
   386     FUNC_LOG;
       
   387     return iVisualizer->ListPosition();
       
   388     }
       
   389 
       
   390 // ---------------------------------------------------------------------------
       
   391 // Controls the visibility of the scrollbar
       
   392 // ---------------------------------------------------------------------------
       
   393 //
       
   394 EXPORT_C void CFsFastAddressingList::SetScrollbarVisibility(
       
   395     const TBool /*aVisible */)
       
   396     {
       
   397     FUNC_LOG;
       
   398  
       
   399     }
       
   400 
       
   401 // ---------------------------------------------------------------------------
       
   402 // Returns status of the visibility of the scrollbar
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 EXPORT_C TBool CFsFastAddressingList::ScrollbarVisibility() const
       
   406     {
       
   407     FUNC_LOG;
       
   408 
       
   409     return ETrue;
       
   410     }
       
   411 
       
   412 // ---------------------------------------------------------------------------
       
   413 // Returns the reference to the tree list component.
       
   414 // ---------------------------------------------------------------------------
       
   415 //
       
   416 EXPORT_C CFsTreeList& CFsFastAddressingList::List() const
       
   417     {
       
   418     FUNC_LOG;
       
   419     return *iTreeList;
       
   420     }
       
   421 
       
   422 // ---------------------------------------------------------------------------
       
   423 // From class CHuiControl
       
   424 // Handling of the key events and passing to the text input field.
       
   425 // ---------------------------------------------------------------------------
       
   426 //
       
   427 TBool CFsFastAddressingList::OfferEventL( const TAlfEvent &aEvent )
       
   428     {
       
   429     FUNC_LOG;
       
   430     TBool keyHandled( EFalse );
       
   431 
       
   432     if ( ( aEvent.IsKeyEvent() ) && ( aEvent.Code() ==  EEventKeyDown ) )
       
   433         {
       
   434         switch ( aEvent.KeyEvent().iScanCode )
       
   435             {
       
   436             case EStdKeyLeftArrow:
       
   437                 {
       
   438                 iTextInputField->MoveCursorL( TCursorPosition::EFLeft,
       
   439                                               EFalse );
       
   440                 keyHandled = ETrue;
       
   441                 break;
       
   442                 }
       
   443 
       
   444             case EStdKeyRightArrow:
       
   445                 {
       
   446                 iTextInputField->MoveCursorL( TCursorPosition::EFRight,
       
   447                                               EFalse );
       
   448                 keyHandled = ETrue;
       
   449                 break;
       
   450                 }
       
   451 
       
   452             default:
       
   453                 {
       
   454                 keyHandled = ( EKeyWasConsumed ==
       
   455                              iTextInputField->OfferKeyEventL( aEvent.KeyEvent(),
       
   456                                                               aEvent.Code() ) );
       
   457                 break;
       
   458                 }
       
   459             }
       
   460         }
       
   461      else
       
   462         {
       
   463         keyHandled = ( EKeyWasConsumed ==
       
   464                          iTextInputField->OfferKeyEventL( aEvent.KeyEvent(),
       
   465                                                           aEvent.Code() ) );
       
   466         }
       
   467 
       
   468     return keyHandled;
       
   469     }
       
   470 
       
   471 // ---------------------------------------------------------------------------
       
   472 // From class CHuiControl
       
   473 // Invoked when layouts are updated
       
   474 // ---------------------------------------------------------------------------
       
   475 //
       
   476 void CFsFastAddressingList::VisualLayoutUpdated( CAlfVisual& /*aVisual */)
       
   477     {
       
   478     FUNC_LOG;
       
   479     
       
   480     }
       
   481 
       
   482 // ---------------------------------------------------------------------------
       
   483 // From class CHuiControl
       
   484 // Invoked when visibility of the control is changing
       
   485 // ---------------------------------------------------------------------------
       
   486 //
       
   487 void CFsFastAddressingList::NotifyControlVisibility( TBool /*aIsVisible*/,
       
   488         CAlfDisplay& /*aDisplay */)
       
   489     {
       
   490     FUNC_LOG;
       
   491     }
       
   492 
       
   493 // ---------------------------------------------------------------------------
       
   494 // From class MFsTextInputFieldObserver
       
   495 // From text input field observer. Invoked when changes in the text are made
       
   496 // ---------------------------------------------------------------------------
       
   497 //
       
   498 void CFsFastAddressingList::HandleTextInputEventL(
       
   499     CFsTextInputField* aTextInputField,
       
   500     MFsTextInputFieldObserver::TFsTextInputEventType /*aEventType */)
       
   501     {
       
   502     FUNC_LOG;
       
   503     HBufC16* text = HBufC16::NewL(
       
   504         aTextInputField->RichText()->DocumentLength() );
       
   505     TPtr16 ptr = text->Des();
       
   506     aTextInputField->RichText()->Extract( ptr );
       
   507     iObserver.TextInputFieldUpdated( ptr );
       
   508     delete text;
       
   509     }
       
   510 
       
   511 // ---------------------------------------------------------------------------
       
   512 // Copies highlighted text to the text input field
       
   513 // ---------------------------------------------------------------------------
       
   514 //
       
   515 void CFsFastAddressingList::MakeSelection()
       
   516     {
       
   517     FUNC_LOG;
       
   518     
       
   519     }
       
   520 
       
   521 // ---------------------------------------------------------------------------
       
   522 // Highlights next item in the tree list
       
   523 // ---------------------------------------------------------------------------
       
   524 //
       
   525 void CFsFastAddressingList::MoveSelectionDown()
       
   526     {
       
   527     FUNC_LOG;
       
   528   
       
   529     }
       
   530 
       
   531 // ---------------------------------------------------------------------------
       
   532 // Highlights previous item in the tree list
       
   533 // ---------------------------------------------------------------------------
       
   534 //
       
   535 void CFsFastAddressingList::MoveSelectionUp()
       
   536     {
       
   537     FUNC_LOG;
       
   538  
       
   539     }
       
   540 
       
   541 // ---------------------------------------------------------------------------
       
   542 // Controls text input mode
       
   543 // ---------------------------------------------------------------------------
       
   544 //
       
   545 void CFsFastAddressingList::SetTextInputMode()
       
   546     {
       
   547     FUNC_LOG;
       
   548   
       
   549     }
       
   550 
       
   551 // ---------------------------------------------------------------------------
       
   552 // Invoked when text has been modified.
       
   553 // ---------------------------------------------------------------------------
       
   554 //
       
   555 void CFsFastAddressingList::TextInputFieldModified()
       
   556     {
       
   557     FUNC_LOG;
       
   558 
       
   559     }
       
   560