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

Qt model representing a decklist for use in views (tree/table). More...

#include <deck_list_model.h>

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

Public Slots

void rebuildTree ()
 Rebuilds the model tree from the underlying DeckLoader.

Signals

void deckHashChanged ()
 Emitted whenever the deck hash changes due to modifications in the model.

Public Member Functions

 DeckListModel (QObject *parent=nullptr)
 ~DeckListModel () override
QModelIndex getRoot () const
 Returns the root index of the model.
QString getGroupCriteriaForCard (CardInfoPtr info) const
 Returns the value of the grouping category for a card based on the current criteria.
int rowCount (const QModelIndex &parent) const override
int columnCount (const QModelIndex &=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role) const override
void emitBackgroundUpdates (const QModelIndex &parent)
QVariant headerData (int section, Qt::Orientation orientation, int role) const override
QModelIndex index (int row, int column, const QModelIndex &parent) const override
QModelIndex parent (const QModelIndex &index) const override
Qt::ItemFlags flags (const QModelIndex &index) const override
bool setData (const QModelIndex &index, const QVariant &value, int role) override
bool removeRows (int row, int count, const QModelIndex &parent) override
QModelIndex findCard (const QString &cardName, const QString &zoneName, const QString &providerId="", const QString &cardNumber="") const
 Finds a card by name, zone, and optional identifiers.
QModelIndex addPreferredPrintingCard (const QString &cardName, const QString &zoneName, bool abAddAnyway)
 Adds a card using the preferred printing if available.
QModelIndex addCard (const ExactCard &card, const QString &zoneName)
 Adds an ExactCard to the specified zone.
int findSortedInsertRow (InnerDecklistNode *parent, CardInfoPtr cardInfo) const
 Determines the sorted insertion row for a card.
void sort (int column, Qt::SortOrder order) override
void cleanList ()
 Removes all cards and resets the model.
DeckListgetDeckList () const
void setDeckList (DeckList *_deck)
QList< ExactCardgetCards () const
QList< ExactCardgetCardsForZone (const QString &zoneName) const
QList< QString > * getZones () const
void setActiveGroupCriteria (DeckListModelGroupCriteria::Type newCriteria)
 Sets the criteria used to group cards in the model.

Private Member Functions

InnerDecklistNodecreateNodeIfNeeded (const QString &name, InnerDecklistNode *parent)
QModelIndex nodeToIndex (AbstractDecklistNode *node) const
DecklistModelCardNodefindCardNode (const QString &cardName, const QString &zoneName, const QString &providerId="", const QString &cardNumber="") const
void emitRecursiveUpdates (const QModelIndex &index)
void sortHelper (InnerDecklistNode *node, Qt::SortOrder order)
template<typename T>
getNode (const QModelIndex &index) const

Private Attributes

DeckListdeckList
InnerDecklistNoderoot
DeckListModelGroupCriteria::Type activeGroupCriteria = DeckListModelGroupCriteria::MAIN_TYPE
int lastKnownColumn
Qt::SortOrder lastKnownOrder

Detailed Description

Qt model representing a decklist for use in views (tree/table).

DeckListModel is a QAbstractItemModel that exposes the structure of a deck (zones and cards) to Qt views. It organizes cards hierarchically under InnerDecklistNode containers and supports grouping, sorting, adding/removing cards, and printing decklists.

Signals:

  • deckHashChanged(): emitted when the deck contents change in a way that affects its hash.

Slots:

  • rebuildTree(): rebuilds the model structure from the underlying DeckLoader.

Constructor & Destructor Documentation

◆ DeckListModel()

DeckListModel::DeckListModel ( QObject * parent = nullptr)
explicit
Here is the call graph for this function:

◆ ~DeckListModel()

DeckListModel::~DeckListModel ( )
override

Member Function Documentation

◆ addCard()

QModelIndex DeckListModel::addCard ( const ExactCard & card,
const QString & zoneName )

Adds an ExactCard to the specified zone.

Parameters
cardThe card to add.
zoneNameThe zone to insert the card into.
Returns
QModelIndex pointing to the newly inserted card node.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addPreferredPrintingCard()

QModelIndex DeckListModel::addPreferredPrintingCard ( const QString & cardName,
const QString & zoneName,
bool abAddAnyway )

Adds a card using the preferred printing if available.

Parameters
cardNameName of the card to add.
zoneNameZone to insert the card into.
abAddAnywayWhether to add the card even if resolution fails.
Returns
QModelIndex pointing to the newly inserted card node.
Here is the call graph for this function:

◆ cleanList()

void DeckListModel::cleanList ( )

Removes all cards and resets the model.

Here is the call graph for this function:

◆ columnCount()

int DeckListModel::columnCount ( const QModelIndex & = QModelIndex()) const
nodiscardoverride
Here is the caller graph for this function:

◆ createNodeIfNeeded()

InnerDecklistNode * DeckListModel::createNodeIfNeeded ( const QString & name,
InnerDecklistNode * parent )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ data()

QVariant DeckListModel::data ( const QModelIndex & index,
int role ) const
nodiscardoverride
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deckHashChanged

