![]() |
Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
|
#include <deck_list_node_tree.h>
Public Member Functions | |
| DecklistNodeTree () | |
| Constructs an empty DecklistNodeTree. | |
| DecklistNodeTree (const DecklistNodeTree &other) | |
| Copy constructor. Deep copies the tree. | |
| DecklistNodeTree & | operator= (const DecklistNodeTree &other) |
| Copy-assignment operator. Deep copies the tree. | |
| virtual | ~DecklistNodeTree () |
| InnerDecklistNode * | getRoot () const |
| Gets a pointer to the underlying root node. Note: DO NOT call this method unless the object needs to have access to the underlying model. For now, only the DeckListModel should be calling this. | |
| bool | isEmpty () const |
| void | clear () |
| Deletes all nodes except the root. | |
| QList< const DecklistCardNode * > | getCardNodes (const QSet< QString > &restrictToZones={}) const |
| QList< const InnerDecklistNode * > | getZoneNodes (const QSet< QString > &restrictToZones={}) const |
| QString | computeDeckHash () const |
| Computes the deck hash. | |
| void | write (QXmlStreamWriter *xml) const |
| Writes the contents of the deck to xml. | |
| void | readZoneElement (QXmlStreamReader *xml) |
| Reads a "zone" section of the xml to this tree. | |
| 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) |
| bool | deleteNode (AbstractDecklistNode *node, InnerDecklistNode *rootNode=nullptr) |
| InnerDecklistNode * | addCustomZone (const QString &boardZoneName, const QString &zoneName) |
| Creates a new custom zone nested under a board zone. | |
| bool | renameCustomZone (const QString &oldZoneName, const QString &newZoneName) |
| Renames a custom zone. | |
| bool | moveCustomZone (const QString &zoneName, const QString &newBoardZoneName) |
| Moves a custom zone (and all its cards) to another board zone. | |
| bool | removeCustomZone (const QString &zoneName) |
| Removes a custom zone and all its cards. | |
| QList< const InnerDecklistNode * > | getCustomZones (const QString &boardZoneName) const |
| Gets all custom zones nested under a board zone. | |
| 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. | |
Private Member Functions | |
| InnerDecklistNode * | getZoneObjFromName (const QString &zoneName) const |
| InnerDecklistNode * | findBoardZone (const QString &boardZoneName) const |
| InnerDecklistNode * | findOrCreateBoardZone (const QString &boardZoneName) |
| InnerDecklistNode * | findCustomZoneByName (const QString &zoneName) const |
| bool | hasZoneName (const QString &zoneName) const |
Private Attributes | |
| InnerDecklistNode * | root |
| Root of the deck tree (zones + cards). | |
| int | totalCards = 0 |
|
explicit |
|
explicit |
Copy constructor. Deep copies the tree.
|
virtual |
| DecklistCardNode * DecklistNodeTree::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 ) |
| InnerDecklistNode * DecklistNodeTree::addCustomZone | ( | const QString & | boardZoneName, |
| const QString & | zoneName ) |
Creates a new custom zone nested under a board zone.
Custom zone names must be unique across the whole deck so that cards can be added to a custom zone without specifying its board zone.
| boardZoneName | Name of the board zone (e.g. DECK_ZONE_MAIN). |
| zoneName | Name of the custom zone. |
| void DecklistNodeTree::clear | ( | ) |
Deletes all nodes except the root.
| QString DecklistNodeTree::computeDeckHash | ( | ) | const |
Computes the deck hash.
| bool DecklistNodeTree::deleteNode | ( | AbstractDecklistNode * | node, |
| InnerDecklistNode * | rootNode = nullptr ) |
|
private |
|
private |
|
private |
| void DecklistNodeTree::forEachCard | ( | const std::function< void(InnerDecklistNode *, DecklistCardNode *)> & | func | ) | const |
Applies a function to every card in the deck tree. This can modify the cards.
| func | Function taking (top-level board zone node, card node). Cards nested in custom zones are reported with their board zone. |
| QList< const DecklistCardNode * > DecklistNodeTree::getCardNodes | ( | const QSet< QString > & | restrictToZones = {} | ) | const |
Gets all card nodes in the tree
| restrictToZones | Only get the nodes in these zones |
| QList< const InnerDecklistNode * > DecklistNodeTree::getCustomZones | ( | const QString & | boardZoneName | ) | const |
Gets all custom zones nested under a board zone.
| boardZoneName | Name of the board zone. |
|
inline |
Gets a pointer to the underlying root node. Note: DO NOT call this method unless the object needs to have access to the underlying model. For now, only the DeckListModel should be calling this.
| QList< const InnerDecklistNode * > DecklistNodeTree::getZoneNodes | ( | const QSet< QString > & | restrictToZones = {} | ) | const |
Gets all zone nodes in the tree
| restrictToZones | If not empty, only get the zone nodes with these names. |
|
private |
Gets the InnerDecklistNode that is the root node for the given zone, creating a new node if it doesn't exist.
Top-level zones take precedence, then deck-unique custom zones nested under boards are resolved. Unknown names create a new top-level zone (legacy behavior).
|
private |
| bool DecklistNodeTree::isEmpty | ( | ) | const |
| bool DecklistNodeTree::moveCustomZone | ( | const QString & | zoneName, |
| const QString & | newBoardZoneName ) |
Moves a custom zone (and all its cards) to another board zone.
| DecklistNodeTree & DecklistNodeTree::operator= | ( | const DecklistNodeTree & | other | ) |
Copy-assignment operator. Deep copies the tree.
| void DecklistNodeTree::readZoneElement | ( | QXmlStreamReader * | xml | ) |
Reads a "zone" section of the xml to this tree.
| bool DecklistNodeTree::removeCustomZone | ( | const QString & | zoneName | ) |
Removes a custom zone and all its cards.
| bool DecklistNodeTree::renameCustomZone | ( | const QString & | oldZoneName, |
| const QString & | newZoneName ) |
Renames a custom zone.
| void DecklistNodeTree::write | ( | QXmlStreamWriter * | xml | ) | const |
Writes the contents of the deck to xml.
|
private |
Root of the deck tree (zones + cards).
|
private |