ORE Studio 0.0.4
Loading...
Searching...
No Matches
CurrencyMdiWindow.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_MDI_WINDOW_HPP
21#define ORES_QT_CURRENCY_MDI_WINDOW_HPP
22
23#include <QTableView>
24#include <QVBoxLayout>
25#include <QToolBar>
26#include <QSortFilterProxyModel>
27#include <QCloseEvent>
28#include <memory>
29#include "ores.qt/EntityListMdiWindow.hpp"
30#include "ores.qt/ClientManager.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.qt/ClientCurrencyModel.hpp"
33#include "ores.qt/PaginationWidget.hpp"
34
35namespace ores::qt {
36
37class ImageCache;
38
43 Q_OBJECT
44
45private:
46 inline static std::string_view logger_name =
47 "ores.qt.currency_mdi_window";
48
49 [[nodiscard]] static auto& lg() {
50 using namespace ores::logging;
51 static auto instance = make_logger(logger_name);
52 return instance;
53 }
54
55public:
56 explicit CurrencyMdiWindow(ClientManager* clientManager,
57 ImageCache* imageCache,
58 const QString& username,
59 QWidget* parent = nullptr);
60 ~CurrencyMdiWindow() override;
61
62 ClientCurrencyModel* currencyModel() const { return currencyModel_.get(); }
63
64 QSize sizeHint() const override;
65
66signals:
67 void statusChanged(const QString& message);
68 void errorOccurred(const QString& error_message);
69 void selectionChanged(int selection_count);
70 void addNewRequested();
71 void showCurrencyDetails(const refdata::domain::currency& currency);
72 void currencyDeleted(const QString& iso_code);
73 void showCurrencyHistory(const QString& iso_code);
74
75public slots:
76 void reload() override;
77 void addNew();
78 void editSelected();
79 void deleteSelected();
80 void viewHistorySelected();
81 void importFromXML();
82 void exportToCSV();
83 void exportToXML();
84 void generateSynthetic();
85
86private slots:
87 void onDataLoaded();
88 void onLoadError(const QString& error_message, const QString& details = {});
89 void onRowDoubleClicked(const QModelIndex& index);
90 void onSelectionChanged();
91 void onConnectionStateChanged();
92 void onFeatureFlagNotification(const QString& eventType, const QDateTime& timestamp,
93 const QStringList& entityIds);
94
95protected:
96 QString normalRefreshTooltip() const override {
97 return tr("Refresh currencies");
98 }
99
100private:
101 void updateActionStates();
102 void setupReloadAction();
103 void setupGenerateAction();
104 void updateGenerateActionVisibility();
105 void setupColumnVisibility();
106 void showHeaderContextMenu(const QPoint& pos);
107 void saveSettings();
108 void restoreSettings();
109
110protected:
111 void closeEvent(QCloseEvent* event) override;
112
113private:
114 QVBoxLayout* verticalLayout_;
115 QTableView* currencyTableView_;
116 QToolBar* toolBar_;
117 PaginationWidget* pagination_widget_;
118
119 // Reload action with stale indicator
120 QAction* reloadAction_;
121
122 QAction* addAction_;
123 QAction* editAction_;
124 QAction* deleteAction_;
125 QAction* historyAction_;
126 QAction* generateAction_;
127
128 std::unique_ptr<ClientCurrencyModel> currencyModel_;
129 QSortFilterProxyModel* proxyModel_;
130 ClientManager* clientManager_;
131 ImageCache* imageCache_;
132 QString username_;
133};
134
135}
136
137#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Model for displaying currencies fetched from the server via client.
Definition ClientCurrencyModel.hpp:43
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
MDI window for displaying currencies.
Definition CurrencyMdiWindow.hpp:42
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition CurrencyMdiWindow.hpp:96
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:56
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:52
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:39
Represents a currency with its metadata and formatting rules.
Definition currency.hpp:33