Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
DecklistNodeTree Class Reference

#include <deck_list_node_tree.h>

Collaboration diagram for DecklistNodeTree:
[legend]

Public Member Functions

 DecklistNodeTree ()
 Constructs an empty DecklistNodeTree.
 DecklistNodeTree (const DecklistNodeTree &other)
 Copy constructor. Deep copies the tree.
DecklistNodeTreeoperator= (const DecklistNodeTree &other)
 Copy-assignment operator. Deep copies the tree.
virtual ~DecklistNodeTree ()
InnerDecklistNodegetRoot () 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.
DecklistCardNodeaddCard (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)
InnerDecklistNodeaddCustomZone (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

InnerDecklistNodegetZoneObjFromName (const QString &zoneName) const
InnerDecklistNodefindBoardZone (const QString &boardZoneName) const
InnerDecklistNodefindOrCreateBoardZone (const QString &boardZoneName)
InnerDecklistNodefindCustomZoneByName (const QString &zoneName) const
bool hasZoneName (const QString &zoneName) const

Private Attributes

InnerDecklistNoderoot
 Root of the deck tree (zones + cards).
int totalCards = 0

Constructor & Destructor Documentation

◆ DecklistNodeTree() [1/2]

DecklistNodeTree::DecklistNodeTree ( )
explicit

Constructs an empty DecklistNodeTree.

Here is the caller graph for this function:

◆ DecklistNodeTree() [2/2]

DecklistNodeTree::DecklistNodeTree ( const DecklistNodeTree & other)
explicit

Copy constructor. Deep copies the tree.

Here is the call graph for this function:

◆ ~DecklistNodeTree()

DecklistNodeTree::~DecklistNodeTree ( )
virtual

Member Function Documentation

◆ addCard()

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 )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addCustomZone()

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.

Parameters
boardZoneNameName of the board zone (e.g. DECK_ZONE_MAIN).
zoneNameName of the custom zone.
Returns
The created zone node, or nullptr if the name is already in use.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

void DecklistNodeTree::clear ( )

Deletes all nodes except the root.

◆ computeDeckHash()

QString DecklistNodeTree::computeDeckHash ( ) const

Computes the deck hash.

Here is the call graph for this function:

◆ deleteNode()

bool DecklistNodeTree::deleteNode ( AbstractDecklistNode * node,
InnerDecklistNode * rootNode = nullptr )
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findBoardZone()

InnerDecklistNode * DecklistNodeTree::findBoardZone ( const QString & boardZoneName) const
private
Here is the caller graph for this function:

◆ findCustomZoneByName()

InnerDecklistNode * DecklistNodeTree::findCustomZoneByName ( const QString & zoneName) const
private
Here is the caller graph for this function:

◆ findOrCreateBoardZone()

InnerDecklistNode * DecklistNodeTree::findOrCreateBoardZone ( const QString & boardZoneName)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forEachCard()

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.

Parameters
funcFunction taking (top-level board zone node, card node). Cards nested in custom zones are reported with their board zone.

◆ getCardNodes()

QList< const DecklistCardNode * > DecklistNodeTree::getCardNodes ( const QSet< QString > & restrictToZones = {}) const

Gets all card nodes in the tree

Parameters
restrictToZonesOnly get the nodes in these zones
Returns
A QList containing all the card nodes in the zone.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCustomZones()

QList< const InnerDecklistNode * > DecklistNodeTree::getCustomZones ( const QString & boardZoneName) const

Gets all custom zones nested under a board zone.

Parameters
boardZoneNameName of the board zone.
Returns
The custom zones, in insertion order.
Here is the call graph for this function:

◆ getRoot()

InnerDecklistNode * DecklistNodeTree::getRoot ( ) const
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.

◆ getZoneNodes()

QList< const InnerDecklistNode * > DecklistNodeTree::getZoneNodes ( const QSet< QString > & restrictToZones = {}) const

Gets all zone nodes in the tree

Parameters
restrictToZonesIf not empty, only get the zone nodes with these names.
Returns
A QList containing all the zone nodes in the tree.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getZoneObjFromName()

InnerDecklistNode * DecklistNodeTree::getZoneObjFromName ( const QString & zoneName) const
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).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ hasZoneName()

bool DecklistNodeTree::hasZoneName ( const QString & zoneName) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEmpty()

bool DecklistNodeTree::isEmpty ( ) const

◆ moveCustomZone()

bool DecklistNodeTree::moveCustomZone ( const QString & zoneName,
const QString & newBoardZoneName )

Moves a custom zone (and all its cards) to another board zone.

Returns
true on success, false if the zone or the new board zone was not found.
Here is the call graph for this function:

◆ operator=()

DecklistNodeTree & DecklistNodeTree::operator= ( const DecklistNodeTree & other)

Copy-assignment operator. Deep copies the tree.

Here is the call graph for this function:

◆ readZoneElement()

void DecklistNodeTree::readZoneElement ( QXmlStreamReader * xml)

Reads a "zone" section of the xml to this tree.

Here is the call graph for this function:

◆ removeCustomZone()

bool DecklistNodeTree::removeCustomZone ( const QString & zoneName)

Removes a custom zone and all its cards.

Returns
true if the zone was found and removed.
Here is the call graph for this function:

◆ renameCustomZone()

bool DecklistNodeTree::renameCustomZone ( const QString & oldZoneName,
const QString & newZoneName )

Renames a custom zone.

Returns
true on success, false if the zone was not found or the new name is taken.
Here is the call graph for this function:

◆ write()

void DecklistNodeTree::write ( QXmlStreamWriter * xml) const

Writes the contents of the deck to xml.

Member Data Documentation

◆ root

InnerDecklistNode* DecklistNodeTree::root
private

Root of the deck tree (zones + cards).

◆ totalCards

int DecklistNodeTree::totalCards = 0
private

The documentation for this class was generated from the following files: