ORE Studio 0.0.4
Loading...
Searching...
No Matches
EntityDetailDialog.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_ENTITY_DETAIL_DIALOG_HPP
21#define ORES_QT_ENTITY_DETAIL_DIALOG_HPP
22
23#include <QTableWidget>
24#include <QToolBar>
25#include <QTreeWidget>
26#include <memory>
27#include <unordered_map>
28#include "ores.qt/ClientManager.hpp"
29#include "ores.qt/DetailDialogBase.hpp"
30#include "ores.qt/ImageCache.hpp"
31#include "ores.qt/EntityDetailOperations.hpp"
32#include "ores.logging/make_logger.hpp"
33#include "ores.refdata.api/domain/party_id_scheme.hpp"
34#include "ores.qt/export.hpp"
35
36namespace Ui {
37class EntityDetailDialog;
38}
39
40namespace ores::qt {
41
50class ORES_QT_API EntityDetailDialog final : public DetailDialogBase {
51 Q_OBJECT
52
53private:
54 inline static std::string_view logger_name =
55 "ores.qt.entity_detail_dialog";
56
57 [[nodiscard]] static auto& lg() {
58 using namespace ores::logging;
59 static auto instance = make_logger(logger_name);
60 return instance;
61 }
62
63public:
64 explicit EntityDetailDialog(
65 std::shared_ptr<entity_detail_operations> ops,
66 QWidget* parent = nullptr);
67 ~EntityDetailDialog() override;
68
69 void setClientManager(ClientManager* clientManager);
70 void setImageCache(ImageCache* imageCache);
71 void setUsername(const std::string& username);
72 void setEntityData(const entity_data& data);
73 void setCreateMode(bool createMode);
74 void setReadOnly(bool readOnly);
75
76signals:
77 void entitySaved(const QString& code);
78 void entityDeleted(const QString& code);
79
80private slots:
81 void onSaveClicked();
82 void onDeleteClicked();
83 void onCodeChanged(const QString& text);
84 void onFieldChanged();
85 void onAddIdentifier();
86 void onDeleteIdentifier();
87 void onAddContact();
88 void onDeleteContact();
89 void onContactDoubleClicked(int row, int column);
90
91protected:
92 QTabWidget* tabWidget() const override;
93 QWidget* provenanceTab() const override;
94 ProvenanceWidget* provenanceWidget() const override;
95
96 bool hasUnsavedChanges() const override { return hasChanges_; }
97
98private:
99 void setupUi();
100 void setupConnections();
101 void setupIdentifierTable();
102 void setupContactTable();
103 void setupHierarchyTree();
104 void populateLookups();
105 void loadIdentifiers();
106 void loadContacts();
107 void loadAllEntities();
108 void loadIdSchemes();
109 void loadCountryImageMap();
110 void populateParentCombo();
111 void populateIdentifierTable();
112 void populateContactTable();
113 void buildHierarchyTree();
114 void updateUiFromEntity();
115 void updateEntityFromUi();
116 void updateSaveButtonState();
117 bool validateInput();
118
119 std::shared_ptr<entity_detail_operations> ops_;
120 Ui::EntityDetailDialog* ui_;
121 ClientManager* clientManager_;
122 ImageCache* imageCache_;
123 std::string username_;
124 entity_data entity_;
125 bool createMode_{true};
126 bool readOnly_{false};
127 bool hasChanges_{false};
128
129 // All entities for parent combo + hierarchy
130 std::vector<parent_entity_entry> allEntities_;
131
132 // Identifier sub-table
133 QTableWidget* identifierTable_;
134 QToolBar* identifierToolbar_;
135 std::vector<identifier_entry> identifiers_;
136
137 // Contact sub-table
138 QTableWidget* contactTable_;
139 QToolBar* contactToolbar_;
140 std::vector<contact_entry> contacts_;
141
142 // Identifier schemes
143 std::vector<refdata::domain::party_id_scheme> idSchemes_;
144
145 // Country code -> image_id mapping for flag icons
146 std::unordered_map<std::string, std::string> countryImageMap_;
147
148 // Hierarchy
149 QTreeWidget* hierarchyTree_;
150};
151
152}
153
154#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:75
Shared detail dialog for viewing and editing party and counterparty records.
Definition EntityDetailDialog.hpp:50
bool hasUnsavedChanges() const override
Definition EntityDetailDialog.hpp:96
Common entity data extracted from party or counterparty types.
Definition EntityDetailOperations.hpp:91
Cache for dynamically loaded images (flags, icons) from the server.
Definition ImageCache.hpp:54
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:40