ORE Studio 0.0.4
Loading...
Searching...
No Matches
CurrencyHistoryDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 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_HISTORY_DIALOG_HPP
21#define ORES_QT_CURRENCY_HISTORY_DIALOG_HPP
22
23#include <memory>
24#include <QPair>
25#include <QWidget>
26#include <QString>
27#include <QVector>
28#include "ores.qt/ClientManager.hpp"
29#include "ores.risk/domain/currency_version.hpp"
30#include "ores.risk/domain/currency_version_history.hpp"
31#include "ores.utility/log/make_logger.hpp"
32#include "ui_CurrencyHistoryDialog.h"
33
34namespace Ui {
35class CurrencyHistoryDialog;
36}
37
38namespace ores::qt {
39
43class CurrencyHistoryDialog : public QWidget {
44 Q_OBJECT
45
46private:
47 inline static std::string_view logger_name =
48 "ores.qt.currency_history_dialog";
49
50 [[nodiscard]] static auto& lg() {
51 using namespace ores::utility::log;
52 static auto instance = make_logger(logger_name);
53 return instance;
54 }
55
56 const QIcon& getHistoryIcon() const;
57
58public:
59 explicit CurrencyHistoryDialog(QString iso_code,
60 ClientManager* clientManager,
61 QWidget* parent = nullptr);
62 ~CurrencyHistoryDialog() override;
63
64 void loadHistory();
65
66 QSize sizeHint() const override; // Provide optimal size based on table content
67
68signals:
69 void statusChanged(const QString& message);
70 void errorOccurred(const QString& error_message);
71
72private slots:
73 void onVersionSelected(int index);
74 void onHistoryLoaded();
75 void onHistoryLoadError(const QString& error);
76
77private:
78 void displayChangesTab(int version_index);
79 void displayFullDetailsTab(int version_index);
80
86 using DiffResult = QVector<QPair<QString, QPair<QString, QString>>>;
87 DiffResult calculateDiff(
88 const risk::domain::currency_version& current,
89 const risk::domain::currency_version& previous);
90
91 std::unique_ptr<Ui::CurrencyHistoryDialog> ui_;
92 ClientManager* clientManager_;
93 QString isoCode_;
95};
96
97}
98
99#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:56
Widget for displaying currency version history.
Definition CurrencyHistoryDialog.hpp:43
Represents a specific version of a currency with metadata.
Definition currency_version.hpp:31
Contains the full version history for a currency.
Definition currency_version_history.hpp:32