Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform 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"
27
61class InnerDecklistNode : public AbstractDecklistNode, public QList<AbstractDecklistNode *>
62{
63 QString name;
64
65public:
73 explicit InnerDecklistNode(QString _name = QString(), InnerDecklistNode *_parent = nullptr, int position = -1)
74 : AbstractDecklistNode(_parent, position), name(std::move(_name))
75 {
76 }
77
83 explicit InnerDecklistNode(InnerDecklistNode *other, InnerDecklistNode *_parent = nullptr);
84
88 ~InnerDecklistNode() override;
89
94 void setSortMethod(DeckSortMethod method) override;
95
97 [[nodiscard]] QString getName() const override
98 {
99 return name;
100 }
101
103 void setName(const QString &_name)
104 {
105 name = _name;
106 }
107
117 static QString visibleNameFromName(const QString &_name);
118
123 [[nodiscard]] virtual QString getVisibleName() const;
124
126 [[nodiscard]] QString getCardProviderId() const override
127 {
128 return "";
129 }
130
132 [[nodiscard]] QString getCardSetShortName() const override
133 {
134 return "";
135 }
136
138 [[nodiscard]] QString getCardCollectorNumber() const override
139 {
140 return "";
141 }
142
144 [[nodiscard]] bool isDeckHeader() const override
145 {
146 return true;
147 }
148
152 void clearTree();
153
159 AbstractDecklistNode *findChild(const QString &_name);
160
172 const QString &_providerId = "",
173 const QString &_cardNumber = "");
174
179 [[nodiscard]] int height() const override;
180
187 [[nodiscard]] int recursiveCount(bool countTotalCards = false) const;
188
197 bool compare(AbstractDecklistNode *other) const override;
198
200 bool compareNumber(AbstractDecklistNode *other) const;
201
203 bool compareName(AbstractDecklistNode *other) const;
204
212 QVector<QPair<int, int>> sort(Qt::SortOrder order = Qt::AscendingOrder);
213
219 bool readElement(QXmlStreamReader *xml) override;
220
225 void writeElement(QXmlStreamWriter *xml) override;
226};
227
228#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:62
~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:49
QString getCardCollectorNumber() const override
Definition inner_deck_list_node.h:138
bool compareNumber(AbstractDecklistNode *other) const
Compare this node against another for sorting.
Definition inner_deck_list_node.cpp:119
bool readElement(QXmlStreamReader *xml) override
Deserialize this node and its children from XML.
Definition inner_deck_list_node.cpp:141
int recursiveCount(bool countTotalCards=false) const
Count cards recursively under this node.
Definition inner_deck_list_node.cpp:90
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:66
virtual QString getVisibleName() const
Get this node’s display-friendly name.
Definition inner_deck_list_node.cpp:44
bool compareName(AbstractDecklistNode *other) const
Compare this node against another for sorting.
Definition inner_deck_list_node.cpp:131
QString getCardProviderId() const override
Definition inner_deck_list_node.h:126
void writeElement(QXmlStreamWriter *xml) override
Serialize this node and its children to XML.
Definition inner_deck_list_node.cpp:163
QString getCardSetShortName() const override
Definition inner_deck_list_node.h:132
void setName(const QString &_name)
Definition inner_deck_list_node.h:103
bool isDeckHeader() const override
Definition inner_deck_list_node.h:144
int height() const override
Compute the height of this node.
Definition inner_deck_list_node.cpp:85
QString name
Internal identifier for this node (zone or group name).
Definition inner_deck_list_node.h:63
InnerDecklistNode(QString _name=QString(), InnerDecklistNode *_parent=nullptr, int position=-1)
Construct a new InnerDecklistNode.
Definition inner_deck_list_node.h:73
QString getName() const override
Definition inner_deck_list_node.h:97
QVector< QPair< int, int > > sort(Qt::SortOrder order=Qt::AscendingOrder)
Sort this node’s children recursively.
Definition inner_deck_list_node.cpp:172
bool compare(AbstractDecklistNode *other) const override
Compare this node against another for sorting.
Definition inner_deck_list_node.cpp:107
AbstractDecklistNode * findChild(const QString &_name)
Find a direct child node by name.
Definition inner_deck_list_node.cpp:56
void setSortMethod(DeckSortMethod method) override
Set the sorting method for this node and all children.
Definition inner_deck_list_node.cpp:36
DeckSortMethod
Defines the different sort strategies a node may use to order its children.
Definition abstract_deck_list_node.h:36