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

Handles searching for and loading card images from local and custom image folders. More...

#include <card_picture_loader_local.h>

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

Public Member Functions

 CardPictureLoaderLocal (QObject *parent)
 Constructs a CardPictureLoaderLocal object.
QImage tryLoad (const ExactCard &toLoad) const
 Attempts to load a card image from local disk or custom folders.

Private Slots

void picsPathChanged ()
 Updates internal paths when the user changes picture settings.

Private Member Functions

void refreshIndex ()
 Rebuilds the index of the custom image folder.
QImage tryLoadCardImageFromDisk (const QString &setName, const QString &correctedCardName, const QString &collectorNumber, const QString &providerId) const
 Attempts to load a card image from disk given its set and name info.

Private Attributes

QString picsPath
 Path to standard card image folder.
QString customPicsPath
 Path to custom card image folder.
QMultiHash< QString, QString > customFolderIndex
 Multimap from cardName to file paths in CUSTOM folder.
QTimer * refreshTimer
 Timer for periodic folder index refresh.

Detailed Description

Handles searching for and loading card images from local and custom image folders.

This class maintains an index of the CUSTOM folder to avoid repeatedly scanning directories, and supports periodic refreshes to update the index.

Responsibilities:

  • Load images for ExactCard objects from local disk or custom folders.
  • Maintain an index for fast lookup of images in the CUSTOM folder.
  • Refresh the index periodically to account for changes in local image directories.

Constructor & Destructor Documentation

◆ CardPictureLoaderLocal()

CardPictureLoaderLocal::CardPictureLoaderLocal ( QObject * parent)
explicit

Constructs a CardPictureLoaderLocal object.

Parameters
parentOptional parent QObject.

Initializes paths from SettingsCache, connects to settings change signals, builds the initial folder index, and starts a periodic refresh timer.

Here is the call graph for this function:

Member Function Documentation

◆ picsPathChanged

void CardPictureLoaderLocal::picsPathChanged ( )
privateslot

Updates internal paths when the user changes picture settings.

Triggered by SettingsCache::picsPathChanged.

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

◆ refreshIndex()

void CardPictureLoaderLocal::refreshIndex ( )
private

Rebuilds the index of the custom image folder.

Iterates through all subdirectories of the CUSTOM folder and populates customFolderIndex with all discovered image files keyed by base name and complete base name.

Here is the caller graph for this function:

◆ tryLoad()

QImage CardPictureLoaderLocal::tryLoad ( const ExactCard & toLoad) const
nodiscard

Attempts to load a card image from local disk or custom folders.

Parameters
toLoadExactCard object representing the card to load.
Returns
Loaded QImage if found; otherwise, an empty QImage.

Uses a set of name variants and folder paths to attempt to locate the correct image.

Here is the call graph for this function:

◆ tryLoadCardImageFromDisk()

QImage CardPictureLoaderLocal::tryLoadCardImageFromDisk ( const QString & setName,
const QString & correctedCardName,
const QString & collectorNumber,
const QString & providerId ) const
nodiscardprivate

Attempts to load a card image from disk given its set and name info.

Parameters
setNameCorrected short name of the card's set.
correctedCardNameCorrected card name (e.g., normalized name).
collectorNumberCollector number of the card.
providerIdOptional provider UUID of the card.
Returns
Loaded QImage if found; otherwise, an empty QImage.

Searches in both the custom folder index and standard pictures paths. Uses several filename patterns to match card images, in order from most-specific to least-specific.

Here is the caller graph for this function:

Member Data Documentation

◆ customFolderIndex

QMultiHash<QString, QString> CardPictureLoaderLocal::customFolderIndex
private

Multimap from cardName to file paths in CUSTOM folder.

◆ customPicsPath

QString CardPictureLoaderLocal::customPicsPath
private

Path to custom card image folder.

◆ picsPath

QString CardPictureLoaderLocal::picsPath
private

Path to standard card image folder.

◆ refreshTimer

QTimer* CardPictureLoaderLocal::refreshTimer
private

Timer for periodic folder index refresh.


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