| 503 | } |
| 504 | |
| 505 | [[nodiscard]] bool ResourceFolderModel::ProxyModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const |
| 506 | { |
| 507 | auto* model = qobject_cast<ResourceFolderModel*>(sourceModel()); |
| 508 | if (!model || !source_left.isValid() || !source_right.isValid() || source_left.column() != source_right.column()) { |
| 509 | return QSortFilterProxyModel::lessThan(source_left, source_right); |
| 510 | } |
| 511 | |
| 512 | // we are now guaranteed to have two valid indexes in the same column... we love the provided invariants unconditionally and |
| 513 | // proceed. |
| 514 | |
| 515 | auto column_sort_key = model->columnToSortKey(source_left.column()); |
| 516 | auto const& resource_left = model->at(source_left.row()); |
| 517 | auto const& resource_right = model->at(source_right.row()); |
| 518 | |
| 519 | auto compare_result = resource_left.compare(resource_right, column_sort_key); |
| 520 | if (compare_result.first == 0) |
| 521 | return QSortFilterProxyModel::lessThan(source_left, source_right); |
| 522 | |
| 523 | if (compare_result.second || sortOrder() != Qt::DescendingOrder) |
| 524 | return (compare_result.first < 0); |
| 525 | return (compare_result.first > 0); |
| 526 | } |
nothing calls this directly
no test coverage detected