ORE Studio 0.0.4
Loading...
Searching...
No Matches
BusinessUnitDetailDialog.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_UNIT_DETAIL_DIALOG_HPP
21#define ORES_QT_BUSINESS_UNIT_DETAIL_DIALOG_HPP
22
23#include <string>
24#include <vector>
25#include <boost/uuid/uuid.hpp>
26#include "ores.qt/ClientManager.hpp"
27#include "ores.qt/DetailDialogBase.hpp"
28#include "ores.qt/ImageCache.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.refdata.api/domain/business_unit.hpp"
31
32namespace Ui {
33class BusinessUnitDetailDialog;
34}
35
36namespace ores::qt {
37
43 boost::uuids::uuid id;
44 std::string name;
45 int level = 0;
46};
47
56 Q_OBJECT
57
58private:
59 inline static std::string_view logger_name =
60 "ores.qt.business_unit_detail_dialog";
61
62 [[nodiscard]] static auto& lg() {
63 using namespace ores::logging;
64 static auto instance = make_logger(logger_name);
65 return instance;
66 }
67
68public:
69 explicit BusinessUnitDetailDialog(QWidget* parent = nullptr);
71
72 void setClientManager(ClientManager* clientManager);
73 void setImageCache(ImageCache* imageCache);
74 void setUsername(const std::string& username);
75 void setUnit(const refdata::domain::business_unit& business_unit);
76 void setCreateMode(bool createMode);
77 void setReadOnly(bool readOnly);
78
79signals:
80 void business_unitSaved(const QString& code);
81 void business_unitDeleted(const QString& code);
82
83private slots:
84 void onSaveClicked();
85 void onDeleteClicked();
86 void onCodeChanged(const QString& text);
87 void onFieldChanged();
88
89protected:
90 QTabWidget* tabWidget() const override;
91 QWidget* provenanceTab() const override;
92 ProvenanceWidget* provenanceWidget() const override;
93 bool hasUnsavedChanges() const override { return hasChanges_; }
94
95private:
96 void setupUi();
97 void setupConnections();
98 void updateUiFromUnit();
99 void updateUnitFromUi();
100 void updateSaveButtonState();
101 void populateBusinessCentres();
102 void populateUnitTypes();
103 bool validateInput();
104
105 Ui::BusinessUnitDetailDialog* ui_;
106 ClientManager* clientManager_;
107 ImageCache* imageCache_{nullptr};
108 std::string username_;
109 refdata::domain::business_unit business_unit_;
110 std::vector<unit_type_entry> unit_type_entries_;
111 bool createMode_{true};
112 bool readOnly_{false};
113 bool hasChanges_{false};
114};
115
116}
117
118#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Lightweight entry for a business unit type, used to populate the unit type combo box.
Definition BusinessUnitDetailDialog.hpp:42
Detail dialog for viewing and editing business unit records.
Definition BusinessUnitDetailDialog.hpp:55
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition BusinessUnitDetailDialog.cpp:59
bool hasUnsavedChanges() const override
Definition BusinessUnitDetailDialog.hpp:93
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition BusinessUnitDetailDialog.cpp:57
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition BusinessUnitDetailDialog.cpp:58
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
Internal organizational unit within a party.
Definition business_unit.hpp:37