ORE Studio 0.0.4
Loading...
Searching...
No Matches
ClientMarketSeriesModel.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_QT_CLIENT_MARKET_SERIES_MODEL_HPP
21#define ORES_QT_CLIENT_MARKET_SERIES_MODEL_HPP
22
23#include <vector>
24#include <string>
25#include <QSize>
26#include <QFutureWatcher>
27#include "ores.qt/AbstractClientModel.hpp"
28#include "ores.qt/ClientManager.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.marketdata.api/domain/market_series.hpp"
31
32namespace ores::qt {
33
38 Q_OBJECT
39
40private:
41 inline static std::string_view logger_name =
42 "ores.qt.client_market_series_model";
43
44 [[nodiscard]] static auto& lg() {
45 using namespace ores::logging;
46 static auto instance = make_logger(logger_name);
47 return instance;
48 }
49
50public:
51 enum Column {
52 SeriesType,
53 Metric,
54 Qualifier,
55 AssetClass,
56 Subclass,
57 IsScalar,
58 Version,
59 ModifiedBy,
60 RecordedAt,
61 ColumnCount
62 };
63
64 inline static const QSize kDefaultWindowSize = {1100, 600};
65 static constexpr std::string_view kSettingsGroup = "MarketSeriesListWindow";
66
67 explicit ClientMarketSeriesModel(ClientManager* clientManager,
68 QObject* parent = nullptr);
69 ~ClientMarketSeriesModel() override = default;
70
71 int rowCount(const QModelIndex& parent = QModelIndex()) const override;
72 int columnCount(const QModelIndex& parent = QModelIndex()) const override;
73 QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
74 QVariant headerData(int section, Qt::Orientation orientation,
75 int role = Qt::DisplayRole) const override;
76
77 void refresh(bool replace = true);
78 void load_page(std::uint32_t offset, std::uint32_t limit);
79 void set_series_type_filter(const std::string& series_type);
80
81 const marketdata::domain::market_series* getSeries(int row) const;
82 std::uint32_t total_available_count() const { return total_available_count_; }
83 std::uint32_t page_size() const { return page_size_; }
84 void set_page_size(std::uint32_t size);
85
86private slots:
87 void onDataLoaded();
88
89private:
90 struct FetchResult {
91 bool success;
92 std::vector<marketdata::domain::market_series> entries;
93 std::uint32_t total_available_count;
94 QString error_message;
95 QString error_details;
96 };
97
98 void fetch_data(std::uint32_t offset, std::uint32_t limit);
99
100 ClientManager* clientManager_;
101 std::vector<marketdata::domain::market_series> entries_;
102 QFutureWatcher<FetchResult>* watcher_;
103 std::string series_type_filter_;
104 std::uint32_t page_size_{500};
105 std::uint32_t total_available_count_{0};
106 bool is_fetching_{false};
107};
108
109}
110
111#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Catalog entry for a market data series.
Definition market_series.hpp:44
Base class for all client-side entity models.
Definition AbstractClientModel.hpp:37
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Qt table model for market series fetched from the market data service.
Definition ClientMarketSeriesModel.hpp:37