ORE Studio 0.0.4
Loading...
Searching...
No Matches
CreditInstrumentDetailDialog.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_CREDIT_INSTRUMENT_DETAIL_DIALOG_HPP
21#define ORES_QT_CREDIT_INSTRUMENT_DETAIL_DIALOG_HPP
22
23#include "ores.qt/ClientManager.hpp"
24#include "ores.qt/DetailDialogBase.hpp"
25#include "ores.logging/make_logger.hpp"
26#include "ores.trading.api/domain/credit_instrument.hpp"
27
28namespace Ui {
29class CreditInstrumentDetailDialog;
30}
31
32namespace ores::qt {
33
38 Q_OBJECT
39
40private:
41 inline static std::string_view logger_name =
42 "ores.qt.credit_instrument_detail_dialog";
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 explicit CreditInstrumentDetailDialog(QWidget* parent = nullptr);
53
54 void setClientManager(ClientManager* clientManager);
55 void setUsername(const std::string& username);
56 void setCreditInstrument(const trading::domain::credit_instrument& v);
57 void setCreateMode(bool createMode);
58 void setReadOnly(bool readOnly);
59
60signals:
61 void creditInstrumentSaved(const QString& id);
62 void creditInstrumentDeleted(const QString& id);
63
64private slots:
65 void onSaveClicked();
66 void onDeleteClicked();
67 void onFieldChanged();
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
75private:
76 void setupUi();
77 void setupConnections();
78 void updateUiFromCreditInstrument();
79 void updateCreditInstrumentFromUi();
80 void updateSaveButtonState();
81 bool validateInput();
82
83 Ui::CreditInstrumentDetailDialog* ui_;
84 ClientManager* clientManager_;
85 std::string username_;
87 bool createMode_{true};
88 bool readOnly_{false};
89 bool hasChanges_{false};
90};
91
92}
93
94#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 credit instrument records.
Definition CreditInstrumentDetailDialog.hpp:37
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition CreditInstrumentDetailDialog.cpp:59
bool hasUnsavedChanges() const override
Definition CreditInstrumentDetailDialog.hpp:73
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition CreditInstrumentDetailDialog.cpp:51
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition CreditInstrumentDetailDialog.cpp:55
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:74
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39
Credit instrument economics for CreditDefaultSwap, CDSIndex, SyntheticCDO, CreditDefaultSwapOption,...
Definition credit_instrument.hpp:39