20#ifndef ORES_QT_CLIENT_CODING_SCHEME_MODEL_HPP
21#define ORES_QT_CLIENT_CODING_SCHEME_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.dq.api/domain/coding_scheme.hpp"
37class ClientCodingSchemeModel final :
public AbstractClientModel {
41 inline static std::string_view logger_name =
42 "ores.qt.client_coding_scheme_model";
44 [[nodiscard]]
static auto& lg() {
46 static auto instance = make_logger(logger_name);
69 static constexpr std::size_t kColumnCount = std::size_t(ColumnCount);
70 static constexpr std::array<ColumnMetadata, kColumnCount> kColumns = {{
73 .header = std::string_view(
"Code"),
75 .hidden_by_default =
false,
80 .header = std::string_view(
"Name"),
82 .hidden_by_default =
false,
86 .column = AuthorityType,
87 .header = std::string_view(
"Authority Type"),
89 .hidden_by_default =
false,
93 .column = SubjectArea,
94 .header = std::string_view(
"Subject Area"),
96 .hidden_by_default =
false,
101 .header = std::string_view(
"Domain"),
103 .hidden_by_default =
false,
107 .column = Description,
108 .header = std::string_view(
"Description"),
110 .hidden_by_default =
false,
115 .header = std::string_view(
"Version"),
117 .hidden_by_default =
false,
121 .column = ModifiedBy,
122 .header = std::string_view(
"Modified By"),
124 .hidden_by_default =
false,
128 .column = RecordedAt,
129 .header = std::string_view(
"Recorded At"),
131 .hidden_by_default =
false,
139 inline static const QSize kDefaultWindowSize = {900, 400};
144 static constexpr std::string_view kSettingsGroup =
"CodingSchemeMdiWindow";
148 static std::vector<column_style>
const& columnStyles() {
149 static std::vector<column_style>
const kStylesVector = []() {
150 std::vector<column_style> result;
151 result.reserve(kColumnCount);
152 for (std::size_t i = 0; i < kColumnCount; ++i)
153 result.push_back(kColumns[i].style);
156 return kStylesVector;
163 static QVector<int>
const result =
164 ::ores::qt::defaultHiddenColumns<kColumnCount>(kColumns);
168 explicit ClientCodingSchemeModel(ClientManager* clientManager,
169 QObject* parent =
nullptr);
170 ~ClientCodingSchemeModel()
override =
default;
172 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
173 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
174 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
175 QVariant headerData(
int section, Qt::Orientation orientation,
176 int role = Qt::DisplayRole)
const override;
184 void onSchemesLoaded();
185 void onPulseStateChanged(
bool isOn);
186 void onPulsingComplete();
189 QVariant recency_foreground_color(
const std::string& code)
const;
193 std::vector<dq::domain::coding_scheme> schemes;
194 QString error_message;
195 QString error_details;
198 ClientManager* clientManager_;
199 std::vector<dq::domain::coding_scheme> schemes_;
200 QFutureWatcher<FetchResult>* watcher_;
201 bool is_fetching_{
false};
204 RecencyTracker<dq::domain::coding_scheme, CodingSchemeKeyExtractor> recencyTracker_;
205 RecencyPulseManager* pulseManager_;
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
QVector< int > defaultHiddenColumns(const std::array< ColumnMetadata, N > &columns)
Builds a QVector of hidden column indices from a metadata array.
Definition ColumnMetadata.hpp:99
constexpr int kColumnWidthAuto
Sentinel value for column default width meaning "auto-size to contents".
Definition ColumnMetadata.hpp:38
@ mono_center
Monospace, centered.
@ text_left
Proportional font, left-aligned (default).
@ mono_left
Monospace, left-aligned.
Defines a coding or identification standard used to identify entities.
Definition coding_scheme.hpp:36