Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
InnerDecklistNode Class Reference

Represents a container node in the deck list hierarchy (zones and groupings). More...

#include <inner_deck_list_node.h>

Inheritance diagram for InnerDecklistNode:
[legend]
Collaboration diagram for InnerDecklistNode:
[legend]

Public Member Functions

 InnerDecklistNode (QString _name=QString(), InnerDecklistNode *_parent=nullptr, int position=-1)
 Construct a new InnerDecklistNode.
 InnerDecklistNode (InnerDecklistNode *other, InnerDecklistNode *_parent=nullptr)
 Copy constructor with parent reassignment.
 ~InnerDecklistNode () override
 Destructor. Recursively deletes all child nodes.
void setSortMethod (DeckSortMethod method) override
 Set the sorting method for this node and all children.
QString getName () const override
void setName (const QString &_name)
virtual QString getVisibleName () const
 Get this node’s display-friendly name.
QString getCardProviderId () const override
QString getCardSetShortName () const override
QString getCardCollectorNumber () const override
bool isDeckHeader () const override
void clearTree ()
 Delete all children of this node, recursively.
AbstractDecklistNodefindChild (const QString &_name)
 Find a direct child node by name.
AbstractDecklistNodefindCardChildByNameProviderIdAndNumber (const QString &_name, const QString &_providerId="", const QString &_cardNumber="")
 Find a child card node by name, provider ID, and collector number.
int height () const override
 Compute the height of this node.
int recursiveCount (bool countTotalCards=false) const
 Count cards recursively under this node.
bool compare (AbstractDecklistNode *other) const override
 Compare this node against another for sorting.
bool compareNumber (AbstractDecklistNode *other) const
 Compare this node against another for sorting.
bool compareName (AbstractDecklistNode *other) const
 Compare this node against another for sorting.
QVector< QPair< int, int > > sort (Qt::SortOrder order=Qt::AscendingOrder)
 Sort this node’s children recursively.
bool readElement (QXmlStreamReader *xml) override
 Deserialize this node and its children from XML.
void writeElement (QXmlStreamWriter *xml) override
 Serialize this node and its children to XML.
Public Member Functions inherited from AbstractDecklistNode
 AbstractDecklistNode (InnerDecklistNode *_parent=nullptr, int position=-1)
 Construct a new AbstractDecklistNode and insert it into its parent.
virtual ~AbstractDecklistNode ()=default
 Virtual destructor. Child classes must clean up their resources.
InnerDecklistNodegetParent () const
int depth () const
 Compute the depth of this node in the tree.

Static Public Member Functions

static QString visibleNameFromName (const QString &_name)
 Translate an internal name into a user-visible name.

Private Attributes

QString name
 Internal identifier for this node (zone or group name).

Additional Inherited Members

Protected Attributes inherited from AbstractDecklistNode
InnerDecklistNodeparent
 Pointer to the parent node, or nullptr if this is the root.
DeckSortMethod sortMethod
 Current sorting strategy for this node's children.

Detailed Description

Represents a container node in the deck list hierarchy (zones and groupings).

Unlike DecklistCardNode, which holds leaf card data, this class manages collections of child nodes, which may themselves be InnerDecklistNode or DecklistCardNode objects.

Role in the hierarchy:

  • Root node (invisible): Holds zones.
  • Zone nodes: "main", "side", "tokens".
  • Grouping nodes: Created dynamically when grouping by type, color, or mana cost.
  • Card nodes: Always children of an InnerDecklistNode.

Design notes:

  • Inherits from AbstractDecklistNode (tree interface) and QList<AbstractDecklistNode*> (storage of children). This allows direct QList-style manipulation of children while still presenting a polymorphic node interface.

Responsibilities:

  • Store a display name.
  • Own and manage child nodes (insert, clear, find).
  • Provide recursive operations such as counting cards or computing height.
  • Implement sorting logic for reordering children.
  • Implement XML serialization for persistence.

Ownership:

  • Owns all child nodes stored in the QList. The destructor recursively deletes children.

Constructor & Destructor Documentation

◆ InnerDecklistNode() [1/2]

InnerDecklistNode::InnerDecklistNode ( QString _name = QString(),
InnerDecklistNode * _parent = nullptr,
int position = -1 )
inlineexplicit

Construct a new InnerDecklistNode.

Parameters
_nameInternal name (e.g., "main", "side", "tokens", or group label).
_parentParent node (may be nullptr for the root).
positionOptional index for insertion into parent. -1 = append.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InnerDecklistNode() [2/2]

InnerDecklistNode::InnerDecklistNode ( InnerDecklistNode * other,
InnerDecklistNode * _parent = nullptr )
explicit

Copy constructor with parent reassignment.

Parameters
otherNode to copy from (deep copy of children).
_parentParent node for the copy.
Here is the call graph for this function:

◆ ~InnerDecklistNode()

InnerDecklistNode::~InnerDecklistNode ( )
override

Destructor. Recursively deletes all child nodes.

Here is the call graph for this function:

Member Function Documentation

◆ clearTree()

void InnerDecklistNode::clearTree ( )

