ORE Studio 0.0.4
Loading...
Searching...
No Matches
FxAccumulatorInstrumentForm.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_FX_ACCUMULATOR_INSTRUMENT_FORM_HPP
21#define ORES_QT_FX_ACCUMULATOR_INSTRUMENT_FORM_HPP
22
23#include "ores.qt/IInstrumentForm.hpp"
24#include "ores.logging/make_logger.hpp"
25#include "ores.trading.api/domain/fx_accumulator_instrument.hpp"
26
27namespace Ui {
28class FxAccumulatorInstrumentForm;
29}
30
31namespace ores::qt {
32
39 Q_OBJECT
40
41private:
42 inline static std::string_view logger_name =
43 "ores.qt.fx_accumulator_instrument_form";
44
45 [[nodiscard]] static auto& lg() {
46 using namespace ores::logging;
47 static auto instance = make_logger(logger_name);
48 return instance;
49 }
50
51public:
52 explicit FxAccumulatorInstrumentForm(QWidget* parent = nullptr);
54
55 void setClientManager(ClientManager* cm) override;
56 void setUsername(const std::string& username) override;
57 void setImageCache(ImageCache* cache) override;
58
59 void setInstrument(
60 const trading::domain::trade_instrument& instrument) override;
61 void clear() override;
62
63 void setTradeType(const QString& code,
64 bool has_options, bool has_extension) override;
65
66 void setReadOnly(bool readOnly) override;
67 bool isDirty() const override;
68 bool isLoaded() const override;
69
70 void setChangeReason(
71 const std::string& code, const std::string& commentary) override;
72 void writeUiToInstrument() override;
73
74 void saveInstrument(
75 std::function<void(const std::string& id)> on_success,
76 std::function<void(const QString& error)> on_failure) override;
77
78private:
79 void setupConnections();
80 void populateCurrencies();
81 void populateFromInstrument();
82 void emitProvenance();
83 void onFieldChanged();
84
85 Ui::FxAccumulatorInstrumentForm* ui_;
86 ClientManager* clientManager_ = nullptr;
87 ImageCache* imageCache_ = nullptr;
88 std::string username_;
90 bool dirty_ = false;
91 bool loaded_ = false;
92};
93
94}
95
96#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:54
IInstrumentForm for FX Accumulator trades.
Definition FxAccumulatorInstrumentForm.hpp:38
void saveInstrument(std::function< void(const std::string &id)> on_success, std::function< void(const QString &error)> on_failure) override
Save the in-flight instrument via the family's NATS request.
Definition FxAccumulatorInstrumentForm.cpp:245
bool isLoaded() const override
True after the asynchronous load has populated the form.
Definition FxAccumulatorInstrumentForm.cpp:140
void setInstrument(const trading::domain::trade_instrument &instrument) override
Populate the form with the already-resolved instrument.
Definition FxAccumulatorInstrumentForm.cpp:169
void writeUiToInstrument() override
Pull the current UI values into the in-flight domain object.
Definition FxAccumulatorInstrumentForm.cpp:148
void setImageCache(ImageCache *cache) override
Inject the image cache for flag icons on currency combo boxes.
Definition FxAccumulatorInstrumentForm.cpp:75
void setUsername(const std::string &username) override
Inject the username stamped on every saved instrument.
Definition FxAccumulatorInstrumentForm.cpp:109
void setTradeType(const QString &code, bool has_options, bool has_extension) override
Inform the form which trade type is currently selected.
Definition FxAccumulatorInstrumentForm.cpp:122
void setChangeReason(const std::string &code, const std::string &commentary) override
Stamp the change reason on the in-flight instrument before the dialog calls saveInstrument.
Definition FxAccumulatorInstrumentForm.cpp:142
void setReadOnly(bool readOnly) override
Toggle read-only on every editable widget.
Definition FxAccumulatorInstrumentForm.cpp:128
void setClientManager(ClientManager *cm) override
Inject the NATS client used for load and save round-trips.
Definition FxAccumulatorInstrumentForm.cpp:70
bool isDirty() const override
Has the user edited any field since the last load or save?
Definition FxAccumulatorInstrumentForm.cpp:139
void clear() override
Reset the form to a blank state ready for create mode.
Definition FxAccumulatorInstrumentForm.cpp:113
Pure-virtual interface implemented by every per-family instrument form widget hosted in TradeDetailDi...
Definition IInstrumentForm.hpp:73
FX Accumulator instrument.
Definition fx_accumulator_instrument.hpp:38