messagingapp/msgui/unifiedviewer/src/univieweraddresscontainer.cpp
changeset 23 238255e8b033
child 25 84d9eb65b26f
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     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 #include "univieweraddresscontainer.h"
       
    19 
       
    20 // SYSTEM INCLUDES
       
    21 #include <QString>
       
    22 #include <QGraphicsLinearLayout>
       
    23 
       
    24 // USER INCLUDES
       
    25 #include "univieweraddresswidget.h"
       
    26 
       
    27 // LOCAL CONSTANTS
       
    28 #define LOC_FROM hbTrId("txt_messaging_formlabel_from    ")
       
    29 #define LOC_TO hbTrId("txt_messaging_viewer_formlabel_to        ")
       
    30 #define LOC_CC hbTrId("txt_messaging_viewer_formlabel_cc        ")
       
    31 
       
    32 //---------------------------------------------------------------
       
    33 // UniViewerAddressContainer :: UniViewerAddressContainer
       
    34 // @see header file
       
    35 //---------------------------------------------------------------
       
    36 UniViewerAddressContainer::UniViewerAddressContainer(QGraphicsItem *parent) :
       
    37     HbWidget(parent), mMainLayout(NULL),
       
    38     mFromWidget(NULL),
       
    39     mToWidget(NULL),
       
    40     mCcWidget(NULL)
       
    41 {
       
    42     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
       
    43     mMainLayout->setContentsMargins(0, 0, 0, 0);
       
    44     mMainLayout->setSpacing(0);
       
    45     setLayout(mMainLayout);
       
    46 }
       
    47 
       
    48 //---------------------------------------------------------------
       
    49 // UniViewerAddressContainer :: ~UniViewerAddressContainer
       
    50 // @see header file
       
    51 //---------------------------------------------------------------
       
    52 UniViewerAddressContainer::~UniViewerAddressContainer()
       
    53 {
       
    54 
       
    55 }
       
    56 
       
    57 //---------------------------------------------------------------
       
    58 // UniViewerAddressContainer :: setFromField
       
    59 // @see header file
       
    60 //---------------------------------------------------------------
       
    61 void UniViewerAddressContainer::setFromField(const QString& fromRecipient,
       
    62                                              const QString& alias)
       
    63 {
       
    64     if (!mFromWidget)
       
    65     {
       
    66         mFromWidget = new UniViewerAddressWidget();
       
    67     }
       
    68 
       
    69     mMainLayout->addItem(mFromWidget);
       
    70     mFromWidget->populate(LOC_FROM, fromRecipient, alias);
       
    71 }
       
    72 
       
    73 //---------------------------------------------------------------
       
    74 // UniViewerAddressContainer :: setToField
       
    75 // @see header file
       
    76 //---------------------------------------------------------------
       
    77 void UniViewerAddressContainer::setToField(
       
    78     ConvergedMessageAddressList toRecipients)
       
    79 {
       
    80     if (!mToWidget)
       
    81     {
       
    82         mToWidget = new UniViewerAddressWidget();
       
    83     }
       
    84 
       
    85     mMainLayout->addItem(mToWidget);
       
    86     mToWidget->populate(LOC_TO, toRecipients);
       
    87 }
       
    88 
       
    89 //---------------------------------------------------------------
       
    90 //UniViewerAddressContainer :: setCcField
       
    91 // @see header file
       
    92 //---------------------------------------------------------------
       
    93 void UniViewerAddressContainer::setCcField(
       
    94     ConvergedMessageAddressList ccRecipients)
       
    95 {
       
    96     if (!mCcWidget)
       
    97     {
       
    98         mCcWidget = new UniViewerAddressWidget();
       
    99     }
       
   100 
       
   101     mMainLayout->addItem(mCcWidget);
       
   102     mCcWidget->populate(LOC_CC, ccRecipients);
       
   103 }
       
   104 
       
   105 //---------------------------------------------------------------
       
   106 // UniViewerAddressContainer :: clearContent
       
   107 // @see header file
       
   108 //---------------------------------------------------------------
       
   109 void UniViewerAddressContainer::clearContent()
       
   110 {
       
   111     if (mFromWidget)
       
   112     {
       
   113         mMainLayout->removeItem(mFromWidget);
       
   114         mFromWidget->setParent(NULL);
       
   115         delete mFromWidget;
       
   116         mFromWidget = NULL;
       
   117     }
       
   118     if (mToWidget)
       
   119     {
       
   120         mMainLayout->removeItem(mToWidget);
       
   121         mToWidget->setParent(NULL);
       
   122         delete mToWidget;
       
   123         mToWidget = NULL;
       
   124     }
       
   125     if (mCcWidget)
       
   126     {
       
   127         mMainLayout->removeItem(mCcWidget);
       
   128         mCcWidget->setParent(NULL);
       
   129         delete mCcWidget;
       
   130         mCcWidget = NULL;
       
   131     }
       
   132 
       
   133     resize(rect().width(), -1);
       
   134 }
       
   135 
       
   136 // EOF