Ejemplo n.º 1
0
QMessageFilter QMessageFilter::byRecipients(const QString &pattern, QMessageDataComparator::LikeComparator cmp)
{
    QMessageIdList ids;

    foreach (QMessageId const& id, QMessageManager().queryMessages()) {
        QMessage msg(id);
        QMessageAddressList addressList(msg.to());
        addressList.append(msg.cc());
        addressList.append(msg.bcc());

        bool matched(false);

        foreach (QMessageAddress const& addr, addressList) {
            if (MessagingUtil::globMatch(pattern, addr.addressee())) {
                matched = true;
                break;
            }
        }

        if ((matched && cmp == QMessageDataComparator::Like)
                || (!matched && cmp == QMessageDataComparator::NotLike)) {
            ids.push_back(id);
        }
    }

    return QMessageFilter::byId(ids);
}
Ejemplo n.º 2
0
QMessageFilter QMessageFilter::bySubject(const QString &pattern, QMessageDataComparator::LikeComparator cmp)
{
    QMessageIdList ids;
    foreach (QMessageId const& id, QMessageManager().queryMessages()) {
        bool matched(MessagingUtil::globMatch(pattern, QMessage(id).subject()));
        if ((matched && cmp == QMessageDataComparator::Like)
                || (!matched && cmp == QMessageDataComparator::NotLike)) {
            ids.push_back(id);
        }
    }

    return QMessageFilter::byId(ids);
}