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