remove priority fallback ternary from CardSet model

This commit is contained in:
Cameron McDonald 2024-08-15 19:45:16 -05:00
parent 0d4d21b8ae
commit 006476b4c6
2 changed files with 5 additions and 3 deletions

View file

@ -214,15 +214,17 @@ void SetList::defaultSort()
QDate distantPast = QDate(1970, 1, 1); QDate distantPast = QDate(1970, 1, 1);
QDate aDate = a->getReleaseDate().isValid() ? a->getReleaseDate() : distantPast; QDate aDate = a->getReleaseDate().isValid() ? a->getReleaseDate() : distantPast;
QDate bDate = b->getReleaseDate().isValid() ? b->getReleaseDate() : distantPast; QDate bDate = b->getReleaseDate().isValid() ? b->getReleaseDate() : distantPast;
CardSet::Priority aPriority = a->getPriority() ? a->getPriority() : CardSet::PriorityFallback;
CardSet::Priority bPriority = b->getPriority() ? b->getPriority() : CardSet::PriorityFallback;
// Sort by priority, then by release date, then by short name // Sort by priority, then by release date, then by short name
if (a->getPriority() == b->getPriority()) { if (aPriority == bPriority) {
if (aDate.daysTo(bDate) == 0) { if (aDate.daysTo(bDate) == 0) {
return a->getShortName().compare(b->getShortName()) < 0; return a->getShortName().compare(b->getShortName()) < 0;
} }
return aDate.daysTo(bDate) < 0; return aDate.daysTo(bDate) < 0;
} }
return a->getPriority() < b->getPriority(); return aPriority < bPriority;
}); });
} }

View file

@ -79,7 +79,7 @@ public:
} }
Priority getPriority() const Priority getPriority() const
{ {
return priority ? priority : PriorityFallback; return priority;
} }
void setLongName(const QString &_longName) void setLongName(const QString &_longName)
{ {