ORE Studio 0.0.4
Loading...
Searching...
No Matches
TradeMdiWindow.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_TRADE_MDI_WINDOW_HPP
21#define ORES_QT_TRADE_MDI_WINDOW_HPP
22
23#include <QToolBar>
24#include <QTableView>
25#include <QSortFilterProxyModel>
26#include "ores.qt/EntityListMdiWindow.hpp"
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/ClientTradeModel.hpp"
29#include "ores.qt/PaginationWidget.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.trading.api/domain/trade.hpp"
32#include "ores.trading.api/messaging/trade_protocol.hpp"
33
34namespace ores::qt {
35
42class TradeMdiWindow final : public EntityListMdiWindow {
43 Q_OBJECT
44
45private:
46 inline static std::string_view logger_name =
47 "ores.qt.trade_mdi_window";
48
49 [[nodiscard]] static auto& lg() {
50 using namespace ores::logging;
51 static auto instance = make_logger(logger_name);
52 return instance;
53 }
54
55public:
56 explicit TradeMdiWindow(
57 ClientManager* clientManager,
58 const QString& username,
59 QWidget* parent = nullptr);
60 ~TradeMdiWindow() override = default;
61
62public slots:
63 void doReload() override;
64
65signals:
66 void statusChanged(const QString& message);
67 void errorOccurred(const QString& error_message);
68 void showTradeDetails(const trading::domain::trade& trade);
69 void addNewRequested();
70 void tradeDeleted(const QString& code);
71 void showTradeHistory(const trading::domain::trade& trade);
72 void importTradesRequested();
73
74public slots:
75 void addNew();
76 void editSelected();
77 void deleteSelected();
78 void viewHistorySelected();
79
80private slots:
81 void onDataLoaded();
82 void onLoadError(const QString& error_message, const QString& details = {});
83 void onSelectionChanged();
84 void onDoubleClicked(const QModelIndex& index);
85
86protected:
87 QString normalRefreshTooltip() const override {
88 return tr("Refresh trades");
89 }
90
91private:
92 void setupUi();
93 void setupToolbar();
94 void setupTable();
95 void setupConnections();
96 void updateActionStates();
97
98 ClientManager* clientManager_;
99 QString username_;
100
101 QToolBar* toolbar_;
102 QTableView* tableView_;
103 ClientTradeModel* model_;
104 QSortFilterProxyModel* proxyModel_;
105 PaginationWidget* paginationWidget_;
106
107 // Toolbar actions
108 QAction* reloadAction_;
109 QAction* addAction_;
110 QAction* editAction_;
111 QAction* deleteAction_;
112 QAction* historyAction_;
113 QAction* importAction_;
114};
115
116}
117
118#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
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:63
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:40
Model for displaying trades fetched from the server.
Definition ClientTradeModel.hpp:42
MDI window for displaying and managing trades.
Definition TradeMdiWindow.hpp:42
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition TradeMdiWindow.hpp:87
Trade capturing FpML Trade Header properties.
Definition trade.hpp:39