ORE Studio 0.0.4
Loading...
Searching...
No Matches
BookMdiWindow.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_BOOK_MDI_WINDOW_HPP
21#define ORES_QT_BOOK_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/ClientBookModel.hpp"
29#include "ores.qt/PaginationWidget.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.refdata.api/domain/book.hpp"
32
33namespace ores::qt {
34
35class BadgeCache;
36
43class BookMdiWindow final : public EntityListMdiWindow {
44 Q_OBJECT
45
46private:
47 inline static std::string_view logger_name =
48 "ores.qt.book_mdi_window";
49
50 [[nodiscard]] static auto& lg() {
51 using namespace ores::logging;
52 static auto instance = make_logger(logger_name);
53 return instance;
54 }
55
56public:
57 explicit BookMdiWindow(
58 ClientManager* clientManager,
59 ImageCache* imageCache,
60 const QString& username,
61 BadgeCache* badgeCache,
62 QWidget* parent = nullptr);
63 ~BookMdiWindow() override = default;
64
65public slots:
66 void doReload() override;
67
68signals:
69 void statusChanged(const QString& message);
70 void errorOccurred(const QString& error_message);
71 void showBookDetails(const refdata::domain::book& book);
72 void addNewRequested();
73 void showBookHistory(const refdata::domain::book& book);
74
75public slots:
76 void addNew();
77 void editSelected();
78 void deleteSelected();
79 void viewHistorySelected();
80 void importTrades();
81 void exportToXml();
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 books");
92 }
93
94private:
95 void setupUi();
96 void setupToolbar();
97 void setupTable();
98 void setupConnections();
99 void updateActionStates();
100
101 ClientManager* clientManager_;
102 ImageCache* imageCache_;
103 QString username_;
104 BadgeCache* badgeCache_;
105
106 QToolBar* toolbar_;
107 QTableView* tableView_;
108 ClientBookModel* model_;
109 QSortFilterProxyModel* proxyModel_;
110 PaginationWidget* paginationWidget_;
111
112 // Toolbar actions
113 QAction* reloadAction_;
114 QAction* addAction_;
115 QAction* editAction_;
116 QAction* deleteAction_;
117 QAction* historyAction_;
118 QAction* importAction_;
119 QAction* exportXmlAction_;
120};
121
122}
123
124#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Client-side cache of badge definitions and mappings.
Definition BadgeCache.hpp:47
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
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:54
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:40
MDI window for displaying and managing books.
Definition BookMdiWindow.hpp:43
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition BookMdiWindow.hpp:90
Model for displaying books fetched from the server.
Definition ClientBookModel.hpp:43
Operational ledger leaf that holds trades.
Definition book.hpp:37