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 <QTabWidget>
26#include <QToolBar>
27#include "ores.qt/ClientManager.hpp"
28#include "ores.qt/DetailDialogBase.hpp"
29#include "ores.qt/ProvenanceWidget.hpp"
30#include "ores.logging/make_logger.hpp"
31#include "ores.dq.api/domain/change_reason.hpp"
32#include "ores.dq.api/domain/change_reason_category.hpp"
33
34namespace Ui {
35class ChangeReasonDetailDialog;
36}
37
38namespace ores::qt {
39
47 Q_OBJECT
48
49private:
50 inline static std::string_view logger_name =
51 "ores.qt.change_reason_detail_dialog";
52
53 [[nodiscard]] static auto& lg() {
54 using namespace ores::logging;
55 static auto instance = make_logger(logger_name);
56 return instance;
57 }
58
59public:
60 explicit ChangeReasonDetailDialog(QWidget* parent = nullptr);
62
63 void setClientManager(ClientManager* clientManager);
64 void setUsername(const std::string& username);
65
66 void setChangeReason(const dq::domain::change_reason& reason);
67 dq::domain::change_reason getChangeReason() const;
68 void setCreateMode(bool createMode);
69 void setReadOnly(bool readOnly, int versionNumber = 0);
70 void setHistory(const std::vector<dq::domain::change_reason>& history,
71 int versionNumber);
72 void clearDialog();
73 void save();
74
75 void setCategories(const std::vector<dq::domain::change_reason_category>& categories);
76
77 QString changeReasonCode() const;
78 bool isDirty() const { return isDirty_; }
79 bool isReadOnly() const { return isReadOnly_; }
80
81signals:
82 void isDirtyChanged(bool dirty);
83 void changeReasonSaved(const QString& code);
84 void changeReasonDeleted(const QString& code);
85
86protected:
87 QTabWidget* tabWidget() const override;
88 QWidget* provenanceTab() const override;
89 ProvenanceWidget* provenanceWidget() const override;
90 bool hasUnsavedChanges() const override { return isDirty_; }
91
92private slots:
93 void onSaveClicked();
94 void onDeleteClicked();
95 void onFieldChanged();
96
97 // Version navigation slots
98 void onFirstVersionClicked();
99 void onPrevVersionClicked();
100 void onNextVersionClicked();
101 void onLastVersionClicked();
102
103private:
104 void updateSaveButtonState();
105 void closeParentWindow();
106 void displayCurrentVersion();
107 void updateVersionNavButtonStates();
108 void showVersionNavActions(bool visible);
109 void populateCategoryComboBox();
110
111private:
112 Ui::ChangeReasonDetailDialog* ui_;
113 QToolBar* toolBar_;
114 QAction* revertAction_;
115
116 dq::domain::change_reason currentReason_;
117 std::vector<dq::domain::change_reason_category> categories_;
118 bool isDirty_;
119 bool isAddMode_;
120 bool isReadOnly_;
121 std::string modifiedByUsername_;
122 ClientManager* clientManager_;
123
124 // Version navigation members
125 std::vector<dq::domain::change_reason> history_;
126 int currentHistoryIndex_;
127 QAction* firstVersionAction_;
128 QAction* prevVersionAction_;
129 QAction* nextVersionAction_;
130 QAction* lastVersionAction_;
131};
132
133}
134
135#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Qt-based graphical user interface for ORE Studio.
Definition AboutDialog.hpp:29
Defines a specific reason for record changes.
Definition change_reason.hpp:48
Dialog widget for creating and editing change reasons.
Definition ChangeReasonDetailDialog.hpp:46
ProvenanceWidget * provenanceWidget() const override
Returns the promoted ProvenanceWidget (named "provenanceWidget" in .ui).
Definition ChangeReasonDetailDialog.cpp:153
bool hasUnsavedChanges() const override
Definition ChangeReasonDetailDialog.hpp:90
QTabWidget * tabWidget() const override
Returns the dialog's QTabWidget (named "tabWidget" in .ui).
Definition ChangeReasonDetailDialog.cpp:151
QWidget * provenanceTab() const override
Returns the Provenance tab widget (named "provenanceTab" in .ui).
Definition ChangeReasonDetailDialog.cpp:152
Manages the lifecycle of the NATS client and login state.
Definition ClientManager.hpp:109
Base class for all detail dialogs.
Definition DetailDialogBase.hpp:74
Widget displaying the 6 standard record provenance fields.
Definition ProvenanceWidget.hpp:39