ORE Studio 0.0.4
Loading...
Searching...
No Matches
ChangeReasonCategoryHistoryDialog.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_CHANGE_REASON_CATEGORY_HISTORY_DIALOG_HPP
21#define ORES_QT_CHANGE_REASON_CATEGORY_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.dq/domain/change_reason_category.hpp"
32#include "ores.logging/make_logger.hpp"
33#include "ui_ChangeReasonCategoryHistoryDialog.h"
34
35namespace Ui {
36class ChangeReasonCategoryHistoryDialog;
37}
38
39namespace ores::qt {
40
44class ChangeReasonCategoryHistoryDialog : public QWidget {
45 Q_OBJECT
46
47private:
48 inline static std::string_view logger_name =
49 "ores.qt.change_reason_category_history_dialog";
50
51 [[nodiscard]] static auto& lg() {
52 using namespace ores::logging;
53 static auto instance = make_logger(logger_name);
54 return instance;
55 }
56
57 const QIcon& getHistoryIcon() const;
58
59public:
61 ClientManager* clientManager,
62 QWidget* parent = nullptr);
64
65 void loadHistory();
66
67 QSize sizeHint() const override;
68
75 void markAsStale();
76
80 [[nodiscard]] QString code() const { return code_; }
81
82signals:
83 void statusChanged(const QString& message);
84 void errorOccurred(const QString& error_message);
85
92 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(
120 const dq::domain::change_reason_category& previous);
121
122 void setupToolbar();
123 void updateButtonStates();
124 int selectedVersionIndex() const;
125
126 std::unique_ptr<Ui::ChangeReasonCategoryHistoryDialog> ui_;
127 ClientManager* clientManager_;
128 QString code_;
129 std::vector<dq::domain::change_reason_category> versions_;
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
Groups change reasons into logical categories.
Definition change_reason_category.hpp:45
Widget for displaying change reason category version history.
Definition ChangeReasonCategoryHistoryDialog.hpp:44
void openVersionRequested(const dq::domain::change_reason_category &category, 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 ChangeReasonCategoryHistoryDialog.cpp:446
void revertVersionRequested(const dq::domain::change_reason_category &category)
Emitted when user requests to revert to a selected version.
QString code() const
Returns the code of the category.
Definition ChangeReasonCategoryHistoryDialog.hpp:80
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90