本文整理汇总了C++中QMailMessage::partAt方法的典型用法代码示例。如果您正苦于以下问题:C++ QMailMessage::partAt方法的具体用法?C++ QMailMessage::partAt怎么用?C++ QMailMessage::partAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMailMessage
的用法示例。
在下文中一共展示了QMailMessage::partAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setMessage
void EmailComposerInterface::setMessage( const QMailMessage &mail )
{
if (mail.multipartType() == QMailMessagePartContainer::MultipartNone) {
if (mail.hasBody())
setText( mail.body().data(), mail.contentType().content() );
} else {
// The only type of multipart message we currently compose is Mixed, with
// all but the first part as out-of-line attachments
int textPart = -1;
for ( uint i = 0; i < mail.partCount(); ++i ) {
QMailMessagePart &part = const_cast<QMailMessagePart&>(mail.partAt(i));
if (textPart == -1 && part.contentType().type().toLower() == "text") {
// This is the first text part, we will use as the forwarded text body
textPart = i;
} else {
QString attPath = part.attachmentPath();
QMailMessage::AttachmentsAction action = QMailMessage::LinkToAttachments;
// Detach the part data to a temporary file if necessary
if (attPath.isEmpty()) {
if (part.detachAttachment(Qtopia::tempDir())) {
attPath = part.attachmentPath();
action = QMailMessage::CopyAttachments;
// Create a content object for the file
QContent doc(attPath);
if (part.hasBody()) {
QMailMessageContentType type(part.contentType());
if (doc.drmState() == QContent::Unprotected)
doc.setType(type.content());
}
doc.setName(part.displayName());
doc.setRole(QContent::Data);
doc.commit();
// This needs to be removed after composition
m_temporaries.append(doc);
}
}
if (!attPath.isEmpty())
attach(attPath, action);
}
}
if (textPart != -1) {
const QMailMessagePart& part = mail.partAt(textPart);
setText( part.body().data(), part.contentType().content() );
}
}
}
示例2: processAttachments
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);
}
}
示例3: attachmentUrl
QString AttachmentListModel::attachmentUrl(const QMailMessage message, const QString &attachmentLocation)
{
QString attachmentDownloadFolder = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation) + "/mail_attachments/" + attachmentLocation;
for (uint i = 0; i < message.partCount(); i++) {
QMailMessagePart sourcePart = message.partAt(i);
if (attachmentLocation == sourcePart.location().toString(true)) {
QString attachmentPath = attachmentDownloadFolder + "/" + sourcePart.displayName();
QFile f(attachmentPath);
if (f.exists()) {
return attachmentPath;
} else {
// we have the part downloaded locally but not in a file type yet
if (sourcePart.hasBody()) {
QString path = sourcePart.writeBodyTo(attachmentDownloadFolder);
return path;
}
return QString();
}
}
}
return QString();
}