Cockatrice 2026-03-05-Development-2.11.0-beta.54
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
DeckLoader Class Reference

#include <deck_loader.h>

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

Public Types

enum  DecklistWebsite { DecklistOrg , DecklistXyz }

Signals

void loadFinished (bool success)

Public Member Functions

 DeckLoader (QObject *parent)
 DeckLoader (const DeckLoader &)=delete
DeckLoaderoperator= (const DeckLoader &)=delete
bool hasNotBeenLoaded () const
void loadFromFileAsync (const QString &fileName, DeckFileFormat::Format fmt, bool userRequest)
 Asynchronously loads a deck from a local file into this DeckLoader. The loadFinished signal will be emitted when the load finishes. Once the loading finishes, the deck can be accessed with getDeck
bool reload ()
 Loads the file that the lastLoadInfo currently points to into this instance. No-ops if the lastLoadInfo is missing the required info or the load fails.
LoadedDeckgetDeck ()
const LoadedDeckgetDeck () const
void setDeck (const LoadedDeck &deck)

Static Public Member Functions

static std::optional< LoadedDeckloadFromFile (const QString &fileName, DeckFileFormat::Format fmt, bool userRequest=false)
 Loads a deck from a local file.
static std::optional< LoadedDeckloadFromRemote (const QString &nativeString, int remoteDeckId)
 Loads a deck from the response of a remote deck request.
static std::optional< LoadedDeck::LoadInfosaveToFile (const DeckList &deck, const QString &fileName, DeckFileFormat::Format fmt)
 Saves a DeckList to a local file.
static bool saveToFile (const LoadedDeck &deck)
 Saves a LoadedDeck to a local file. Uses the lastLoadInfo in the LoadedDeck to determine where to save to.
static bool saveToNewFile (LoadedDeck &deck, const QString &fileName, DeckFileFormat::Format fmt)
 Saves a LoadedDeck to a new local file.
static QString exportDeckToDecklist (const DeckList &deckList, DecklistWebsite website)
static void saveToClipboard (const DeckList &deckList, bool addComments=true, bool addSetNameAndNumber=true)
static bool saveToStream_Plain (QTextStream &out, const DeckList &deckList, bool addComments=true, bool addSetNameAndNumber=true)
static void printDeckList (QPrinter *printer, const DeckList &deckList)
 Prints the decklist to the provided QPrinter.
static bool convertToCockatriceFormat (LoadedDeck &deck)

Static Public Attributes

static const QStringList ACCEPTED_FILE_EXTENSIONS = {"*.cod", "*.dec", "*.dek", "*.txt", "*.mwDeck"}
static const QStringList FILE_NAME_FILTERS

Static Private Member Functions

static bool updateLastLoadedTimestamp (LoadedDeck &deck)
 Updates the lastLoadedTimestamp field in the file corresponding to the deck, without changing the FileModificationTime of the file.
static void printDeckListNode (QTextCursor *cursor, const InnerDecklistNode *node)
static void saveToStream_DeckHeader (QTextStream &out, const DeckList &deckList)
static void saveToStream_DeckZone (QTextStream &out, const InnerDecklistNode *zoneNode, bool addComments=true, bool addSetNameAndNumber=true)
static void saveToStream_DeckZoneCards (QTextStream &out, const InnerDecklistNode *zoneNode, QList< DecklistCardNode * > cards, bool addComments=true, bool addSetNameAndNumber=true)

Private Attributes

LoadedDeck loadedDeck

Member Enumeration Documentation

◆ DecklistWebsite

Enumerator
DecklistOrg 
DecklistXyz 

Constructor & Destructor Documentation

◆ DeckLoader() [1/2]

DeckLoader::DeckLoader ( QObject * parent)
Here is the caller graph for this function:

◆ DeckLoader() [2/2]

DeckLoader::DeckLoader ( const DeckLoader & )
delete
Here is the call graph for this function:

Member Function Documentation

◆ convertToCockatriceFormat()

bool DeckLoader::convertToCockatriceFormat ( LoadedDeck & deck)
static

Converts the given deck's file to the cockatrice file format. Uses the lastLoadInfo in the LoadedDeck to determine the current name of the file and where to save to.

Parameters
deckThe deck to convert. Should have valid lastLoadInfo. Will update the lastLoadInfo.
Returns
Whether the conversion succeeded.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ exportDeckToDecklist()

QString DeckLoader::exportDeckToDecklist ( const DeckList & deckList,
DecklistWebsite website )
static

Export deck to decklist function, called to format the deck in a way to be sent to a server

Parameters
deckListThe decklist to export
websiteThe website we're sending the deck to
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getDeck() [1/2]

LoadedDeck & DeckLoader::getDeck ( )
inline
Here is the caller graph for this function:

◆ getDeck() [2/2]

const LoadedDeck & DeckLoader::getDeck ( ) const
inline

◆ hasNotBeenLoaded()

bool DeckLoader::hasNotBeenLoaded ( ) const
inlinenodiscard

◆ loadFinished

void DeckLoader::loadFinished ( bool success)
signal
Here is the caller graph for this function:

◆ loadFromFile()

std::optional< LoadedDeck > DeckLoader::loadFromFile ( const QString & fileName,
DeckFileFormat::Format fmt,
bool userRequest = false )
static

