Cockatrice 2026-01-14-Development-2.11.0-beta.46
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
deck_list_node_tree.h
Go to the documentation of this file.
1#ifndef COCKATRICE_DECKLIST_NODE_TREE_H
2#define COCKATRICE_DECKLIST_NODE_TREE_H
3
7
8#include <QSet>
9
11{
13
14public:
16 explicit DecklistNodeTree();
18 explicit DecklistNodeTree(const DecklistNodeTree &other);
21
22 virtual ~DecklistNodeTree();
23
30 {
31 return root;
32 }
33
34 bool isEmpty() const;
35
39 void clear();
40
46 QList<const DecklistCardNode *> getCardNodes(const QSet<QString> &restrictToZones = {}) const;
47
48 QList<const InnerDecklistNode *> getZoneNodes() const;
49
53 QString computeDeckHash() const;
54
58 void write(QXmlStreamWriter *xml) const;
59
63 void readZoneElement(QXmlStreamReader *xml);
64
65 DecklistCardNode *addCard(const QString &cardName,
66 int amount,
67 const QString &zoneName,
68 int position,
69 const QString &cardSetName = QString(),
70 const QString &cardSetCollectorNumber = QString(),
71 const QString &cardProviderId = QString(),
72 const bool formatLegal = true);
73 bool deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode = nullptr);
74
80 void forEachCard(const std::function<void(InnerDecklistNode *, DecklistCardNode *)> &func) const;
81
82private:
83 // Helpers for traversing the tree
84 InnerDecklistNode *getZoneObjFromName(const QString &zoneName) const;
85};
86
87#endif // COCKATRICE_DECKLIST_NODE_TREE_H
InnerDecklistNode * getRoot() const
Gets a pointer to the underlying root node. Note: DO NOT call this method unless the object needs to ...
Definition deck_list_node_tree.h:29
bool isEmpty() const
Definition deck_list_node_tree.cpp:30
InnerDecklistNode * root
Root of the deck tree (zones + cards).
Definition deck_list_node_tree.h:12
DecklistNodeTree()
Constructs an empty DecklistNodeTree.
Definition deck_list_node_tree.cpp:8
DecklistCardNode * addCard(const QString &cardName, int amount, const QString &zoneName, int position, const QString &cardSetName=QString(), const QString &cardSetCollectorNumber=QString(), const QString &cardProviderId=QString(), const bool formatLegal=true)
Definition deck_list_node_tree.cpp:112
InnerDecklistNode * getZoneObjFromName(const QString &zoneName) const
Definition deck_list_node_tree.cpp:176
DecklistNodeTree & operator=(const DecklistNodeTree &other)
Copy-assignment operator. Deep copies the tree.
Definition deck_list_node_tree.cpp:16
QString computeDeckHash() const
Computes the deck hash.
Definition deck_list_node_tree.cpp:72
QList< const DecklistCardNode * > getCardNodes(const QSet< QString > &restrictToZones={}) const
Definition deck_list_node_tree.cpp:40
void clear()
Deletes all nodes except the root.
Definition deck_list_node_tree.cpp:35
void readZoneElement(QXmlStreamReader *xml)
Reads a "zone" section of the xml to this tree.
Definition deck_list_node_tree.cpp:105
void forEachCard(const std::function< void(InnerDecklistNode *, DecklistCardNode *)> &func) const
Apply a function to every card in the deck tree. This can modify the cards.
Definition deck_list_node_tree.cpp:160
void write(QXmlStreamWriter *xml) const
Writes the contents of the deck to xml.
Definition deck_list_node_tree.cpp:98
bool deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode=nullptr)
Definition deck_list_node_tree.cpp:127
virtual ~DecklistNodeTree()
Definition deck_list_node_tree.cpp:25
QList< const InnerDecklistNode * > getZoneNodes() const
Definition deck_list_node_tree.cpp:59
Represents a container node in the deck list hierarchy (zones and groupings).
Definition inner_deck_list_node.h:62
static constexpr int amount
Definition deck_hash_performance_test.cpp:5
Defines the DecklistCardNode class, representing a single card entry in the deck list tree.
Defines the InnerDecklistNode class, which represents structural nodes (zones and groups) in the deck...