20#ifndef ORES_QT_CLIENT_CURRENCY_MODEL_HPP
21#define ORES_QT_CLIENT_CURRENCY_MODEL_HPP
24#include <unordered_set>
26#include <QFutureWatcher>
27#include <QAbstractTableModel>
29#include "ores.qt/ClientManager.hpp"
30#include "ores.utility/log/make_logger.hpp"
31#include "ores.risk/domain/currency.hpp"
45 inline static std::string_view logger_name =
46 "ores.qt.client_currency_model";
48 [[nodiscard]]
static auto& lg() {
50 static auto instance = make_logger(logger_name);
79 QObject* parent =
nullptr);
83 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
84 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
85 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
86 QVariant headerData(
int section, Qt::Orientation orientation,
87 int role = Qt::DisplayRole)
const override;
99 void refresh(
bool replace =
true);
106 bool canFetchMore(
const QModelIndex& parent = QModelIndex())
const override;
114 void fetchMore(
const QModelIndex& parent = QModelIndex())
override;
164 void onCurrenciesLoaded();
165 void onPulseTimerTimeout();
177 QVariant recency_foreground_color(
const std::string& iso_code)
const;
182 void update_recent_currencies();
186 std::vector<risk::domain::currency> currencies;
187 std::uint32_t total_available_count;
190 using FutureWatcherResult = FetchResult;
193 std::vector<risk::domain::currency> currencies_;
194 QFutureWatcher<FutureWatcherResult>* watcher_;
195 std::uint32_t page_size_{100};
196 std::uint32_t total_available_count_{0};
197 bool is_fetching_{
false};
200 std::unordered_set<std::string> recent_iso_codes_;
201 QDateTime last_reload_time_;
202 QTimer* pulse_timer_;
203 bool pulse_state_{
false};
205 static constexpr int max_pulse_cycles_{6};
206 static constexpr int pulse_interval_ms_{500};
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Model for displaying currencies fetched from the server via client.
Definition ClientCurrencyModel.hpp:41
bool canFetchMore(const QModelIndex &parent=QModelIndex()) const override
Check if more data can be fetched from the server.
Definition ClientCurrencyModel.cpp:300
void fetchMore(const QModelIndex &parent=QModelIndex()) override
Fetch the next page of data from the server.
Definition ClientCurrencyModel.cpp:321
std::vector< risk::domain::currency > getCurrencies() const
Get all currencies.
Definition ClientCurrencyModel.cpp:296
void set_page_size(std::uint32_t size)
Set the page size for pagination.
Definition ClientCurrencyModel.cpp:329
std::uint32_t total_available_count() const
Get the total number of records available on the server.
Definition ClientCurrencyModel.hpp:150
const risk::domain::currency * getCurrency(int row) const
Get currency at the specified row.
Definition ClientCurrencyModel.cpp:289
void dataLoaded()
Emitted when data has been successfully loaded.
void refresh(bool replace=true)
Refresh currency data from server asynchronously.
Definition ClientCurrencyModel.cpp:127
std::uint32_t page_size() const
Get the page size used for pagination.
Definition ClientCurrencyModel.hpp:136
void loadError(const QString &error_message)
Emitted when an error occurs during data loading.
Column
Enumeration of table columns for type-safe column access.
Definition ClientCurrencyModel.hpp:61
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:47
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:30