void DeckListModel::deckHashChanged ( )
signal

Emitted whenever the deck hash changes due to modifications in the model.

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

◆ emitBackgroundUpdates()

void DeckListModel::emitBackgroundUpdates ( const QModelIndex & parent)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emitRecursiveUpdates()

void DeckListModel::emitRecursiveUpdates ( const QModelIndex & index)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findCard()

QModelIndex DeckListModel::findCard ( const QString & cardName,
const QString & zoneName,
const QString & providerId = "",
const QString & cardNumber = "" ) const
nodiscard

Finds a card by name, zone, and optional identifiers.

Parameters
cardNameThe card's name.
zoneNameThe zone to search in (main/side/etc.).
providerIdOptional provider-specific ID.
cardNumberOptional collector number.
Returns
QModelIndex of the card, or invalid index if not found.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findCardNode()

DecklistModelCardNode * DeckListModel::findCardNode ( const QString & cardName,
const QString & zoneName,
const QString & providerId = "",
const QString & cardNumber = "" ) const
nodiscardprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ findSortedInsertRow()

int DeckListModel::findSortedInsertRow ( InnerDecklistNode * parent,
CardInfoPtr cardInfo ) const

Determines the sorted insertion row for a card.

Parameters
parentThe parent node where the card will be inserted.
cardInfoThe card info to insert.
Returns
Row index where the card should be inserted to maintain sort order.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flags()

Qt::ItemFlags DeckListModel::flags ( const QModelIndex & index) const
nodiscardoverride
Here is the call graph for this function:

◆ getCards()

QList< ExactCard > DeckListModel::getCards ( ) const
nodiscard
Here is the call graph for this function:

◆ getCardsForZone()

QList< ExactCard > DeckListModel::getCardsForZone ( const QString & zoneName) const
nodiscard
Here is the call graph for this function:

◆ getDeckList()

DeckList * DeckListModel::getDeckList ( ) const
inlinenodiscard
Here is the caller graph for this function:

◆ getGroupCriteriaForCard()

QString DeckListModel::getGroupCriteriaForCard ( CardInfoPtr info) const
nodiscard

Returns the value of the grouping category for a card based on the current criteria.

Parameters
infoPointer to card information.
Returns
String representing the value of the current grouping criteria for the card.
Here is the caller graph for this function:

◆ getNode()

template<typename T>
T DeckListModel::getNode ( const QModelIndex & index) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getRoot()

QModelIndex DeckListModel::getRoot ( ) const
inlinenodiscard

Returns the root index of the model.

Returns
QModelIndex representing the root node.
Here is the call graph for this function:

◆ getZones()

QList< QString > * DeckListModel::getZones ( ) const
nodiscard
Here is the call graph for this function:

◆ headerData()

QVariant DeckListModel::headerData ( int section,
Qt::Orientation orientation,
int role ) const
nodiscardoverride
Here is the call graph for this function:

◆ index()

QModelIndex DeckListModel::index ( int row,
int column,
const QModelIndex & parent ) const
nodiscardoverride
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nodeToIndex()

QModelIndex DeckListModel::nodeToIndex ( AbstractDecklistNode * node) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parent()

QModelIndex DeckListModel::parent ( const QModelIndex & index) const
nodiscardoverride
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rebuildTree

void DeckListModel::rebuildTree ( )
slot

Rebuilds the model tree from the underlying DeckLoader.

This updates all indices and ensures the model reflects the current state of the deck.

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

◆ removeRows()

bool DeckListModel::removeRows ( int row,
int count,
const QModelIndex & parent )
override
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rowCount()

int DeckListModel::rowCount ( const QModelIndex & parent) const
nodiscardoverride
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setActiveGroupCriteria()

void DeckListModel::setActiveGroupCriteria ( DeckListModelGroupCriteria::Type newCriteria)

Sets the criteria used to group cards in the model.

Parameters
newCriteriaThe new grouping criteria.
Here is the call graph for this function:

◆ setData()

bool DeckListModel::setData ( const QModelIndex & index,
const QVariant & value,
int role )
override
Here is the call graph for this function:

◆ setDeckList()

void DeckListModel::setDeckList ( DeckList * _deck)
Parameters
_deckThe deck.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sort()

void DeckListModel::sort ( int column,
Qt::SortOrder order )
override
Here is the call graph for this function:
Here is the caller graph for this function:

◆ sortHelper()

void DeckListModel::sortHelper ( InnerDecklistNode * node,
Qt::SortOrder order )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ activeGroupCriteria

DeckListModelGroupCriteria::Type DeckListModel::activeGroupCriteria = DeckListModelGroupCriteria::MAIN_TYPE
private

◆ deckList

DeckList* DeckListModel::deckList
private

Pointer to the deck loader providing the underlying data.

◆ lastKnownColumn

int DeckListModel::lastKnownColumn
private

Last column used for sorting.

◆ lastKnownOrder

Qt::SortOrder DeckListModel::lastKnownOrder
private

Last known sort order.

◆ root

InnerDecklistNode* DeckListModel::root
private

Root node of the model tree.


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