|
ORE Studio 0.0.4
|
Cache for dynamically loaded images (flags, icons) from the server. More...
#include <ImageCache.hpp>
Inherits QObject.

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 | clear () |
| Clear all caches and reset load state. | |
| 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. | |
| QIcon | getCurrencyFlagIcon (const std::string &iso_code) |
| Get flag icon for a currency by its ISO code. | |
| QIcon | getCountryFlagIcon (const std::string &alpha2_code) |
| Get flag icon for a country by its alpha-2 code. | |
| QIcon | getBusinessCentreFlagIcon (const std::string &bc_code) |
| Get flag icon for a business centre by its code. | |
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:
| 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.
| 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.
| 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.
| image_id | The image UUID as a string |
| bool hasIcon | ( | const std::string & | image_id | ) | const |
Check if an image is cached.
| image_id | The image UUID |
| void clear | ( | ) |
| 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.

| const std::vector< assets::messaging::image_info > & availableImages | ( | ) | const |
Get the list of available images.
| 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.

| 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.
| iso_code | The currency ISO code |
| image_id | The image ID to assign (empty to remove) |
| assigned_by | Username performing the assignment |
| 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.
| alpha2_code | The country alpha-2 code |
| image_id | The image ID to assign (empty to remove) |
| assigned_by | Username performing the assignment |
| std::string getNoFlagImageId | ( | ) | const |
Get the image ID for the "no-flag" placeholder.
| QIcon getNoFlagIcon | ( | ) | const |
Get the icon for the "no-flag" placeholder.
| QIcon getCurrencyFlagIcon | ( | const std::string & | iso_code | ) |
Get flag icon for a currency by its ISO code.
Looks up the currency's image_id from the cached mapping, then returns the corresponding icon. Returns empty icon if not found.

| QIcon getCountryFlagIcon | ( | const std::string & | alpha2_code | ) |
Get flag icon for a country by its alpha-2 code.
Looks up the country's image_id from the cached mapping, then returns the corresponding icon. Returns empty icon if not found.

| QIcon getBusinessCentreFlagIcon | ( | const std::string & | bc_code | ) |
Get flag icon for a business centre by its code.
Chains business centre code -> country alpha-2 -> country flag icon. Returns empty icon if any mapping is missing.

|
signal |
Emitted when a single image has been loaded.
Connect to this signal to refresh UI when on-demand images finish loading.
