mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 19:47:46 -07:00
Add different compare methods for sorting
Give DeckList nodes the ability to sort based on name, price, or number.
This commit is contained in:
parent
ed5f02bf7a
commit
a62ba91a5d
2 changed files with 96 additions and 6 deletions
|
|
@ -38,9 +38,11 @@ public:
|
|||
class AbstractDecklistNode {
|
||||
protected:
|
||||
InnerDecklistNode *parent;
|
||||
int sortMethod;
|
||||
public:
|
||||
AbstractDecklistNode(InnerDecklistNode *_parent = 0);
|
||||
virtual ~AbstractDecklistNode() { }
|
||||
virtual void setSortMethod(int method) { sortMethod = method; }
|
||||
virtual QString getName() const = 0;
|
||||
InnerDecklistNode *getParent() const { return parent; }
|
||||
int depth() const;
|
||||
|
|
@ -59,6 +61,7 @@ public:
|
|||
InnerDecklistNode(const QString &_name = QString(), InnerDecklistNode *_parent = 0) : AbstractDecklistNode(_parent), name(_name) { }
|
||||
InnerDecklistNode(InnerDecklistNode *other, InnerDecklistNode *_parent = 0);
|
||||
virtual ~InnerDecklistNode();
|
||||
void setSortMethod(int method);
|
||||
QString getName() const { return name; }
|
||||
void setName(const QString &_name) { name = _name; }
|
||||
static QString visibleNameFromName(const QString &_name);
|
||||
|
|
@ -69,6 +72,9 @@ public:
|
|||
int recursiveCount(bool countTotalCards = false) const;
|
||||
float recursivePrice(bool countTotalCards = false) const;
|
||||
bool compare(AbstractDecklistNode *other) const;
|
||||
bool compareNumber(AbstractDecklistNode *other) const;
|
||||
bool compareName(AbstractDecklistNode *other) const;
|
||||
bool comparePrice(AbstractDecklistNode *other) const;
|
||||
QVector<QPair<int, int> > sort(Qt::SortOrder order = Qt::AscendingOrder);
|
||||
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
|
|
@ -87,6 +93,9 @@ public:
|
|||
float getTotalPrice() const { return getNumber() * getPrice(); }
|
||||
int height() const { return 0; }
|
||||
bool compare(AbstractDecklistNode *other) const;
|
||||
bool compareNumber(AbstractDecklistNode *other) const;
|
||||
bool compareName(AbstractDecklistNode *other) const;
|
||||
bool compareTotalPrice(AbstractDecklistNode *other) const;
|
||||
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue