uifw/ganes/src/HgItem.cpp
changeset 47 2f0c06423c72
parent 46 0e1e0022bd03
child 53 3c67ea82fafc
equal deleted inserted replaced
46:0e1e0022bd03 47:2f0c06423c72
     1 /*
       
     2 * Copyright (c) 2009 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:     
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <ganes/HgItem.h>
       
    20 #include <gulicon.h>
       
    21 
       
    22 // -----------------------------------------------------------------------------
       
    23 // CHgItem::NewL()
       
    24 // -----------------------------------------------------------------------------
       
    25 //
       
    26 EXPORT_C CHgItem* CHgItem::NewL(
       
    27         TInt aFlags,
       
    28         CGulIcon* aIcon,
       
    29         const TDesC& aTitle,
       
    30         const TDesC& aText )
       
    31     {
       
    32     CHgItem* self = CHgItem::NewLC( aFlags, aIcon, aTitle, aText );
       
    33     CleanupStack::Pop( self );
       
    34     return self;
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CHgItem::NewL()
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C CHgItem* CHgItem::NewLC(
       
    42         TInt aFlags,
       
    43         CGulIcon* aIcon,
       
    44         const TDesC& aTitle,
       
    45         const TDesC& aText )
       
    46     {
       
    47     CHgItem* self = new (ELeave) CHgItem( aFlags, aIcon );
       
    48     CleanupStack::PushL( self );
       
    49     self->ConstructL( aTitle, aText );
       
    50     return self;
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CHgItem::~CHgItem()
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 EXPORT_C CHgItem::~CHgItem()
       
    58     {    
       
    59     delete iIcon;
       
    60     delete iTitle;
       
    61     delete iText;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // CHgItem::CHgItem()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CHgItem::CHgItem( TInt aFlags, CGulIcon* aIcon ) :
       
    69     iIcon( aIcon ),
       
    70     iFlags( aFlags )
       
    71     {
       
    72     iTime.HomeTime();
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CHgItem::ConstructL()
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 void CHgItem::ConstructL( const TDesC& aTitle, const TDesC& aText )
       
    80     {
       
    81     iTitle = aTitle.AllocL();
       
    82     iText = aText.AllocL();
       
    83     }
       
    84 
       
    85 // -----------------------------------------------------------------------------
       
    86 // CHgItem::Icon()
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 EXPORT_C CGulIcon* CHgItem::Icon() const
       
    90     {
       
    91     return iIcon;
       
    92     }
       
    93 
       
    94 // -----------------------------------------------------------------------------
       
    95 // CHgItem::Title()
       
    96 // -----------------------------------------------------------------------------
       
    97 //
       
    98 EXPORT_C const TDesC& CHgItem::Title() const
       
    99     {
       
   100     return *iTitle;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CHgItem::Text()
       
   105 // -----------------------------------------------------------------------------
       
   106 //
       
   107 EXPORT_C const TDesC& CHgItem::Text() const
       
   108     {
       
   109     return *iText;
       
   110     }
       
   111 
       
   112 // -----------------------------------------------------------------------------
       
   113 // CHgItem::Time()
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 EXPORT_C TTime CHgItem::Time() const
       
   117     {
       
   118     return iTime;
       
   119     }
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CHgItem::SetIcon()
       
   123 // -----------------------------------------------------------------------------
       
   124 //
       
   125 EXPORT_C void CHgItem::SetIcon( CGulIcon* aIcon, TInt aFlags )
       
   126     {
       
   127     delete iIcon;        
       
   128     iIcon = aIcon;
       
   129     SetFlags( aFlags );
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CHgItem::SetTitleL()
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 EXPORT_C void CHgItem::SetTitleL( const TDesC& aTitle )
       
   137     {
       
   138     delete iTitle;
       
   139     iTitle = 0;
       
   140     iTitle = aTitle.AllocL();
       
   141     }
       
   142 
       
   143 // -----------------------------------------------------------------------------
       
   144 // CHgItem::SetTextL()
       
   145 // -----------------------------------------------------------------------------
       
   146 //
       
   147 EXPORT_C void CHgItem::SetTextL( const TDesC& aText )
       
   148     {
       
   149     delete iText;
       
   150     iText = 0;
       
   151     iText = aText.AllocL();
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CHgItem::SetTime()
       
   156 // -----------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C void CHgItem::SetTime( TTime aTime )
       
   159     {
       
   160     iTime = aTime;
       
   161     }
       
   162 
       
   163 // -----------------------------------------------------------------------------
       
   164 // CHgItem::SetTextL()
       
   165 // -----------------------------------------------------------------------------
       
   166 //
       
   167 EXPORT_C void CHgItem::SetFlags( TInt aFlags )
       
   168     {
       
   169     iFlags |= aFlags;
       
   170     }
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CHgItem::SetTextL()
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 EXPORT_C void CHgItem::ClearFlags( TInt aFlags )
       
   177     {
       
   178     iFlags &= ~aFlags;
       
   179     }
       
   180 
       
   181 // -----------------------------------------------------------------------------
       
   182 // CHgItem::SetTextL()
       
   183 // -----------------------------------------------------------------------------
       
   184 //
       
   185 EXPORT_C TInt CHgItem::Flags()
       
   186     {
       
   187     return iFlags;
       
   188     }
       
   189 
       
   190 // End of file