new zone view code

This commit is contained in:
Max-Wilhelm Bruker 2010-03-08 15:55:35 +01:00
parent ad3f4ba9e8
commit 26a77d9e40
27 changed files with 474 additions and 397 deletions

View file

@ -1,5 +1,6 @@
#include "cardlist.h"
#include "carditem.h"
#include "carddatabase.h"
CardList::CardList(bool _contentsKnown)
: QList<CardItem *>(), contentsKnown(_contentsKnown)
@ -32,15 +33,27 @@ CardItem *CardList::findCard(const int id, const bool remove, int *position)
}
class CardList::compareFunctor {
private:
int flags;
public:
compareFunctor(int _flags) : flags(_flags)
{
}
inline bool operator()(CardItem *a, CardItem *b) const
{
return a->getName() < b->getName();
if (flags & SortByType) {
QString t1 = a->getInfo()->getMainCardType();
QString t2 = b->getInfo()->getMainCardType();
if ((t1 == t2) && (flags & SortByName))
return a->getName() < b->getName();
return t1 < t2;
} else
return a->getName() < b->getName();
}
};
void CardList::sort()
void CardList::sort(int flags)
{
compareFunctor cf;
compareFunctor cf(flags);
qSort(begin(), end(), cf);
}