ORE Studio 0.0.4
Loading...
Searching...
No Matches
InstrumentDetailDialog.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_DETAIL_DIALOG_HPP
21#define ORES_QT_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/instrument.hpp"
27
28namespace Ui {
29class InstrumentDetailDialog;
30}
31
32namespace ores::qt {
33
42 Q_OBJECT
43
44private:
45 inline static std::string_view logger_name =
46 "ores.qt.instrument_detail_dialog";
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 InstrumentDetailDialog(QWidget* parent = nullptr);
56 ~InstrumentDetailDialog() override;
57
58 void setClientManager(ClientManager* clientManager);
59 void setUsername(const std::string& username);
60 void setInstrument(const trading::domain::instrument& v);
61 void setCreateMode(bool createMode);
62 void setReadOnly(bool readOnly);
63
64signals:
65 void instrumentSaved(const QString& id);
66 void instrumentDeleted(const QString& id);
67
68private slots:
69 void onSaveClicked();
70 void onDeleteClicked();
71 void onFieldChanged();
72
73protected:
74 QTabWidget* tabWidget() const override;
75 QWidget* provenanceTab() const override;
76 ProvenanceWidget* provenanceWidget() const override;
77 bool hasUnsavedChanges() const override { return hasChanges_; }
78
79private:
80 void setupUi();
81 void setupConnections();
82 void updateUiFromInstrument();
83 void updateInstrumentFromUi();
84 void updateSaveButtonState();
85 bool validateInput();
86
87 Ui::InstrumentDetailDialog* ui_;
88 ClientManager* clientManager_;
89 std::string username_;
91 bool createMode_{true};
92 bool readOnly_{false};
93 bool hasChanges_{false};
94};
95
96}
97
98#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
Detail dialog for viewing and editing instrument records.
Definition InstrumentDetailDialog.hpp:41
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition InstrumentDetailDialog.cpp:59
bool hasUnsavedChanges() const override
Definition InstrumentDetailDialog.hpp:77
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition InstrumentDetailDialog.cpp:51
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition InstrumentDetailDialog.cpp:55
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39
Parent instrument record holding economic terms for a trade.
Definition instrument.hpp:40