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; }
template <typename Stream> void QMailMessageKey::deserialize(Stream &stream) { int enumInt = 0; stream >> enumInt; d->combiner = static_cast<QMailDataComparator::Combiner>(enumInt); stream >> d->negated; int argumentCount = 0; stream >> argumentCount; for (int i = 0; i < argumentCount; ++i) { QMailMessageKeyPrivate::Argument a; a.deserialize(stream); d->arguments.append(a); } int subKeyCount = 0; stream >> subKeyCount; for (int i = 0; i < subKeyCount; ++i) { QMailMessageKey subKey; subKey.deserialize(stream); d->subKeys.append(subKey); } }
bool QMailMessageListModelPrivate::processMessagesAdded(const QMailMessageIdList &ids) { if (_ignoreUpdates) { // Defer until resynchronised _needSynchronize = true; return true; } if (_key.isNonMatching()) { // No messages are relevant return true; } init(); // Find if and where these messages should be added if (!addMessages(ids)) { return false; } return true; }