20#ifndef ORES_QT_CLIENT_BUSINESS_CENTRE_MODEL_HPP
21#define ORES_QT_CLIENT_BUSINESS_CENTRE_MODEL_HPP
26#include <QFutureWatcher>
27#include <QAbstractTableModel>
28#include "ores.qt/AbstractClientModel.hpp"
29#include "ores.qt/ClientManager.hpp"
30#include "ores.qt/ColumnMetadata.hpp"
31#include "ores.qt/ImageCache.hpp"
32#include "ores.qt/RecencyPulseManager.hpp"
33#include "ores.qt/RecencyTracker.hpp"
34#include "ores.logging/make_logger.hpp"
35#include "ores.refdata.api/domain/business_centre.hpp"
49 inline static std::string_view logger_name =
50 "ores.qt.client_business_centre_model";
52 [[nodiscard]]
static auto& lg() {
54 static auto instance = make_logger(logger_name);
80 static constexpr std::size_t
kColumnCount = std::size_t(ColumnCount);
81 static constexpr std::array<ColumnMetadata, kColumnCount> kColumns = {{
83 .column = CountryAlpha2,
84 .header = std::string_view(
"Country"),
86 .hidden_by_default =
false,
91 .header = std::string_view(
"Code"),
93 .hidden_by_default =
false,
98 .header = std::string_view(
"City"),
100 .hidden_by_default =
false,
105 .header = std::string_view(
"Source"),
107 .hidden_by_default =
false,
111 .column = Description,
112 .header = std::string_view(
"Description"),
114 .hidden_by_default =
true,
118 .column = CodingScheme,
119 .header = std::string_view(
"Coding Scheme"),
121 .hidden_by_default =
true,
126 .header = std::string_view(
"Version"),
128 .hidden_by_default =
false,
132 .column = ModifiedBy,
133 .header = std::string_view(
"Modified By"),
135 .hidden_by_default =
false,
139 .column = RecordedAt,
140 .header = std::string_view(
"Recorded At"),
142 .hidden_by_default =
false,
161 static std::vector<column_style>
const kStylesVector = []() {
162 std::vector<column_style> result;
165 result.push_back(kColumns[i].style);
168 return kStylesVector;
175 static QVector<int>
const result =
176 ::ores::qt::defaultHiddenColumns<kColumnCount>(kColumns);
182 QObject* parent =
nullptr);
186 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
187 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
188 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
189 QVariant headerData(
int section, Qt::Orientation orientation,
190 int role = Qt::DisplayRole)
const override;
200 void refresh(
bool replace =
true);
208 void load_page(std::uint32_t offset, std::uint32_t limit);
218 std::uint32_t page_size()
const {
return page_size_; }
219 void set_page_size(std::uint32_t size);
220 std::uint32_t total_available_count()
const {
return total_available_count_; }
232 void onBusinessCentresLoaded();
233 void onPulseStateChanged(
bool isOn);
234 void onPulsingComplete();
237 QVariant recency_foreground_color(
const std::string& code)
const;
241 std::vector<refdata::domain::business_centre> business_centres;
242 std::uint32_t total_available_count;
243 QString error_message;
244 QString error_details;
247 void fetch_business_centres(std::uint32_t offset, std::uint32_t limit);
249 ClientManager* clientManager_;
250 ImageCache* imageCache_;
251 std::vector<refdata::domain::business_centre> business_centres_;
252 QFutureWatcher<FetchResult>* watcher_;
253 std::uint32_t page_size_{100};
254 std::uint32_t total_available_count_{0};
255 bool is_fetching_{
false};
258 RecencyTracker<refdata::domain::business_centre, BusinessCentreKeyExtractor> recencyTracker_;
259 RecencyPulseManager* pulseManager_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
constexpr int kColumnWidthAuto
Sentinel value for column default width meaning "auto-size to contents".
Definition ColumnMetadata.hpp:37
@ mono_center
Monospace, centered.
@ text_left
Proportional font, left-aligned (default).
@ mono_bold_left
Monospace bold, left-aligned.
@ mono_bold_center
Monospace bold, centered.
@ mono_left
Monospace, left-aligned.
Base class for all client-side entity models.
Definition AbstractClientModel.hpp:36
Model for displaying business centres fetched from the server.
Definition ClientBusinessCentreModel.hpp:45
static constexpr std::string_view kSettingsGroup
Settings group name for persisting window and column state.
Definition ClientBusinessCentreModel.hpp:155
static constexpr std::size_t kColumnCount
Column metadata: header text, style, visibility, and width.
Definition ClientBusinessCentreModel.hpp:80
static const QSize kDefaultWindowSize
Default window size for the tenant list window.
Definition ClientBusinessCentreModel.hpp:150
static std::vector< column_style > const & columnStyles()
Returns a static vector of column styles (built once per process).
Definition ClientBusinessCentreModel.hpp:160
static QVector< int > defaultHiddenColumns()
Returns a static QVector of hidden column indices (built once per process).
Definition ClientBusinessCentreModel.hpp:174
void refresh(bool replace=true)
Refresh business centre data from server asynchronously.
Definition ClientBusinessCentreModel.cpp:174
void load_page(std::uint32_t offset, std::uint32_t limit)
Load a specific page of business centre data.
Definition ClientBusinessCentreModel.cpp:200
const refdata::domain::business_centre * getBusinessCentre(int row) const
Get business centre at the specified row.
Definition ClientBusinessCentreModel.cpp:308
Column
Enumeration of table columns for type-safe column access.
Definition ClientBusinessCentreModel.hpp:62
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:53
Represents a business centre using FpML-style codes.
Definition business_centre.hpp:37