bool ConversationsSortFilterProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{
QModelIndex index = sourceModel()->index(sourceRow, 0, sourceParent);
if (filterRole() == ConversationListModel::ConversationIdRole) {
return sourceModel()->data(index, ConversationListModel::ConversationIdRole) != INVALID_THREAD_ID;
} else {
if (sourceModel()->data(index, Qt::DisplayRole).toString().contains(filterRegExp())) {
return true;
}
// This block of code compares each address in the multi target conversation to find a match
const QList addressList = sourceModel()->data(index, ConversationListModel::AddressesRole).value>();
for (const ConversationAddress &address : addressList) {
QString canonicalAddress = SmsHelper::canonicalizePhoneNumber(address.address());
if (canonicalAddress.contains(filterRegExp())) {
return true;
}
}
}
return false;
}
This implements checking if the given row is accepted by the filter. It first checks if the source row is of the correct type, then checks if the source row contains the filter regex. If the filter is of the typeConversationIdRole, the source row is of the typeConversationIdRole, the source model is of the typeConversationListModel::ConversationIdRole, the source model is of the typeConversationListModel::ConversationIdRole, the source model is of the typeConversationListModel::AddressesRole, the filter is of the typeConversationListModel::AddressesRole, the function checks if the source row contains the filter regex, if the filter is of the typeConversationIdRole, the source model contains the invalid_thread_id, the source row is of the typeConversationIdRole, the source model is of the typeConversationListModel::DisplayRole, the source model is of the typeConversationListModel::AddressesRole, the filter is of the typeConversationListModel::AddressesRole, the filter is of the typeConversationListModel::The filter is of the typeConversationListModel::TheFilterRegExp() function, which checks if the filter is of the typeConversationIdRole, the filter is true, and the filter is not a valid_thread_id, the source model is of the typeConversationIdRole, the filter is of the typeConversationList, the filter is of the typeConversationList, the filter is of the typeConversationList, the filter is