1#ifndef COCKATRICE_DECKLIST_NODE_TREE_H
2#define COCKATRICE_DECKLIST_NODE_TREE_H
13class QXmlStreamReader;
14class QXmlStreamWriter;
60 QList<const InnerDecklistNode *>
getZoneNodes(
const QSet<QString> &restrictToZones = {})
const;
70 void write(QXmlStreamWriter *xml)
const;
77 DecklistCardNode *
addCard(
const QString &cardName,
79 const QString &zoneName,
81 const QString &cardSetName = QString(),
82 const QString &cardSetCollectorNumber = QString(),
83 const QString &cardProviderId = QString(),
84 const bool formatLegal =
true);
85 bool deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode =
nullptr);
97 InnerDecklistNode *
addCustomZone(
const QString &boardZoneName,
const QString &zoneName);
103 bool renameCustomZone(
const QString &oldZoneName,
const QString &newZoneName);
109 bool moveCustomZone(
const QString &zoneName,
const QString &newBoardZoneName);
122 QList<const InnerDecklistNode *>
getCustomZones(
const QString &boardZoneName)
const;
149 void forEachCard(
const std::function<
void(InnerDecklistNode *, DecklistCardNode *)> &func)
const;
154 InnerDecklistNode *
findBoardZone(
const QString &boardZoneName)
const;
Base class for all nodes in the deck list tree.
Definition abstract_deck_list_node.h:75
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:36
bool hasZoneName(const QString &zoneName) const
Checks whether a zone name is taken anywhere in the deck.
Definition deck_list_node_tree.cpp:388
int totalCards
Definition deck_list_node_tree.h:19
InnerDecklistNode * findOrCreateBoardZone(const QString &boardZoneName)
Definition deck_list_node_tree.cpp:273
bool isEmpty() const
Definition deck_list_node_tree.cpp:120
InnerDecklistNode * getZoneObjFromName(const QString &zoneName)
Definition deck_list_node_tree.cpp:252
bool moveCustomZone(const QString &zoneName, const QString &newBoardZoneName)
Moves a custom zone (and all its cards) to another board zone.
Definition deck_list_node_tree.cpp:314
InnerDecklistNode * root
Root of the deck tree (zones + cards).
Definition deck_list_node_tree.h:18
DecklistNodeTree()
Constructs an empty DecklistNodeTree.
Definition deck_list_node_tree.cpp:98
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:184
DecklistNodeTree & operator=(const DecklistNodeTree &other)
Copy-assignment operator. Deep copies the tree.
Definition deck_list_node_tree.cpp:106
QList< const InnerDecklistNode * > getCustomZones(const QString &boardZoneName) const
Gets all custom zones nested under a board zone.
Definition deck_list_node_tree.cpp:351
QString computeDeckHash() const
Computes the deck hash.
Definition deck_list_node_tree.cpp:158
QList< const DecklistCardNode * > getCardNodes(const QSet< QString > &restrictToZones={}) const
Definition deck_list_node_tree.cpp:130
void clear()
Deletes all nodes except the root.
Definition deck_list_node_tree.cpp:125
bool renameCustomZone(const QString &oldZoneName, const QString &newZoneName)
Renames a custom zone.
Definition deck_list_node_tree.cpp:299
InnerDecklistNode * addCustomZone(const QString &boardZoneName, const QString &zoneName)
Creates a new custom zone nested under a board zone.
Definition deck_list_node_tree.cpp:284
void readZoneElement(QXmlStreamReader *xml)
Reads a "zone" section of the xml to this tree.
Definition deck_list_node_tree.cpp:177
void forEachCard(const std::function< void(InnerDecklistNode *, DecklistCardNode *)> &func) const
Applies a function to every card in the deck tree. This can modify the cards.
Definition deck_list_node_tree.cpp:237
void write(QXmlStreamWriter *xml) const
Writes the contents of the deck to xml.
Definition deck_list_node_tree.cpp:170
bool deleteNode(AbstractDecklistNode *node, InnerDecklistNode *rootNode=nullptr)
Definition deck_list_node_tree.cpp:201
void pruneEmptyBoardZone(InnerDecklistNode *container)
Recursively removes container when it is an empty board zone.
Definition deck_list_node_tree.cpp:230
QList< const InnerDecklistNode * > getZoneNodes(const QSet< QString > &restrictToZones={}) const
Definition deck_list_node_tree.cpp:141
InnerDecklistNode * findBoardZone(const QString &boardZoneName) const
Definition deck_list_node_tree.cpp:268
InnerDecklistNode * findCustomZoneByName(const QString &zoneName) const
Finds a custom zone anywhere in the deck by name.
Definition deck_list_node_tree.cpp:369
bool removeCustomZone(const QString &zoneName)
Removes a custom zone and all its cards.
Definition deck_list_node_tree.cpp:337
Represents a container node in the deck list hierarchy (zones and groupings).
Definition inner_deck_list_node.h:73
Definition remote_connection_controller.h:20
Definition dlg_manage_sets.h:29
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...