ORE Studio 0.0.4
Loading...
Searching...
No Matches
AccountDetailDialog.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 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_DETAIL_DIALOG_HPP
21#define ORES_QT_ACCOUNT_DETAIL_DIALOG_HPP
22
23#include <QToolBar>
24#include <QAction>
25#include <memory>
26#include <optional>
27#include "ores.iam/domain/account.hpp"
28#include "ores.iam/domain/login_info.hpp"
29#include "ores.qt/ClientManager.hpp"
30#include "ores.qt/AccountRolesWidget.hpp"
31#include "ores.qt/DetailDialogBase.hpp"
32#include "ores.logging/make_logger.hpp"
33
34
35namespace Ui {
36
37class AccountDetailDialog;
38
39}
40
41namespace ores::qt {
42
56 Q_OBJECT
57
58private:
59 inline static std::string_view logger_name =
60 "ores.qt.account_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 AccountDetailDialog(QWidget* parent = nullptr);
70 ~AccountDetailDialog() override;
71
72 void setClientManager(ClientManager* clientManager);
73 void setUsername(const std::string& username);
74
83 void setAccount(const iam::domain::account& account);
84
93 void setLoginInfo(const std::optional<iam::domain::login_info>& loginInfo);
94
100 [[nodiscard]] iam::domain::account getAccount() const;
101
105 void clearDialog();
106
110 void save();
111
125 void setReadOnly(bool readOnly, int versionNumber = 0);
126
134 void markAsStale();
135
139 [[nodiscard]] QString accountId() const;
140
141signals:
142 void accountUpdated(const boost::uuids::uuid& account_id);
143 void accountCreated(const boost::uuids::uuid& account_id);
144 void accountDeleted(const boost::uuids::uuid& account_id);
145 void isDirtyChanged(bool isDirty);
146
152
153private slots:
154 void onSaveClicked();
155 void onResetClicked();
156 void onDeleteClicked();
157 void onRevertClicked();
158 void onFieldChanged();
159 void updatePasswordMatchIndicator();
160
161private:
162 void updateSaveResetButtonState();
163 void setCreateMode(bool createMode);
164 void setFieldsReadOnly(bool readOnly);
165 bool validatePassword() const;
166
167private:
168 std::unique_ptr<Ui::AccountDetailDialog> ui_;
169 bool isDirty_;
170 bool isAddMode_;
171 bool isReadOnly_;
172 bool isStale_;
173 int historicalVersion_;
174 std::string modifiedByUsername_;
175 QToolBar* toolBar_;
176 QAction* saveAction_;
177 QAction* deleteAction_;
178 QAction* revertAction_;
179
180 ClientManager* clientManager_;
181 iam::domain::account currentAccount_;
182 std::optional<iam::domain::login_info> currentLoginInfo_;
183 AccountRolesWidget* rolesWidget_;
184};
185
186}
187
188#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Represents an account for an entity in the system.
Definition account.hpp:32
Dialog widget for creating and editing user accounts.
Definition AccountDetailDialog.hpp:55
iam::domain::account getAccount() const
Gets the current account state from the form.
Definition AccountDetailDialog.cpp:198
void revertRequested(const iam::domain::account &account)
Emitted when user requests to revert to the displayed historical version.
void markAsStale()
Mark the dialog data as stale.
Definition AccountDetailDialog.cpp:689
void setReadOnly(bool readOnly, int versionNumber=0)
Sets the dialog to read-only mode for viewing historical versions.
Definition AccountDetailDialog.cpp:633
void setAccount(const iam::domain::account &account)
Sets the account to display/edit.
Definition AccountDetailDialog.cpp:151
void save()
Saves the account (create or update).
Definition AccountDetailDialog.cpp:264
void setLoginInfo(const std::optional< iam::domain::login_info > &loginInfo)
Sets the login info to display (read-only).
Definition AccountDetailDialog.cpp:231
void clearDialog()
Clears all form fields and resets dialog state.
Definition AccountDetailDialog.cpp:207
QString accountId() const
Returns the account ID of the account being edited.
Definition AccountDetailDialog.cpp:703
Widget for managing roles assigned to an account.
Definition AccountRolesWidget.hpp:42
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:54