void ConversationPage::processAttachments(const QMailMessage &message) { if (!message.status() & QMailMessageMetaData::HasAttachments) return; connect(this, SIGNAL(downloadCompleted()), this, SLOT(saveAttachment())); bool oneTimeFlag = true; for (uint i = 1; i < message.partCount(); ++i) { QMailMessagePart sourcePart = message.partAt(i); if (!(sourcePart.multipartType() == QMailMessagePartContainer::MultipartNone)) continue; if (oneTimeFlag) { MSeparator *separator = new MSeparator(); separator->setObjectName("Separator"); m_policy->addItem(separator); oneTimeFlag = false; } MStylableWidget *w = new MStylableWidget(this); QGraphicsLinearLayout *layout = new QGraphicsLinearLayout(Qt::Horizontal); w->setLayout(layout); //% "Attached: " MLabel *label = new MLabel(qtTrId("xx_attached")); label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); label->setObjectName ("AttachmentText"); layout->addItem(label); MButton *button = new MButton(sourcePart.displayName()); button->setObjectName ("AttachmentButton"); button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); layout->addItem(button); //% "Download..." AttachmentAction *action = new AttachmentAction(qtTrId("xx_download_context_menu"), button, sourcePart); connect(action, SIGNAL(triggered()), this, SLOT(openAttachmentDownloadDialog())); //% "Open..." action = new AttachmentAction(qtTrId("xx_open_context_menu"), button, sourcePart); connect(action, SIGNAL(triggered()), this, SLOT(openAttachmentOpenDialog())); m_policy->addItem (w); } }
void ConversationPage::createContent() { MApplicationPage::createContent(); setContentsMargins(0, 0, 0, 0); setPannable(true); createActions(); //% "Mail" setTitle(qtTrId("xx_page_title")); MLayout *layout = new MLayout(centralWidget()); layout->setContentsMargins(0, 0, 0, 0); layout->setAnimation(0); m_policy = new MLinearLayoutPolicy(layout, Qt::Vertical); m_policy->setObjectName("VerticalPolicy"); m_policy->setContentsMargins(0, 0, 0, 0); m_policy->setSpacing(0); QMailMessage message(m_id); //% "From" QString body = qtTrId("xx_from") + ": " + message.from().address() + "\n"; QStringList addresses = QMailAddress::toStringList(message.to()); //% "To" body.append(qtTrId("xx_to") + ": " + addresses.join("; ") + "\n"); addresses = QMailAddress::toStringList(message.cc()); if (addresses.size() > 0) //% "Cc" body.append(qtTrId("xx_cc" ) + ": " + addresses.join("; ") + "\n"); addresses = QMailAddress::toStringList(message.bcc()); if (addresses.size() > 0) //% "Bcc" body.append(qtTrId("xx_bcc" ) + ": " + addresses.join("; ") + "\n"); QMailAddress replyTo = message.replyTo(); if (!replyTo.isNull()) //% "Reply-To" body.append(qtTrId("xx_reply_to") + ": " + replyTo.toString() + "\n"); //% "Subject" body.append(qtTrId("xx_subject") + ": " + message.subject() + "\n"); //% "Date: %1" body.append(qtTrId("xx_date").arg(message.date().toLocalTime().toString(Qt::SystemLocaleShortDate))); MLabel *messageBody = new MLabel(body); messageBody->setWordWrap(true); messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); messageBody->setObjectName("BodyText"); m_policy->addItem(messageBody); MSeparator *separator = new MSeparator(); separator->setObjectName("Separator"); m_policy->addItem(separator); messageBody = new MLabel("\n" + Utils::bodyPlainText(&message)); messageBody->setWordWrap(true); messageBody->setObjectName("BodyText"); messageBody->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); m_policy->addItem (messageBody); processAttachments(message); centralWidget()->setLayout(layout); }