Loads a deck from a local file.

Parameters
fileNameThe file to load
fmtThe format of the file to load
userRequestWhether the load was manually requested by the user, instead of being done in the background.
Returns
An optional containing the LoadedDeck, or empty if the load failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ loadFromFileAsync()

void DeckLoader::loadFromFileAsync ( const QString & fileName,
DeckFileFormat::Format fmt,
bool userRequest )

Asynchronously loads a deck from a local file into this DeckLoader. The loadFinished signal will be emitted when the load finishes. Once the loading finishes, the deck can be accessed with getDeck

Parameters
fileNameThe file to load
fmtThe format of the file to load
userRequestWhether the load was manually requested by the user, instead of being done in the background.
Here is the call graph for this function:

◆ loadFromRemote()

std::optional< LoadedDeck > DeckLoader::loadFromRemote ( const QString & nativeString,
int remoteDeckId )
static

Loads a deck from the response of a remote deck request.

Parameters
nativeStringThe deck string, in cod format
remoteDeckIdThe remote deck id
Returns
An optional containing the LoadedDeck, or empty if the load failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

DeckLoader & DeckLoader::operator= ( const DeckLoader & )
delete
Here is the call graph for this function:

◆ printDeckList()

void DeckLoader::printDeckList ( QPrinter * printer,
const DeckList & deckList )
static

Prints the decklist to the provided QPrinter.

Parameters
printerThe printer to render the decklist to.
deckList
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printDeckListNode()

void DeckLoader::printDeckListNode ( QTextCursor * cursor,
const InnerDecklistNode * node )
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reload()

bool DeckLoader::reload ( )

Loads the file that the lastLoadInfo currently points to into this instance. No-ops if the lastLoadInfo is missing the required info or the load fails.

Returns
Whether the loaded succeeded.
Here is the call graph for this function:

◆ saveToClipboard()

void DeckLoader::saveToClipboard ( const DeckList & deckList,
bool addComments = true,
bool addSetNameAndNumber = true )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToFile() [1/2]

std::optional< LoadedDeck::LoadInfo > DeckLoader::saveToFile ( const DeckList & deck,
const QString & fileName,
DeckFileFormat::Format fmt )
static

Saves a DeckList to a local file.

Parameters
deckThe DeckList
fileNameThe file to write to
fmtThe deck file format to use
Returns
An optional containing the LoadInfo for the new file, or empty if the save failed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToFile() [2/2]

bool DeckLoader::saveToFile ( const LoadedDeck & deck)
static

Saves a LoadedDeck to a local file. Uses the lastLoadInfo in the LoadedDeck to determine where to save to.

Parameters
deckThe LoadedDeck to save. Should have valid lastLoadInfo.
Returns
Whether the save succeeded.
Here is the call graph for this function:

◆ saveToNewFile()

bool DeckLoader::saveToNewFile ( LoadedDeck & deck,
const QString & fileName,
DeckFileFormat::Format fmt )
static

Saves a LoadedDeck to a new local file.

Parameters
deckThe LoadedDeck to save. Will update the lastLoadInfo.
fileNameThe file to write to
fmtThe deck file format to use
Returns
Whether the save succeeded.
Here is the call graph for this function:

◆ saveToStream_DeckHeader()

void DeckLoader::saveToStream_DeckHeader ( QTextStream & out,
const DeckList & deckList )
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToStream_DeckZone()

void DeckLoader::saveToStream_DeckZone ( QTextStream & out,
const InnerDecklistNode * zoneNode,
bool addComments = true,
bool addSetNameAndNumber = true )
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToStream_DeckZoneCards()

void DeckLoader::saveToStream_DeckZoneCards ( QTextStream & out,
const InnerDecklistNode * zoneNode,
QList< DecklistCardNode * > cards,
bool addComments = true,
bool addSetNameAndNumber = true )
staticprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveToStream_Plain()

bool DeckLoader::saveToStream_Plain ( QTextStream & out,
const DeckList & deckList,
bool addComments = true,
bool addSetNameAndNumber = true )
static
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDeck()

void DeckLoader::setDeck ( const LoadedDeck & deck)
inline

◆ updateLastLoadedTimestamp()

bool DeckLoader::updateLastLoadedTimestamp ( LoadedDeck & deck)
staticprivate

Updates the lastLoadedTimestamp field in the file corresponding to the deck, without changing the FileModificationTime of the file.

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

Member Data Documentation

◆ ACCEPTED_FILE_EXTENSIONS

const QStringList DeckLoader::ACCEPTED_FILE_EXTENSIONS = {"*.cod", "*.dec", "*.dek", "*.txt", "*.mwDeck"}
static

Supported file extensions for decklist files

◆ FILE_NAME_FILTERS

const QStringList DeckLoader::FILE_NAME_FILTERS
static
Initial value:
= {
tr("Common deck formats (%1)").arg(ACCEPTED_FILE_EXTENSIONS.join(" ")), tr("All files (*.*)")}
static const QStringList ACCEPTED_FILE_EXTENSIONS
Definition deck_loader.h:23

For use with QFileDialog::setNameFilters

◆ loadedDeck

LoadedDeck DeckLoader::loadedDeck
private

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