ORE Studio 0.0.4
Loading...
Searching...
No Matches
CounterpartyMdiWindow.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_COUNTERPARTY_MDI_WINDOW_HPP
21#define ORES_QT_COUNTERPARTY_MDI_WINDOW_HPP
22
23#include <QToolBar>
24#include <QTableView>
25#include <QSortFilterProxyModel>
26#include "ores.qt/EntityListMdiWindow.hpp"
27#include "ores.qt/PaginationWidget.hpp"
28#include "ores.qt/ClientManager.hpp"
29#include "ores.qt/ImageCache.hpp"
30#include "ores.qt/ClientCounterpartyModel.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.refdata.api/domain/counterparty.hpp"
33
34namespace ores::qt {
35
36class BadgeCache;
37
45 Q_OBJECT
46
47private:
48 inline static std::string_view logger_name =
49 "ores.qt.counterparty_mdi_window";
50
51 [[nodiscard]] static auto& lg() {
52 using namespace ores::logging;
53 static auto instance = make_logger(logger_name);
54 return instance;
55 }
56
57public:
58 explicit CounterpartyMdiWindow(
59 ClientManager* clientManager,
60 ImageCache* imageCache,
61 const QString& username,
62 BadgeCache* badgeCache,
63 QWidget* parent = nullptr);
64 ~CounterpartyMdiWindow() override = default;
65
66public slots:
67 void doReload() override;
68
69signals:
70 void statusChanged(const QString& message);
71 void errorOccurred(const QString& error_message);
72 void showCounterpartyDetails(const refdata::domain::counterparty& counterparty);
73 void addNewRequested();
74 void counterpartyDeleted(const QString& code);
75 void showCounterpartyHistory(const refdata::domain::counterparty& counterparty);
76
77public slots:
78 void addNew();
79 void editSelected();
80 void deleteSelected();
81 void viewHistorySelected();
82
83private slots:
84 void onDataLoaded();
85 void onLoadError(const QString& error_message, const QString& details = {});
86 void onSelectionChanged();
87 void onDoubleClicked(const QModelIndex& index);
88
89protected:
90 QString normalRefreshTooltip() const override {
91 return tr("Refresh counterparties");
92 }
93private:
94 void setupUi();
95 void setupToolbar();
96 void setupTable();
97 void setupConnections();
98 void updateActionStates();
99
100 ClientManager* clientManager_;
101 ImageCache* imageCache_;
102 QString username_;
103 BadgeCache* badgeCache_;
104
105 QToolBar* toolbar_;
106 QTableView* tableView_;
107 PaginationWidget* pagination_widget_;
109 QSortFilterProxyModel* proxyModel_;
110
111 // Toolbar actions
112 QAction* reloadAction_;
113 QAction* addAction_;
114 QAction* editAction_;
115 QAction* deleteAction_;
116 QAction* historyAction_;
117};
118
119}
120
121#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Client-side cache of badge definitions and mappings.
Definition BadgeCache.hpp:46
Model for displaying counterparties fetched from the server.
Definition ClientCounterpartyModel.hpp:45
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
MDI window for displaying and managing counterparties.
Definition CounterpartyMdiWindow.hpp:44
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition CounterpartyMdiWindow.hpp:90
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:62
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:53
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:39
An external trading partner participating in financial transactions.
Definition counterparty.hpp:37