ORE Studio 0.0.4
Loading...
Searching...
No Matches
ChangeReasonDialog.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_DIALOG_HPP
21#define ORES_QT_CHANGE_REASON_DIALOG_HPP
22
23#include <QDialog>
24#include <QComboBox>
25#include <QTextEdit>
26#include <QLabel>
27#include <QPushButton>
28#include <QDialogButtonBox>
29#include <vector>
30#include "ores.dq/domain/change_reason.hpp"
31
32namespace ores::qt {
33
50class ChangeReasonDialog final : public QDialog {
51 Q_OBJECT
52
53public:
57 enum class OperationType {
58 Amend,
59 Delete
60 };
61
72 explicit ChangeReasonDialog(
73 const std::vector<dq::domain::change_reason>& reasons,
74 OperationType operation,
75 bool hasFieldChanges,
76 QWidget* parent = nullptr);
77
78 ~ChangeReasonDialog() override = default;
79
85 std::string selectedReasonCode() const;
86
92 std::string commentary() const;
93
94private slots:
95 void onReasonChanged(int index);
96 void onCommentaryChanged();
97 void validateAndAccept();
98
99private:
100 void setupUi();
101 void updateValidation();
102
103 std::vector<dq::domain::change_reason> reasons_;
104 OperationType operation_;
105 bool hasFieldChanges_;
106
107 QComboBox* reasonCombo_;
108 QLabel* descriptionLabel_;
109 QLabel* commentaryLabel_;
110 QTextEdit* commentaryEdit_;
111 QLabel* requiredLabel_;
112 QDialogButtonBox* buttonBox_;
113 QPushButton* saveButton_;
114
115 bool commentary_required_{false};
116};
117
118}
119
120#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:35
Dialog for selecting a change reason when saving/deleting entities.
Definition ChangeReasonDialog.hpp:50
std::string selectedReasonCode() const
Get the selected reason code.
Definition ChangeReasonDialog.cpp:237
OperationType
Type of operation requiring a change reason.
Definition ChangeReasonDialog.hpp:57
@ Amend
Updating an existing entity.
std::string commentary() const
Get the commentary entered by the user.
Definition ChangeReasonDialog.cpp:245