ORE Studio 0.0.4
Loading...
Searching...
No Matches
CompositeInstrumentDetailDialog.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_COMPOSITE_INSTRUMENT_DETAIL_DIALOG_HPP
21#define ORES_QT_COMPOSITE_INSTRUMENT_DETAIL_DIALOG_HPP
22
23#include <vector>
24#include "ores.qt/ClientManager.hpp"
25#include "ores.qt/DetailDialogBase.hpp"
26#include "ores.logging/make_logger.hpp"
27#include "ores.trading.api/domain/composite_instrument.hpp"
28#include "ores.trading.api/domain/composite_leg.hpp"
29
30namespace Ui {
31class CompositeInstrumentDetailDialog;
32}
33
34namespace ores::qt {
35
40 Q_OBJECT
41
42private:
43 inline static std::string_view logger_name =
44 "ores.qt.composite_instrument_detail_dialog";
45
46 [[nodiscard]] static auto& lg() {
47 using namespace ores::logging;
48 static auto instance = make_logger(logger_name);
49 return instance;
50 }
51
52public:
53 explicit CompositeInstrumentDetailDialog(QWidget* parent = nullptr);
55
56 void setClientManager(ClientManager* clientManager);
57 void setUsername(const std::string& username);
58 void setCompositeInstrument(
60 void setLegs(
61 const std::vector<trading::domain::composite_leg>& legs);
62 void setCreateMode(bool createMode);
63 void setReadOnly(bool readOnly);
64
70 void loadLegs();
71
72signals:
73 void compositeInstrumentSaved(const QString& id);
74 void compositeInstrumentDeleted(const QString& id);
75
76private slots:
77 void onSaveClicked();
78 void onDeleteClicked();
79 void onFieldChanged();
80
81protected:
82 QTabWidget* tabWidget() const override;
83 QWidget* provenanceTab() const override;
84 ProvenanceWidget* provenanceWidget() const override;
85 bool hasUnsavedChanges() const override { return hasChanges_; }
86
87private:
88 void setupUi();
89 void setupConnections();
90 void updateUiFromCompositeInstrument();
91 void updateCompositeInstrumentFromUi();
92 void updateSaveButtonState();
93 bool validateInput();
94
95 Ui::CompositeInstrumentDetailDialog* ui_;
96 ClientManager* clientManager_;
97 std::string username_;
99 bool createMode_{true};
100 bool readOnly_{false};
101 bool hasChanges_{false};
102};
103
104}
105
106#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Detail dialog for viewing and editing composite instrument records.
Definition CompositeInstrumentDetailDialog.hpp:39
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition CompositeInstrumentDetailDialog.cpp:59
void loadLegs()
Asynchronously fetch legs from the server and populate the widget.
Definition CompositeInstrumentDetailDialog.cpp:118
bool hasUnsavedChanges() const override
Definition CompositeInstrumentDetailDialog.hpp:85
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition CompositeInstrumentDetailDialog.cpp:51
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition CompositeInstrumentDetailDialog.cpp:55
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:74
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39
Composite instrument economics for CompositeTrade and MultiLegOption ORE product types.
Definition composite_instrument.hpp:37