<commit_before>#include "messagesortfilter.h"
#include "eavesdroppermodel.h"

MessageSortFilter::MessageSortFilter()
{
    setDynamicSortFilter(true);
}

bool MessageSortFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    if (m_filterString.isEmpty() || sourceParent.isValid()) {
        return true;
    }
    EavesdropperModel *model = static_cast<EavesdropperModel *>(sourceModel());

    const std::vector<MessageRecord> &msgList = model->m_messages;
    const MessageRecord &msg = msgList[sourceRow];
    return msg.conversationMethod(msgList).contains(m_filterString, Qt::CaseInsensitive) ||
           msg.niceSender(msgList).contains(m_filterString, Qt::CaseInsensitive) ||
           msg.niceDestination(msgList).contains(m_filterString, Qt::CaseInsensitive);
}

bool MessageSortFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
    Q_ASSERT(!left.parent().isValid());
    Q_ASSERT(!right.parent().isValid());
    EavesdropperModel *model = static_cast<EavesdropperModel *>(sourceModel());
    const std::vector<MessageRecord> &msgList = model->m_messages;
    const MessageRecord &leftMsg = msgList[left.row()];
    const MessageRecord &rightMsg = msgList[right.row()];

    return leftMsg.conversationStartTime(msgList) < rightMsg.conversationStartTime(msgList);
}

void MessageSortFilter::setFilterString(const QString &s)
{
    m_filterString = s;
    invalidateFilter();
}<commit_msg>Additionally match interface and object path in the filter.<commit_after>#include "messagesortfilter.h"
#include "eavesdroppermodel.h"

#include "message.h"

MessageSortFilter::MessageSortFilter()
{
    setDynamicSortFilter(true);
}

bool MessageSortFilter::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
    if (m_filterString.isEmpty() || sourceParent.isValid()) {
        return true;
    }
    EavesdropperModel *model = static_cast<EavesdropperModel *>(sourceModel());

    const std::vector<MessageRecord> &msgList = model->m_messages;
    const MessageRecord &msg = msgList[sourceRow];
    return msg.conversationMethod(msgList).contains(m_filterString, Qt::CaseInsensitive) ||
           msg.niceSender(msgList).contains(m_filterString, Qt::CaseInsensitive) ||
           msg.niceDestination(msgList).contains(m_filterString, Qt::CaseInsensitive) ||
           QString::fromStdString(msg.message->interface()).contains(m_filterString, Qt::CaseInsensitive) ||
           QString::fromStdString(msg.message->path()).contains(m_filterString, Qt::CaseInsensitive);
}

bool MessageSortFilter::lessThan(const QModelIndex &left, const QModelIndex &right) const
{
    Q_ASSERT(!left.parent().isValid());
    Q_ASSERT(!right.parent().isValid());
    EavesdropperModel *model = static_cast<EavesdropperModel *>(sourceModel());
    const std::vector<MessageRecord> &msgList = model->m_messages;
    const MessageRecord &leftMsg = msgList[left.row()];
    const MessageRecord &rightMsg = msgList[right.row()];

    return leftMsg.conversationStartTime(msgList) < rightMsg.conversationStartTime(msgList);
}

void MessageSortFilter::setFilterString(const QString &s)
{
    m_filterString = s;
    invalidateFilter();
}
{'fraction_non_alphanumeric': 0.12550860719874804, 'fraction_numerical': 0.0, 'mean_word_length': 5.714285714285714, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5516201', 'n_tokens_mistral': 939, 'n_tokens_neox': 944, 'n_words': 160}