ORE Studio 0.0.4
Loading...
Searching...
No Matches
CurrencyController.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2024 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_CURRENCY_CONTROLLER_HPP
21#define ORES_QT_CURRENCY_CONTROLLER_HPP
22
23#include <QPointer>
24#include <QDateTime>
25#include "ores.qt/EntityController.hpp"
26#include "ores.refdata/domain/currency.hpp"
27#include "ores.logging/make_logger.hpp"
28
29namespace ores::qt {
30
31class DetachableMdiSubWindow;
32class ImageCache;
33class ChangeReasonCache;
34
54 Q_OBJECT
55
56private:
57 inline static std::string_view logger_name =
58 "ores.qt.currency_controller";
59
60 [[nodiscard]] static auto& lg() {
61 using namespace ores::logging;
62 static auto instance = make_logger(logger_name);
63 return instance;
64 }
65
66public:
78 explicit CurrencyController(
79 QMainWindow* mainWindow,
80 QMdiArea* mdiArea,
81 ClientManager* clientManager,
82 ImageCache* imageCache,
83 ChangeReasonCache* changeReasonCache,
84 const QString& username,
85 QObject* parent = nullptr);
86
93 ~CurrencyController() override;
94
103 void showListWindow() override;
104
113 void closeAllWindows() override;
114
115 void reloadListWindow() override;
116
117private slots:
124 void onAddNewRequested();
125
135 void onShowCurrencyDetails(const refdata::domain::currency& currency);
136
146 void onShowCurrencyHistory(const QString& isoCode);
147
157 void onOpenCurrencyVersion(const refdata::domain::currency& currency, int versionNumber);
158
167 void onRevertCurrency(const refdata::domain::currency& currency);
168
180 void onNotificationReceived(const QString& eventType, const QDateTime& timestamp,
181 const QStringList& entityIds);
182
183private:
187 ImageCache* imageCache_;
188
192 ChangeReasonCache* changeReasonCache_;
193
201 QPointer<DetachableMdiSubWindow> currencyListWindow_;
202};
203
204}
205
206#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Shared cache for change reasons used across all entity dialogs.
Definition ChangeReasonCache.hpp:47
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Controller managing all currency-related windows and operations.
Definition CurrencyController.hpp:53
void closeAllWindows() override
Closes all windows managed by this controller.
Definition CurrencyController.cpp:189
void reloadListWindow() override
Reloads the list window. Must be implemented by derived classes.
Definition CurrencyController.cpp:200
~CurrencyController() override
Destroys the currency controller.
Definition CurrencyController.cpp:93
void showListWindow() override
Shows the currency list window.
Definition CurrencyController.cpp:103
Abstract base class for entity controllers.
Definition EntityController.hpp:50
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:52
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:33