ORE Studio 0.0.4
Loading...
Searching...
No Matches
ChangeReasonDetailDialog.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_DETAIL_DIALOG_HPP
21#define ORES_QT_CHANGE_REASON_DETAIL_DIALOG_HPP
22
23#include <vector>
24#include <QAction>
25#include <QToolBar>
26#include "ores.qt/ClientManager.hpp"
27#include "ores.qt/DetailDialogBase.hpp"
28#include "ores.logging/make_logger.hpp"
29#include "ores.dq/domain/change_reason.hpp"
30#include "ores.dq/domain/change_reason_category.hpp"
31
32namespace Ui {
33class ChangeReasonDetailDialog;
34}
35
36namespace ores::qt {
37
45 Q_OBJECT
46
47private:
48 inline static std::string_view logger_name =
49 "ores.qt.change_reason_detail_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
57public:
58 explicit ChangeReasonDetailDialog(QWidget* parent = nullptr);
60
61 void setClientManager(ClientManager* clientManager);
62 void setUsername(const std::string& username);
63
64 void setChangeReason(const dq::domain::change_reason& reason);
65 dq::domain::change_reason getChangeReason() const;
66 void setCreateMode(bool createMode);
67 void setReadOnly(bool readOnly, int versionNumber = 0);
68 void setHistory(const std::vector<dq::domain::change_reason>& history,
69 int versionNumber);
70 void clearDialog();
71 void save();
72
73 void setCategories(const std::vector<dq::domain::change_reason_category>& categories);
74
75 QString changeReasonCode() const;
76 bool isDirty() const { return isDirty_; }
77 bool isReadOnly() const { return isReadOnly_; }
78
79signals:
80 void isDirtyChanged(bool dirty);
81 void changeReasonSaved(const QString& code);
82 void changeReasonDeleted(const QString& code);
83
84private slots:
85 void onSaveClicked();
86 void onDeleteClicked();
87 void onFieldChanged();
88
89 // Version navigation slots
90 void onFirstVersionClicked();
91 void onPrevVersionClicked();
92 void onNextVersionClicked();
93 void onLastVersionClicked();
94
95private:
96 void updateSaveButtonState();
97 void closeParentWindow();
98 void displayCurrentVersion();
99 void updateVersionNavButtonStates();
100 void showVersionNavActions(bool visible);
101 void populateCategoryComboBox();
102
103private:
104 Ui::ChangeReasonDetailDialog* ui_;
105 QToolBar* toolBar_;
106 QAction* saveAction_;
107 QAction* deleteAction_;
108 QAction* revertAction_;
109
110 dq::domain::change_reason currentReason_;
111 std::vector<dq::domain::change_reason_category> categories_;
112 bool isDirty_;
113 bool isAddMode_;
114 bool isReadOnly_;
115 std::string modifiedByUsername_;
116 ClientManager* clientManager_;
117
118 // Version navigation members
119 std::vector<dq::domain::change_reason> history_;
120 int currentHistoryIndex_;
121 QAction* firstVersionAction_;
122 QAction* prevVersionAction_;
123 QAction* nextVersionAction_;
124 QAction* lastVersionAction_;
125};
126
127}
128
129#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Defines a specific reason for record changes.
Definition change_reason.hpp:47
Dialog widget for creating and editing change reasons.
Definition ChangeReasonDetailDialog.hpp:44
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:54