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
43 Q_OBJECT
44
45private:
46 inline static std::string_view logger_name =
47 "ores.qt.account_mdi_window";
48
49 [[nodiscard]] static auto& lg() {
50 using namespace ores::logging;
51 static auto instance = make_logger(logger_name);
52 return instance;
53 }
54
55public:
56 explicit AccountMdiWindow(ClientManager* clientManager,
57 const QString& username,
58 QWidget* parent = nullptr);
59 ~AccountMdiWindow() override;
60
61 ClientAccountModel* accountModel() const { return accountModel_.get(); }
62
63signals:
64 void statusChanged(const QString& message);
65 void errorOccurred(const QString& error_message);
66 void selectionChanged(int selection_count);
67 void addNewRequested();
68 void showAccountDetails(const AccountWithLoginInfo& accountWithLoginInfo);
69 void showAccountHistory(const QString& username);
70 void showSessionHistory(const boost::uuids::uuid& accountId, const QString& username);
71 void accountDeleted(const boost::uuids::uuid& account_id);
72
73public slots:
74 void doReload() override;
75 void addNew();
76 void editSelected();
77 void deleteSelected();
78 void lockSelected();
79 void unlockSelected();
80 void resetPasswordSelected();
81 void viewHistorySelected();
82 void viewSessionsSelected();
83
84private slots:
85 void onDataLoaded();
86 void onLoadError(const QString& error_message, const QString& details = {});
87 void onRowDoubleClicked(const QModelIndex& index);
88 void onSelectionChanged();
89 void onConnectionStateChanged();
90
91protected:
92 QString normalRefreshTooltip() const override {
93 return tr("Refresh accounts");
94 }
95
96private:
97 void updateActionStates();
98 void setupReloadAction();
99
100private:
101 QVBoxLayout* verticalLayout_;
102 QTableView* accountTableView_;
103 QToolBar* toolBar_;
104 PaginationWidget* pagination_widget_;
105
106 // Reload action with stale indicator
107 QAction* reloadAction_;
108
109 QAction* addAction_;
110 QAction* editAction_;
111 QAction* deleteAction_;
112 QAction* lockAction_;
113 QAction* unlockAction_;
114 QAction* resetPasswordAction_;
115 QAction* historyAction_;
116 QAction* sessionsAction_;
117
118 std::unique_ptr<ClientAccountModel> accountModel_;
119 QSortFilterProxyModel* proxyModel_;
120 ClientManager* clientManager_;
121 QString username_;
122};
123
124}
125
126#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:42
QString normalRefreshTooltip() const override
Get the normal (non-stale) tooltip text for the refresh action.
Definition AccountMdiWindow.hpp:92
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:109
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