mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-17 07:52:16 -07:00
reuse comparator
This commit is contained in:
parent
d38e9ca1b9
commit
9ee575c1a2
2 changed files with 2 additions and 19 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
#include "picture_to_load.h"
|
#include "picture_to_load.h"
|
||||||
|
|
||||||
#include "../../../settings/cache_settings.h"
|
#include "../../../settings/cache_settings.h"
|
||||||
|
#include "../../../utility/card_set_comparator.h"
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDate>
|
#include <QDate>
|
||||||
|
|
@ -20,7 +21,7 @@ PictureToLoad::PictureToLoad(CardInfoPtr _card)
|
||||||
if (sortedSets.empty()) {
|
if (sortedSets.empty()) {
|
||||||
sortedSets << CardSet::newInstance("", "", "", QDate());
|
sortedSets << CardSet::newInstance("", "", "", QDate());
|
||||||
}
|
}
|
||||||
std::sort(sortedSets.begin(), sortedSets.end(), SetDownloadPriorityComparator());
|
std::sort(sortedSets.begin(), sortedSets.end(), SetPriorityComparator());
|
||||||
|
|
||||||
// If the user hasn't disabled arts other than their personal preference...
|
// If the user hasn't disabled arts other than their personal preference...
|
||||||
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
if (!SettingsCache::instance().getOverrideAllCardArtWithPersonalPreference()) {
|
||||||
|
|
|
||||||
|
|
@ -10,24 +10,6 @@ inline Q_LOGGING_CATEGORY(PictureToLoadLog, "picture_loader.picture_to_load");
|
||||||
class PictureToLoad
|
class PictureToLoad
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
class SetDownloadPriorityComparator
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/*
|
|
||||||
* Returns true if a has higher download priority than b
|
|
||||||
* Enabled sets have priority over disabled sets
|
|
||||||
* Both groups follows the user-defined order
|
|
||||||
*/
|
|
||||||
inline bool operator()(const CardSetPtr &a, const CardSetPtr &b) const
|
|
||||||
{
|
|
||||||
if (a->getEnabled()) {
|
|
||||||
return !b->getEnabled() || a->getSortKey() < b->getSortKey();
|
|
||||||
} else {
|
|
||||||
return !b->getEnabled() && a->getSortKey() < b->getSortKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
CardInfoPtr card;
|
CardInfoPtr card;
|
||||||
QList<CardSetPtr> sortedSets;
|
QList<CardSetPtr> sortedSets;
|
||||||
QList<QString> urlTemplates;
|
QList<QString> urlTemplates;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue