messagingapp/msgui/unifiedviewer/src/univiewerheadercontainer.cpp
changeset 27 e4592d119491
parent 25 84d9eb65b26f
child 47 5b14749788d7
equal deleted inserted replaced
25:84d9eb65b26f 27:e4592d119491
    34 #define LOC_SEND_FAILED hbTrId("txt_messaging_formlabel_sending_failed")
    34 #define LOC_SEND_FAILED hbTrId("txt_messaging_formlabel_sending_failed")
    35 
    35 
    36 // LOCAL CONSTANTS
    36 // LOCAL CONSTANTS
    37 const QString ADDR_LIST_SEPARATOR(", ");
    37 const QString ADDR_LIST_SEPARATOR(", ");
    38 const QString BG_FRAME_GRAPHICS("qtg_fr_form_heading");
    38 const QString BG_FRAME_GRAPHICS("qtg_fr_form_heading");
       
    39 const QString DIVIDER_FRAME("qtg_graf_divider_h_thin");
    39 
    40 
    40 //---------------------------------------------------------------
    41 //---------------------------------------------------------------
    41 // UniViewerHeaderContainer :: UniViewerHeaderContainer
    42 // UniViewerHeaderContainer :: UniViewerHeaderContainer
    42 // @see header file
    43 // @see header file
    43 //---------------------------------------------------------------
    44 //---------------------------------------------------------------
    44 UniViewerHeaderContainer::UniViewerHeaderContainer(UniViewerFeeder* feeder, QGraphicsItem *parent) :
    45 UniViewerHeaderContainer::UniViewerHeaderContainer(UniViewerFeeder* feeder, QGraphicsItem *parent) :
    45     HbWidget(parent), mViewFeeder(feeder), mViewerDetails(0), mHeaderGroupBox(0),
    46     HbWidget(parent), mViewFeeder(feeder), mViewerDetails(0), mHeaderGroupBox(0), mSeparator(0),
    46         mAddressContainer(0), mAttachmentContainer(0)
    47         mAddressContainer(0), mAttachmentContainer(0)
    47 {
    48 {
       
    49     this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
       
    50 
    48     HbFrameItem *bgItem = new HbFrameItem(BG_FRAME_GRAPHICS, HbFrameDrawer::NinePieces, this);
    51     HbFrameItem *bgItem = new HbFrameItem(BG_FRAME_GRAPHICS, HbFrameDrawer::NinePieces, this);
    49     this->setBackgroundItem(bgItem);
    52     this->setBackgroundItem(bgItem);
    50 
    53 
    51     QGraphicsLinearLayout *mainLayout = new QGraphicsLinearLayout(Qt::Vertical);
    54     mMainLayout = new QGraphicsLinearLayout(Qt::Vertical, this);
    52     mainLayout->setSpacing(0);
    55     mMainLayout->setSpacing(0);
    53     mainLayout->setContentsMargins(0, 0, 0, 0);
    56     mMainLayout->setContentsMargins(0, 0, 0, 0);
    54 
    57 
    55     // Address Group box
    58     // Address Group box
    56     mHeaderGroupBox = new HbGroupBox(this);
    59     mHeaderGroupBox = new HbGroupBox(this);
       
    60     connect(mHeaderGroupBox, SIGNAL(toggled(bool)), this, SLOT(addressBoxToggled(bool)));
    57 
    61 
    58     // Address container
    62     // Address container
    59     mAddressContainer = new UniViewerAddressContainer(mHeaderGroupBox);
    63     mAddressContainer = new UniViewerAddressContainer(this);
       
    64     connect(mAddressContainer,SIGNAL(sendMessage(const QString&,const QString&)),
       
    65             this, SIGNAL(sendMessage(const QString&,const QString&)));
    60 
    66 
    61     mHeaderGroupBox->setContentWidget(mAddressContainer);
    67     mHeaderGroupBox->setContentWidget(mAddressContainer);
       
    68 
       
    69     // Separator
       
    70     mSeparator = new HbFrameItem(DIVIDER_FRAME, HbFrameDrawer::OnePiece, this);
       
    71     mSeparator->setMaximumHeight(1);
       
    72     mSeparator->hide();
    62 
    73 
    63     // Viewer Details widget
    74     // Viewer Details widget
    64     mViewerDetails = new UniViewerDetailsWidget(this);
    75     mViewerDetails = new UniViewerDetailsWidget(this);
    65 
    76 
    66     // Attachment Container
       
    67     mAttachmentContainer = new UniViewerAttachmentContainer(this);
       
    68 
       
    69     //Add address group box and insert into layout
    77     //Add address group box and insert into layout
    70     mainLayout->addItem(mHeaderGroupBox);
    78     mMainLayout->addItem(mHeaderGroupBox);
    71     mainLayout->addItem(mViewerDetails);
    79     mMainLayout->addItem(mSeparator);
    72     mainLayout->addItem(mAttachmentContainer);
    80     mMainLayout->addItem(mViewerDetails);
    73 
    81 
    74     this->setLayout(mainLayout);
    82     this->setLayout(mMainLayout);
    75 }
    83 }
    76 
    84 
    77 //---------------------------------------------------------------
    85 //---------------------------------------------------------------
    78 // UniViewerHeaderContainer :: ~UniViewerHeaderContainer
    86 // UniViewerHeaderContainer :: ~UniViewerHeaderContainer
    79 // @see header file
    87 // @see header file
   121 //---------------------------------------------------------------
   129 //---------------------------------------------------------------
   122 void UniViewerHeaderContainer::clearContent()
   130 void UniViewerHeaderContainer::clearContent()
   123 {
   131 {
   124     if (mViewerDetails) {
   132     if (mViewerDetails) {
   125         mViewerDetails->clearContent();
   133         mViewerDetails->clearContent();
   126     }
       
   127     if (mAddressContainer) {
       
   128         mAddressContainer->clearContent();
       
   129     }
   134     }
   130     if (mAttachmentContainer) {
   135     if (mAttachmentContainer) {
   131         mAttachmentContainer->clearContent();
   136         mAttachmentContainer->clearContent();
   132     }
   137     }
   133 }
   138 }
   160 // UniViewerHeaderContainer :: populateAttachments
   165 // UniViewerHeaderContainer :: populateAttachments
   161 // @see header file
   166 // @see header file
   162 //---------------------------------------------------------------
   167 //---------------------------------------------------------------
   163 void UniViewerHeaderContainer::populateAttachments()
   168 void UniViewerHeaderContainer::populateAttachments()
   164 {
   169 {
       
   170     if (!mAttachmentContainer) {
       
   171         // Attachment Container
       
   172         mAttachmentContainer = new UniViewerAttachmentContainer(this);
       
   173         mMainLayout->addItem(mAttachmentContainer);
       
   174     }
       
   175 
   165     UniMessageInfoList attachList = mViewFeeder->attachmentsList();
   176     UniMessageInfoList attachList = mViewFeeder->attachmentsList();
   166     for (int a = 0; a < attachList.count(); ++a) {
   177     for (int a = 0; a < attachList.count(); ++a) {
   167         UniMessageInfo* info = attachList.at(a);
   178         UniMessageInfo* info = attachList.at(a);
   168         mAttachmentContainer->addAttachmentWidget(info->mimetype(), info->path());
   179         mAttachmentContainer->addAttachmentWidget(info->mimetype(), info->path());
   169         delete info;
   180         delete info;
   182 
   193 
   183     // From field is added ONLY for incoming messages.
   194     // From field is added ONLY for incoming messages.
   184     if (mViewFeeder->isIncoming()) {
   195     if (mViewFeeder->isIncoming()) {
   185         mAddressContainer->setFromField(from, alias);
   196         mAddressContainer->setFromField(from, alias);
   186     }
   197     }
   187     // TO field is added ONLY for outgoing messages.
   198     // For outgoing SMS messages add TO field.
   188     else if (!toList.isEmpty()) {
   199     else if (mViewFeeder->msgType() == KSenduiMtmSmsUidValue && !toList.isEmpty()) {
   189         mAddressContainer->setToField(toList);
   200         mAddressContainer->setToField(toList);
   190     }
   201     }
   191 
   202 
   192     // CC field is added ONLY for MMS messages.
   203     // For MMS messages add TO, CC, BCC fields irrespective of incoming/outgoing.
   193     if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) {
   204     if (mViewFeeder->msgType() == KSenduiMtmMmsUidValue) {
       
   205         if (!toList.isEmpty()) {
       
   206             mAddressContainer->setToField(toList);
       
   207         }
   194         ConvergedMessageAddressList ccList = mViewFeeder->ccAddressList();
   208         ConvergedMessageAddressList ccList = mViewFeeder->ccAddressList();
   195         if (!ccList.isEmpty()) {
   209         if (!ccList.isEmpty()) {
   196             mAddressContainer->setCcField(ccList);
   210             mAddressContainer->setCcField(ccList);
   197         }
   211         }
   198     }
   212     }
   199 
   213 
   200     mAddressContainer->insertDivider();
       
   201 }
   214 }
   202 //---------------------------------------------------------------
   215 //---------------------------------------------------------------
   203 // UniViewerHeaderContainer :: setAddrGroupBoxHeading
   216 // UniViewerHeaderContainer :: setAddrGroupBoxHeading
   204 // @see header file
   217 // @see header file
   205 //---------------------------------------------------------------
   218 //---------------------------------------------------------------
   235         address.append(ADDR_LIST_SEPARATOR);
   248         address.append(ADDR_LIST_SEPARATOR);
   236     }
   249     }
   237     address.chop(ADDR_LIST_SEPARATOR.size());
   250     address.chop(ADDR_LIST_SEPARATOR.size());
   238     return address;
   251     return address;
   239 }
   252 }
       
   253 
       
   254 //---------------------------------------------------------------
       
   255 // UniViewerHeaderContainer :: addressBoxToggled
       
   256 // @see header file
       
   257 //---------------------------------------------------------------
       
   258 void UniViewerHeaderContainer::addressBoxToggled(bool state)
       
   259 {
       
   260     (state) ? mSeparator->hide() : mSeparator->show();
       
   261 }