mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-20 09:22:15 -07:00
refactor to use lambda
This commit is contained in:
parent
b1911d13c8
commit
db858e3140
2 changed files with 4 additions and 19 deletions
|
|
@ -31,17 +31,9 @@ CardItem *CardList::findCard(const int cardId) const
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
class CardList::compareFunctor
|
||||
void CardList::sort(int flags)
|
||||
{
|
||||
private:
|
||||
int flags;
|
||||
|
||||
public:
|
||||
explicit compareFunctor(int _flags) : flags(_flags)
|
||||
{
|
||||
}
|
||||
inline bool operator()(CardItem *a, CardItem *b) const
|
||||
{
|
||||
auto comparator = [flags](CardItem *a, CardItem *b) {
|
||||
if (flags & SortByType) {
|
||||
QString t1 = a->getInfo() ? a->getInfo()->getMainCardType() : QString();
|
||||
QString t2 = b->getInfo() ? b->getInfo()->getMainCardType() : QString();
|
||||
|
|
@ -50,11 +42,7 @@ public:
|
|||
return t1 < t2;
|
||||
} else
|
||||
return a->getName() < b->getName();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void CardList::sort(int flags)
|
||||
{
|
||||
compareFunctor cf(flags);
|
||||
std::sort(begin(), end(), cf);
|
||||
std::sort(begin(), end(), comparator);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,6 @@ class CardItem;
|
|||
|
||||
class CardList : public QList<CardItem *>
|
||||
{
|
||||
private:
|
||||
class compareFunctor;
|
||||
|
||||
protected:
|
||||
bool contentsKnown;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue