ORE Studio 0.0.4
Loading...
Searching...
No Matches
InstrumentMdiWindow.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_INSTRUMENT_MDI_WINDOW_HPP
21#define ORES_QT_INSTRUMENT_MDI_WINDOW_HPP
22
23#include <QToolBar>
24#include <QTableView>
25#include <QSortFilterProxyModel>
26#include "ores.qt/EntityListMdiWindow.hpp"
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/ClientInstrumentModel.hpp"
29#include "ores.qt/PaginationWidget.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.trading.api/domain/instrument.hpp"
32
33namespace ores::qt {
34
42 Q_OBJECT
43
44private:
45 inline static std::string_view logger_name =
46 "ores.qt.instrument_mdi_window";
47
48 [[nodiscard]] static auto& lg() {
49 using namespace ores::logging;
50 static auto instance = make_logger(logger_name);
51 return instance;
52 }
53
54public:
55 explicit InstrumentMdiWindow(
56 ClientManager* clientManager,
57 QString username,
58 QWidget* parent = nullptr);
59 ~InstrumentMdiWindow() override = default;
60
61public slots:
62 void doReload() override;
63
64signals:
65 void statusChanged(const QString& message);
66 void errorOccurred(const QString& error_message);
67 void showInstrumentDetails(const trading::domain::instrument& v);
68 void addNewRequested();
69 void instrumentDeleted(const QString& id);
70 void showInstrumentHistory(const trading::domain::instrument& v);
71
72public slots:
73 void addNew();
74 void editSelected();
75 void deleteSelected();
76 void viewHistorySelected();
77
78private slots:
79 void onDataLoaded();
80 void onLoadError(const QString& error_message, const QString& details = {});
81 void onSelectionChanged();
82 void onDoubleClicked(const QModelIndex& index);
83
84protected:
85 QString normalRefreshTooltip() const override {
86 return tr("Refresh instruments");
87 }
88
89private:
90 void setupUi();
91 void setupToolbar();
92 void setupTable();
93 void setupConnections();
94 void updateActionStates();
95
96 ClientManager* clientManager_;
97 QString username_;
98
99 QToolBar* toolbar_;
100 QTableView* tableView_;
101 ClientInstrumentModel* model_;
102 QSortFilterProxyModel* proxyModel_;
103 PaginationWidget* paginationWidget_;
104
105 // Toolbar actions
106 QAction* reloadAction_;
107 QAction* addAction_;
108 QAction* editAction_;
109 QAction* deleteAction_;
110 QAction* historyAction_;
111};
112
113}
114
115#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Model for displaying instruments fetched from the server.
Definition ClientInstrumentModel.hpp:40
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:62
MDI window for displaying and managing instruments.
Definition InstrumentMdiWindow.hpp:41
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition InstrumentMdiWindow.hpp:85
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:39
Parent instrument record holding economic terms for a trade.
Definition instrument.hpp:40