configurable set priority for card pictures

This commit is contained in:
Max-Wilhelm Bruker
2009-06-20 20:09:19 +02:00
parent e0d773e4e5
commit fb03c5cdbb
10 changed files with 242 additions and 17 deletions

View File

@@ -41,6 +41,19 @@ void CardSet::updateSortKey()
sortKey = settings.value("sortkey", 0).toInt();
}
class SetList::CompareFunctor {
public:
inline bool operator()(CardSet *a, CardSet *b) const
{
return a->getSortKey() < b->getSortKey();
}
};
void SetList::sortByKey()
{
qSort(begin(), end(), CompareFunctor());
}
CardInfo::CardInfo(CardDatabase *_db, const QString &_name, const QString &_manacost, const QString &_cardtype, const QString &_powtough, const QStringList &_text)
: db(_db), name(_name), manacost(_manacost), cardtype(_cardtype), powtough(_powtough), text(_text), pixmap(NULL)
{
@@ -95,14 +108,6 @@ void CardInfo::addToSet(CardSet *set)
sets << set;
}
class CardInfo::SetCompareFunctor {
public:
inline bool operator()(CardSet *a, CardSet *b) const
{
return a->getSortKey() < b->getSortKey();
}
};
QPixmap *CardInfo::loadPixmap()
{
if (pixmap)
@@ -112,7 +117,7 @@ QPixmap *CardInfo::loadPixmap()
pixmap->load("../pics/back.jpg");
return pixmap;
}
qSort(sets.begin(), sets.end(), SetCompareFunctor());
sets.sortByKey();
QString debugOutput = QString("CardDatabase: loading pixmap for '%1' from ").arg(getName());
for (int i = 0; i < sets.size(); i++)
@@ -227,6 +232,17 @@ CardSet *CardDatabase::getSet(const QString &setName)
}
}
SetList CardDatabase::getSetList() const
{
SetList result;
QHashIterator<QString, CardSet *> i(setHash);
while (i.hasNext()) {
i.next();
result << i.value();
}
return result;
}
void CardDatabase::importOracleFile(const QString &fileName, CardSet *set)
{
QFile file(fileName);