ORE Studio 0.0.4
Loading...
Searching...
No Matches
ChangeReasonCategoryDetailDialog.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_DETAIL_DIALOG_HPP
21#define ORES_QT_CHANGE_REASON_CATEGORY_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_category.hpp"
30
31namespace Ui {
32class ChangeReasonCategoryDetailDialog;
33}
34
35namespace ores::qt {
36
44 Q_OBJECT
45
46private:
47 inline static std::string_view logger_name =
48 "ores.qt.change_reason_category_detail_dialog";
49
50 [[nodiscard]] static auto& lg() {
51 using namespace ores::logging;
52 static auto instance = make_logger(logger_name);
53 return instance;
54 }
55
56public:
57 explicit ChangeReasonCategoryDetailDialog(QWidget* parent = nullptr);
59
60 void setClientManager(ClientManager* clientManager);
61 void setUsername(const std::string& username);
62
63 void setCategory(const dq::domain::change_reason_category& category);
64 dq::domain::change_reason_category getCategory() const;
65 void setCreateMode(bool createMode);
66 void setReadOnly(bool readOnly, int versionNumber = 0);
67 void setHistory(const std::vector<dq::domain::change_reason_category>& history,
68 int versionNumber);
69 void clearDialog();
70 void save();
71
72 QString categoryCode() const;
73 bool isDirty() const { return isDirty_; }
74 bool isReadOnly() const { return isReadOnly_; }
75
76signals:
77 void isDirtyChanged(bool dirty);
78 void categorySaved(const QString& code);
79 void categoryDeleted(const QString& code);
80
81private slots:
82 void onSaveClicked();
83 void onDeleteClicked();
84 void onFieldChanged();
85
86 // Version navigation slots
87 void onFirstVersionClicked();
88 void onPrevVersionClicked();
89 void onNextVersionClicked();
90 void onLastVersionClicked();
91
92private:
93 void updateSaveButtonState();
94 void closeParentWindow();
95 void displayCurrentVersion();
96 void updateVersionNavButtonStates();
97 void showVersionNavActions(bool visible);
98
99private:
100 Ui::ChangeReasonCategoryDetailDialog* ui_;
101 QToolBar* toolBar_;
102 QAction* saveAction_;
103 QAction* deleteAction_;
104 QAction* revertAction_;
105
106 dq::domain::change_reason_category currentCategory_;
107 bool isDirty_;
108 bool isAddMode_;
109 bool isReadOnly_;
110 std::string modifiedByUsername_;
111 ClientManager* clientManager_;
112
113 // Version navigation members
114 std::vector<dq::domain::change_reason_category> history_;
115 int currentHistoryIndex_;
116 QAction* firstVersionAction_;
117 QAction* prevVersionAction_;
118 QAction* nextVersionAction_;
119 QAction* lastVersionAction_;
120};
121
122}
123
124#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
Dialog widget for creating and editing change reason categories.
Definition ChangeReasonCategoryDetailDialog.hpp:43
Manages the lifecycle of the network client and IO context.
Definition ClientManager.hpp:90
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:54