20#ifndef ORES_QT_CLIENT_SUBJECT_AREA_MODEL_HPP
21#define ORES_QT_CLIENT_SUBJECT_AREA_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/subject_area.hpp"
37class ClientSubjectAreaModel final :
public AbstractClientModel {
41 inline static std::string_view logger_name =
42 "ores.qt.client_subject_area_model";
44 [[nodiscard]]
static auto& lg() {
46 static auto instance = make_logger(logger_name);
66 static constexpr std::size_t kColumnCount = std::size_t(ColumnCount);
67 static constexpr std::array<ColumnMetadata, kColumnCount> kColumns = {{
70 .header = std::string_view(
"Name"),
72 .hidden_by_default =
false,
77 .header = std::string_view(
"Domain Name"),
79 .hidden_by_default =
false,
83 .column = Description,
84 .header = std::string_view(
"Description"),
86 .hidden_by_default =
false,
91 .header = std::string_view(
"Version"),
93 .hidden_by_default =
false,
98 .header = std::string_view(
"Modified By"),
100 .hidden_by_default =
false,
104 .column = RecordedAt,
105 .header = std::string_view(
"Recorded At"),
107 .hidden_by_default =
false,
115 inline static const QSize kDefaultWindowSize = {900, 400};
120 static constexpr std::string_view kSettingsGroup =
"SubjectAreaMdiWindow";
124 static std::vector<column_style>
const& columnStyles() {
125 static std::vector<column_style>
const kStylesVector = []() {
126 std::vector<column_style> result;
127 result.reserve(kColumnCount);
128 for (std::size_t i = 0; i < kColumnCount; ++i)
129 result.push_back(kColumns[i].style);
132 return kStylesVector;
139 static QVector<int>
const result =
140 ::ores::qt::defaultHiddenColumns<kColumnCount>(kColumns);
144 explicit ClientSubjectAreaModel(ClientManager* clientManager,
145 QObject* parent =
nullptr);
146 ~ClientSubjectAreaModel()
override =
default;
148 int rowCount(
const QModelIndex& parent = QModelIndex())
const override;
149 int columnCount(
const QModelIndex& parent = QModelIndex())
const override;
150 QVariant data(
const QModelIndex& index,
int role = Qt::DisplayRole)
const override;
151 QVariant headerData(
int section, Qt::Orientation orientation,
152 int role = Qt::DisplayRole)
const override;
160 void onSubjectAreasLoaded();
161 void onPulseStateChanged(
bool isOn);
162 void onPulsingComplete();
165 QVariant recency_foreground_color(
const std::string& key)
const;
169 std::vector<dq::domain::subject_area> subject_areas;
170 QString error_message;
171 QString error_details;
174 ClientManager* clientManager_;
175 std::vector<dq::domain::subject_area> subject_areas_;
176 QFutureWatcher<FetchResult>* watcher_;
177 bool is_fetching_{
false};
180 RecencyTracker<dq::domain::subject_area, SubjectAreaKeyExtractor> recencyTracker_;
181 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.
Represents a subdivision within a data domain.
Definition subject_area.hpp:39