Base class for all nodes in the deck list tree.
More...
#include <abstract_deck_list_node.h>
Base class for all nodes in the deck list tree.
This class defines the common interface for every node in the deck representation: zones, groupings, and cards.
Responsibilities:
- Maintain a pointer to its parent (if any).
- Track the sorting method to be used for child nodes.
- Provide a consistent interface for retrieving basic identifying properties (name, set, collector number, provider ID).
- Define abstract methods for XML serialization, used when saving or loading deck files.
Lifetime / Ownership:
- Nodes are arranged hierarchically under
InnerDecklistNode parents.
- The parent takes ownership of its children; destruction cascades.
- The DeckListModel holds the invisible root node, which in turn owns the entire hierarchy.
Extension:
◆ AbstractDecklistNode()
| AbstractDecklistNode::AbstractDecklistNode |
( |
InnerDecklistNode * | _parent = nullptr, |
|
|
int | position = -1 ) |
|
explicit |
Construct a new AbstractDecklistNode and insert it into its parent.
- Parameters
-
| _parent | Parent node. May be nullptr if this is the root. |
| position | Optional index at which to insert into the parent's children. If -1, the node is appended to the end. |
If a parent is provided, the constructor automatically appends or inserts this node into the parent’s child list.
◆ ~AbstractDecklistNode()
| virtual AbstractDecklistNode::~AbstractDecklistNode |
( |
| ) |
|
|
virtualdefault |
Virtual destructor. Child classes must clean up their resources.
◆ compare()
Compare this node against another for sorting.
The semantics of comparison depend on the node type and the current sortMethod.
- Parameters
-
| other | The node to compare against. |
- Returns
- true if this node should come before
other.
Implemented in AbstractDecklistCardNode, and InnerDecklistNode.
◆ depth()
| int AbstractDecklistNode::depth |
( |
| ) |
const |
|
nodiscard |
Compute the depth of this node in the tree.
- Returns
- Distance from the root (root = 0, children = 1, etc.).
◆ getCardCollectorNumber()
| virtual QString AbstractDecklistNode::getCardCollectorNumber |
( |
| ) |
const |
|
nodiscardpure virtual |
◆ getCardProviderId()
| virtual QString AbstractDecklistNode::getCardProviderId |
( |
| ) |
const |
|
nodiscardpure virtual |
◆ getCardSetShortName()
| virtual QString AbstractDecklistNode::getCardSetShortName |
( |
| ) |
const |
|
nodiscardpure virtual |
◆ getName()
| virtual QString AbstractDecklistNode::getName |
( |
| ) |
const |
|
nodiscardpure virtual |
◆ getParent()
- Returns
- The parent node, or nullptr if this is the root.
◆ height()
| virtual int AbstractDecklistNode::height |
( |
| ) |
const |
|
nodiscardpure virtual |
Compute the "height" of this node.
Height is defined by subclasses; it usually represents how many levels of descendants this node spans.
For example:
- A card node has height 1.
- A group node containing cards has height 2.
Implemented in AbstractDecklistCardNode, and InnerDecklistNode.
◆ isDeckHeader()
| virtual bool AbstractDecklistNode::isDeckHeader |
( |
| ) |
const |
|
nodiscardpure virtual |
◆ readElement()
| virtual int AbstractDecklistNode::readElement |
( |
QXmlStreamReader * | xml, |
|
|
int | limit ) |
|
pure virtual |
◆ setParent()
- Parameters
-
| newParent | Reparent this node. The new parent takes ownership. |
◆ setSortMethod()
| virtual void AbstractDecklistNode::setSortMethod |
( |
DeckSortMethod | method | ) |
|
|
inlinevirtual |
Set the sort method for this node’s children.
- Parameters
-
| method | The sorting strategy to use. |
Subclasses may override if they need to apply additional logic.
Reimplemented in InnerDecklistNode.
◆ writeElement()
| virtual void AbstractDecklistNode::writeElement |
( |
QXmlStreamWriter * | xml | ) |
|
|
pure virtual |
◆ parent
Pointer to the parent node, or nullptr if this is the root.
Ownership note: The parent is responsible for destroying this node when it is removed from the tree.
◆ sortMethod
Current sorting strategy for this node's children.
Sorting is applied recursively by the DeckListModel when the view requests it.
The documentation for this class was generated from the following files: