ORE Studio 0.0.4
Loading...
Searching...
No Matches
BusinessCentreDetailDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_BUSINESS_CENTRE_DETAIL_DIALOG_HPP
21#define ORES_QT_BUSINESS_CENTRE_DETAIL_DIALOG_HPP
22
23#include "ores.qt/ClientManager.hpp"
24#include "ores.qt/DetailDialogBase.hpp"
25#include "ores.qt/ImageCache.hpp"
26#include "ores.logging/make_logger.hpp"
27#include "ores.refdata.api/domain/business_centre.hpp"
28
29namespace Ui {
30class BusinessCentreDetailDialog;
31}
32
33namespace ores::qt {
34
43 Q_OBJECT
44
45private:
46 inline static std::string_view logger_name =
47 "ores.qt.business_centre_detail_dialog";
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 BusinessCentreDetailDialog(QWidget* parent = nullptr);
58
59 void setClientManager(ClientManager* clientManager);
60 void setImageCache(ImageCache* imageCache);
61 void setUsername(const std::string& username);
62 void setBusinessCentre(const refdata::domain::business_centre& business_centre);
63 void setCreateMode(bool createMode);
64 void setReadOnly(bool readOnly);
65
66signals:
67 void businessCentreSaved(const QString& code);
68 void businessCentreDeleted(const QString& code);
69
70private slots:
71 void onSaveClicked();
72 void onDeleteClicked();
73 void onCodeChanged(const QString& text);
74 void onFieldChanged();
75
76protected:
77 QTabWidget* tabWidget() const override;
78 QWidget* provenanceTab() const override;
79 ProvenanceWidget* provenanceWidget() const override;
80
81 bool hasUnsavedChanges() const override { return hasChanges_; }
82
83private:
84 void setupUi();
85 void setupConnections();
86 void populateCountries();
87 void updateUiFromBusinessCentre();
88 void updateBusinessCentreFromUi();
89 void updateSaveButtonState();
90 bool validateInput();
91
92 Ui::BusinessCentreDetailDialog* ui_;
93 ClientManager* clientManager_;
94 ImageCache* imageCache_{nullptr};
95 std::string username_;
96 refdata::domain::business_centre business_centre_;
97 bool createMode_{true};
98 bool readOnly_{false};
99 bool hasChanges_{false};
100 std::string pending_country_;
101};
102
103}
104
105#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Detail dialog for viewing and editing business centre records.
Definition BusinessCentreDetailDialog.hpp:42
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition BusinessCentreDetailDialog.cpp:55
bool hasUnsavedChanges() const override
Definition BusinessCentreDetailDialog.hpp:81
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition BusinessCentreDetailDialog.cpp:53
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition BusinessCentreDetailDialog.cpp:54
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:74
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:53
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39
Represents a business centre using FpML-style codes.
Definition business_centre.hpp:37