ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
ClientCurrencyModel Class Referencefinal

Model for displaying currencies fetched from the server via client. More...

#include <ClientCurrencyModel.hpp>

Inheritance diagram for ClientCurrencyModel:
Inheritance graph
Collaboration diagram for ClientCurrencyModel:
Collaboration graph

Public Types

enum  Column {
  IsoCode , CurrencyName , NumericCode , Symbol ,
  FractionSymbol , FractionsPerUnit , RoundingType , RoundingPrecision ,
  Format , MonetaryNature , MarketTier , Version ,
  ModifiedBy , RecordedAt , ColumnCount
}
 Enumeration of table columns for type-safe column access. More...
 

Public Member Functions

 ClientCurrencyModel (ClientManager *clientManager, ImageCache *imageCache, QObject *parent=nullptr)
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
void refresh (bool replace=true)
 Refresh currency data from server asynchronously.
 
void load_page (std::uint32_t offset, std::uint32_t limit)
 Load a specific page of currency data.
 
const refdata::domain::currencygetCurrency (int row) const
 Get currency at the specified row.
 
std::vector< refdata::domain::currencygetCurrencies () const
 Get all currencies.
 
std::uint32_t page_size () const
 Get the page size used for pagination.
 
void set_page_size (std::uint32_t size)
 Set the page size for pagination.
 
std::uint32_t total_available_count () const
 Get the total number of records available on the server.
 
void add_synthetic_currencies (std::vector< refdata::domain::currency > currencies)
 Add synthetic (generated) currencies to the model.
 
bool is_synthetic (const std::string &iso_code) const
 Check if a currency is synthetic (generated but not saved).
 
void mark_as_saved (const std::string &iso_code)
 Mark a synthetic currency as saved (no longer synthetic).
 
void clear_synthetic_markers ()
 Clear all synthetic currency markers.
 

Static Public Member Functions

static std::vector< column_style > const & columnStyles ()
 Returns a static vector of column styles (built once per process).
 
static QVector< int > defaultHiddenColumns ()
 Returns a static QVector of hidden column indices (built once per process).
 

Static Public Attributes

static constexpr std::size_t kColumnCount = std::size_t(ColumnCount)
 Column metadata: header text, style, visibility, and width.
 
static constexpr std::array< ColumnMetadata, kColumnCountkColumns
 
static const QSize kDefaultWindowSize = {1000, 600}
 Default window size for the currency list window.
 
static constexpr std::string_view kSettingsGroup = "CurrencyListWindow"
 Settings group name for persisting window and column state.
 

Additional Inherited Members

- Signals inherited from AbstractClientModel
void dataLoaded ()
 
void loadError (const QString &error_message, const QString &details={})
 

Detailed Description

Model for displaying currencies fetched from the server via client.

This model extends QAbstractTableModel and fetches currency data asynchronously using the ores.comms client instead of direct database access.

Member Enumeration Documentation

◆ Column

enum Column

Enumeration of table columns for type-safe column access.

Using an enum instead of magic numbers makes the code self-documenting and easier to refactor when columns are added, removed, or reordered.

Member Function Documentation

◆ refresh()

void refresh ( bool  replace = true)

Refresh currency data from server asynchronously.

This method initiates an async request to fetch currencies. The model will emit dataChanged() when the fetch completes.

◆ load_page()

void load_page ( std::uint32_t  offset,
std::uint32_t  limit 
)

Load a specific page of currency data.

Used for pagination navigation. Replaces current data with the requested page.

Parameters
offsetNumber of records to skip
limitNumber of records to fetch

◆ getCurrency()

const refdata::domain::currency * getCurrency ( int  row) const

Get currency at the specified row.

Parameters
rowThe row index.
Returns
The currency object, or nullptr if row is invalid.

◆ getCurrencies()

std::vector< refdata::domain::currency > getCurrencies ( ) const

Get all currencies.

Returns
A vector containing all current currencies.

◆ page_size()

std::uint32_t page_size ( ) const

Get the page size used for pagination.

Returns
The number of records fetched per page.

◆ set_page_size()

void set_page_size ( std::uint32_t  size)

Set the page size for pagination.

Parameters
sizeThe number of records to fetch per page (1-1000).

◆ total_available_count()

std::uint32_t total_available_count ( ) const

Get the total number of records available on the server.

Returns
Total available record count.

◆ add_synthetic_currencies()

void add_synthetic_currencies ( std::vector< refdata::domain::currency currencies)

Add synthetic (generated) currencies to the model.

These currencies are displayed with a distinct color to indicate they haven't been saved to the server yet.

Parameters
currenciesThe generated currencies to add.

◆ is_synthetic()

bool is_synthetic ( const std::string &  iso_code) const

Check if a currency is synthetic (generated but not saved).

Parameters
iso_codeThe ISO code to check.
Returns
true if the currency is synthetic.

◆ mark_as_saved()

void mark_as_saved ( const std::string &  iso_code)

Mark a synthetic currency as saved (no longer synthetic).

Called after a generated currency has been successfully saved to server.

Parameters
iso_codeThe ISO code of the saved currency.

◆ clear_synthetic_markers()

void clear_synthetic_markers ( )

Clear all synthetic currency markers.

Called when refreshing data from server.

Member Data Documentation

◆ kColumnCount

constexpr std::size_t kColumnCount = std::size_t(ColumnCount)
staticconstexpr

Column metadata: header text, style, visibility, and width.

Order must match the Column enum.