Merge pull request #1286 from ctrlaltca/disabled_sets
Prefer enabled sets when loading images
This commit is contained in:
commit
e318b70329
3 changed files with 42 additions and 5 deletions
|
@ -92,7 +92,7 @@ void CardSet::setIsKnown(bool _isknown)
|
||||||
settings.setValue("isknown", isknown);
|
settings.setValue("isknown", isknown);
|
||||||
}
|
}
|
||||||
|
|
||||||
class SetList::CompareFunctor {
|
class SetList::KeyCompareFunctor {
|
||||||
public:
|
public:
|
||||||
inline bool operator()(CardSet *a, CardSet *b) const
|
inline bool operator()(CardSet *a, CardSet *b) const
|
||||||
{
|
{
|
||||||
|
@ -102,7 +102,39 @@ public:
|
||||||
|
|
||||||
void SetList::sortByKey()
|
void SetList::sortByKey()
|
||||||
{
|
{
|
||||||
qSort(begin(), end(), CompareFunctor());
|
qSort(begin(), end(), KeyCompareFunctor());
|
||||||
|
}
|
||||||
|
|
||||||
|
class SetList::EnabledAndKeyCompareFunctor {
|
||||||
|
public:
|
||||||
|
inline bool operator()(CardSet *a, CardSet *b) const
|
||||||
|
{
|
||||||
|
if(a->getEnabled())
|
||||||
|
{
|
||||||
|
if(b->getEnabled())
|
||||||
|
{
|
||||||
|
// both enabled: sort by key
|
||||||
|
return a->getSortKey() < b->getSortKey();
|
||||||
|
} else {
|
||||||
|
// only a enabled
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(b->getEnabled())
|
||||||
|
{
|
||||||
|
// only b enabled
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
// both disabled: sort by key
|
||||||
|
return a->getSortKey() < b->getSortKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void SetList::sortByEnabledAndKey()
|
||||||
|
{
|
||||||
|
qSort(begin(), end(), EnabledAndKeyCompareFunctor());
|
||||||
}
|
}
|
||||||
|
|
||||||
int SetList::getEnabledSetsNum()
|
int SetList::getEnabledSetsNum()
|
||||||
|
@ -185,7 +217,7 @@ PictureToLoad::PictureToLoad(CardInfo *_card, bool _hq)
|
||||||
{
|
{
|
||||||
if (card) {
|
if (card) {
|
||||||
sortedSets = card->getSets();
|
sortedSets = card->getSets();
|
||||||
sortedSets.sortByKey();
|
sortedSets.sortByEnabledAndKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -857,6 +889,8 @@ void CardDatabase::clearPixmapCache()
|
||||||
}
|
}
|
||||||
if (noCard)
|
if (noCard)
|
||||||
noCard->clearPixmapCache();
|
noCard->clearPixmapCache();
|
||||||
|
|
||||||
|
QPixmapCache::clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
void CardDatabase::loadSetsFromXml(QXmlStreamReader &xml)
|
||||||
|
|
|
@ -54,8 +54,10 @@ public:
|
||||||
|
|
||||||
class SetList : public QList<CardSet *> {
|
class SetList : public QList<CardSet *> {
|
||||||
private:
|
private:
|
||||||
class CompareFunctor;
|
class KeyCompareFunctor;
|
||||||
|
class EnabledAndKeyCompareFunctor;
|
||||||
public:
|
public:
|
||||||
|
void sortByEnabledAndKey();
|
||||||
void sortByKey();
|
void sortByKey();
|
||||||
void guessSortKeys();
|
void guessSortKeys();
|
||||||
void enableAllUnknown();
|
void enableAllUnknown();
|
||||||
|
|
|
@ -92,7 +92,7 @@ WndSets::WndSets(QWidget *parent)
|
||||||
|
|
||||||
|
|
||||||
QLabel *labNotes = new QLabel;
|
QLabel *labNotes = new QLabel;
|
||||||
labNotes->setText("<b>" + tr("hints:") + "</b>" + "<ul><li>" + tr("Enable the sets that you want to have available in the deck editor") + "</li><li>" + tr("Move sets around to change their order, or click on a column header to sort sets on that field") + "</li><li>" + tr("Sets order decides the source that will be used when loading images for a specific card") + "</li><li>" + tr("Disabled sets will still be used for loading images") + "</li></ul>");
|
labNotes->setText("<b>" + tr("hints:") + "</b>" + "<ul><li>" + tr("Enable the sets that you want to have available in the deck editor") + "</li><li>" + tr("Move sets around to change their order, or click on a column header to sort sets on that field") + "</li><li>" + tr("Sets order decides the source that will be used when loading images for a specific card") + "</li><li>" + tr("Disabled sets will be used for loading images only if all the enabled sets failed") + "</li></ul>");
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave()));
|
connect(buttonBox, SIGNAL(accepted()), this, SLOT(actSave()));
|
||||||
|
@ -123,6 +123,7 @@ WndSets::~WndSets()
|
||||||
void WndSets::actSave()
|
void WndSets::actSave()
|
||||||
{
|
{
|
||||||
model->save(db);
|
model->save(db);
|
||||||
|
db->clearPixmapCache();
|
||||||
QMessageBox::information(this, tr("Success"), tr("The sets database has been saved successfully."));
|
QMessageBox::information(this, tr("Success"), tr("The sets database has been saved successfully."));
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue