ORE Studio 0.0.4
Loading...
Searching...
No Matches
ImportTradeDialog.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_IMPORT_TRADE_DIALOG_HPP
21#define ORES_QT_IMPORT_TRADE_DIALOG_HPP
22
23#include <atomic>
24#include <vector>
25#include <QString>
26#include <QDialog>
27#include <QLabel>
28#include <QWidget>
29#include <QCheckBox>
30#include <QDateEdit>
31#include <QLineEdit>
32#include <QPushButton>
33#include <QComboBox>
34#include <QTableWidget>
35#include <QProgressBar>
36#include <QFutureWatcher>
37#include <boost/uuid/uuid.hpp>
38#include "ores.ore/xml/importer.hpp"
39#include "ores.refdata.api/domain/book.hpp"
40#include "ores.refdata.api/domain/counterparty.hpp"
41#include "ores.qt/ClientManager.hpp"
42#include "ores.logging/make_logger.hpp"
43
44namespace ores::qt {
45
57class ImportTradeDialog final : public QDialog {
58 Q_OBJECT
59
60private:
61 inline static std::string_view logger_name =
62 "ores.qt.import_trade_dialog";
63
64 [[nodiscard]] static auto& lg() {
65 using namespace ores::logging;
66 static auto instance = make_logger(logger_name);
67 return instance;
68 }
69
70public:
81 explicit ImportTradeDialog(
82 const refdata::domain::book& book,
83 const std::vector<ore::xml::trade_import_item>& items,
84 const QString& source_label,
85 ClientManager* clientManager,
86 const QString& username,
87 QWidget* parent = nullptr);
88
89 ~ImportTradeDialog() override;
90
91signals:
97 void importCompleted(int success_count, int total_count);
98
103
104private slots:
105 void onImportClicked();
106 void onCancelClicked();
107 void onSelectAllChanged(Qt::CheckState state);
108 void onTradeCheckChanged();
109 void onApplyNettingSetToAll();
110 void onApplyCounterpartyToAll();
111
112private:
113 void setupUI();
114 void populateTradeTable();
115 void populateCounterpartyCombos();
116 void loadCounterparties();
117 void updateImportButtonState();
118 void updateSelectionCount();
119
120private:
122 std::vector<ore::xml::trade_import_item> items_;
123 std::vector<std::string> validation_errors_;
124 std::vector<refdata::domain::counterparty> counterparties_;
125 QString source_label_;
126 ClientManager* clientManager_;
127 QString username_;
128
129 // Import defaults
130 QDateEdit* tradeDateEdit_;
131 QDateEdit* effectiveDateEdit_;
132 QDateEdit* terminationDateEdit_;
133 QComboBox* lifecycleEventCombo_;
134 QLineEdit* defaultNettingSetEdit_;
135 QComboBox* defaultCounterpartyCombo_;
136 QLabel* counterpartyStatusLabel_;
137
138 // Trade table and controls
139 QLabel* fileLabel_;
140 QLabel* bookLabel_;
141 QCheckBox* selectAllCheckbox_;
142 QLabel* selectionCountLabel_;
143 QTableWidget* tradeTable_;
144
145 // Progress and status
146 QProgressBar* progressBar_;
147 QLabel* statusLabel_;
148 QPushButton* importButton_;
149 QPushButton* cancelButton_;
150
151 bool importInProgress_;
152 std::atomic<bool> cancelRequested_;
153};
154
155}
156
157#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
Dialog for reviewing defaults and importing ORE portfolio trades.
Definition ImportTradeDialog.hpp:57
void importCompleted(int success_count, int total_count)
Emitted when import completes.
void importCancelled()
Emitted when import is cancelled.
Operational ledger leaf that holds trades.
Definition book.hpp:37