messagingapp/msgui/unifiedviewer/src/univieweraddresscontainer.cpp
changeset 37 518b245aa84c
parent 25 84d9eb65b26f
equal deleted inserted replaced
25:84d9eb65b26f 37:518b245aa84c
    16  */
    16  */
    17 
    17 
    18 #include "univieweraddresscontainer.h"
    18 #include "univieweraddresscontainer.h"
    19 
    19 
    20 // SYSTEM INCLUDES
    20 // SYSTEM INCLUDES
    21 #include <QString>
       
    22 #include <QGraphicsLinearLayout>
    21 #include <QGraphicsLinearLayout>
    23 #include <HbIconItem>
       
    24 
    22 
    25 // USER INCLUDES
    23 // USER INCLUDES
    26 #include "univieweraddresswidget.h"
    24 #include "univieweraddresswidget.h"
    27 
    25 
    28 // LOCAL CONSTANTS
    26 // LOCAL CONSTANTS
    29 #define LOC_FROM hbTrId("txt_messaging_formlabel_from")
    27 #define LOC_FROM hbTrId("txt_messaging_formlabel_from")
    30 #define LOC_TO hbTrId("txt_messaging_viewer_formlabel_to")
    28 #define LOC_TO hbTrId("txt_messaging_viewer_formlabel_to")
    31 #define LOC_CC hbTrId("txt_messaging_viewer_formlabel_cc")
    29 #define LOC_CC hbTrId("txt_messaging_viewer_formlabel_cc")
    32 
    30 #define LOC_BCC hbTrId("txt_messaging_viewer_formlabel_bcc")
    33 // LOCAL CONSTANTS
       
    34 const QString DIVIDER_ICON("qtg_graf_divider_h_thin");
       
    35 
    31 
    36 //---------------------------------------------------------------
    32 //---------------------------------------------------------------
    37 // UniViewerAddressContainer :: UniViewerAddressContainer
    33 // UniViewerAddressContainer::UniViewerAddressContainer
    38 // @see header file
    34 // @see header file
    39 //---------------------------------------------------------------
    35 //---------------------------------------------------------------
    40 UniViewerAddressContainer::UniViewerAddressContainer(QGraphicsItem *parent) :
    36 UniViewerAddressContainer::UniViewerAddressContainer(QGraphicsItem* parent) :
    41     HbWidget(parent), mMainLayout(0), mFromWidget(0), mToWidget(0), mCcWidget(0), mDivider(0)
    37     HbWidget(parent)
    42 {
    38 {
    43     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    39     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
    44     mMainLayout->setContentsMargins(0, 0, 0, 0);
    40     mMainLayout->setContentsMargins(0, 0, 0, 0);
    45     mMainLayout->setSpacing(0);
    41     mMainLayout->setSpacing(0);
    46     setLayout(mMainLayout);
    42     setLayout(mMainLayout);
    47 }
    43 }
    48 
    44 
    49 //---------------------------------------------------------------
    45 //---------------------------------------------------------------
    50 // UniViewerAddressContainer :: ~UniViewerAddressContainer
    46 // UniViewerAddressContainer::~UniViewerAddressContainer
    51 // @see header file
    47 // @see header file
    52 //---------------------------------------------------------------
    48 //---------------------------------------------------------------
    53 UniViewerAddressContainer::~UniViewerAddressContainer()
    49 UniViewerAddressContainer::~UniViewerAddressContainer()
    54 {
    50 {
       
    51 }
       
    52 
       
    53 //---------------------------------------------------------------
       
    54 // UniViewerAddressContainer::setFromField
       
    55 // @see header file
       
    56 //---------------------------------------------------------------
       
    57 void UniViewerAddressContainer::setFromField(const QString& fromRecipient, const QString& alias)
       
    58 {
       
    59     UniViewerAddressWidget* fromWidget = new UniViewerAddressWidget(this);
       
    60 
       
    61     connect(fromWidget, SIGNAL(sendMessage(const QString&,const QString&)), this,
       
    62         SIGNAL(sendMessage(const QString&,const QString&)));
       
    63 
       
    64     mMainLayout->addItem(fromWidget);
       
    65 
       
    66     fromWidget->populate(LOC_FROM, fromRecipient, alias);
       
    67 }
       
    68 
       
    69 //---------------------------------------------------------------
       
    70 // UniViewerAddressContainer::setToField
       
    71 // @see header file
       
    72 //---------------------------------------------------------------
       
    73 void UniViewerAddressContainer::setToField(ConvergedMessageAddressList toRecipients)
       
    74 {
       
    75     UniViewerAddressWidget* toWidget = new UniViewerAddressWidget();
       
    76 
       
    77     connect(toWidget, SIGNAL(sendMessage(const QString&,const QString&)), this,
       
    78         SIGNAL(sendMessage(const QString&,const QString&)));
       
    79 
       
    80     mMainLayout->addItem(toWidget);
       
    81 
       
    82     toWidget->populate(LOC_TO, toRecipients);
    55 
    83 
    56 }
    84 }
    57 
    85 
    58 //---------------------------------------------------------------
    86 //---------------------------------------------------------------
    59 // UniViewerAddressContainer :: setFromField
    87 // UniViewerAddressContainer::setCcField
    60 // @see header file
       
    61 //---------------------------------------------------------------
       
    62 void UniViewerAddressContainer::setFromField(const QString& fromRecipient, const QString& alias)
       
    63 {
       
    64     if (!mFromWidget) {
       
    65         mFromWidget = new UniViewerAddressWidget();
       
    66     }
       
    67 
       
    68     mMainLayout->addItem(mFromWidget);
       
    69     mFromWidget->populate(LOC_FROM, fromRecipient, alias);
       
    70 }
       
    71 
       
    72 //---------------------------------------------------------------
       
    73 // UniViewerAddressContainer :: setToField
       
    74 // @see header file
       
    75 //---------------------------------------------------------------
       
    76 void UniViewerAddressContainer::setToField(ConvergedMessageAddressList toRecipients)
       
    77 {
       
    78     if (!mToWidget) {
       
    79         mToWidget = new UniViewerAddressWidget();
       
    80     }
       
    81 
       
    82     mMainLayout->addItem(mToWidget);
       
    83     mToWidget->populate(LOC_TO, toRecipients);
       
    84 }
       
    85 
       
    86 //---------------------------------------------------------------
       
    87 //UniViewerAddressContainer :: setCcField
       
    88 // @see header file
    88 // @see header file
    89 //---------------------------------------------------------------
    89 //---------------------------------------------------------------
    90 void UniViewerAddressContainer::setCcField(ConvergedMessageAddressList ccRecipients)
    90 void UniViewerAddressContainer::setCcField(ConvergedMessageAddressList ccRecipients)
    91 {
    91 {
    92     if (!mCcWidget) {
    92     UniViewerAddressWidget* ccWidget = new UniViewerAddressWidget();
    93         mCcWidget = new UniViewerAddressWidget();
       
    94     }
       
    95 
    93 
    96     mMainLayout->addItem(mCcWidget);
    94     connect(ccWidget, SIGNAL(sendMessage(const QString&,const QString&)), this,
    97     mCcWidget->populate(LOC_CC, ccRecipients);
    95         SIGNAL(sendMessage(const QString&,const QString&)));
       
    96 
       
    97     mMainLayout->addItem(ccWidget);
       
    98 
       
    99     ccWidget->populate(LOC_CC, ccRecipients);
    98 }
   100 }
    99 
   101 
   100 //---------------------------------------------------------------
   102 //---------------------------------------------------------------
   101 // UniViewerAddressContainer :: clearContent
   103 // UniViewerAddressContainer :: setBccField
   102 // @see header file
   104 // @see header file
   103 //---------------------------------------------------------------
   105 //---------------------------------------------------------------
   104 void UniViewerAddressContainer::clearContent()
   106 void UniViewerAddressContainer::setBccField(ConvergedMessageAddressList bccRecipients)
   105 {
   107 {
   106     if (mFromWidget) {
   108     UniViewerAddressWidget* bccWidget = new UniViewerAddressWidget();
   107         mMainLayout->removeItem(mFromWidget);
       
   108         mFromWidget->setParent(NULL);
       
   109         delete mFromWidget;
       
   110         mFromWidget = NULL;
       
   111     }
       
   112     if (mToWidget) {
       
   113         mMainLayout->removeItem(mToWidget);
       
   114         mToWidget->setParent(NULL);
       
   115         delete mToWidget;
       
   116         mToWidget = NULL;
       
   117     }
       
   118     if (mCcWidget) {
       
   119         mMainLayout->removeItem(mCcWidget);
       
   120         mCcWidget->setParent(NULL);
       
   121         delete mCcWidget;
       
   122         mCcWidget = NULL;
       
   123     }
       
   124     if (mDivider) {
       
   125         mMainLayout->removeItem(mDivider);
       
   126         mDivider->setParent(NULL);
       
   127         delete mDivider;
       
   128         mDivider = NULL;
       
   129     }
       
   130 
   109 
   131     resize(rect().width(), -1);
   110     connect(bccWidget, SIGNAL(sendMessage(const QString&,const QString&)), this,
   132 }
   111         SIGNAL(sendMessage(const QString&,const QString&)));
   133 
   112 
   134 //---------------------------------------------------------------
   113     mMainLayout->addItem(bccWidget);
   135 // UniViewerAddressContainer :: insertDivider
       
   136 // @see header file
       
   137 //---------------------------------------------------------------
       
   138 void UniViewerAddressContainer::insertDivider()
       
   139 {
       
   140     if (!mDivider) {
       
   141         mDivider = new HbIconItem(this);
       
   142     }
       
   143 
   114 
   144     mDivider->sizePolicy().setHorizontalPolicy(QSizePolicy::Expanding);
   115     bccWidget->populate(LOC_BCC, bccRecipients);
   145     mDivider->sizePolicy().setVerticalPolicy(QSizePolicy::Fixed);
       
   146     mDivider->setIconName(DIVIDER_ICON);
       
   147     mMainLayout->addItem(mDivider);
       
   148 }
   116 }
   149 
   117 
   150 // EOF
   118 // EOF