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
63 QSize sizeHint() const override;
64
65signals:
66 void statusChanged(const QString& message);
67 void errorOccurred(const QString& error_message);
68 void selectionChanged(int selection_count);
69 void addNewRequested();
70 void showAccountDetails(const AccountWithLoginInfo& accountWithLoginInfo);
71 void showAccountHistory(const QString& username);
72 void showSessionHistory(const boost::uuids::uuid& accountId, const QString& username);
73 void accountDeleted(const boost::uuids::uuid& account_id);
74
75public slots:
76 void reload() override;
77 void addNew();
78 void editSelected();
79 void deleteSelected();
80 void lockSelected();
81 void unlockSelected();
82 void resetPasswordSelected();
83 void viewHistorySelected();
84 void viewSessionsSelected();
85
86private slots:
87 void onDataLoaded();
88 void onLoadError(const QString& error_message, const QString& details = {});
89 void onRowDoubleClicked(const QModelIndex& index);
90 void onSelectionChanged();
91 void onConnectionStateChanged();
92
93protected:
94 QString normalRefreshTooltip() const override {
95 return tr("Refresh accounts");
96 }
97
98private:
99 void updateActionStates();
100 void setupReloadAction();
101
102private:
103 QVBoxLayout* verticalLayout_;
104 QTableView* accountTableView_;
105 QToolBar* toolBar_;
106 PaginationWidget* pagination_widget_;
107
108 // Reload action with stale indicator
109 QAction* reloadAction_;
110
111 QAction* addAction_;
112 QAction* editAction_;
113 QAction* deleteAction_;
114 QAction* lockAction_;
115 QAction* unlockAction_;
116 QAction* resetPasswordAction_;
117 QAction* historyAction_;
118 QAction* sessionsAction_;
119
120 std::unique_ptr<ClientAccountModel> accountModel_;
121 QSortFilterProxyModel* proxyModel_;
122 ClientManager* clientManager_;
123 QString username_;
124};
125
126}
127
128#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
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:94
Composite structure combining account with its login status.
Definition ClientAccountModel.hpp:57
Model for displaying accounts fetched from the server via client.
Definition ClientAccountModel.hpp:68
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Base class for entity list MDI windows providing stale indicator support.
Definition EntityListMdiWindow.hpp:56
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:39