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/ClientManager.hpp"
28#include "ores.qt/RecencyPulseManager.hpp"
29#include "ores.qt/RecencyTracker.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.iam/domain/account.hpp"
32#include "ores.iam/domain/login_info.hpp"
59 std::optional<iam::domain::login_info> loginInfo;
72 inline static std::string_view logger_name =
73 "ores.qt.client_account_model";
75 [[nodiscard]]
static auto& lg() {
77 static auto instance = make_logger(logger_name);
83 QObject* parent =
nullptr);
87 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
88 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
89 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
90 QVariant headerData(
int section, Qt::Orientation orientation,
91 int role = Qt::DisplayRole)
const override;
103 void refresh(
bool replace =
true);
114 void load_page(std::uint32_t offset, std::uint32_t limit);
121 bool canFetchMore(
const QModelIndex& parent = QModelIndex())
const override;
129 void fetchMore(
const QModelIndex& parent = QModelIndex())
override;
184 void loadError(
const QString& error_message,
const QString& details = {});
187 void onAccountsLoaded();
188 void onPulseStateChanged(
bool isOn);
189 void onPulsingComplete();
201 QVariant recency_foreground_color(
const std::string& username)
const;
228 const std::optional<iam::domain::login_info>& loginInfo);
232 std::vector<iam::domain::account> accounts;
233 std::vector<iam::domain::login_info> loginInfos;
234 std::uint32_t total_available_count;
235 QString error_message;
236 QString error_details;
239 using FutureWatcherResult = FetchResult;
241 ClientManager* clientManager_;
242 std::vector<AccountWithLoginInfo> accounts_;
243 QFutureWatcher<FutureWatcherResult>* watcher_;
244 std::uint32_t page_size_{100};
245 std::uint32_t total_available_count_{0};
246 bool is_fetching_{
false};
250 RecencyTracker<iam::domain::account, AccountKeyExtractor> recencyTracker_;
251 RecencyPulseManager* pulseManager_;
256 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:35
LoginStatus
Enum representing account login status buckets.
Definition ClientAccountModel.hpp:42
Represents an account for an entity in the system.
Definition account.hpp:32
Composite structure combining account with its login status.
Definition ClientAccountModel.hpp:57
Model for displaying accounts fetched from the server via client.
Definition ClientAccountModel.hpp:68
bool canFetchMore(const QModelIndex &parent=QModelIndex()) const override
Check if more data can be fetched from the server.
Definition ClientAccountModel.cpp:377
void fetchMore(const QModelIndex &parent=QModelIndex()) override
Fetch the next page of data from the server.
Definition ClientAccountModel.cpp:389
std::vector< AccountWithLoginInfo > getAccountsWithLoginInfo() const
Get all accounts with their login info.
Definition ClientAccountModel.cpp:373
void set_page_size(std::uint32_t size)
Set the page size for pagination.
Definition ClientAccountModel.cpp:397
std::uint32_t total_available_count() const
Get the total number of records available on the server.
Definition ClientAccountModel.hpp:173
const AccountWithLoginInfo * getAccountWithLoginInfo(int row) const
Get account with login info at the specified row.
Definition ClientAccountModel.cpp:359
void dataLoaded()
Emitted when data has been successfully loaded.
const iam::domain::account * getAccount(int row) const
Get account at the specified row (for backward compatibility).
Definition ClientAccountModel.cpp:366
void refresh(bool replace=true)
Refresh account data from server asynchronously.
Definition ClientAccountModel.cpp:147
void load_page(std::uint32_t offset, std::uint32_t limit)
Load a specific page of account data.
Definition ClientAccountModel.cpp:179
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 ClientAccountModel.hpp:159
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90