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

The list model backing the Visual Deck Storage widget tree. More...

#include <visual_deck_storage_model.h>

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

Signals

void deckLoaded (int row)
 Emitted when a deck file finishes loading.
void deckFilePathChanged (const QString &oldFilePath, const QString &newFilePath)
 Emitted when a deck's file path changes (rename file, conversion).

Public Member Functions

 VisualDeckStorageModel (QObject *parent=nullptr)
void setDeckPath (const QString &path)
 Sets the folder to scan for deck files and starts (re)loading. Clears the model immediately (modelReset), then populates it asynchronously as the background scan discovers deck files.
void refresh ()
 Re-scans the current deck folder, reloading every deck file.
QString getDeckPath () const
QStringList getFolderPaths () const
 The relative paths of all subdirectories of the deck folder, one level at a time. Used by the view to build the folder tree. Sorted for deterministic order.
Qt model overrides
int rowCount (const QModelIndex &parent=QModelIndex()) const override
QVariant data (const QModelIndex &index, int role) const override
Data accessors
const DeckPreviewDatadataForRow (int row) const
const LoadedDeckdeckForRow (int row) const
int rowForFilePath (const QString &filePath) const
Mutations (persist to disk and update the row)
bool renameDeck (int row, const QString &newName)
bool renameFile (int row, const QString &newBaseName)
bool deleteFile (int row)
bool setTags (int row, const QStringList &tags)
bool setBannerCard (int row, const CardRef &cardRef)
bool convertToCockatriceFormat (int row)
bool reloadIfModified (int row)

Private Slots

void drainPendingLoads ()

Private Member Functions

void startScan ()
void beginLoad (int row)
void reindexFilePaths ()
 Rebuilds the file path -> row index from scratch after bulk changes.
void schedulePendingLoadDrain ()
void setFilePathForRow (int row, const QString &newFilePath)

Static Private Member Functions

static void recomputeDeckMetadata (DeckPreviewData &data, bool recomputeColorIdentity=true)
 Recomputes all derived metadata of a row from its loaded deck.

Private Attributes

QString deckPath
QList< DeckPreviewDatadecks
QHash< QString, int > rowByFilePath
 Maps each deck's file path to its row for O(1) lookups.
QStringList folderPaths
 All subdirectories of the deck folder, sorted.
int scanGeneration = 0
 Bumped on every scan so stale results are ignored.
QVector< PendingDeckLoadpendingLoads
 Finished background loads waiting to be applied.
bool drainScheduled = false
 Whether a queued drain pass is already pending.

Detailed Description

The list model backing the Visual Deck Storage widget tree.

Rows are in filesystem scan order; ordering and filtering are handled by VisualDeckStorageSortFilterProxyModel on top of this model. The proxy keeps every row and exposes each row's filter result through its FilterMatchRole.

Constructor & Destructor Documentation

◆ VisualDeckStorageModel()

VisualDeckStorageModel::VisualDeckStorageModel ( QObject * parent = nullptr)
explicit

Member Function Documentation

◆ beginLoad()

void VisualDeckStorageModel::beginLoad ( int row)
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ convertToCockatriceFormat()

bool VisualDeckStorageModel::convertToCockatriceFormat ( int row)
Here is the call graph for this function:

◆ data()

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

◆ dataForRow()

const DeckPreviewData & VisualDeckStorageModel::dataForRow ( int row) const
nodiscard
Here is the caller graph for this function:

◆ deckFilePathChanged

void VisualDeckStorageModel::deckFilePathChanged ( const QString & oldFilePath,
const QString & newFilePath )
signal

Emitted when a deck's file path changes (rename file, conversion).

Parameters
oldFilePathThe previous file path.
newFilePathThe new file path.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ deckForRow()

const LoadedDeck & VisualDeckStorageModel::deckForRow ( int row) const
nodiscard
Here is the call graph for this function:

◆ deckLoaded

void VisualDeckStorageModel::deckLoaded ( int row)
signal

Emitted when a deck file finishes loading.

Parameters
rowThe row of the deck that finished loading.
Here is the caller graph for this function:

◆ deleteFile()

bool VisualDeckStorageModel::deleteFile ( int row)

◆ drainPendingLoads

void VisualDeckStorageModel::drainPendingLoads ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDeckPath()

QString VisualDeckStorageModel::getDeckPath ( ) const
inlinenodiscard

◆ getFolderPaths()

QStringList VisualDeckStorageModel::getFolderPaths ( ) const
inlinenodiscard

The relative paths of all subdirectories of the deck folder, one level at a time. Used by the view to build the folder tree. Sorted for deterministic order.

◆ recomputeDeckMetadata()

void VisualDeckStorageModel::recomputeDeckMetadata ( DeckPreviewData & data,
bool recomputeColorIdentity = true )
staticprivate

Recomputes all derived metadata of a row from its loaded deck.

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

◆ refresh()

void VisualDeckStorageModel::refresh ( )

Re-scans the current deck folder, reloading every deck file.

Here is the call graph for this function:

◆ reindexFilePaths()

void VisualDeckStorageModel::reindexFilePaths ( )
private

Rebuilds the file path -> row index from scratch after bulk changes.

Here is the caller graph for this function:

◆ reloadIfModified()

bool VisualDeckStorageModel::reloadIfModified ( int row)
Here is the call graph for this function:

◆ renameDeck()

bool VisualDeckStorageModel::renameDeck ( int row,
const QString & newName )
Here is the call graph for this function:

◆ renameFile()

bool VisualDeckStorageModel::renameFile ( int row,
const QString & newBaseName )
Here is the call graph for this function:

◆ rowCount()

int VisualDeckStorageModel::rowCount ( const QModelIndex & parent = QModelIndex()) const
nodiscardoverride

◆ rowForFilePath()

int VisualDeckStorageModel::rowForFilePath ( const QString & filePath) const
nodiscard
Here is the caller graph for this function:

◆ schedulePendingLoadDrain()

void VisualDeckStorageModel::schedulePendingLoadDrain ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBannerCard()

bool VisualDeckStorageModel::setBannerCard ( int row,
const CardRef & cardRef )
Here is the call graph for this function:

◆ setDeckPath()

void VisualDeckStorageModel::setDeckPath ( const QString & path)

Sets the folder to scan for deck files and starts (re)loading. Clears the model immediately (modelReset), then populates it asynchronously as the background scan discovers deck files.

Here is the call graph for this function:

◆ setFilePathForRow()

void VisualDeckStorageModel::setFilePathForRow ( int row,
const QString & newFilePath )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTags()

bool VisualDeckStorageModel::setTags ( int row,
const QStringList & tags )
Here is the call graph for this function:

◆ startScan()

void VisualDeckStorageModel::startScan ( )
private
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ deckPath

QString VisualDeckStorageModel::deckPath
private

◆ decks

QList<DeckPreviewData> VisualDeckStorageModel::decks
private

◆ drainScheduled

bool VisualDeckStorageModel::drainScheduled = false
private

Whether a queued drain pass is already pending.

◆ folderPaths

QStringList VisualDeckStorageModel::folderPaths
private

All subdirectories of the deck folder, sorted.

◆ pendingLoads

QVector<PendingDeckLoad> VisualDeckStorageModel::pendingLoads
private

Finished background loads waiting to be applied.

◆ rowByFilePath

QHash<QString, int> VisualDeckStorageModel::rowByFilePath
private

Maps each deck's file path to its row for O(1) lookups.

◆ scanGeneration

int VisualDeckStorageModel::scanGeneration = 0
private

Bumped on every scan so stale results are ignored.


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