ORE Studio 0.0.4
Loading...
Searching...
No Matches
TradeDetailDialog.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_TRADE_DETAIL_DIALOG_HPP
21#define ORES_QT_TRADE_DETAIL_DIALOG_HPP
22
23#include <vector>
24#include <QTabWidget>
25#include "ores.qt/ClientManager.hpp"
26#include "ores.qt/DetailDialogBase.hpp"
27#include "ores.qt/ProvenanceWidget.hpp"
28#include "ores.logging/make_logger.hpp"
29#include "ores.trading.api/domain/trade.hpp"
30#include "ores.refdata.api/domain/book.hpp"
31#include "ores.refdata.api/domain/counterparty.hpp"
32
33namespace Ui {
34class TradeDetailDialog;
35}
36
37namespace ores::qt {
38
46class TradeDetailDialog final : public DetailDialogBase {
47 Q_OBJECT
48
49private:
50 inline static std::string_view logger_name =
51 "ores.qt.trade_detail_dialog";
52
53 [[nodiscard]] static auto& lg() {
54 using namespace ores::logging;
55 static auto instance = make_logger(logger_name);
56 return instance;
57 }
58
59public:
60 explicit TradeDetailDialog(QWidget* parent = nullptr);
61 ~TradeDetailDialog() override;
62
63 void setClientManager(ClientManager* clientManager);
64 void setUsername(const std::string& username);
65 void setTrade(const trading::domain::trade& trade);
66 void setCreateMode(bool createMode);
67 void setReadOnly(bool readOnly);
68
69protected:
70 QTabWidget* tabWidget() const override;
71 QWidget* provenanceTab() const override;
72 ProvenanceWidget* provenanceWidget() const override;
73 bool hasUnsavedChanges() const override { return hasChanges_; }
74
75signals:
76 void tradeSaved(const QString& code);
77 void tradeDeleted(const QString& code);
78
79private slots:
80 void onSaveClicked();
81 void onDeleteClicked();
82 void onCodeChanged(const QString& text);
83 void onFieldChanged();
84
85private:
86 void setupUi();
87 void setupConnections();
88 void loadBooks();
89 void selectCurrentBook();
90 void loadCounterparties();
91 void selectCurrentCounterparty();
92 void updateUiFromTrade();
93 void updateTradeFromUi();
94 void updateSaveButtonState();
95 bool validateInput();
96
97 Ui::TradeDetailDialog* ui_;
98 ClientManager* clientManager_;
99 std::string username_;
101 std::vector<refdata::domain::book> books_;
102 std::vector<refdata::domain::counterparty> counterparties_;
103 bool createMode_{true};
104 bool readOnly_{false};
105 bool hasChanges_{false};
106};
107
108}
109
110#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
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:74
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39
Detail dialog for viewing and editing trade records.
Definition TradeDetailDialog.hpp:46
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition TradeDetailDialog.cpp:59
bool hasUnsavedChanges() const override
Definition TradeDetailDialog.hpp:73
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition TradeDetailDialog.cpp:57
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition TradeDetailDialog.cpp:58
Trade capturing FpML Trade Header properties.
Definition trade.hpp:38