ORE Studio 0.0.4
Loading...
Searching...
No Matches
AccountMdiWindow.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_MDI_WINDOW_HPP
21#define ORES_QT_ACCOUNT_MDI_WINDOW_HPP
22
23#include <QTableView>
24#include <QVBoxLayout>
25#include <QToolBar>
26#include <QSortFilterProxyModel>
27#include <memory>
28#include "ores.qt/EntityListMdiWindow.hpp"
29#include "ores.qt/ClientManager.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.qt/ClientAccountModel.hpp"
32#include "ores.qt/PaginationWidget.hpp"
33
34namespace ores::qt {
35
36class BadgeCache;
37
45 Q_OBJECT
46
47private:
48 inline static std::string_view logger_name =
49 "ores.qt.account_mdi_window";
50
51 [[nodiscard]] static auto& lg() {
52 using namespace ores::logging;
53 static auto instance = make_logger(logger_name);
54 return instance;
55 }
56
57public:
58 explicit AccountMdiWindow(ClientManager* clientManager,
59 const QString& username,
60 BadgeCache* badgeCache,
61 QWidget* parent = nullptr);
62 ~AccountMdiWindow() override;
63
64 ClientAccountModel* accountModel() const { return accountModel_.get(); }
65
66signals:
67 void statusChanged(const QString& message);
68 void errorOccurred(const QString& error_message);
69 void selectionChanged(int selection_count);
70 void addNewRequested();
71 void showAccountDetails(const AccountWithLoginInfo& accountWithLoginInfo);
72 void showAccountHistory(const QString& username);
73 void showSessionHistory(const boost::uuids::uuid& accountId, const QString& username);
74 void accountDeleted(const boost::uuids::uuid& account_id);
75
76public slots:
77 void doReload() override;
78 void addNew();
79 void editSelected();
80 void deleteSelected();
81 void lockSelected();
82 void unlockSelected();
83 void resetPasswordSelected();
84 void viewHistorySelected();
85 void viewSessionsSelected();
86
87private slots:
88 void onDataLoaded();
89 void onLoadError(const QString& error_message, const QString& details = {});
90 void onRowDoubleClicked(const QModelIndex& index);
91 void onSelectionChanged();
92 void onConnectionStateChanged();
93
94protected:
95 QString normalRefreshTooltip() const override {
96 return tr("Refresh accounts");
97 }
98
99private:
100 void updateActionStates();
101 void setupReloadAction();
102
103private:
104 QVBoxLayout* verticalLayout_;
105 QTableView* accountTableView_;
106 QToolBar* toolBar_;
107 PaginationWidget* pagination_widget_;
108
109 // Reload action with stale indicator
110 QAction* reloadAction_;
111
112 QAction* addAction_;
113 QAction* editAction_;
114 QAction* deleteAction_;
115 QAction* lockAction_;
116 QAction* unlockAction_;
117 QAction* resetPasswordAction_;
118 QAction* historyAction_;
119 QAction* sessionsAction_;
120
121 std::unique_ptr<ClientAccountModel> accountModel_;
122 QSortFilterProxyModel* proxyModel_;
123 ClientManager* clientManager_;
124 QString username_;
125 BadgeCache* badgeCache_;
126};
127
128}
129
130#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
MDI window for displaying and managing user accounts.
Definition AccountMdiWindow.hpp:44
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition AccountMdiWindow.hpp:95
Client-side cache of badge definitions and mappings.
Definition BadgeCache.hpp:46
Composite structure combining account with its login status.
Definition ClientAccountModel.hpp:59
Model for displaying accounts fetched from the server via client.
Definition ClientAccountModel.hpp:71
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:112
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:62
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:39