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.api/domain/change_reason.hpp"
31
32namespace ores::qt {
33
50class ChangeReasonDialog final : public QDialog {
51 Q_OBJECT
52
53public:
57 enum class OperationType {
58 Create,
59 Amend,
60 Delete
61 };
62
74 explicit ChangeReasonDialog(
75 const std::vector<dq::domain::change_reason>& reasons,
76 OperationType operation,
77 bool hasFieldChanges,
78 QWidget* parent = nullptr);
79
80 ~ChangeReasonDialog() override = default;
81
87 std::string selectedReasonCode() const;
88
94 std::string commentary() const;
95
96private slots:
97 void onReasonChanged(int index);
98 void onCommentaryChanged();
99 void validateAndAccept();
100
101private:
102 void setupUi();
103 void updateValidation();
104
105 std::vector<dq::domain::change_reason> reasons_;
106 OperationType operation_;
107 bool hasFieldChanges_;
108
109 QComboBox* reasonCombo_;
110 QLabel* descriptionLabel_;
111 QLabel* commentaryLabel_;
112 QTextEdit* commentaryEdit_;
113 QLabel* requiredLabel_;
114 QDialogButtonBox* buttonBox_;
115 QPushButton* saveButton_;
116
117 bool commentary_required_{false};
118};
119
120}
121
122#endif
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
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:250
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:258