Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
inner_deck_list_node.h
Go to the documentation of this file.
1
15
16#ifndef COCKATRICE_INNER_DECK_LIST_NODE_H
17#define COCKATRICE_INNER_DECK_LIST_NODE_H
18
20
22#define DECK_ZONE_MAIN "main"
24#define DECK_ZONE_SIDE "side"
26#define DECK_ZONE_TOKENS "tokens"
28#define DECK_ZONE_MAYBEBOARD "maybeboard"
29
63class InnerDecklistNode : public AbstractDecklistNode, public QList<AbstractDecklistNode *>
64{
65 QString name;
66
67public:
75 explicit InnerDecklistNode(QString _name = QString(), InnerDecklistNode *_parent = nullptr, int position = -1)
76 : AbstractDecklistNode(_parent, position), name(std::move(_name))
77 {
78 }
79
85 explicit InnerDecklistNode(InnerDecklistNode *other, InnerDecklistNode *_parent = nullptr);
86
90 ~InnerDecklistNode() override;
91
96 void setSortMethod(DeckSortMethod method) override;
97
99 [[nodiscard]] QString getName() const override
100 {
101 return name;
102 }
103
105 void setName(const QString &_name)
106 {
107 name = _name;
108 }
109
119 static QString visibleNameFromName(const QString &_name);
120
125 [[nodiscard]] virtual QString getVisibleName() const;
126
128 [[nodiscard]] QString getCardProviderId() const override
129 {
130 return "";
131 }
132
134 [[nodiscard]] QString getCardSetShortName() const override
135 {
136 return "";
137 }
138
140 [[nodiscard]] QString getCardCollectorNumber() const override
141 {
142 return "";
143 }
144
146 [[nodiscard]] bool isDeckHeader() const override
147 {
148 return true;
149 }
150
154 void clearTree();
155
161 AbstractDecklistNode *findChild(const QString &_name);
162
174 const QString &_providerId = "",
175 const QString &_cardNumber = "");
176
181 [[nodiscard]] int height() const override;
182
189 [[nodiscard]] int recursiveCount(bool countTotalCards = false) const;
190
199 bool compare(AbstractDecklistNode *other) const override;
200
202 bool compareNumber(AbstractDecklistNode *other) const;
203
205 bool compareName(AbstractDecklistNode *other) const;
206
214 QVector<QPair<int, int>> sort(Qt::SortOrder order = Qt::AscendingOrder);
215
222 int readElement(QXmlStreamReader *xml, int limit) override;
223
228 void writeElement(QXmlStreamWriter *xml) override;
229};
230
231#endif // COCKATRICE_INNER_DECK_LIST_NODE_H
Defines the AbstractDecklistNode base class used as the foundation for all nodes in the deck list tre...
Base class for all nodes in the deck list tree.
Definition abstract_deck_list_node.h:73
AbstractDecklistNode(InnerDecklistNode *_parent=nullptr, int position=-1)
Construct a new AbstractDecklistNode and insert it into its parent.
Definition abstract_deck_list_node.cpp:5
Represents a container node in the deck list hierarchy (zones and groupings).
Definition inner_deck_list_node.h:64
~InnerDecklistNode() override
Destructor. Recursively deletes all child nodes.
Definition inner_deck_list_node.cpp:18
static QString visibleNameFromName(const QString &_name)
Translate an internal name into a user-visible name.
Definition inner_deck_list_node.cpp:23
void clearTree()
Delete all children of this node, recursively.
Definition inner_deck_list_node.cpp:51
QString getCardCollectorNumber() const override
Definition inner_deck_list_node.h:140
bool compareNumber(AbstractDecklistNode *other) const
Compare this node against another for sorting.
Definition inner_deck_list_node.cpp:122
int recursiveCount(bool countTotalCards=false) const
Count cards recursively under this node.
Definition inner_deck_list_node.cpp:93
AbstractDecklistNode * findCardChildByNameProviderIdAndNumber(const QString &_name, const QString &_providerId="", const QString &_cardNumber="")
Find a child card node by name, provider ID, and collector number.
Definition inner_deck_list_node.cpp:69
virtual QString getVisibleName() const
Get this node’s display-friendly name.
Definition inner_deck_list_node.cpp:46
bool compareName(AbstractDecklistNode *other) const
Compare this node against another for sorting.
Definition inner_deck_list_node.cpp:134
QString getCardProviderId() const override
Definition inner_deck_list_node.h:128
void writeElement(QXmlStreamWriter *xml) override
Serialize this node and its children to XML.
Definition inner_deck_list_node.cpp:171
QString getCardSetShortName() const override
Definition inner_deck_list_node.h:134
void setName(const QString &_name)
Definition inner_deck_list_node.h:105
int readElement(QXmlStreamReader *xml, int limit) override
Deserialize this node and its children from XML.
Definition inner_deck_list_node.cpp:144
bool isDeckHeader() const override
Definition inner_deck_list_node.h:146
int height() const override
Compute the height of this node.
Definition inner_deck_list_node.cpp:88
QString name
Internal identifier for this node (zone or group name).
Definition inner_deck_list_node.h:65
InnerDecklistNode(QString _name=QString(), InnerDecklistNode *_parent=nullptr, int position=-1)
Construct a new InnerDecklistNode.
Definition inner_deck_list_node.h:75
QString getName() const override
Definition inner_deck_list_node.h:99
QVector< QPair< int, int > > sort(Qt::SortOrder order=Qt::AscendingOrder)
Sort this node’s children recursively.
Definition inner_deck_list_node.cpp:181
bool compare(AbstractDecklistNode *other) const override
Compare this node against another for sorting.
Definition inner_deck_list_node.cpp:110
AbstractDecklistNode * findChild(const QString &_name)
Find a direct child node by name.
Definition inner_deck_list_node.cpp:59
void setSortMethod(DeckSortMethod method) override
Set the sorting method for this node and all children.
Definition inner_deck_list_node.cpp:38
DeckSortMethod
Defines the different sort strategies a node may use to order its children.
Definition abstract_deck_list_node.h:36