emailuis/uicomponents/src/fsmultilineitemdata.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:  A data class for the MultiLine item.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //////TOOLKIT INCLUDES
       
    20 // <cmail> SF
       
    21 #include "emailtrace.h"
       
    22 #include <alf/alftexture.h>
       
    23 // </cmail>
       
    24 
       
    25 //////PROJECT INCLUDES
       
    26 //<cmail> removed __FS_ALFRED_SUPPORT flag
       
    27 //#include <fsconfig.h>
       
    28 //</cmail> removed __FS_ALFRED_SUPPORT flag
       
    29 #include "fsmultilineitemdata.h"
       
    30 
       
    31 // ---------------------------------------------------------------------------
       
    32 // Two-phased constructor.
       
    33 // ---------------------------------------------------------------------------
       
    34 //
       
    35 EXPORT_C CFsMultiLineItemData* CFsMultiLineItemData::NewL( )
       
    36     {
       
    37     FUNC_LOG;
       
    38     CFsMultiLineItemData* self = new( ELeave ) CFsMultiLineItemData();
       
    39     CleanupStack::PushL(self);
       
    40     self->ConstructL( );
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43     }
       
    44     
       
    45 // ---------------------------------------------------------------------------
       
    46 // C++ destructor.
       
    47 // ---------------------------------------------------------------------------
       
    48 //
       
    49 CFsMultiLineItemData::~CFsMultiLineItemData()
       
    50     {
       
    51     FUNC_LOG;
       
    52     delete iFirstLineText;
       
    53     delete iSecondLineText;
       
    54     delete iThirdLineText;
       
    55     delete iFourthLineText;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // The function sets text to a specified line.
       
    60 // ---------------------------------------------------------------------------
       
    61 //
       
    62 void CFsMultiLineItemData::SetLineTextL( const TDesC& aText, TInt aLineNumber )
       
    63     {
       
    64     FUNC_LOG;
       
    65     
       
    66     if ( aLineNumber >= 0 && aLineNumber < 4 )
       
    67         {
       
    68         switch ( aLineNumber )
       
    69             {
       
    70             case 0:
       
    71                 SetTextL( iFirstLineText, aText );
       
    72                 break;
       
    73             case 1:
       
    74                 SetTextL( iSecondLineText, aText );
       
    75                 break;
       
    76             case 2:
       
    77                 SetTextL( iThirdLineText, aText );
       
    78                 break;
       
    79             case 3:                
       
    80                 SetTextL( iFourthLineText, aText );
       
    81                 break;
       
    82             default:
       
    83                 break;
       
    84             }                        
       
    85         }
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // The function return a text associated with a specified line.
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 TDesC& CFsMultiLineItemData::LineText( TInt aLineNumber ) const
       
    93     {
       
    94     FUNC_LOG;
       
    95     HBufC* text(NULL);
       
    96     
       
    97     switch ( aLineNumber )
       
    98         {
       
    99         case 0:
       
   100             text = iFirstLineText;            
       
   101             break;
       
   102         case 1:
       
   103             text = iSecondLineText;            
       
   104             break;
       
   105         case 2:
       
   106             text = iThirdLineText;            
       
   107             break;
       
   108         case 3:
       
   109             text = iFourthLineText;
       
   110             break;
       
   111         default:
       
   112             text = iFirstLineText;
       
   113             break;
       
   114         }
       
   115     return *text;
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------------------------
       
   119 // The function sets icon to a specified line.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CFsMultiLineItemData::SetLineIcon ( CAlfTexture* aIcon, TInt aLineNumber  )
       
   123     {
       
   124     FUNC_LOG;
       
   125     if ( aLineNumber >= 0 && aLineNumber < 4 )
       
   126         {
       
   127         switch ( aLineNumber )
       
   128             {
       
   129             case 0:
       
   130                 iFirstLineIcon = aIcon;
       
   131                 break;
       
   132             case 1:
       
   133                 iSecondLineIcon = aIcon;
       
   134                 break;
       
   135             case 2:
       
   136                 iThirdLineIcon = aIcon;
       
   137                 break;
       
   138             case 3:
       
   139                 iFourthLineIcon = aIcon;
       
   140                 break;
       
   141             default:
       
   142                 break;
       
   143             }                
       
   144         }
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // The function returns an icon associated with a specified line.
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 const CAlfTexture* CFsMultiLineItemData::LineIcon ( TInt aLineNumber  ) const
       
   152     {
       
   153     FUNC_LOG;
       
   154     CAlfTexture* icon(NULL);
       
   155     
       
   156     switch ( aLineNumber )
       
   157         {
       
   158         case 0:
       
   159             icon = iFirstLineIcon;
       
   160             break;
       
   161         case 1:
       
   162             icon = iSecondLineIcon;
       
   163             break;
       
   164         case 2:
       
   165             icon = iThirdLineIcon;
       
   166             break;
       
   167         case 3:
       
   168             icon = iFourthLineIcon;            
       
   169             break;
       
   170         default:
       
   171             icon = iFirstLineIcon;            
       
   172             break;
       
   173         }
       
   174     return icon;
       
   175     }
       
   176     
       
   177 // ---------------------------------------------------------------------------
       
   178 // The function sets icons for a checkbox.
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CFsMultiLineItemData::SetCheckBoxIcons( CAlfTexture* aCheckedIcon, CAlfTexture* aUncheckedIcon )
       
   182     {
       
   183     FUNC_LOG;
       
   184     iFirstLineCheckedIcon = aCheckedIcon;
       
   185 
       
   186     iFirstLineUncheckedIcon = aUncheckedIcon;
       
   187     }
       
   188 
       
   189 // ---------------------------------------------------------------------------
       
   190 // The function returns an icon for a checked checkbox's state.
       
   191 // ---------------------------------------------------------------------------
       
   192 //
       
   193 const CAlfTexture* CFsMultiLineItemData::CheckBoxCheckedIcon() const
       
   194     {
       
   195     FUNC_LOG;
       
   196     return iFirstLineCheckedIcon;
       
   197     }
       
   198 
       
   199 // ---------------------------------------------------------------------------
       
   200 // The function returns an icon for an unchecked checkbox's state.
       
   201 // ---------------------------------------------------------------------------
       
   202 //
       
   203 const CAlfTexture* CFsMultiLineItemData::CheckBoxUncheckedIcon() const
       
   204     {
       
   205     FUNC_LOG;
       
   206     return iFirstLineUncheckedIcon;
       
   207     }
       
   208 
       
   209 //from MFsTreeItemData.
       
   210 
       
   211 // ---------------------------------------------------------------------------
       
   212 // 
       
   213 // ---------------------------------------------------------------------------
       
   214 //
       
   215 TFsTreeItemDataType CFsMultiLineItemData::Type() const
       
   216     {
       
   217     FUNC_LOG;
       
   218     return KFsMultiLineItemDataType;
       
   219     }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // The function copies the text from a given source to destination.
       
   223 // ---------------------------------------------------------------------------
       
   224 //
       
   225 void CFsMultiLineItemData::SetTextL( HBufC*& aDest, const TDesC& aSrcText )
       
   226     {
       
   227     FUNC_LOG;
       
   228     delete aDest;
       
   229     aDest = NULL;       
       
   230     
       
   231     TInt eolIndex = aSrcText.Find(_L("\n"));
       
   232     if (eolIndex==KErrNotFound)
       
   233         {
       
   234         aDest = aSrcText.AllocL();
       
   235         }
       
   236     else
       
   237         {
       
   238         aDest = HBufC::NewL(eolIndex+3);
       
   239         *aDest = aSrcText.Left(eolIndex);
       
   240         TPtr16 desc = aDest->Des();
       
   241         desc.Append(_L("..."));
       
   242         }
       
   243     }
       
   244     
       
   245 // ---------------------------------------------------------------------------
       
   246 //  C++ constructor.
       
   247 // ---------------------------------------------------------------------------
       
   248 //
       
   249 CFsMultiLineItemData::CFsMultiLineItemData( )
       
   250     {
       
   251     FUNC_LOG;
       
   252     
       
   253     }
       
   254 
       
   255 // ---------------------------------------------------------------------------
       
   256 //  Second phase constructor.
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 void CFsMultiLineItemData::ConstructL( )
       
   260     {
       
   261     FUNC_LOG;
       
   262     TInt line(0);
       
   263     SetLineTextL( KNullDesC, line++ );
       
   264     SetLineTextL( KNullDesC, line++ );
       
   265     SetLineTextL( KNullDesC, line++ );
       
   266     SetLineTextL( KNullDesC, line );
       
   267     }
       
   268 
       
   269 //EOF
       
   270