messagingapp/msgui/unifiedviewer/src/univiewerheadercontainer.cpp
branchGCC_SURGE
changeset 47 5b14749788d7
parent 27 e4592d119491
parent 44 36f374c67aa8
equal deleted inserted replaced
35:a32b19fb291e 47:5b14749788d7
    22 #include <HbGroupBox>
    22 #include <HbGroupBox>
    23 #include <HbFrameItem>
    23 #include <HbFrameItem>
    24 
    24 
    25 // USER INCLUDES
    25 // USER INCLUDES
    26 #include "univieweraddresscontainer.h"
    26 #include "univieweraddresscontainer.h"
    27 #include "univiewerattachmentcontainer.h"
       
    28 #include "univiewerdetailswidget.h"
    27 #include "univiewerdetailswidget.h"
    29 #include "univiewerfeeder.h"
    28 #include "univiewerfeeder.h"
       
    29 #include "univiewerattachmentwidget.h"
    30 
    30 
    31 #include "nativemessageconsts.h"
    31 #include "nativemessageconsts.h"
    32 
    32 
    33 // LOCALIZATION
    33 // LOCALIZATION
    34 #define LOC_SEND_FAILED hbTrId("txt_messaging_formlabel_sending_failed")
    34 #define LOC_SEND_FAILED hbTrId("txt_messaging_formlabel_sending_failed")
    42 // UniViewerHeaderContainer :: UniViewerHeaderContainer
    42 // UniViewerHeaderContainer :: UniViewerHeaderContainer
    43 // @see header file
    43 // @see header file
    44 //---------------------------------------------------------------
    44 //---------------------------------------------------------------
    45 UniViewerHeaderContainer::UniViewerHeaderContainer(UniViewerFeeder* feeder, QGraphicsItem *parent) :
    45 UniViewerHeaderContainer::UniViewerHeaderContainer(UniViewerFeeder* feeder, QGraphicsItem *parent) :
    46     HbWidget(parent), mViewFeeder(feeder), mViewerDetails(0), mHeaderGroupBox(0), mSeparator(0),
    46     HbWidget(parent), mViewFeeder(feeder), mViewerDetails(0), mHeaderGroupBox(0), mSeparator(0),
    47         mAddressContainer(0), mAttachmentContainer(0)
    47         mAddressContainer(0)
    48 {
    48 {
    49     this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    49     this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    50 
       
    51     HbFrameItem *bgItem = new HbFrameItem(BG_FRAME_GRAPHICS, HbFrameDrawer::NinePieces, this);
       
    52     this->setBackgroundItem(bgItem);
       
    53 
    50 
    54     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
    51     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
    55     mMainLayout->setSpacing(0);
    52     mMainLayout->setSpacing(0);
    56     mMainLayout->setContentsMargins(0, 0, 0, 0);
    53     mMainLayout->setContentsMargins(0, 0, 0, 0);
    57 
    54 
    66 
    63 
    67     mHeaderGroupBox->setContentWidget(mAddressContainer);
    64     mHeaderGroupBox->setContentWidget(mAddressContainer);
    68 
    65 
    69     // Separator
    66     // Separator
    70     mSeparator = new HbFrameItem(DIVIDER_FRAME, HbFrameDrawer::OnePiece, this);
    67     mSeparator = new HbFrameItem(DIVIDER_FRAME, HbFrameDrawer::OnePiece, this);
    71     mSeparator->setMaximumHeight(1);
    68     mSeparator->setMinimumHeight(2.0);
       
    69     mSeparator->frameDrawer().fillWholeRect();
    72     mSeparator->hide();
    70     mSeparator->hide();
    73 
    71 
    74     // Viewer Details widget
    72     // Viewer Details widget
    75     mViewerDetails = new UniViewerDetailsWidget(this);
    73     mViewerDetails = new UniViewerDetailsWidget(this);
    76 
    74 
       
    75     // This widget is created to apply background for header & details.
       
    76     HbWidget *headerContainer = new HbWidget(this);
       
    77 
       
    78     QGraphicsLinearLayout *headerLayout = new QGraphicsLinearLayout(Qt::Vertical, headerContainer);
       
    79     headerLayout->setSpacing(0);
       
    80     headerLayout->setContentsMargins(0, 0, 0, 0);
       
    81 
       
    82     HbFrameItem *bgItem = new HbFrameItem(BG_FRAME_GRAPHICS, HbFrameDrawer::NinePieces, this);
       
    83     headerContainer->setBackgroundItem(bgItem, -2.0);
       
    84 
    77     //Add address group box and insert into layout
    85     //Add address group box and insert into layout
    78     mMainLayout->addItem(mHeaderGroupBox);
    86     headerLayout->addItem(mHeaderGroupBox);
    79     mMainLayout->addItem(mSeparator);
    87     headerLayout->addItem(mSeparator);
    80     mMainLayout->addItem(mViewerDetails);
    88     headerLayout->addItem(mViewerDetails);
       
    89 
       
    90     headerContainer->setLayout(headerLayout);
       
    91 
       
    92     mMainLayout->addItem(headerContainer);
    81 
    93 
    82     this->setLayout(mMainLayout);
    94     this->setLayout(mMainLayout);
    83 }
    95 }
    84 
    96 
    85 //---------------------------------------------------------------
    97 //---------------------------------------------------------------
   115     populateAttachments();
   127     populateAttachments();
   116 
   128 
   117     // Expand address group box for outgoing messages.
   129     // Expand address group box for outgoing messages.
   118     if (mViewFeeder->isIncoming()) {
   130     if (mViewFeeder->isIncoming()) {
   119         mHeaderGroupBox->setCollapsed(true);
   131         mHeaderGroupBox->setCollapsed(true);
       
   132         addressBoxToggled(true);
   120     }
   133     }
   121     else {
   134     else {
   122         mHeaderGroupBox->setCollapsed(false);
   135         mHeaderGroupBox->setCollapsed(false);
       
   136         addressBoxToggled(false);
   123     }
   137     }
   124 }
   138 }
   125 
   139 
   126 //---------------------------------------------------------------
   140 //---------------------------------------------------------------
   127 // UniViewerHeaderContainer :: clearContent
   141 // UniViewerHeaderContainer :: clearContent
   130 void UniViewerHeaderContainer::clearContent()
   144 void UniViewerHeaderContainer::clearContent()
   131 {
   145 {
   132     if (mViewerDetails) {
   146     if (mViewerDetails) {
   133         mViewerDetails->clearContent();
   147         mViewerDetails->clearContent();
   134     }
   148     }
   135     if (mAttachmentContainer) {
   149 
   136         mAttachmentContainer->clearContent();
   150     // Clear the attachments.
   137     }
   151     for (int i = 0; i < mUniViewerAttachmentstList.count(); ++i) {
       
   152         mMainLayout->removeItem(mUniViewerAttachmentstList[i]);
       
   153         mUniViewerAttachmentstList[i]->setParent(NULL);
       
   154         delete mUniViewerAttachmentstList[i];
       
   155         mUniViewerAttachmentstList[i] = NULL;
       
   156     }
       
   157     mUniViewerAttachmentstList.clear();
       
   158 
       
   159     resize(rect().width(), -1);
   138 }
   160 }
   139 
   161 
   140 //---------------------------------------------------------------
   162 //---------------------------------------------------------------
   141 // UniViewerHeaderContainer :: populateSubject
   163 // UniViewerHeaderContainer :: populateSubject
   142 // @see header file
   164 // @see header file
   165 // UniViewerHeaderContainer :: populateAttachments
   187 // UniViewerHeaderContainer :: populateAttachments
   166 // @see header file
   188 // @see header file
   167 //---------------------------------------------------------------
   189 //---------------------------------------------------------------
   168 void UniViewerHeaderContainer::populateAttachments()
   190 void UniViewerHeaderContainer::populateAttachments()
   169 {
   191 {
   170     if (!mAttachmentContainer) {
       
   171         // Attachment Container
       
   172         mAttachmentContainer = new UniViewerAttachmentContainer(this);
       
   173         mMainLayout->addItem(mAttachmentContainer);
       
   174     }
       
   175 
       
   176     UniMessageInfoList attachList = mViewFeeder->attachmentsList();
   192     UniMessageInfoList attachList = mViewFeeder->attachmentsList();
   177     for (int a = 0; a < attachList.count(); ++a) {
   193     for (int a = 0; a < attachList.count(); ++a) {
   178         UniMessageInfo* info = attachList.at(a);
   194         UniMessageInfo* info = attachList.at(a);
   179         mAttachmentContainer->addAttachmentWidget(info->mimetype(), info->path());
   195         UniViewerAttachmentWidget *attachmentWidget = new UniViewerAttachmentWidget(this);
       
   196         mUniViewerAttachmentstList.append(attachmentWidget);
       
   197         attachmentWidget->populate(info);
   180         delete info;
   198         delete info;
       
   199         mMainLayout->addItem(attachmentWidget);
   181     }
   200     }
   182 }
   201 }
   183 
   202 
   184 //---------------------------------------------------------------
   203 //---------------------------------------------------------------
   185 // UniViewerHeaderContainer :: populateAttachments
   204 // UniViewerHeaderContainer :: populateAttachments
   206             mAddressContainer->setToField(toList);
   225             mAddressContainer->setToField(toList);
   207         }
   226         }
   208         ConvergedMessageAddressList ccList = mViewFeeder->ccAddressList();
   227         ConvergedMessageAddressList ccList = mViewFeeder->ccAddressList();
   209         if (!ccList.isEmpty()) {
   228         if (!ccList.isEmpty()) {
   210             mAddressContainer->setCcField(ccList);
   229             mAddressContainer->setCcField(ccList);
       
   230         }
       
   231         ConvergedMessageAddressList bccList = mViewFeeder->bccAddressList();
       
   232         if (!bccList.isEmpty()) {
       
   233             mAddressContainer->setBccField(bccList);
   211         }
   234         }
   212     }
   235     }
   213 
   236 
   214 }
   237 }
   215 //---------------------------------------------------------------
   238 //---------------------------------------------------------------
   257 //---------------------------------------------------------------
   280 //---------------------------------------------------------------
   258 void UniViewerHeaderContainer::addressBoxToggled(bool state)
   281 void UniViewerHeaderContainer::addressBoxToggled(bool state)
   259 {
   282 {
   260     (state) ? mSeparator->hide() : mSeparator->show();
   283     (state) ? mSeparator->hide() : mSeparator->show();
   261 }
   284 }
       
   285 
       
   286 // EOF