QMailMessageKey EmailStandardFolderMessageSet::contentKey(QMailFolder::StandardFolder type) { QMailMessageKey key; quint64 setMask = 0; quint64 unsetMask = 0; switch (type) { case QMailFolder::OutboxFolder: setMask = QMailMessage::Outbox; unsetMask = QMailMessage::Trash; break; case QMailFolder::DraftsFolder: setMask = QMailMessage::Draft; unsetMask = QMailMessage::Trash | QMailMessage::Outbox; break; case QMailFolder::TrashFolder: setMask = QMailMessage::Trash; break; case QMailFolder::SentFolder: setMask = QMailMessage::Sent; unsetMask = QMailMessage::Trash; break; case QMailFolder::JunkFolder: setMask = QMailMessage::Junk; unsetMask = QMailMessage::Trash; break; default: break; } if (setMask) { key &= QMailMessageKey(QMailMessageKey::status(setMask, QMailDataComparator::Includes)); } if (unsetMask) { key &= QMailMessageKey(QMailMessageKey::status(unsetMask, QMailDataComparator::Excludes)); } if (key.isEmpty()) { return QMailMessageKey::nonMatchingKey(); } return key; }
QMailMessageKey QMailMessageKey::operator|(const QMailMessageKey& other) const { if (isEmpty() || isNonMatching()) return other; else if (other.isEmpty() || other.isNonMatching()) return *this; QMailMessageKey k; k.d->combiner = Or; if(d->combiner != And && !d->negated && other.d->combiner != And && !other.d->negated) { k.d->subKeys = d->subKeys + other.d->subKeys; k.d->arguments = d->arguments + other.d->arguments; } else { k.d->subKeys.append(*this); k.d->subKeys.append(other); } return k; }
QMessageFilter QMessageFilter::byStatus(QMessage::StatusFlags mask, QMessageDataComparator::InclusionComparator cmp) { QMailMessageKey key; // This should be interpreted as specifying a match or otherwise on each of the flags set in the mask if (mask & QMessage::Read) { key &= QMailMessageKey::status(convert(QMessage::Read), convert(cmp)); } if (mask & QMessage::HasAttachments) { key &= QMailMessageKey::status(convert(QMessage::HasAttachments), convert(cmp)); } if (mask & QMessage::Incoming) { key &= QMailMessageKey::status(convert(QMessage::Incoming), convert(cmp)); } if (mask & QMessage::Removed) { key &= QMailMessageKey::status(convert(QMessage::Removed), convert(cmp)); } QMessageFilter result; result.d_ptr->_key = (key.isEmpty() ? QMailMessageKey::nonMatchingKey() : key); return result; }