本文整理汇总了C++中QMailMessage::bcc方法的典型用法代码示例。如果您正苦于以下问题:C++ QMailMessage::bcc方法的具体用法?C++ QMailMessage::bcc怎么用?C++ QMailMessage::bcc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QMailMessage
的用法示例。
在下文中一共展示了QMailMessage::bcc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setHeaderField
void tst_QMailMessagePart::setHeaderField()
{
QString addr1("[email protected]");
QString addr2("[email protected]");
QString ownHdr("hello");
QMailMessage m;
m.setHeaderField("To", addr2);
QCOMPARE(m.headerFieldText("to"), addr2);
QCOMPARE(m.headerField("to").content(), addr2.toLatin1());
// Ensure overwrite
m.setHeaderField("To", addr1);
m.setHeaderField("X-My-Own-Header", ownHdr);
QCOMPARE(m.headerFieldText("to"), addr1);
QCOMPARE(m.headerField("to").content(), addr1.toLatin1());
QCOMPARE(m.headerFieldText("X-My-Own-Header"), ownHdr);
QCOMPARE(m.headerField("X-My-Own-Header").content(), ownHdr.toLatin1());
QCOMPARE(m.to(), (QList<QMailAddress>() << QMailAddress(addr1)));
QCOMPARE(m.recipients(), (QList<QMailAddress>() << QMailAddress(addr1)));
QMailMessageMetaData mtdata = *static_cast<QMailMessageMetaData*>(&m);
QCOMPARE(mtdata.recipients(), (QList<QMailAddress>() << QMailAddress(addr1)));
m.setHeaderField("Cc", addr2);
QCOMPARE(m.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2)));
mtdata = *static_cast<QMailMessageMetaData*>(&m);
QCOMPARE(mtdata.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2)));
QCOMPARE(m.cc(), (QList<QMailAddress>() << QMailAddress(addr2)));
QString addr3("[email protected]");
m.setHeaderField("Bcc", addr3);
QCOMPARE(m.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2) << QMailAddress(addr3)));
mtdata = *static_cast<QMailMessageMetaData*>(&m);
QCOMPARE(mtdata.recipients(), (QList<QMailAddress>() << QMailAddress(addr1) << QMailAddress(addr2) << QMailAddress(addr3)));
QCOMPARE(m.bcc(), (QList<QMailAddress>() << QMailAddress(addr3)));
QString rfc822 = m.toRfc2822();
QMailMessage m2 = QMailMessage::fromRfc2822(rfc822.toLatin1());
QCOMPARE(m2.headerFieldText("to"), addr1);
QCOMPARE(m2.headerField("to").content(), addr1.toLatin1());
QCOMPARE(m2.headerFieldText("X-My-Own-Header"), ownHdr);
QCOMPARE(m2.headerField("X-My-Own-Header").content(), ownHdr.toLatin1());
QCOMPARE(m2.to(), (QList<QMailAddress>() << QMailAddress(addr1)));
m2.setTo(QList<QMailAddress>() << QMailAddress(addr2));
QCOMPARE(m2.headerFieldText("to"), addr2);
QCOMPARE(m2.headerField("to").content(), addr2.toLatin1());
QCOMPARE(m2.to(), (QList<QMailAddress>() << QMailAddress(addr2)));
}
示例2: data
QVariant EmailMessageListModel::data(const QModelIndex & index, int role) const {
if (!index.isValid() || index.row() > rowCount(parent(index))) {
qWarning() << Q_FUNC_INFO << "Invalid Index";
return QVariant();
}
if (role == MessageSortByRole) {
return m_sortBy;
}
QMailMessageId msgId = idFromIndex(index);
if (role == QMailMessageModelBase::MessageBodyTextRole) {
QMailMessage message (msgId);
return EmailAgent::instance()->bodyPlainText(message);
}
else if (role == MessageHtmlBodyRole) {
QMailMessage message (msgId);
return bodyHtmlText(message);
}
else if (role == MessageQuotedBodyRole) {
QMailMessage message (msgId);
QString body = EmailAgent::instance()->bodyPlainText(message);
body.prepend('\n');
body.replace('\n', "\n>");
body.truncate(body.size() - 1); // remove the extra ">" put there by QString.replace
return body;
}
else if (role == MessageIdRole) {
return msgId.toULongLong();
}
else if (role == MessageToRole) {
QMailMessage message (msgId);
return QMailAddress::toStringList(message.to());
}
else if (role == MessageCcRole) {
QMailMessage message (msgId);
return QMailAddress::toStringList(message.cc());
}
else if (role == MessageBccRole) {
QMailMessage message (msgId);
return QMailAddress::toStringList(message.bcc());
}
else if (role == MessageSelectModeRole) {
int selected = 0;
if (m_selectedMsgIds.contains(msgId) == true)
selected = 1;
return (selected);
}
QMailMessageMetaData messageMetaData(msgId);
if (role == QMailMessageModelBase::MessageTimeStampTextRole) {
QDateTime timeStamp = messageMetaData.date().toLocalTime();
return (timeStamp.toString("hh:mm MM/dd/yyyy"));
}
else if (role == MessageAttachmentCountRole) {
// return number of attachments
if (!messageMetaData.status() & QMailMessageMetaData::HasAttachments)
return 0;
QMailMessage message(msgId);
const QList<QMailMessagePart::Location> &attachmentLocations = message.findAttachmentLocations();
return attachmentLocations.count();
}
else if (role == MessageAttachmentsRole) {
// return a stringlist of attachments
if (!messageMetaData.status() & QMailMessageMetaData::HasAttachments)
return QStringList();
QMailMessage message(msgId);
QStringList attachments;
foreach (const QMailMessagePart::Location &location, message.findAttachmentLocations()) {
const QMailMessagePart &attachmentPart = message.partAt(location);
attachments << attachmentPart.displayName();
}
return attachments;
}
else if (role == MessageRecipientsRole) {