ORE Studio 0.0.4
Loading...
Searching...
No Matches
AccountController.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_CONTROLLER_HPP
21#define ORES_QT_ACCOUNT_CONTROLLER_HPP
22
23#include <optional>
24#include <QPointer>
25#include <QDateTime>
26#include <boost/uuid/uuid.hpp>
27#include "ores.qt/EntityController.hpp"
28#include "ores.qt/ClientAccountModel.hpp"
29#include "ores.logging/make_logger.hpp"
30#include "ores.iam.api/domain/account.hpp"
31
32namespace ores::qt { class ChangeReasonCache; }
33namespace ores::qt { class BadgeCache; }
34
35namespace ores::qt {
36
37class DetachableMdiSubWindow;
38
57 Q_OBJECT
58
59private:
60 inline static std::string_view logger_name =
61 "ores.qt.account_controller";
62
63 [[nodiscard]] static auto& lg() {
64 using namespace ores::logging;
65 static auto instance = make_logger(logger_name);
66 return instance;
67 }
68
69public:
79 explicit AccountController(
80 QMainWindow* mainWindow,
81 QMdiArea* mdiArea,
82 ClientManager* clientManager,
83 const QString& username,
84 ChangeReasonCache* changeReasonCache = nullptr,
85 BadgeCache* badgeCache = nullptr,
86 QObject* parent = nullptr);
87
94 ~AccountController() override;
95
104 void showListWindow() override;
105
114 void closeAllWindows() override;
115
116 void reloadListWindow() override;
117
118private slots:
125 void onAddNewRequested();
126
136 void onShowAccountDetails(const AccountWithLoginInfo& accountWithLoginInfo);
137
146 void onShowAccountHistory(const QString& username);
147
157 void onShowSessionHistory(const boost::uuids::uuid& accountId,
158 const QString& username);
159
169 void onOpenAccountVersion(const iam::domain::account& account, int versionNumber);
170
179 void onRevertAccount(const iam::domain::account& account);
180
191 void onNotificationReceived(const QString& eventType, const QDateTime& timestamp,
192 const QStringList& entityIds, const QString& tenantId);
193
194private:
204 void showDetailWindow(const std::optional<AccountWithLoginInfo>& accountWithLoginInfo);
205
211 void markAccountListAsStale();
212
220 QPointer<DetachableMdiSubWindow> accountListWindow_;
221 ChangeReasonCache* changeReasonCache_ = nullptr;
222 BadgeCache* badgeCache_ = nullptr;
223};
224
225}
226
227#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AccountController.hpp:32
Represents an account for an entity in the system.
Definition account.hpp:34
Controller managing all account-related windows and operations.
Definition AccountController.hpp:56
void closeAllWindows() override
Closes all windows managed by this controller.
Definition AccountController.cpp:174
void reloadListWindow() override
Reloads the list window. Must be implemented by derived classes.
Definition AccountController.cpp:180
~AccountController() override
Destroys the account controller.
Definition AccountController.cpp:93
void showListWindow() override
Shows the account list window.
Definition AccountController.cpp:103
Composite structure combining account with its login status.
Definition ClientAccountModel.hpp:59
Client-side cache of badge definitions and mappings.
Definition BadgeCache.hpp:47
Shared cache for change reasons used across all entity dialogs.
Definition ChangeReasonCache.hpp:48
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:123
Abstract base class for entity controllers.
Definition EntityController.hpp:52