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
65signals:
66 void currencyUpdated(const QString& iso_code);
67 void currencyCreated(const QString& iso_code);
68 void currencyDeleted(const QString& iso_code);
69 void statusMessage(const QString& message);
70 void errorMessage(const QString& message);
71 void isDirtyChanged(bool isDirty);
72
73private slots:
74 void onSaveClicked();
75 void onResetClicked();
76 void onDeleteClicked();
77 void onFieldChanged();
78
79private:
80 void updateSaveResetButtonState();
81
82private:
83 std::unique_ptr<Ui::CurrencyDetailDialog> ui_;
84 bool isDirty_;
85 bool isAddMode_;
86 std::string username_;
87 QToolBar* toolBar_;
88 QAction* saveAction_;
89 QAction* deleteAction_;
90
91 ClientManager* clientManager_;
92 risk::domain::currency currentCurrency_;
93 static constexpr const char* max_timestamp = "9999-12-31 23:59:59";
94};
95
96}
97
98#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