ORE Studio 0.0.4
Loading...
Searching...
No Matches
CurrencyDetailDialog.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_DETAIL_DIALOG_HPP
21#define ORES_QT_CURRENCY_DETAIL_DIALOG_HPP
22
23#include <QWidget>
24#include <QToolBar>
25#include <QAction>
26#include <memory>
27#include "ores.risk/domain/currency.hpp"
28#include "ores.qt/ClientManager.hpp"
29#include "ores.utility/log/make_logger.hpp"
30
31
32namespace Ui {
33
34class CurrencyDetailDialog;
35
36}
37
38namespace ores::qt {
39
40class CurrencyDetailDialog final : public QWidget {
41 Q_OBJECT
42
43private:
44 inline static std::string_view logger_name =
45 "ores.qt.currency_detail_dialog";
46
47 [[nodiscard]] static auto& lg() {
48 using namespace ores::utility::log;
49 static auto instance = make_logger(logger_name);
50 return instance;
51 }
52
53public:
54 explicit CurrencyDetailDialog(QWidget* parent = nullptr);
55 ~CurrencyDetailDialog() override;
56
57 void setClientManager(ClientManager* clientManager);
58 void setUsername(const std::string& username);
59
60 void setCurrency(const risk::domain::currency& currency);
61 [[nodiscard]] risk::domain::currency getCurrency() const;
62 void clearDialog();
63 void save();
64
78 void setReadOnly(bool readOnly, int versionNumber = 0);
79
80signals:
81 void currencyUpdated(const QString& iso_code);
82 void currencyCreated(const QString& iso_code);
83 void currencyDeleted(const QString& iso_code);
84 void statusMessage(const QString& message);
85 void errorMessage(const QString& message);
86 void isDirtyChanged(bool isDirty);
87
92 void revertRequested(const risk::domain::currency& currency);
93
94private slots:
95 void onSaveClicked();
96 void onResetClicked();
97 void onDeleteClicked();
98 void onRevertClicked();
99 void onFieldChanged();
100
101private:
102 void updateSaveResetButtonState();
103 void setFieldsReadOnly(bool readOnly);
104
105private:
106 std::unique_ptr<Ui::CurrencyDetailDialog> ui_;
107 bool isDirty_;
108 bool isAddMode_;
109 bool isReadOnly_;
110 int historicalVersion_;
111 std::string username_;
112 QToolBar* toolBar_;
113 QAction* saveAction_;
114 QAction* deleteAction_;
115 QAction* revertAction_;
116
117 ClientManager* clientManager_;
118 risk::domain::currency currentCurrency_;
119 static constexpr const char* max_timestamp = "9999-12-31 23:59:59";
120};
121
122}
123
124#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:30