本文整理汇总了C++中QMailMessage::hasBody方法的典型用法代码示例。如果您正苦于以下问题:C++ QMailMessage::hasBody方法的具体用法?C++ QMailMessage::hasBody怎么用?C++ QMailMessage::hasBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMailMessage
的用法示例。
在下文中一共展示了QMailMessage::hasBody方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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() );
}
}
}