20#ifndef ORES_QT_CLIENT_ACCOUNT_MODEL_HPP
21#define ORES_QT_CLIENT_ACCOUNT_MODEL_HPP
25#include <QFutureWatcher>
26#include <QAbstractTableModel>
27#include "ores.qt/AbstractClientModel.hpp"
28#include "ores.qt/ClientManager.hpp"
29#include "ores.qt/RecencyPulseManager.hpp"
30#include "ores.qt/RecencyTracker.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.iam.api/domain/account.hpp"
33#include "ores.iam.api/domain/account_party.hpp"
34#include "ores.iam.api/domain/login_info.hpp"
61 std::optional<iam::domain::login_info> loginInfo;
75 inline static std::string_view logger_name =
76 "ores.qt.client_account_model";
78 [[nodiscard]]
static auto& lg() {
80 static auto instance = make_logger(logger_name);
108 QObject* parent =
nullptr);
112 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
113 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
114 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
115 QVariant headerData(
int section, Qt::Orientation orientation,
116 int role = Qt::DisplayRole)
const override;
128 void refresh(
bool replace =
true);
139 void load_page(std::uint32_t offset, std::uint32_t limit);
195 void onAccountsLoaded();
196 void onPulseStateChanged(
bool isOn);
197 void onPulsingComplete();
209 QVariant recency_foreground_color(
const std::string& username)
const;
218 const std::optional<iam::domain::login_info>& loginInfo);
222 std::vector<iam::domain::account> accounts;
223 std::vector<iam::domain::login_info> loginInfos;
224 std::vector<iam::domain::account_party> accountParties;
225 std::uint32_t total_available_count;
226 QString error_message;
227 QString error_details;
230 using FutureWatcherResult = FetchResult;
232 ClientManager* clientManager_;
233 std::vector<AccountWithLoginInfo> accounts_;
234 QFutureWatcher<FutureWatcherResult>* watcher_;
235 std::uint32_t page_size_{100};
236 std::uint32_t total_available_count_{0};
237 bool is_fetching_{
false};
241 RecencyTracker<iam::domain::account, AccountKeyExtractor> recencyTracker_;
242 RecencyPulseManager* pulseManager_;
247 void fetch_accounts(std::uint32_t offset, std::uint32_t limit);
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
LoginStatus
Enum representing account login status buckets.
Definition ClientAccountModel.hpp:44
Represents an account for an entity in the system.
Definition account.hpp:34
Base class for all client-side entity models.
Definition AbstractClientModel.hpp:36
Composite structure combining account with its login status.
Definition ClientAccountModel.hpp:59
Model for displaying accounts fetched from the server via client.
Definition ClientAccountModel.hpp:71
std::vector< AccountWithLoginInfo > getAccountsWithLoginInfo() const
Get all accounts with their login info.
Definition ClientAccountModel.cpp:368
void set_page_size(std::uint32_t size)
Set the page size for pagination.
Definition ClientAccountModel.cpp:372
std::uint32_t total_available_count() const
Get the total number of records available on the server.
Definition ClientAccountModel.hpp:183
const AccountWithLoginInfo * getAccountWithLoginInfo(int row) const
Get account with login info at the specified row.
Definition ClientAccountModel.cpp:354
const iam::domain::account * getAccount(int row) const
Get account at the specified row (for backward compatibility).
Definition ClientAccountModel.cpp:361
void refresh(bool replace=true)
Refresh account data from server asynchronously.
Definition ClientAccountModel.cpp:150
void load_page(std::uint32_t offset, std::uint32_t limit)
Load a specific page of account data.
Definition ClientAccountModel.cpp:175
std::uint32_t page_size() const
Get the page size used for pagination.
Definition ClientAccountModel.hpp:169
Column
Enumeration of table columns for type-safe column access.
Definition ClientAccountModel.hpp:94
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109