ORE Studio 0.0.4
Loading...
Searching...
No Matches
IInstrumentForm.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_I_INSTRUMENT_FORM_HPP
21#define ORES_QT_I_INSTRUMENT_FORM_HPP
22
23#include <chrono>
24#include <functional>
25#include <string>
26#include <QString>
27#include <QWidget>
28#include "ores.trading.api/domain/trade_instrument.hpp"
29
30namespace ores::qt {
31
32class ClientManager;
33class ImageCache;
34
40 int version = 0;
41 std::string modified_by;
42 std::string performed_by;
43 std::chrono::system_clock::time_point recorded_at;
44 std::string change_reason_code;
45 std::string change_commentary;
46};
47
73class IInstrumentForm : public QWidget {
74 Q_OBJECT
75public:
76 using QWidget::QWidget;
77 ~IInstrumentForm() override = default;
78
80 virtual void setClientManager(ClientManager* cm) = 0;
81
83 virtual void setUsername(const std::string& username) = 0;
84
86 virtual void setImageCache(ImageCache* /*cache*/) {}
87
98 virtual void setInstrument(
99 const trading::domain::trade_instrument& instrument) = 0;
100
102 virtual void clear() = 0;
103
114 virtual void setTradeType(const QString& code,
115 bool has_options, bool has_extension) = 0;
116
118 virtual void setReadOnly(bool readOnly) = 0;
119
121 virtual bool isDirty() const = 0;
122
124 virtual bool isLoaded() const = 0;
125
134 virtual void setChangeReason(
135 const std::string& code, const std::string& commentary) = 0;
136
138 virtual void writeUiToInstrument() = 0;
139
150 virtual void saveInstrument(
151 std::function<void(const std::string& id)> on_success,
152 std::function<void(const QString& error)> on_failure) = 0;
153
154signals:
156 void changed();
157
160
162 void loadFailed(const QString& error);
163
172};
173
174}
175
176#endif
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
Audit metadata snapshot reported by an IInstrumentForm so the outer dialog can refresh its (shared) i...
Definition IInstrumentForm.hpp:39
Pure-virtual interface implemented by every per-family instrument form widget hosted in TradeDetailDi...
Definition IInstrumentForm.hpp:73
virtual bool isLoaded() const =0
True after the asynchronous load has populated the form.
virtual bool isDirty() const =0
Has the user edited any field since the last load or save?
virtual void setUsername(const std::string &username)=0
Inject the username stamped on every saved instrument.
virtual void setClientManager(ClientManager *cm)=0
Inject the NATS client used for load and save round-trips.
virtual void setChangeReason(const std::string &code, const std::string &commentary)=0
Stamp the change reason on the in-flight instrument before the dialog calls saveInstrument.
void changed()
Emitted when any field changes (after the initial load).
virtual void clear()=0
Reset the form to a blank state ready for create mode.
virtual void setReadOnly(bool readOnly)=0
Toggle read-only on every editable widget.
void loadFailed(const QString &error)
Emitted on a load failure with the server's error message.
virtual void setInstrument(const trading::domain::trade_instrument &instrument)=0
Populate the form with the already-resolved instrument.
virtual void setImageCache(ImageCache *)
Inject the image cache for flag icons on currency combo boxes.
Definition IInstrumentForm.hpp:86
void provenanceChanged(const InstrumentProvenance &provenance)
Emitted with the latest audit metadata after load and save.
virtual void writeUiToInstrument()=0
Pull the current UI values into the in-flight domain object.
virtual void setTradeType(const QString &code, bool has_options, bool has_extension)=0
Inform the form which trade type is currently selected.
void instrumentLoaded()
Emitted once the asynchronous load has populated the form.
virtual void saveInstrument(std::function< void(const std::string &id)> on_success, std::function< void(const QString &error)> on_failure)=0
Save the in-flight instrument via the family's NATS request.