ORE Studio 0.0.4
Loading...
Searching...
No Matches
ImportCurrencyDialog.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_IMPORT_CURRENCY_DIALOG_HPP
21#define ORES_QT_IMPORT_CURRENCY_DIALOG_HPP
22
23#include <atomic>
24#include <vector>
25#include <QString>
26#include <QDialog>
27#include <QLabel>
28#include <QCheckBox>
29#include <QPushButton>
30#include <QTableWidget>
31#include <QProgressBar>
32#include <QFutureWatcher>
33#include "ores.risk/domain/currency.hpp"
34#include "ores.qt/ClientManager.hpp"
35#include "ores.utility/log/make_logger.hpp"
36
37namespace ores::qt {
38
49class ImportCurrencyDialog final : public QDialog {
50 Q_OBJECT
51
52private:
53 inline static std::string_view logger_name =
54 "ores.qt.import_currency_dialog";
55
56 [[nodiscard]] static auto& lg() {
57 using namespace ores::utility::log;
58 static auto instance = make_logger(logger_name);
59 return instance;
60 }
61
62public:
70 explicit ImportCurrencyDialog(
71 const std::vector<risk::domain::currency>& currencies,
72 const QString& filename,
73 ClientManager* clientManager,
74 const QString& username,
75 QWidget* parent = nullptr);
76
77 ~ImportCurrencyDialog() override;
78
83 [[nodiscard]] std::vector<risk::domain::currency>
85
86signals:
92 void importCompleted(int success_count, int total_count);
93
98
99private slots:
103 void onImportClicked();
104
108 void onCancelClicked();
109
113 void onSelectAllChanged(int state);
114
118 void onCurrencyCheckChanged();
119
120private:
124 void setupUI();
125
129 void populateTable();
130
134 void updateImportButtonState();
135
139 void updateSelectionCount();
140
141private:
142 std::vector<risk::domain::currency> currencies_;
143 std::vector<std::string> validation_errors_;
144 QString filename_;
145 ClientManager* clientManager_;
146 QString username_;
147
148 // UI Components
149 QLabel* filenameLabel_;
150 QCheckBox* selectAllCheckbox_;
151 QLabel* selectionCountLabel_;
152 QTableWidget* currencyTable_;
153 QProgressBar* progressBar_;
154 QLabel* statusLabel_;
155 QPushButton* importButton_;
156 QPushButton* cancelButton_;
157
158 bool importInProgress_;
159 std::atomic<bool> cancelRequested_;
160};
161
162}
163
164#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
Dialog for previewing and importing currencies from XML files.
Definition ImportCurrencyDialog.hpp:49
std::vector< risk::domain::currency > getSelectedCurrencies() const
Get the currencies selected for import.
Definition ImportCurrencyDialog.cpp:262
void importCompleted(int success_count, int total_count)
Emitted when import completes successfully.
void importCancelled()
Emitted when import is cancelled.