bool QMessageAccountSortOrderPrivate::lessThan(const QMessageAccountSortOrder &sortOrder, const QMessageAccount &account1, const QMessageAccount &account2) { QMessageAccountSortOrderPrivate *d(sortOrder.d_ptr); if (d->_order == Qt::AscendingOrder) { return (account1.name().compare(account2.name(), Qt::CaseInsensitive) < 0); } return (account1.name().compare(account2.name(), Qt::CaseInsensitive) > 0); }
bool QMessageAccountFilterPrivate::filter(const QMessageAccount &messageAccount, const QMessageAccountFilterPrivate &filter) { if ((filter._field == QMessageAccountFilterPrivate::None) && (filter._filterList.count() == 0)) { if (filter._notFilter) { return false; } else { return true; } } Qt::CaseSensitivity caseSensitivity = (filter._matchFlags & QMessageDataComparator::MatchCaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive; switch (filter._field) { case QMessageAccountFilterPrivate::Id: { if (filter._comparatorType == QMessageAccountFilterPrivate::Equality) { QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(filter._comparatorValue)); if (cmp == QMessageDataComparator::Equal) { if (messageAccount.id().toString() == filter._value.toString()) { return true; } } else { // NotEqual if (!(messageAccount.id().toString() == filter._value.toString())) { return true; } } } else if (filter._comparatorType == QMessageAccountFilterPrivate::Inclusion) { QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(filter._comparatorValue)); if (cmp == QMessageDataComparator::Includes) { if (filter._ids.contains(messageAccount.id())) { return true; } } else { // Excludes if (!filter._ids.contains(messageAccount.id())) { return true; } } } break; } case QMessageAccountFilterPrivate::Name: { if (filter._comparatorType == QMessageAccountFilterPrivate::Equality) { QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(filter._comparatorValue)); if (cmp == QMessageDataComparator::Equal) { if (messageAccount.name().compare(filter._value.toString(),caseSensitivity) == 0) { return true; } } else { // NotEqual if (messageAccount.name().compare(filter._value.toString(),caseSensitivity) != 0) { return true; } } } else if (filter._comparatorType == QMessageAccountFilterPrivate::Inclusion) { QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(filter._comparatorValue)); if (cmp == QMessageDataComparator::Includes) { if (messageAccount.name().contains(filter._value.toString(),caseSensitivity)) { return true; } } else { // Excludes if (!messageAccount.name().contains(filter._value.toString(),caseSensitivity)) { return true; } } } break; } case QMessageAccountFilterPrivate::None: break; } return false; }