Delete all children of this node, recursively.

Here is the caller graph for this function:

◆ compare()

bool InnerDecklistNode::compare ( AbstractDecklistNode * other) const
overridevirtual

Compare this node against another for sorting.

Uses current sortMethod to determine the comparison.

Parameters
otherNode to compare.
Returns
true if this node should sort before other.

Implements AbstractDecklistNode.

Here is the call graph for this function:

◆ compareName()

bool InnerDecklistNode::compareName ( AbstractDecklistNode * other) const

Compare this node against another for sorting.

Uses current sortMethod to determine the comparison.

Parameters
otherNode to compare.
Returns
true if this node should sort before other.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ compareNumber()

bool InnerDecklistNode::compareNumber ( AbstractDecklistNode * other) const

Compare this node against another for sorting.

Uses current sortMethod to determine the comparison.

Parameters
otherNode to compare.
Returns
true if this node should sort before other.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findCardChildByNameProviderIdAndNumber()

AbstractDecklistNode * InnerDecklistNode::findCardChildByNameProviderIdAndNumber ( const QString & _name,
const QString & _providerId = "",
const QString & _cardNumber = "" )

Find a child card node by name, provider ID, and collector number.

Searches immediate children only.

Parameters
_nameCard name to match.
_providerIdOptional provider ID to match.
_cardNumberOptional collector number to match.
Returns
Pointer to child node if found, nullptr otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findChild()

AbstractDecklistNode * InnerDecklistNode::findChild ( const QString & _name)

Find a direct child node by name.

Parameters
_nameName to match.
Returns
Pointer to child node, or nullptr if not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getCardCollectorNumber()

QString InnerDecklistNode::getCardCollectorNumber ( ) const
inlinenodiscardoverridevirtual
Returns
Always empty for container nodes.

Implements AbstractDecklistNode.

◆ getCardProviderId()

QString InnerDecklistNode::getCardProviderId ( ) const
inlinenodiscardoverridevirtual
Returns
Always empty for container nodes.

Implements AbstractDecklistNode.

◆ getCardSetShortName()

QString InnerDecklistNode::getCardSetShortName ( ) const
inlinenodiscardoverridevirtual
Returns
Always empty for container nodes.

Implements AbstractDecklistNode.

◆ getName()

QString InnerDecklistNode::getName ( ) const
inlinenodiscardoverridevirtual
Returns
The internal name of this node.

Implements AbstractDecklistNode.

Here is the caller graph for this function:

◆ getVisibleName()

QString InnerDecklistNode::getVisibleName ( ) const
nodiscardvirtual

Get this node’s display-friendly name.

Returns
Human-readable name (zone/group name).
Here is the call graph for this function:

◆ height()

int InnerDecklistNode::height ( ) const
nodiscardoverridevirtual

Compute the height of this node.

Returns
Maximum depth of descendants + 1.

Implements AbstractDecklistNode.

Here is the call graph for this function:

◆ isDeckHeader()

bool InnerDecklistNode::isDeckHeader ( ) const
inlinenodiscardoverridevirtual
Returns
Always true; InnerDecklistNode represents deck structure.

Implements AbstractDecklistNode.

◆ readElement()

bool InnerDecklistNode::readElement ( QXmlStreamReader * xml)
overridevirtual

Deserialize this node and its children from XML.

Parameters
xmlReader positioned at this element.
Returns
true if parsing succeeded.

Implements AbstractDecklistNode.

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

◆ recursiveCount()

int InnerDecklistNode::recursiveCount ( bool countTotalCards = false) const
nodiscard

Count cards recursively under this node.

Parameters
countTotalCardsIf true, sums up quantities of cards. If false, counts unique card nodes.
Returns
Total count.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setName()

void InnerDecklistNode::setName ( const QString & _name)
inline
Parameters
_nameSet the internal name of this node.

◆ setSortMethod()

void InnerDecklistNode::setSortMethod ( DeckSortMethod method)
overridevirtual

Set the sorting method for this node and all children.

Parameters
methodSort method to apply recursively.

Reimplemented from AbstractDecklistNode.

◆ sort()

QVector< QPair< int, int > > InnerDecklistNode::sort ( Qt::SortOrder order = Qt::AscendingOrder)

Sort this node’s children recursively.

Parameters
orderAscending or descending.
Returns
A QVector of (oldIndex, newIndex) pairs indicating how children were reordered.
Here is the caller graph for this function:

◆ visibleNameFromName()

QString InnerDecklistNode::visibleNameFromName ( const QString & _name)
static

Translate an internal name into a user-visible name.

For example, the internal string "main" is presented as "Mainboard" in the UI.

Parameters
_nameInternal identifier.
Returns
Display-friendly string.
Here is the caller graph for this function:

◆ writeElement()

void InnerDecklistNode::writeElement ( QXmlStreamWriter * xml)
overridevirtual

Serialize this node and its children to XML.

Parameters
xmlWriter to append elements to.

Implements AbstractDecklistNode.

Member Data Documentation

◆ name

QString InnerDecklistNode::name
private

Internal identifier for this node (zone or group name).


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