20#ifndef ORES_QT_CLIENT_COUNTRY_MODEL_HPP
21#define ORES_QT_CLIENT_COUNTRY_MODEL_HPP
24#include <QFutureWatcher>
25#include <QAbstractTableModel>
26#include "ores.qt/ClientManager.hpp"
27#include "ores.qt/RecencyPulseManager.hpp"
28#include "ores.qt/RecencyTracker.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.refdata/domain/country.hpp"
46 inline static std::string_view logger_name =
47 "ores.qt.client_country_model";
49 [[nodiscard]]
static auto& lg() {
51 static auto instance = make_logger(logger_name);
74 QObject* parent =
nullptr);
78 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
79 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
80 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
81 QVariant headerData(
int section, Qt::Orientation orientation,
82 int role = Qt::DisplayRole)
const override;
89 void refresh(
bool replace =
true);
97 void load_page(std::uint32_t offset, std::uint32_t limit);
102 bool canFetchMore(
const QModelIndex& parent = QModelIndex())
const override;
107 void fetchMore(
const QModelIndex& parent = QModelIndex())
override;
122 std::vector<refdata::domain::country>
getCountries()
const;
150 void loadError(
const QString& error_message,
const QString& details = {});
153 void onCountriesLoaded();
154 void onPulseStateChanged(
bool isOn);
155 void onPulsingComplete();
158 QVariant recency_foreground_color(
const std::string& alpha2_code)
const;
162 std::vector<refdata::domain::country> countries;
163 std::uint32_t total_available_count;
164 QString error_message;
165 QString error_details;
168 void fetch_countries(std::uint32_t offset, std::uint32_t limit);
170 ClientManager* clientManager_;
171 ImageCache* imageCache_;
172 std::vector<refdata::domain::country> countries_;
173 QFutureWatcher<FetchResult>* watcher_;
174 std::uint32_t page_size_{100};
175 std::uint32_t total_available_count_{0};
176 bool is_fetching_{
false};
180 RecencyTracker<refdata::domain::country, CountryKeyExtractor> recencyTracker_;
181 RecencyPulseManager* pulseManager_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Model for displaying countries fetched from the server.
Definition ClientCountryModel.hpp:42
bool canFetchMore(const QModelIndex &parent=QModelIndex()) const override
Check if more data can be fetched from the server.
Definition ClientCountryModel.cpp:332
void fetchMore(const QModelIndex &parent=QModelIndex()) override
Fetch the next page of data from the server.
Definition ClientCountryModel.cpp:348
void set_page_size(std::uint32_t size)
Set the page size for pagination.
Definition ClientCountryModel.cpp:356
std::uint32_t total_available_count() const
Get the total number of records available on the server.
Definition ClientCountryModel.hpp:139
std::vector< refdata::domain::country > getCountries() const
Get all countries.
Definition ClientCountryModel.cpp:328
void dataLoaded()
Emitted when data has been successfully loaded.
const refdata::domain::country * getCountry(int row) const
Get country at the specified row.
Definition ClientCountryModel.cpp:321
void refresh(bool replace=true)
Refresh country data from server asynchronously.
Definition ClientCountryModel.cpp:161
void load_page(std::uint32_t offset, std::uint32_t limit)
Load a specific page of country data.
Definition ClientCountryModel.cpp:190
void loadError(const QString &error_message, const QString &details={})
Emitted when an error occurs during data loading.
std::uint32_t page_size() const
Get the page size used for pagination.
Definition ClientCountryModel.hpp:127
Column
Enumeration of table columns for type-safe column access.
Definition ClientCountryModel.hpp:59
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:52
Represents a country using ISO 3166-1 standard codes.
Definition country.hpp:33