emailuis/nmailui/src/nmeditorheader.cpp
changeset 20 ecc8def7944a
parent 18 578830873419
child 23 2dc6caa42ec3
equal deleted inserted replaced
18:578830873419 20:ecc8def7944a
   100 
   100 
   101     // Add attachment list
   101     // Add attachment list
   102     NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
   102     NmAttachmentListWidget *attachmentList = qobject_cast<NmAttachmentListWidget *>
   103         (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
   103         (mDocumentLoader->findWidget(NMUI_EDITOR_ATTACHMENT_LIST));
   104     // Create attachment list handling object
   104     // Create attachment list handling object
   105     mAttachmentList = new NmAttachmentList(attachmentList);
   105     mAttachmentList = new NmAttachmentList(*attachmentList);
   106 
   106 
   107     mPriorityIconLabel = qobject_cast<HbLabel *>
   107     mPriorityIconLabel = qobject_cast<HbLabel *>
   108         (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
   108         (mDocumentLoader->findWidget(NMUI_EDITOR_PRIORITY_ICON));
   109 }
   109 }
   110 
   110 
   133     // Signal for handling the recipient group box expanding/collapsing
   133     // Signal for handling the recipient group box expanding/collapsing
   134     connect(mGroupBoxRecipient, SIGNAL(toggled(bool)),
   134     connect(mGroupBoxRecipient, SIGNAL(toggled(bool)),
   135             this, SLOT(groupBoxExpandCollapse()));
   135             this, SLOT(groupBoxExpandCollapse()));
   136 
   136 
   137     // Signals for handling the attachment list
   137     // Signals for handling the attachment list
   138     connect(mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)),
   138     connect(&mAttachmentList->listWidget(), SIGNAL(itemActivated(int)),
   139             this, SLOT(attachmentSelected(int, QPointF)));
   139             this, SLOT(attachmentActivated(int)));
       
   140     connect(&mAttachmentList->listWidget(), SIGNAL(longPressed(int, QPointF)),
       
   141             this, SLOT(attachmentLongPressed(int, QPointF)));
   140     connect(mAttachmentList ,SIGNAL(attachmentListLayoutChanged()),
   142     connect(mAttachmentList ,SIGNAL(attachmentListLayoutChanged()),
   141             this, SLOT(sendHeaderHeightChanged()));
   143             this, SLOT(sendHeaderHeightChanged()));
   142 }
   144 }
   143 
   145 
   144 /*!
   146 /*!
   170             mGroupBoxRecipientContent->geometry().height() + HeaderAreaMarginsTotal;
   172             mGroupBoxRecipientContent->geometry().height() + HeaderAreaMarginsTotal;
   171     }
   173     }
   172 
   174 
   173     qreal attHeight = 0;
   175     qreal attHeight = 0;
   174     if (mAttachmentList && mAttachmentList->count() > 0) {
   176     if (mAttachmentList && mAttachmentList->count() > 0) {
   175         attHeight = mAttachmentList->listWidget()->geometry().height();
   177         attHeight = mAttachmentList->listWidget().geometry().height();
   176     }
   178     }
   177 
   179 
   178     return (int)(toHeight + recipientGroupBoxHeight + subjectHeight + attHeight);
   180     return (int)(toHeight + recipientGroupBoxHeight + subjectHeight + attHeight);
   179 }
   181 }
   180 
   182 
   372     mAttachmentList->insertAttachment(fileName, fileSize, nmid);
   374     mAttachmentList->insertAttachment(fileName, fileSize, nmid);
   373     sendHeaderHeightChanged();
   375     sendHeaderHeightChanged();
   374 }
   376 }
   375 
   377 
   376 /*!
   378 /*!
   377    Remove attachment from the list. This function is used when attachment adding has failed
   379    Remove attachment from the list. This function is used when
   378    and attachment id is not known.
   380    attachment adding has failed and attachment id is not known.
   379  */
   381  */
   380 void NmEditorHeader::removeAttachment(const QString &fileName)
   382 void NmEditorHeader::removeAttachment(const QString &fileName)
   381 {
   383 {
   382     mAttachmentList->removeAttachment(fileName);
   384     mAttachmentList->removeAttachment(fileName);
       
   385     sendHeaderHeightChanged();
       
   386 }
       
   387 
       
   388 /*!
       
   389    Remove attachment from the list. This function is used when
       
   390    attachment has been selected for remove.
       
   391  */
       
   392 void NmEditorHeader::removeAttachment(const NmId &nmid)
       
   393 {
       
   394     mAttachmentList->removeAttachment(nmid);
   383     sendHeaderHeightChanged();
   395     sendHeaderHeightChanged();
   384 }
   396 }
   385 
   397 
   386 /*!
   398 /*!
   387     This function set messagePartId and fileSize for attachment.
   399     This function set messagePartId and fileSize for attachment.
   398         mAttachmentList->setAttachmentSize(msgPartId, fileSize);
   410         mAttachmentList->setAttachmentSize(msgPartId, fileSize);
   399     }
   411     }
   400 }
   412 }
   401 
   413 
   402 /*!
   414 /*!
       
   415    Attachment launched from attachment list by "open" menu item.
       
   416  */
       
   417 void NmEditorHeader::launchAttachment(const NmId &itemId)
       
   418 {
       
   419     attachmentActivated(mAttachmentList->indexByNmId(itemId));
       
   420 }
       
   421 
       
   422 /*!
       
   423    Slot attachment activated from attachment list by short tap.
       
   424  */
       
   425 void NmEditorHeader::attachmentActivated(int arrayIndex)
       
   426 {
       
   427     const char *engineerText="Unable to open. Attachment file type not supported";
       
   428     const char *localizedText="txt_mail_dialog_unable_to_open_attachment_file_ty";
       
   429 	
       
   430     QFile launchFile(mAttachmentList->getFullFileNameByIndex(arrayIndex));
       
   431     if (NmUtilities::openFile( launchFile ) == NmNotFoundError) {
       
   432         NmUtilities::displayErrorNote( QObject::tr(engineerText, localizedText) ); 
       
   433     }
       
   434 }
       
   435 
       
   436 /*!
   403    Slot attachment selected from attachment list by longtap.
   437    Slot attachment selected from attachment list by longtap.
   404  */
   438  */
   405 void NmEditorHeader::attachmentSelected(int arrayIndex, QPointF point)
   439 void NmEditorHeader::attachmentLongPressed(int arrayIndex, QPointF point)
   406 {
   440 {
   407     Q_UNUSED(point);
       
   408     // Remove selected attachment
   441     // Remove selected attachment
   409     emit attachmentRemoved(mAttachmentList->nmIdByIndex(arrayIndex));
   442     emit attachmentLongPressed(mAttachmentList->nmIdByIndex(arrayIndex), point);
   410     mAttachmentList->removeAttachment(arrayIndex);
       
   411 }
   443 }
   412     
   444