Commit 6744a932 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵

let GridViewProxyModel be able to filter tracks by rating

parent 10f771a8
......@@ -30,9 +30,16 @@ bool GridViewProxyModel::filterAcceptsRow(int source_row, const QModelIndex &sou
const auto &mainValue = sourceModel()->data(currentIndex, Qt::DisplayRole).toString();
const auto &artistValue = sourceModel()->data(currentIndex, DataTypes::ArtistRole).toString();
const auto &allArtistsValue = sourceModel()->data(currentIndex, DataTypes::AllArtistsRole).toStringList();
const auto maximumRatingValue = sourceModel()->data(currentIndex, DataTypes::HighestTrackRating).toInt();
if (maximumRatingValue < mFilterRating) {
bool collectionMaximumRatingValueIsValid = false;
const auto collectionMaximumRatingValue = sourceModel()->data(currentIndex, DataTypes::HighestTrackRating).toInt(&collectionMaximumRatingValueIsValid);
bool maximumRatingValueIsValid = false;
const auto maximumRatingValue = sourceModel()->data(currentIndex, DataTypes::RatingRole).toInt(&maximumRatingValueIsValid);
if ((collectionMaximumRatingValueIsValid && maximumRatingValueIsValid &&
collectionMaximumRatingValue < mFilterRating && maximumRatingValue < mFilterRating) ||
(collectionMaximumRatingValueIsValid && !maximumRatingValueIsValid && collectionMaximumRatingValue < mFilterRating) ||
(!collectionMaximumRatingValueIsValid && maximumRatingValueIsValid && maximumRatingValue < mFilterRating) ||
(!collectionMaximumRatingValueIsValid && !maximumRatingValueIsValid && mFilterRating)) {
result = false;
return result;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment