20#ifndef ORES_QT_CLIENT_TENANT_MODEL_HPP
21#define ORES_QT_CLIENT_TENANT_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.qt/ColumnMetadata.hpp"
32#include "ores.logging/make_logger.hpp"
33#include "ores.iam.api/domain/tenant.hpp"
47 inline static std::string_view logger_name =
48 "ores.qt.client_tenant_model";
50 [[nodiscard]]
static auto& lg() {
52 static auto instance = make_logger(logger_name);
77 static constexpr std::size_t
kColumnCount = std::size_t(ColumnCount);
78 static constexpr std::array<ColumnMetadata, kColumnCount> kColumns = {{
81 .header = std::string_view(
"Code"),
83 .hidden_by_default =
false,
88 .header = std::string_view(
"Name"),
90 .hidden_by_default =
false,
95 .header = std::string_view(
"Type"),
97 .hidden_by_default =
false,
102 .header = std::string_view(
"Hostname"),
104 .hidden_by_default =
false,
109 .header = std::string_view(
"Status"),
111 .hidden_by_default =
false,
116 .header = std::string_view(
"Version"),
118 .hidden_by_default =
false,
122 .column = ModifiedBy,
123 .header = std::string_view(
"Modified By"),
125 .hidden_by_default =
false,
129 .column = RecordedAt,
130 .header = std::string_view(
"Recorded At"),
132 .hidden_by_default =
false,
151 static std::vector<column_style>
const kStylesVector = []() {
152 std::vector<column_style> result;
155 result.push_back(kColumns[i].style);
158 return kStylesVector;
165 static QVector<int>
const result =
166 ::ores::qt::defaultHiddenColumns<kColumnCount>(kColumns);
171 QObject* parent =
nullptr);
175 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
176 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
177 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
178 QVariant headerData(
int section, Qt::Orientation orientation,
179 int role = Qt::DisplayRole)
const override;
204 void onTenantsLoaded();
205 void onPulseStateChanged(
bool isOn);
206 void onPulsingComplete();
209 QVariant recency_foreground_color(
const std::string& code)
const;
213 std::vector<iam::domain::tenant> tenants;
214 QString error_message;
215 QString error_details;
218 ClientManager* clientManager_;
219 std::vector<iam::domain::tenant> tenants_;
220 QFutureWatcher<FetchResult>* watcher_;
221 bool is_fetching_{
false};
224 RecencyTracker<iam::domain::tenant, TenantKeyExtractor> recencyTracker_;
225 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_left
Monospace, left-aligned.
A tenant representing an isolated organisation or the system platform.
Definition tenant.hpp:43
Base class for all client-side entity models.
Definition AbstractClientModel.hpp:36
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Model for displaying tenants fetched from the server.
Definition ClientTenantModel.hpp:43
static constexpr std::string_view kSettingsGroup
Settings group name for persisting window and column state.
Definition ClientTenantModel.hpp:145
const iam::domain::tenant * getTenant(int row) const
Get tenant at the specified row.
Definition ClientTenantModel.cpp:206
static constexpr std::size_t kColumnCount
Column metadata: header text, style, visibility, and width.
Definition ClientTenantModel.hpp:77
static const QSize kDefaultWindowSize
Default window size for the tenant list window.
Definition ClientTenantModel.hpp:140
static std::vector< column_style > const & columnStyles()
Returns a static vector of column styles (built once per process).
Definition ClientTenantModel.hpp:150
void refresh()
Refresh tenant data from server asynchronously.
Definition ClientTenantModel.cpp:135
static QVector< int > defaultHiddenColumns()
Returns a static QVector of hidden column indices (built once per process).
Definition ClientTenantModel.hpp:164
Column
Enumeration of table columns for type-safe column access.
Definition ClientTenantModel.hpp:60