20#ifndef ORES_QT_CLIENT_TENANT_TYPE_MODEL_HPP
21#define ORES_QT_CLIENT_TENANT_TYPE_MODEL_HPP
25#include <QFutureWatcher>
26#include <QAbstractTableModel>
27#include "ores.qt/AbstractClientModel.hpp"
28#include "ores.qt/ClientManager.hpp"
29#include "ores.qt/ColumnMetadata.hpp"
30#include "ores.qt/RecencyPulseManager.hpp"
31#include "ores.qt/RecencyTracker.hpp"
32#include "ores.logging/make_logger.hpp"
33#include "ores.iam.api/domain/tenant_type.hpp"
47 inline static std::string_view logger_name =
48 "ores.qt.client_tenant_type_model";
50 [[nodiscard]]
static auto& lg() {
52 static auto instance = make_logger(logger_name);
76 static constexpr std::size_t
kColumnCount = std::size_t(ColumnCount);
77 static constexpr std::array<ColumnMetadata, kColumnCount> kColumns = {{
80 .header = std::string_view(
"Type"),
82 .hidden_by_default =
false,
87 .header = std::string_view(
"Name"),
89 .hidden_by_default =
false,
93 .column = Description,
94 .header = std::string_view(
"Description"),
96 .hidden_by_default =
false,
100 .column = DisplayOrder,
101 .header = std::string_view(
"Display Order"),
103 .hidden_by_default =
false,
108 .header = std::string_view(
"Version"),
110 .hidden_by_default =
false,
114 .column = ModifiedBy,
115 .header = std::string_view(
"Modified By"),
117 .hidden_by_default =
false,
121 .column = RecordedAt,
122 .header = std::string_view(
"Recorded At"),
124 .hidden_by_default =
false,
142 static std::vector<column_style>
const kStylesVector = []() {
143 std::vector<column_style> result;
146 result.push_back(kColumns[i].style);
149 return kStylesVector;
156 static QVector<int>
const result =
157 ::ores::qt::defaultHiddenColumns<kColumnCount>(kColumns);
162 QObject* parent =
nullptr);
166 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
167 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
168 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
169 QVariant headerData(
int section, Qt::Orientation orientation,
170 int role = Qt::DisplayRole)
const override;
195 void onTypesLoaded();
196 void onPulseStateChanged(
bool isOn);
197 void onPulsingComplete();
200 QVariant recency_foreground_color(
const std::string& code)
const;
204 std::vector<iam::domain::tenant_type> tenant_types;
205 QString error_message;
206 QString error_details;
209 ClientManager* clientManager_;
210 std::vector<iam::domain::tenant_type> tenant_types_;
211 QFutureWatcher<FetchResult>* watcher_;
212 bool is_fetching_{
false};
215 RecencyTracker<iam::domain::tenant_type, TenantTypeKeyExtractor> recencyTracker_;
216 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.
Classification of tenant types.
Definition tenant_type.hpp:38
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 tenant types fetched from the server.
Definition ClientTenantTypeModel.hpp:43
static constexpr std::string_view kSettingsGroup
Settings group name for persisting window and column state.
Definition ClientTenantTypeModel.hpp:137
static constexpr std::size_t kColumnCount
Column metadata: header text, style, visibility, and width.
Definition ClientTenantTypeModel.hpp:76
static const QSize kDefaultWindowSize
Default window size for the tenant type list window.
Definition ClientTenantTypeModel.hpp:132
static std::vector< column_style > const & columnStyles()
Returns a static vector of column styles (built once per process).
Definition ClientTenantTypeModel.hpp:141
void refresh()
Refresh tenant type data from server asynchronously.
Definition ClientTenantTypeModel.cpp:131
static QVector< int > defaultHiddenColumns()
Returns a static QVector of hidden column indices (built once per process).
Definition ClientTenantTypeModel.hpp:155
Column
Enumeration of table columns for type-safe column access.
Definition ClientTenantTypeModel.hpp:60
const iam::domain::tenant_type * getType(int row) const
Get tenant type at the specified row.
Definition ClientTenantTypeModel.cpp:202