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