|
ORE Studio 0.0.4
|
Model for displaying currencies fetched from the server via client. More...
#include <ClientCurrencyModel.hpp>
Inherits QAbstractTableModel.

Public Types | |
| enum | Column { Flag , CurrencyName , IsoCode , Version , NumericCode , Symbol , FractionSymbol , FractionsPerUnit , RoundingType , RoundingPrecision , Format , CurrencyType , RecordedBy , RecordedAt , ColumnCount } |
| Enumeration of table columns for type-safe column access. More... | |
Signals | |
| void | dataLoaded () |
| Emitted when data has been successfully loaded. | |
| void | loadError (const QString &error_message, const QString &details={}) |
| Emitted when an error occurs during data loading. | |
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. | |
| bool | canFetchMore (const QModelIndex &parent=QModelIndex()) const override |
| Check if more data can be fetched from the server. | |
| void | fetchMore (const QModelIndex &parent=QModelIndex()) override |
| Fetch the next page of data from the server. | |
| const refdata::domain::currency * | getCurrency (int row) const |
| Get currency at the specified row. | |
| std::vector< refdata::domain::currency > | getCurrencies () 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. | |
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.
| 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.
| 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. When replace is true, existing data is cleared before loading. When false, new data is appended (for pagination).
| replace | If true, replace existing data; if false, append. |
| 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.
| offset | Number of records to skip |
| limit | Number of records to fetch |
|
override |
Check if more data can be fetched from the server.
|
override |
Fetch the next page of data from the server.
This is called automatically by Qt views when scrolling approaches the end of currently loaded data.
| const refdata::domain::currency * getCurrency | ( | int | row | ) | const |
Get currency at the specified row.
| row | The row index. |
| std::vector< refdata::domain::currency > getCurrencies | ( | ) | 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.
| size | The number of records to fetch per page (1-1000). |
| 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.
These currencies are displayed with a distinct color to indicate they haven't been saved to the server yet.
| currencies | The generated currencies to add. |
| bool is_synthetic | ( | const std::string & | iso_code | ) | const |
Check if a currency is synthetic (generated but not saved).
| iso_code | The ISO code to check. |
| 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.
| iso_code | The ISO code of the saved currency. |
| void clear_synthetic_markers | ( | ) |
Clear all synthetic currency markers.
Called when refreshing data from server.