ORE Studio 0.0.4
Loading...
Searching...
No Matches
Signals | Public Member Functions | List of all members
ImageCache Class Referencefinal

Cache for dynamically loaded images (flags, icons) from the server. More...

#include <ImageCache.hpp>

Inherits QObject.

Collaboration diagram for ImageCache:
Collaboration graph

Signals

void imagesLoaded ()
 Emitted when images have been loaded.
 
void allLoaded ()
 Emitted when all data has been loaded (after loadAll()).
 
void loadError (const QString &error_message)
 Emitted when an error occurs during loading.
 
void imageListLoaded ()
 Emitted when image list has been loaded.
 
void imageLoaded (const QString &image_id)
 Emitted when a single image has been loaded.
 
void allAvailableImagesLoaded ()
 Emitted when all available images have been loaded.
 
void currencyImageSet (const QString &iso_code, bool success, const QString &message)
 Emitted when currency image assignment is complete.
 
void countryImageSet (const QString &alpha2_code, bool success, const QString &message)
 Emitted when country image assignment is complete.
 

Public Member Functions

 ImageCache (ClientManager *clientManager, QObject *parent=nullptr)
 
void loadAll ()
 Preload images for current currencies and countries.
 
void reload ()
 Clear all caches and reload images.
 
QIcon getIcon (const std::string &image_id)
 Get icon for an image by its UUID.
 
bool hasIcon (const std::string &image_id) const
 Check if an image is cached.
 
std::size_t cachedIconCount () const
 Get the number of cached images.
 
bool isLoading () const
 Check if images are currently being loaded.
 
void loadImageList ()
 Load list of all available images from the server.
 
const std::vector< assets::messaging::image_info > & availableImages () const
 Get the list of available images.
 
bool hasImageList () const
 Check if image list has been loaded.
 
void loadAllAvailableImages ()
 Load all available images from the image list.
 
void setCurrencyImage (const std::string &iso_code, const std::string &image_id, const std::string &assigned_by)
 Set or remove a currency's image association.
 
void setCountryImage (const std::string &alpha2_code, const std::string &image_id, const std::string &assigned_by)
 Set or remove a country's image association.
 
std::string getNoFlagImageId () const
 Get the image ID for the "no-flag" placeholder.
 
QIcon getNoFlagIcon () const
 Get the icon for the "no-flag" placeholder.
 

Detailed Description

Cache for dynamically loaded images (flags, icons) from the server.

This class manages the fetching and caching of images from the server. Images are cached by their UUID (image_id) and can be retrieved for any entity that references them.

Simplified design:

Typical usage:

  1. Call loadAll() to preload images for current entities
  2. Use getIcon(image_id) to retrieve icons - loads on-demand if missing

Member Function Documentation

◆ loadAll()

void loadAll ( )

Preload images for current currencies and countries.

Fetches current entities to discover their image_ids, then loads those images into the cache. After completion, allLoaded() signal is emitted.

◆ reload()

void reload ( )

Clear all caches and reload images.

Use this after data changes (e.g., publishing datasets) to refresh the cache with current server data. Emits allLoaded() when complete.

◆ getIcon()

QIcon getIcon ( const std::string &  image_id)

Get icon for an image by its UUID.

If the image is cached, returns it immediately. If not cached, triggers async load and returns placeholder icon. When the image loads, imageLoaded(image_id) signal is emitted.

Parameters
image_idThe image UUID as a string
Returns
QIcon for the image, or placeholder if not yet loaded

◆ hasIcon()

bool hasIcon ( const std::string &  image_id) const

Check if an image is cached.

Parameters
image_idThe image UUID
Returns
true if icon is cached, false otherwise

◆ loadImageList()

void loadImageList ( )

Load list of all available images from the server.

Fetches metadata for all images (without SVG data). After completion, imageListLoaded() signal is emitted.

Here is the caller graph for this function:

◆ availableImages()

const std::vector< assets::messaging::image_info > & availableImages ( ) const

Get the list of available images.

Returns
Vector of image metadata (id, key, description)

◆ loadAllAvailableImages()

void loadAllAvailableImages ( )

Load all available images from the image list.

Fetches SVG data for all images in the available_images_ list. After completion, allAvailableImagesLoaded() signal is emitted.

Here is the caller graph for this function:

◆ setCurrencyImage()

void setCurrencyImage ( const std::string &  iso_code,
const std::string &  image_id,
const std::string &  assigned_by 
)

Set or remove a currency's image association.

Parameters
iso_codeThe currency ISO code
image_idThe image ID to assign (empty to remove)
assigned_byUsername performing the assignment

◆ setCountryImage()

void setCountryImage ( const std::string &  alpha2_code,
const std::string &  image_id,
const std::string &  assigned_by 
)

Set or remove a country's image association.

Parameters
alpha2_codeThe country alpha-2 code
image_idThe image ID to assign (empty to remove)
assigned_byUsername performing the assignment

◆ getNoFlagImageId()

std::string getNoFlagImageId ( ) const

Get the image ID for the "no-flag" placeholder.

Returns
The image ID for the "no-flag" image, or empty string if not found

◆ getNoFlagIcon()

QIcon getNoFlagIcon ( ) const

Get the icon for the "no-flag" placeholder.

Returns
The QIcon for the "no-flag" image, or empty icon if not loaded

◆ imageLoaded

void imageLoaded ( const QString &  image_id)
signal

Emitted when a single image has been loaded.

Connect to this signal to refresh UI when on-demand images finish loading.

Here is the caller graph for this function: