ORE Studio 0.0.4
Loading...
Searching...
No Matches
AccountPartiesWidget.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_ACCOUNT_PARTIES_WIDGET_HPP
21#define ORES_QT_ACCOUNT_PARTIES_WIDGET_HPP
22
23#include <QWidget>
24#include <QListWidget>
25#include <QComboBox>
26#include <QToolButton>
27#include <QGroupBox>
28#include <vector>
29#include <boost/uuid/uuid.hpp>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.logging/make_logger.hpp"
32#include "ores.iam.api/domain/account_party.hpp"
33#include "ores.refdata.api/domain/party.hpp"
34
35namespace ores::qt {
36
48class AccountPartiesWidget : public QWidget {
49 Q_OBJECT
50
51private:
52 inline static std::string_view logger_name =
53 "ores.qt.account_parties_widget";
54
55 [[nodiscard]] static auto& lg() {
56 using namespace ores::logging;
57 static auto instance = make_logger(logger_name);
58 return instance;
59 }
60
61public:
62 explicit AccountPartiesWidget(QWidget* parent = nullptr);
63 ~AccountPartiesWidget() override = default;
64
65 void setClientManager(ClientManager* clientManager);
66 void setAccountId(const boost::uuids::uuid& accountId);
67 void setAccountType(const std::string& accountType);
72 void load();
73 void setReadOnly(bool readOnly);
74
75 [[nodiscard]] bool hasPendingChanges() const;
76 [[nodiscard]] bool hasAvailableParties() const;
77 [[nodiscard]] const std::vector<boost::uuids::uuid>& pendingAdds() const;
78 [[nodiscard]] const std::vector<boost::uuids::uuid>& pendingRemoves() const;
79
80signals:
81 void statusMessage(const QString& message);
82 void errorMessage(const QString& title, const QString& message);
83
90
91private slots:
92 void onAddPartyClicked();
93 void onRemovePartyClicked();
94 void onAssignedSelectionChanged();
95
96private:
97 void setupUi();
98 void refreshView();
99 void updateButtonStates();
100
101 QGroupBox* partiesGroup_;
102 QListWidget* assignedList_;
103 QComboBox* partyCombo_;
104 QToolButton* addButton_;
105 QToolButton* removeButton_;
106
107 ClientManager* clientManager_ = nullptr;
108 boost::uuids::uuid accountId_;
109 std::string accountType_;
110 bool readOnly_ = false;
111
112 // DB state
113 std::vector<iam::domain::account_party> assignedParties_;
114 std::vector<refdata::domain::party> allParties_;
115
116 // Pending local changes (committed by the parent dialog's Save action)
117 std::vector<boost::uuids::uuid> pendingAdds_;
118 std::vector<boost::uuids::uuid> pendingRemoves_;
119};
120
121}
122
123#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Widget for managing parties assigned to an account.
Definition AccountPartiesWidget.hpp:48
void load()
Load parties. If accountId is set, also fetches assigned parties. If accountId is nil (create mode),...
Definition AccountPartiesWidget.cpp:121
void partyListChanged()
Emitted when the staged party list changes.
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109