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 <QWidget>
24#include <QTableView>
25#include <QVBoxLayout>
26#include <QToolBar>
27#include <QIcon>
28#include <QTimer>
29#include <QSortFilterProxyModel>
30#include <memory>
31#include "ores.qt/ClientManager.hpp"
32#include "ores.utility/log/make_logger.hpp"
33#include "ores.qt/ClientAccountModel.hpp"
34#include "ores.qt/PaginationWidget.hpp"
35
36namespace ores::qt {
37
44class AccountMdiWindow : public QWidget {
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::utility::log;
53 static auto instance = make_logger(logger_name);
54 return instance;
55 }
56
57public:
58 explicit AccountMdiWindow(ClientManager* clientManager,
59 const QString& username,
60 QWidget* parent = nullptr);
61 ~AccountMdiWindow() override;
62
63 ClientAccountModel* accountModel() const { return accountModel_.get(); }
64
65 QSize sizeHint() const override;
66
67signals:
68 void statusChanged(const QString& message);
69 void errorOccurred(const QString& error_message);
70 void selectionChanged(int selection_count);
71 void addNewRequested();
72 void showAccountDetails(const AccountWithLoginInfo& accountWithLoginInfo);
73 void showAccountHistory(const QString& username);
74 void accountDeleted(const boost::uuids::uuid& account_id);
75
76public slots:
77 void reload();
78 void addNew();
79 void editSelected();
80 void deleteSelected();
81 void lockSelected();
82 void unlockSelected();
83 void resetPasswordSelected();
84 void viewHistorySelected();
85
93 void markAsStale();
94
100 void clearStaleIndicator();
101
102private slots:
103 void onDataLoaded();
104 void onLoadError(const QString& error_message);
105 void onRowDoubleClicked(const QModelIndex& index);
106 void onSelectionChanged();
107 void onConnectionStateChanged();
108
109private:
110 void updateActionStates();
111 void setupReloadAction();
112 void startPulseAnimation();
113 void stopPulseAnimation();
114
115private:
116 QVBoxLayout* verticalLayout_;
117 QTableView* accountTableView_;
118 QToolBar* toolBar_;
119 PaginationWidget* pagination_widget_;
120
121 // Reload action with stale indicator
122 QAction* reloadAction_;
123 QIcon normalReloadIcon_;
124 QIcon staleReloadIcon_;
125 QTimer* pulseTimer_;
126 bool pulseState_{false};
127 int pulseCount_{0};
128
129 QAction* addAction_;
130 QAction* editAction_;
131 QAction* deleteAction_;
132 QAction* lockAction_;
133 QAction* unlockAction_;
134 QAction* resetPasswordAction_;
135 QAction* historyAction_;
136
137 std::unique_ptr<ClientAccountModel> accountModel_;
138 QSortFilterProxyModel* proxyModel_;
139 ClientManager* clientManager_;
140 QString username_;
141 bool isStale_{false};
142};
143
144}
145
146#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
MDI window for displaying and managing user accounts.
Definition AccountMdiWindow.hpp:44
void clearStaleIndicator()
Clear the stale indicator.
Definition AccountMdiWindow.cpp:1077
void markAsStale()
Mark the data as stale (changed on server).
Definition AccountMdiWindow.cpp:1068
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:56
Widget providing pagination controls for data tables.
Definition PaginationWidget.hpp:38