ORE Studio 0.0.4
Loading...
Searching...
No Matches
AccountHistoryDialog.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_HISTORY_DIALOG_HPP
21#define ORES_QT_ACCOUNT_HISTORY_DIALOG_HPP
22
23#include <memory>
24#include <QPair>
25#include <QWidget>
26#include <QString>
27#include <QVector>
28#include <QToolBar>
29#include <QAction>
30#include "ores.qt/ClientManager.hpp"
31#include "ores.iam/domain/account_version.hpp"
32#include "ores.iam/domain/account_version_history.hpp"
33#include "ores.logging/make_logger.hpp"
34#include "ui_AccountHistoryDialog.h"
35
36namespace Ui {
37class AccountHistoryDialog;
38}
39
40namespace ores::qt {
41
45class AccountHistoryDialog : public QWidget {
46 Q_OBJECT
47
48private:
49 inline static std::string_view logger_name =
50 "ores.qt.account_history_dialog";
51
52 [[nodiscard]] static auto& lg() {
53 using namespace ores::logging;
54 static auto instance = make_logger(logger_name);
55 return instance;
56 }
57
58 const QIcon& getHistoryIcon() const;
59
60public:
61 explicit AccountHistoryDialog(QString username,
62 ClientManager* clientManager,
63 QWidget* parent = nullptr);
64 ~AccountHistoryDialog() override;
65
66 void loadHistory();
67
68 QSize sizeHint() const override;
69
76 void markAsStale();
77
81 [[nodiscard]] QString username() const { return username_; }
82
83signals:
84 void statusChanged(const QString& message);
85 void errorOccurred(const QString& error_message);
86
92 void openVersionRequested(const iam::domain::account& account, int versionNumber);
93
99
100private slots:
101 void onVersionSelected(int index);
102 void onHistoryLoaded();
103 void onHistoryLoadError(const QString& error);
104 void onOpenClicked();
105 void onRevertClicked();
106 void onReloadClicked();
107
108private:
109 void displayChangesTab(int version_index);
110 void displayFullDetailsTab(int version_index);
111
117 using DiffResult = QVector<QPair<QString, QPair<QString, QString>>>;
118 DiffResult calculateDiff(
119 const iam::domain::account_version& current,
120 const iam::domain::account_version& previous);
121
122 void setupToolbar();
123 void updateButtonStates();
124 int selectedVersionIndex() const;
125
126 std::unique_ptr<Ui::AccountHistoryDialog> ui_;
127 ClientManager* clientManager_;
128 QString username_;
130
131 QToolBar* toolBar_;
132 QAction* reloadAction_;
133 QAction* openAction_;
134 QAction* revertAction_;
135};
136
137}
138
139#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Represents an account for an entity in the system.
Definition account.hpp:32
Represents a specific version of an account with metadata.
Definition account_version.hpp:32
Contains the full version history for an account.
Definition account_version_history.hpp:32
Widget for displaying account version history.
Definition AccountHistoryDialog.hpp:45
QString username() const
Returns the username of the account.
Definition AccountHistoryDialog.hpp:81
void openVersionRequested(const iam::domain::account &account, int versionNumber)
Emitted when user requests to open a version in read-only mode.
void markAsStale()
Mark the history data as stale and reload.
Definition AccountHistoryDialog.cpp:455
void revertVersionRequested(const iam::domain::account &account)
Emitted when user requests to revert to a selected version.
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90